Skip to content

ADR 0002 — Agent step specs and the local loop runner

  • Status: accepted
  • Accepted in: https://github.com/bamr87/bamr87/pull/521 (merged 2026-11-01 by @bamr87)
  • Date: 2026-10-30
  • Deciders: proposed by an agent for bamr87/bamr87#485; the maintainer accepts or rejects it in that PR's review
  • Related: epic bamr87/bamr87#484, P0 bamr87/bamr87#485, the motivating incident bamr87/bamr87#89, constitution § 10.8 (PR #480), § 12.3 (PR #481), § 13 (PR #482), § 15 (PR #491), docs/JEV.md
  • Tracking: #484

Context

Needs assessment

Who needs what. The maintainer wants every fleet loop to run locally with Claude Code agents using JEV's optimizations, and #484 (epic) and #485 (P0) record this. A local run is only worth having if it does exactly what CI does: the same hard-rules prompt, tool allowlist, model, turn and dollar caps, and workspace contract. Today the CI copy is the only copy. P1 (the JEV loop engine) needs one machine-readable source to render from. The console, the TUI and the fleet MCP need that same source to describe and later drive the loop. The § 13 tracing and eval work needs to pin a run to the exact text and model it used.

Evidence from the hub:

  • Agent prompts live only inside workflow YAML. There are 7 inline prompt: | blocks across 5 workflows that call anthropics/claude-code-action@v1: fleet-pulse, issue-pipeline (×3), fleet-verify, repo-scout, repo-evolution. Two more take an expression: fanout.yml's agent-fill builds its hard-rules brief in a shell heredoc (steps.brief.outputs.prompt), and ai-lane.yml passes the caller's inputs.prompt. No workflow reads a prompt from a committed file. repo-scout's hard rules were at repo-scout.yml:277-338 at cb8c077.
  • The console can plan scout but cannot run its agent. LOOPS maps repo_scout → workflow repo-scout (tools/console/core.py:202-204). Its only local op is scout = dash-gen scout --offline (core.py:1200). Every agent step is reachable only through DISPATCH_WORKFLOWS (core.py:103), which means GitHub runs it.
  • The one local headless wrapper, dash ai run (ai_activity.run_headless), takes its cap from budget.local_usd ($5), not the call site's cap (repo-scout.yml:scout = $8). Prompt, tools and model pass through untouched, so a hand-run local scout would be capped differently from CI.
  • Scout's caps already exist in up to five places, held together only by hand-written tests: --max-turns 40 = scout.max_turns, --max-budget-usd 8 = budget.call_sites, and claude-cost budget-usd (test_scout.py:222-283 at cb8c077, test_ai_budget.py). harness_registry records scout's model as null because MODEL_RX cannot read ${{ needs.plan.outputs.model }}.
  • When a prompt and its allowlist are written in two places, they drift, silently and at a cost. In bamr87/bamr87#89 the prompt's first order is to Read a file, but the compiled --allowedTools grants no Read. The result was 12 of 26 turns denied, error_max_turns, and $0.55 API-equivalent (estimate) on every scheduled run. Scout's prompt names both Read and Write, so it carries the same exposure.
  • § 13.3 (ratified, PR #482) requires exact model ids from _data/fleet.yml ai_models.allowed (claude-opus-5-5, claude-sonnet-5-5, claude-haiku-5-5). Scout runs on scout.model: sonnet with the fallback // "sonnet". A step format that copies today's values would carry the alias into the new format.
  • The brief templates (.github/scout/, .github/evolution/) already split tunable material from hard rules using {{UPPER_SNAKE}} tokens. But evolution.render_template (evolution.py:401-404) chains str.replace calls. That makes it multi-pass: a GitHub-synced DESCRIPTION containing a later token gets expanded. It also leaves unknown tokens in place silently and never reports missing values. It cannot carry hard rules safely.

Why now. Every later phase builds on the format this P0 fixes, and changing it after P1 ships would touch every consumer:

  • P1: the local runner.
  • P2: the console "run locally" surface.
  • P3: the doctor, evolve and issue-pipeline step specs.
  • P4: CI executing through the runner.
  • P5: local schedules.

§ 10.8 (ratified, PR #480) requires this record before any of that code exists. #466 (kaizen) is waiting to be born as a spec rather than inline.

The § 13 no-op claim, as far as the repo can show it

The only repo-side mapping is ai_activity.MODEL_ALIASES (ai_activity.py:110-112: "sonnet": "claude-sonnet-5-5"). That is the hub's cost-accounting normalization, not the CLI's alias resolution. docs/AI-INTEGRATION.md does not mention a sonnet alias.

External evidence settles it for first-party auth. Scheduled run 41169651906 passed --model sonnet and logged system/init "model": "claude-sonnet-5-5", with modelUsage provider firstParty. The Claude Code model-config docs map sonnet to Sonnet 5.5 on the Anthropic API, but to Sonnet 4.5/4.6 on Bedrock, Vertex and Foundry.

So pinning claude-sonnet-5-5 is a no-op for the fleet's oauth,api_key auth order, and it removes a latent difference on third-party providers. The pin covers the main loop only. The same run made one claude-haiku-5-5 side call ($0.0002 API-equivalent (estimate)), so the ledger must sum modelUsage across models.

Decision

Build the format, adopt everything around it. No candidate holds prompt, allowlist, caps, inputs, workspace contract and risk in one file that both a GitHub-hosted action and a local claude -p can render byte-identically. JEV capability two therefore adds a small stdlib+PyYAML spec format and loader under tools/jev/ (tools/jev/spec.py, specs at tools/jev/steps/<loop>/<step>.yml + <step>.prompt.txt), with python3 -m tools.jev steps check|render.

Adopted as is

  • anthropics/claude-code-action@v1 stays the CI executor in P0. The spec renders its prompt and its claude_args stays literal, so the workflow diff is the prompt source only.
  • The {{UPPER_SNAKE}} token syntax and names from the brief templates (REPO_NAME, NWO, BRANCH, plus BRIEF).
  • The tunable/hard-rules split. The briefs stay in .github/scout/ as inputs, and the spec is the hard-rules half.
  • JEV house style: header docstring, no import side effects, a python3 -m tools.jev subcommand, and a plain-python test runner.
  • fleet.yml as the single home of values that already live there.
  • The console's LOOPS.workflow field as the join key.
  • claude -p --output-format json as P1's local executor (recorded here, built in P1).

Extended

  • dash ai run / run_headless: in P1 it takes its cap from the spec's call_site via budget.call_sites instead of local_usd, and it gains the stream, timeout, repo and result-file changes listed in #486.
  • JEV's claude_argv shape: it gains --allowedTools rendered from the spec.
  • JEV's charge-at-cap and cost_source rules apply to loop runs.
  • The existing test_scout contract checks are repointed at the spec rather than duplicated.
  • The harness_registry cap regexes MAX_TURNS_RX and MAX_BUDGET_RX are inlined into spec.py, citing harness_registry.py:87,91-92, so tools/jev never imports dash-gen.

Spec format decisions

  • Placement: under tools/jev/steps/, beside JEV capability one, so the local engine (P1) and the specs share a home with no dash-gen dependency.
  • Prompt file: .prompt.txt, not .md, because markdown-oneline would reflow a .md prompt (60 → 28 lines) and push the reflow with GITHUB_TOKEN, where it could merge green. .gitattributes pins eol=lf, and the loader refuses trailing whitespace or more than one final LF, because pre-commit's whitespace hooks do touch .txt.
  • References, not copies (AGENTS.md central configuration): model_from: scout.model, max_turns_from: scout.max_turns, call_site: repo-scout.yml:scout (→ budget.call_sites). The spec carries no literal model, turns or budget.
  • Literals only for what has no other home: prompt, inputs, allowed_tools, timeout_minutes, workspace, risk.
  • Placeholders: caller-filled {{UPPER_SNAKE}}, rendered in a single pass by re.sub with a callback that refuses unknown tokens, unfilled declared inputs and undeclared inputs. A value is never re-scanned, which closes the DESCRIPTION expansion hole in render_template.
  • Caps stay literal in the workflow's claude_args, so harness_registry, the workflow atlas and test_ai_budget keep reading them unchanged. parity_errors resolves the references and holds every workflow literal equal to the resolved values: --max-turns, --max-budget-usd, claude-cost budget-usd, timeout-minutes, --allowedTools, the download/upload paths, and the absence of a GitHub token in the agent step's effective env (workflow, job and step), its github_token input and any earlier $GITHUB_ENV export. What the action does outside that env — it exports its OIDC App token to Claude's subprocesses, and without --setting-sources it loads the checkout's .claude/ settings and hooks — is a gap parity reports: the spec declares each open gap under workspace.exceptions with its reason, and steps check fails on an undeclared gap or a stale exception. It adds the #89 lint: every tool the prompt orders by name ("with the Read tool") must be in allowed_tools.
  • Content-hash pin: the agent step carries env: JEV_STEP_SHA256: <sha256 of <step>.yml, a NUL, <step>.prompt.txt>, a runtime no-op that parity requires to equal the spec pair. It follows the literal-plus-parity pattern of the caps, and it means any edit to the hard rules also edits the workflow file (see the governance trade-off).
  • Exact model ids: the resolved model must appear in ai_models.allowed (any provider list), and the loader and parity refuse an alias. Scout is pinned to claude-sonnet-5-5 in fleet.yml scout.model and in the repo-scout.yml fallback, with repo_scout.DEFAULTS and its tests updated to match.
  • Optional risk: (§ 13.6): per action, tags from {reversible, external, money} and a tier low|medium|high, where irreversible, external or money starts high. For scout:
  • the agent step (a run-to-verify, code-executing allowlist plus Write of .scout/proposals.json) is external, high: it runs the target repo's interpreters, package managers and make with network egress over untrusted repo and issue text, and the action's App token reaches it, so it meets the § 13.8 trifecta (private data, untrusted content, an external send) with the send ungated;
  • the publish action (dash-gen scout-file --apply, files issues) is external, high.
  • Both tiers are declared, not enforced: CI reads neither today, and the scheduled file job runs --apply without a human yes, gated only by REPO_SCOUT_ENABLED. The tier lint (HUB-049) and P2's confirm gate are where they start to bind.
  • Optional evals: (§ 13.1): a path to the eval set, or null during the grace period. Its shape is validated when present.
  • Versioning: loop-step/v1 evolves the way harness-registry/v1 does (AGENTS.md, consumed interfaces): an optional key added together with its loader support keeps v1; removing or renaming a key, making an optional key required, or changing a key's meaning bumps to loop-step/v2. The strict refusal of an unknown key is deliberate — the Rejected list faults .claude/agents for silently ignoring unknown fields — and every consumer reads specs through tools/jev/spec.py.

Loop key mapping

The spec directory is the workflow stem (repo-scout), matching wtd's "lane id = workflow stem". The console LOOPS id repo_scout and the schedule key join through LOOPS[...]["workflow"]. Neither side is renamed.

Rejected

  • claude-run/run.sh as the runner: acceptEdits auto-approves edits outside the allowlist, it resolves the model consumer-side, it needs Ruby, and it hands a 429 to the API key (#348). P1 ports only its per-attempt env -u credential isolation, its exit contract and its stubbed-claude test pattern.
  • .claude/agents frontmatter or --agents JSON: no caps, inputs or references, it silently ignores unknown fields, and it replaces the system prompt, which breaks byte parity. P1 may generate one from steps render later; the direction is spec → artifact, never the reverse.
  • Copilot-format prompts, Dotprompt, LangSmith: no agent-loop semantics, extra dependencies, or the prompt leaves the repo.
  • Agent SDK as P1's executor: a dependency for no parity gain. Held in reserve for can_use_tool gating of high-risk actions.
  • gh-aw, act, self-hosted runner: none runs locally and faithfully.
  • Waiting for a platform prompt-file standard: the one GitHub-native standard (.prompt.yml) was retired.

Governance trade-off

Moving the hard rules out of .github/workflows/ into tools/jev/steps/ would remove GitHub's workflow-scope barrier from them. The identities that barrier stops are the ones GitHub refuses on .github/workflows/*:

  • GITHUB_TOKEN pushers: the github.token fallback of resolve-fleet-token (issue-pipeline, fleet-pulse), jev-conflicts' FLEET_TOKEN || GITHUB_TOKEN, and markdown-oneline's repair push.
  • The Claude GitHub App installation token: claude.yml, and the token claude-code-action exports to every agent's subprocesses — the scout agent's included (Follow-ups).

FLEET_TOKEN is not among them: it already holds workflows:write on the repos the fixer opens PRs against, the hub included (docs/AI-INTEGRATION.md, fleet.yml tokens:), so an agent holding it could always edit the inline prompt. For it the maintainer's review is the only control, before this change and after it. This reverses the stated rule in .github/scout/README.md, so that sentence is rewritten in the same PR.

The control that restores the barrier is the content-hash pin. The Scout step carries JEV_STEP_SHA256, and steps check refuses a spec pair whose hash differs from it, so an edit to scout.prompt.txt or scout.yml is also an edit to repo-scout.yml — which GITHUB_TOKEN and the App token cannot push. Without the pin nothing would hold: steps check does not read the prompt's text, and the byte pins in tools/test_jev_spec.py and test_scout.py are re-pinned by the same PR, which makes a change visible but does not block it.

What is not a control, stated so the trade is accepted on the facts:

  • CODEOWNERS names @bamr87 for every path (*), /tools/ and /.github/workflows/ alike, and is not enforced: main has no branch protection and the strict ruleset is disabled. It becomes a control only if the maintainer turns on required code-owner review (§ 12.4). Agent PRs pushed with FLEET_TOKEN are authored as the owner anyway.
  • An agent may merge a mergeable PR (§ 12.2) and never a gated one (§ 12.5). A change under tools/jev/steps/** is security-sensitive config under § 12.3, so it is gated; tools/jev/steps/SCHEMA.md and its README say so where agents read them. The § 12.4 needs-amr label does not exist yet (HUB-045), so today the effective control is that no workflow merges and the maintainer reviews every such PR.
  • JEV's conflict classifier gives tools/jev/steps/** the kind source, not workflow, so with jev.auto_tiers beyond tier0 a conflict in a prompt would be open to tiers 1 and 2. It is off today (auto_tiers: [tier0]), and § 12.3 gates a non-trivial resolution anyway; P1 makes step specs a tier-1-forbidden kind routed to tier 3.

The fallback, if the maintainer rejects the trade, is .github/loops/. It does not restore the barrier either — only .github/workflows/* carries it — so the content-hash pin is the one option that does.

The maintainer accepts or rejects this explicitly in the PR review.

What P1-P5 build on this

  • P1 (python3 -m tools.jev loop run) renders the same spec into claude -p with the resolved model, turns and call-site cap and the rendered --allowedTools. It isolates settings with --setting-sources, --strict-mcp-config and disableAllHooks (never --bare; amended in P1: --restricted, not --setting-sources), and picks one credential per CLAUDE_AUTH_ORDER with env -u for the rest. It sandboxes code-executing tools per § 13.8, writes a redacted stream-json trace and one ledger entry, and refuses non-allowed models.
  • P2 exposes the publish action as a remote op behind the existing confirm gate (high), so § 13.6 is enforced by code that already exists. The agent step becomes a console/MCP op at the tier its spec declares: high today, and lower only once P1's § 13.8 sandbox (no network, no credentials) lets a § 13.9-gated re-tier bring it down.
  • P3 gives doctor, evolve and the three issue-pipeline tiers their specs and appends their decisions here. Because v1 allows no literal model or turns, P3 first adds their fleet.yml homes: remediation.model and remediation.max_turns: 240 (test_fleet_pulse_doctor keeps it ≥ max_candidates × 55), issue_pipeline.tiers.<tier>.model and .max_turns (250/400/400), evolution.model, and verification.agent.model repinned from sonnet — every model an exact id there (opus → claude-opus-5-5); changing the format instead is appended to this ADR. P3 also brings in fleet-verify.yml:verify and fanout.yml:agent-fill (which passes no --model today and needs one before parity can pass) or records why not. claude.yml (interactive, no hard-rules prompt) and ai-lane.yml (the prompt is the caller's input; its spec belongs to the caller) are out of scope. Any agent step added after P0 (e.g. kaizen #466) is born as a spec.
  • P4 first teaches the detectors (atlas, harness_registry, ai_usage_collector, test_ai_budget, test_schedule) the new step shape, then may move CI to base-action with prompt_file or to loop run --ci, keeping caps literal on that line.
  • P5 schedules local runs under its own budget ceiling in the budget.jev shape.

Every later phase that changes the format or the executor (the P1 runner, the P4 keep-or-convert decision) appends its decision to this ADR or supersedes it, and never records it only in a PR.

Consequences

Positive

  • One file pair holds scout's prompt and its grant, and a lint holds them together, so the #89 failure mode is caught before spend.
  • CI and the coming local runner render the same bytes from the same spec, and the model, turns and dollar cap resolve from _data/fleet.yml for both.
  • The model is an exact, allowed id, which § 13.3 requires and which removes the alias's provider-dependent meaning.

Negative

  • The hard rules leave .github/workflows/; the workflow-scope barrier still covers them only through the JEV_STEP_SHA256 pin, so every spec pair edit carries a matching workflow edit. For FLEET_TOKEN identities the maintainer's review stays the only control (see the governance trade-off).
  • The CI agent step meets the § 13.8 trifecta today with an ungated send, and its spec declares the two action gaps (app-token, setting-sources) as known exceptions rather than claiming a credential-free step CI does not deliver.
  • Scout's caps now have one more reader that must agree (the spec's resolved values), so a cap bump touches several files, though parity fails loudly until they agree.
  • dash-gen scout (the plan job, tools/dash scout plan and the console scout op) now depends on the spec loading; a broken spec fails the plan before any spend.

Follow-ups outside P0

  • claude-code-action's App token reaches Claude's subprocesses, contradicting the "NO GitHub token in this step's env" comment, and with no --setting-sources the action loads the scouted repo's .claude/settings.json (permissions and hooks). The spec declares both as workspace.exceptions (app-token, setting-sources). File a separate issue; the fix options are CLAUDE_CODE_SUBPROCESS_ENV_SCRUB: '1', a read-only github_token: ${{ github.token }} (which needs a new github_credential posture, since none refuses any github_token), or base-action, plus --setting-sources user. Closing one makes its exception stale, and steps check then asks for its removal. P1 must not reproduce either. (P1 found that on CLI 2.1.308 CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 also forces the permission mode to default, overriding --permission-mode and the settings' defaultMode; choosing that option in CI changes the step's permission posture too.)
  • JEV's classifier treats tools/jev/steps/** as source (governance trade-off); P1 makes it a tier-1-forbidden kind, with a case in tools/test_jev_classify.py.
  • JEV's tier-½ models are outside ai_models.allowed. That is a § 13.3 follow-up for the maintainer.
  • harness_registry keeps recording scout's model as null until it resolves the model through the spec or the workflow passes a literal --model.
  • Byte identity at the action boundary (JSON through the matrix) is verified on the first maintainer-dispatched run by comparing the action's logged prompt with steps render. Agents do not trigger that run.

Alternatives considered

In-repo candidates

  • ai-runner kit (claude-run/run.sh, ai-lane.yml, templates/ai-runner/ 0.2.0): Partial fit.
  • It standardises how a call is made (auth order, exit contract, AI_REPO_ROOT for local trees) but has no spec, so nothing keeps CI and local identical.
  • It hard-codes --permission-mode acceptEdits (run.sh:143), resolves the model from the target repo's _data/ai.yml, and needs Ruby.
  • No hub loop uses it; all 9 hub agent call sites use claude-code-action.
  • dash ai run (ai_activity.run_headless, :771-856): Partial fit.
  • It covers the cost and ledger half (result_record, budget_was_hit, usage_from_result, models_from_result, record_run), and it refuses a passed-through --max-budget-usd.
  • It knows nothing about specs, and its cap is local_usd rather than the call site's.
  • JEV conflict engine (tools/jev/conflicts.py): Strong precedent for house style.
  • It is one Python code path for local and CI, with a capped claude_argv, a free-first tier ladder, and a ledger with cost_source reported/estimated/no-spend.
  • It is not a spec: prompts are f-strings (_prompt, :382-398) and claude_argv passes no --allowedTools.
  • Its tier models (claude-haiku-4-5-20251001, claude-sonnet-5) are not in ai_models.allowed.
  • Brief templates (.github/scout/, .github/evolution/): They set the {{UPPER_SNAKE}} syntax and token names (REPO_NAME, NWO, BRANCH) and the tunable/hard-rules split. They cannot carry hard rules: the render is multi-pass, never reports unknown or missing tokens, and the Markdown files are reflowed by the prose gates.
  • .claude/agents, skills and commands: No fit to carry the spec.
  • They have no place for caps, inputs, workspace, risk or evals, and model: inherit conflicts with § 13.3.
  • Scout runs in the target repo's checkout, where hub agent files are not on the path.
  • Command allowed-tools is precedent for keeping an allowlist next to its prompt.
  • .github/agents|instructions|prompts (Copilot-format reference templates): No fit. They are repo-agnostic by rule, have no allowlist or caps, use model aliases, and nothing renders them. Their README rule ("concrete paths belong in the invoking prompt") supports caller-filled inputs.
  • Harness Console OPS/LOOPS/JobManager and the fleet MCP: The surface for P1 and P2, not the format.
  • LOOPS.workflow is the join key to the spec directory.
  • The remote op and its confirm=true gate are the runtime counterpart of a § 13.6 high-risk action.
  • GitFactory/gitorio (agent.claude machine, blueprint compiler): The closest precedent, but it points the wrong way for P0.
  • It compiles to CI only, in TypeScript the hub cannot import, and it derives grants in code, which is how #89 happened.
  • Its lessons: "frontmatter is documentation; the compiled claude_args is what grants", an exact-id model list identical to ai_models.allowed, and belt mode (the agent writes JSON, a deterministic sink consumes it).
  • It is a future consumer of the spec.
  • wtd fleet/v1 lane manifest (fleet.manifest.yml): Not a step spec. It has no prompt, allowlist, caps or inputs, and the hub copy is stale (0 repo-scout lanes). It backs "lane id = workflow stem".
  • bamr87/bamr87#89: The motivating incident, not a tool. It justifies one file holding prompt and grant together, plus a lint that checks the prompt against the grant.
  • Existing parity tests (test_scout.test_workflow_contract, test_ai_budget.py, harness_registry cap regexes :86-92): Direct precedent for the parity half, but tied to one workflow rather than driven by a spec. Keep and repoint them; do not duplicate them.

External candidates

  • anthropics/claude-code-action@v1 (agent mode): The right CI executor today; it passes the prompt verbatim to the SDK's query().
  • It cannot run outside Actions: it needs @actions/github context, GITHUB_ACTION_PATH, an OIDC URL and github.token.
  • It has no spec, cap, ledger or tiers.
  • It exports its minted App token (contents/issues/PR write) into GH_TOKEN/GITHUB_TOKEN for Claude's subprocesses, and it loads the scouted repo's .claude hooks and .mcp.json (settingSources default user,project,local). See Consequences.
  • claude-code-action/base-action@v1 (mirror: claude-code-base-action, v0.0.x only): A better later CI executor.
  • It accepts prompt_file and mints no GitHub token.
  • It shares the SDK option parsing, so the parity rules carry over.
  • It still cannot run outside Actions, and it is not a format.
  • Claude Code headless CLI (claude -p, 2.1.308 installed): The right local executor for P1.
  • It takes exactly the flags the spec renders, and --output-format json returns total_cost_usd, per-model modelUsage, session_id and permission_denials.
  • Gotcha: --bare never reads CLAUDE_CODE_OAUTH_TOKEN, which breaks oauth-first auth. Isolate with --setting-sources, --strict-mcp-config and disableAllHooks instead.
  • Claude Agent SDK (Python/TS): The same loop, with a can_use_tool seam that could enforce risk tiers per call.
  • It adds a non-stdlib dependency to a stdlib+PyYAML hub, and the docs steer SDK products away from claude.ai login.
  • Its option names become the spec's vocabulary; the SDK itself is held in reserve.
  • Claude Code sandboxed Bash + dontAsk: The right § 13.8 control for laptop runs of scout's code-executing allowlist (python3, node, npm, make). It is per-run --settings JSON. It does not cover Read/Write or MCP. P1 concern.
  • anthropics/sandbox-runtime (srt): Optional whole-process boundary. It is beta, not installed, and an npm dependency, so it becomes an opt-in runner flag at most.
  • Claude Code subagent definitions (--agent, --agents <json>): Native, but there is no budget field, no caller inputs, no risk or evals, and no way to reference fleet.yml. The body replaces the system prompt, which breaks byte parity with today's user-turn prompt. Unknown fields are ignored silently.
  • GitHub Agentic Workflows (gh-aw v1.0.1): The closest concept (safe-outputs ≈ scout's plan → scout → file split), but run and trial execute on GitHub. The Claude engine rejects subscription OAuth, and adopting it would hand workflow generation to a compiler outside the workflow-atlas rules.
  • GitHub Models .prompt.yml (actions/ai-inference): Dead. The service was retired 2026-07-30 and gh-models is archived, and the format was single-shot with no agent concepts. Only the {{var}} and testData conventions survive as reference.
  • nektos/act (v0.2.92): No. It ignores timeout-minutes and permissions, has no OIDC (so the action's token exchange fails), needs Docker, and runs whole workflows.
  • Self-hosted runner on the Mac: No. GitHub advises against it for public repos; it is still dispatched by GitHub; and installing it breaks § 10's no-change-to-the-Mac rule.
  • Promptfoo: Not a runner or format, but the best fit for the § 13.1 evals: slot. It can point file:// at the same .prompt.txt and run it through the Agent SDK with the spec's caps. Its Nunjucks templating is a superset, so either pre-render with JEV or keep prompts free of {%.
  • Dotprompt (google/dotprompt): Format only. It has no turn, budget or permission concepts; it needs a non-stdlib dependency; and Handlebars logic makes byte-exact rendering across runtimes harder. Its typed inputs: (missing or unknown fails) is borrowed.
  • LangSmith prompt hub: No. Prompts would live in a SaaS store behind a key, so they are no longer reviewed in a PR. Only content-hash pinning is borrowed, for the § 13.5 trace.

P1 — the headless executor and its § 13.8 posture

  • Status: accepted, with the maintainer's decisions of 2026-10-31 for #486 (P1 of #484) recorded below
  • Accepted in: https://github.com/bamr87/bamr87/pull/523 (merged 2026-11-01 by @bamr87)
  • Date: 2026-10-31
  • Scope: the executor and the posture (PR-A, feature/jev-headless-executor); the $0 engine (PR-B, feature/jev-loop-engine); attempts, the canary, the monthly ceiling and publishing (PR-C, feature/jev-loop-run); the last two are recorded at the end of this section

The executor

Extended, not forked. dash ai run (dash-gen ai-run, ai_activity.run_headless) is the one capped, streamed, ledgered headless executor, for a human and for the loop engine alike. It gains --call-site (the cap is budget.call_sites[...], and --max-budget-usd may only lower it), --stream, --timeout, --repo, --cwd, --prompt-file, --trace, --result-file (readable by claude-cost's log:), --outcome-file, --isolate, --auth-order, --usage-limit and --meta. Without them it behaves as before, except for deliberate changes: a run with no result record is now ledgered at its cap, which is a correctness fix (below); the wrapper adds --session-id <uuid> unless the passthrough names a session; the passthrough also refuses -p, --print, --output-format, --dangerously-skip-permissions, --allow-dangerously-skip-permissions, any --permission-mode or hidden --inherit-permission-mode of bypassPermissions, a --settings value whose defaultMode is bypassPermissions, an --agents value that gives an agent that permissionMode, a --settings or --agents value it cannot read (a relative path is read from --cwd, where claude reads it), and --cloud, --remote and --teleport (an attached cloud session enforces no cap from this invocation); the result file and the stdout echo are redacted like the trace; both output files are removed when ai-run starts; the row's model is never guessed from modelUsage; a claude killed by a signal exits 128+N; and every dollar figure printed is labelled API-equivalent (estimate). The refusal reads flags only: the user's and the project's settings files still load unless the passthrough carries --restricted, which --isolate does not add.

The boundary points one way. The new tools/jev/headless.py holds the isolation argv, the --settings document, the agent environment, the credential choice, redaction, the streaming runner and the outcome classifier. dash-gen imports it lazily, with the hub root appended to sys.path (the way repo_scout.step_spec() imports tools.jev.spec), and tools/jev never imports dash-gen. The engine (PR-B) runs tools/dash-gen ai-run as a subprocess.

One ledger row per invocation. record_run and merge_ledger take an exclusive flock on <ledger>.lock, so concurrent attempts and a dash ai scan cannot drop each other's rows. dash ai run waits for it at most --ledger-wait seconds (30 by default), because it holds a cancel while it records: past that a stopped or hung writer costs the run its row, never the cancel, and the outcome file's ledger_error says so. RUN_FIELDS grows additively (call_site, origin, run_id, attempt_id, loop, step, item, tier, model, outcome, cost_source, cap_usd, auth_method, cli_version, duration_s) and LEDGER_VERSION stays 1. JEV's charge-at-cap rule now applies to dash ai run itself: a run whose session may have started, or that a wall clock or signal stopped, and that left no result is recorded at its cap as estimated; no-spend needs proof that the model was never reached — under stream-json, an exit before the init event the CLI prints ahead of any request; under json, which shows no init, the CLI's own argv refusal as the first stderr line. A CLI that is missing or cannot start writes an outcome file and no row. A signal that lands before claude is started cancels the run with no process and no row (interrupted, no-spend, exit 130); one that arrives once claude has exited does not change the run's outcome and is held until the row and both files are written (the CLI's version is read before the run, so no process starts in that window), and ai-run then exits 128+N. dash ai reports billed_cost_usd (reported rows) and estimated_cost_usd apart, so an estimate never reads as measured spend (HUB-032).

The wall clock is SIGINT first. The headless docs say SIGTERM leaves the turn unfinished and records no result, while SIGINT ends the turn; so a timeout sends SIGINT to claude's process group, SIGTERM 15 s later and SIGKILL 10 s after that, and kills what is left of the group. A SIGINT, SIGTERM, SIGHUP or SIGQUIT sent to ai-run, or any other asynchronous signal that would end it (USR1, USR2, ALRM, VTALRM, PROF, XCPU), starts the same ladder, so an outer backstop or a closed terminal still gets a result: claude runs in its own session, out of the terminal's reach, and only a signal ai-run cannot forward orphans it (bounded by its cap and turn limit): SIGKILL, which nothing can catch, a fault, or a Linux real-time signal. A tee that can no longer be written, as after a hangup, is dropped and the run goes on. Exit 124 for the wall clock; a forwarded signal (Ctrl-C, a console cancel) is the interrupted outcome, exit 130, and is read before the usage-limit and credential tests, because a turn aborted before its first response reports $0 and an empty modelUsage, the credential-rejected signature, for a request that was in flight.

Amendment: --restricted instead of --setting-sources

The P1 bullet above planned to isolate settings with --setting-sources, --strict-mcp-config and disableAllHooks. P1 uses --restricted instead, because:

  • the permissions docs say that under -p a repository's settings env block is applied, and that it survives even --bare. A target repo's .claude/settings.json with env: {ANTHROPIC_BASE_URL: …} would send the session, with its OAuth credential, to another host, and disableAllHooks does not cover env;
  • --setting-sources '' parses on 2.1.308, but what an empty list means is undocumented, and a control whose meaning is undocumented cannot carry that risk;
  • --restricted is documented to ignore the user, project and local settings files while managed policy and --settings still apply; it also confines the file tools to the working directories and removes the code-running tools unless --tools names them.

It is joined by --safe-mode (no CLAUDE.md or memory, skills, installed plugins or mods — a mod can approve calls under dontAsk — hooks, MCP or custom agents), --tools limited to the spec's tool families, each of which must be in GRANTABLE_TOOLS (Bash, Read, Write, Edit, NotebookEdit, Glob, Grep — an allowlist, because the CLI keeps adding tools such as Artifact, RemoteTrigger, PushNotification and SendUserFile that reach past the sandbox; the default -p toolset carries Task, Skill, SendMessage and ListAgents, which reach the user's other local sessions, ScheduleWakeup, Workflow, Edit, WebFetch and WebSearch), --permission-mode dontAsk --permission-prompts none, the spec's allowlist verbatim plus a deny list (gh, git push|remote|config, curl, wget, ssh, scp, nc, open, osascript, security, WebFetch, WebSearch), --strict-mcp-config with an empty config, --disable-slash-commands, --no-session-persistence, a --session-id the engine chose and a --debug-file. A generic local-runner note goes in with --append-system-prompt, so the byte-pinned spec prompt stays the CI prompt. MIN_CLI is 2.1.259, the first release that accepts --permission-prompts. --bare stays rejected: it never reads OAuth or the keychain.

§ 13.8 posture for local runs: both layers (maintainer decision 1)

  1. Session isolation, the flags above.
  2. A mandatory, fail-closed Seatbelt sandbox for Bash and its children, from the --settings document: enabled, failIfUnavailable, allowUnsandboxedCommands: false, autoAllowBashIfSandboxed: false (its default would approve any sandboxed command), network.allowedDomains: [] with strictAllowlist, permissions.blockReadsOutsideWorkingDirectories, disableAllHooks, and sandbox.credentials denying every credential variable (GH_TOKEN, GITHUB_TOKEN, FLEET_TOKEN, FLEET_WRITE_TOKEN, PROJECTS_TOKEN, NPM_TOKEN, RUBYGEMS_API_KEY, both Claude credentials, ANTHROPIC_AUTH_TOKEN) and file (~/.ssh, ~/.aws, ~/.config/gh, ~/.netrc, ~/.git-credentials, ~/.npmrc, ~/.docker, ~/.kube, ~/.gnupg, ~/.claude, ~/.claude.json and the hub .env).
  3. An environment built from scratch (headless.agent_env): PATH without hub or work-root entries, HOME (the keychain login needs it), the locale, offline git/npm/pip settings, GIT_CONFIG_GLOBAL=/dev/null, an empty GH_CONFIG_DIR and at most one Claude credential. CLAUDE_CODE_SUBPROCESS_ENV_SCRUB is deliberately NOT set: on 2.1.308 it forces the permission mode to default whatever --permission-mode and the settings say, so the posture the probe proves (dontAsk) would not be the one the run has. The credential variables are kept from Bash by the sandbox's credentials.envVars deny list instead, and the reduced posture has no Bash. ai-run's own process keeps the caller's environment, because on the maintainer's Mac PyYAML imports only through PYTHONPATH.
  4. A workspace outside the hub tree and inside the home fence: ~/.cache/jev/work/<run_id>/ (0700, JEV_WORK_ROOT overrides), so there is no CLAUDE.md walk-up into the hub and no nested clone for hub scanners; run records in the gitignored .fleet/runs/ (PR-B).

CI's allowlist is kept verbatim locally (npm, pip, node, python3 and the rest stay): dropping package managers would change the scout without reducing arbitrary-code risk, so containment rests on the sandbox and the absence of network, and offline installs simply fail. No network domain is allowed in P1; any future one is a per-domain, § 12.3-gated decision recorded with its exfiltration trade-off. --posture reduced (no Bash at all, same isolation) is the explicit fallback for a host without Seatbelt or bubblewrap and is never scheduled.

Proof before trust. Three checks, each failing closed (exit 4, outputs discarded unread):

  • the $0 flag preflight (preflight_parse): the real argv, which must carry -p and --max-budget-usd, with stdin /dev/null must answer "Input must be provided", which proves every flag parses, the hidden --max-turns included, on the installed CLI; nothing it prints or logs may report the --settings document skipped, because under -p a document that fails validation is skipped with nothing but a debug-log line. That check is negative (a debug log that was never written passes it): the positive proof that the document applied is the probe's (its read-fence line), and which settings keys the CLI honours (unknown keys are dropped silently) only the canary proves;
  • the $0 self-calibrating isolation probe (probe_isolation): both $0 checks run in probe_env, the run's own environment (agent_env) with no credential and a scratch CLAUDE_CONFIG_DIR, refused outright if that environment is logged in. The fixture plants a SessionStart hook, an env block, an output style, a .mcp.json server, a skill, a CLAUDE.md and an AGENTS.md, and the scratch config dir's user settings plant an env block. The control run must show the hook, the server, the output style, the skill and the user env key (2.1.308's CA-certs debug line lists the user settings' env keys, and only those), or the result is "detector stale". The isolated run must pass init_problems (exactly the spec's tool families, nothing never-grantable or outside GRANTABLE_TOOLS, dontAsk, no MCP server, no skill, the default output style), run no hook or server, apply no user env, and log the --settings document's read fence and "project memory is off". On 2.1.308 the read fence is a Sandbox: blockReadsOutsideWorkingDirectories: … stays under an existing denyRead line naming one of the document's own denyRead paths: the CLI logs no flagSettings line before a model call, and the line is absent without --settings or with an empty denyRead (#557). The reduced posture's document has no sandbox and so no such $0 proof; its probe fails closed. A third, restricted leg runs the isolation flags minus --safe-mode (which on its own drops hooks, MCP, skills and output styles) and must show the default output style: that proves --restricted itself ignores the project settings file, the one whose env block could carry ANTHROPIC_BASE_URL, since no $0 output names a project env key. Memory content reaching the model has no $0 check: it rests on the documented --safe-mode semantics and on the canary;
  • a per-run sandbox-engaged check and a one-time live canary of at most $0.10 API-equivalent (estimate) per CLI version and posture template (posture_template_sha: the settings document, the isolation flags with the spec's toolset, the environment's key set, the posture's name and any private read deny the work root lifts, so changing any of them invalidates a cached pass), which proves enforcement (home and secret reads, a private path outside home, network, writes outside the clone by a sandboxed command and by the Write tool, symlinks, no SECRET_ENV variable in the sandbox); it is also cached per credential exposure, because a canary on a stored login has no credential in claude's environment to hide. The canary and the pilot are implemented, and run only with the maintainer's approval (§ 10.5); no agent runs them.

Sandbox enforcement under -p with --restricted and --safe-mode has not been observed yet — every probe so far ran without a credential — so until the canary passes, a sandbox-posture run refuses rather than running untrusted repo code unproven.

Credentials (maintainer decision 5)

CLAUDE_AUTH_ORDER (else the hub's ai_auth: entry, else oauth,api_key). Within oauth: the env token, then the keychain login (claude auth status), then the hub .env value; within api_key: the env key, then .env. The .env is parsed for those two names only and never sourced. The first present credential is chosen once and the other is unset; nothing falls back in the run. A 429 is capacity: usage_limit, a warning, exit 0 under --usage-limit skip so the P2 console shows it as a warning and not red; the queue stops. A refused credential is credential_rejected, and a cancelled run is interrupted, never credential_rejected. Where a credential is chosen, the CLI's other auth inputs (ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL, CLAUDE_CONFIG_DIR, the provider switches) are removed too, so the run uses the credential that was checked. Neither is retried with the other method (#348's status quo; its decision stays with #348). The run records the method and source, never the value.

Publishing (maintainer decision 3): --apply is the yes

This differs from the design's exact-bytes gate (a plan id typed back on a TTY). A loop run … --apply typed by the maintainer is the § 13.6 "high waits for Amr's yes": the run still does its dry-run preview first — the exact issue bodies written to the run directory — and then files in the same run, with no typed-back plan id. The reasoning: the maintainer runs the command by hand, names the target, and can read the preview it writes; a second confirmation on the same terminal adds friction without adding a person. Review-then-file stays available: loop publish <run_id> --apply publishes a previous dry run's reviewed bytes, idempotently (publish-result.json), and refuses changed bytes or a second apply. The refusals that remain:

  • --apply with --scheduled is refused: no unattended local filing until § 13.7 earned autonomy exists;
  • the console and MCP stay unable to apply until the § 11 decision (#487); P1 adds nothing that lets them;
  • --apply refuses a dirty spec, adapter or engine (tools/jev/, _data/fleet.yml, ai-run, tools/dash-gen) unless --allow-dirty;
  • before filing, a live recheck runs: backpressure, the publish token probed with gh api user, and per-issue failure detection the way CI's file job greps gh issue create failed.

Implemented in PR-C.

Budget and budget hits (maintainer decisions 2 and 4)

_data/fleet.yml budget.loops: {monthly_usd: 25, scheduled_stop_pct: 80}, in the budget.jev shape, enforced through tools.jev.ledger.BudgetState over the AI ledger's origin: local rows that carry a loop field (a plain dash ai run row is origin: local too but has none, so hand runs never count against it), by UTC month; each attempt is still capped by budget.call_sites (scout $8), and test_ai_budget asserts loops + jev ≤ harnesses.budget.monthly_ai_usd. Every figure is labelled API-equivalent (estimate). A scout attempt that hits its budget is discarded locally (JEV's rule), a deliberate divergence from CI's file job, which files whatever a budget-hit leg left behind: a local rerun costs about $0.61, and the bytes a human reviews should come from a completed run. Implemented in PR-C.

Recorded local-vs-CI differences

No network, so dependency installs fail and the runner note says not to propose from that; symlinks in the clone are plain files; the target's CLAUDE.md is not auto-loaded (the scout prompt reads it); the target's .claude/ settings are never loaded, where CI's claude-code-action loads them; a budget hit discards the output.

§ 10.8, the alternatives for the executor

  • --bare: rejected — it never reads OAuth or the keychain, and the docs say it will become the -p default; the preflight and credential_rejected would catch that change.
  • claude-run/run.sh: only its per-attempt env -u credential isolation is ported (with_one_credential).
  • The Agent SDK: deferred; held in reserve for per-call can_use_tool gating.
  • anthropics/sandbox-runtime and a devcontainer: P5.
  • act and a self-hosted runner: no, for the reasons above.

Consequences of P1's executor

  • Positive: one executor and one ledger shape for every local headless run; no local run is free in the books; the agent's environment holds no GitHub credential by construction, and the flags, the settings document loading, the toolset, the permission mode, project hooks, the project settings file (the restricted leg), the user settings env, MCP, skills and memory-off each have a $0 check against the installed CLI (memory content and sandbox enforcement rest on the canary).
  • Negative: the detectors read the CLI's own output (init fields, debug-log wording, the preflight text), so a Claude Code update can turn the probe into "detector stale" until the maintainer re-runs it and the canary; local proposals can differ from CI's for the recorded reasons; the trace holds repository content and its redaction is pattern- and value-based, so it stays local and gitignored.
  • Outstanding: tools/jev/conflicts.py claude_argv (tiers 1–2) still builds its own argv without this isolation; it is switched off by jev.auto_tiers: [tier0] and is ported onto headless.py (follow-up 1) before tier1 or tier2 is enabled.

The engine, at $0 (PR-B)

python3 -m tools.jev loop (tools/dash loop) is tools/jev/loop.py with workspace.py and adapters/; the spec gains one optional key, local: (adapter, switch, planner, publish, on_budget_hit), which every P0 consumer ignores and steps check holds to the workflow's gating if:. This slice is list, doctor (no --live), plan, run --rehearse and show; a run without --rehearse refuses, so nothing in it can reach a model. Where it departs from the design, and why:

  • A rehearsal reports, a live attempt refuses. A missing isolation probe, a missing canary and a missing credential are notes under --rehearse and refusals (exit 4, 4, 3) for a live attempt (PR-C); a failed probe, an old CLI, no sandbox and a failed flag preflight refuse either way. The canary cannot exist before PR-C, so requiring it would make the $0 slice unusable.
  • The planned executor command is proven at $0. The rehearsal runs the exact tools/dash-gen ai-run command an attempt will run, as ai-run --dry-run, without its --prompt-file and on an empty stdin: ai-run's own parsing, passthrough refusals, call-site cap and credential choice are exercised, and even if --dry-run were ever ignored the CLI would answer "Input must be provided" before any request.
  • ai-run gets the chosen credential, the deterministic halves get none. The planner and the filer run with the user's environment minus every Claude credential (their gh auth reads GitHub); ai-run runs with it minus every GitHub and Claude secret and the SSH agent, plus the one chosen Claude credential, and builds claude's own environment from scratch with --isolate.
  • The harvest refuses a hard link as well as a symlink, a non-regular file, an oversize file and a real-path escape: a hard link to a file outside the clone passes every path check.
  • The gh and git guards are allowlists. A denylist kept missing spellings the tools still run: gh finds the verb past a flag (gh pr -R o/r merge) and takes aliases (gh secret remove), pflag splits -iXPUT into -i -X PUT, and git runs an alias, an autocorrected typo, send-pack, a :ref refspec set through -c and config passed by --config-env or the environment. So assert_no_admin passes only the gh <noun> <verb> commands JEV issues, read from the argv's first two words (a flag there is refused), and fails closed on gh api: every call but a GET, or an inline GraphQL query that is no mutation, is refused (a REST POST can merge, transfer or move a ref; gh POSTs implicitly once a field is added), with shorthand bundles read as gh reads them and an unknown shorthand refused. assert_safe_git passes only the subcommands, global options and -c keys JEV uses (none that undoes the wrapper's own hook, fsmonitor and pager settings), passes through env only the GIT_* names JEV hands git (an allowlist: a third review planted remote.origin.receivepack through GIT_TEMPLATE_DIR and GIT_COMMON_DIR, which a denylist had missed) and moves HOME or XDG_CONFIG_HOME only when the global config is /dev/null, holds clone, init, fetch, remote and git config writes to the options and keys JEV uses (a second review planted a delete refspec through a clone's own -c, remote add --mirror and include.path, the third a receivepack through init --template), and on a push refuses a force, mirror, delete or prune flag in any spelling and any refspec but an explicit <src>:<dst>, while common.git names git's own receive-pack and upload-pack on every push and fetch, so config that got in some other way is never followed. jev conflicts' own calls are unaffected. Both guard only the calls JEV makes itself: the planner and filer are dash-gen subprocesses, bounded instead by their argv templates, whose subcommands spec.py pins (PLANNER_COMMANDS, PUBLISH_COMMANDS) and which may not carry the apply flag or a prefix argparse would read as it.
  • The engine's git never reads an agent-touched .git configuration. The design's tamper baseline (config, HEAD, info/exclude, hooks) left commondir and a gitfile planted in a submodule directory, each of which makes a later git status run an agent-defined filter on the host, outside the sandbox; config.worktree and info/attributes cannot define a filter on their own but widen what a config change does. So every engine git call on a clone runs against a copy of the fresh GIT_DIR held beside the clone — its config, hooks, index and attributes, sharing only the object store through objects/info/alternates — with no global or system config (a .gitattributes the agent writes could otherwise name a filter from the user's own ~/.gitconfig), no attributes file and --ignore-submodules=all, and is refused when the baseline — now all of .git but its objects and index, plus the alternates files and any nested .git — has changed; a tampered clone is destroyed with no git run in it, even under --keep-workspace. A workspace is removed on any failure before it is handed back, a Ctrl-C included, and workspace.brief_dir must be a relative path inside the clone (the agent's TMPDIR is built from it). A target that commits the brief directory is refused (its file would be harvested as the agent's), a fork's upstream remote is removed, and destroy never chmods through a symlink.
  • The publish phases get their own bodies directories ({bodies_dir}: items/<dir>/bodies/ for the preview, filed/ for the apply), and scout-file --apply never clears one, so filing cannot overwrite or renumber the bytes a person reviewed. Item directories are keyed by the item, not the repo (workspace.item_dirname: <owner>__<repo> for a repo key, else the key's safe characters plus 8 hex of its sha256), so P3's per-marker and per-issue items fit without a layout change. A publish is matched to an attempt by the validated file's sha256, so a later run that reused and filed an attempt's outputs marks it published.
  • Planner flags are passed as --flag=value, so a free-text --focus that starts with - cannot read as an option.
  • Every refusal ends with its documented code and a closed record. A work root inside the hub is host safety (exit 4) for run as for doctor, checked before anything is planned or any CLI runs, and the rehearsal's flag preflight runs in a throwaway directory under the work root, never in the hub tree. A step with no local.switch refuses --scheduled (AGENTS.md: every scheduled loop has a kill switch), and a default-on switch reads "not found" as unset only once the hub repository is shown readable. An item that fails after its clone is that item's failure (exit 1) and the run goes on; a malformed or missing --plan-file is a usage error; any other error ends the record failed before its traceback, so no run stays running.
  • --json puts only the run record on stdout; the run: <path> line goes to stderr, so the console (P2) can parse stdout.
  • The sandbox posture requires macOS Seatbelt in P1 (sandbox-exec), as designed; Linux bubblewrap is a P4/P5 posture.

The budget block (budget.loops), the live attempt, the per-run sandbox-engaged check, loop doctor --live, the dry-run preview with scout-file --bodies-dir and the --apply gate recorded above are PR-C. scout-file --bodies-dir is new for the local runner and the runner uses the existing scout-file --offline as its $0 structural check; CI passes neither.

Attempts, the ceiling and publishing (PR-C)

loop run without --rehearse now makes one attempt per item through tools/dash-gen ai-run --isolate, held to budget.loops; loop doctor --live is the canary; loop publish and loop budget are new verbs. Maintainer decisions 2–4 are implemented as recorded above. Where PR-C departs from the design, and why:

  • The gate is the --apply flag (decision 3), and the exact bytes are still enforced. There is no typed-back plan id. Instead, before any write, apply_item refuses (exit 2) when publish-result.json already exists, when the validated file no longer has the sha256 the preview recorded, when any reviewed body in bodies/ changed, and when a live dry run into a scratch directory would file a body whose hash is not among the reviewed ones (a live dedupe that only drops a reviewed body files the rest). The plan id survives as a record and as an optional loop publish --plan-id pin, for the console after § 11. The same holds for what the bytes do not cover: a live dry run that would file a title or a label set that was not reviewed (scout's labels come from _data/fleet.yml at filing time), a publish argv that is not the reviewed one, or bodies that cannot be compared is refused too, and so are validated bytes another run already filed (History.published_run: a tier-0 reuse gives one attempt two previews, and only one is ever filed). The filing itself is held to the reviewed bytes too, not only the fresh dry run before it: the engine adds the filer's reviewed flag (spec.PUBLISH_REVIEWED_FLAGS, scout-file --reviewed-bodies <bodies/>) to every apply, so the filer skips any body that is not byte-identical to a reviewed one before it makes a label or an issue for it (the apply lists the open issues again, and an issue that deduped a proposal can close between the two lists), and files nothing when that list cannot be read (it used to file without the duplicate check). publish-result.json is claimed with O_EXCL before the filer runs, so a second or concurrent apply is refused even after a crash mid-filing. A filing that failed outright (no issue filed) is not recorded as published, so tier 0 reuses its validated copy at $0 in a new run and previews it again; a partial filing (some filed, some failed) counts as published, so tier 0 skips it until HEAD or the brief changes or --fresh is passed, and its failures are listed in publish-result.json and the run record.
  • loop publish <run_id> without --apply is read-only. The design re-ran the preview with a fresh dedupe; that would overwrite the bytes a person reviewed, so it compares instead: a live dry run into a scratch directory, reported as "matches" or "differs".
  • The token is probed before any spend. Under run --apply the publish token is resolved (FLEET_TOKEN from the environment, then the hub .env, else the ambient gh login) and probed with gh api user before the plan, so a refused token exits 1 having spent nothing; loop publish --apply probes it again. It reaches the filer as GH_TOKEN in that one subprocess.
  • The per-run check covers the whole posture, not only the sandbox line. Before any output is read: the clone's tamper baseline (a tampered clone fails its item, exit 1, destroyed with no git run in it, and the run goes on); then no user settings env keys in the debug log; the session's init held to init_problems (the probed toolset, dontAsk, no MCP server or skill, the default output style), and a session that reported a result or a tool use without an init record is unverifiable (a cap estimate alone is not evidence: a wall clock before init or an ai-run that died fails as attention); Bash under the reduced posture; Bash that executed — the per-tool permission denials are subtracted, since a denied call never ran — without the sandbox line, with a read: none or write: none fence on any wrapped command, or under the CLI's relaxed filesystem policy. So does an outcome whose credential (method and source) is not the one the host check chose: ai-run is pinned to that choice with --auth-source and refuses rather than falling through to the next source, since a canary passed on a stored login proves nothing about a hub .env token in claude's environment, and the engine checks the outcome's auth as a second layer. Any of these stops the run with exit 4, the outputs destroyed unread. The --settings document pins sandbox.filesystem.disabled: false against a remote relaxed policy (a managed one still wins, which the fence check catches) and read-denies this account's Claude temp roots (/tmp/claude-<uid>, and claude-<uid> in the per-user temp directory; the agent's own CLI temp root moves into the clone with CLAUDE_CODE_TMPDIR), the per-user temp directory and a JEV_DOTENV file outside the hub; a work root inside a Claude temp root is refused (exit 4, like one inside the hub), since the deny on the root that holds the work root is left out. A work root in the per-user temp directory itself is accepted and lifts that directory's deny (its Claude root stays denied); the posture template records the lifted deny (lifted_private_reads), so such a work root has its own probe and canary cache key and never reuses a pass proved with the full deny list.
  • The canary checks the environment with python, and each command is matched to its call. The scout allowlist has no env, so the six Bash commands are cat and python3 -c one-liners (read the secret, open a socket to example.com:443, write beside the secret, count the SECRET_ENV variables by exact name, read a second copy of the secret planted in a read-denied private path outside home), all inside the step's own allowlist, plus a Write outside the clone (Write runs outside Seatbelt, so its confinement is --restricted's). The judge pairs each command with the Bash call that ran it and requires a sandbox result, matching the paths as ai-run's trace wrote them (its redactor writes $HOME as ~, and the canary directory is under $HOME by default) while the files left on disk are checked by their real paths; a skipped, unanswered or permission-layer-refused command is inconclusive, and a symlink Read must succeed and name its target, since a refused Read naming the target is what a followed symlink gives. The canary runs under the run's own credential and is cached per credential exposure (loop.canary_key), so a pass on a stored login never unlocks a run that puts CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY in claude's environment. It runs with the step's own isolation flags and settings document, only --model (claude-haiku-5-5, refused unless it is in ai_models.allowed) and --max-turns (12) swapped, so the posture template hash it is cached under is the one a run checks. It is ledgered like an attempt (loop, item: canary), so it counts against budget.loops, and it is not run (exit 1) when the month cannot absorb its $0.10 or another attempt holds the budget lock.
  • A live run --offline is refused: an attempt needs its clone and a live dedupe; --offline stays for plan and --rehearse.
  • The ceiling fails closed, and only where money is spent. An attempt runs only when spent + the step's full call-site cap ≤ the ceiling (the cap, not the typical ~$0.61), asked just before the model call, after tier 0 (so a $0 reuse or skip is never blocked at the ceiling), against a fresh read of the ledger under a lock beside it that is held until ai-run has ledgered the attempt (so concurrent runs of any step, from any checkout, and the canary cannot overshoot it together); an AI ledger that exists but cannot be read (not JSON, not an object, another version) refuses rather than reading as an empty month, and the ledger's writers (dash ai, the collector, record_run) now refuse to overwrite one instead of replacing it with their own rows; and an attempt that left no ledger row (ai-run died, the backstop killed it, or its ledger write failed) is charged at the cap by the engine, durably, in <ledger>.loops-unledgered.jsonl beside the ledger, which budget_position counts for every attempt id the ledger lacks, so later runs and the canary see it. The writers' refusal says to repair or migrate the ledger in place, never to move it aside, which would read as an empty month. ai-run is handed exactly the cap the ceiling was judged on (--max-budget-usd beside --call-site), so an edit to _data/fleet.yml during a run cannot raise it. A usage window spent earlier in the run is checked after tier 0 too: it stops model calls, not a $0 reuse; and a lock another attempt holds (budget-locked) or an unreadable ledger (budget-unreadable) is not reported as the ceiling.
  • An interrupt is recorded, not lost. A SIGTERM or SIGHUP to the engine (the P2 console's cancel, a closed terminal, a kill of its pid) is turned into the same KeyboardInterrupt as a Ctrl-C and passed on to ai-run as SIGTERM, even when it reached the engine alone, so ai-run always runs claude's SIGINT-first ladder; the engine then waits, through any second cancel, for ai-run's outcome and ledger row before it destroys the clone and ends run.json interrupted (exit 130) instead of dying at running. The item in flight is appended to the record with what it was charged, so the totals, summary.md and the CLI line match the ledger. A tier-0 reuse whose preview or live recheck fails is that item's failure (exit 1), as on the attempt path, not a refused run.
  • Tier-0 reuse re-hashes. A reused attempt's validated copy is copied into the new run only when it still has its recorded sha256; otherwise the item is attempted afresh. A reused item goes straight to a fresh preview, so its bytes are reviewed (or filed under --apply) like a new attempt's.
  • The stale $75. docs/JEV.md, tools/test_jev_ledger.py and the budget.jev comment in _data/fleet.yml named a $75 fleet ceiling; harnesses.budget.monthly_ai_usd is $200. All three now point at that key, and the test reads it instead of copying it.

The canary and the pilot (loop run repo-scout --target SCHEMA, ocrmd the alternate) are implemented and were not run: they are the maintainer's approved deploy step under § 10.5, in the order doctor ($0), doctor --live (≤ \(0.10), plan (\)0), one dry run (about $0.61 API-equivalent, estimate; $8 cap), a review of publish-plan.md, and optionally loop publish … --apply.

P1 amendment — the per-run evidence model on Claude Code 2.1.308 (maintainer decision 4c, 2026-11-03)

The first live canaries (bamr87/bamr87#560, found in #486's deploy step after #557 and #559) ran end to end on 2.1.308 and were judged failed although the sandbox enforced every test it reached: the judge was miscalibrated, and the per-run check would have failed every live Bash attempt. The maintainer chose option 4c — both: find the switch that makes 2.1.308 log the per-command line, and add the configuration-loaded evidence to the per-run check. Decisions, each with its test:

  • The per-command line is the sandbox runtime's, on stderr, under SRT_DEBUG. The [Sandbox macOS] Applied restrictions - network: …, read: …, write: … line is written by the sandbox runtime's own logger ([SandboxDebug] prefix), which on 2.1.308 prints to stderr only when SRT_DEBUG is set in the CLI's environment and never to --debug-file; the switch was found in the CLI bundle at $0, not by trial sessions. agent_env sets it (a new key, so the posture template's hash changes and every cached probe and canary is invalidated, as designed), stream keeps every [Sandbox… stderr line in Invocation.sandbox_lines (redacted, at most STDERR_KEEP_LINES), ai-run writes them to the outcome file, and posture_lines joins them with the reduced debug log for the per-run check and the canary. A line in the debug log (an older CLI) is still accepted; no line from either source for a Bash that executed fails closed (exit 4), as before.
  • Both layers, each failing closed. The per-run check now also requires the session's own --settings read-fence line (settings_fence_problems: the positive proof the document's rules applied to this session, the same line the probe proved credential-free) and no skipped-document line — option (b)'s evidence — and still requires the per-command line with both fences — option (a)'s. A canary pass for this CLI version, posture template and credential exposure stays the gate before any live attempt.
  • Network (item 1). The canary's socket command prints 'NET=' + 'open', and _printed drops the source line a Python traceback quotes (the line after each File "…", line N frame) before the judge reads a result, so an echoed literal is never a network success while a real NET=open line, itself a substring of the command, still is.
  • The outside-home read (item 2). The canary gains command 7, a python read of the private path outside home, the twin of the cat in command 6, as command 2 is the twin of command 1 (CAT_TWINS). Under dontAsk with blockReadsOutsideWorkingDirectories the permission layer refuses cat before Seatbelt sees it: such a refusal is layer-1 evidence only when the python twin reached the sandbox and was refused there (an error or a denial wording, not a permission-layer wording); otherwise the cat is inconclusive, as before.
  • The Read tool (item 3). The planted files are fixture.txt, not secret.txt, and the prompt says every file it names was created by the self-test and that attempting each step is the test; the attempt is still required (inconclusive is not a pass) rather than inferred from the Write test.
  • Not changed. The shell snapshot the CLI writes into the real ~/.claude/shell-snapshots/ before its first Bash call (observed in #560) is outside this record; SECRETS=0 shows no credential variable reaches the sandbox.

Tests: tools/test_jev_headless.py (the 2.1.308 traceback echo, the permission-twin rule, posture_lines, settings_fence_problems, the stderr capture and its cap, SRT_DEBUG in the environment), tools/test_jev_loop.py (the engine reads the stderr evidence and an older CLI's debug-file line alike; a session without the read-fence line stops the run with 4) and .github/scripts/dash-gen/test_ai_run.py (the outcome file carries the lines, redacted).

P3 amendment — the canary's probe grants (2026-11-03)

The first live canary for fleet-pulse/doctor was judged inconclusive: the doctor's allowlist grants cat but no python3, so five of the seven probe commands were refused by Claude Code's permission layer before Seatbelt saw them, and the model stopped after two refusals. The probes test the sandbox, which wraps every child process alike, so canary_flags now appends CANARY_GRANTS (Bash(cat:*), Bash(python3:*)) to --allowedTools when a step's allowlist lacks them, and nothing else: the settings document, the isolation flags, the tool families (--tools, which the init record is held to), the deny list and the environment stay the step's own, so the posture-template key stays honest; the verdict's grants_added records the addition. A posture with no Bash gets no grant (the canary refuses under reduced). Test: tools/test_jev_loop.py (the grants per step and an end-to-end doctor canary in the box).

P3 — repo evolution (step 2)

  • Status: accepted
  • Accepted in: https://github.com/bamr87/bamr87/pull/641 (merged 2026-11-04 by @bamr87)
  • Date: 2026-11-03
  • Scope: the second step of bamr87/bamr87#488 — repo-evolution.yml job evolve, step evolve, as a spec (tools/jev/steps/repo-evolution/evolve.yml + evolve.prompt.txt) and on the local loop runner (repo_evolution_evolve adapter, dash-gen targets --out-dir … [--offline], dash-gen evolve-file); agent-fill and the issue-pipeline tiers follow, one pull request each, appending here

What evolve is that the doctor was not

  • Four matrix tokens, and the prompt stays inline. The prompt names its repository, branch and brief through ${{ matrix.nwo }}, ${{ matrix.name }}, ${{ matrix.branch }} and ${{ matrix.brief }}; the spec declares them as {{NWO}}, {{REPO_NAME}}, {{BRANCH}} and {{BRIEF}} (inputs, the plan row's keys). The workflow keeps its prompt: | inline with the expressions in their places — the form parity already accepted for scout when it is byte-equal to the spec rendered with the matrix expressions — so CI's behaviour did not change, no runtime render step was added (the $GITHUB_OUTPUT newline hazard the doctor recorded), and the evolve step pins JEV_STEP_SHA256. dash-gen targets still carries the spec's render in every plan row (include[].prompt), as scout's and the doctor's planners do, so the local engine's check_plan_prompts holds the planner to the spec too.
  • The target is the checkout (workspace.cwd: target, as scout): CI checks out matrix.nwo at matrix.branch; locally every item's clone is the row's repository, and the brief lands in .evolution/ (brief_dir), where the prompt reads it.
  • The step holds a read-only token in CI (workspace.github_credential: fleet-read): FLEET_TOKEN as GH_TOKEN in the step's env, for the gh issue|pr view|list, pr diff and run view|list verbs the allowlist grants on private targets, and no other route (no github_token input, so app-token stays a declared gap beside setting-sources). The posture is named with its exact route (CREDENTIAL_SITES), and parity holds the step to it: a github_token input appearing, a second token in the env, or GH_TOKEN going missing is a drift. The local engine hands the agent no credential under any posture; the brief already lists the issues and PRs the prompt would read.
  • The agent's edits are the output (local.harvest: patch), and the report is the body. CI's publish step commits the checkout as bamr87-bot, pushes <prefix>/<yyyymmdd>-<run id> to an explicit URL derived from the matrix nwo (bamr87/bamr87#220, after a push once went to the hub), and opens a draft PR whose body is the marker line, the agent's final message and a footer. The adapter reproduces that document step for step: the engine's changes.patch with the lockfiles CI's publish step drops removed (and the drop flagged), the final result text — or CI's _The agent left no summary — review the diff._ — behind the marker line, CI's footer naming the run and the brief, the branch <prefix>/<yyyymmdd>-local-<run id>, and remote: https://github.com/<nwo>, which the filer refuses to see changed. A refused publishing command in the trace (git push, git checkout -b, gh pr create) is flagged for the reviewer, never filed. A body or patch carrying a local path or the host name is withheld.
  • An empty pass is a valid result. CI writes "No changes — no pull request opened" and opens nothing; the prompt says an empty pass is better than a risky change. The adapter writes kind: none (no patch, no branch), the filer's dry run reports it skipped with that reason, and the item is previewed with nothing to file, not rejected. A lockfile alone is no change.
  • on_budget_hit: publish-flagged (bamr87/bamr87#238). CI's publish step, when it runs after a budget abort, writes a warning block first: the pass was stopped mid-task, the diff is partial by construction, the agent's verification never ran. The format gains publish-flagged beside discard: a budget_hit session's edits are harvested, validated and previewed with that block first and flagged: true on every row — nothing is filed without --apply, and the maintainer sees PARTIAL before anything else. A max_turns session is still discarded, under either value: CI's Salvage a successful overshoot step publishes only a reported success (subtype == "success" and is_error == false), which ai-run classifies as ok here, so a genuine turn exhaustion reaches no publish step in CI either; whether it should is #238's open question, not this record's. The engine's branch for any other value stays fail-closed.
  • Exact ids and literals. _data/fleet.yml gained evolution.model: claude-opus-5-5, the home the spec references; the workflow's --model opus became that literal and --max-turns ${{ needs.plan.outputs.max_turns }} became --max-turns 120, the literal of evolution.max_turns (the run summary reads the figure from plan.json itself; the plan job's max_turns output and its jq fallback, which nothing read after that, were removed in the review round). test_evolution.py reads the hard rules from the spec's render and holds both literals to fleet.yml; test_ai_budget.py already read a literal first.
  • The planner's --offline. dash-gen targets --offline (the engine's rehearsals and loop plan --offline) makes no GitHub read and marks every row's dedupe unavailable, so a local --apply refuses until a live plan; --no-dedupe (CI's force) keeps marking rows off.
  • --apply is refused in this release. dash-gen evolve-file is a complete dry run (the exact body bytes, the patch, the open-pass dedupe in the target by branch prefix or marker, the structural rules, the #220 remote guard); with --apply it exits 2 naming #488 and files nothing. The publish step — the branch pushed to the target with FLEET_TOKEN probed by gh api user, and the draft PR with its labels — is #488's next pull request, after the write path #487 settles.

Review round (2026-11-04)

  • The turn cap is not a console knob. evolution.max_turns was editable from the console's Config page while the workflow carried the literal: an edit there changed nothing at run time and failed steps check. The field left the console's editable set (the Contract page explains where the pair lives); a change is a pull request that moves fleet.yml and the workflow together, as the doctor's remediation.max_turns already is.
  • The lockfile rule is CI's rule, from one list. CI's publish step drops only UNTRACKED lockfiles (git ls-files --others); the preview had dropped every lockfile section, a tracked Gemfile.lock the agent updated included, and could report a pass as empty that CI would have opened. drop_lockfiles and the filer now drop only sections that create the file, and both read the policy from _data/fleet.yml dependencies.lockfile_patterns (the list test_evolution.py holds CI's grep to) instead of hand-copied lists; a diff --git header is parsed by a shared reader that accepts a path with a space and git's quoted form, so no section can ride inside its neighbour's.
  • The plan's figures follow --config. dash-gen targets --config PATH had printed the hub's real model and max_turns whatever the given config said; the spec is now resolved against that config.
  • What --apply does is the adapter's sentence. publish-plan.md had described every filing as labels plus gh issue create; the adapter contract gained apply_steps(ctx, item, plan) (the hook PR #642 also adds, same signature), and evolve's names the branch push to the item's remote and the draft PR. The dead failures the evolve adapter copied from scout is gone, and the three adapters' shared helpers live in tools/jev/adapters/common.py (one widening: the local-artefact wording now includes Claude Code's dontAsk refusal for scout too, a flag, never a rejection).

Out of scope here, with the reason

As the doctor's record says: claude.yml, fleet-verify and ai-lane / claude-run stay out; fanout.yml:agent-fill and the three issue-pipeline tiers follow in their own pull requests.

P3 — the fan-out agent fill (step 3)

  • Status: accepted
  • Accepted in: https://github.com/bamr87/bamr87/pull/640 (merged 2026-11-04 by @bamr87)
  • Date: 2026-11-03
  • Scope: the third step of bamr87/bamr87#488 — fanout.yml job agent-fill as two specs (tools/jev/steps/fanout/agent-fill-standardize.yml + .prompt.txt, agent-fill-schema.yml + .prompt.txt) and on the local loop runner (fanout_agent_fill adapter, dash-gen agent-fill --kit <kit>, dash-gen agent-fill-file); evolve and the issue-pipeline tiers follow, appending here

What the agent fill is that the doctor was not

  • One spec per kit, one step per kit. The brief was a shell case over two quoted heredocs written to $GITHUB_OUTPUT, and a spec holds one prompt whose tokens are single-line values, so a kit's brief cannot be a token. Each kit's brief is its own spec pair and its own claude-code-action step (fill-standardize, fill-schema), gated on inputs.kit, with the brief inline and byte-equal (parity holds each step to its spec; test_jev_spec.py pins both at their heredoc bytes of 3b30f87 — plus the one final newline $GITHUB_OUTPUT dropped). Both share the job's call site and cap (fanout.yml:agent-fill, $10) because only one runs; the cost step reads whichever did (steps.fill-standardize.outcome == 'skipped' && steps.fill-schema.outcome || steps.fill-standardize.outcome). The alternative, a ${{ steps.brief.outputs.prompt }} render with a per-kit JEV_STEP_SHA256 expression, would have needed parity to read expressions for both and was rejected.
  • The prompt is the whole work order (workspace.no_brief: true): nothing is downloaded in CI, the planner's rows carry no brief, the engine places none, and the context pack is off — a pack reaches the agent through a pointer appended to the brief's copy, so with no brief there is nothing to point from (the loader refuses no_brief with a brief_file or a pack mode other than off); parity requires no download-artifact step of such a spec. The planner is registered with a brief pattern all the same (agent-fill-workorder-*.md), reserved and never emitted.
  • CI's behaviour changes in two explicit ways, recorded here. The step passed no --model (ADR line above: "needs one before parity can pass") and no --allowedTools; it now carries --model claude-sonnet-5-5 (the new _data/fleet.yml agent_fill.model; the CLI's own default ran before, a read-and-edit task of this size sits with Sonnet, the scout's model) and --allowedTools limited to reading the repository, editing (Edit, Write) and the schema kit's own gate (python3 tools/schema_lint.py): no gh, no git push, no network. Everything else — the prompt bytes, --max-turns 25, the $10 cap, the job's gating, the push step — is unchanged.
  • The credential posture is none, honestly qualified. Parity's detector sees no token on the step (no env, no input, no resolve-fleet-token) and both action gaps open (app-token, setting-sources), declared as scout declares them. The job's checkout runs with token: secrets.FLEET_TOKEN and default persist-credentials, so the clone's git config holds that token for the later push step — a route the detector does not model. The explicit allowlist grants the agent no push and no gh; closing the route (persist-credentials: false, an explicit token on the push step) is a CI behaviour change left to the follow-up that closes the other gaps.
  • The target at the kit's branch is the workspace (workspace.cwd: target), as in CI: the pass fills the scaffold the fan-out seeded on chore/standardize-baseline / chore/schema-adoption. The planner (the fan-out's own target list: bamr87-owned, non-archived registry entries; --target picks one by name, slug or nwo) checks online that the branch exists and carries no (Claude agent pass) commit yet — CI's dedupe is the commit its push step makes — and skips what cannot or need not run; --offline emits every target with its branch state unknown. On 2026-11-03 no fleet repository carries either kit branch (the earlier fan-outs merged and deleted them), so the live pilot waits for a fan-out with dry_run=false; the $0 rehearsal ran through the offline planner (--rehearse --offline: the prompt, settings and argv, no clone).
  • The agent's edits are the output, held to the brief (local.harvest: patch): the adapter parses the harvested patch's diff --git headers and withholds the whole attempt when any touched path is outside what the kit's brief allows (standardize: CLAUDE.md alone; schema: SCHEMA.md files anywhere, a deletion included) — in CI such an edit would have been pushed. dash-gen agent-fill-file then runs the structural rules (the kit's branch and commit subject, the declared files equal to the patch's own, no credential shape, size) and writes the exact patch and commit message the push step would make; its --apply is refused (exit 2, naming #488) until the publish step — the validated patch committed as the (Claude agent pass) commit and pushed to the kit's PR branch with FLEET_TOKEN probed by gh api user — lands.
  • A step without a kill switch. fanout.yml is dispatch-only (no schedule), gated on the dispatch's own agent_fill input, so the specs declare no local.switch; --scheduled is refused for them as the format already provides, and loop list now says so instead of printing None.

Out of scope here

The push step's credential route (above), on_budget_hit: publish-flagged (evolve's, step 2), and the issue-pipeline tiers.

Review fixes (2026-11-04)

  • Both sides of every diff --git header count. patch_files (the adapter and the filer alike) read only the b/ side, so a rename whose destination the brief allows (README.md → CLAUDE.md, which git prints as one header with rename from/to) hid the deletion of its source. Both paths of every header are held to the brief now, so a rename or a deletion of a file the kit does not allow fails the check; git's quoted-path form ("a/docs/caf\303\251.md", C-style escapes, either side) and unquoted paths with spaces are parsed, and a header the parser cannot read (a bad escape, an octal above 255, a NUL, trailing text, missing prefixes) withholds the whole attempt rather than passing a path the check cannot see. The two copies are held equal by the adapter suite's agreement test.
  • A recheck never writes into the run's plan. RunContext.planner routes every targeted call (the live recheck of one item) into a scratch directory whatever the planner's flags; before, only a planner with a no_files flag was routed there, and the agent-fill planner, which has none, overwrote plan/plan.json with its one-target plan so loop publish lost the run's other items.
  • No brief, no pack, whatever --context says. context_mode returns off for a workspace.no_brief step, so the CLI override can neither build and place a pack nothing points at nor block the item under require; the spec loader's invariant holds at run time too.
  • The host name is matched as a token or a path component, never inside a word (host_mentioned): a Mac named work, main, home or mini no longer withholds a patch that says workflow, def main, homepage or minimal, while /Users/work/x, work.local and user@work are still withheld. The evolve step carries the same matcher in the shared adapter helpers; the agent-fill adapter adopts that helper once both land.
  • One spec loader. The planner reuses evolution.step_spec (the hub root appended to sys.path, so dash-gen's own modules keep precedence) instead of a second loader that inserted it first; the unreachable "N files in the patch" flag and the /dev/null branch of the old header parser are gone.

P2 — the write path (option (a) of #487, the agent's recommendation of 2026-11-03; the maintainer's merge decides)

Issue #487 held the loop runner's apply from the console and the MCP behind a § 11 decision: (a) a clarifying amendment that scopes § 11 to the Projects editing service and names the OPS remote-write path as sanctioned, or (b) routing every loop-run write through gh_projects_write plans (an issue.create and a draft pr.create in its allowlist, and P2 and P3 waiting on #472). The maintainer had not picked (a) or (b); under the 2026-11-03 instruction to continue the epic's remaining work, the agent recommends (a) and built it, so that the maintainer's merge of the amendment PR is both the choice and the ratification (§ 12.3). The record is docs/amendments/proposed/ops-remote-write-path.md (numbered at merge) and the constitution gains § 11.8; what it sanctions is the shape P1 already built: the op marked remote and run only with confirm=true (the § 13.6 yes; --apply typed on a terminal is the same yes), one such job at a time under the job manager's remote lock, a dry run first and only its reviewed bytes filed, the token resolved as the engine does and probed with gh api user before any spend, the same filer CI runs with GH_TOKEN in that one subprocess, never with --scheduled, every write in the run record and the job document.

  • The console's loop-run op takes apply (and run_id, which maps to tools/dash loop publish <run_id> [--item <name>] --json; without apply that is the read-only "matches / differs" check). apply is a remote write, so JobManager.submit refuses it without confirm, and the job document says confirm: write; apply with rehearse and any scheduled parameter are refused at the op, and the op never passes --scheduled. The TUI and the fleet MCP (console_run) reach it through the same job API, so no new surface bypasses the gate.
  • dash-gen doctor-file --apply --reviewed-bodies <dir> publishes the doctor's reviewed dry run the way CI's Step 3a/3b/3c would, and nothing else: the open-marker lists must be readable (remediation.open_markers reads a failed gh … list as empty, so the filer probes gh issue list / gh pr list itself first; exit 3 and nothing filed otherwise), the body and the patch must be byte-identical to the reviewed preview's (<slug>.md / <slug>.patch; otherwise the item is withheld, which the adapter reads as a failure), the token is probed again with gh api user (exit 3 otherwise); then for a pr: gh repo clone into a scratch directory (never the hub checkout or a submodule working tree), git checkout -b <branch>, git apply --index of the reviewed patch, a commit as fleet-doctor <fleet-doctor@users.noreply.github.com> (a noreply identity, so push protection never sees a private email), ONE push of HEAD:refs/heads/<branch> with --receive-pack=git-receive-pack pinned and credential.helper=!gh auth git-credential (the credential comes from gh — GH_TOKEN in the filer's environment, the engine's probed FLEET_TOKEN — and is never in argv or a URL), then gh pr create --draft --base <base> --head <branch> with the fleet-doctor and automation labels (created with --force first, as the scout's filer does); for an issue: the labels, then gh issue create. A failed push or create is a skipped row whose reason says failed, which the adapter reads as a failure (publish-failed), and the scratch clone is removed whatever happens. The boundary test holds the filer to exactly one push, with the refspec, the pinned pack program and the credential helper on it, and to no --force, --mirror, --delete, merge or close.
  • The plan document names the apply steps. preview() records ctx.adapter.apply_steps(ctx, item, plan) in publish-plan.json, and publish-plan.md's "What --apply does" renders them; an adapter that returns None keeps the engine's default text (labels, then one gh issue create per body). The doctor's steps say the clone, the branch, the one push and the draft PR, or the issue.
  • Not changed. gh_projects_write.py's ALLOWLIST (option (b) is not taken); the engine's publish gate itself (apply_item: the result claim, the live recheck, the review gap, the fresh dry run); CI's doctor job.
  • The publish route names a preview by its item key (review, 2026-11-04). The console op's run_id route took --item <target> with a registry name, which loop publish --item never matches (previews are keyed by the engine's item key: owner/repo, or owner/repo:path for the doctor); the op now takes item for that route, held to the key shape (no shell metacharacters, no ..), refuses target beside run_id and item without it, and the form, the MCP table and the README say so.
  • --apply is refused before any spend where the filer cannot file. spec.PUBLISH_CAN_APPLY names the filers whose apply flag files today (scout-file, doctor-file); ArgvTemplate.can_apply reads it, loop.apply_refusal refuses run --apply and publish --apply for the others as usage (exit 2, naming #488 and the dry-run command) before a clone, a token probe or an attempt, loop list says so per step, and the console surfaces can_apply in agent_steps so the page disables the box and the op refuses it the same way. Until then evolve-file and agent-fill-file took the flag only to refuse it after a full capped attempt.
  • The PR's base is the target's registry branch, written by the adapter. The doctor's validated document carries base: item.branch (the planner's row, the hub's branch for a hub fix); the filer's problems() requires it for a PR, checks that branch out in the scratch clone before creating the fix branch, and opens the PR with --base set to it — never an assumed main.
  • Labels before any write, and the fix branch checked before the one push. ensure_labels runs before the clone and refuses the item (exit 3, nothing pushed, nothing created) when a label cannot be created, since a gh pr create --label failing after the push would strand the branch; open_pr reads git ls-remote --heads first: a fix branch already on the remote is reused without a push when its tip is this run's commit (the title as subject, the run URL in the trailer) and refused for a human when it carries anything else, so a push is never rejected non-fast-forward and never forced.

Supersedes / Superseded by

  • Supersedes: none
  • Superseded by: none

P3 — the fleet doctor (step 1)

  • Status: accepted
  • Accepted in: https://github.com/bamr87/bamr87/pull/637 (merged 2026-11-03 by @bamr87)
  • Date: 2026-11-03
  • Scope: the first step of bamr87/bamr87#488 — fleet-pulse.yml job doctor, step fix, as a spec (tools/jev/steps/fleet-pulse/doctor.yml + doctor.prompt.txt) and on the local loop runner (fleet_pulse_doctor adapter, dash-gen remediate --plan-dir, dash-gen doctor-file); evolve, agent-fill and the issue-pipeline tiers follow, one pull request each, appending here

What the doctor is that scout was not

  • No caller-filled part. The queue reaches the agent as the work order it reads, so the prompt has no token. The format allows inputs: {} (a render is the file's own bytes); null and a non-mapping stay refused. The workflow keeps its prompt: | inline, which the format already accepted while byte-equal to the spec; steps check fails either copy edited alone, and the fix step pins JEV_STEP_SHA256. A runtime render through a job output was rejected for this step: $GITHUB_OUTPUT carries a multi-line value without its final newline, so the byte identity the P0 format rests on would have to be proven on a live run rather than by the gate. The P4 keep-or-convert decision (base-action with prompt_file) is where the inline copy goes away.
  • The checkout is the hub (workspace.cwd: hub): CI's doctor works in the hub checkout and clones a submodule only to push its fix. Locally every item's clone is the hub, named by the plan row's nwo; the candidate's repository is the row's repo. Parity requires the job's first checkout to be the hub.
  • The brief has a fixed name (workspace.brief_file: remediation-workorder.md): the prompt reads it in the checkout root. CI downloads the artifact with no path; the engine places the item's brief there, git-excludes it and refuses a target that commits that name. brief_dir (.doctor) stays the engine's own: the agent's TMPDIR and the context pack, beside a pointer appended to the brief.
  • The step holds a token in CI (workspace.github_credential: fleet-write): FLEET_TOKEN as FLEET_WRITE_TOKEN in the step's env and the resolve-fleet-token probe's winner as its github_token input. v1 knew only none; the posture is named with its exact routes (CREDENTIAL_SITES), and parity holds the step to those routes and no others, so a token cannot drift in or out of the step unnoticed. app-token is therefore closed for this step (the action mints nothing when given a token); setting-sources stays declared. The local engine hands the agent no credential under any posture: the environment is built from scratch, gh, git push, git remote and git config are denied, there is no network, and the publish step (the filer) holds the token behind --apply — § 13.8's trifecta is cut at every leg locally, as the posture table in docs/JEV.md records, whereas CI's doctor meets it ungated (private data: the token and fleet run logs; untrusted content: failing repositories' logs and workflow files; the send: a push, a PR, an issue with that token). That CI gap is the step's declared risk, not something this phase changes.
  • The agent's edits are the output (local.harvest: patch): the doctor keeps no file output; in CI it pushes. Locally the engine diffs the clone against the fresh HEAD with its own git (the pristine GIT_DIR, as everywhere) into outputs/changes.patch, tracked edits and new files, and discards nothing. Because Step 3a of the prompt branches and commits, the tamper baseline for such a workspace leaves out what git's own branch, add and commit write — HEAD, the ref and log files, packed-refs, the merge and rebase state files — and keeps config, hooks, info/ and the object redirects; the engine's git never reads the agent's refs, so a change there steers nothing. A step with declared outputs cannot be a patch step.
  • The filing is what the agent asked for. The prompt orders gh pr create / gh issue create; locally the permission layer refuses them and the call stays in the trace. The adapter reads it back (shlex, as gh would parse it) as the title and body, holds the MARKER line first (CI's dedupe), takes the branch from the session's git checkout -b or derives fix/fleet-doctor-<slug>, withholds a body or patch carrying a local path or the host name, and flags a body resting on a sandbox denial. A hub fix with no filing call is synthesised from the result text and flagged; a submodule candidate cannot be cloned offline, so Step 3b fails and the preview is the Step 3c issue the agent fell back to — never a hub PR for a submodule file. Nothing to file is rejected. --body-file is not followed (the file is not harvested): the body is then the marker alone, flagged.
  • One candidate per attempt. CI's doctor works the whole queue in one session. dash-gen remediate --plan-dir builds the same queue (the same guards, dedupe, billing and existence checks) and emits one item and one brief per selected candidate, in the CI work-order format; --target picks one candidate by its marker key, owner/repo/workflow or the file stem regardless of the cap; --offline makes a network-free plan for rehearsals. Each brief carries an Evidence section the planner fetches with the operator's own gh: the --log-failed dump filtered with the prompt's own filter and clipped, the workflow definition, a slow run's step timings — what Step 2 of the prompt would read, because the attempt's shell cannot. The prompt is unchanged; the brief is the planner's. The remediation.enabled switch gates the local planner (CI's gate is vars.FLEET_PULSE_ENABLED, held equal by steps check).
  • Exact ids. _data/fleet.yml gained remediation.model: claude-opus-5-5 and remediation.max_turns: 240, the homes the spec references; the workflow's --model opus became the literal id (a no-op on first-party auth, § 13 no-op claim above). test_fleet_pulse_doctor.py now reads the prompt from the spec and holds the inline copy and both literals equal.
  • --apply is refused in this release. dash-gen doctor-file is a complete dry run (the exact body bytes, the patch, the open-marker dedupe in the hub and the target, the structural rules); with --apply it exits 2 naming #488 and files nothing. The publish step — a fix branch pushed with FLEET_TOKEN probed by gh api user and a draft PR, or the hub issue, each carrying the MARKER line — is #488's next pull request, after the write path #487 settles. loop run --apply therefore ends with the filer's refusal or the live recheck, the preview on disk.
  • The ceiling. An attempt needs budget.loops to afford its full call-site cap; the doctor's is $40 against a $25 pilot ceiling, so no doctor attempt could ever run. budget.loops.monthly_usd is raised to $50 (scheduled_stop_pct 80 → a scheduled run stops at $40), a maintainer decision reviewed in the P3 pull request; lowering the doctor's shared cap would change CI, which this phase does not.
  • loop doctor [loop [step]]: the host checks and the canary are per step (each posture template differs by its toolset), and an operator can run one step's alone.

Out of scope here, with the reason

claude.yml (the interactive mention handler: its local equivalent is an interactive session), fleet-verify (runs the pull request's own untrusted app: CI or a container only) and ai-lane / claude-run (consumer-owned prompts) stay out, as #488 records; fanout.yml:agent-fill passes no --model today and needs one before parity can pass. The three issue-pipeline tiers and evolve each need their _data/fleet.yml homes and their own planner split, and follow in their own pull requests.