# Groot v2 architecture > Status: **normative design for the v2 refactor** (branch `refactor/groot-v2-core`). The v1 engine design in [architecture.md](./architecture.md) remains authoritative for the scaffold pipeline that v2 wraps. Research behind these decisions: [v2-research.md](./v2-research.md). Progress: [v2-execution.md](./v2-execution.md). Product line: **Build it. Grow it. Prove it works.** Groot v2 is a Bun-first lifecycle CLI for developers and their coding agents: create or adopt a project, apply coherent changes through previewable plans, keep agent context current, delegate bounded work to installed agents, and attach executable evidence to every claim. ## Concepts | Concept | Contract | Meaning | | --- | --- | --- | | Project | `schemas/v2/project.schema.json` | **Observed** state from read-only discovery: units (apps/packages/services), topology, toolchains, agent files, git state. Every inferred value is a fact with source, method, confidence, observation time, and the source fingerprint. | | Blueprint | `groot.json` v2 (`schemas/v2/blueprint.schema.json`) | **Desired** state: apps, capabilities, decisions (with authority), environment contracts, verification obligations, context settings, action policy. A strict superset of the v1 manifest. | | Capability | `capability`, `recipe` | A product or operational result (auth, data) and the certified recipes that supply it. Frameworks are surfaces; provider services are external effects; developer agents are never product capabilities. | | Operation | `plan`, `journal-record`, `operation` | A concrete plan (actions, preconditions, ownership, env, verification, recovery) executed with an append-only journal. | | Evidence | `evidence`, `verification` | One check outcome — pass/fail/skipped/blocked — tied to revision, environment, timing, artifacts, and limitations. | Observed facts never silently overwrite desired state. Where they disagree, discovery reports a contradiction; reconciliation is an explicit plan. ## Module boundaries (`packages/cli/src`) ``` index.ts thin citty entry (command registry) commands/ presentation: flags, prompts, human rendering — v1 init/add/doctor + v2 surfaces cli/ shared v2 runner: envelope on stdout, events on stderr, signals, exit codes engine/, adapters/ the v1 scaffold engine — unchanged; wrapped by v2 operations core/contracts/ zod contracts (single source: validation, TS types, schemas/v2/*.json) core/fs/ project-boundary paths, hashing, atomic writes, writer lock core/transforms/ structured edits: JSON pointer ops, managed regions, source anchors, lines, env core/discovery/ static inspection → ProjectObservation (never runs project scripts or code; see the git caveat below) core/blueprint/ groot.json read/validate/write, v1→v2 migration core/capabilities/ recipe registry + compatibility solver core/recipes/ certified recipes (data, auth) and v1 scaffold wrappers core/planner/ PlanBuilder + planners (init, adopt, migrate, add-capability, context-sync) core/executor/ apply/resume/rollback with journal checkpoints, idempotency, cancellation core/verify/ checkers + evidence store (structural/build/runtime/product-flow) core/context/ task context, managed AGENTS.md/CLAUDE.md regions, skills core/runners/ installed-agent adapters (Claude Code, Codex) + capability discovery core/tasks/ task store, dependency DAG, worktrees, review, integration core/mcp/ MCP stdio server: typed tools over the same core functions ``` Every surface (CLI, MCP, task runners) calls the same core functions with a `CoreContext` (cwd, AbortSignal, event sink). Core code never prints or prompts; it returns typed results or throws `GrootV2Error` with a stable `GROOT_E_*` id. Policy is enforced in the executor, so no surface can bypass it. ## State | File | Committed | Purpose | | --- | --- | --- | | `groot.json` | yes | Blueprint (v2) — or v1 manifest in un-migrated workspaces | | `groot.lock.json` | yes | Exact generator versions + integrity, recipe versions + exact dependencies, Groot-owned artifacts with content hashes | | `.groot/` | no (self-ignoring `.gitignore` inside) | Local state. Must be a real directory inside the project: a symlinked `.groot`, `.groot/.gitignore`, or state subdirectory is refused with `GROOT_E_PATH_OUTSIDE_PROJECT`, and ids are validated before they become paths | | `.groot/plans/.json` | no | Saved plans (0600) with known secret values concealed; `.secrets.json` beside one that quotes any (see the secrets paragraph under [Capabilities and recipes](#capabilities-and-recipes)) | | `.groot/operations//` | no | Owner-only (0700): `plan.json` (0600, concealed like saved plans, with `plan.secrets.json` beside it when needed), `journal.jsonl`, `state.json`, `backups/`, `logs/` (0600, redacted). Backups are file copies (0600; the original modes are recorded) or copies of a directory tree, plus per-step records `backups/.{secrets,modes,dirs,generator}.json` (0600): the placeholders of concealed secrets, the original file modes, the directories absent at intent, and a generator's promotion record. A symlink standing in for any of these is refused | | `.groot/evidence//` · `tasks//` · `reviews/` · `worktrees/` | no | Evidence records with redacted artifacts; task documents, prompts, attempt logs, and `runner.json` (the live run and its runner's process group); reviews; task and integration worktrees | | `.groot/ref-moves.jsonl` | no | Target-branch fast-forwards made by `task integrate`, each journaled before it happens, so the repository guard of a task running beside it can tell Groot's own move from anyone else's | | `.groot/lock.json` | no | The writer lock | **Why files, not SQLite:** per-project volumes are small; recovery is append + replay; humans and agents can inspect everything; no platform SQLite variance (macOS uses Apple's system SQLite). Revisit if task queries outgrow directory scans. ## Execution 1. **Plan** — planners compute exact previews: every file write/edit carries the expected current hash and, when the content it applies to is known at planning time (on disk, or the exact result of an earlier write or previewed edit), the resulting content. An edit after a step that changes the file without a preview (`deps.add`, `env.secret`, a deferred or secret-bearing edit, a move, a generator) is deferred (`after: null`) and computed by the executor at apply time. Env edits and edits of non-example dotenv files (any letter case) never carry content — `expect` pins the file hash and the edit's variable names are the preview; the plan contract rejects a `file.edit` that violates this. Generator output is marked unpredictable and runs staged. Plans list dependencies, commands, environment contracts, external effects, required action classes, verification, recovery limits, and assumptions. `fingerprint` = sha256 over intent + actions + preconditions. 2. **Apply** — validate the plan document: the contract plus integrity (the fingerprint and every exact preview match; step ids are unique; a `produced` expectation names an earlier step that produces exactly that path, and no precondition expects one; no action names a path inside `.groot/` or `.git/`, compared the way filesystems and git match names — any letter case, trailing dots and spaces, NTFS stream suffixes, 8.3 short names, code points HFS+ ignores) → `GROOT_E_INVALID_DOCUMENT`. Refuse a different root. Enforce policy: every class the plan declares or its actions imply ⊆ the policy's `allow` plus this run's approvals; the policy is read fail-closed from a v2 `groot.json` (invalid → `GROOT_E_INVALID_DOCUMENT`, unknown version → `GROOT_E_UNSUPPORTED_SCHEMA`), with `DEFAULT_POLICY` only for a project without a v2 blueprint. If a completed operation has the same fingerprint, return `alreadyApplied` with no effects (an unfinished one is a conflict pointing at resume). Re-check preconditions — declared, and implied by the actions: each action's own expectation of a path no earlier step changes, generator destinations fresh, move targets absent (any affected path whose hash changed → `GROOT_E_STALE_PLAN` naming exactly those paths). Toolchain preconditions run only the probes discovery uses (bun is the running runtime; other tools are found on `PATH`, never inside the project, and run from a neutral directory); any other name is a stale finding, never executed. Take the writer lock, repeat the idempotency and freshness checks under it, and journal `operation.started`. 3. **Each step** — right before the step, its paths are checked where they really resolve (a symlink into `.groot/` or `.git/` → `GROOT_E_PATH_OUTSIDE_PROJECT`), and a recursive delete — allowed only for a tree an earlier step of the operation produced — is refused with `GROOT_E_CONFLICT` when that tree holds a `.git` or `.groot` anywhere (tree hashes ignore those names). Then journal `step.intent` (before-hashes, backups of files about to change, directories still absent) → effect → journal `step.done` (after-hashes, created paths) → atomic `state.json`. Staged generators run in a temporary directory; right before promotion, freshness is checked again, and an entry that appeared meanwhile is never overwritten. Promotion runs under a record written before its first rename — each top-level entry with a fingerprint of everything it holds, `.git` and `node_modules` included — and marked complete after its last; a destination that does not exist yet is created by one rename. Abort (SIGINT/SIGTERM/MCP cancel) stops at the next checkpoint; running children are terminated by process group; the operation becomes `interrupted` and resumable (exit 130). 4. **Resume** — under the writer lock, read the journal once; the plan copy must be the plan it started (plan id + fingerprint; otherwise `GROOT_E_INVALID_DOCUMENT`), and a sealed copy (see the secrets paragraph under [Capabilities and recipes](#capabilities-and-recipes)) is never resumed. The steps still to run are held to the policy again, with this run's approvals only (approvals are not journaled). Skip completed steps; reconcile the in-flight step against its postcondition (already applied → mark done; untouched → re-run; changed by someone else → conflict); re-check preconditions for pending steps. Non-idempotent commands are never re-run blindly. Generators settle by their record: a complete record with an unchanged tree → done; a cut-off staged promotion is cleared — and the step re-run — only while every present entry still holds exactly what promotion moved; anything else is the retry/skip decision, which lists what a retry removes. Recovery never removes a `.git` or `.groot`, nested ones included. 5. **Rollback** — reverse order; a file is restored/deleted only if its current hash equals the hash Groot recorded after applying it; any later human edit is a `GROOT_E_ROLLBACK_CONFLICT` naming the files (nothing is overwritten). It is the same conflict, naming the path, when undoing a tree would delete a `.git` or `.groot` inside it (nested ones included; the project root keeps its own), or when a backup quotes a secret whose value changed or is gone (naming the variable). Links are removed, never followed. Directories a step created are removed once empty — including those recorded at intent for in-flight, reconciled, and command steps, and for steps with nothing else to undo — and files an internal handler created are removed when unchanged. Commands and network effects report their real compensation or are listed as irreversible: after a dependency change or install is undone, `package.json`/`bun.lock` are restored from backup and `bun install --no-save` re-syncs `node_modules`. Rollback takes no approvals and that install is not policy-checked; when it fails, the rollback still completes and says to run `bun install`. Writer coordination: `.groot/lock.json` is created together with its holder record (a fully written temp file hard-linked into place; `O_CREAT|O_EXCL` where hard links are unsupported), so a live writer's lock is never observed empty; an unreadable lock counts as held and is recovered under the takeover mutex only once it is older than 10 s; stale locks from dead local processes are taken over; live or remote holders yield `GROOT_E_LOCKED` (exit 8). Read-only commands (inspect, status, context, structural verify) take no lock. Process supervision: every child runs detached in its own process group; timeouts, cancellation, and completion sweep the whole group (SIGTERM → grace → SIGKILL) because Bun's `kill()`/`timeout`/`AbortSignal` reach only the direct child. Captured output is size-capped (whole lines dropped from the head; a lone `\r` also ends a line) and secret-redacted once over the whole capture after exit — never per pipe chunk — and live output callbacks receive redacted complete lines. Evidence records are redacted in full (summary, details, reasons, next steps), not only their artifacts. Git probes run with every `GIT_*` variable removed except `GIT_CEILING_DIRECTORIES`, `core.fsmonitor` and all hooks disabled (`core.hooksPath=/dev/null`), the index never written (`GIT_OPTIONAL_LOCKS=0`, `diff.autoRefreshIndex=false`), and `--no-ext-diff --no-textconv`; only clean/smudge/process filter drivers configured in a repository's own `.git/config` can still run during `git status`/`git diff`, so an untrusted `.git` (for example from an extracted archive) should be cloned with `git clone --no-local` before Groot inspects it. CLI startup: v2 commands load on demand and bootstrap the core (recipes, checkers) only when one runs, so v1 commands and `bun create groot ` never load the v2 core. ## Compatibility path (v1 → v2) | Surface | v2 behavior | | --- | --- | | `init` / `add` / `doctor` flags, exit codes, stdout/stderr routing | Unchanged (contract tests) | | `groot.json` written by `init` | **Deliberate major change:** v2 blueprint, a superset of v1 (`createdWith`, `conventions`, `scaffolds` identical). `init --dry-run --json` emits it. | | `add` on a v1 workspace | Reads and writes v1 (no silent migration) | | `add` on a v2 workspace | Updates `scaffolds` and `apps` together | | `doctor` | Reads v1 and v2; `--json` shape unchanged | | `groot migrate` | Explicit, previewable v1 → v2 plan; unknown/newer versions are rejected | | `schemas/groot.schema.json` | Accepts v1 and v2 (discriminated by `version`); `groot.v1.schema.json` keeps the frozen v1 schema | v2 commands use new exit codes 6 (conflict), 7 (blocked), 8 (locked); the v1 codes keep their meanings. ## Capabilities and recipes A recipe declares requirements, conflicts, targets (unit kinds, frameworks, runtimes, topologies), exact dependency versions, environment contracts, verification contracts, external effects, and recovery. The solver orders requirements first, refuses incompatible combinations at planning time with alternatives, and reports already-satisfied capabilities. Recipes plan only through the PlanBuilder, so every change they make is previewable, owned, journaled, and reversible within stated limits. Environment contracts name each variable's consumer, scope (server/public/build), sensitivity, requirement, and the file the consuming framework actually loads. Secrets are generated locally into gitignored files by a dedicated step; values never enter plans (enforced by the plan contract: an env or non-example dotenv edit with content is invalid), journals, logs, context, or evidence. Variables with client-exposure prefixes (`NEXT_PUBLIC_`, `VITE_`, `PUBLIC_`, `EXPO_PUBLIC_`, …) can never be secrets. Secrets Groot knows — the variables named by this and every earlier operation's `env.secret` steps and secret contracts, and by the blueprint's secret contracts, with values read from their env files and never persisted — are redacted from process output and logs, and concealed wherever Groot stores file content: backups, and the plan documents it keeps (saved plans and operation plan copies, since an exact preview can quote a file a human copied a secret into). Each value of 16 characters or more becomes a placeholder; a sidecar (`.secrets.json` for backups, `plan.secrets.json` / `.secrets.json` for plans) records the variable and env file behind it, and for a plan document the original document's sha256. Revealing reads the values from their env files at that moment and either reproduces the original bytes exactly or fails: a saved plan then is stale, an operation's plan copy is *sealed* — listed, shown, and rolled back, never resumed — and a backup is a rollback conflict naming the variable. Ports: the blueprint records each app's dev port. `groot add` in a v2 workspace allocates the next free port for a new scaffold and applies it through the adapter (dev-script `--port`, or source — Elysia, Hono, and Fastify read `PORT` with the assigned port as the default, which is how verification starts them on an ephemeral port; [architecture.md#port-allocation](./architecture.md#port-allocation)); adopted ports are recorded as observed and collisions among them are reported, never silently changed. Recipes derive coupled URLs from the target app's recorded port (e.g. `BETTER_AUTH_URL`). Verification starts apps on OS-assigned ephemeral ports, so runtime occupancy is checked separately from blueprint collisions. Re-allocating an existing app's port (and rewriting the URLs coupled to it) is not implemented yet. Generator locks: series pins (`create-next-app@16`) resolve to exact versions with Bun's own rule (latest if it satisfies, else the highest stable match) and their registry integrity; generators run as `bunx @`. Inputs fetched at run time (GitHub templates, dist-tags) are recorded as non-hermetic rather than claimed deterministic. ## Verification Profiles: **structural** (fast, offline, no processes), **build** (install/typecheck/build commands), **runtime** (start the app on an ephemeral port, health probe), **product-flow** (drive the declared user flow against real wiring, e.g. sign-up → protected write → unauthorized rejection). Each check yields evidence with `pass`/`fail`/`skipped`/`blocked` and a reason; missing credentials or toolchains are `blocked` with the exact prerequisite (names only — values are never read into evidence). A credential counts as set only when the environment holds a non-empty value or its storage file assigns one Bun loads as non-blank (`NAME=` or `NAME=""` leave it unset), and `structural.env` reads required variables from their storage files the same way; it also fails when a secret's storage file is not ignored by the repository's own `.gitignore` files (`.git/info/exclude` and `core.excludesFile` don't travel with a clone). Reports summarize each profile separately; a run is `interrupted` only when a selected check did not finish, and only failures are rewritten as cancelled. Evidence produced by mocks or simulated runners is flagged `simulated`. ## Context and instructions - Root `AGENTS.md` is canonical (read natively by Codex, Cursor, Copilot, and Claude Code ≥ 2.1.277 when no CLAUDE.md exists). Groot owns one managed region (``) only while the well-formed hash in its begin marker matches its body — a missing or malformed hash is a conflict, never an overwrite; everything outside is human-owned. Text transforms keep the file's line endings (CRLF stays CRLF) and final newline and return the file unchanged when nothing changes; source-anchor insertion refuses a statement that continues on the next line (chains, trailing or leading operators) or whose end cannot be found; JSON pointers refuse `__proto__`/`constructor`/`prototype` tokens. - `CLAUDE.md`: a managed region whose first content is `@AGENTS.md`. Because a root CLAUDE.md disables Claude Code's native AGENTS.md reading, every nested `AGENTS.md` gets a sibling CLAUDE.md shim. - Skill: canonical `.agents/skills/groot/SKILL.md` (Codex and agentskills hosts) plus a byte-identical `.claude/skills/groot/SKILL.md` (Claude Code), spec-only frontmatter. - Caps: managed region ≤ 8 KiB; warn above 16 KiB root file; refuse a root→nested chain above 32 KiB (Codex's combined budget). - `groot context --task "…"` returns task-scoped facts (relevant units, commands, env names, decisions, acceptance checks, known gaps) with provenance; no secret values or private session state. ## Agent runners and tasks Runners wrap documented interfaces only (Claude Code headless `claude -p --output-format stream-json`; Codex `codex exec --json`), discover capabilities truthfully (executable, version, auth state, features), and reuse each tool's own login — Groot never reads another tool's credentials. Tasks carry objective, dependencies, ownership globs, acceptance criteria, limits (wall time, turns, budget where enforceable, bounded attempts), status, attempts with observed usage, evidence, review, and integration. Each task runs in its own git worktree; overlapping ownership is serialized; integration merges into a fresh integration worktree and re-runs verification before anything reaches the user's branch. **Claude Code containment.** Every run — start and resume — passes: | Flag | Effect | | --- | --- | | `--permission-mode acceptEdits` · `--permission-prompts none` | File edits in the worktree are approved; anything that would prompt is denied | | `--strict-mcp-config` | No MCP servers | | `--safe-mode` | Hooks (except managed-policy hooks), installed plugins, skills, and CLAUDE.md files do not load; auth and permissions work normally | | `--tools Read,Edit,Write,Glob,Grep,Bash` | The only built-in tools (no subagents, worktrees, web fetch or search); tools `system/init` reports beyond this list are recorded as a warning note | | `--max-turns` · `--max-budget-usd` | Bounded spend | | `--allowedTools` | The file tools, plus Bash only for the task's acceptance commands and `git status`/`git diff` | | `--disallowedTools` | git commands that move refs or HEAD (`commit`, `checkout`, `reset`, `push`, `update-ref`, …), WebFetch, WebSearch — deny wins | | `--settings` | `sandbox: {enabled: true, failIfUnavailable: true, autoAllowBashIfSandboxed: false, allowUnsandboxedCommands: false, filesystem: {denyWrite: []}}`: Bash runs only inside the OS sandbox, a sandboxed command still needs an allow rule, there is no unsandboxed escape hatch, and the repository's git directory is write-denied | Never passed: `--dangerously-*`, `bypassPermissions`, `--bare` (it would break subscription and keychain auth). Preflight refuses, as `incompatible`, a Claude Code whose `--help` lacks any flag this containment depends on — `--tools` and `--safe-mode` included. A sandbox that cannot start blocks the task (cause `sandbox-unavailable`). Codex runs as `codex exec --json --sandbox workspace-write -C -c approval_policy="never"` (plus `--ignore-user-config` when its help lists it), with no turn or spend limit — Groot enforces the wall time. Residual risks: Claude's project and local settings files still load, so an agent-written `.claude/settings.local.json` can add allow rules for later attempts (still sandboxed); the Claude sandbox covers Bash only — the file tools are bounded by permissions; nothing stops Claude Code's own bookkeeping outside the worktree; Codex has no per-path deny. **Repository guard.** A snapshot holds every git ref, the HEADs of the main checkout and of the worktree in use, and the git directory's executable surface (`config`, `config.worktree`, `hooks/`, `info/`, and each linked worktree's `config.worktree`). Snapshots are compared around three windows: the runner's attempt, the pre-review checks (after each check), and integration's fresh checks. Only other tasks' `refs/heads/groot/*` branches, `refs/remotes/*`, and target-branch fast-forwards Groot's integration journaled in `.groot/ref-moves.jsonl` before making them may change; the task's own branches move only between windows. Anything else blocks the task with the exact list and stops the remaining checks. This fails closed — a commit the user makes on the target branch, or a ref another tool moves, during a window also blocks; running the task (or the integration) again continues. Changes to the main checkout's files are a warning. The guard detects; it does not confine. Groot's own git never runs repository hooks or an fsmonitor (`core.hooksPath=/dev/null`, `core.fsmonitor=false`, `commit --no-verify`). **Pre-review checks.** Before review, the checks run code nobody has reviewed, without an OS sandbox. Every process Groot starts for them — the dependency install, the acceptance commands, and the scripts and apps a verify criterion runs — gets a credential-free environment: names with credential words anywhere (`TOKEN`, `SECRET`, `PASSWORD`, `PASSWD`, `PASSPHRASE`, `API_KEY`, `AUTH`, `CREDENTIAL`, `PRIVATE`, `WEBHOOK`) or as whole words (`KEY`, `KEYS`, `PASS`, `PWD`, `PAT`, `DSN` — `PWD` and `OLDPWD` themselves stay), cloud/provider/agent/registry namespaces (`AWS_`, `AZURE_`, `GOOGLE_`, `ANTHROPIC_`, `OPENAI_`, `CLAUDE_CODE_`, `CODEX_`, `NPM_CONFIG_`, …), git config injected through the environment, key-agent sockets and credential-file pointers (`SSH_AUTH_SOCK`, `KUBECONFIG`, `NETRC`, …), URLs carrying a password or token, and agent-session variables are removed, while `PATH`, `HOME`, `TMPDIR`, locale, `CI`, `BUN_*`, and proxies without credentials stay. Name patterns cannot recognize every credential, and files under `HOME` stay readable. Every piece of pre-review evidence records that it ran unsandboxed; command and install evidence also records the credential removal. Integration (after approval) runs its checks with the caller's environment minus agent-session variables. **Dependencies.** Worktrees live inside the project, so without their own `node_modules`, Bun resolves packages — workspace packages included — from the main checkout's. Before the checks, a task worktree (when the task has acceptance criteria) or an integration worktree with a Bun lockfile therefore gets `bun install --frozen-lockfile` (evidence check `task.dependencies`; a failure blocks the checks), provided `node_modules` is git-ignored in any form (`node_modules`, `node_modules/`, `/node_modules/`) — otherwise Groot would commit it. Without a lockfile, or when `node_modules` is not ignored, nothing is installed and every piece of evidence says so; even after an install, an import the worktree's packages don't declare can still resolve from the main checkout. Groot's task commits never stage new files under `node_modules`. **Crash recovery.** Runners lead their own process groups. SIGHUP, and SIGTERM when the host has no handler of its own, kill every live runner group before Groot exits 128 + n (the CLI and the MCP server handle SIGTERM by aborting the run). `runner.json` records the runner's process group and spawn time, so the next `task run`/`task resume` — or the overlap check before another claim — stops a provably orphaned runner (its group leader alive and started when recorded) before marking the task interrupted; a group whose leader has exited is never signalled, and the task stays `running` with the next step in its reason. SIGKILL of Groot can still orphan a runner until then. Only established sessions survive a crash: a crashed attempt keeps its session id only when its log shows `system/init` (Codex: `thread.started`). A resume target Claude Code reports as unknown ("No conversation found") is replaced by a fresh session without spending an attempt, keeping the task prompt, the project context, and the reason. Claims are re-validated under the project lock, and review decisions are written under it against a fresh read; a review without a decision never waits behind another operation (unrecorded, with a warning, when the lock is not free within 2 s). `task show`, `task list`, and MCP reads show an abandoned run as it will be reconciled, without writing or signalling anything. ## MCP `groot mcp` serves typed tools over stdio that call the same core functions and policy as the CLI (inspect, plan, apply/operation status, verify, evidence, context, tasks, review, schema discovery). stdout carries only JSON-RPC; logs go to stderr. Long operations return operation ids so clients can poll after timeouts; cancellation aborts through the same AbortSignal path. `operation_apply` and `operation_resume` accept per-run approvals (`allow`) but never `external`: an agent cannot approve provider effects for itself, so the refusal (`GROOT_E_POLICY_DENIED`) names the terminal command a person runs — `groot apply --allow external` or `groot resume --allow external`.