From 8cb1905050cea7fc0f4493fa71ec634a3402b8cb Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Tue, 20 Oct 2026 16:12:42 +0000 Subject: [PATCH 1/2] GREEN's dependency check reads only the plan text the human's grant pins (M0.9, M10.2) A reviewed grant now records the plan file by file (and keeps the approved text); under an autonomy grant the plan is the one the planner's gate passed on the planner's stop (`plan.gated`, `ids gated`, gate-owned). `deps unplanned` reads only that text, so text added after the grant names no dependency and a re-plan does not undo an approved one. The approved plan now covers the sprint's intake.md and standards.md too. Tests: supply-chain.test.py 2-2e, plan-approval.test.py 4 and 21; 16/16 mutants killed. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WBVFNrEg85XAnSfHQidCXN --- CHANGELOG.md | 2 +- docs/ROADMAP.md | 4 +- plugin/bin/README.md | 6 +- plugin/bin/_approval.py | 114 ++++++++++++++++++++++++++--- plugin/bin/_events.py | 2 +- plugin/bin/deps | 45 ++++++++---- plugin/bin/events | 2 +- plugin/bin/gate-stage2-complete | 7 ++ plugin/bin/ids | 37 +++++++++- scripts/test/plan-approval.test.py | 49 ++++++++++++- scripts/test/supply-chain.test.py | 102 +++++++++++++++++++++++--- 11 files changed, 325 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e30b7676..3286c1d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ tag in lockstep. Tag releases as `vMAJOR.MINOR.PATCH`. ## [Unreleased] ### Added -- Plan approval is a gate (ROADMAP M0.9): `gate-dispatch` starts no execution role (RED, SCAFFOLD, GREEN, structural review, final gate) of a sprint until the human approved that sprint's plan as it is now. `events authority --sprint N` exits 3 with the line to type, `approve SN ` (reviewed, the code naming the sha256 of the sprint's plan files) or `autonomous SN ` (autonomy for that sprint, re-plans included, the code naming the authority record); the task contract's `STORY_DIR` and task must be a live story and task of that plan's frozen `ids.json`; the line must be among the human's captured prompts and typed after the sprint's last decision (M9.17's mechanism). A changed plan, a re-plan in reviewed mode, a roll-back to an old line, another sprint's line, a negated line and a hand-edited or emitted record all block (`plan.approved` and `human.approval` cannot be `events emit`ted); an approved autonomous mission grants its own sprints autonomy with no line. `events approval SPRINT|TASK_ID` is the check. Codex's `spawn_agent` (`agent_type`, `message`) and OpenCode's `task` now reach `gate-dispatch` too, and `claude -p`, `codex exec` and `opencode run` from a tool call are blocked in every aloop project, not only where a mission is set. `e2e-live.sh` pre-approves with an `autonomous S1 ` line in its prompt. Reason: the north star allows no human help beyond approval, and the approval was a playbook rule a supervisor could skip. A 4-lens adversarial review found 9 defects: 7 fixed with a check red on the first head (cross-sprint or unplanned `STORY_DIR`, a retyped line kept stale, mission autonomy over a non-mission sprint, `transcripts prune` dropping the prompts grants cite, `codex plugin add` refused, a code past column 200, a crash on a malformed run-log line), 2 in the playbook (intake reuses a mission's handed-off intent; a reviewed re-plan waits for the human's new line). `transcripts prune` now keeps the human's prompts. Test: `plan-approval.test.py` (20 checks, red on master), plus the host suites. +- Plan approval is a gate (ROADMAP M0.9): `gate-dispatch` starts no execution role (RED, SCAFFOLD, GREEN, structural review, final gate) of a sprint until the human approved that sprint's plan as it is now. `events authority --sprint N` exits 3 with the line to type, `approve SN ` (reviewed, the code naming the sha256 of the sprint's plan files, its intake and standards included) or `autonomous SN ` (autonomy for that sprint, re-plans included, the code naming the authority record); the task contract's `STORY_DIR` and task must be a live story and task of that plan's frozen `ids.json`; the line must be among the human's captured prompts and typed after the sprint's last decision (M9.17's mechanism). A changed plan, a re-plan in reviewed mode, a roll-back to an old line, another sprint's line, a negated line and a hand-edited or emitted record all block (`plan.approved` and `human.approval` cannot be `events emit`ted); an approved autonomous mission grants its own sprints autonomy with no line. `events approval SPRINT|TASK_ID` is the check. Codex's `spawn_agent` (`agent_type`, `message`) and OpenCode's `task` now reach `gate-dispatch` too, and `claude -p`, `codex exec` and `opencode run` from a tool call are blocked in every aloop project, not only where a mission is set. `e2e-live.sh` pre-approves with an `autonomous S1 ` line in its prompt. Reason: the north star allows no human help beyond approval, and the approval was a playbook rule a supervisor could skip. A 4-lens adversarial review found 9 defects: 7 fixed with a check red on the first head (cross-sprint or unplanned `STORY_DIR`, a retyped line kept stale, mission autonomy over a non-mission sprint, `transcripts prune` dropping the prompts grants cite, `codex plugin add` refused, a code past column 200, a crash on a malformed run-log line), 2 in the playbook (intake reuses a mission's handed-off intent; a reviewed re-plan waits for the human's new line). `transcripts prune` now keeps the human's prompts. Test: `plan-approval.test.py` (20 checks, red on master), plus the host suites. The approved plan's files include the sprint's `intake.md` and `standards.md`, and a grant pins them file by file: GREEN's check for an unplanned dependency reads only the text the human's grant pins, the plan they approved or, under their autonomy grant, the plan as the planner's gate last passed it (`gate-stage2-complete` records `plan.gated` on the planner's stop), as it was then, so text added later names nothing and a re-plan does not undo an approved dependency. - Core agent principles and the one-way / two-way door rule (ROADMAP §4.12, M9.30): seven core principles from Amazon's Leadership Principles, the door rule first, go to every aloop agent at session start (`aloop mission principles show --core`). A two-way door (a branch, a local edit, a test, a draft PR) is decided, not asked. A one-way door (`aloop mission doors list`: a push or merge to the default branch, a force-push, a release, a deploy, a message sent outside, a secret, dropped data, …) is stopped by a PreToolUse gate with `ASK[door] ` until the human records an authorization in their own terminal (`aloop mission doors authorize ID --by NAME --reason TEXT [--until DATE] [--once DIGEST]`, a hash-chained ledger row); a wall (switching a gate off, forging a human record) is never crossed. While a run is live, a question to the human must name a door the gate stopped and nobody authorized. Reason: Adeel's request that agents decide two-way doors themselves and ask only at a one-way door not already authorized. Test: `mission-doors.test.py`. Hardened by an adversarial review (15 findings, each a test): the gate reads Bash as the shell does (comments, line continuations, heredoc bodies, `xargs`, `find -exec`, `echo … | sh`), a branch condition reads the directory the command acts on (`git -C`, `cd`), settings are guarded wherever they live, dry runs and `command -v` are two-way, the newest decision by time counts and a revoke holds on every branch, a once-grant is crossed once under a lock, a broken ledger is named, and `doors authorize` refuses an agent's shell. - DeepSeek Harness (dsh) host (ROADMAP §4.9): `aloop install dsh` (alias `deepseek`; `--project P` or `--global`) renders a `dsh --profile aloop` profile in `$DSH_HOME` and installs the skills. Its native plugin (`plugin/hosts/dsh/aloop.mjs`) runs the same gates as Claude Code on dsh's own events: a deny before a tool runs, a block after an invalid artifact write, and a stop gate that steers a role back up to 3 times before the supervisor is told it is BLOCKED (or STUCK, released unverified). Roles are agent presets on two subagent tools, one per model route (`deepseek-v4-pro` for planning, `deepseek-flash` for work by default; `MODEL_PLANNING_DSH` / `MODEL_WORKER_DSH` override). A writer's `aloop bind` moves its working directory into its worktree, and `host-adapter` confines its commands, edits and `working_directory` there. Usage is recorded Claude-shaped per role, so budgets, the ledger and `run-summary` work unchanged. `make e2e-live HOST=dsh` drives it live and exits 2 with the fix when no `DEEPSEEK_API_KEY` is set. Reason: DeepSeek's own harness is the cheapest route to a strong model. The profile records the project it serves (or `--global`), so another project's `aloop-init` never re-renders it, and gates get the worker shell's environment (no API key). The mission layer's six roles run on dsh too: presets on their route group's subagent tool, `gate-mission-scope` on every write and command, and `gate-mission-artifact` at each role's start and stop; the mission skill installs as `aloop-mission`. A second review (3 lenses; 11 confirmed findings, each fixed with a test) closed: a working directory that vanished (dsh's tools move it back to the main tree, so the plugin judges `ensure()`'s directory and `host-adapter` refuses to run from a missing one), gate switches from the project's `.env` (dsh loads it; `SKIP_HOOKS`, `GATE_RUN_TESTS`, `REPO_DIR`, `AGENTIC_*` from it never reach a gate), an interrupted Stop that dropped the sprint-close notice, and the shared profile: its owner is the main tree, an older unrecorded profile is claimed only by the project that installed it, and a project it does not serve is told so by `install status`, `aloop-init` and the session itself. Tests: `dsh-plugin.test.mjs` (40 checks, emulated), `dsh-runtime.test.mjs` (32 checks on the real pinned dsh 0.2.1-rc.2 with a scripted model; the CI hosts job installs it) and `dsh-install.test.py` (9). - Brand kit and repo front page: `docs/brand/` holds the mark (an **a** whose bowl is a red-to-green loop passing a gold gate, with a 16 px cut), lockups, light and dark README banners, favicons, app icons, the site's OG card and the GitHub social preview, all generated by `docs/brand/gen_brand.py` from one palette with WCAG checks (rules in `docs/brand/README.md`). The README leads with the mission layer, the agent principles and the door rule, the supported hosts and the measured demo runs; the site carries the favicon and Open Graph/Twitter card metadata; `SECURITY.md` and bug/feature issue forms are new. diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index ca68bfba..1f3ca954 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -17,7 +17,7 @@ original plan. |---|---|---|---| | **M0 — Hygiene** | v0.10.x | Mark `DESIGN` / `ARCHITECTURE` / `KICKSTART` historical; fix stale counts (8 → 9 roles) and the README CI section; add the `CONTRIBUTING.md` the README badge links to; one live-session smoke test of the hook wiring (open since `DEVLOG` v0.1) | done: live smoke test `make smoke-live YES=1` (6 checks, ~$0.004 on haiku); its first run found the Linux fail-open in `gate-supervisor-scope` (fixed, regression test added) | | **M0.8 — North-star run** | v0.11.x | `make e2e-live YES=1`: a one-line intent (semver parser) goes through retrospective, intake, standards, planner, RED/SCAFFOLD/GREEN per task, structural review and the final gate to merged, tested code in a real Claude Code session, with the approval given up front. Reason: nothing had ever run the whole loop live; the first run found that no role gate fired on plugin installs | run 1: done end to end, 19 min, $1.15 (sonnet supervisor, haiku workers), 22 tests on main, 9/11 checks; found and fixed the `aloop:` matcher bug, a selfcheck crash and copy-merging. Run 2: **11/11**, 12m46s, $0.92, host gates on every role, worktree branches merged with `--no-ff`; found gates looping on the supervisor's contract slips (fixed). Run 3: 11/11, 12m00s, **$0.79**; found GREEN looping on RED's unformatted tests (fixed: RED/SCAFFOLD run the format check) and selfcheck missing the contract in Claude Code worktrees (fixed: the contract is copied in). Run 4 (all fixes): 11/11, 17m56s, $1.10, 12 gate blocks and no loops (28 → 17 → 12). Cost varies $0.79–1.15 per run; next: cut it (scaffold symbol parsing slips such as `(enum,`, supervisor turns), then a second intent beyond the semver fixture. Run 5: 11/11 but 29 min, $1.83, 44 blocks (the planner made 5 tasks; 27 false isolation blocks after workers `cd`'d to the main tree, fixed; subagents also read the plugin's own source, which costs tokens). Run 6: 11/11, **11m10s, $0.65**, plugin-source reads 30 → 2 after the agent prompts said not to; found a dispatch-before-contract loop (25 blocks, fixed by `gate-dispatch`) and annotated scaffold-symbol lines (fixed). Run 7 (after #9): 11/11, 13m46s, $0.98, 20 blocks, no dispatch loop; found RED blocked for listing an earlier task's passing tests, scaffold-symbols tables with a header row and trait-impl lines, and a guessed memory.md frontmatter (all fixed; `aloop init` now seeds memory.md). The re-plan coverage loss is now caught by `gate-final` (every planned test must be on main). Run 8, **second intent** (`INTENT=wordfreq`, two dependent stories): 12/12, 18m05s, $1.53, 54 blocks; found scope globs expanded against the worktree (29 GREEN blocks) and `mod common;` across test crates reported as a HIGH duplicate (57 review halts), both fixed. Run 9 (wordfreq again): 12/12, 19m42s, $1.56, 29 blocks; the ctx-symbols fix had not reached the run (`ensure-tools` rebuilt only on a version bump, fixed) and the planner named story dirs `S1-01/` (block message now names `s1-01-/`). Run 10 (rebuilt tools): 12/12, $1.20, but 44m48s and 45 blocks: the duplicate false positive is gone (0 HIGH); a RED worker's Write/Edit to the story's output.md was refused by Claude Code's worktree isolation and it stopped 29 times without trying a shell append (fixed: the block and the personas say how), plus 3 stale-`ATTEMPT` tamper blocks (fixed). Fixed after run 10: a worker that repeats an identical block 3 times is released unverified with a `STUCK` marker the supervisor acts on (reason: 29 minutes lost in run 10). Run 11 (all run-10 fixes): 12/12, **12m56s, $0.86, 6 blocks** (from 44m48s, $1.20, 45): no repeated block, one RED report-append block fixed on the first retry, one scaffold fmt block, two structural-reviewer comms blocks (STORY_DIR unset for a sprint-wide review, then a stale block) and 12 `gate-validate-artifact` write blocks on the planner's artifacts. Fixed after run 11: the artifact-write block carries md-db's diagnostics (the planner guessed twice per artifact: 12 of 25 verdicts), `gate-dispatch` requires an existing `STORY_DIR` and names the sprint dir for a whole-wave structural review (2 blocks), and OpenCode reports a stuck release as unverified. Run 12 (those fixes): 12/12, 15m22s, $1.10, 21 blocks: the planner fixed each artifact on the first retry (8 write blocks, from 12) and the reviewer's contract had `STORY_DIR`, but a stale worktree checkout under `.claude/worktrees/` made `ctx-symbols conflicts` report every symbol of main as a duplicate and the reviewer was blocked 10 times on a HIGH finding it could not fix (fixed: the walk skips host checkouts, `.agentic/`, `.transcripts/`). The stuck release now covers the structural reviewer and the final gate too (reason: 10 identical blocks, run 12). Gap: `targets check` blocked the planner twice because a context target named a planned symbol not yet in `src/lib.rs` (reason: planned symbols do not exist before SCAFFOLD; §4.6 owner to decide). Run 13 (those fixes): 12/12, 16m31s, $1.33, 16 blocks; the first build of the walk exclusion also excluded a worktree that IS a host checkout, so the scaffold gate counted every symbol 0 times (9 blocks; the worker was then released by the stuck release and the run still finished); fixed before the run ended (the exclusion applies below the walk root) and covered by a conformance case. Open: `targets check` blocks on the planner's first `targets.json` (2 per run, fixed on retry; §4.6 owner), and sub-agents reading the plugin's own source rose to 17 (from 2–10). Run 14 (all fixes): 12/12, **13m47s, $0.88, 11 blocks**, one host-run block in all (RED touched `src/lib.rs`, fixed on retry), no stuck worker; the rest are planning write blocks fixed on the first retry and workers' own self-checks. The supervisor's GREEN mandates in runs 11–14 named one symbol and `src/lib.rs only`, and the diff scope (from `tasks.md` or `targets scope`) bounds them anyway, so the "GREEN instructions overreaching" item is closed as not reproduced. The planner persona now carries the schema's artifact shapes and the `targets check` rules (to measure). Run 15 (planner shapes + rules, `task-worktree merge`): **13/13**, 13m13s, $1.42, 6 blocks: **0 planning write blocks** (from 8–12: every artifact and `targets.json` passed first time), no host-run block, and §4.7 is live on Claude Code for the first time: 8 commits, 8 `commit.created`, 6 `worktree.merged`, every merged commit answers `events trace` (new e2e check). Plugin-source reads, counted precisely (tool calls naming a plugin path; `--schema` uses excluded): 9, 8, 6 in runs 13–15, all by the supervisor reading `init.template.md` and `log-execution` to learn shapes SKILL.md now states (`log-execution --help` added). Run 15 cost more than run 14 ($1.42 vs $0.88) because the supervisor dispatched every single-task wave in the background and woke 16 times (run 14: 2), each wake re-reading its context: 5.5M cached Sonnet tokens vs 2.8M. SKILL.md now runs a one-task wave in the foreground. Run 16 (that rule): 12/13, **13m04s, $0.79** (from $1.42), **4 wakes** (from 16), 2.3M cached Sonnet tokens (from 5.5M), 9 blocks, 4 plugin-source reads (from 6); the one failed check was the trace: the supervisor committed `Track Cargo.lock` on main itself (the fixture left the lockfile untracked), a commit no task owns. SKILL.md: the supervisor never commits on main; the fixture seeds the lockfile. Of run 16's 9 blocks, 4 were workers self-checking before appending their report block (the personas said "run selfcheck, append your report"; fixed: report first, then selfcheck), 2 were scaffold fmt/uncommitted work and 1 RED touching `src/lib.rs`. Run 17 (report-first personas, never-commit-on-main, seeded lockfile): **13/13, 12m58s, $0.95, 2 wakes, 0 plugin-source reads**, 6 blocks: 3 were the structural reviewer's own `selfcheck` finding no contract (only workers got the worktree copy; fixed in `budget hook`, test-first), 2 RED self-checks before the report (the persona fix landed after this run started), 1 RED touching `src/lib.rs`. Run 18 (reviewer contract copy, v0.12.0): 13/13, 21m21s, $1.03, 6 wakes, 2 plugin-source reads, 6 blocks: the first RED self-check found no contract because Claude Code now prepends a session-context line to the sub-agent transcript and `budget` read only the first `user` line for `TASK_ID` (fixed, test-first: it reads on to the first line naming one); a RED worker's `cat >>` created a story's `output.md` without its frontmatter and self-checked twice against it (fixed: `budget hook pre` seeds `output.md` with `type: output` before the worker's first call); the planner's `targets check` and `TBW` self-checks (3, fixed on retry, by design); one RED touched `src/lib.rs` because the supervisor's mandate told it to shim there (SKILL.md: the mandate names `tests/common/mod.rs`); one scaffold symbol slip. Wall time was runner contention, not more turns. The never-commit-on-main rule is now a gate (`gate-supervisor-scope` blocks the supervisor's `git commit` in the main tree while the sprint is live; reason: a prose rule that one run already broke is cheaper to enforce than to re-find). Next: measure blocks ≤3 with these fixes Run 19 (never-commit-on-main gate): 12/12, 15m47s, $0.99, 39 supervisor turns, 2 plugin-source reads, **2 logged blocks** (one RED whose T2 tests already passed against T1's placeholder, one scaffold) — but 9 unlogged ones: the mid-sprint re-plan of T2 ran the planner's stop gate again, and `targets check` blocked its stop 9 times with "create targets tests/parse.rs, which already exists" for T1's merged change, which the brief had told it not to touch; it stopped only once it rewrote C1/C2 to `modify` and the supervisor dispatched it a second time. Fixed: a `create` whose file now exists and defines its planned_symbol is realized, not a defect (`targets check` passes; `target` resolves it to file:line; test: `semantic-targets.test.py`, reproduced on run 19's plan). Fixed after run 19: the planner's stop-gate verdicts are logged in `gates.jsonl` and the stuck release covers the planner (reason: 9 identical blocks in run 19 went uncounted and nothing ended the loop; test: `planner-stuck.test.py`). The planner persona now plans a later task's RED tests against what the earlier tasks leave on main (reason: run 19's T2 re-plan; to measure in run 20). A second, parallel run 19 (the other thread's, on #29's run-18 fixes): **13/13, 15m24s, $1.01, 1 wake**, 0 plugin-source reads (first counted as 5: the planner's `md-db describe --schema "$SCH"` on the plugin's schemas, a legitimate use the counter now recognises), 3 host-run blocks: run 18's two classes (unbound worker, bare `output.md`) did not recur; the scaffolder wrote its `### Scaffold` report shape (`+ create fn crate::count_words @ src/lib.rs`) into `.aladdin/scaffold-symbols` and the gate read `create` as a symbol twice (fixed, conformance cases: markers, verbs, keywords and crate paths are skipped, the block names the file's shape); the structural reviewer was dispatched without a worktree and its self-check found no contract in the main tree (fixed, test-first: `budget hook` copies the contract into the main tree for an observed role and removes it at stop). The planner's `targets render` diff and `targets check` self-checks (7, fixed on retry) are its own loop. Run 20 (planner stuck release + RED rule): 12/12, **10m47s, 1 block, 0 re-plans, 0 stuck** (the planner's 5 stop verdicts are now in `gates.jsonl`), 36 supervisor turns, 2 plugin-source reads — but **$2.79**: the supervisor dispatched the planning roles on opus and the workers on sonnet although defaults.md said haiku for both and its own `aloop models resolve` call had printed `haiku` (opus $1.11 + sonnet $1.68; run 19 on haiku workers: $0.99). Fixed, test-first: `gate-dispatch` refuses a dispatch whose `model` is not the role's resolved one, or that passes none (reason: a per-dispatch model choice is a project setting the supervisor had no business re-deciding; the cheapest deterministic fix). Run 21 (model gate): 12/12, **8m17s, $0.66** (from $2.79; run 19: $0.99), 29 supervisor turns, 1 wake, 0 plugin-source reads, 3 blocks (two planner self-checks fixed on retry, one structural-review finding fixed on retry), 0 stuck: every dispatch went on haiku (haiku $0.10 + supervisor sonnet $0.56). The cost is now where the model table puts it; the next lever is the supervisor's own context (sonnet $0.56 of $0.66). Run 22 (wordfreq on master before the model gate, 361f8d7): **13/13, 16m18s, $1.14, 2 wakes, 0 plugin-source reads**, 3 logged blocks (all the planner's own stop-gate self-checks, fixed on retry), 0 re-plans, 0 stuck. One loop the gate log does not show: the final-gate persona grepped its own suppression list, failed the sprint on RED's `#![allow(dead_code)]` in `tests/common/mod.rs` (a shared test-helper module, the Rust idiom; the deterministic gate accepts it) and cost a second GREEN dispatch and a final-gate retry. Fixed: the persona names exactly `assert_no_suppression`'s patterns and defers to `selfcheck final-gate` (reason: models explore, gates decide; test: `suppression-contract.test.py`, eval case final-gate #4). Run 23 (model gate, second intent `wordfreq`): **13/13, 10m58s, $0.76, 0 blocks**, 24 supervisor turns, 4 wakes, 1 plugin-source read: both dependent stories planned, built and merged with no gate block for the first time (run 22 on the same intent without the gate: $1.14, 16m18s, 3 blocks). Run 24 (experiment: the same intent with a **haiku supervisor**, `e2e-live.sh --model haiku`): 10/13, 19m09s, $0.66, 51 supervisor turns (from 24), 6 blocks — no cheaper than sonnet (the turns doubled), and the supervisor put the whole sprint under `.aladdin/sprint1/`, the git-ignored run-data dir, so the three planning checks found no sprint; every gate passed it. Fixed, test-first: `gate-stage2-complete` and `gate-dispatch` refuse a sprint or `STORY_DIR` inside `.aladdin/`/`.agentic/` and name `docs/agents/sprintN/` (reason: the plan is the audit trail and must be where the layout commits it; tests: `planner-stuck.test.py`, `dispatch.test.py`). The supervisor stays on the strong route. Run 25 (wordfreq under the model gate, #40's head, a second sample of run 23's setup): **13/13, 16m13s, $0.98** (from $1.14; haiku $0.19 + supervisor sonnet $0.79), 3 wakes, 0 plugin-source reads, 5 blocks, 0 re-plans, and the final gate passed first time (the persona fix held). 4 of the 5 blocks were one GREEN worker: it tried the Write tool on the main tree's `output.md`, worktree isolation refused it, and the gate's "latest block is not from 'green-worker'" named no way out, so it stopped three times, hit the stuck release and needed a supervisor wake to append with `cat >>`. Fixed: that block now carries the same shell-heredoc instruction as the missing-block one (conformance case). Run 26 (the supervisor's playbook trimmed: the Codex/OpenCode notes, the budget re-plan route, review blind spots, the script list, transcripts and worktree hygiene moved to an on-demand `skills/aloop/reference.md`, SKILL.md 58k → 49k chars): 13/13, 16m01s, $0.95, 36 supervisor turns, 2 wakes, 1 plugin-source read, 7 blocks. The playbook load fell from 25.0k to 18.8k tokens, about 6k fewer tokens re-read on every supervisor turn, and the supervisor never needed the reference file; the run's cost was set by a RED loop instead (5 of 7 blocks): the supervisor's mandate allowed a `src/` skeleton, the gate made RED revert it, and the tests then called a symbol that no longer existed; the block said only "add mod-common shims", so the worker stopped three times and hit the stuck release. Fixed: the compile block names each missing symbol and its shim, e.g. `pub fn count_words(…) -> … { todo!() }` in `tests/common/mod.rs`, called through `mod common;` (conformance case). Run 27 (master with the trimmed playbook and the named-symbol RED block, wordfreq): **13/13, 9m54s, $0.70, 1 wake**, 33 supervisor turns, 1 plugin-source read, 3 blocks (the planner's own self-check, and two scaffolders self-checking before they committed, each fixed on retry), 0 stuck, 0 re-plans: the fastest and cheapest two-story run so far (haiku $0.12 + supervisor sonnet $0.59). All 3 of those blocks were the workers' own `selfcheck` catches, with 0 blocks at stop. `run-summary` now counts them as `selfcheck_blocks`, and the worker prompts give the finish order as block, commit, selfcheck. Run 28 (master after #47, wordfreq): 13/13, 13m14s, $1.15, 3 wakes, 4 blocks (2 self-check catches). The supervisor took the manual task-worktree route without copying the contract into the worktree, so RED's `aloop bind` failed and its stop blocked twice in the shared tree. Fixed: `gate-dispatch` copies and refreshes the contract in a task worktree on every dispatch (test: `dispatch.test.py`). Run 29 (master after #49, with `aloop budget contract`, wordfreq): 13/13, 12m55s, $0.91 (haiku $0.15 + supervisor sonnet $0.76), 1 wake, 0 plugin-source reads, **0 gate blocks**, 38 supervisor turns. The supervisor wrote every contract with `budget contract` (no heredocs), but spent 5 turns polling for the planners' files with `sleep` loops after dispatching intake and standards in the background, and the final gate's sign-off never reached the main tree: its Write was refused, it wrote a worktree copy the host discarded, its stop passed because `gate-final` never checked comms, and the supervisor wrote the final-gate block itself. Fixed: `gate-final` runs `validate_comms` for a final-gate worker under a contract (conformance cases), the persona says how to append, and SKILL.md runs planning roles in the foreground (two in one message) and forbids writing an agent's block. Run 30 (master after #50, wordfreq): 13/13, 11m27s, **$0.70** (haiku $0.15 + supervisor sonnet $0.54), **23 supervisor turns** (from 38), 2 wakes, 0 plugin-source reads, 4 blocks, all caught by the workers' own self-checks (0 at stop). Every planning role ran in the foreground with no polling, and the final gate appended its own sign-off block (its first self-check caught it missing; the new comms check working as meant). The never-write-an-agent's-block rule is now a gate too (`gate-supervisor-scope`, test: `supervisor-scope.test.py`; reason: run 29 broke the prose rule once). Run 31 (semver on master after #52): 12/12, 10m24s, $0.91 (haiku $0.12 + supervisor sonnet $0.79), 27 supervisor turns, 2 wakes, 1 plugin-source read, 5 blocks; the supervisor-scope gate never fired. 4 of the 5 blocks were one loop: T2's tests called only T1's finished `parse`, the scaffolder listed it, and the gate demanded a TODO panic in a body it had not touched, so it hit the stuck release and needed a second dispatch. Fixed: a listed symbol that existed at `BASE_REF` in an unchanged file needs no stub (conformance cases). Run 32 (semver on master after #53): 12/12, $0.90, 0 scaffold blocks (2 blocks, both self-check catches), but 23m30s wall for 11m of work: the supervisor set a 1200s `ScheduleWakeup` "heartbeat" when the host moved the planner to the background, and the headless session waited for it 12 minutes after the final gate. It also ran `task-worktree add --help`, which made a worktree named `--help`. Fixed: `gate-supervisor-scope` blocks the supervisor's `ScheduleWakeup` while a sprint is live, and `task-worktree` prints usage for `--help` and refuses a dash-led TASK_ID (tests). Run 33 (wordfreq on master after #54): 13/13, 12m20s, $0.84, 27 supervisor turns, 2 wakes, 0 plugin-source reads, 5 blocks (all self-check catches), no wakeup. Runs 31-33 each improvised the same RED-to-SCAFFOLD handoff on Claude Code (`task-worktree --help`, inspect the host worktree, `task-worktree add` on RED's branch, then SCAFFOLD/GREEN bound to it); SKILL.md Part B now states it (skill-layout test). Run 34 (semver on master after #55): 12/12, 10m23s, $0.74, 21 supervisor turns (27 in run 31), 2 wakes, 1 block (a self-check catch); the supervisor went straight from RED to `task-worktree add` on RED's branch for both tasks, with no `--help` or inspection turns. Runs 32-34 also inherited the launching agent session (its session id and its team memory, recalled at start); `e2e-live.sh` now unsets those before the run (e2e-live-hosts test), so earlier runs from an agent session carry that caveat. Run 35 (wordfreq, the first with a clean env): 13/13, 12m59s, $0.91, 31 supervisor turns, 2 wakes, 0 plugin-source reads, 2 blocks (self-check catches), no memory recall and its own session id; within the range of runs 27-33, so the inherited memory had not been carrying the earlier results. Next: the Codex/OpenCode public runs (need a machine with those CLIs) | -| **M0.9 — Plan approval is a gate** | v0.13 | `gate-dispatch` admits no execution role (RED, SCAFFOLD, GREEN, the structural reviewer, the final gate) of a sprint until the human approved that sprint's plan as it is now. `events authority --sprint N` asks for a typed line, `approve SN ` (reviewed, the code naming the sha256 of the plan files: `stories.md`, `plan.md`, `ids.json`, each story's `tasks.md`, `validate.md`, `plan.md`, `targets.json`) or `autonomous SN ` (autonomy for that sprint, re-plans included, the code naming the authority record); the task contract's `STORY_DIR` and the task must be that plan's own (a live story and task in its frozen `ids.json`), and RED/SCAFFOLD/GREEN need a task id; the line must be among the human's captured prompts (M9.17's mechanism), typed after the sprint's last decision. A changed plan, a re-plan, a roll-back, another sprint's line, a hand-edited or emitted record and a negated line all block; an approved autonomous mission grants autonomy with no line. Covers Claude Code (`Task`), Codex (`spawn_agent`), OpenCode (`task`) and dsh; `claude -p`, `codex exec` and `opencode run` from a tool call are blocked in every aloop project (the prompt log is the approval's evidence). Reason: the north star says *no human help beyond approval*, but the approval was a prose rule: `events authority` trusted `--initiated-by` and nothing stopped a dispatch before it, so a supervisor could build an unapproved plan | done: `scripts/test/plan-approval.test.py` (20 checks, fails on master at check 1: an unapproved dispatch was admitted). A 4-lens adversarial review (each finding re-verified) found 9 real defects. Seven are fixed with a check that is red on the first head: another sprint's or an unplanned `STORY_DIR` passed under an approval, a line typed again after a later decision stayed stale, an approved mission's autonomy swallowed a non-mission sprint's typed line, `transcripts prune` dropped the prompts grants cite, `codex plugin add` was refused, a code past column 200 recorded a grant the gate refused, and a malformed run-log line crashed `events authority`. Two are playbook fixes: intake reuses the intent `mission goal next` handed off (a fresh `intent new` made the plan serve no mission intent), and a reviewed re-plan waits for the human's new line. Three test gaps (forged autonomy grants, a replayed approval, one sprint's autonomy over another) are covered; mutation results are in #99. every dispatching suite now approves first (`fixtures/plan_fixture.py`, `plan-fixture.mjs`); `e2e-live.sh` pre-approves with a typed `autonomous S1 ` line in the prompt. Open: the run log is not hash-chained, so deleting a later decision line restores an older approval (a roll-back by edit, not by re-typing); a program's write to the prompt log (`python -c`) is invisible to the scope gate, as in M9.17; the mission loop's `APPROVE_PLAN` step counts any `plan.approved` and should ask `events approval` (M9.23 owner); the door gate's `live_run` (M9.30) reads `plan.approved` or `AGENTIC_AUTONOMY_MODE`, so a sprint granted autonomy by the human's `autonomous SN ` line is not yet a live run for it: it should ask `events approval` too (M9.30 owner); M10.2's dependency check (`deps unplanned`) reads the story's plan files as they are at GREEN's stop, so a plan edited after approval can name a dependency: it should also require `events approval` to hold (next, this thread) | +| **M0.9 — Plan approval is a gate** | v0.13 | `gate-dispatch` admits no execution role (RED, SCAFFOLD, GREEN, the structural reviewer, the final gate) of a sprint until the human approved that sprint's plan as it is now. `events authority --sprint N` asks for a typed line, `approve SN ` (reviewed, the code naming the sha256 of the plan files: `stories.md`, `plan.md`, `ids.json`, `intake.md`, `standards.md`, each story's `tasks.md`, `validate.md`, `plan.md`, `targets.json`) or `autonomous SN ` (autonomy for that sprint, re-plans included, the code naming the authority record); the task contract's `STORY_DIR` and the task must be that plan's own (a live story and task in its frozen `ids.json`), and RED/SCAFFOLD/GREEN need a task id; the line must be among the human's captured prompts (M9.17's mechanism), typed after the sprint's last decision. A changed plan, a re-plan, a roll-back, another sprint's line, a hand-edited or emitted record and a negated line all block; an approved autonomous mission grants autonomy with no line. Covers Claude Code (`Task`), Codex (`spawn_agent`), OpenCode (`task`) and dsh; `claude -p`, `codex exec` and `opencode run` from a tool call are blocked in every aloop project (the prompt log is the approval's evidence). Reason: the north star says *no human help beyond approval*, but the approval was a prose rule: `events authority` trusted `--initiated-by` and nothing stopped a dispatch before it, so a supervisor could build an unapproved plan | done: `scripts/test/plan-approval.test.py` (20 checks, fails on master at check 1: an unapproved dispatch was admitted). A 4-lens adversarial review (each finding re-verified) found 9 real defects. Seven are fixed with a check that is red on the first head: another sprint's or an unplanned `STORY_DIR` passed under an approval, a line typed again after a later decision stayed stale, an approved mission's autonomy swallowed a non-mission sprint's typed line, `transcripts prune` dropped the prompts grants cite, `codex plugin add` was refused, a code past column 200 recorded a grant the gate refused, and a malformed run-log line crashed `events authority`. Two are playbook fixes: intake reuses the intent `mission goal next` handed off (a fresh `intent new` made the plan serve no mission intent), and a reviewed re-plan waits for the human's new line. Three test gaps (forged autonomy grants, a replayed approval, one sprint's autonomy over another) are covered; mutation results are in #99. every dispatching suite now approves first (`fixtures/plan_fixture.py`, `plan-fixture.mjs`); `e2e-live.sh` pre-approves with a typed `autonomous S1 ` line in the prompt. Since: the plan also covers the sprint's `intake.md` and `standards.md`, and a grant pins it file by file: GREEN's dependency check (M10.2) reads only the text the human's grant pins, the files of the plan they approved or, under their autonomy grant, of the plan as the planner's gate last passed it on the planner's stop (`plan.gated`), as they were then (a kept copy once a file changes), so text added later names nothing and a re-plan does not undo an approved dependency (`supply-chain.test.py` 2–2e, `plan-approval.test.py` 21). Open: the run log is not hash-chained, so deleting a later decision line restores an older approval (a roll-back by edit, not by re-typing); a program's write to the prompt log or the run log (`python -c`) is invisible to the scope gate, as in M9.17 (containing the workers is M10.1); the mission loop's `APPROVE_PLAN` step counts any `plan.approved` and should ask `events approval` (M9.23 owner); the door gate's `live_run` (M9.30) reads `plan.approved` or `AGENTIC_AUTONOMY_MODE`, so a sprint granted autonomy by the human's `autonomous SN ` line is not yet a live run for it: it should ask `events approval` too (M9.30 owner) | | **M0.6 — Gates fail closed** | v0.11.x | A gate that crashes (exit 1, e.g. an unbound variable) is a non-blocking hook error on Claude Code, so the action goes through. Make every gate trap unexpected errors into exit 2 with the reason, and add a conformance case per gate. Reason: the smoke run showed one real instance | done: `_failclosed.sh` on all 10 sub-agent gates + supervisor-scope inside a sprint; `scripts/test/fail-closed.test.py` (5 checks). Left fail-open on purpose: `gate-commit-author` and `gate-validate-artifact` outside a sprint, which see every session on the machine | | **M0.7 — Supervisor-owned task contract** | v0.11.x | The contract lives in the main tree, `.agentic/state/tasks/.env`, and the dispatch prompt's first line names the task; gates and the time box find it from the host's transcript, a worktree `task.env` that disagrees blocks, and sub-agents may not Write/Edit `.agentic/state/` or `task.env`. Settled by a live probe: Claude Code's `isolation: "worktree"` makes `.claude/worktrees/agent-` at dispatch, so a pre-written in-worktree contract was impossible there. Bash writes are guarded too (a command naming the contract with a write verb is blocked; a heuristic, so an obfuscated write still gets through). On hosts with no sub-agent transcript the worktree's `TASK_ID` (or its `.agentic/worktrees/` path) picks the contract | done: `make conformance` (58 today) + `scripts/test/{budget-worktree,supervisor-scope}.test.py` | | **M0.5 — Rename to aloop** | v0.11.0 | Plugin, marketplace, skill, CLI (`aloop`, `aloop init`), OpenCode plugin file and docs renamed; `agentic`, `agentic init`, `agentic-init` and `agentic bind` kept as aliases; OpenCode/Codex installs clean up pre-rename files. Data layout and settings keys unchanged (moved to M1). GitHub repo rename is the owner's call | done: `scripts/test/rename-compat.test.py` | @@ -210,7 +210,7 @@ Event types: | Group | Events | |---|---| -| Intent and plan | `intent.received`, `intent.normalized`, `plan.created`, `plan.approved`, `plan.revised` | +| Intent and plan | `intent.received`, `intent.normalized`, `plan.created`, `plan.approved`, `plan.revised`, `plan.gated` | | Sprint and context | `sprint.started`, `sprint.token_soft_limit`, `sprint.admission_closed`, `sprint.rolled_over`, `sprint.context_handoff`, `context.compacted`, `context.rotated` | | Tasks | `task.created`, `task.dispatched`, `task.completed`, `task.retry`, `task.time_soft_preempt`, `task.time_hard_timeout`, `task.token_soft_limit`, `task.token_hard_limit`, `task.cancelled` | | Gates and worktrees | `gate.started`, `gate.passed`, `gate.failed`, `worktree.created`, `worktree.discarded`, `worktree.merged` | diff --git a/plugin/bin/README.md b/plugin/bin/README.md index 2c779793..6ff02fd0 100644 --- a/plugin/bin/README.md +++ b/plugin/bin/README.md @@ -35,7 +35,7 @@ ctx-symbols) → WARN + grep fallback; never a silent pass. | gate-structural-integrity | SubagentStop · structural-reviewer | appended output.md block; orphan/parallel/duplicate via ctx-symbols | no/stale output.md block / foundation-poisoning finding | | gate-final | SubagentStop · final-gate | full matrix; zero suppressions; all plan-ready ticked | matrix red / suppression / unticked | | gate-standards-cited | SubagentStop · standards | standards.md citations resolve | dangling citation | -| gate-stage2-complete | supervisor self-check + SubagentStop · planner | the sprint is in `docs/agents/sprintN/`, never the run-data dir; every story Stage-2 valid; no TBW; sprint self-contained (no later-sprint story IDs, no work deferred to a later sprint); verdicts logged like every gate, and the stuck release covers the planner (3 identical blocks → stop released unverified, marker `state/stuck/plan-sprintN.`) | incomplete or spilling planning | +| gate-stage2-complete | supervisor self-check + SubagentStop · planner | the sprint is in `docs/agents/sprintN/`, never the run-data dir; every story Stage-2 valid; no TBW; sprint self-contained (no later-sprint story IDs, no work deferred to a later sprint); verdicts logged like every gate, and the stuck release covers the planner (3 identical blocks → stop released unverified, marker `state/stuck/plan-sprintN.`); a pass on the planner's stop records the plan it passed (`ids gated`, M0.9) | incomplete or spilling planning | | gate-plan-shape | standalone (not hook-wired) | each plan checkbox carries `path::fn` | malformed plan | | gate-ledger-format | standalone (not hook-wired) | execution.log line shape | malformed ledger | @@ -66,8 +66,8 @@ ctx-symbols) → WARN + grep fallback; never a silent pass. | `budget` | per-attempt time box for red/scaffolder/green workers. `hook pre\|post\|stop` (PreToolUse/PostToolUse `*`, SubagentStop): soft time limit → warning in the worker's tool result; soft token limit → telemetry only (`task.token_soft_limit` in `.agentic/logs/events.jsonl`, surfaced in stats.md/NEXT.md, worker not told); hard limit → PostToolUse `continue: false` stops the worker on that call, later calls refused; the harness (not the worker) appends the `status: re-plan` output.md block and records `task.token_hard_limit`/`task.time_hard_timeout` (+ the worktree's `.aladdin/budget-exceeded`, so its gate releases the stop unverified). `resolve` · `watch` (supervisor sleep; exits with STOPPED / KILL / STUCK lines) · `status` · `mark-killed` · `replans` (split cap) | | `events` | the `aladdin.event/1` stream in `.agentic/logs/events.jsonl` (`_events.py`): `emit EVENT --task … --parent …` · `query --task/--event/--sprint` · `lineage TASK_ID` (worktree → limits → gates → decisions → merged/discarded, from refs, never transcripts) · `trace SHA` (commit → task → gates → plan → intent → approver) · `commit-msg TASK` (title + decisions + ids) · `graph [--format json|dot]` (downstream export) · `authority … --sprint N` (the human's grant: exits 3 with the `approve SN ` / `autonomous SN ` line to type, M0.9) · `approval SPRINT|TASK_ID [--story-dir D] [--role R]` (exit 0 approved, 2 not; `gate-dispatch` runs it). `plan.approved` and `human.approval` cannot be emitted. Written by `budget`, every gate verdict (`_gatelib.sh`) and `task-worktree`. | | `intent` | the internal Intent Contract (ROADMAP §4.1): `new` issues the canonical `intent_id` + skeleton under `docs/agents/intents/`; `check FILE [--mode reviewed\|autonomous]` validates fields and the clarification policy (exit 2 invalid, 3 an `ask` needs the human); `summary FILE` lists defaults/assumptions/spikes for approval. Run by `gate-intake`. | -| `ids` | canonical identity + referential integrity (ROADMAP §4.5): `freeze SPRINT_DIR` checks the structured references (story frontmatter ↔ dir, dirs ↔ stories.md, validate.md ↔ tasks.md headings, `split_from` → a retired task) and issues frozen UUIDv7 ids in `sprintN/ids.json`; a retired alias is never reused · `check` · `resolve ALIAS`. Run by `gate-stage2-complete`; events then carry `story_uid`/`task_uid`. | -| `deps` | supply chain (ROADMAP M10.2): `added --base REF` lists the dependencies a change adds to Cargo.toml, package.json, requirements*.txt, pyproject.toml or go.mod · `unplanned --base REF --story DIR` the ones the story's plan does not name (exit 2); gate-green-verify blocks on them. No third-party parser. | +| `ids` | canonical identity + referential integrity (ROADMAP §4.5): `freeze SPRINT_DIR` checks the structured references (story frontmatter ↔ dir, dirs ↔ stories.md, validate.md ↔ tasks.md headings, `split_from` → a retired task) and issues frozen UUIDv7 ids in `sprintN/ids.json`; a retired alias is never reused · `check` · `resolve ALIAS`. Run by `gate-stage2-complete`; events then carry `story_uid`/`task_uid`. `gated SPRINT_DIR` (the planner's stop payload on stdin) records `plan.gated`, the plan's files' sha256 with their text kept: `gate-stage2-complete` runs it when the planner's stop passes, and under an autonomy grant it is the plan text `deps unplanned` reads. | +| `deps` | supply chain (ROADMAP M10.2): `added --base REF` lists the dependencies a change adds to Cargo.toml, package.json, requirements*.txt, pyproject.toml or go.mod · `unplanned --base REF --story DIR` the ones the story's plan does not name (exit 2), reading only the plan text the human's grant pins, as it was then (M0.9: the approved plan, or under autonomy the plan as the planner's gate passed it); gate-green-verify blocks on them. No third-party parser. | | `secrets` | secret scan (ROADMAP M10.2): `scan [--base REF]` reports `path:line: kind` for a private key or a fixed-prefix token (AWS, GitHub, GitLab, Slack, Stripe, Google, Anthropic, OpenAI), never the text; with `--base` only added lines. gate-green-verify scans the task's added lines, gate-final the whole project (exit 2). `aloop: allow-secret` on a line exempts a fixture. | | `targets` | semantic execution map (ROADMAP §4.6): the planner's `/targets.json` — change targets and, with `tasks`, the whole semantic plan. `render STORY_DIR [--check]` writes tasks.md / validate.md / plan.md as deterministic views over it (the gate refuses a hand-edited view) · `check STORY_DIR` (run by `gate-stage2-complete`) · `target Tn STORY_DIR` (file:line, or `planned` for the shadow workspace) · `shadow` · `scope Tn STORY_DIR` (the diff scope gate-green-verify derives when SCOPE_GLOBS is unset) · `context Cn --budget N` (just the target's definition) · `refs\|callers\|callees` via the LSP server in `AGENTIC_LSP_COMMAND` (`_lsp.py`: references + call hierarchy); no server or a missing capability → exit 4, never guessed. Backend: ctx-symbols, else a definition regex flagged weaker. | | `impact` | optional cross-project impact provider seam (ROADMAP §4.8): `query consumers\|rationale\|migration\|standards SUBJECT [--task]` runs `AGENTIC_IMPACT_PROVIDER` (defaults.md or env), keeps only results with a `source_ref`, saves them under `docs/agents/impact/` and emits `artifact.created`. No provider or a failing one → WARN, exit 0. Builds no index. | diff --git a/plugin/bin/_approval.py b/plugin/bin/_approval.py index 1fe4cb6e..bf88bc36 100644 --- a/plugin/bin/_approval.py +++ b/plugin/bin/_approval.py @@ -28,9 +28,11 @@ import _mission as M import _paths -# the plan of a sprint: what the planner writes and the human approves. Comms (init.md, output.md), -# plan-ready.md ticks, logs and stats change during execution and are not the plan. -SPRINT_FILES = ("stories.md", "plan.md", "ids.json") +# the plan of a sprint: what the planning activities write and the human approves, the intent and the +# standards it is built and judged by included. Comms (init.md, output.md), plan-ready.md ticks, logs and +# stats change during execution and are not the plan. +SPRINT_FILES = ("stories.md", "plan.md", "ids.json", "intake.md", "standards.md") +NEW_SPRINT_FILES = ("intake.md", "standards.md") # in the plan since per-file pins; an older approval left them out STORY_FILES = ("tasks.md", "validate.md", "plan.md", "targets.json") STORY_DIR = re.compile(r"^s(\d+)-(\d+)-") TASK = re.compile(r"^S(\d+)-(\d+)-T\d+$", re.I) @@ -59,15 +61,29 @@ def plan_files(cwd, sp): return [(M.rel(cwd, p), p) for p in out if os.path.isfile(p)] +def file_sha(p): + with open(p, "rb") as f: + return hashlib.sha256(f.read()).hexdigest() + + +def sprint_rels(cwd, sp, names): + return {M.rel(cwd, os.path.join(sprint_dir(cwd, sp), n)) for n in names} + + +def plan_map(cwd, sp): + """{project-relative path: sha256} of the sprint's plan files as they are now.""" + return {rel: file_sha(p) for rel, p in plan_files(cwd, sp)} + + +def map_digest(files): + return hashlib.sha256(json.dumps(files, sort_keys=True).encode()).hexdigest() + + def plan_digest(cwd, sp): """The sha256 of the sprint's plan as it is now (None when the sprint has no dir).""" if not os.path.isdir(sprint_dir(cwd, sp)): return None - files = {} - for rel, p in plan_files(cwd, sp): - with open(p, "rb") as f: - files[rel] = hashlib.sha256(f.read()).hexdigest() - return hashlib.sha256(json.dumps(files, sort_keys=True).encode()).hexdigest() + return map_digest(plan_map(cwd, sp)) def content(auth): @@ -176,10 +192,12 @@ def grant_for(cwd, initiated_by, mode, scope, sprint="", policy="default", overr auth = {"initiated_by": initiated_by, "autonomy_mode": mode, "scope": scope, "policy": policy, "overrides": overrides or {}, "sprint": sp} if mode == "reviewed": - plan_sha = plan_digest(cwd, sp) + files = plan_map(cwd, sp) + plan_sha = map_digest(files) sha = grant_sha(auth, plan_sha) - grant = {"kind": "plan", "sha256": sha, "plan_sha256": plan_sha, "files": [r for r, _ in plan_files(cwd, sp)], + grant = {"kind": "plan", "sha256": sha, "plan_sha256": plan_sha, "files": sorted(files), "file_sha256": files, "prompt": provenance(cwd, sp, VERBS["plan"], sha, "The approval of %s's plan" % sp)} + snapshot(cwd, files) # the text they approved counts after later edits too (deps unplanned) else: sha = grant_sha(auth) # the mission's autonomy covers only its own sprints: one planned from another intent asks the human @@ -291,6 +309,10 @@ def holds(cwd, sp, plan_sha): auth, g = e["authority"], e["authority"]["grant"] who = "%s (%s)" % (auth.get("initiated_by"), auth.get("autonomy_mode")) if g.get("kind") == "plan" and auth.get("autonomy_mode") == "reviewed": + if g.get("plan_sha256") != plan_sha and "file_sha256" not in g and g.get("plan_sha256") == map_digest( + {r: h for r, h in plan_map(cwd, sp).items() if r not in sprint_rels(cwd, sp, NEW_SPRINT_FILES)}): + return False, ["the human's approval of %s is older than its intake.md and standards.md being part of the" + " plan: they approve the plan again." % sp, " " + how] if g.get("plan_sha256") != plan_sha: return False, ["the plan of %s changed after the human approved it (approved %s, now %s): a changed plan is" " a new decision." % (sp, M.code(g.get("plan_sha256") or ""), M.code(plan_sha)), @@ -320,3 +342,75 @@ def holds(cwd, sp, plan_sha): return True, "%s autonomous, granted by %s, code %s" % (sp, who, M.code(g["sha256"])) return False, ["the newest grant of %s is neither a plan approval nor an autonomy grant (a hand-written record);" " %s" % (sp, how)] + + +def snap_dir(cwd, make=False): + return _paths.home(cwd, os.path.join("state", "plan"), make=make) + + +def snapshot(cwd, files): + """Keep each pinned plan file's bytes under its sha256 (run data), so the text the human's grant pins + outlives later edits of the file; a copy counts only while it still hashes to its name.""" + root, d = _paths.project(cwd), None + for rel, sha in sorted(files.items()): + try: + with open(os.path.join(root, rel), "rb") as f: + b = f.read() + except OSError: + continue + if hashlib.sha256(b).hexdigest() != sha: + continue + d = d or snap_dir(cwd, make=True) + dst = os.path.join(d, sha) + if pinned_text(cwd, rel, sha, live=False) is None: + with open(dst + ".tmp", "wb") as f: + f.write(b) + os.replace(dst + ".tmp", dst) + + +def pinned_text(cwd, rel, sha, live=True): + """The text of plan file `rel` as pinned (`sha`): the file while it is unchanged, else its kept copy; + None when neither holds that text.""" + paths = ([os.path.join(_paths.project(cwd), rel)] if live else []) + [os.path.join(snap_dir(cwd), sha)] + for p in paths: + try: + with open(p, "rb") as f: + b = f.read() + except OSError: + continue + if hashlib.sha256(b).hexdigest() == sha: + return b.decode("utf-8", "replace") + return None + + +def gated(cwd, sp): + """{path: sha256} of the sprint's plan as the planner's gate last passed it (gate-stage2-complete records + `plan.gated` on the planner's stop), or {}.""" + for e in reversed(list(_events.read(cwd))): + d = data(e) + if e.get("event") == "plan.gated" and d.get("sprint") == sp and isinstance(d.get("file_sha256"), dict) \ + and map_digest(d["file_sha256"]) == d.get("plan_sha256"): + return d["file_sha256"] + return {} + + +def pinned(cwd, sp): + """({path: sha256}, why) of the plan files the human's newest grant of sprint sp pins; ({}, the reason) when + none: a reviewed approval pins the plan they approved, whatever changed since; their autonomy grant pins the + plan as the planner's gate last passed it. Text that differs from its pin is no plan the human stands behind.""" + gs = grants(cwd, sp) + if not gs: + return {}, "the human has not approved the plan of %s" % sp + g = gs[-1]["authority"]["grant"] + if g.get("kind") == "plan": + files = g.get("file_sha256") + if not isinstance(files, dict) or map_digest(files) != g.get("plan_sha256"): + return {}, ("the newest approval of %s pins no plan files (recorded before they were pinned file by file, " + "or edited): the human approves the plan again" % sp) + good, why = holds(cwd, sp, g.get("plan_sha256")) + return (files, "") if good else ({}, why[0]) + good, why = holds(cwd, sp, None) + if not good: + return {}, why[0] + files = gated(cwd, sp) + return (files, "") if files else ({}, "%s is autonomous, but no plan of it has passed the planner's gate yet" % sp) diff --git a/plugin/bin/_events.py b/plugin/bin/_events.py index a1131e9f..3aba4ad2 100644 --- a/plugin/bin/_events.py +++ b/plugin/bin/_events.py @@ -16,7 +16,7 @@ SCHEMA = "aladdin.event/1" EVENT_TYPES = { - "intent.received", "intent.normalized", "plan.created", "plan.approved", "plan.revised", + "intent.received", "intent.normalized", "plan.created", "plan.approved", "plan.revised", "plan.gated", "sprint.started", "sprint.token_soft_limit", "sprint.admission_closed", "sprint.rolled_over", "sprint.context_handoff", "context.compacted", "context.rotated", "task.created", "task.dispatched", "task.completed", "task.retry", "task.time_soft_preempt", diff --git a/plugin/bin/deps b/plugin/bin/deps index f45f4a58..47d0edba 100755 --- a/plugin/bin/deps +++ b/plugin/bin/deps @@ -16,6 +16,10 @@ Usage: (tasks.md, targets.json, plan.md, validate.md, the sprint's stories.md); exit 2 if any + +Plan text is only what the human's grant pins (ROADMAP M0.9, `_approval.pinned`): the files of the plan +they approved, or under their autonomy grant of the plan as the planner's gate passed it, as they were +then (a kept copy once the file changes). Text added since, or outside the plan's files, names nothing. """ import json import os @@ -142,19 +146,30 @@ def added(root, base): return out -def plan_text(story): - parts = [] - for f in ("tasks.md", "targets.json", "plan.md", "validate.md"): - try: - parts.append(open(os.path.join(story, f)).read()) - except OSError: - pass - try: - parts.append(open(os.path.join(os.path.dirname(os.path.abspath(story)), "stories.md")).read()) - except OSError: - pass - return "\n".join(parts) - +def plan_text(story, cwd): + """(the story's plan text as the human's grant pins it, notes on plan text that does not count).""" + sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) + import _approval + import _mission + story = os.path.realpath(story) + sprint_dir = os.path.dirname(story) + sp = _approval.sprint_of(os.path.basename(sprint_dir)) + pins, why = _approval.pinned(cwd, sp) if sp else ({}, "%s is no story of a sprint" % story) + parts, changed = [], [] + for p in [os.path.join(story, f) for f in ("tasks.md", "targets.json", "plan.md", "validate.md")] + \ + [os.path.join(sprint_dir, "stories.md")]: + rel = _mission.rel(cwd, p) + if rel not in pins: + continue + text = _approval.pinned_text(cwd, rel, pins[rel]) + if text is not None: + parts.append(text) + if not os.path.isfile(p) or _approval.file_sha(p) != pins[rel]: + changed.append(rel) + notes = ["no plan text counts: %s" % why] if why else [] + if changed: + notes.append("text changed since the human's grant pinned it names nothing: %s" % ", ".join(changed)) + return "\n".join(parts), notes def named(name, text): return re.search(r"(?&2 fi +# 7) The plan as the planner's stop passed it, file by file (a verdict, not a self-check): under the human's +# autonomy grant it is the plan text GREEN's dependency check reads (ROADMAP M0.9). +if [ "${AGENTIC_SELFCHECK:-}" != 1 ]; then + printf '%s' "$GATE_PAYLOAD" | "$BIN_DIR/ids" gated "$sprint_dir" \ + || echo "WARN[$GATE_NAME]: could not record the gated plan of $sprint_dir (see above)" >&2 +fi + echo "[$GATE_NAME] Stage-2 complete for all stories in $sprint_dir" >&2 exit 0 diff --git a/plugin/bin/ids b/plugin/bin/ids index 94cd6e72..dda1a331 100755 --- a/plugin/bin/ids +++ b/plugin/bin/ids @@ -10,6 +10,10 @@ Usage: ids freeze SPRINT_DIR check, then issue ids for new aliases and retire vanished ones (exit 2 on a broken reference or a reused retired alias; nothing written) ids check SPRINT_DIR the referential check alone (also: every live alias must be frozen) + ids gated SPRINT_DIR 1: + if argv[0] in ("freeze", "check", "gated") and len(argv) > 1: sdir = argv[1].rstrip("/") if not os.path.isdir(sdir): print("ids: no such sprint dir %s" % sdir, file=sys.stderr) return 64 - return cmd_freeze(sdir) if argv[0] == "freeze" else cmd_check(sdir) + return {"freeze": cmd_freeze, "check": cmd_check, "gated": cmd_gated}[argv[0]](sdir) if argv[0] == "resolve" and len(argv) > 1: return cmd_resolve(argv[1], argv[2] if len(argv) > 2 else "") print("ids: unknown or incomplete command (see ids --help)", file=sys.stderr) diff --git a/scripts/test/plan-approval.test.py b/scripts/test/plan-approval.test.py index 5c9fa244..83e19a26 100644 --- a/scripts/test/plan-approval.test.py +++ b/scripts/test/plan-approval.test.py @@ -152,7 +152,8 @@ def project(name): orig = open(tasks).read() for rel in (tasks, os.path.join(story, "validate.md"), os.path.join(story, "plan.md"), os.path.join(P, "docs/agents/sprint1/stories.md"), os.path.join(P, "docs/agents/sprint1/plan.md"), - os.path.join(P, "docs/agents/sprint1/ids.json"), os.path.join(story, "targets.json")): + os.path.join(P, "docs/agents/sprint1/ids.json"), os.path.join(story, "targets.json"), + os.path.join(P, "docs/agents/sprint1/standards.md"), os.path.join(P, "docs/agents/sprint1/intake.md")): before = open(rel).read() if os.path.exists(rel) else None write(rel, (before or "{}") + "\n") r = dispatch("S1-01-T1") @@ -162,7 +163,8 @@ def project(name): else: write(rel, before) assert dispatch("S1-01-T1").returncode == 0, rel -ok("a change to any plan file (stories, plans, ids, a story's tasks/validate/plan/targets) blocks until it is approved;" +ok("a change to any plan file (stories, plans, ids, standards, intake, a story's tasks/validate/plan/targets) blocks" + " until it is approved;" " init.md, output.md, plan-ready.md and logs do not") # 5) the old line does not approve new content; a fresh line does @@ -464,6 +466,49 @@ def append(rec, i): ok("each dispatch re-proves the newest record: an autonomy grant with no line, an unknown prompt, edited overrides " "or another verb's line, and a replayed copy of an older approval, all block") +# 21) the plan text a grant pins (GREEN's dependency check reads only it, deps unplanned): the sprint's newest grant +# decides and must hold itself; under autonomy it pins the plan the planner's gate passed, of that sprint only; +# a reviewed grant's per-file hashes must add up to the plan its code names +qs4 = sprint(4, cwd=Q) +now4 = _approval.plan_map(Q, "S4") +gate4 = {"sprint": "S4", "file_sha256": now4, "plan_sha256": _approval.map_digest(now4)} +_approval._events.emit(Q, "plan.gated", role="planner", **gate4) +assert _approval.pinned(Q, "S4") == ({}, "the human has not approved the plan of S4") # a gated plan alone pins nothing +assert authority("--sprint", "4", cwd=Q, mode="autonomous", human=True).returncode == 0 +assert _approval.pinned(Q, "S4") == (now4, "") +other = {"docs/agents/sprint9/stories.md": "0" * 64} +_approval._events.emit(Q, "plan.gated", role="planner", sprint="S9", file_sha256=other, + plan_sha256=_approval.map_digest(other)) +assert _approval.pinned(Q, "S4") == (now4, ""), "another sprint's gated plan pinned S4" +auth4 = dict(auth, sprint="S4") +append(dict(base, authority=dict(auth4, grant={"kind": "autonomy", "sha256": _approval.grant_sha(auth4)})), 21) +files, why = _approval.pinned(Q, "S4") +assert files == {} and "not the human's own words" in why, why # a forged autonomy record +assert authority("--sprint", "4", cwd=Q, human=True).returncode == 0 # the human approves S4's plan +rec = [e for e in events(Q) if e["event"] == "human.approval"][-1] +assert _approval.pinned(Q, "S4") == (now4, "") and rec["authority"]["grant"]["file_sha256"] == now4 +bad = json.loads(json.dumps(rec)) +bad["authority"]["grant"]["file_sha256"][_approval.M.rel(Q, os.path.join(qs4, "tasks.md"))] = "0" * 64 +append(bad, 22) +files, why = _approval.pinned(Q, "S4") +assert files == {} and "pins no plan files" in why, why # hashes that do not add up +bad = json.loads(json.dumps(rec)) +del bad["authority"]["grant"]["prompt"] +append(bad, 23) +files, why = _approval.pinned(Q, "S4") +assert files == {} and "not the human's own words" in why, why # a reviewed record with no line +qs5 = sprint(5, cwd=Q) +write("docs/agents/sprint5/standards.md", "# standards\n", Q) +old5 = {r: h for r, h in _approval.plan_map(Q, "S5").items() if not r.endswith("standards.md")} +auth5 = dict(auth, autonomy_mode="reviewed", sprint="S5") +append(dict(base, authority=dict(auth5, grant={"kind": "plan", "plan_sha256": _approval.map_digest(old5), + "sha256": _approval.grant_sha(auth5, _approval.map_digest(old5))})), 24) +good, why = _approval.holds(Q, "S5", _approval.plan_digest(Q, "S5")) +assert not good and "older than its intake.md and standards.md" in why[0], why # an approval from before them +ok("a grant pins plan text only while it holds: none before the human's grant, the planner's gated plan of that " + "sprint under autonomy, the approved files under review; a forged record or edited per-file hashes pin nothing; an " + "approval from before intake.md and standards.md were plan files says so") + shutil.rmtree(mp.dir, ignore_errors=True) shutil.rmtree(sp.dir, ignore_errors=True) print("%d checks passed" % n[0]) diff --git a/scripts/test/supply-chain.test.py b/scripts/test/supply-chain.test.py index c4b46f5e..38909122 100644 --- a/scripts/test/supply-chain.test.py +++ b/scripts/test/supply-chain.test.py @@ -1,14 +1,17 @@ #!/usr/bin/env python3 -"""ROADMAP M10.2: GREEN refuses a dependency added to a manifest that the approved plan does not -name, and a credential committed to the project blocks GREEN (in the lines it added) and the -final gate (anywhere). Package installs are the usual supply-chain entry, and acceptance proved -behaviour, not where the code came from. `deps added` lists the new names per manifest -(Cargo.toml, package.json, requirements*.txt, pyproject.toml, go.mod); gate-green-verify blocks -on any the story's plan (tasks.md, targets.json, plan.md, validate.md, stories.md) leaves out. -`secrets scan` finds fixed-shape credentials and prints where, never the text. +"""ROADMAP M10.2: GREEN refuses a dependency added to a manifest that the approved plan does not name +(only plan text the human's grant pins counts, M0.9: the plan they approved, or under their autonomy +grant the plan as the planner's gate passed it), and a credential committed to the project blocks +GREEN (in the lines it added) and the final gate (anywhere). Package installs are the usual +supply-chain entry, and acceptance proved behaviour, not where the code came from. `deps added` +lists the new names per manifest (Cargo.toml, package.json, requirements*.txt, pyproject.toml, +go.mod); gate-green-verify blocks on any the story's plan (tasks.md, targets.json, plan.md, +validate.md, stories.md) leaves out. `secrets scan` finds fixed-shape credentials and prints where, +never the text. python3 scripts/test/supply-chain.test.py """ import atexit +import json import os import shutil import subprocess @@ -16,6 +19,9 @@ import tempfile sys.dont_write_bytecode = True +sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures")) +from plan_fixture import approve_plan # noqa: E402 + BIN = os.path.realpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "plugin", "bin")) T = os.path.realpath(tempfile.mkdtemp(prefix="aloop-deps-")) atexit.register(shutil.rmtree, T, ignore_errors=True) @@ -102,12 +108,90 @@ def green(): capture_output=True, text=True, input="") +TASKS = "---\ntype: tasks\nstory: S1-01\n---\n## T1 — fetch a page\n%s\n" r = green() assert r.returncode == 2 and "leftpadx" in r.stderr and "requirements.txt" in r.stderr and "plan" in r.stderr, r.stderr -write(os.path.join(STORY, "tasks.md"), "---\ntype: tasks\nstory: S1-01\n---\n## T1 — fetch a page\nAdds `leftpadx` for padding.\n") +approve_plan(MAIN, ENV) # the human approves the plan as it is: it does not name leftpadx +r = green() +assert r.returncode == 2 and "leftpadx" in r.stderr, r.stderr +ok("GREEN refuses a dependency the approved plan does not name") + +# 2b) plan text counts only as the human approved it: naming the dependency after their approval does +# not cover it (the changed file is named); their approval of the plan that names it does +write(os.path.join(STORY, "tasks.md"), TASKS % "Adds `leftpadx` for padding.") +r = green() +assert r.returncode == 2 and "leftpadx" in r.stderr and "s1-01-fetch/tasks.md" in r.stderr and "changed since" in r.stderr, r.stderr +approve_plan(MAIN, ENV) +assert green().returncode == 0 +ok("a dependency named after the human's approval is refused; their approval of the plan that names it admits it") + +# 2c) a re-plan after the approval leaves the approved text standing: another story's change, or this story's +# tasks.md growing a task, does not undo the approved dependency; a dependency only the new text names is refused +write(os.path.join(os.path.dirname(STORY), "s1-02-other", "tasks.md"), "---\ntype: tasks\nstory: S1-02\n---\n## T1 — other\nlater\n") +assert green().returncode == 0 +write(os.path.join(STORY, "tasks.md"), TASKS % "Adds `leftpadx` for padding.\n\n## T2 — more\nAdds `padx9` too.") +r = green() +assert r.returncode == 0, r.stderr +write(os.path.join(wt, "requirements.txt"), "# pinned\nrequests==2.31\nleftpadx==0.1\npadx9==1.0\n") +sh("git", "commit", "-qam", "green: padx9", cwd=wt) +r = green() +assert r.returncode == 2 and "padx9" in r.stderr and "s1-01-fetch/tasks.md" in r.stderr and "changed since" in r.stderr, r.stderr +sh("git", "reset", "-q", "--hard", "HEAD~1", cwd=wt) +write(os.path.join(STORY, "tasks.md"), TASKS % "Adds `leftpadx` for padding.") +ok("a re-plan after the approval keeps the approved text: its dependency stands, one only the new text names does not") + +# 2d) only the files the approval pins are plan text: a STORY_DIR that is the sprint dir reads none of them +write(os.path.join(os.path.dirname(STORY), "tasks.md"), TASKS % "Adds `leftpadx` for padding.") +r = subprocess.run([DEPS, "unplanned", "--base", "main", "--story", os.path.dirname(STORY), "--root", wt], + env=ENV, capture_output=True, text=True) +assert r.returncode == 2 and "requirements.txt\tleftpadx" in r.stdout, r +os.remove(os.path.join(os.path.dirname(STORY), "tasks.md")) +ok("text outside the approved plan's files names no dependency (a sprint-dir STORY_DIR, an unpinned tasks.md)") + +# 2e) under the human's autonomy grant the plan counts as the planner's gate passed it (gate-stage2-complete +# records it on the planner's stop): before a pass nothing counts, and says so; a dependency named after the +# pass is refused; neither a bare `ids gated`, a self-check nor `events emit` records the plan; the planner's +# next pass (here naming it in stories.md) admits it +SPRINT = os.path.dirname(STORY) +PLANNER_STOP = json.dumps({"hook_event_name": "SubagentStop", "agent_type": "aloop:planner", "agent_id": "planner-1"}) + + +def stage2(selfcheck=False): + env = dict(ENV, AGENTIC_SELFCHECK="1") if selfcheck else ENV + r = subprocess.run([os.path.join(BIN, "gate-stage2-complete"), SPRINT], cwd=MAIN, env=env, + capture_output=True, text=True, input=PLANNER_STOP) + assert r.returncode == 0, r.stderr + + +write(os.path.join(SPRINT, "stories.md"), "---\ntype: stories\nsprint: 1\n---\n# Sprint 1\n\n- S1-01 (s1-01-fetch)\n- S1-02 (s1-02-other)\n") +write(os.path.join(SPRINT, "plan.md"), "---\ntype: sprint-plan\nsprint: 1\nstage: \"2\"\n---\n# Waves\n") +for sid, k in (("s1-01-fetch", 1), ("s1-02-other", 2)): + write(os.path.join(SPRINT, sid, "validate.md"), "---\ntype: validate\nstory: S1-0%d\n---\n## T1\npytest -q\n" % k) + write(os.path.join(SPRINT, sid, "plan.md"), "---\ntype: plan\nstory: S1-0%d\nstage: \"2\"\n---\n# Plan\n" % k) +approve_plan(MAIN, ENV, mode="autonomous") +r = green() +assert r.returncode == 2 and "leftpadx" in r.stderr and "S1 is autonomous, but no plan of it has passed the planner's gate yet" in r.stderr, r.stderr +stage2() +assert green().returncode == 0 +write(os.path.join(wt, "requirements.txt"), "# pinned\nrequests==2.31\nleftpadx==0.1\npadx2==1.0\n") +sh("git", "commit", "-qam", "green: padx2", cwd=wt) +write(os.path.join(STORY, "tasks.md"), TASKS % "Adds `leftpadx` for padding and `padx2` for more.") +r = green() +assert r.returncode == 2 and "padx2" in r.stderr and "s1-01-fetch/tasks.md" in r.stderr and "changed since" in r.stderr, r.stderr +IDS = os.path.join(BIN, "ids") +for args, inp in ((["gated", SPRINT], ""), (["gated", SPRINT], json.dumps({"agent_type": "aloop:green-worker"}))): + assert subprocess.run([IDS] + args, cwd=MAIN, env=ENV, input=inp, capture_output=True, text=True).returncode == 64 +stage2(selfcheck=True) # the supervisor's self-check is no verdict +forged = subprocess.run([os.path.join(BIN, "events"), "emit", "plan.gated", "--data", "sprint=S1"], cwd=MAIN, env=ENV, + capture_output=True, text=True) +assert forged.returncode != 0 and green().returncode == 2, forged +write(os.path.join(STORY, "tasks.md"), TASKS % "Adds `leftpadx` for padding.") +write(os.path.join(SPRINT, "stories.md"), "---\ntype: stories\nsprint: 1\n---\n# Sprint 1\n\n- S1-01 (s1-01-fetch), " + "with `padx2`\n- S1-02 (s1-02-other)\n") +stage2() r = green() assert r.returncode == 0, r.stderr -ok("GREEN refuses a dependency the approved plan does not name, and accepts it once the plan names it") +ok("under an autonomy grant a dependency counts once the planner's gate passed the plan that names it, and only then") # Fake credentials are assembled at run time so this file never holds one (push protection). SECRETS = os.path.join(BIN, "secrets") From 15b90229275532d043165f88185e694db1a37dc5 Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Tue, 20 Oct 2026 17:05:59 +0000 Subject: [PATCH 2/2] Make the cap test's fresh-checkout approval wait out the last record's second On a fresh checkout a typed line from the same second as an earlier human decision counts as older (stale_before), so on a fast runner the raise-the-cap approval asked again and the test failed. The human now types after that second, as a clone's human always does. Reproduced with a frozen clock. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WBVFNrEg85XAnSfHQidCXN --- scripts/test/mission-tick.test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/test/mission-tick.test.py b/scripts/test/mission-tick.test.py index 34d9a7c9..4b9e2469 100755 --- a/scripts/test/mission-tick.test.py +++ b/scripts/test/mission-tick.test.py @@ -1226,6 +1226,8 @@ def lifts(p): doc["budget"]["tokens"] = 5000 doc["status"] = "draft" M.save(M.path_of(p.dir, "mission"), doc) +while M.now() <= M.ledger_rows(p.dir)[0][-1]["ts"]: # the clone's human types after the last record: + time.sleep(0.05) # a line from its second counts as older assert p.mi("approve", "--by", "Adeel", "--reason", "raise the cap").returncode == 0 p.review(p.mission_ref(), p.mission_doc(), "clear", 1.3) d = p.tick(1.4)