From 3ade61e2fe4543501e1c303692bb83bfa8358ed7 Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Tue, 20 Oct 2026 09:36:53 +0000 Subject: [PATCH 1/2] A mission's gap list counts only as `mission evaluate` computed it (M9.27) `mission evaluate` now records eval.completed in the committed ledger. `evaluate check`, `goal derive`/`close` and `mission tick` count an eval only with that record of its content, so a hand-written or edited eval no longer reads as "goal met", and a fresh checkout derives and closes goals from the evals it committed (goal close orders by the ledger). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Aw6CiQcdpzdzZZXKf8WbUM --- CHANGELOG.md | 1 + docs/ROADMAP.md | 8 ++--- docs/TRACKING.md | 2 +- plugin/bin/_mission.py | 9 ++--- plugin/mission/README.md | 3 +- plugin/mission/evaluate.py | 30 ++++++++++++---- plugin/mission/goal.py | 34 ++++++------------- plugin/mission/tick.py | 19 +++++------ scripts/test/mission-evaluate.test.py | 2 ++ scripts/test/mission-tick.test.py | 49 +++++++++++++++++++++++++++ 10 files changed, 108 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7835938..213522db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ tag in lockstep. Tag releases as `vMAJOR.MINOR.PATCH`. ### Added - 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. +- A mission's gap lists count only as `mission evaluate` computed them (ROADMAP §4.12, M9.27): `evaluate` records `eval.completed` in the committed ledger, and `evaluate check`, `goal derive`/`close` and `mission tick` count an eval only with that record of its content. An eval file written by hand, or edited after it was recorded, no longer sends the loop to `RESEARCH` as "goal met", and a fresh checkout derives and closes goals from the evals it committed. Test: `mission-tick` check 32. - A mission's stop at a spend cap holds on a fresh checkout (ROADMAP §4.12, M9.24): the first `STOP_BUDGET` tick records a `mission.budget_exhausted` ledger row for the mission's content (once per content), and `mission tick` stops on it whatever the checkout's token ledger says, until a raised cap changes the content. - Lifting a mission block is the human's own words (ROADMAP §4.12, M9.51): `aloop mission tick --force --by` now asks (exit 3) for the human's typed `lift ` line, the code bound to this occurrence of that block, and records a `mission.lifted` ledger row, so `--by` alone, a lift only the run log has (or a replayed one), an old line or a line typed for an earlier block lift nothing, a lift of 3 failed goals reaches only those goals whatever `--now` says, and a fresh checkout keeps a lifted block lifted. `/aloop:mission` counts a lift among the typed grants it relays. A lift recorded before this (run data only) no longer counts. - The mission layer's six fixed roles (ROADMAP §4.12, M9.9): `market-researcher`, `product-tester`, `state-assessor`, `evaluator`, `mission-planner` and `ethics-reviewer`, each a persona with a four-case eval suite, a model route (the four that judge on the planning route, the two that measure on the worker route), hook matchers on Claude Code, Codex, OpenCode and dsh, and Codex/OpenCode agents and dsh presets from `aloop install` (which also renders the mission skill for OpenCode as `aloop-mission` once it ships). `plugin/mission/roles.json` names the paths each role writes. `gate-mission-scope` (PreToolUse) is the role path guard: a mission role never writes source, mission.json or another role's dir, never commits and never runs a human's approval; a builder never writes `docs/agents/mission/` or runs a writing `mission` command; the supervisor never hand-writes a role's artifact. No one hand-writes `docs/agents/mission/ledger.jsonl` or the captured prompts a grant reads (`/transcripts/`), runs a hook's `transcripts prompt|record|…`, or starts a host session (`claude -p`, `codex exec`, `opencode run`, `dsh `) from a tool call where a mission is set (its prompt would count as the human's words, M9.17), and no dispatched agent runs `mission baseline restore`, `events authority` or an `events emit` of a human event. `gate-mission-artifact` records what exists when a role starts and, at its stop, requires an artifact in its own paths that passes the core contract and its area's check, refuses a deleted artifact, a change to another role's or a ledger that no longer verifies, and records `artifact.created|updated` as provenance. A mission write never arms the sprint lock. The scope gate reads a Bash command as the shell would (`_shellread.py`: quotes, comments, line continuations, heredocs, wrappers such as `timeout` and `env`, `bash -c`, `eval`, a script run by an interpreter, variables and `$(mktemp)`). Each area's check runs once per artifact with its id or subject, an ethics hard line is the reviewer's finding, not a defect, and a derived goal whose only blocks are its pending ethics review waits on the Ethics Reviewer, not on the planner. Test: `mission-roles.test.py` (33 checks, with each role run through the real journeys, baseline, assess, evaluate and ethics, goal, research and judge areas), `mission-scope-bash.test.py` (225 commands), `opencode-plugin.test.mjs`. diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index b9c11f22..376ad453 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -406,8 +406,8 @@ replacement applies after the mission's veto window) → open goal? its `ETHICS_ `APPROVE_PLAN`) → `WAIT` until the sprint closes, with an `ASSESS`/`EVALUATE` whenever the cadence is due mid-sprint (12h silent → `BLOCKED`) → `ASSESS` → `EVALUATE` → goal met? `RESEARCH` (raise the bar, at most once per cadence) : `DERIVE_GOAL` (3 failed goals in a row → `BLOCKED`). The budget -comes before the mission's review because a review spends tokens. Human decisions, the baseline -and state reports are read from the committed ledger, the way their areas decide them, so on a +comes before the mission's review because a review spends tokens. Human decisions, the baseline, +state reports and gap lists are read from the committed ledger, the way their areas decide them, so on a fresh checkout these decide the same, a stop at a spend cap included (the spend itself is the checkout's token ledger; sprint history is still run data: M9.26); a broken ledger or confirmed baseline is `BLOCKED`. A version once confirmed is archived, never a replacement; a @@ -441,7 +441,7 @@ Each task flips only its own row here and in TRACKING.md. | M9.5 | Judges: rubric setup check and an agreement verdict from recorded runs | M9.0 | `plugin/mission/judge.py`, `schemas/rubric.json`, `scripts/test/mission-judge.test.py` | yes | done: `mission-judge.test.py` (24 checks: pinned models, majority, frozen rubrics, records matched to their judge.run events, verdict shopping, fresh clones). `verdict(…, rubric_sha256=)` lets an approved journey pin its rubric (M9.3 adopts it). Open: a judge on Codex/OpenCode needs an envelope that names the served model (plain text never counts); assess should pass `input_sha256` of a runner-made artifact, since today the judged agent picks the input | | M9.6 | Telemetry (GA4): opt-in consent, Admin API setup, Measurement Protocol debug hit, fixed Data API reports (+ realtime), minimum-sample rule, static emit check; network faked in tests | M9.0 | `plugin/mission/telemetry.py`, `schemas/telemetry.json`, `scripts/test/mission-telemetry.test.py`, `scripts/test/fixtures/fake-ga.py` | yes | done: `mission-telemetry.test.py` (15 checks, fake GA); consent and revoke are human rows in the ledger, the newest by time decides (a union merge keeps order-free), a ledger failing its check decides nothing, and a fresh checkout keeps them (their provenance rides M9.17); the journeys it binds are what the records pin (frozen or a recorded replacement, not retired, unchanged); `verify` is the live round-trip (MP hit → realtime report), and the probe's client is never a counted user | | M9.7 | Principles in two variants with tension pairs; `principles show --mode`, hashed and injected into goals | M9.0 | `plugin/mission/principles.{md,py}`, `scripts/test/mission-principles.test.py` | yes | done: `mission principles show / hash / check`, `stamp()` / `verify()` / `stale()` for goals; `mission-principles.test.py` (7 checks). Calls: a goal keeps the stamp it was derived under (an older block is stale, not invalid: re-stamping would void its ethics review and approval); the Amazon tension pairs map onto our principle ids; the standing set and the four pairs are required, more may be added; a variant is at most 280 characters (the block rides on every goal) | -| M9.8 | Loop: `tick` (the state machine above), `due` (zero-token cadence check), `cron` (host routine or crontab line), budget caps from the token ledger | M9.0 | `plugin/mission/{tick,due,cron}.py`, `scripts/test/mission-tick.test.py` | yes | done: `mission-tick.test.py` (31 checks, on baselines proposed, measured and confirmed through `aloop mission`; on a fresh checkout the human decisions, the baseline and state reports decide the same). Review (13 findings, each a test that failed before its fix): a restore is never undone; an unmeasurable or vetoed proposal names what the gates accept; distinct block keys; the ledger folds by time; a committed hard review fails closed; a state needs its `state.assessed` record; only the 3-failed-goals grant resets that count; the facts fingerprint covers spend, reviews, intents, plans, the lock and grants | +| M9.8 | Loop: `tick` (the state machine above), `due` (zero-token cadence check), `cron` (host routine or crontab line), budget caps from the token ledger | M9.0 | `plugin/mission/{tick,due,cron}.py`, `scripts/test/mission-tick.test.py` | yes | done: `mission-tick.test.py` (32 checks, on baselines proposed, measured and confirmed through `aloop mission`; on a fresh checkout the human decisions, the baseline, state reports and gap lists decide the same). Review (13 findings, each a test that failed before its fix): a restore is never undone; an unmeasurable or vetoed proposal names what the gates accept; distinct block keys; the ledger folds by time; a committed hard review fails closed; a state needs its `state.assessed` record; only the 3-failed-goals grant resets that count; the facts fingerprint covers spend, reviews, intents, plans, the lock and grants | | M9.9 | Roles and wiring: the six personas, hook matchers, model routes, host install, eval suites, role counts in docs; `gate-mission-scope` (role path guards) and `gate-mission-artifact` (a role's artifact passes its check at stop) | M9.0 | `plugin/agents/` (6 new files), `plugin/mission/roles.json` (the role table), `plugin/bin/_mission_roles.py`, `plugin/hooks/hooks.json`, `plugin/hosts/`, `plugin/evals/`, `plugin/bin/gate-mission-*`, the role lists in `_routes` / `install` / `gate-dispatch` / `selfcheck` / `budget`, role counts in README / OVERVIEW / plugin docs | yes (the only track touching shared lists) | done: `mission-roles.test.py` (33 checks, two of them runs of each role through master's real research, judge, journeys, baseline, assess, evaluate, ethics and goal areas), `mission-scope-bash.test.py` (225 Bash commands from two adversarial reviews and the M9.2/M9.3/M9.8/M9.17 asks), 6 OpenCode and 3 dsh end-to-end checks. Calls: judges (researcher, evaluator, planner, ethics) take the planning route, the two measuring roles the worker route; every mission role is read-only on source and writes only its own dirs (the planner also `docs/agents/intents/`, where only its `source: mission` intents are its work) and never the event log or the gates' state; the supervisor never hand-writes a role's artifact (mission.json stays the human's) and no one hand-writes `ledger.jsonl` (an edit made inside a role's run blocks its stop) or the captured prompts a grant reads (`/transcripts/`), runs a hook's `transcripts prompt|record|…`, or, where a mission is set, starts a host session from a tool call (`claude -p`, `codex exec`, `opencode run`, `dsh ` fire UserPromptSubmit: M9.17); no dispatched agent runs a human's step (`approve`, `confirm`, `veto`, `restore`…, `tick --force`, `events authority`, an `events emit|decide` with role `human`) or hand-emits a mission-layer event; a mission write never arms the sprint lock; an area's check runs once per artifact with its id or subject (`area_checks` in roles.json), and an ethics hard line is the reviewer's finding, not a defect, and a goal check that waits only on the goal's ethics review is the reviewer's step, not the planner's defect; a status change an event of the run explains (a human's step, or the role's own command: `baseline apply` freezing journeys, a hard line blocking its goal) is not another role's write; at stop a role must have written an artifact, and a content or status change to another role's artifact blocks unless a run of that role overlapped or the human approved it; a human event during a role's run is named, not blocked (the gate cannot tell who ran it: M9.17); the scope gate reads Bash with its own shell reader (`_shellread.py`), and what only running a command would tell is judged by its known directory or not at all | | M9.10 | Assess and evaluate: the State Assessor's report (numbers only, from pinned scripts) and the Evaluator's gap list against the baseline and rivals, with `goal_met` | M9.2, M9.3, M9.5 | `plugin/mission/{assess,evaluate}.py`, `schemas/{state,eval}.json`, `scripts/test/mission-evaluate.test.py` | after its needs | done: `mission-evaluate.test.py` (8 checks); judged metrics come from `judge.verdict(cwd, rubric, journey_id, rubric_sha256=…)` (M9.5) for the rubric content the journey pinned and stay pending until a pass or fail verdict; every input is the content its record covers (state `state.assessed`, baseline confirmation, frozen journeys, goal `goal.derived`/`goal.approved`). Open: rival values keyed per benchmark in the baseline, so the gap list compares against rivals (review finding) | | M9.11 | Goals and the Aladdin handoff: top gaps → a goal → intents (`intent` source `mission`), ethics and principles applied, mode → autonomy; `events trace` reaches goal → mission | M9.4, M9.7, M9.10 | `plugin/mission/goal.py`, `schemas/goal.json`, `plugin/bin/intent` (source list), `plugin/bin/events` (trace) | after its needs | done: `mission goal options / derive / check / approve / intents / next / close / show`, `intent new --source mission --goal --gap`, `events trace` adds goal → eval → ethics → mission; `mission-goal.test.py` (13 checks, on the real journeys → baseline → assess → evaluate pipeline; every new gate mutation-tested: deleting it fails a check). Calls: a goal takes M9.10's gaps in its own order (regressions, then closest to target) and names them as `targets` [{journey_id, criterion_id}], which `mission evaluate` narrows to while the goal is active; autonomous takes the top 3 by default, spoon-fed the human's `--pick` (the pick is `goal.approved`); a goal comes only from the latest eval of the whole mission (not an older one, whose gaps may be closed, nor one narrowed to an active goal) whose gap list `evaluate check` confirms, whose content its `eval.completed` recorded, and whose state a `state.assessed` recorded (a hand-written state that `mission evaluate` accepted is still refused); `goal check`, `intents`, `next` and `close` hold a goal to the content its `goal.derived` recorded, so a crafted or edited-and-resealed goal file is never handed off or closed; a goal is stale once the mission's content changes; intents are filled from the gap and the journey without a model (zero tokens), one per gap, normalized one at a time by `next`, which first makes that intent the newest file (gate-intake re-checks the newest, so the sprint's plan links the right gap); `intent new --source mission` needs `--gap` and a goal that passes `goal check` and lists that gap, and `intent check` holds a mission intent to its own `intent.received` record (goal and gap) and to the goal's autonomy (a reviewed goal's intent is not checked as autonomous); the handoff counts only intents whose first `intent.received` names the goal; `intents` and `close` change only the status, never the goal's hashed content (its ethics review, consent and approval stay valid); a goal is met by a newer evaluation of that goal that says `goal_met`, only while it is active (a derived, blocked or retired goal never closes; closing a met goal again is a no-op); `events emit` refuses `goal.derived`, `goal.met`, `state.assessed`, `eval.completed` and `intent.received`, so the lineage `trace` reads and the records a goal is derived and closed from are written only by their commands (edits outside its files: `assess` and `evaluate` add the content's `sha256` to their events, one field each). A gap a hard line fixed is held, by its id and by its summary: listed apart by `options`, never taken by `derive`, so the autonomous loop moves on instead of re-deriving it (`ethics.blocked` names the gaps); a gap's summary is the journey's title, criterion and target (stable across evals); a goal keeps the principles stamp it was derived under (stale after an upgrade, not invalid, since re-stamping would void its ethics review and approval) | @@ -460,7 +460,7 @@ Each task flips only its own row here and in TRACKING.md. | M9.24 | The human's `mission tick --force --by` grant, the ethics reviews (`ethics.reviewed`/`ethics.blocked`, already `LEDGER_EVENTS`, still only emitted) and `mission.budget_exhausted` are ledger rows, not run data. Reason: found aligning M9.8 with the ledger and in its review, a fresh checkout loses them, so 3 failed goals block again, every review is asked again, and a hit spend cap starts from zero (`tick` fails closed on a committed hard review meanwhile) | M9.0, M9.4 | `plugin/bin/_mission.py` (`LEDGER_EVENTS`), `plugin/mission/{tick,ethics}.py`, their tests | yes | done. Ethics part: `ethics.reviewed` and `ethics.blocked` are ledger rows (`M.record`), and ethics reads `M.history` (the ledger's rows, plus the run-log events that are not ledger rows), so a clone keeps every review, hard line and held gap; an edited run-log copy of a row changes nothing, and a broken ledger makes every verdict `broken` (`mission-ethics.test.py` checks 12 and 13, `mission-e2e.test.py`). The `--force` part is done in M9.51 (a `mission.lifted` ledger row with the human's typed line), and the stop at a cap is a `mission.budget_exhausted` ledger row for the mission's content, once per content, so a clone stays stopped until the cap is raised (`mission-tick.test.py` check 31). The spend itself is still the checkout's token ledger | | M9.25 | A baseline binds the mission's direction (statement, mode, constraints), not its whole content. Reason: found in M9.8's budget test, raising a budget cap re-approves the mission and so asks for a new baseline version, though nothing about "best" changed | M9.2 | `plugin/mission/baseline.py`, `mission-baseline.test.py` | yes | done: `mission-baseline.test.py` check 5; a baseline and its state carry `direction_sha256` = `M.direction(mission)` (`mission_id`, `statement`, `mode`, `constraints`); a new budget, deadline or cadence keeps the baseline once the mission is approved again, a new direction asks for a new version, and an unapproved mission decides nothing | | M9.26 | A goal's sprint history (intent → goal, sprint planned and closed) is read from committed records. Reason: found in M9.8's review, `intent.received`, `plan.created` and `sprints.json` are run data, so a fresh checkout re-sprints an active goal whose intents were already sprinted | M9.8, M9.11 | `plugin/mission/tick.py`, the sprint-close writer, `mission-tick.test.py` | yes | open | -| M9.27 | `tick` trusts an eval only when `evaluate check` would (a record, or a recomputed gap list). Reason: found in M9.8's review, an eval file nobody computed can say `goal_met` and send the loop to `RESEARCH` instead of `DERIVE_GOAL` | M9.8, M9.10 | `plugin/mission/{tick,evaluate}.py`, their tests | yes | open | +| M9.27 | `tick` trusts an eval only when `evaluate check` would (a record, or a recomputed gap list). Reason: found in M9.8's review, an eval file nobody computed can say `goal_met` and send the loop to `RESEARCH` instead of `DERIVE_GOAL` | M9.8, M9.10 | `plugin/mission/{tick,evaluate}.py`, their tests | yes | done: `mission-tick.test.py` check 32; `mission evaluate` records `eval.completed` in the ledger (`LEDGER_EVENTS`), `evaluate check` and `tick` count a gap list only with that record of its content, and `goal derive`/`close` read the same record and its ledger order, so a fresh checkout derives and closes from the evals it committed | | M9.28 | `tick` drives the goal commands (M9.11): a goal counts only with its `goal.derived`/`goal.approved` record and closes by `goal.met`; handouts name `goal derive`, `options` (spoon-fed), `intents`, `next` and `close`; an eval narrowed to a closed goal asks for a whole-mission eval. Reason: found when M9.11 landed, `tick` read goal files and their status, so a goal nobody derived steered the loop and a met goal was never closed | M9.8, M9.11 | `plugin/mission/tick.py`, `plugin/skills/mission/SKILL.md`, `mission-tick.test.py` | yes | done: `mission-tick.test.py` (29 checks; a real goal run on the real clock: derive → review → intents → next and a sprint per intent → narrowed eval → close → whole-mission eval → `RESEARCH`) | | M9.29 | A goal that crosses a hard line stops being the active goal (`evaluate.active_goal` skips it, or a recorded retirement). Reason: found wiring M9.28, `evaluate` keeps narrowing to a hard-lined goal and `goal derive` refuses a narrowed eval, so the mission deadlocks (`tick` hands it to the human meanwhile) | M9.10, M9.11 | `plugin/mission/{evaluate,goal}.py`, their tests | yes | open | | M9.40 | Artifact provenance in the loop: `mission tick` and each area's check accept a role's artifact only with the `artifact.created\|updated` event `gate-mission-artifact` records for it (role, agent id, sha256). Reason: found while building M9.9, the path guards stop a tool's write, but an area command the supervisor runs itself can still write a role's artifact | M9.8, M9.9 | `plugin/mission/tick.py` (M9.8's), its test | after its needs | open | diff --git a/docs/TRACKING.md b/docs/TRACKING.md index 173f7f5a..6e65e919 100644 --- a/docs/TRACKING.md +++ b/docs/TRACKING.md @@ -83,7 +83,7 @@ Status of every requirement in [ROADMAP.md](ROADMAP.md), in the four states §8 | M9.24 | `--force` grants, ethics reviews and the budget stop are ledger rows | IMPLEMENTED_TESTED | `scripts/test/mission-tick.test.py` | | M9.25 | A baseline binds the mission's direction, not its budget | IMPLEMENTED_TESTED | `scripts/test/mission-baseline.test.py` | | M9.26 | A goal's sprint history is read from committed records | NOT_IMPLEMENTED | §4.12 | -| M9.27 | The mission loop trusts an eval only when `evaluate check` would | NOT_IMPLEMENTED | §4.12 | +| M9.27 | The mission loop trusts an eval only when `evaluate check` would | IMPLEMENTED_TESTED | `scripts/test/mission-tick.test.py` | | M9.28 | The mission loop drives the goal commands and reads goals by their records | IMPLEMENTED_TESTED | `scripts/test/mission-tick.test.py` | | M9.29 | A hard-lined goal stops being the active goal | NOT_IMPLEMENTED | §4.12 | | M9.40 | Artifact provenance in the mission loop | NOT_IMPLEMENTED | §4.12 | diff --git a/plugin/bin/_mission.py b/plugin/bin/_mission.py index 6bab2ac9..d63c5cd3 100644 --- a/plugin/bin/_mission.py +++ b/plugin/bin/_mission.py @@ -242,10 +242,11 @@ def emit(cwd, event, role="", refs=None, **data): # a human decision that is not an approval: a veto, an opt-out HUMAN_EVENTS = tuple(APPROVAL_EVENTS) + ("baseline.vetoed", "telemetry.revoked") # every record a mission gate decides from: the human decisions, plus what the harness measured, -# assessed, retired, reviewed (a hard ethics line stays blocked on a fresh checkout), derived and the -# loop's own stop at a spend cap (a clone stays stopped) -LEDGER_EVENTS = HUMAN_EVENTS + ("baseline.measured", "state.assessed", "journey.retired", "ethics.reviewed", - "ethics.blocked", "goal.derived", "goal.met", "mission.budget_exhausted") +# assessed, evaluated (a clone trusts the same gap lists), retired, reviewed (a hard ethics line stays +# blocked on a fresh checkout), derived and the loop's own stop at a spend cap (a clone stays stopped) +LEDGER_EVENTS = HUMAN_EVENTS + ("baseline.measured", "state.assessed", "eval.completed", "journey.retired", + "ethics.reviewed", "ethics.blocked", "goal.derived", "goal.met", + "mission.budget_exhausted") def ledger(cwd=None): diff --git a/plugin/mission/README.md b/plugin/mission/README.md index c0bede40..c288d829 100644 --- a/plugin/mission/README.md +++ b/plugin/mission/README.md @@ -106,7 +106,8 @@ A gate checks structure and evidence, never whether a judgment is right. - A gap list (`evl_…`, sealed) is `{eval_id, state_id, baseline_id, goal_id, goal_met, regressions, gaps, earned, metrics}`; each gap is `{gap_id: "#", journey_id, criterion_id, kind: regression|open|unscored, now, baseline, target, distance}`, regressions first, - then by distance. `eval.completed` carries `eval_id` and `sha256`. Every input is the content its + then by distance. `eval.completed` is a ledger record carrying `eval_id` and `sha256`: a gap list + counts (for `evaluate check`, `goal` and `tick`) only with the record of its content. Every input is the content its record covers: the state a `state.assessed` ledger record (only `mission assess` measures), the baseline a confirmation, each journey the content the baseline froze, and the goal a `goal.derived` or `goal.approved` record (the newest such goal with no later `goal.met` record is the active one; a diff --git a/plugin/mission/evaluate.py b/plugin/mission/evaluate.py index f897d134..cc3d7f7d 100644 --- a/plugin/mission/evaluate.py +++ b/plugin/mission/evaluate.py @@ -16,9 +16,10 @@ Usage: mission evaluate [STATE_ID] [--rival REF]… [--json] evaluate a state report (default: the latest); writes docs/agents/mission/eval/.json - (sealed) and emits eval.completed. Exit 0 · 2 block (the state is not intact or its runs disagree) + (sealed) and records eval.completed in the ledger. Exit 0 · 2 block (the state is not intact or + its runs disagree) mission evaluate check [EVAL_ID] [--json] - the gap list is intact and follows from its state, baseline and goal. Exit 0 · 2 + the gap list is intact, recorded and follows from its state, baseline and goal. Exit 0 · 2 """ import json import os @@ -172,9 +173,9 @@ def cmd_evaluate(cwd, sid, o): goal_id=(goal or {}).get("goal_id"), rival_refs=o.get("rival", []), status="recorded", created_at=M.now()) M.seal(doc) path = M.save(M.path_of(cwd, KIND, eid), doc) - M.emit(cwd, "eval.completed", role="evaluator", refs={"eval": M.rel(cwd, path), "state": M.rel(cwd, spath)}, - eval_id=eid, sha256=doc["sha256"], state_id=state["state_id"], goal_id=doc["goal_id"], - goal_met=res["goal_met"], gaps=len(res["gaps"]), regressions=res["regressions"]) + M.record(cwd, "eval.completed", M.rel(cwd, path), "evaluator", eval_id=eid, sha256=doc["sha256"], + state_id=state["state_id"], goal_id=doc["goal_id"], goal_met=res["goal_met"], gaps=len(res["gaps"]), + regressions=res["regressions"]) if o.get("json"): print(json.dumps(doc, indent=1)) else: @@ -185,8 +186,15 @@ def cmd_evaluate(cwd, sid, o): return 0 +def recorded(cwd, path, doc): + """The eval.completed ledger record of exactly this content (only `mission evaluate` writes it), or None.""" + rec = M.newest(cwd, "eval.completed", M.rel(cwd, path)) + return rec if rec and rec["data"].get("sha256") == M.digest(doc) else None + + def latest(cwd): - rows = M.artifacts(cwd, KIND) + """The newest gap list `mission evaluate` recorded (a file with no record is not one).""" + rows = [(p, d) for p, d in M.artifacts(cwd, KIND) if recorded(cwd, p, d)] return max(rows, key=lambda pd: (pd[1].get("created_at", ""), pd[0])) if rows else (None, None) @@ -194,6 +202,16 @@ def problems(cwd, path, doc): out = M.problems(doc, KIND, path) if out: return out + out = follows(cwd, doc) + if not recorded(cwd, path, doc): + out.append("eval %s has no eval.completed record for this content: only `mission evaluate` evaluates" + % doc["eval_id"]) + return out + + +def follows(cwd, doc): + """A well-formed gap list's problems against its inputs: sealed, and recomputed from them.""" + out = [] if "sha256" not in doc: out.append("a gap list is sealed when it is written") spath = M.path_of(cwd, "state", doc["state_id"]) diff --git a/plugin/mission/goal.py b/plugin/mission/goal.py index 52150a29..dcf661a5 100644 --- a/plugin/mission/goal.py +++ b/plugin/mission/goal.py @@ -67,18 +67,10 @@ # ── evals (M9.10's gap list: plugin/mission/evaluate.py) ──────────────────────────── -def first(cwd, event, key, value): - """The first event of a kind whose data[key] is value (gate-owned events: the one its command wrote).""" - for e in _events.read(cwd): - if e.get("event") == event and (e.get("data") or {}).get(key) == value: - return e - return None - - def eval_record(cwd, eid): - """(doc, eval.completed event, problems) of one gap list: M9.10's own check (it follows from its + """(doc, eval.completed record, problems) of one gap list: M9.10's own check (it follows from its state, which a state.assessed ledger record covers, its baseline and goal) and the eval.completed - that recorded this content (written only by `mission evaluate`).""" + ledger record of this content (written only by `mission evaluate`; a fresh checkout keeps it).""" if not isinstance(eid, str) or not EVAL_ID.match(eid): return None, None, ["%r is not an eval id (evl_…)" % (eid,)] path = M.path_of(cwd, "eval", eid) @@ -92,17 +84,17 @@ def eval_record(cwd, eid): return doc, None, ["eval %s is malformed (%s)" % (eid, e)] if doc.get("eval_id") != eid: bad.append("eval %s: eval_id does not match the file name" % eid) - ev = first(cwd, "eval.completed", "eval_id", eid) + ev = M.newest(cwd, "eval.completed", M.rel(cwd, path)) if not ev: - bad.append("eval %s is not recorded (no eval.completed event names it)" % eid) + bad.append("eval %s is not recorded (no eval.completed record names it)" % eid) elif ev["data"].get("sha256") != sha: bad.append("eval %s is not the content its eval.completed recorded" % eid) return doc, ev, bad def latest_eval(cwd): - """The id of the latest recorded eval (stream order), or None.""" - ids = [(e.get("data") or {}).get("eval_id") for e in _events.read(cwd) if e.get("event") == "eval.completed"] + """The id of the latest recorded eval (ledger order), or None.""" + ids = [r["data"].get("eval_id") for r in M.records(cwd, "eval.completed")] for eid in reversed(ids): if eid and os.path.exists(M.path_of(cwd, "eval", eid)): return eid @@ -133,13 +125,10 @@ def split_held(cwd, gaps): return [g for g in gaps if g not in held], held -def stream_index(cwd, pred): - """The position of the last event matching pred in the stream, or -1.""" - hit = -1 - for i, e in enumerate(_events.read(cwd)): - if pred(e): - hit = i - return hit +def ledger_index(cwd, event_id): + """The position of a ledger row in the ledger (a fresh checkout keeps the order), or -1.""" + ids = [r.get("event_id") for r in M.ledger_rows(cwd)[0]] + return ids.index(event_id) if event_id in ids else -1 # ── the goal's gate ────────────────────────────────────────────────────────────────── @@ -532,8 +521,7 @@ def cmd_close(cwd, gid, eid): report(["eval %s is not an evaluation of goal %s (it evaluates %s): evaluate while the goal is active" % (eid, gid, doc.get("goal_id") or "the whole mission")], []) return 2 - born = stream_index(cwd, lambda e: e.get("event_id") == derived(cwd, gid)["event_id"]) - seen = stream_index(cwd, lambda e: e.get("event_id") == ev.get("event_id")) + born, seen = ledger_index(cwd, derived(cwd, gid)["event_id"]), ledger_index(cwd, ev.get("event_id")) if born < 0 or seen <= born: report(["eval %s was recorded before goal %s was derived: it says nothing about the goal's work" % (eid, gid)], []) return 2 diff --git a/plugin/mission/tick.py b/plugin/mission/tick.py index a69e4125..663b4188 100644 --- a/plugin/mission/tick.py +++ b/plugin/mission/tick.py @@ -53,8 +53,8 @@ each goal (none → ETHICS_REVIEW, pending → ASK_CONSENT, hard or broken → BLOCKED, or a goal re-derived; one rule with the gate: a hard line follows its words to any goal, a review edited after it was recorded is broken), and a committed review of tier hard, so a checkout without the -run log fails closed; the eval's -`goal_met`; a goal only with its goal.derived (or goal.approved) record, closed by goal.met, and an +run log fails closed; a gap list +only with its eval.completed record (its `goal_met` and gaps); a goal only with its goal.derived (or goal.approved) record, closed by goal.met, and an eval narrowed to it (goal_id) decides its close (`aloop mission goal close`); Aladdin's intent, plan and sprint events and .aladdin/state/sprints.json; the sprint lock; and the token ledger (/ledger/). A goal's sprints are planned from its intents (intent.received @@ -291,12 +291,14 @@ def rel(p): # decides, so restoring content an older approval covered is a rollback, not approved raw, _ = M.ledger_rows(cwd) rows = sorted(raw, key=lambda r: r["ts"]) # the core's order: a union merge interleaves branches - assessed, born, met = {}, {}, {} + assessed, evaluated, born, met = {}, set(), {}, {} f["lifted"], f["lifts"], f["stops"] = {}, {}, {} for r in rows: name, d = r["event"], r["data"] if name == "state.assessed": assessed[d.get("subject")] = d.get("sha256") + if name == "eval.completed": + evaluated.add((d.get("subject"), d.get("sha256"))) if name in ("goal.derived", "goal.approved"): born.setdefault((d.get("subject"), d.get("sha256")), []).append(r["ts"]) if name == "goal.met": @@ -318,6 +320,9 @@ def rel(p): f["ledger_head"] = raw[-1]["hash"] if raw else "" # a state report counts only with the state.assessed record of its content (mission assess) f["kinds"]["state"] = [a for a in f["kinds"]["state"] if assessed.get(a["ref"]) == a["sha"]] + # and a gap list only with the eval.completed record of its content (mission evaluate), as `evaluate + # check` and `goal derive` read it: a file nobody computed, or an edited one, says nothing (M9.27) + f["kinds"]["eval"] = [a for a in f["kinds"]["eval"] if (a["ref"], a["sha"]) in evaluated] # a goal is one `mission goal derive` recorded (goal.derived, or the human's goal.approved, for # its content) and it is closed by its goal.met record, as `mission evaluate` reads them f["kinds"]["goal"] = [dict(a, met=any(t >= max(born[(a["ref"], a["sha"])]) for t in met.get(a["ref"], []))) @@ -402,13 +407,7 @@ def has(f, event, a): def goal_met(f, e): - if "goal_met" in e["doc"]: - return e["doc"]["goal_met"] is True - for ev in f["events"]: - d = ev["data"] - if ev.get("event") == "eval.completed" and d.get("eval_id") == e["id"]: - return d.get("goal_met") is True - return False + return e["doc"].get("goal_met") is True # its record covers this content def latest(f, kind): diff --git a/scripts/test/mission-evaluate.test.py b/scripts/test/mission-evaluate.test.py index 33e552b0..5f091e1d 100644 --- a/scripts/test/mission-evaluate.test.py +++ b/scripts/test/mission-evaluate.test.py @@ -60,6 +60,8 @@ def made(r): assert e1["gaps"][0]["distance"] == 0.8 and e1["earned"] == [] ec = p.events("eval.completed")[-1]["data"] assert ec["gaps"] == 2 and ec["eval_id"] == e1["eval_id"] and ec["sha256"] == e1["sha256"] == M.digest(e1), ec +rec = M.newest(p.dir, "eval.completed", M.rel(p.dir, M.path_of(p.dir, "eval", e1["eval_id"]))) +assert rec and rec["role"] == "evaluator" and rec["data"]["sha256"] == e1["sha256"], rec # a ledger row (M9.27) p.app(seconds_to_first_task=11.0, working_steps=["open", "add"], tasks_shown=0) # slower: j2's ok10 passed at baseline s2 = made(p.run("assess")) e2 = made(p.run("evaluate", s2["state_id"])) diff --git a/scripts/test/mission-tick.test.py b/scripts/test/mission-tick.test.py index 7fef7f11..f8c521c2 100755 --- a/scripts/test/mission-tick.test.py +++ b/scripts/test/mission-tick.test.py @@ -101,6 +101,10 @@ def art(self, kind, status, hours, record=True, **fields): with self.clock(hours): M.record(self.dir, "goal.derived", self.ref(kind, aid), "mission-planner", goal_id=aid, sha256=M.digest(doc)) + if kind == "eval" and record: # as `mission evaluate` records it + with self.clock(hours): + M.record(self.dir, "eval.completed", self.ref(kind, aid), "evaluator", eval_id=aid, + sha256=M.digest(doc), goal_met=fields.get("goal_met")) M.save(M.path_of(self.dir, kind, aid), doc) return aid, doc @@ -1195,4 +1199,49 @@ def lifts(p): assert d["action"] != "STOP_BUDGET", d # the raised cap resumes the loop ok("a hit cap is a ledger row for the mission's content: a fresh checkout stays stopped until the cap is raised") +# 31) a gap list counts only with the eval.completed ledger record of its content (M9.27), as `evaluate check` +# and `goal derive` read it: an eval file nobody computed, or one edited after it was recorded, says nothing +# (not even "goal met"), and a fresh checkout keeps the gap lists `mission evaluate` wrote, so the loop and +# the goal commands decide the same there +p = Project().init() +cleared(p) +sid = json.load(open(p.mi("assess").stdout.strip()))["state_id"] +bid = TICK.B.current_id(p.dir) +fake, fdoc = p.art("eval", "recorded", later(p), record=False, state_id=sid, baseline_id=bid, goal_id=None, gaps=[], + earned=[], regressions=0, metrics=[], rival_refs=[], goal_met=True) +M.seal(fdoc) +M.save(M.path_of(p.dir, "eval", fake), fdoc) # sealed and well-formed, but never computed +expect(p.tick(later(p), "--peek"), "EVALUATE", 0, "no eval yet") # not RESEARCH: nobody computed it +r = p.mi("evaluate", "check", fake) +assert r.returncode == 2 and "no eval.completed record for this content" in r.stderr, r.stderr +os.remove(M.path_of(p.dir, "eval", fake)) +r = p.mi("evaluate") +assert r.returncode == 0, r.stderr +eid = json.load(open(r.stdout.strip()))["eval_id"] +assert [x["data"]["eval_id"] for x in M.ledger_rows(p.dir)[0] if x["event"] == "eval.completed"] == [eid] +expect(p.tick(later(p), "--peek"), "DERIVE_GOAL", 0, eid) +real = p.load("eval", eid) +M.save(M.path_of(p.dir, "eval", eid), dict(real, gaps=[], goal_met=True)) # edited after it was recorded +expect(p.tick(later(p), "--peek"), "EVALUATE", 0, "no eval yet") +M.save(M.path_of(p.dir, "eval", eid), real) +shutil.rmtree(os.path.join(p.dir, ".aladdin")) # a fresh checkout: no run log +expect(p.tick(later(p)), "DERIVE_GOAL", 0, eid) +assert p.mi("evaluate", "check").returncode == 0 # the latest recorded one, from the ledger +r = p.mi("goal", "derive") +assert r.returncode == 0, r.stderr # goal derive reads the same record +gid = json.load(open(r.stdout.strip()))["goal_id"] +p.review(p.ref("goal", gid), p.load("goal", gid), "clear") +assert p.mi("goal", "intents", gid).returncode == 0 +p.app(**PASSING) +assert p.mi("assess").returncode == 0 +r = p.mi("evaluate") +e2 = json.load(open(r.stdout.strip()))["eval_id"] +assert p.load("eval", e2)["goal_id"] == gid and p.load("eval", e2)["goal_met"] is True +shutil.rmtree(os.path.join(p.dir, ".aladdin")) +expect(p.tick(later(p)), "EVALUATE", 0, "aloop mission goal close %s --eval %s" % (gid, e2)) +r = p.mi("goal", "close", gid, "--eval", e2) +assert r.returncode == 0, r.stderr # ordered by the ledger, not the run log +ok("a gap list counts only with its eval.completed ledger record: a file nobody computed or an edited one says " + "nothing, and on a fresh checkout the loop, `evaluate check`, `goal derive` and `goal close` read the same records") + print("mission-tick: %d checks passed" % PASS[0]) From 5eb534d62e6067f3793ac7d3d17f61069754eba5 Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Tue, 20 Oct 2026 10:09:07 +0000 Subject: [PATCH 2/2] Every reader takes the same newest intact eval, in ledger order (M9.27 review) Review findings, each a test that failed before this: - goal derive/options took the newest recorded eval even when its file was edited, while tick and evaluate check skipped it; now all three read evaluate.evaluated (record of the content, schema, a seal that matches). - a re-stamped eval (status or sha256 field, outside the digest) was still trusted by tick; the seal must now match the content. - tick ordered evals by the id's clock, goal by the ledger and evaluate check by created_at; all now use the ledger's order. - journey and baseline evidence accepted an eval or state nobody computed. The recomputation half and tick checking a goal's own problems are new ROADMAP items M9.52 and M9.53. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Aw6CiQcdpzdzZZXKf8WbUM --- CHANGELOG.md | 2 +- docs/ROADMAP.md | 4 +- docs/TRACKING.md | 2 + plugin/mission/README.md | 3 +- plugin/mission/evaluate.py | 43 ++++++++++++++------ plugin/mission/goal.py | 8 +--- plugin/mission/journeys.py | 15 ++++++- plugin/mission/tick.py | 13 ++++--- scripts/test/mission-journeys.test.py | 5 +++ scripts/test/mission-tick.test.py | 56 +++++++++++++++++++++++---- 10 files changed, 115 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 213522db..b814a79e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,7 @@ tag in lockstep. Tag releases as `vMAJOR.MINOR.PATCH`. ### Added - 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. -- A mission's gap lists count only as `mission evaluate` computed them (ROADMAP §4.12, M9.27): `evaluate` records `eval.completed` in the committed ledger, and `evaluate check`, `goal derive`/`close` and `mission tick` count an eval only with that record of its content. An eval file written by hand, or edited after it was recorded, no longer sends the loop to `RESEARCH` as "goal met", and a fresh checkout derives and closes goals from the evals it committed. Test: `mission-tick` check 32. +- A mission's gap lists count only as `mission evaluate` computed them (ROADMAP §4.12, M9.27): `evaluate` records `eval.completed` in the committed ledger, and `mission tick`, `evaluate check` and `goal` take the newest eval whose content that record covers, with a matching seal, in the ledger's order. An eval file written by hand, or edited (or re-stamped) after it was recorded, no longer sends the loop to `RESEARCH` as "goal met" or makes `goal derive` refuse what tick handed out, a clock that is behind no longer reorders them, and a fresh checkout derives and closes goals from the evals it committed. An eval or state named as journey or baseline evidence needs its record too. Tests: `mission-tick` check 32, `mission-journeys`. - A mission's stop at a spend cap holds on a fresh checkout (ROADMAP §4.12, M9.24): the first `STOP_BUDGET` tick records a `mission.budget_exhausted` ledger row for the mission's content (once per content), and `mission tick` stops on it whatever the checkout's token ledger says, until a raised cap changes the content. - Lifting a mission block is the human's own words (ROADMAP §4.12, M9.51): `aloop mission tick --force --by` now asks (exit 3) for the human's typed `lift ` line, the code bound to this occurrence of that block, and records a `mission.lifted` ledger row, so `--by` alone, a lift only the run log has (or a replayed one), an old line or a line typed for an earlier block lift nothing, a lift of 3 failed goals reaches only those goals whatever `--now` says, and a fresh checkout keeps a lifted block lifted. `/aloop:mission` counts a lift among the typed grants it relays. A lift recorded before this (run data only) no longer counts. - The mission layer's six fixed roles (ROADMAP §4.12, M9.9): `market-researcher`, `product-tester`, `state-assessor`, `evaluator`, `mission-planner` and `ethics-reviewer`, each a persona with a four-case eval suite, a model route (the four that judge on the planning route, the two that measure on the worker route), hook matchers on Claude Code, Codex, OpenCode and dsh, and Codex/OpenCode agents and dsh presets from `aloop install` (which also renders the mission skill for OpenCode as `aloop-mission` once it ships). `plugin/mission/roles.json` names the paths each role writes. `gate-mission-scope` (PreToolUse) is the role path guard: a mission role never writes source, mission.json or another role's dir, never commits and never runs a human's approval; a builder never writes `docs/agents/mission/` or runs a writing `mission` command; the supervisor never hand-writes a role's artifact. No one hand-writes `docs/agents/mission/ledger.jsonl` or the captured prompts a grant reads (`/transcripts/`), runs a hook's `transcripts prompt|record|…`, or starts a host session (`claude -p`, `codex exec`, `opencode run`, `dsh `) from a tool call where a mission is set (its prompt would count as the human's words, M9.17), and no dispatched agent runs `mission baseline restore`, `events authority` or an `events emit` of a human event. `gate-mission-artifact` records what exists when a role starts and, at its stop, requires an artifact in its own paths that passes the core contract and its area's check, refuses a deleted artifact, a change to another role's or a ledger that no longer verifies, and records `artifact.created|updated` as provenance. A mission write never arms the sprint lock. The scope gate reads a Bash command as the shell would (`_shellread.py`: quotes, comments, line continuations, heredocs, wrappers such as `timeout` and `env`, `bash -c`, `eval`, a script run by an interpreter, variables and `$(mktemp)`). Each area's check runs once per artifact with its id or subject, an ethics hard line is the reviewer's finding, not a defect, and a derived goal whose only blocks are its pending ethics review waits on the Ethics Reviewer, not on the planner. Test: `mission-roles.test.py` (33 checks, with each role run through the real journeys, baseline, assess, evaluate and ethics, goal, research and judge areas), `mission-scope-bash.test.py` (225 commands), `opencode-plugin.test.mjs`. diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 376ad453..0e285d31 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -460,7 +460,7 @@ Each task flips only its own row here and in TRACKING.md. | M9.24 | The human's `mission tick --force --by` grant, the ethics reviews (`ethics.reviewed`/`ethics.blocked`, already `LEDGER_EVENTS`, still only emitted) and `mission.budget_exhausted` are ledger rows, not run data. Reason: found aligning M9.8 with the ledger and in its review, a fresh checkout loses them, so 3 failed goals block again, every review is asked again, and a hit spend cap starts from zero (`tick` fails closed on a committed hard review meanwhile) | M9.0, M9.4 | `plugin/bin/_mission.py` (`LEDGER_EVENTS`), `plugin/mission/{tick,ethics}.py`, their tests | yes | done. Ethics part: `ethics.reviewed` and `ethics.blocked` are ledger rows (`M.record`), and ethics reads `M.history` (the ledger's rows, plus the run-log events that are not ledger rows), so a clone keeps every review, hard line and held gap; an edited run-log copy of a row changes nothing, and a broken ledger makes every verdict `broken` (`mission-ethics.test.py` checks 12 and 13, `mission-e2e.test.py`). The `--force` part is done in M9.51 (a `mission.lifted` ledger row with the human's typed line), and the stop at a cap is a `mission.budget_exhausted` ledger row for the mission's content, once per content, so a clone stays stopped until the cap is raised (`mission-tick.test.py` check 31). The spend itself is still the checkout's token ledger | | M9.25 | A baseline binds the mission's direction (statement, mode, constraints), not its whole content. Reason: found in M9.8's budget test, raising a budget cap re-approves the mission and so asks for a new baseline version, though nothing about "best" changed | M9.2 | `plugin/mission/baseline.py`, `mission-baseline.test.py` | yes | done: `mission-baseline.test.py` check 5; a baseline and its state carry `direction_sha256` = `M.direction(mission)` (`mission_id`, `statement`, `mode`, `constraints`); a new budget, deadline or cadence keeps the baseline once the mission is approved again, a new direction asks for a new version, and an unapproved mission decides nothing | | M9.26 | A goal's sprint history (intent → goal, sprint planned and closed) is read from committed records. Reason: found in M9.8's review, `intent.received`, `plan.created` and `sprints.json` are run data, so a fresh checkout re-sprints an active goal whose intents were already sprinted | M9.8, M9.11 | `plugin/mission/tick.py`, the sprint-close writer, `mission-tick.test.py` | yes | open | -| M9.27 | `tick` trusts an eval only when `evaluate check` would (a record, or a recomputed gap list). Reason: found in M9.8's review, an eval file nobody computed can say `goal_met` and send the loop to `RESEARCH` instead of `DERIVE_GOAL` | M9.8, M9.10 | `plugin/mission/{tick,evaluate}.py`, their tests | yes | done: `mission-tick.test.py` check 32; `mission evaluate` records `eval.completed` in the ledger (`LEDGER_EVENTS`), `evaluate check` and `tick` count a gap list only with that record of its content, and `goal derive`/`close` read the same record and its ledger order, so a fresh checkout derives and closes from the evals it committed | +| M9.27 | `tick` trusts an eval only when `evaluate check` would (a record, or a recomputed gap list). Reason: found in M9.8's review, an eval file nobody computed can say `goal_met` and send the loop to `RESEARCH` instead of `DERIVE_GOAL` | M9.8, M9.10 | `plugin/mission/{tick,evaluate}.py`, their tests | yes | done for the record, shape and seal (the recomputation is M9.52): `mission-tick.test.py` check 32, `mission-journeys.test.py`. `mission evaluate` records `eval.completed` in the ledger (`LEDGER_EVENTS`); `evaluate.evaluated` (the record of its content, its schema, a seal that matches it) in the ledger's order is where `tick`, `evaluate check` and `goal` take the latest from, so an uncomputed, edited or re-stamped eval says nothing to any of them and a clock that is behind does not reorder them; `goal derive`/`close` read the record and its ledger order, so a fresh checkout derives and closes from the evals it committed; an eval or state named as journey or baseline evidence needs its record. No migration: the mission layer is unreleased, so an eval written before this has no record and is evaluated again | | M9.28 | `tick` drives the goal commands (M9.11): a goal counts only with its `goal.derived`/`goal.approved` record and closes by `goal.met`; handouts name `goal derive`, `options` (spoon-fed), `intents`, `next` and `close`; an eval narrowed to a closed goal asks for a whole-mission eval. Reason: found when M9.11 landed, `tick` read goal files and their status, so a goal nobody derived steered the loop and a met goal was never closed | M9.8, M9.11 | `plugin/mission/tick.py`, `plugin/skills/mission/SKILL.md`, `mission-tick.test.py` | yes | done: `mission-tick.test.py` (29 checks; a real goal run on the real clock: derive → review → intents → next and a sprint per intent → narrowed eval → close → whole-mission eval → `RESEARCH`) | | M9.29 | A goal that crosses a hard line stops being the active goal (`evaluate.active_goal` skips it, or a recorded retirement). Reason: found wiring M9.28, `evaluate` keeps narrowing to a hard-lined goal and `goal derive` refuses a narrowed eval, so the mission deadlocks (`tick` hands it to the human meanwhile) | M9.10, M9.11 | `plugin/mission/{evaluate,goal}.py`, their tests | yes | open | | M9.40 | Artifact provenance in the loop: `mission tick` and each area's check accept a role's artifact only with the `artifact.created\|updated` event `gate-mission-artifact` records for it (role, agent id, sha256). Reason: found while building M9.9, the path guards stop a tool's write, but an area command the supervisor runs itself can still write a role's artifact | M9.8, M9.9 | `plugin/mission/tick.py` (M9.8's), its test | after its needs | open | @@ -469,6 +469,8 @@ Each task flips only its own row here and in TRACKING.md. | M9.43 | A goal binds the mission's direction and its current approval, like a baseline (M9.25), not the whole mission sha256. Reason: found reviewing M9.25, raising the budget cap during an active goal keeps the baseline but voids the goal (`goal check`: "the mission changed"), so `goal next` refuses while `tick` keeps handing out SPRINT until it blocks and asks for `--force` | M9.11, M9.25 | `plugin/mission/goal.py`, `plugin/mission/tick.py`, `mission-goal.test.py` | yes | open | | M9.50 | A goal whose intents were all sprinted and whose eval still lists gaps gets a next step (re-plan the open gaps as intents, or a recorded retirement so a new goal can be derived). Reason: found wiring M9.28, `goal close` refuses an unmet goal and `goal next` has no intent left, so the loop can only hand it to the human | M9.11 | `plugin/mission/goal.py`, `mission-goal.test.py`, then `tick.py` | yes | open | | M9.51 | Lifting a block (`mission tick --force --by`) is the human's own words: it asks (exit 3) for their typed `lift ` line, the code bound to this occurrence of the block (its key, the lifts of it so far, and the handout that tripped it or the newest failed goal), and records a `mission.lifted` ledger row (`APPROVAL_EVENTS`, `GRANT_VERBS`); a repeat restarts only at that row's own run-log event (first copy), and the 3-failed-goals count only up to the goals the human lifted; `/aloop:mission` counts a lift among the typed grants. Reason: found after M9.17 merged, `--by` alone still lifted a block and the lift was run data, so a fresh checkout blocked again (M9.24's first part) | M9.8, M9.12, M9.17 | `plugin/mission/tick.py`, `plugin/bin/_mission.py`, `plugin/bin/_events.py`, `plugin/skills/mission/`, `scripts/test/mission-{tick,skill}.test.py` | yes | done: `mission-tick.test.py` check 30 (`--by` alone, a run-log-only or replayed lift, a negated line, another code, an old line and a line typed for an earlier block lift nothing; a far `--now` lifts no later goals; a fresh checkout keeps a lift), `mission-skill.test.py` check 8 | +| M9.52 | `tick` reads a gap list only when it still recomputes from its inputs, as `evaluate check` does (an intact eval that a changed `compute`, an edited journey or goal no longer reproduces asks for `EVALUATE`). Reason: found in M9.27's review, `tick` reads the record, shape and seal but not the recomputation (the tick test's synthetic evals cannot recompute), so after an upgrade that changes `compute` `goal derive` refuses while `tick` hands out `DERIVE_GOAL` until it blocks | M9.27 | `plugin/mission/tick.py`, `mission-tick.test.py` (real evals in its synthetic sections) | yes | open | +| M9.53 | `tick` hands out a goal's commands (`PLAN_INTENTS`, `SPRINT`, its close) only when `goal check` passes, else names the goal's problem. Reason: found in M9.27's review, a goal whose source eval changed or is gone (or one derived before evals were ledger records) gets `PLAN_INTENTS` 3 times while `goal intents` refuses, then `BLOCKED` with no cause named (M9.43 is one case of it) | M9.11, M9.28 | `plugin/mission/tick.py`, `mission-tick.test.py` | yes | open | **Parallel tracks** (one thread each, from M9.0 on master): (1) Research + Judges, M9.1 + M9.5; (2) Baseline + Journeys → Assess/Evaluate, M9.2 + M9.3 → M9.10; (3) Ethics + Principles → Goals, diff --git a/docs/TRACKING.md b/docs/TRACKING.md index 6e65e919..506760a6 100644 --- a/docs/TRACKING.md +++ b/docs/TRACKING.md @@ -92,3 +92,5 @@ Status of every requirement in [ROADMAP.md](ROADMAP.md), in the four states §8 | M9.43 | A goal binds the mission's direction, not its budget | NOT_IMPLEMENTED | §4.12 | | M9.50 | A goal sprinted with gaps still open gets a next step | NOT_IMPLEMENTED | §4.12 | | M9.51 | Lifting a mission block is the human's typed line, kept in the ledger | IMPLEMENTED_TESTED | `scripts/test/mission-tick.test.py` | +| M9.52 | The mission loop reads a gap list only when it still recomputes | NOT_IMPLEMENTED | §4.12 | +| M9.53 | The mission loop hands out a goal's commands only when `goal check` passes | NOT_IMPLEMENTED | §4.12 | diff --git a/plugin/mission/README.md b/plugin/mission/README.md index c288d829..52438d4d 100644 --- a/plugin/mission/README.md +++ b/plugin/mission/README.md @@ -107,7 +107,8 @@ A gate checks structure and evidence, never whether a judgment is right. gaps, earned, metrics}`; each gap is `{gap_id: "#", journey_id, criterion_id, kind: regression|open|unscored, now, baseline, target, distance}`, regressions first, then by distance. `eval.completed` is a ledger record carrying `eval_id` and `sha256`: a gap list - counts (for `evaluate check`, `goal` and `tick`) only with the record of its content. Every input is the content its + counts (for `evaluate check`, `goal` and `tick`) only with the record of its content and a seal that + matches it, and the newest is the newest by the ledger's order. Every input is the content its record covers: the state a `state.assessed` ledger record (only `mission assess` measures), the baseline a confirmation, each journey the content the baseline froze, and the goal a `goal.derived` or `goal.approved` record (the newest such goal with no later `goal.met` record is the active one; a diff --git a/plugin/mission/evaluate.py b/plugin/mission/evaluate.py index cc3d7f7d..7b5627e7 100644 --- a/plugin/mission/evaluate.py +++ b/plugin/mission/evaluate.py @@ -192,28 +192,49 @@ def recorded(cwd, path, doc): return rec if rec and rec["data"].get("sha256") == M.digest(doc) else None -def latest(cwd): - """The newest gap list `mission evaluate` recorded (a file with no record is not one).""" - rows = [(p, d) for p, d in M.artifacts(cwd, KIND) if recorded(cwd, p, d)] - return max(rows, key=lambda pd: (pd[1].get("created_at", ""), pd[0])) if rows else (None, None) - - -def problems(cwd, path, doc): +def intact(cwd, path, doc): + """Why a gap list is not what `mission evaluate` wrote: its shape, its seal (`status` and `sha256` + are outside the digest, so the seal must match it) and the eval.completed record of its content. + `mission tick` reads exactly these (ROADMAP M9.27); `problems` adds the recomputation.""" out = M.problems(doc, KIND, path) if out: return out - out = follows(cwd, doc) + if doc.get("sha256") != M.digest(doc): + out.append("a gap list is sealed when it is written (its sha256 is not its content's)") if not recorded(cwd, path, doc): out.append("eval %s has no eval.completed record for this content: only `mission evaluate` evaluates" % doc["eval_id"]) return out +def evaluated(cwd): + """(path, doc) of every intact gap list in the ledger's order (oldest first): the order the + evaluations were made, whatever a machine's clock said. `mission tick`, `goal` and `evaluate + check` read the latest from here.""" + at = {} + for i, r in enumerate(M.records(cwd, "eval.completed")): + at[r["data"].get("subject")] = i # its newest record (`recorded` reads that one) + rows = [(at.get(M.rel(cwd, path)), path, doc) for path, doc in M.artifacts(cwd, KIND)] + return [(p, d) for i, p, d in sorted((x for x in rows if x[0] is not None), key=lambda x: x[0]) + if not intact(cwd, p, d)] + + +def latest(cwd): + """The newest intact gap list (a file with no record, or edited since, is not one).""" + rows = evaluated(cwd) + return rows[-1] if rows else (None, None) + + +def problems(cwd, path, doc): + out = intact(cwd, path, doc) + if M.malformed(out): + return out + return follows(cwd, doc) + out + + def follows(cwd, doc): - """A well-formed gap list's problems against its inputs: sealed, and recomputed from them.""" + """A well-formed gap list's problems against its inputs: it is recomputed from them.""" out = [] - if "sha256" not in doc: - out.append("a gap list is sealed when it is written") spath = M.path_of(cwd, "state", doc["state_id"]) state, _ = M.load(spath) if not isinstance(state, dict): diff --git a/plugin/mission/goal.py b/plugin/mission/goal.py index dcf661a5..f5331a8a 100644 --- a/plugin/mission/goal.py +++ b/plugin/mission/goal.py @@ -93,12 +93,8 @@ def eval_record(cwd, eid): def latest_eval(cwd): - """The id of the latest recorded eval (ledger order), or None.""" - ids = [r["data"].get("eval_id") for r in M.records(cwd, "eval.completed")] - for eid in reversed(ids): - if eid and os.path.exists(M.path_of(cwd, "eval", eid)): - return eid - return None + """The id of the newest intact eval (ledger order, as `mission tick` and `evaluate check` read it), or None.""" + return (EV.latest(cwd)[1] or {}).get("eval_id") def gap_of(cwd, g): diff --git a/plugin/mission/journeys.py b/plugin/mission/journeys.py index 94e9e6b0..2f798a2f 100644 --- a/plugin/mission/journeys.py +++ b/plugin/mission/journeys.py @@ -92,15 +92,26 @@ def ref_problems(cwd, refs, where, what="source ref"): EVIDENCE_KIND = {"evl": "eval", "sta": "state", "rsr": "research"} +# an eval or a state is evidence only as its command recorded it (a file nobody computed is not) +EVIDENCE_RECORD = {"eval": "eval.completed", "state": "state.assessed"} + + def evidence_problems(cwd, refs, where): """Evidence is a research claim (#) or an eval, state or research id - that exists: a placeholder string is not evidence.""" + that exists (an eval or state with the ledger record of its content): a placeholder string is + not evidence.""" out = [] for r in refs or []: m = EVIDENCE.match(str(r)) if m: - if not isinstance(M.load(M.path_of(cwd, EVIDENCE_KIND[m.group(1)], r))[0], dict): + kind = EVIDENCE_KIND[m.group(1)] + path = M.path_of(cwd, kind, r) + doc = M.load(path)[0] + rec = M.newest(cwd, EVIDENCE_RECORD[kind], M.rel(cwd, path)) if kind in EVIDENCE_RECORD else None + if not isinstance(doc, dict): out.append("%s %s does not exist" % (where, r)) + elif kind in EVIDENCE_RECORD and (rec or {}).get("data", {}).get("sha256") != M.digest(doc): + out.append("%s %s has no %s record for this content" % (where, r, EVIDENCE_RECORD[kind])) elif REF.match(str(r)): out += ref_problems(cwd, [r], where, "evidence") else: diff --git a/plugin/mission/tick.py b/plugin/mission/tick.py index 663b4188..a0abf2bf 100644 --- a/plugin/mission/tick.py +++ b/plugin/mission/tick.py @@ -85,6 +85,7 @@ import _paths # noqa: E402 import baseline as B # noqa: E402 import ethics as E # noqa: E402 +import evaluate as EV # noqa: E402 import journeys as J # noqa: E402 NO_ARGS = True # `mission tick` with no arguments runs (plugin/bin/mission run_area) @@ -291,14 +292,12 @@ def rel(p): # decides, so restoring content an older approval covered is a rollback, not approved raw, _ = M.ledger_rows(cwd) rows = sorted(raw, key=lambda r: r["ts"]) # the core's order: a union merge interleaves branches - assessed, evaluated, born, met = {}, set(), {}, {} + assessed, born, met = {}, {}, {} f["lifted"], f["lifts"], f["stops"] = {}, {}, {} for r in rows: name, d = r["event"], r["data"] if name == "state.assessed": assessed[d.get("subject")] = d.get("sha256") - if name == "eval.completed": - evaluated.add((d.get("subject"), d.get("sha256"))) if name in ("goal.derived", "goal.approved"): born.setdefault((d.get("subject"), d.get("sha256")), []).append(r["ts"]) if name == "goal.met": @@ -320,9 +319,11 @@ def rel(p): f["ledger_head"] = raw[-1]["hash"] if raw else "" # a state report counts only with the state.assessed record of its content (mission assess) f["kinds"]["state"] = [a for a in f["kinds"]["state"] if assessed.get(a["ref"]) == a["sha"]] - # and a gap list only with the eval.completed record of its content (mission evaluate), as `evaluate - # check` and `goal derive` read it: a file nobody computed, or an edited one, says nothing (M9.27) - f["kinds"]["eval"] = [a for a in f["kinds"]["eval"] if (a["ref"], a["sha"]) in evaluated] + # and a gap list only intact (the eval.completed record of its content, its shape and seal), in the + # ledger's order, as `evaluate check` and `goal` read it: an uncomputed or edited one says nothing (M9.27) + order = [M.rel(cwd, path) for path, _ in EV.evaluated(cwd)] + evals = {a["ref"]: a for a in f["kinds"]["eval"]} + f["kinds"]["eval"] = [evals[r] for r in order if r in evals] # a goal is one `mission goal derive` recorded (goal.derived, or the human's goal.approved, for # its content) and it is closed by its goal.met record, as `mission evaluate` reads them f["kinds"]["goal"] = [dict(a, met=any(t >= max(born[(a["ref"], a["sha"])]) for t in met.get(a["ref"], []))) diff --git a/scripts/test/mission-journeys.test.py b/scripts/test/mission-journeys.test.py index 9b6fd524..f6eb3337 100644 --- a/scripts/test/mission-journeys.test.py +++ b/scripts/test/mission-journeys.test.py @@ -126,6 +126,11 @@ def bad(**over): assert "never retired without evidence" in p.run("journeys", "retire", jid, "--replaced-by", stricter).stderr r = p.run("journeys", "retire", jid, "--replaced-by", stricter, "--evidence", "x") assert r.returncode == 2 and "must be # or an eval, state or research id" in r.stderr, r.stderr +fake = "evl_" + "a" * 20 # an eval file nobody computed (M9.27) +M.save(M.path_of(p.dir, "eval", fake), {"eval_id": fake, "goal_met": True}) +r = p.run("journeys", "retire", jid, "--replaced-by", stricter, "--evidence", fake) +assert r.returncode == 2 and "has no eval.completed record for this content" in r.stderr, r.stderr +os.remove(M.path_of(p.dir, "eval", fake)) r = p.run("journeys", "retire", jid, "--replaced-by", jid, "--evidence", rid + "#c2") assert r.returncode == 2 and "cannot replace itself" in r.stderr, r.stderr r = p.run("journeys", "retire", jid, "--replaced-by", looser, "--evidence", rid + "#c2") diff --git a/scripts/test/mission-tick.test.py b/scripts/test/mission-tick.test.py index f8c521c2..c3768297 100755 --- a/scripts/test/mission-tick.test.py +++ b/scripts/test/mission-tick.test.py @@ -101,10 +101,14 @@ def art(self, kind, status, hours, record=True, **fields): with self.clock(hours): M.record(self.dir, "goal.derived", self.ref(kind, aid), "mission-planner", goal_id=aid, sha256=M.digest(doc)) - if kind == "eval" and record: # as `mission evaluate` records it + if kind == "eval" and record: # well-formed and sealed, as `mission evaluate` records it + doc = dict({"state_id": "sta_" + "0" * 20, "baseline_id": TICK.B.current_id(self.dir) or "bln_" + "0" * 20, + "goal_id": None, "gaps": [], "earned": [], "regressions": 0, "metrics": [], "rival_refs": []}, + **doc) + M.seal(doc) with self.clock(hours): M.record(self.dir, "eval.completed", self.ref(kind, aid), "evaluator", eval_id=aid, - sha256=M.digest(doc), goal_met=fields.get("goal_met")) + sha256=doc["sha256"], goal_met=fields.get("goal_met")) M.save(M.path_of(self.dir, kind, aid), doc) return aid, doc @@ -1199,10 +1203,11 @@ def lifts(p): assert d["action"] != "STOP_BUDGET", d # the raised cap resumes the loop ok("a hit cap is a ledger row for the mission's content: a fresh checkout stays stopped until the cap is raised") -# 31) a gap list counts only with the eval.completed ledger record of its content (M9.27), as `evaluate check` -# and `goal derive` read it: an eval file nobody computed, or one edited after it was recorded, says nothing -# (not even "goal met"), and a fresh checkout keeps the gap lists `mission evaluate` wrote, so the loop and -# the goal commands decide the same there +# 31) a gap list counts only intact, as `evaluate check` and `goal` read it (M9.27): the eval.completed ledger +# record of its content, its shape and its seal. An eval file nobody computed, or one edited after it was +# recorded, says nothing (not even "goal met"); every reader takes the newest intact one by the ledger's +# order (not a machine's clock); and a fresh checkout keeps the gap lists `mission evaluate` wrote, so the +# loop and the goal commands decide the same there p = Project().init() cleared(p) sid = json.load(open(p.mi("assess").stdout.strip()))["state_id"] @@ -1220,6 +1225,19 @@ def lifts(p): eid = json.load(open(r.stdout.strip()))["eval_id"] assert [x["data"]["eval_id"] for x in M.ledger_rows(p.dir)[0] if x["event"] == "eval.completed"] == [eid] expect(p.tick(later(p), "--peek"), "DERIVE_GOAL", 0, eid) +r = p.mi("evaluate") # a second gap list of the same state +eb = json.load(open(r.stdout.strip()))["eval_id"] +expect(p.tick(later(p), "--peek"), "DERIVE_GOAL", 0, eb) +newer = p.load("eval", eb) +for bad in (dict(newer, gaps=[], goal_met=True), dict(newer, status="bogus"), dict(newer, sha256="0" * 64)): + M.save(M.path_of(p.dir, "eval", eb), bad) # edited, or only its unhashed fields + d = p.tick(later(p), "--peek") + expect(d, "DERIVE_GOAL", 0, eid) # the newest intact one, for every reader + assert eb not in d["reason"], d["reason"] + assert json.loads(p.mi("evaluate", "check", "--json").stdout)["eval_id"] == eid + r = p.mi("goal", "options") + assert r.returncode == 0, r.stderr # not "eb is not the content recorded" +os.remove(M.path_of(p.dir, "eval", eb)) real = p.load("eval", eid) M.save(M.path_of(p.dir, "eval", eid), dict(real, gaps=[], goal_met=True)) # edited after it was recorded expect(p.tick(later(p), "--peek"), "EVALUATE", 0, "no eval yet") @@ -1241,7 +1259,29 @@ def lifts(p): expect(p.tick(later(p)), "EVALUATE", 0, "aloop mission goal close %s --eval %s" % (gid, e2)) r = p.mi("goal", "close", gid, "--eval", e2) assert r.returncode == 0, r.stderr # ordered by the ledger, not the run log -ok("a gap list counts only with its eval.completed ledger record: a file nobody computed or an edited one says " - "nothing, and on a fresh checkout the loop, `evaluate check`, `goal derive` and `goal close` read the same records") +k = Project().init() # two machines, one clock behind +cleared(k) +ks = json.load(open(k.mi("assess").stdout.strip())) +time.sleep(2.1) +ka = json.load(open(k.mi("evaluate").stdout.strip()))["eval_id"] +real_time, real_now, here = time.time, M.now, os.getcwd() +skew = real_time() - (TICK.ms_doc(ks, "state") / 1000.0 + 0.6) # its clock: just after the state +time.time = lambda: real_time() - skew # so its id and stamp sort before ka's +M.now = lambda: time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(time.time())) +os.chdir(k.dir) +try: + with contextlib.redirect_stdout(io.StringIO()) as out, contextlib.redirect_stderr(io.StringIO()): + assert TICK.cli().main(["evaluate"]) == 0 +finally: + os.chdir(here) + time.time, M.now = real_time, real_now +kb = json.load(open(out.getvalue().strip().splitlines()[-1]))["eval_id"] +assert TICK.ms_doc(k.load("eval", kb), "eval") < TICK.ms_doc(k.load("eval", ka), "eval") +assert k.load("eval", kb)["created_at"] < k.load("eval", ka)["created_at"] +expect(k.tick(later(k), "--peek"), "DERIVE_GOAL", 0, kb) # the ledger's newest, not the clock's +assert json.loads(k.mi("evaluate", "check", "--json").stdout)["eval_id"] == kb +ok("a gap list counts only intact (its eval.completed ledger record, its shape and seal): a file nobody computed " + "or an edited one says nothing, and the loop, `evaluate check` and `goal` take the newest intact one by the " + "ledger's order; on a fresh checkout they, `goal derive` and `goal close` read the same records") print("mission-tick: %d checks passed" % PASS[0])