@sabaiway/agent-workflow-kit 23.12.0 → 24.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/README.md +4 -4
- package/SKILL.md +1 -1
- package/bridges/codex-cli-bridge/SKILL.md +7 -2
- package/bridges/codex-cli-bridge/bin/codex-exec-jev.test.mjs +11 -6
- package/bridges/codex-cli-bridge/bin/codex-exec.sh +72 -33
- package/bridges/codex-cli-bridge/bin/codex-exec.test.mjs +111 -3
- package/bridges/codex-cli-bridge/bin/codex-fixtures-harness.test.mjs +16 -1
- package/bridges/codex-cli-bridge/bin/codex-model-posture.test.mjs +5 -3
- package/bridges/codex-cli-bridge/bin/codex-review.sh +1 -1
- package/bridges/codex-cli-bridge/capability.json +2 -2
- package/capability.json +1 -1
- package/package.json +1 -1
- package/references/advisor-writers.md +2 -0
- package/references/agents/author.md +21 -0
- package/references/agents/executor.md +12 -6
- package/references/contracts.md +4 -4
- package/references/hooks/gate-approve.mjs +7 -8
- package/references/hooks/stage-write-guard.mjs +314 -0
- package/references/modes/agents.md +6 -4
- package/references/modes/bootstrap.md +1 -1
- package/references/modes/flow-writer.md +10 -2
- package/references/modes/hook.md +4 -1
- package/references/modes/now.md +1 -1
- package/references/modes/procedures.md +49 -10
- package/references/modes/recipes.md +7 -7
- package/references/modes/recommendations.md +4 -3
- package/references/modes/robustness-brief.md +9 -8
- package/references/modes/set-recipe.md +1 -1
- package/references/modes/state-block-guard.md +4 -3
- package/references/modes/status.md +1 -1
- package/references/modes/upgrade.md +1 -1
- package/references/modes/worktrees.md +28 -5
- package/references/rules/story-sessions.md +2 -2
- package/references/scripts/archives/archive-caps.mjs +1 -1
- package/references/scripts/archives/archive-changelog.mjs +8 -8
- package/references/scripts/archives/archive-decisions.mjs +7 -7
- package/references/scripts/archives/archive-issues.mjs +5 -5
- package/references/scripts/archives/rotation-conservation.mjs +2 -1
- package/references/scripts/docs-size/check-docs-size.mjs +15 -15
- package/references/scripts/family.json +2 -0
- package/references/scripts/gates/kit-command-gates.mjs +7 -8
- package/references/scripts/gates/migrate-gates.mjs +10 -10
- package/references/scripts/git-hooks/install-git-hooks.mjs +13 -13
- package/references/scripts/run.mjs +1 -2
- package/references/scripts/shared/index.mjs +2 -0
- package/references/scripts/shared/locations.mjs +103 -0
- package/references/scripts/spec-schema/spec-schema.mjs +2 -1
- package/references/templates/orchestration.json +1 -1
- package/tools/ack-store.mjs +2 -1
- package/tools/apply-danger-check.mjs +20 -6
- package/tools/atomic-write.mjs +3 -2
- package/tools/attribution.mjs +2 -1
- package/tools/autonomy-config.mjs +2 -1
- package/tools/bridge-wiring.mjs +13 -11
- package/tools/carriers.mjs +54 -14
- package/tools/cheap-agents-read.mjs +28 -7
- package/tools/cheap-agents.mjs +15 -10
- package/tools/checker-gates-read.mjs +6 -5
- package/tools/commands.mjs +2 -2
- package/tools/coverage-declared/config.mjs +2 -1
- package/tools/coverage-producer.mjs +10 -9
- package/tools/delegation.mjs +7 -6
- package/tools/detect-backends.mjs +1 -1
- package/tools/dispatch-baseline.mjs +2 -1
- package/tools/distribution-files/scripts.mjs +4 -4
- package/tools/ensure-configs.mjs +2 -2
- package/tools/ensure-ops.mjs +24 -24
- package/tools/ensure-specs.mjs +7 -7
- package/tools/epic-shape-cli.mjs +2 -2
- package/tools/epic-shape-ledger.mjs +5 -5
- package/tools/epic-shape.mjs +5 -3
- package/tools/epic-store.mjs +2 -1
- package/tools/family-members.mjs +7 -5
- package/tools/family-registry.mjs +36 -30
- package/tools/feedback-record-cli.mjs +4 -5
- package/tools/flow-writer.mjs +26 -15
- package/tools/gate-hook.mjs +33 -28
- package/tools/gates-declaration.mjs +2 -1
- package/tools/gates-init.mjs +6 -5
- package/tools/git-hooks.mjs +64 -41
- package/tools/grounding.mjs +3 -2
- package/tools/hide-footprint.mjs +2 -1
- package/tools/hook-writer/index.mjs +147 -0
- package/tools/init-preflight.mjs +5 -4
- package/tools/init-project.mjs +12 -11
- package/tools/inject-methodology.mjs +3 -2
- package/tools/jev-guide.mjs +2 -2
- package/tools/known-footprint.mjs +27 -25
- package/tools/mcp-registration.mjs +6 -5
- package/tools/migration-blocks.mjs +2 -1
- package/tools/migration-notes.mjs +2 -2
- package/tools/node-evidence.mjs +4 -4
- package/tools/now-facts.mjs +5 -5
- package/tools/now-status.mjs +1 -5
- package/tools/orchestration-config.mjs +2 -1
- package/tools/orchestration-readme.mjs +7 -2
- package/tools/plan-approval/cli.mjs +45 -0
- package/tools/plan-approval/entries.mjs +109 -0
- package/tools/plan-approval/index.mjs +2 -0
- package/tools/plan-approval/record.mjs +198 -0
- package/tools/plan-files.mjs +6 -4
- package/tools/plan-shape-cli.mjs +10 -64
- package/tools/plan-shape-facts.mjs +240 -83
- package/tools/plan-shape.mjs +173 -160
- package/tools/plan-structure/cli.mjs +79 -0
- package/tools/plan-structure/index.mjs +67 -0
- package/tools/procedures.mjs +21 -17
- package/tools/profile-gaps.mjs +4 -6
- package/tools/project-rules/rules-priors.mjs +2 -0
- package/tools/project-rules/themes.mjs +6 -4
- package/tools/recipes.mjs +44 -29
- package/tools/recommendations.mjs +84 -33
- package/tools/reference-profile.mjs +2 -2
- package/tools/renderers.mjs +14 -8
- package/tools/repo-lex.mjs +84 -0
- package/tools/robustness-brief.mjs +14 -11
- package/tools/satellite-locator.mjs +3 -2
- package/tools/script-priors.mjs +3 -2
- package/tools/session-close-check.mjs +71 -15
- package/tools/set-flow.mjs +2 -2
- package/tools/set-recipe.mjs +17 -9
- package/tools/source-size/help.mjs +4 -4
- package/tools/source-size/layout.mjs +2 -1
- package/tools/source-size/piles.mjs +2 -2
- package/tools/source-size-config.mjs +3 -3
- package/tools/source-size-refusal.mjs +4 -3
- package/tools/source-size-report.mjs +41 -13
- package/tools/spec-check-cli.mjs +159 -21
- package/tools/spec-check-ops.mjs +74 -5
- package/tools/spec-check.mjs +54 -45
- package/tools/spec-coverage-cli.mjs +3 -2
- package/tools/stage-render/cli.mjs +231 -0
- package/tools/stage-render/index.mjs +340 -0
- package/tools/stage-render/stages.json +115 -0
- package/tools/stage-write-guard/cli.mjs +64 -0
- package/tools/stage-write-guard/index.mjs +56 -0
- package/tools/state-block-hook.mjs +38 -163
- package/tools/task-brief.mjs +8 -13
- package/tools/task-thread.mjs +3 -1
- package/tools/tier-guide-facts.mjs +23 -9
- package/tools/tier-preview.mjs +15 -19
- package/tools/transition/index.mjs +10 -9
- package/tools/uninstall.mjs +26 -12
- package/tools/vehicle-settings.mjs +2 -1
- package/tools/velocity-profile.mjs +5 -6
- package/tools/view-model.mjs +7 -4
- package/tools/worktree-prompt.mjs +7 -3
- package/tools/worktrees.mjs +235 -159
- package/tools/write-lanes.mjs +20 -14
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,64 @@ Semantically versioned ([semver](https://semver.org)), newest first. The `versio
|
|
|
4
4
|
is the current release. `upgrade` mode reads a project's `docs/ai/.workflow-version` and applies
|
|
5
5
|
every `migrations/<version>-<slug>.md` newer than it, in semver order.
|
|
6
6
|
|
|
7
|
+
## 24.0.0 — every session starts from its stage's template, code and tests wait for your recorded yes, and on Claude Code a guard refuses code writes in a stage that writes none (AD-241)
|
|
8
|
+
|
|
9
|
+
**After `npx @sabaiway/agent-workflow-kit@latest init` and then `/agent-workflow-kit upgrade` in a new session, each
|
|
10
|
+
session starts by rendering one kit template for its stage, and the tests, code, diff review and split edits of a
|
|
11
|
+
plan start only after your yes on that plan is recorded.** Before, the next session's instruction was free text the
|
|
12
|
+
agent wrote at the close, and nothing in the kit stopped an agent from writing a story's code in the session meant for
|
|
13
|
+
its spec and plan. MAJOR: a plan in flight asks its yes again under this kit, a render or a dispatch of tests or code
|
|
14
|
+
refuses without that yes, and a plan in the old row form is refused by name.
|
|
15
|
+
|
|
16
|
+
- **One template per stage.** `node <kit>/tools/stage-render/cli.mjs docs/plans/next-session.json` renders the stage
|
|
17
|
+
the slot file names (eleven stages: epic, design consult, spec and plan, waiting on approval, tests, code, diff
|
|
18
|
+
review, split modules, split edits, pause, empty queue), its steps read from the installed engine, its plan or
|
|
19
|
+
queue row from the slot file. A work tree has one slot file, `docs/plans/next-session.json`. The handover's
|
|
20
|
+
`## Next session` holds the one render line; the session's close writes the next stage through
|
|
21
|
+
`--write docs/plans/next-session.json --stage <id>`.
|
|
22
|
+
- **The close gives you a start prompt.** Outside a linked work tree `--write` prints two lines to paste into the next
|
|
23
|
+
session: the session's name with its plan or queue row, then ``To start: run `<the render command>` and follow the
|
|
24
|
+
stage it prints.`` A linked work tree prints none; `worktrees provision` writes its slot file itself and prints its
|
|
25
|
+
own command.
|
|
26
|
+
- **Your yes is recorded and checked.** At a plan's approval the agent shows you the plan's essence in your dialogue
|
|
27
|
+
language and records your yes with `node <kit>/tools/plan-approval/cli.mjs record <plan> --essence-file <file>` in
|
|
28
|
+
the git directory (`agent-workflow-plan-approvals.jsonl`); `check <plan>` reads it. The render of a tests, code,
|
|
29
|
+
diff-review or split-edits stage, the executor vehicle, `codex-exec` with a dispatch nonce (through the
|
|
30
|
+
`aw-plan-approval` block `stage-render/cli.mjs --dispatch <plan>` prints) and `worktrees provision` each refuse a plan
|
|
31
|
+
with no matching record, naming the record command. A change to the plan's approved part or to the text of its
|
|
32
|
+
contracts asks the yes again; amendment entries, robustness tags and a contract's status, revision, date and
|
|
33
|
+
scenario bindings do not change what the yes covers. A provisioned work tree matches its plan digest alone.
|
|
34
|
+
- **On Claude Code, a stage that writes no code cannot write code through the edit tools.** The upgrade offers
|
|
35
|
+
`stage-guard`; on your chat yes, after its danger check prints the hook file and the settings entry, it places
|
|
36
|
+
`.claude/hooks/stage-write-guard.mjs` and adds one `hooks.PreToolUse` entry for `Write|Edit|MultiEdit|NotebookEdit`
|
|
37
|
+
to `.claude/settings.json`. Every render records its stage in the work tree's git directory
|
|
38
|
+
(`agent-workflow-stage.json`) where git answers one; while that stage writes no code, a write outside the authoring
|
|
39
|
+
documents is refused with a reason naming the stage and the render line, never a prompt. The authoring documents
|
|
40
|
+
are `.md` and `.json` files under `docs/ai/`, `.md` and `.txt` files under `docs/plans/`, the slot file, the debt
|
|
41
|
+
queue and convergence summary your orchestration config names when each is a `.md` file under `docs/`, and `.md`
|
|
42
|
+
files directly in Claude Code's memory and default plan-mode directories. The guard never allows or asks anything.
|
|
43
|
+
It does not bind the shell or another host. When neither the session's work tree nor the target's holds a record
|
|
44
|
+
and the path and git checks succeed, it makes no decision. A deliberate breach remains bound by the template's text
|
|
45
|
+
alone. A later kit refreshes the hook file as
|
|
46
|
+
`stage-guard.not-current`, with no question. `/agent-workflow-kit uninstall` names the guard's settings entry in
|
|
47
|
+
the edit it prints, since a wired guard keeps refusing after the kit is gone.
|
|
48
|
+
- **Authoring rides a no-shell author agent.** `/agent-workflow-kit agents` places `.claude/agents/author.md`; plan
|
|
49
|
+
authoring and an epic's author slot ride it, each slot is judged by its role, and without it the author slot
|
|
50
|
+
resolves to solo with its reason stated. The executor vehicle no longer authors.
|
|
51
|
+
- **A spec session's gates judge its contracts before any code exists.** `spec-check-cli.mjs --plan <plan>` judges
|
|
52
|
+
the plan's drafts and revisions, a revision of a live contract waits in the plan's revision home
|
|
53
|
+
`docs/plans/<plan stem>.specs/`, and the plan gate reads its facts on demand.
|
|
54
|
+
- **A plan carries no line counts.** A ledger row holds five fields and the ledger no total line; the plan gate
|
|
55
|
+
judges no size and refuses the old six-field row (`retired-size-field`) and a total line (`retired-total-line`) by
|
|
56
|
+
name. The row cap is 45; a plan past a count that still belongs in one plan states why on one `One plan: ` line. A
|
|
57
|
+
file missed after the approval is an entry under `amendments:` with no new yes, and
|
|
58
|
+
`node <kit>/tools/plan-structure/cli.mjs <plan>` re-runs the plan's structure mid-flow.
|
|
59
|
+
- **A size limit that fires asks whether the code rules were kept.** Each recorded raise takes its own reason.
|
|
60
|
+
- The kit's tools read the project's locations from one definition (memory 11.2.0), and the state-block hook's
|
|
61
|
+
writer runs on the kit's one hook writer, every line it prints unchanged.
|
|
62
|
+
- The codex bridge goes to 7.0.0: `codex-exec --help` names the `aw-plan-approval` stop; your next `init` or upgrade
|
|
63
|
+
refreshes it where you placed it.
|
|
64
|
+
|
|
7
65
|
## 23.12.0 — a skipped check keeps its whole reason in the upgrade report; three checkers open red output with the failure (AD-240)
|
|
8
66
|
|
|
9
67
|
**After `npx @sabaiway/agent-workflow-kit@latest init` and then `/agent-workflow-kit upgrade` in a new session, a
|
package/README.md
CHANGED
|
@@ -248,7 +248,7 @@ file), or run the guarded `/agent-workflow-kit uninstall`.
|
|
|
248
248
|
| `/agent-workflow-kit now` | any time | **read-only** answer to where work stands in four blocks: **NOW** names every plan in flight, its phase, current and next step, and the tree evidence; **STEPS** gives every ledger row its evidence-derived status; **QUEUE** folds named rows under their full heading paths and calls position priority only in the judged backlog; **CAMPAIGN** shows the source-size practice figures and config state. The plan's own text never sets a status; a contradicted claim prints beside it. A block that cannot be derived is WITHHELD with its cause; NOW has two halves, plans and tree, each independently a value or WITHHELD, and NOW itself is WITHHELD only when both are. Never writes, never commits, never runs a subscription CLI. |
|
|
249
249
|
| `/agent-workflow-kit tier` | any time | **read-only** guide to the epic, story and task tier: what each level is, and the next step of the walk, with the command that runs it wherever a tool does. Never writes, never commits, never runs a subscription CLI. |
|
|
250
250
|
| `/agent-workflow-kit jev` | any time | **read-only** guide to Jev (TypeSafe), a decision model: what it is, why it pays here, what it is not, the two steps to a set key (the connect command, the optional vendor skill) and three prompts where it pays. Opens no connection and never prints the key. |
|
|
251
|
-
| `/agent-workflow-kit recipes` | any time | **read-only** orchestration advisor: presents five named recipes for composing the carriers of a step — the bridges and the
|
|
251
|
+
| `/agent-workflow-kit recipes` | any time | **read-only** orchestration advisor: presents five named recipes for composing the carriers of a step — the bridges, the executor for carry slots and the no-shell author vehicle for author slots — into plan → execute → review — **Solo / Reviewed / Council / Delegated / Subagent** — plans + recommends one for your environment (degrading with a stated reason when a backend isn't ready, or when a slot's vehicle is not ready), and offers the choice. The activity/slot registry (six activities) is rendered by `procedures` and by `set-recipe --help`. The orchestrator runs it via the bridge skills or the slot's vehicle and **always commits**; the kit never executes a recipe, never runs a subscription CLI, never commits. |
|
|
252
252
|
| `/agent-workflow-kit procedures <activity>` | any time | **read-only** activity-procedures advisor: prints a named activity's ordered steps (`plan-authoring` / `plan-execution` / `routine` / `feedback-triage` / `epic` / `task`) read **live** from the engine, plus the **resolved recipe per slot** from your `docs/ai/orchestration.json` (agent-writable via `set-recipe`, or hand-edited) + carrier readiness (`plan-authoring`: author, fold, review; default Reviewed when a backend is ready, Council on request; slot-aware incl. Delegated and Subagent) — and, for every dispatched backend, the **full driving contract at the point of use** (exact copy-pasteable invocation, grounding levers like agy's `--facts`/`--decided`, the round-2 `--continue` delta, guarded passthrough), verbatim from the bridge manifests (drift-guarded; each wrapper's `--help` prints the same) — except `feedback-triage`, whose record-bound block carries the check with `--excerpts`, the resolved member lines (ready bridge commands, the ready lens brief, or explicit skipped members), and either the record round-table command for a bridge obligation or the no-receipt fact otherwise: the record is the artifact. `--override <slot>=<value>` adjusts one slot per run. Composes with `recipes`; never writes, never commits, never runs a subscription CLI. |
|
|
253
253
|
| `/agent-workflow-kit set-recipe` | any time | **config writer** for `docs/ai/orchestration.json`: tell the agent your preference in plain language and it maps it to explicit `--set <activity>.<slot>=<value>` / `--unset` ops; the kit validates, **previews by default**, and writes only on `--write` (deployment-gated, atomic, symlink/TOCTOU-safe), resolving the effective recipe vs live readiness. Writes **only** that file — **never runs a backend or a subagent, never commits**; hand-editing stays fully supported. |
|
|
254
254
|
| `/agent-workflow-kit review-state` | any time | **read-only review-receipt checker** — makes "reviewed ≠ shipped" detectable: the bridge review wrappers append a receipt per successful review (into a file inside the git dir — never committable); this checks that every backend your configured `plan-execution.review` recipe names holds a **fresh, grounded receipt for the current uncommitted tree** (any later edit the payload can see moves the fingerprint and stales the receipt; a review continuation never re-attests a folded tree). `--check` gives a gate exit code to declare in `docs/ai/gates.json` **by hand or via the consent-gated seeder** (preview → your explicit yes; never without consent). `--await [--timeout <s>]` (AD-049) BLOCKS until every recipe-named backend has receipted the current tree — the durable completion signal is the receipt, never a process event — so you wait for the bridges instead of hand-polling. Never writes, never commits, never runs a subscription CLI; it spawns read-only `git` queries to fingerprint the tree — and `git commit --no-verify` stays possible (discipline, not a sandbox). |
|
|
@@ -262,11 +262,11 @@ file), or run the guarded `/agent-workflow-kit uninstall`.
|
|
|
262
262
|
| `/agent-workflow-kit recommendations` | any time (every `upgrade` ends with it) | **read-only deployment advisor** (AD-044) — computes what in THIS deployment is configured sub-optimally (allowlist not seeded, autonomy render drifted, OS sandbox unavailable, gates undeclared, bridge friction, sandbox-mask clutter, a feature-spec layer never adopted) and renders **verdict-first**: one composed verdict line (does anything need attention?), then each item as **{severity · what · one-line benefit · an optional `recipe:` line (the bridge-tier item's missing-entries line — each missing entry by kind: allow rules, exclusions, hosts, state dirs, then what the execution wrapper codex-exec needs, then the host condition; the worktrees-dir ack fallback for a host that ignores the settings key, the agents hidden-mode reconcile follow-up, a user item's own facts, the spec-adoption decline preview, or another offer's decline preview) · the exact consent-gated apply one-liner}**; `references/advisor-writers.md` names each variant's writer or user step. The agent PRESENTS the section in the user's conversational language — every fact and count, nothing added or dropped; commands, paths, hosts and rule strings byte-exact; raw tool block on request — and runs EXACTLY the rendered one-liners and the follow-up commands required by the mode doc, only on the answer authorizing that step — your yes to apply or your explicit decline to record it — with a second yes where the mode doc requires it, surfacing each item's posture note first; a kit item it applies with no question, its check line first, the harness's own dialog the only ask, or the one plain step where auto mode refuses its check or apply. Renders **present-even-when-empty** (`no recommendations — flow optimal.`); a failed probe degrades to a stated skip line. Registry strings are fact-true frozen one-line data (posture/risk notes live in the mode doc at the consent moment); `velocity --bridge-tier` seeds the used bridges' review allow rules, `<wrapper> *` exclusions (`codex-exec *` where an execute slot delegates, keeping its permission prompt), declared hosts into `sandbox.network.allowedDomains`, and home-relative state dirs into `sandbox.filesystem.allowWrite`; hosts and dirs come from the kit service fragments (`agent-workflow-kit/tools/services/`) each bridge's `capability.json` names in `services`, then from your own services list (`services.json` beside the bridge settings file, Mode: setup), and the advisor's `bridge-tier` item counts and names each missing one. `--cwd` is required (the target project is explicit); writes nothing, never commits, never runs a subscription CLI. |
|
|
263
263
|
| `/agent-workflow-kit doc-parity` | any time | **read-only doc-parity lint** (AD-049) — kills the doc-drift class where a mode-contract doc silently lags a code constant (a `--check` doc still reading `300` after the diff cap moved to `400`): a **closed, exported registry** binds each live constant (review caps, schema versions, the ledger's own class/scope vocabulary, and the autonomy-doctor EXIT/status/trusted-dir contract) to the exact token its `references/modes/*.md` contract must carry, and asserts the CURRENT value renders into every bound file — a drifted doc, an unreadable file, or an absent token **fails closed**. The values are sourced from the live imports (never re-typed), so the lint can't itself go stale; adding a binding is adding a checked entry (closed-world, edit-safe). `--check` is the gate exit code a kit maintainer runs: the lint checks the kit's own package. Never writes, never commits, never runs a subscription CLI. |
|
|
264
264
|
| `/agent-workflow-kit dispatch` | any time | **the delegation engine** — makes "how much does delegating a sub-task actually buy?" a measured number instead of a feeling. `check <file>` validates a sub-task brief's contract block and exits 0/1 naming the first violated field — **form only**: whether the task is genuinely bounded, its design decided and its acceptance adequate stays your judgment, and a well-formed absurdity passes here by construction. `advise --step-class <c>` answers the question that comes BEFORE that one — which vehicle should carry this kind of sub-task, whether it is even present on this machine, and what the ledger has already recorded for threads of that class (finished, failed, closed without a fold, and still open — counted separately) — and it decides nothing: it refuses no dispatch, gates no verb, and a choice that diverges from the advice is noted rather than blocked. It reads the filesystem only: nothing is launched to find out what is installed, an absent ledger prints "no recorded history", an unreadable one prints the store's own words, and either way the advice still prints. The same block appears as a footer under a form-valid `check` — never under a refusal, so it can never hide one. `register` pre-registers an acceptance wave (step classes, pairing key, minimum observations per class, the mean and first-pass thresholds) so the bar can never be chosen after the results it judges — immutable per wave. `observe` records ONE hand-written observation (`solo-construction`, the baseline whose ratio is 1 by construction — except over a scope measuring zero bytes, which has no ratio at all and is recorded ineligible by name — or `self-reported`) — delegated numbers are never hand-written, they are derived. The writer verbs are where that derivation happens: `open` puts a delegated thread on the record with every mint-time field copied from the brief's own header, refusing a deadline the wrapper's cap plus its kill grace would not fit inside, and recording whether the tree it started from was clean against the thread's base — HEAD by default, or the tree `--checkpoint <oid>` names, so the second task of a story is measured over the first one's uncommitted work instead of opening dirty (a dirty one makes the result honestly unmeasurable rather than quietly counted), while `--task <brief>` also records which task brief the thread carries out and the files that brief lists, refusing, since the last commit, a task thread whose files overlap by path prefix those of an open task thread or of a folded thread of another brief (`files-overlap`), and a mix of the two kinds — an untasked open beside an open task thread or, for a `code` open of backend `codex`, after a task fold, and a task open beside an open untasked thread (`mixed-open`), refusing at open a Files path the snapshot scope can never hold (`task-files-scope`), and measuring a task thread over its files alone, so `return` and `fold` refuse a changed path that no open or folded task thread on the same base claims (`out-of-files`); `await` waits for that one dispatch to answer and writes nothing — only the finished receipt satisfies it, a run still holding the nonce means keep waiting, and a wait that runs out says so with its own exit code, names whether the deadline or your own timeout ended it, and authorizes nothing: a wait that ended without an answer is a question for you, never permission to dispatch again; `return` absorbs the receipt the wrapper minted — only a finished one, checked against the contract it actually ran, its deadline and its own report, and refused outright when the tree hides changes from git or moves while the return is being computed — and derives the bytes from git rather than from anyone's claim; `fold` is the acceptance, and it refuses if the tree moved since the return — precisely, it re-confirms **equality of the visible canonical payload**, which is a change detector rather than a cryptographic identity of the tree: under the default head base that payload's untracked section is unframed and carries no file mode, so a content or symlink target that imitates the marker opening the next entry can alias two trees, and making an untracked file executable moves nothing (both named as residuals in the mode doc, with the fix queued); under a checkpoint base it is one indexed diff that carries modes. A change set carrying a binary, a non-regular path, a submodule, or a symlink whose target is not valid UTF-8 is **refused** at `return` and `fold` — CONSERVATIVELY, rather than promise what the default head payload may not be able to follow — and the same refusals hold for a checkpoint thread. `degrade` closes a thread that never earned a fold, on the record and with its reason. `aggregate` prints one wave: the registered thresholds, every observation as context, and per step class the finished threads — a folded success with git-provable bytes contributes its ratio, one whose bytes are unprovable is excluded from the mean but still counts in the first-pass rate, and a failed thread, a degrade-closed one, or one folded after failing acceptance each count as a real zero. Below the registered minimum nothing is computed (insufficient); at or above it is computed and labeled PILOT evidence. It REFUSES rather than guessing: no pre-registration, an unfinished thread in scope, a recorded refusal-to-delegate that never opened a thread, or an ambiguous wave each stop the computation by name. `handoff-return --slug <s>` closes the worktree loop after `land --prepare`: it re-attests that main still holds exactly the prepared tree under the same HEAD (both recorded in the handoff at prepare time), prints the satellite handoff's user-owned content byte for byte with its boundaries, byte lengths and the main-owned destinations each part folds into, prints the handoff digest and both OIDs as its proof, states the after-the-fold order (a fold landed after the gates leaves them stale), and records ONE self-reported worktree-stream observation only when the whole prepared change set is measurable — a deletion, a rename, a symlink, a submodule or a mode-only change ends with a named NOT RECORDED instead, never a partial number. Appends only to its own ledger inside the git dir (never committable); it also writes `handoff-return`'s `write-tree` tree object and, for a checkpoint measurement, the leaf's OWN temporary index file and the blobs its forced adds store — never a ref, never the real index; never commits, never runs a subscription CLI. |
|
|
265
|
-
| `/agent-workflow-kit worktrees` | any time | **parallel feature worktrees** — run several features in DIFFERENT agent sessions on one repo, zero interference on working-tree files (the ONE exception is the dependency cache, below): `provision <slug> --plan <file
|
|
265
|
+
| `/agent-workflow-kit worktrees` | any time | **parallel feature worktrees** — run several features in DIFFERENT agent sessions on one repo, zero interference on working-tree files (the ONE exception is the dependency cache, below): `provision <slug> --plan <file> [--stage <id>]` creates a sibling git worktree on branch `aw/<slug>` only for a plan whose approval record matches (the worktree's own, or MAIN's, whose entry it carries into the worktree; otherwise it refuses naming the record command) and populates it (the slot file `docs/plans/next-session.json` for `--stage`, one of `tests`, `code`, `diff-review`, `split-edits`, `tests` when absent, composed by the stage renderer's `composeSlotText` and written by provision's own journaled write; registry-derived footprint copy-if-missing — a tracked file is never overwritten; EXACTLY ONE seeded feature plan; the `handoff-<slug>.md` record from minute zero; `node_modules` symlinked where the link stays ignored — a shared MUTABLE dependency cache: writes through it hit MAIN's node_modules; for isolation run the printed isolated-install command (`--install` only PRINTS it; on `--resume` run the printed unlink-first recovery first — printed only for a link whose RAW TARGET is MAIN's `node_modules`, since a foreign or unreadable link is reported as such with no removal advised); absolute root-pinned gate commands rebased on untracked copies only, and only while their bytes equal the MAIN source or its rebased form — user-modified copies stay untouched); `list` is read-only (slug, branch, base, dirty, handoff); `prompt <slug>` is read-only too and re-prints the satellite's cold-start prompt — the same text `provision` ends its report with: where the worktree is, its ONE seeded plan, the handoff as the one channel back, MAIN's orientation (shared series index, landing) and, under its own heading because it is probed on the satellite, that checkout's install posture — every value derived LIVE rather than replayed from the frozen provision record, a recorded value that no longer matches NAMED as a divergence (with the cause its source makes likely) instead of printed as the runnable one, every offered command marked with WHO runs it (`MAIN $ …` for the landing, `HERE $ …` for the render command of that slot file, the session's first step, and for this checkout's own install, a posture with nothing to run staying prose), and a control character in any rendered value a typed STOP rather than a forged prompt line; `land <slug> --prepare` locks the common git dir, fail-closes on divergence or incomplete satellite state, transfers the complete accepted satellite diff onto a CLEAN main, runs sync plus the declared gates, and reports HEAD/TRANSFER/PREPARED OIDs — the commit ALWAYS stays a dialogue ask; `cleanup <slug>` takes the same lock and removes a LANDED worktree only after live landed-verification against main HEAD, while `--abandon` is the ONE destructive arm (destroys unlanded work; **no preview step** on any writer). The parent dir is the `docs/ai/worktrees.json` `parentDir` setting (default: the repo's sibling parent); an unwritable parent prints the `worktrees-dir` check line: the agent applies the grant on your chat yes after the check, one entry in this copy's `.claude/settings.local.json`, never the committed project settings (`init` is the route you may take instead, and the ack is the fallback for a host that ignores the key), else the printed terminal command runs it. Never commits, never pushes, never runs a subscription CLI. |
|
|
266
266
|
| `/agent-workflow-kit uninstall` | opt-in, any time | **guarded teardown** — the inverse of `init` / `setup`. Removes only what's **provably ours** (managed skill dirs + bridge wrappers; in a project, the hidden-mode git-ignore block it added + the pre-commit hook it installed); **never deletes** your `docs/ai` / `AGENTS.md` (prints the exact `rm` to run by hand) or your `.claude/settings.json` (prints an **edit** — remove the attribution key, review any velocity `permissions.*` — never an `rm`). Always `--dry-run` first; preflight-then-mutate; never commits. |
|
|
267
267
|
| `/agent-workflow-kit velocity` | Claude Code · opt-in | **onboarding velocity profile** — seeds a fixed, audited **read-only** allowlist into `.claude/settings.json` so routine read-only commands stop idling on approval prompts while you're away; every allowlist apply (flagless, `--kit-tools`, `--bridge-tier`) also seeds one `permissions.ask` rule, so all work can stay in auto mode: without it auto mode refuses a harness or kit apply (the `apply:` line of each harness or kit item the upgrade advisor renders) and you must leave auto mode for it; with it the harness shows its usual dialog — the rule allows nothing; opt-in `acceptEdits`; plus a **read-only advisory** of likely project gate commands to add by hand. Writes `.claude/settings.json`; a fourth opt-in, `--worktrees`, writes the worktrees grant into the local settings, `.claude/settings.local.json`, alone — **never** allowlists commit/push/publish, never commits. A seeded entry is a **trust posture, not a sandbox** (a runtime residual remains at the settings level — its guard ships as the opt-in `hook` command); a direct commit/push/publish still asks. `--dry-run` first. |
|
|
268
|
-
| `/agent-workflow-kit agents` | Claude Code · opt-in | **subagent vehicles** — places the
|
|
269
|
-
| `/agent-workflow-kit hook` | Claude Code · opt-in | **gate-approval hook** — places a self-contained PreToolUse hook (`.claude/hooks/`) and wires it into `.claude/settings.json`: a Bash command **byte-identical** to a gate you declared in `docs/ai/gates.json` (run from the project root) is auto-approved — no prompt, no idle; a seeded read-only command carrying a runtime residual (output redirection, command substitution, `--output` writes) now **asks** even where an allow rule would have silently passed it (proven live — hook `ask` overrides an allow rule). Detection is a conservative string scan, so it over-asks on a byte that is ordinary text — searching for `=>`, or a read wearing `2>/dev/null`, prompts. That is a documented open limit: 4.1.0 built three mechanisms to narrow it and removed all three in review, each counterexample kept as a test (see Mode: hook). Exact matches only, never patterns; never `deny`; a broken `gates.json` only disables auto-approval, never the guard. An opt-in **read-lane** (`--read-lane` → `docs/ai/lanes.json`, a **separate** file from `gates.json`) additionally auto-approves *compounds* of seeded read-only commands carrying no shell metaprogramming; `--apply --read-lane` verifies the placed hook is current first. Within a hook you wired, its file is placed when absent and written with the kit's body when it differs, with no question and no copy kept (the upgrade's `gate-hook.not-current`); a hook of your own goes in `.claude/hooks/<name>.local.mjs`, which you wire. Preview by default; never writes `settings.local.json`; never commits. |
|
|
268
|
+
| `/agent-workflow-kit agents` | Claude Code · opt-in | **subagent vehicles** — places the bundled subagent definitions into `.claude/agents/`: **four read-only vehicles, the author vehicle and one full-tool `executor`**. **No read-only vehicle gets `Bash`**, and that is the load-bearing property: a read-only fan-out on a full-tool subagent shells out for facts it could have read, and every shelled command is an approval prompt you never needed to see. Three of the four ride a **cheap model** (haiku, low effort) for mechanical work — extraction sweeps, changelog fact-skeletons, gate-failure triage; the fourth, **`review-lens`**, is an ADDITIONAL independent read-only review opinion on code your configured backends have already seen (never a replacement for your plan or diff review recipe, advisory like every review; an epic is reviewed by the lens alone, whatever `epic.review` resolves to). The **`author`** (Read, Grep, Glob, Write, Edit; no shell) drafts plans, contracts and epic files from the orchestrator's briefs, and folds a round's findings, for author slots. The **`executor`** (all tools; model and effort from `docs/ai/vehicles.json`), is the ONE vehicle with a shell and the instrument behind the **Subagent** recipe for carry slots: dispatched only for a bounded, file-disjoint execution / routine slice you verify afterwards — never for read-only work, never as a review backend, and it never commits. Its state (`placed` / `customized` / `unusable` / `missing`) decides carry-slot readiness; only `placed` makes the author vehicle ready for author slots. Writing code and running gates stay off the four read-only vehicles; the executor carries a bounded slice you re-verify on your main lane, and every vehicle's output is verified. Preview by default (`--apply` writes); every kit agent file (the bundled names and each configured roster-derived lens) is **written current with no question** — an absent one placed, a differing one written with the body the kit writes for it, the executor's and the bundled `review-lens`'s (opus / high by default, set in the file's optional `review-lens` section) derived from `docs/ai/vehicles.json`, no copy kept; a link at a kit agent path stops the run naming it, nothing written; a vehicle of your own goes in `.claude/agents/<name>.local.md` with a `name:` of its own; never touches `settings*.json`, never commits. |
|
|
269
|
+
| `/agent-workflow-kit hook` | Claude Code · opt-in | **gate-approval hook** — places a self-contained PreToolUse hook (`.claude/hooks/`) and wires it into `.claude/settings.json`: a Bash command **byte-identical** to a gate you declared in `docs/ai/gates.json` (run from the project root) is auto-approved — no prompt, no idle; a seeded read-only command carrying a runtime residual (output redirection, command substitution, `--output` writes) now **asks** even where an allow rule would have silently passed it (proven live — hook `ask` overrides an allow rule). Detection is a conservative string scan, so it over-asks on a byte that is ordinary text — searching for `=>`, or a read wearing `2>/dev/null`, prompts. That is a documented open limit: 4.1.0 built three mechanisms to narrow it and removed all three in review, each counterexample kept as a test (see Mode: hook). Exact matches only, never patterns; never `deny`; a broken `gates.json` only disables auto-approval, never the guard. An opt-in **read-lane** (`--read-lane` → `docs/ai/lanes.json`, a **separate** file from `gates.json`) additionally auto-approves *compounds* of seeded read-only commands carrying no shell metaprogramming; `--apply --read-lane` verifies the placed hook is current first. Within a hook you wired, its file is placed when absent and written with the kit's body when it differs, with no question and no copy kept (the upgrade's `gate-hook.not-current`); a hook of your own goes in `.claude/hooks/<name>.local.mjs`, which you wire. Preview by default; never writes `settings.local.json`; never commits. The kit's third hook, the **stage write guard** (`.claude/hooks/stage-write-guard.mjs`, one PreToolUse entry for the four edit tools Write, Edit, MultiEdit and NotebookEdit; its writer is `tools/stage-write-guard/cli.mjs`, the upgrade's `stage-guard` offer, applied on your chat yes after the danger check), refuses a write through the edit tools outside the authoring documents while the stage last rendered writes no code: a deny, never a prompt, and it approves nothing. Its bound: it binds the edit tools on Claude Code alone; the agent's shell, a host without hooks, a session never started by a render, a write where no tree holds a stage record, and a record or plan changed after the render are bound by the text alone; it tracks one stage per work tree, shared by the sessions working in it; the agent's own render writes the record, so it stops a mistake, not a deliberate breach. Within the wired guard its file is written with the kit's body when absent or differing, with no question (the upgrade's `stage-guard.not-current`). |
|
|
270
270
|
| `/agent-workflow-kit state-block-guard` | Claude Code · opt-in | **closing-block detector** — a `Stop` hook that reads the turn's final assistant message and warns when the closing state block is defective: the «what I need from you» slot answering *nothing* (a turn that ENDS always needs a resume, so the answer is false, not merely unhelpful), or a first-person promise of imminent work in a turn that is over. Judged on the slot's first clause, so a real ask followed by a clause break and "nothing else" passes, and a promise gated on something named passes; matching is word-bounded and Unicode-aware, quoted and fenced examples are stripped, and the last STARTED block decides — an incomplete tail counts as no block rather than falling back to an earlier one. A message carrying no block at all is silent unless you pass `--require-block` — this kit does not mandate the block, and a hook that runs every turn must not warn every turn. The judgement is lexical and the mode doc names every residual it leaves. **Detection, never prevention** — a `Stop` hook cannot un-send the message it judges; what it buys is that a silent recurrence becomes a visible one. Warns via `systemMessage` and **exits 0 on every path**: never `deny`, never blocks the stop, never re-enters the model. Reads nothing but the message, makes no network call, approves nothing. Its writer is `tools/state-block-hook.mjs`: it places the self-contained hook and merges its `Stop` entry into `.claude/settings.json` by the three merge cases, keeping every foreign hook — the agent applies it on the chat yes after the danger check. Within the wired hook its runtime file is written with the kit's body when absent or differing, with no question (the upgrade's `state-block.not-current`); a hook of your own goes in `.claude/hooks/<name>.local.mjs`, which you wire. |
|
|
271
271
|
| `/agent-workflow-kit bridge-settings` | opt-in, any time | **host-level bridge settings** — read or change the bridges' `KEY=VALUE` config file (`${XDG_CONFIG_HOME:-~/.config}/agent-workflow/bridge-settings.conf`), the **one place a knob survives kit upgrades** (it lives outside every kit tree; a refresh never touches it, and now states loudly if it ever overwrote a local edit). The **model each bridge runs**: `CODEX_MODEL` + `CODEX_EFFORT` (default `gpt-6.2-sol` at `high`) and `AGY_MODEL` (default `Gemini 3.8 Flash (High)`) — the read-out shows the models each installed CLI offers, and a set one is checked against that list before anything is written. The judge's `JEV_MODEL` defaults to its manifest's `posture.model` and is checked against the versions its manifest offers. Other knobs: the **codex Fast tier** (`CODEX_SERVICE_TIER=priority` — "2x speed, **increased usage**" in the catalog's own words, quality-neutral, default off — a consented spend), the codex/agy hard timeouts, the codex review byte cap, and `AGY_REVIEW_MAX_TOTAL_BYTES` (the ceiling on what an oversized agy code review may feed before it refuses pre-spend). `AGY_REVIEW_ALLOW_ADDDIR` is a **retired** compatibility key: still recognized so an existing line never warns as unknown, but it arms nothing — the writer refuses to set it and `--unset` clears it. Allowed keys + value rules come from the bundled bridge manifests. **Previews by default**; refuses an unknown key, an out-of-range value, a model or effort the catalog does not offer, or a duplicate-carrying file; writes atomically (symlink/TOCTOU-safe). Never commits, never runs a model (only the read-only catalog commands). |
|
|
272
272
|
| `/agent-workflow-kit autonomy-doctor` | opt-in, any time | **guarded sandbox provisioner "doctor"** — can this machine run the Claude sandbox, and (only with your consent) fix it: macOS Seatbelt built-in / Linux+WSL2 needs `bwrap`+`socat` / native Windows → WSL2. Flagless = **FS-only preview** (the diagnosis, the exact absolute-path command it WOULD run, the exact `--apply <pm>:<pkgs>` consent tuple — runs nothing, never claims ready); `--verify` runs the unprivileged proof (a `bwrap` user-namespace smoke + `socat -V`) — the **only** source of a Linux "ready (verified)" claim; `--apply <pm>:<pkgs>` is the consent-gated privileged install (the tuple must equal the previewed plan; everything executed resolves to absolute paths inside `/usr/bin:/bin:/usr/sbin:/sbin`; the exact command is re-printed immediately before execution), then verifies. Honest loud degrades (unknown PM, untrusted location, nested-sandbox INDETERMINATE, root-unproven) and a stated restart step. Sits **outside every velocity auto-approve tier**; never auto-runs, never writes repo files, never commits. |
|
package/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: agent-workflow-kit
|
|
|
3
3
|
description: Deploy or upgrade a portable AI-agent memory-and-workflow system in any project. Use when the user wants to bootstrap `docs/ai/` + an entry-point `AGENTS.md` (+ `CLAUDE.md` alias) + cap/archive/index enforcement in a new or existing repo, set up the Memory Map and session protocols, install the docs-rotation pre-commit hook, or run `/agent-workflow-kit` / `/agent-workflow-kit upgrade`. Triggers on phrases like "set up the memory system", "deploy the AI workflow here", "bootstrap docs/ai", "upgrade the workflow". New to the epic, story and task tier? Run `/agent-workflow-kit tier`. A typed decision with a confidence from Jev? Run `/agent-workflow-kit jev`.
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
metadata:
|
|
6
|
-
version: '
|
|
6
|
+
version: '24.0.0'
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# agent-workflow-kit
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: codex-cli-bridge
|
|
3
3
|
description: Delegate work to the OpenAI Codex CLI (`codex`) under a ChatGPT subscription — run plan/instruction EXECUTION in a sandboxed workspace, or get a read-only ADVISORY review of a plan or working-tree diff — as a second delegated-execution backend beside Antigravity. Use when the user wants to hand a bounded coding task or plan to `codex exec`, get a second-opinion review from codex, install or authenticate Codex CLI, understand its sandbox/network/approval policy, drive codex efficiently from the main agent (exec vs review, resume, the commit boundary), bridge project context (`AGENTS.md`) into codex, or troubleshoot codex flags, models, auth, or its no-TTY headless behaviour.
|
|
4
4
|
metadata:
|
|
5
|
-
version: '
|
|
5
|
+
version: '7.0.0'
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# codex-cli-bridge
|
|
@@ -196,7 +196,12 @@ skipped entirely without a nonce: the wrapper is byte-unchanged, writes no artif
|
|
|
196
196
|
in state `reserved`, atomically and **no-clobber**, beside the delegation store. A second dispatch
|
|
197
197
|
on the same nonce (or a leftover report under that name) refuses **before any spend**. So does a
|
|
198
198
|
run with no capping binary, without `node`, with the prompt on stdin instead of a contract file, or
|
|
199
|
-
with a file carrying no ` ```aw-dispatch-contract ` block.
|
|
199
|
+
with a file carrying no ` ```aw-dispatch-contract ` block. The file also carries ONE top-level
|
|
200
|
+
` ```aw-plan-approval ` block, a JSON object of exactly `plan`, `approval` and `check`, as the kit's
|
|
201
|
+
`tools/stage-render/cli.mjs --dispatch <plan>` prints it: a run whose block is absent, doubled or
|
|
202
|
+
malformed, or whose `NODE_OPTIONS= node <check> check <plan> --digest <approval>` exits non-zero,
|
|
203
|
+
refuses **before any spend**, so a nonced run executes only an approved plan. That block never
|
|
204
|
+
enters `contractDigest`.
|
|
200
205
|
- **`contractDigest` is computed HERE**, by the wrapper, from the dispatch file it was handed — an
|
|
201
206
|
independent value, never a copy of what the ledger holds, so `dispatch return` can refuse a run
|
|
202
207
|
that executed a *different* contract than the one it opened.
|
|
@@ -5,7 +5,7 @@ import { tmpdir } from 'node:os';
|
|
|
5
5
|
import { join, dirname } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
import { spawnSync } from 'node:child_process';
|
|
8
|
-
import { makeFixtureRepo, openSuiteScopes } from './codex-fixtures-harness.test.mjs';
|
|
8
|
+
import { composeApprovalBlock, makeFixtureRepo, openSuiteScopes, writeStubCheck } from './codex-fixtures-harness.test.mjs';
|
|
9
9
|
const stripGitLocationEnv = (env) => Object.fromEntries(Object.entries(env).filter(([key]) => !/^[Gg][Ii][Tt]_/.test(key)));
|
|
10
10
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
11
11
|
const MANIFEST = JSON.parse(readFileSync(join(HERE, '..', 'capability.json'), 'utf8'));
|
|
@@ -54,6 +54,11 @@ const sandbox = (root = tmp) => {
|
|
|
54
54
|
cpSync(TEMPLATE, dir, { recursive: true });
|
|
55
55
|
return { dir, bin: join(dir, 'bin'), home: join(dir, 'home'), repo: join(dir, 'repo'), state: join(dir, 'home', '.local', 'state', 'agent-workflow', 'codex-jev-profile-refused') };
|
|
56
56
|
};
|
|
57
|
+
const withApprovedTask = (sb) => {
|
|
58
|
+
writeFileSync(join(sb.repo, 'task.md'), CONTRACT
|
|
59
|
+
+ composeApprovalBlock({ plan: 'docs/plans/approved-plan.md', approval: 'c'.repeat(64), check: writeStubCheck(sb.dir) }));
|
|
60
|
+
return sb;
|
|
61
|
+
};
|
|
57
62
|
const drive = (sb, args, env = {}, cwd = sb.repo) => {
|
|
58
63
|
const cap = (name) => join(sb.dir, name);
|
|
59
64
|
for (const name of ['log', 'argv', 'stdin']) rmSync(cap(name), { force: true });
|
|
@@ -239,7 +244,7 @@ describe('the fallback by version and by the refused record — spec:jev-every-r
|
|
|
239
244
|
describe('the profile error item before the turn — spec:jev-every-run/S11', () => {
|
|
240
245
|
for (const [label, shape] of [['the P13 shape', P13], ['the P1 shape', P1]]) {
|
|
241
246
|
it(`${label}, printed twice before turn.started: exit 72, one entry appended, a transport-failure receipt`, { skip: profileSkip }, () => {
|
|
242
|
-
const sb = sandbox(repos);
|
|
247
|
+
const sb = withApprovedTask(sandbox(repos));
|
|
243
248
|
const r = drive(sb, ['--nonce', 'n1', 'task.md'], { CODEX_FAKE_PRE: `${shape}\n${shape}` });
|
|
244
249
|
assert.equal(r.status, 72, r.stderr);
|
|
245
250
|
assert.ok(r.stderr.includes(JSON.parse(shape).item.message), 'the matched message is printed');
|
|
@@ -260,7 +265,7 @@ describe('the profile error item before the turn — spec:jev-every-run/S11', ()
|
|
|
260
265
|
});
|
|
261
266
|
}
|
|
262
267
|
it('a failed write warns once naming the path and still exits 72 with its receipt', { skip: profileSkip }, () => {
|
|
263
|
-
const sb = sandbox(repos);
|
|
268
|
+
const sb = withApprovedTask(sandbox(repos));
|
|
264
269
|
mkdirSync(dirname(dirname(sb.state)), { recursive: true });
|
|
265
270
|
writeFileSync(dirname(sb.state), 'a file where the state directory belongs\n');
|
|
266
271
|
const r = drive(sb, ['--nonce', 'n1', 'task.md'], { CODEX_FAKE_PRE: P13 });
|
|
@@ -271,7 +276,7 @@ describe('the profile error item before the turn — spec:jev-every-run/S11', ()
|
|
|
271
276
|
});
|
|
272
277
|
describe('bwrap: execvp in a failed command — spec:jev-every-run/S12', () => {
|
|
273
278
|
it('exits 72 without touching the state file', { skip: profileSkip }, () => {
|
|
274
|
-
const sb = sandbox(repos);
|
|
279
|
+
const sb = withApprovedTask(sandbox(repos));
|
|
275
280
|
const r = drive(sb, ['--nonce', 'n1', 'task.md'], { CODEX_FAKE_POST: command(BWRAP, 1, 'failed') });
|
|
276
281
|
assert.equal(r.status, 72, r.stderr);
|
|
277
282
|
assert.ok(r.stderr.includes('bwrap: execvp'), r.stderr);
|
|
@@ -281,7 +286,7 @@ describe('bwrap: execvp in a failed command — spec:jev-every-run/S12', () => {
|
|
|
281
286
|
});
|
|
282
287
|
describe('the same strings where they never fire — spec:jev-every-run/S13', () => {
|
|
283
288
|
it('inside a successful command\'s output and in the final message: exit 0, a success receipt, no state file', { skip: profileSkip }, () => {
|
|
284
|
-
const sb = sandbox(repos);
|
|
289
|
+
const sb = withApprovedTask(sandbox(repos));
|
|
285
290
|
const r = drive(sb, ['--nonce', 'n1', 'task.md'], { CODEX_FAKE_POST: command(`${P13_TEXT}\n${BWRAP}`, 0, 'completed'),
|
|
286
291
|
CODEX_FAKE_FINAL: `${P13_TEXT} ${BWRAP}` });
|
|
287
292
|
assertProfile(r);
|
|
@@ -292,7 +297,7 @@ describe('the same strings where they never fire — spec:jev-every-run/S13', ()
|
|
|
292
297
|
});
|
|
293
298
|
describe('the exec banner and the receipt — spec:jev-every-run/S14', () => {
|
|
294
299
|
it('a profile run reads sandbox=jev-profile and the two hosts before source=, the receipt keys unchanged', { skip: profileSkip }, () => {
|
|
295
|
-
const sb = sandbox(repos);
|
|
300
|
+
const sb = withApprovedTask(sandbox(repos));
|
|
296
301
|
const r = drive(sb, ['--nonce', 'n1', 'task.md']);
|
|
297
302
|
assertProfile(r);
|
|
298
303
|
assert.equal(bannerOf(r), banner('jev-profile', HOSTS));
|
|
@@ -193,8 +193,12 @@ Receipt:
|
|
|
193
193
|
name empty-report) or the report IS on disk and the terminal receipt was not completed (the absorb
|
|
194
194
|
reads it, report-if-present). The post-report lane never claims the reservation still stands,
|
|
195
195
|
because after that point its fate is no longer something this run observed. Every lane names the
|
|
196
|
-
tree as partial/dirtied rather than untouched. A
|
|
197
|
-
|
|
196
|
+
tree as partial/dirtied rather than untouched. A nonced run also refuses pre-spend, reserving
|
|
197
|
+
nothing, unless its contract file carries exactly one top-level aw-plan-approval block of exactly
|
|
198
|
+
plan, approval and check whose check (the kit's tools/plan-approval/cli.mjs check <plan> --digest
|
|
199
|
+
<approval>) exits 0, so a nonced run never starts unless the approval record matches the block's own plan and approval; the kit's
|
|
200
|
+
tools/stage-render/cli.mjs --dispatch <plan> prints that block. A nonce-LESS invocation is
|
|
201
|
+
byte-unchanged: no reservation, no receipt, no artifact, and it needs no node.
|
|
198
202
|
|
|
199
203
|
Notes:
|
|
200
204
|
nested-sandbox limit: codex-exec ships its OWN OS sandbox (bwrap workspace-write) and cannot run
|
|
@@ -513,7 +517,7 @@ CHATGPT_LOGIN_GUARD="Logged in using ChatGPT"
|
|
|
513
517
|
# receipt this wrapper mints; scripts/release/version-sync.mjs bumps it under the one-anchor-per-file
|
|
514
518
|
# rule, so a release can never leave it behind (the AD-053 drift class).
|
|
515
519
|
AW_RECEIPT_BACKEND="codex"
|
|
516
|
-
AW_BRIDGE_VERSION="
|
|
520
|
+
AW_BRIDGE_VERSION="7.0.0" # aw-version-anchor
|
|
517
521
|
# The kill grace handed to timeout(1) as --kill-after, and recorded in the receipt as killGraceS:
|
|
518
522
|
# ONE constant, so the number the ledger checks against the dispatch deadline is the number the run
|
|
519
523
|
# actually applied.
|
|
@@ -962,7 +966,7 @@ if [[ -z "${task//[[:space:]]/}" ]]; then
|
|
|
962
966
|
exit 2
|
|
963
967
|
fi
|
|
964
968
|
|
|
965
|
-
# --- The ACCOUNTED lane:
|
|
969
|
+
# --- The ACCOUNTED lane: the mint core below fires only for a NONCED run ------
|
|
966
970
|
# A nonce-LESS invocation is byte-unchanged — no reservation, no receipt, no artifact, needs no node —
|
|
967
971
|
# which is what keeps every existing caller working. The whole mint core rides ONE node script per
|
|
968
972
|
# step (the family floor, codex-review.sh's finding-manifest precedent): a bash re-implementation of
|
|
@@ -1029,31 +1033,40 @@ AW_JS
|
|
|
1029
1033
|
NODE_OPTIONS= node -e "$aw_js" "$common"
|
|
1030
1034
|
}
|
|
1031
1035
|
|
|
1032
|
-
# The
|
|
1033
|
-
#
|
|
1034
|
-
#
|
|
1035
|
-
#
|
|
1036
|
-
#
|
|
1037
|
-
#
|
|
1038
|
-
# fence is outside the block either way.
|
|
1036
|
+
# The two blocks this run is accountable for, both read from the bytes ALREADY loaded as the prompt
|
|
1037
|
+
# (fed on stdin) rather than from a second open of the path. That single read is load-bearing: two
|
|
1038
|
+
# reads leave a window in which the file can be swapped, and the run would then execute contract A
|
|
1039
|
+
# while its receipt claimed the digest of B — a return the ledger would accept. Dropping the trailing
|
|
1040
|
+
# newlines (`$( )` does) cannot move the digest: the digest is taken over the PARSED object and the
|
|
1041
|
+
# fence walk is line-based, so anything after the closing fence is outside the block either way.
|
|
1039
1042
|
#
|
|
1040
|
-
#
|
|
1041
|
-
# newline) of the ONE top-level
|
|
1042
|
-
#
|
|
1043
|
-
#
|
|
1044
|
-
# extractContractBlock — nesting-aware, so a
|
|
1045
|
-
# text; both line endings accepted.
|
|
1046
|
-
# `open` is the single form door, and a second one would
|
|
1047
|
-
#
|
|
1048
|
-
|
|
1043
|
+
# Part `header` answers the contract's `nonce` and `contractDigest`: sha256 over the CANONICAL
|
|
1044
|
+
# serialization (recursively key-sorted JSON, no trailing newline) of the ONE top-level
|
|
1045
|
+
# ```aw-dispatch-contract block. Independently produced HERE: without it the ledger would compare a
|
|
1046
|
+
# dispatch record against values derived from itself, and a run that executed a DIFFERENT contract
|
|
1047
|
+
# would correlate cleanly. The fence walk mirrors the kit's extractContractBlock — nesting-aware, so a
|
|
1048
|
+
# marker inside another fenced block is example text; both line endings accepted. The contract's FORM
|
|
1049
|
+
# is deliberately NOT validated here: the kit's `open` is the single form door, and a second one would
|
|
1050
|
+
# drift. The ONE field validated is `nonce`, because this wrapper COMPARES it.
|
|
1051
|
+
#
|
|
1052
|
+
# Part `approval` judges the ONE top-level ```aw-plan-approval block whole, since no kit door reads it
|
|
1053
|
+
# before the run, and runs its check (spec plan-approval): a non-zero exit refuses.
|
|
1054
|
+
aw_read_dispatch_blocks() {
|
|
1049
1055
|
local aw_js=""
|
|
1050
1056
|
IFS= read -r -d '' aw_js <<'AW_JS' || true
|
|
1051
1057
|
const fs = require("node:fs");
|
|
1058
|
+
const { isAbsolute } = require("node:path");
|
|
1059
|
+
const { spawnSync } = require("node:child_process");
|
|
1052
1060
|
const { createHash } = require("node:crypto");
|
|
1053
1061
|
const INFO = "aw-dispatch-contract";
|
|
1062
|
+
const APPROVAL_INFO = "aw-plan-approval";
|
|
1063
|
+
const APPROVAL_KEYS = "approval,check,plan";
|
|
1064
|
+
const APPROVAL_DIGEST = /^[0-9a-f]{64}$/;
|
|
1065
|
+
const CHECK_TAIL = "/tools/plan-approval/cli.mjs";
|
|
1054
1066
|
const FENCE = /^(`{3,})(.*)$/;
|
|
1055
1067
|
const SAFE = /^[A-Za-z0-9._-]{1,64}$/;
|
|
1056
1068
|
const die = (m) => { process.stderr.write("error: dispatch contract — " + m + ".\n"); process.exit(2); };
|
|
1069
|
+
const refuse = (m) => { process.stderr.write("error: plan approval — " + m + ".\n"); process.exit(2); };
|
|
1057
1070
|
let text;
|
|
1058
1071
|
try { text = fs.readFileSync(0, "utf8"); } catch (err) { die("cannot read the dispatch contract bytes (" + (err && err.code) + ")"); }
|
|
1059
1072
|
const lines = text.split(/\r?\n/);
|
|
@@ -1066,26 +1079,48 @@ for (let i = 0; i < lines.length; i += 1) {
|
|
|
1066
1079
|
const info = fence[2].trim();
|
|
1067
1080
|
if (openTicks === 0) { openTicks = ticks; openInfo = info; openAt = i; continue; }
|
|
1068
1081
|
if (info === "" && ticks >= openTicks) {
|
|
1069
|
-
|
|
1082
|
+
blocks.push({ info: openInfo, body: lines.slice(openAt + 1, i).join("\n") });
|
|
1070
1083
|
openTicks = 0; openInfo = ""; openAt = -1;
|
|
1071
1084
|
}
|
|
1072
1085
|
}
|
|
1086
|
+
const bodiesOf = (wanted) => blocks.filter((block) => block.info === wanted).map((block) => block.body);
|
|
1087
|
+
const contracts = bodiesOf(INFO);
|
|
1073
1088
|
if (openTicks !== 0 && openInfo === INFO) die("the ```" + INFO + " block is never closed");
|
|
1074
|
-
if (
|
|
1075
|
-
if (
|
|
1089
|
+
if (contracts.length === 0) die("no top-level ```" + INFO + " block found — an accounted dispatch runs a contract");
|
|
1090
|
+
if (contracts.length > 1) die(contracts.length + " ```" + INFO + " blocks found — a dispatch file carries exactly one");
|
|
1076
1091
|
let contract;
|
|
1077
|
-
try { contract = JSON.parse(
|
|
1092
|
+
try { contract = JSON.parse(contracts[0]); } catch { die("the ```" + INFO + " block body is not valid JSON"); }
|
|
1078
1093
|
if (contract === null || typeof contract !== "object" || Array.isArray(contract)) die("the ```" + INFO + " block body must be ONE JSON object");
|
|
1079
1094
|
if (typeof contract.nonce !== "string" || !SAFE.test(contract.nonce)) die("the header carries no nonce in the safe grammar ([A-Za-z0-9._-]{1,64}) — an accounted dispatch is identified by the nonce the ledger copied from this header");
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1095
|
+
if (process.argv[1] === "header") {
|
|
1096
|
+
const ser = (v) => (Array.isArray(v)
|
|
1097
|
+
? "[" + v.map(ser).join(",") + "]"
|
|
1098
|
+
: (v !== null && typeof v === "object")
|
|
1099
|
+
? "{" + Object.keys(v).sort().map((k) => JSON.stringify(k) + ":" + ser(v[k])).join(",") + "}"
|
|
1100
|
+
: JSON.stringify(v));
|
|
1101
|
+
process.stdout.write(contract.nonce + "\n" + createHash("sha256").update(ser(contract), "utf8").digest("hex"));
|
|
1102
|
+
process.exit(0);
|
|
1103
|
+
}
|
|
1104
|
+
const approvals = bodiesOf(APPROVAL_INFO);
|
|
1105
|
+
if (openTicks !== 0 && openInfo === APPROVAL_INFO) refuse("the ```" + APPROVAL_INFO + " block is never closed");
|
|
1106
|
+
if (approvals.length === 0) refuse("no top-level ```" + APPROVAL_INFO + " block found — a nonced run executes a slice of an approved plan, and the kit's tools/stage-render/cli.mjs --dispatch <plan> prints that block");
|
|
1107
|
+
if (approvals.length > 1) refuse(approvals.length + " ```" + APPROVAL_INFO + " blocks found — a dispatch file carries exactly one");
|
|
1108
|
+
let record;
|
|
1109
|
+
try { record = JSON.parse(approvals[0]); } catch { refuse("the ```" + APPROVAL_INFO + " block body is not valid JSON"); }
|
|
1110
|
+
if (record === null || typeof record !== "object" || Array.isArray(record) || Object.keys(record).sort().join(",") !== APPROVAL_KEYS) refuse("the ```" + APPROVAL_INFO + " block body must be ONE JSON object of exactly plan, approval and check");
|
|
1111
|
+
const { plan, approval, check } = record;
|
|
1112
|
+
if (typeof approval !== "string" || !APPROVAL_DIGEST.test(approval)) refuse("approval must be 64 lower-case hex, got " + JSON.stringify(approval));
|
|
1113
|
+
if (typeof plan !== "string" || plan === "" || plan.startsWith("-")) refuse("plan must be a non-empty path that does not start with '-', got " + JSON.stringify(plan));
|
|
1114
|
+
if (typeof check !== "string" || !isAbsolute(check) || !check.endsWith(CHECK_TAIL)) refuse("check must be an absolute path ending " + CHECK_TAIL.slice(1) + ", got " + JSON.stringify(check));
|
|
1115
|
+
let checkStat;
|
|
1116
|
+
try { checkStat = fs.statSync(check); } catch (err) { refuse("the check " + JSON.stringify(check) + " cannot be read (" + (err && err.code) + ")"); }
|
|
1117
|
+
if (!checkStat.isFile()) refuse("the check " + JSON.stringify(check) + " is not a regular file");
|
|
1118
|
+
const run = spawnSync(process.execPath, [check, "check", plan, "--digest", approval], { stdio: ["ignore", 2, 2], env: { ...process.env, NODE_OPTIONS: "" } });
|
|
1119
|
+
if (run.error) refuse("the check " + JSON.stringify(check) + " could not start (" + run.error.code + ")");
|
|
1120
|
+
if (run.status !== 0) refuse("no approval record matches the plan " + JSON.stringify(plan) + ": its check exited " + (run.status === null ? "on the signal " + run.signal : run.status) + " (see above)");
|
|
1086
1121
|
AW_JS
|
|
1087
|
-
aw_require_core "$aw_js" "the
|
|
1088
|
-
printf '%s' "$1" | NODE_OPTIONS= node -e "$aw_js"
|
|
1122
|
+
aw_require_core "$aw_js" "the dispatch-block reader" || return 1
|
|
1123
|
+
printf '%s' "$1" | NODE_OPTIONS= node -e "$aw_js" "$2"
|
|
1089
1124
|
}
|
|
1090
1125
|
|
|
1091
1126
|
if [[ -n "$aw_nonce" ]]; then
|
|
@@ -1116,7 +1151,7 @@ if [[ -n "$aw_nonce" ]]; then
|
|
|
1116
1151
|
fi
|
|
1117
1152
|
aw_artifact_dir="${aw_dir_raw%x}"
|
|
1118
1153
|
aw_header=""
|
|
1119
|
-
if ! aw_header="$(
|
|
1154
|
+
if ! aw_header="$(aw_read_dispatch_blocks "$task" header)"; then
|
|
1120
1155
|
echo "error: the prompt '$prompt_src' carries no readable dispatch contract (see above) — an accounted dispatch is refused before any spend." >&2
|
|
1121
1156
|
exit 2
|
|
1122
1157
|
fi
|
|
@@ -1130,6 +1165,10 @@ if [[ -n "$aw_nonce" ]]; then
|
|
|
1130
1165
|
echo "error: the dispatch nonce '$aw_nonce' does not match the contract header's nonce '$aw_contract_nonce' — 'dispatch open' copies the nonce FROM the header, so this run would reserve an identity no return could absorb; nothing was reserved and nothing was spent." >&2
|
|
1131
1166
|
exit 2
|
|
1132
1167
|
fi
|
|
1168
|
+
if ! aw_read_dispatch_blocks "$task" approval; then
|
|
1169
|
+
echo "error: the prompt '$prompt_src' carries no approval that its check matches (see above) — a nonced run executes only an approved plan; nothing was reserved and nothing was spent." >&2
|
|
1170
|
+
exit 2
|
|
1171
|
+
fi
|
|
1133
1172
|
fi
|
|
1134
1173
|
|
|
1135
1174
|
# --- Enforced git-write boundary (physical shim file) ------------------------
|
|
@@ -9,7 +9,7 @@ import { join, dirname, resolve } from 'node:path';
|
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
10
|
import { spawnSync, execFile } from 'node:child_process';
|
|
11
11
|
import { createHash } from 'node:crypto';
|
|
12
|
-
import { makeFixtureRepo } from './codex-fixtures-harness.test.mjs';
|
|
12
|
+
import { composeApprovalBlock, makeFixtureRepo, writeStubCheck } from './codex-fixtures-harness.test.mjs';
|
|
13
13
|
|
|
14
14
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
15
15
|
const WRAPPER = join(HERE, 'codex-exec.sh');
|
|
@@ -1088,6 +1088,13 @@ describe('codex-exec.sh — --help contract (manifest-pinned)', { concurrency: 2
|
|
|
1088
1088
|
assert.equal(norm(helpSection(help, 'Notes:').join(' ')), norm(EXEC_CONTRACT.notes.join(' ')));
|
|
1089
1089
|
});
|
|
1090
1090
|
|
|
1091
|
+
it('Receipt names the aw-plan-approval stop: a nonced run without a matching approval refuses pre-spend', async () => {
|
|
1092
|
+
const receipt = norm(helpSection(runHelp('--help').stdout, 'Receipt:').join(' '));
|
|
1093
|
+
const sentence = receipt.split(/(?<=\.)\s+/).find((part) => part.includes('aw-plan-approval'));
|
|
1094
|
+
assert.ok(sentence, 'the Receipt section names the aw-plan-approval stop');
|
|
1095
|
+
for (const word of [/nonce/i, /approval/i, /match/i, /pre-spend/i]) assert.match(sentence, word);
|
|
1096
|
+
});
|
|
1097
|
+
|
|
1091
1098
|
it('--help after the -- separator is passthrough payload, never intercepted', async () => {
|
|
1092
1099
|
const sb = makeSandbox();
|
|
1093
1100
|
const r = await run(sb, { args: ['-', '--', '--help'], input: 'go' });
|
|
@@ -1740,7 +1747,11 @@ const readReceipt = (dir, nonce) => JSON.parse(readFileSync(join(dir, receiptNam
|
|
|
1740
1747
|
// A dispatch file carrying exactly ONE top-level contract block — the same shape `dispatch open
|
|
1741
1748
|
// --contract` parses, so the digest the wrapper computes here is the digest the ledger recorded.
|
|
1742
1749
|
const CONTRACT_FENCE = '```';
|
|
1743
|
-
const
|
|
1750
|
+
const APPROVED_PLAN = 'docs/plans/approved-plan.md';
|
|
1751
|
+
const APPROVAL = createHash('sha256').update('the approved essence').digest('hex');
|
|
1752
|
+
const approvalOf = (sb, over = {}) => ({ plan: APPROVED_PLAN, approval: APPROVAL, ...over, check: over.check ?? writeStubCheck(sb.root) });
|
|
1753
|
+
const approvalBlockFor = (sb, over = {}) => composeApprovalBlock(approvalOf(sb, over));
|
|
1754
|
+
const writeContract = (sb, nonce, over = {}, approvalBlock = approvalBlockFor(sb)) => {
|
|
1744
1755
|
const contract = {
|
|
1745
1756
|
schema: 1,
|
|
1746
1757
|
nonce,
|
|
@@ -1754,7 +1765,7 @@ const writeContract = (sb, nonce, over = {}) => {
|
|
|
1754
1765
|
};
|
|
1755
1766
|
const rel = `${nonce}-dispatch.md`;
|
|
1756
1767
|
writeFileSync(join(sb.repo, rel),
|
|
1757
|
-
`# sub-task\n\n${CONTRACT_FENCE}aw-dispatch-contract\n${JSON.stringify(contract, null, 2)}\n${CONTRACT_FENCE}\n`);
|
|
1768
|
+
`# sub-task\n\n${CONTRACT_FENCE}aw-dispatch-contract\n${JSON.stringify(contract, null, 2)}\n${CONTRACT_FENCE}\n${approvalBlock}`);
|
|
1758
1769
|
return rel;
|
|
1759
1770
|
};
|
|
1760
1771
|
|
|
@@ -2050,6 +2061,103 @@ describe('codex-exec.sh — the pre-spend reservation (D1/D8)', { concurrency: 2
|
|
|
2050
2061
|
});
|
|
2051
2062
|
});
|
|
2052
2063
|
|
|
2064
|
+
const APPROVAL_MODES = [
|
|
2065
|
+
{ label: 'fresh', args: (file) => ['--nonce', 'appr', file] },
|
|
2066
|
+
{ label: '--resume <id>', args: (file) => ['--resume', 'sess-xyz', '--nonce', 'appr', file] },
|
|
2067
|
+
{ label: '--resume-last', args: (file) => ['--resume-last', '--nonce', 'appr', file] },
|
|
2068
|
+
];
|
|
2069
|
+
const fenceApproval = (body) => `${CONTRACT_FENCE}aw-plan-approval\n${body}\n${CONTRACT_FENCE}\n`;
|
|
2070
|
+
const runApproval = async (blockFor, mode) => {
|
|
2071
|
+
const sb = makeSandbox();
|
|
2072
|
+
writeFileSync(join(sb.repo, '.codex-last-session'), 'sess-from-sidecar\n');
|
|
2073
|
+
const r = await run(sb, { args: mode.args(writeContract(sb, 'appr', {}, blockFor(sb))) });
|
|
2074
|
+
const callsFile = join(sb.root, 'check-calls.jsonl');
|
|
2075
|
+
const calls = existsSync(callsFile) ? readFileSync(callsFile, 'utf8').split('\n').filter(Boolean).map((line) => JSON.parse(line)) : [];
|
|
2076
|
+
const artifacts = execArtifacts(storeDirOf(sb));
|
|
2077
|
+
const receipt = artifacts.includes(receiptName('appr')) ? readReceipt(storeDirOf(sb), 'appr') : null;
|
|
2078
|
+
rmSync(sb.root, { recursive: true, force: true });
|
|
2079
|
+
return { ...r, calls, artifacts, receipt };
|
|
2080
|
+
};
|
|
2081
|
+
const REFUSED_APPROVALS = [
|
|
2082
|
+
['an absent block', () => ''],
|
|
2083
|
+
['a doubled block', (sb) => approvalBlockFor(sb) + approvalBlockFor(sb)],
|
|
2084
|
+
['a block with an extra key', (sb) => fenceApproval(JSON.stringify({ ...approvalOf(sb), extra: 'x' }))],
|
|
2085
|
+
['a block without check', () => fenceApproval(JSON.stringify({ plan: APPROVED_PLAN, approval: APPROVAL }))],
|
|
2086
|
+
['a block holding an array', (sb) => fenceApproval(JSON.stringify([approvalOf(sb)]))],
|
|
2087
|
+
['a block that is no JSON', () => fenceApproval(`plan: ${APPROVED_PLAN}`)],
|
|
2088
|
+
['an approval of 63 hex', (sb) => approvalBlockFor(sb, { approval: APPROVAL.slice(1) })],
|
|
2089
|
+
['an upper-case approval', (sb) => approvalBlockFor(sb, { approval: APPROVAL.toUpperCase() })],
|
|
2090
|
+
['an approval that is not hex', (sb) => approvalBlockFor(sb, { approval: 'g'.repeat(64) })],
|
|
2091
|
+
['a plan starting with -', (sb) => approvalBlockFor(sb, { plan: `-${APPROVED_PLAN}` })],
|
|
2092
|
+
['an empty plan', (sb) => approvalBlockFor(sb, { plan: '' })],
|
|
2093
|
+
['a relative check path', (sb) => {
|
|
2094
|
+
writeStubCheck(sb.repo);
|
|
2095
|
+
return approvalBlockFor(sb, { check: join('tools', 'plan-approval', 'cli.mjs') });
|
|
2096
|
+
}],
|
|
2097
|
+
['a check path that does not exist', (sb) => approvalBlockFor(sb, { check: join(sb.root, 'absent', 'tools', 'plan-approval', 'cli.mjs') })],
|
|
2098
|
+
['a check path that is a directory', (sb) => {
|
|
2099
|
+
const folder = join(sb.root, 'folder', 'tools', 'plan-approval', 'cli.mjs');
|
|
2100
|
+
mkdirSync(folder, { recursive: true });
|
|
2101
|
+
return approvalBlockFor(sb, { check: folder });
|
|
2102
|
+
}],
|
|
2103
|
+
['a check file not named cli.mjs', (sb) => {
|
|
2104
|
+
const other = join(sb.root, 'tools', 'plan-approval', 'check.mjs');
|
|
2105
|
+
cpSync(writeStubCheck(sb.root), other);
|
|
2106
|
+
return approvalBlockFor(sb, { check: other });
|
|
2107
|
+
}],
|
|
2108
|
+
['a check that exits non-zero', (sb) => approvalBlockFor(sb, { check: writeStubCheck(sb.root, { status: 1 }) })],
|
|
2109
|
+
['a block standing only inside another fence', (sb) => `${CONTRACT_FENCE}\`md\n${approvalBlockFor(sb)}${CONTRACT_FENCE}\`\n`],
|
|
2110
|
+
];
|
|
2111
|
+
|
|
2112
|
+
describe('codex-exec.sh — a nonced run checks the plan approval — spec:plan-approval/S8', { concurrency: 2 }, () => {
|
|
2113
|
+
for (const [label, blockFor] of REFUSED_APPROVALS) {
|
|
2114
|
+
it(`${label}: exit 2 before any reservation or spend, fresh, --resume and --resume-last`, async () => {
|
|
2115
|
+
for (const mode of APPROVAL_MODES) {
|
|
2116
|
+
const r = await runApproval(blockFor, mode);
|
|
2117
|
+
assert.equal(r.status, 2, `${mode.label}: ${r.stderr}`);
|
|
2118
|
+
assert.equal(r.argv, '', `${mode.label}: the fake CLI was never started`);
|
|
2119
|
+
assert.deepEqual(r.artifacts, [], `${mode.label}: nothing was reserved`);
|
|
2120
|
+
}
|
|
2121
|
+
});
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
it('a check that exits 0 lets every mode proceed, called as check <plan> --digest <approval>, the contract digest unchanged', async () => {
|
|
2125
|
+
const digests = [];
|
|
2126
|
+
for (const [index, mode] of APPROVAL_MODES.entries()) {
|
|
2127
|
+
const plan = `docs/plans/approved-${index}.md`;
|
|
2128
|
+
const approval = createHash('sha256').update(plan).digest('hex');
|
|
2129
|
+
const r = await runApproval((sb) => approvalBlockFor(sb, { plan, approval }), mode);
|
|
2130
|
+
assert.equal(r.status, 0, `${mode.label}: ${r.stderr}`);
|
|
2131
|
+
assert.deepEqual(r.calls, [['check', plan, '--digest', approval]], `${mode.label}: the check ran once on the block's plan and approval`);
|
|
2132
|
+
assert.match(r.argv, /(^|\n)exec(\n|$)/, `${mode.label}: codex exec was reached`);
|
|
2133
|
+
assert.equal(r.receipt?.state, 'terminal', `${mode.label}: the run published its terminal receipt`);
|
|
2134
|
+
digests.push(r.receipt.contractDigest);
|
|
2135
|
+
}
|
|
2136
|
+
assert.equal(new Set(digests).size, 1, 'the approval block never enters the contract digest');
|
|
2137
|
+
});
|
|
2138
|
+
|
|
2139
|
+
it('a nonce-less run is byte-unchanged and needs no node', async () => {
|
|
2140
|
+
const sb = makeSandbox();
|
|
2141
|
+
const refusing = writeStubCheck(join(sb.root, 'refusing'), { status: 1 });
|
|
2142
|
+
const file = writeContract(sb, 'plain', {}, approvalBlockFor(sb, { check: refusing }));
|
|
2143
|
+
const withNode = await run(sb, { args: [file] });
|
|
2144
|
+
clearCaptures(sb);
|
|
2145
|
+
const withoutNode = await run(sb, { args: [file], path: `${sb.bin}:${farmFor(['node'])}` });
|
|
2146
|
+
const checked = existsSync(join(sb.root, 'refusing', 'check-calls.jsonl'));
|
|
2147
|
+
const prompt = readFileSync(join(sb.repo, file), 'utf8');
|
|
2148
|
+
const artifacts = execArtifacts(storeDirOf(sb));
|
|
2149
|
+
rmSync(sb.root, { recursive: true, force: true });
|
|
2150
|
+
for (const r of [withNode, withoutNode]) {
|
|
2151
|
+
assert.equal(r.status, 0, r.stderr);
|
|
2152
|
+
assert.ok(r.capStdin.includes(prompt.trimEnd()), 'the prompt reaches codex byte for byte');
|
|
2153
|
+
}
|
|
2154
|
+
assert.equal(withoutNode.stdout, withNode.stdout);
|
|
2155
|
+
assert.equal(withoutNode.capStdin, withNode.capStdin);
|
|
2156
|
+
assert.equal(checked, false, 'a nonce-less run never runs the check');
|
|
2157
|
+
assert.deepEqual(artifacts, []);
|
|
2158
|
+
});
|
|
2159
|
+
});
|
|
2160
|
+
|
|
2053
2161
|
describe('codex-exec.sh — the fail-closed terminal receipt (D1/D3/3.1.d)', { concurrency: 2 }, () => {
|
|
2054
2162
|
it('a SUCCESSFUL run publishes a complete report and a terminal receipt that describes it', async () => {
|
|
2055
2163
|
const sb = makeSandbox();
|