---
title: "Security model"
description: "What Greenware's agents can and can't touch: stage permissions in clayx, the Claude Code tool rules, protected paths, the record-content rule for web-enabled stages, holdouts, signed records and the gates."
sidebar:
  icon: shield
---

Agents propose; the engine and you decide. Four layers enforce that, and none of them is an LLM judgment:

1. **Claude Code tool rules** decide which tools and files a stage agent can use.
2. **clayx** decides which Clay commands a stage can run, in which workspace, within which budget.
3. **Signed engine records** stop an agent from forging state, approvals or the reviewed snapshot.
4. **Gates** bind your approval to a hash of exactly what you reviewed.

## Stage agents and their tools

Every stage agent runs Claude Code with `--permission-mode dontAsk`: a tool not on its allow list is denied, never asked about.

**Allowed:** `Read`, `Write`, `Edit`, `Glob`, `Grep`, and `Bash(gw clay …)`. That last one is the only way to reach Clay.

**Always denied:** raw `clay`, `curl`, `WebFetch`, and slash commands and skills (`--disable-slash-commands`).

**Protected paths** a stage can neither read nor edit:

| Path | Why |
| --- | --- |
| `clients/**` | Clay logins, holdouts, ledgers, suppression lists. Stages get a filtered copy of the client context in `.greenware/context/` inside their play folder, never holdouts or logins |
| `.greenware/**` (factory root) | The engine's signing secret, the per-stage settings files that hold these rules, the `gw` shim |
| `factory.yaml` | So no agent can raise its own budget or widen its own tools |

**Engine-owned play files** a stage can read but not edit: `state.json`, `approvals/**`, `snapshot.json`, `setup.json`, `events.jsonl`, `published.json` and `feedback/**` (your words: gate comments, rulings and acceptances that later stages obey).

Stages may also not point a Clay command at a file outside their play folder (`--input`, `--file` and similar upload a path to Clay): clayx refuses it as `path_outside_play`.

Under Herdr the same rules go in a settings file under `.greenware/stages/`, which stages are denied, so no agent can loosen its own rules.

## clayx: Clay permissions per stage

Every Clay call, from an agent or from you via `gw clay`, goes through clayx. It classifies the command against Clay's real command tree (`src/clay/commands.json`, generated from `clay --help`) and fails closed: anything it doesn't recognize is `gated`.

| Class | Examples | Who may run it |
| --- | --- | --- |
| read | `… list`, `… get`, `graph validate`, `estimate-credits`, `whoami` | every stage, people |
| segment | `audiences create`, `audiences update` (saved filters: free, change no records) | Research, Spec, Plan, Build, Verify, people |
| schema | `audiences fields create` | Gate A (the engine applying `prereqs.json`), people |
| build | `workflows create/update`, `nodes …`, `triggers …`, `groups …` (draft edits only) | Build, Verify |
| spend | `runs test`, `nodes test`, `test-data run`, `triggers csv` (cost credits or execute steps) | Verify |
| gated | `workflows publish`, `workflows delete`, `sequences`, `webhooks`, `schedules`, `signals` changes, `audiences archive`, … | Publish only, for publishing the Gate B-approved draft |
| never | `login`, `logout`, `update`, `feedback`, `api-keys`, `credits top-up`, `workspaces switch` | nobody, from the factory |

So the planner can't build, the builder can't spend or publish, and nothing can launch sequences. Denied calls exit `77` with a JSON error naming the rule.

### Guards on top of the class

- **`[GREENWARE]` names.** Audiences and fields the factory creates must be named `[GREENWARE] …`. Only audiences the factory created (recorded in `resources.json`) can be updated, a stage may update only its own play's audiences, and an update can't drop the prefix.
- **One client, one login, one workspace.** Each client has its own `CLAY_CONFIG_HOME`. Every non-read call checks that the login still resolves to the pinned `clayWorkspaceId`; a mismatch exits `78` (`workspace_mismatch`), and a client with no pin can only read. `workspaces switch` is never allowed from the factory, so an agent can't move a login.
- **Budget.** Spend commands are metered per run. Once a play's spend reaches `maxCreditsPerPlay`, spend calls exit `79` (`budget_exhausted`) until a person raises the cap.
- **Approvals.** When Clay asks for approval before a test run, Verify may approve it only for a pending test run of its own play's unpublished draft (from the engine-signed snapshot). Publish may approve only publishing the Gate B-approved draft, and only with sequences off. `--always-allow` standing rules are never allowed. Anything else a person decides in Clay.
- **Hidden subcommands.** A bare `--` and `publish-as-function` anywhere in the arguments are treated as gated, so they can't hide a command behind a shorter prefix.
- **Ledger.** Every call, allowed or denied, is written to `clients/<id>/ledger.jsonl` and the play's `events.jsonl`.

## Web tools and record contents

Pages read from the web are untrusted. A prompt-injected page must never be able to send client data out or change Clay. So:

- MCP tools (`agents.mcpAllow`, default Firecrawl) run only in stages listed in `agents.mcpStages` (default Research).
- A stage that can build, spend or publish never gets them, even if you list it.
- A stage that has them **can't read record contents** from Clay (people, companies, rows, run inputs and outputs). clayx denies those reads as `record_read_denied`; the stage sizes lists with counts (`audiences records search-count`, `search-ids`) instead, and record reads stay with Build and Verify.
- Onboarding research has web access but no shell and no Clay access; the engine reads the workspace for it.

Agents load your Claude Code MCP servers, but in `dontAsk` mode only allowed tools run. Leave connectors that send or write (mail, LinkedIn, CRM) out of `mcpAllow`.

## Holdouts

Holdouts (`clients/<id>/gold/`) are labeled real records Verify scores the build against. Only Verify can read them, so the builder can't fit the workflow to the test. Exports drop email and phone fields unless you pass `--keep-contact`. The factory `.gitignore` keeps `gold/` out of git: holdouts are often personal data.

## Signed records

Stage agents can write files in their own play folder, so the engine signs what it owns (`state.json`, approvals, `snapshot.json`, `setup.json`) with a per-factory secret in `.greenware/secret` (mode `0600`, denied to agents). A record without a valid signature was written by something other than the engine and is refused. Publish, for example, ignores an unsigned or edited `snapshot.json`.

## Gates

- **Gate A** is bound to a hash of `spec.md`, the contract's definitions, `plan.md`, `workflow.mmd`, `prereqs.json` and `golive.md`. Gate A's prerequisites are created by the engine, not an agent, and only after your approval.
- **Gate B** is bound to `verification.md`, `audit.md` and `snapshot.json`. Publish runs only with a Gate B approval of the current artifacts, only if the workflow's latest snapshot is still the one you approved, and always with `--no-launch-sequences`.
- Changing a reviewed file afterwards voids the approval. Approvals record who decided and when, and only a person makes them: the Claude Code gates skill and the maestro run `gw approve` only on your explicit go-ahead, and Claude Code asks you to confirm.

## What a person still owns

- Launching sequences, deleting workflows, publishing functions, webhooks and connection changes: do these in Clay.
- Clay sign-in (`gw client login`), and confirming a workspace whose name doesn't match the client.
- Saving suppression lists (a person confirms each one).
- Raising `maxCreditsPerPlay` and changing which MCP tools agents get.

## Your factory folder

The factory holds client context and decisions even with the ignores. Keep it in a private repository, and don't share it with anyone who shouldn't see client data. See [Your factory in git](/guides/factory-in-git).
