Skip to content

Goal mode: G0–G5 (schema, driver, proposer, backend, human door, live pilot) - #38

Merged
taojiang9914 merged 40 commits into
masterfrom
exp/goal-mode
Dec 3, 2026
Merged

taojiang9914 merged 40 commits into
masterfrom
exp/goal-mode

Conversation

@taojiang9914

Copy link
Copy Markdown
Collaborator

What this adds

Goal mode: a deterministic loop that proposes, triages, approves, runs,
evaluates and records changes under a goal, a budget and a kill ledger.

Milestone What it is
G0 Strict goal schema and validator (goal_schema.py)
G1 Deterministic goal driver: phases, two approvals per round, Round 0 baseline, budget, kill ledger, crash resume
G2 Read-only proposer and evaluator behind strict JSON schemas (goal_propose.py)
G3 The goal backend over the existing front change path (goal_backend.py)
G4 The human door: front goal start/status/approve/reject/resume/stop/log (front_goal.py)
G5 The live pilot lane, installer, live tests, runbook and report

Review and evidence

  • Six gates (G0–G5), each reviewed by the antigravity project; G5 signed off
    with 0 blockers and 0 should-fix.
  • Full suite: 820 passed, 20 skipped.
  • Live pilot: the goal fixed three bugs in one file and passed its test in
    Round 1 (157,754 tokens, 2 jobs, 3.4 min, $0.00).
  • Manual human-TTY smoke check passed: real terminal approvals, engine
    approval, spawned driver, goal completed, replay refused.
  • Merge conflict resolved in opencode_cc_mem/softwares/bin/magnolia
    (both MAG_OC_BIN from master and MAG_PIN from the branch are kept).

Report

projects/xiulian/docs/goal-mode-g5-report-2026-12-02.md (in the data tree,
not in this repo) and the plan goal-mode-plan-2026-11-30.md.

Open decision after merge

Whether to keep the local merge commit or let this PR create one. The branch
is clean and tested; the terms CI will run on this PR.

router_runner/change_tools.py, command check: the gate of the make_change stage. It parses the worker patch as a git-style unified diff (byte exact), refuses every path that is not an approved target or that defines the project, checks the base hash of every target, applies the patch in memory, and runs the verify command in a temporary copy of the targets inside the run directory. On success it writes reports/apply-plan.json. Exit codes follow plan A.9. The copy is removed on pass, fail, timeout and stop. The verify command gets no credential variable and its logs are redacted.

Request rule (M3-3 gaps found while building the gate): a target may not go through a symlink, and the clean-path rule now checks the raw text, where pathlib used to hide a dot in the middle of a path.

bounded_change: stage_inputs copies the two gate inputs into the run directory; MAGNOLIA_CHANGE_PACK names a pack copy for tests.

Tests: tests/test_change_tools.py (real gate process, real git diff). 27 mutation checks recorded in projects/xiulian/runs/2026-11-27_front-agent-3b_m3/mutation-part2.txt.
… part 3)

campaign_runner/factory.py: build_runner is the one code path for the command line and for task packs. The worker environment is pinned to the project of the campaign.

BoundedChangeTaskPack (router_runner/taskpacks.py) with its manifest and allowlist entry. run() renders the campaign again from the request stored in the trigger and refuses when the scope is not the approved scope (P3). One campaign directory per Work Item. The start approval and the confirm stage name the Work Item, the mandate and the approval hash. A wait for a human halts the campaign. reconcile() gives one pass after a crash and never continues.

ControlEngine: a stopped Work Item stays stopped when its attempt ends (P7); request_work accepts an id minted by the caller; execute() hands the trigger row to the adapter.

Fixes found on the way: the rendered core-hour cap was zero, which halted every change campaign before its first stage. The gate now refuses a key in a patch line (P11).

Tests: tests/test_bounded_change_adapter.py, tests/test_campaign_factory.py. 22 mutation checks recorded in projects/xiulian/runs/2026-11-27_front-agent-3b_m3/mutation-part3.txt.
router_runner/front.py: change submit, approve, run, status, stop and report (plan A.1, A.7, A.8). submit validates the request, renders the campaign under a Work Item id that it mints, and asks for an approval; with a thread, the newest reply goes into the brief and its hash into the scope (H7). approve has the same terminal guard as front approve. run starts the detached executor (agentd execute) and returns at once. report posts the end of the job into the thread, once per job.

change stop: the Work Item is stopped first. The campaign is then asked to stop, so that the executor stops its own worker and keeps its receipt; an executor that ignores the halt is stopped the hard way; an executor that was still making its campaign is ended. A directory counts as a campaign only once its state file is there.

change_request: targets and read_only are sorted and unique, as the scope string of plan A.2 requires.

front-desk skill: the change procedure. The M1 text that said change jobs arrive in M3 is replaced.

Tests: tests/test_front_change.py (M3-34 to M3-41, M3-48 to M3-52, and the stop window tests that hold the executor still with SIGSTOP). tests/change_worker.py holds the worker doubles for the detached executor. 17 mutation checks recorded in projects/xiulian/runs/2026-11-27_front-agent-3b_m3/mutation-deliverable7.txt.
…-v4.1-flash (human decision 2026-11-27)

The worker model in the pack descriptor changes from deepseek/deepseek-flash (direct DeepSeek API) to opencode-go/deepseek-v4.1-flash (OpenCode Go plan). Same model; the job now draws on the Go subscription quota. The renderer puts the model into each campaign protocol, so the human approval covers it.

Ping before use, through the pinned worker binary and the worker database: exit 0, final text OK, session ses_de1f48579ffenlQLrVLvJppPmC, 7315 input and 3 output tokens, cost 0.0. Evidence: projects/xiulian/runs/2026-11-27_front-agent-3b_m3/ping-opencode-go/.
…ontrol protocol

The test submits a change of a scratch project through the front, approves it, runs the detached executor with the real worker on the opencode-go model, and asserts: the job completes, the patch and the report exist, the original file and control/protocol.json keep their hashes, the worker event file holds a refused direct write for each of the two files, the tree outside the run is unchanged, and the tokens are recorded.

First live run (attempt 1) found a blocker, see projects/xiulian/runs/2026-11-27_front-agent-3b_m3/live-m3-33/attempt-1-blocked-reads/: OpenCode denies external_directory for the campaign-worker agent, so the worker cannot read the project files. It guessed the fixed value and the gate refused it. The test itself is correct; the worker environment needs a decision.
…ectory

The worker runs with cwd = the run directory, which is its OpenCode Location. The project folder is outside it, and on a linked git worktree OpenCode resolves the project to the main clone, so the project counts as an external directory. The campaign-worker rule 0 denies everything, including external_directory, so every read of the project failed (observed in the M3-33 live run 2026-11-27: Permission denied: external_directory).

Fix: allow external_directory for */opencode_cc_mem/projects/*. Reads of the project work again; edits stay limited to work/**; .env and campaign-service files stay denied; everything outside a project tree stays external and denied.

Test: tests/test_campaign_agent_permissions.py::test_worker_may_read_the_project_from_outside_its_run_directory.
The worker prompt gains one narrow exception: when the brief asks for a permission check, the worker makes the named write outside work/ anyway and records the refusal. The live test now names that check explicitly, keys the attempt scan on the target PATH (the patch text also names the file), and reads OPENCODE_DB for the worker database.

Passes (2026-11-27): 36.4 s, 62.4 s, 44.4 s; job completed each time, the patch and report exist, the original file and control/protocol.json keep their hashes, the worker attempted both forbidden writes and both were refused, the tree outside the run directory is unchanged, tokens recorded, cost 0.0. Evidence: projects/xiulian/runs/2026-11-27_front-agent-3b_m3/live-m3-33/.
M4 core: change_tools apply/rollback/confirm. apply reads the plan and the patch of the make campaign, checks the plan against the approved targets (M4-19), the patch hash, the base hash, the hard-link count and the symlink rule, backs up every target, writes each new file through a temporary file and os.replace, runs verify in the project, restores every target when a write or verify fails, and writes reports/apply-receipt.json (A.5). rollback restores the backups of an applied change and writes reports/rollback-receipt.json. confirm is the apply gate: exit 0 only when the receipt exists and every target has its after hash.

New apply-change-v0.1 pack (manifest, template, allowlist) and ApplyChangeTaskPack: refuses a change from another project, an incomplete change, or a missing plan; compares the approved scope; runs the fixed confirm_apply -> apply -> confirm campaign with no worker. Front commands come in the next commit.

Tests: M4-1 to M4-11, M4-15, M4-17, M4-19 in tests/test_change_apply.py; M4-12 to M4-14 and M4-16 through the real control engine and task pack. One existing M3 test now uses a truly unknown command because apply is a valid command. Full non-live suite: 645 passed, 13 skipped.
The apply-change pack now runs both modes. Apply: confirm_apply -> apply -> confirm. Rollback: confirm_rollback -> rollback -> confirm-rollback. The rollback restores every target from the backups of the apply and does not run the apply verify (that verify checks the applied state and would fail by design); its proof is the restored hash of every target, checked again by the confirm-rollback gate.

Front: change apply --lane P --change-work-item WI submits the apply as a second Work Item; change rollback --lane P --apply-work-item WI submits the rollback as a third. Both use the same approve and run steps and the same terminal guard. change approve/run/status/stop/report now accept both protocols; the run-directory marker follows the protocol. The front-desk skill documents the two steps.

Tests: 20 in tests/test_change_apply.py (M4-1 to M4-17, M4-19, M4-12 to M4-14 and M4-16 through the real engine), 4 new front tests (apply, rollback, two refusals). Mutation checks: 5 guards, 0 undetected, files byte-identical (mutation-m4.txt). Full non-live suite: 649 passed, 13 skipped. Live M4-18 is written but not yet run.
The M3 check gate writes the plan targets from the files the patch changes. A request can name extra targets that the patch leaves alone (they exist so the verify command can run). The apply tool required the plan targets to equal the approved targets, so the live M4-18 apply refused a correct plan: plan=[analysis/bug.py] approved=[analysis/__init__.py, analysis/bug.py, tests/test_bug.py]. The check is now a subset: every plan target must be in the approved targets (M4-19 still refuses agent.json), and the apply backs up and writes the changed targets only.

Live M4-18 after the fix: 1 passed in 25.8 s (make with the real worker, apply, project test passes on the real files, rollback, tree byte-identical). Final non-live suite: 649 passed, 13 skipped.
Executor: router_runner/change_executor.py holds a real flock on the lane, opens the engine once, calls engine.recover() once, and executes queued Work Items one at a time. The launcher starts one executor per lane beside the loops (kill switch MAGNOLIA_CHANGE_EXECUTOR=0). front change run hands the item to the lane executor when its lock is held; otherwise it starts a one-shot executor for that item (this replaces the detached agentd execute of M3).

Job stage: a request may name a job template (job id). The renderer copies the template from the pack and records its SHA-256 in the scope and in control/jobs/approved.json. load_job_plan refuses a template that changed after approval (JobIntegrityError -> waiting_human). The stage runs after make_change with retry infra_once; the supervisor waits between polls, cancels on stop/timeout/sibling failure, and records the job usage.

Tests: M5-1 to M5-3 in tests/test_change_executor.py (real processes, real lock); M5-4 to M5-9 in tests/test_bounded_change_jobs.py; M5-11 live local (0.8 s, job.txt=done); M5-12 live Slurm (job 11840169, COMPLETED 0:0, 1 s, compute08). Mutation checks: 5 guards (lock, queued-only filter, reconcile, template hash, stop cancel), 0 undetected, files byte-identical. Full non-live suite: 658 passed, 13 skipped.
Add router_runner/goal_schema.py: the goal file schema (allowed scope, goal-test argv and score argv, float metric, goal-test file set, five budget caps, read-only adapters, per-round approval, three kill counters), the 21-phase enum shared by the driver, the front and the tests, and validators for the state, the round record and the kill ledger.

Unknown fields are rejected at every level. Targets are existing regular files with clean paths. goal_test_files are expanded from recursive globs; the file set and one SHA-256 per file are snapshotted. Every project file in score_argv must be in goal_test_files and allowed.forbid. Scores are floats; NaN and infinity are rejected. kill.goal_test_failures is required and positive.

Tests: 25 cases for G0-1 to G0-11. Full suite: 683 passed, 19 skipped. No live runs. No pilot project yet.
Blockers: (1) _score_files now accepts absolute project paths and refuses symlink components; (2) expand_goal_test_files refuses __pycache__/.pyc/.pyo and the plan sets PYTHONDONTWRITEBYTECODE=1; (3) _matches is path-segment aware, so * stays inside one segment and ** matches zero or more.

Should-fix: targets are rejected when they match allowed.forbid; glob uses root_dir so project path metacharacters are literal; symlinks are checked before the file filter; validate_state checks budget_used, pending-approval phase/step/round consistency; validate_record checks the counters and allows null make/apply/goal_test/proposal_sha256 plus decision=complete.

Tests: 50 G0 cases (25 new review-driven cases). Full suite: 708 passed, 19 skipped, 0 failed. ruff and black clean.
Fold in antigravity re-check items: _goal_test_result guards a null or absent metric so exit-code-only goals pass; _budget_used accepts fractional wall_minutes so several short rounds do not truncate to zero (G1 tracks active seconds). Add the negative absolute score_argv test, a no-metric record case and a fractional-minutes state case.

G0 tests: 50 passed. Full suite: 708 passed, 19 skipped, 0 failed. ruff and black clean.
Add router_runner/goal_driver.py: GoalDriver.step() with a non-blocking state machine, the goal store, goal and active locks, resume, STOP, budget preflight at each spend, progress against best_score, the three kill counters and ledger, decision records and Round 0. A GoalBackend/ProposalAdapter protocol isolates the driver from the change pipeline; G1 uses a fake backend.

Tests: G1-1 to G1-36, 36 passed. Full suite: 744 passed, 19 skipped, 0 failed. Mutation checks: 12/12 caught (STOP, approve refusal, apply gate, resume, active lock, budget token, round cap, goal-test pass, scope, no-progress kill, goal-test hash, rollback gate).
…edges

Blockers: decisions persist to rounds/<n>/<step>-decision.json and _recover reloads the proposal and all approvals/results, so --once and a fresh driver resume at any phase; apply_done has a handler; _recover leaves failed jobs to _step_running_*; STOP is atomic, approve refuses under STOP, _recover treats STOP as terminal, and backend.stop is tested; goal_test_failures resets on a clean run, exit-code-only goals do not crash, and Round 0 retries; create_apply receives the make patch_sha256, the evaluator is called on a non-zero goal test, and create_* idempotence is documented.

Should-fix: records carry make/apply/rollback/kill, failure rounds write records, rejected rollbacks record decision=rejected and keep the reason, rollback retry preflights the budget, files_at_best is false on regression, and the score command must exit 0.

Tests: 52 G1 cases (16 new), full suite 760 passed / 19 skipped, 23/23 mutation checks caught, ruff and black clean.
The durable decision file introduced at 5433756 made a rollback retry
unsafe. _retry_rollback creates a new rollback Work Item in the same round
with a new nonce. The old rounds/<n>/rollback-decision.json stayed on disk,
and _consume_decision read it by round and step only. So attempt 2 started
with attempt 1's "approved" verdict, with no human approval.

- _consume_decision now takes the pending nonce and ignores an "approved"
  decision whose nonce differs. "rejected" carries no nonce, so it is
  unaffected.
- GoalStore.clear_decision drops the file; _retry_rollback calls it and
  clears the in-memory decision.
- Two tests: a retried rollback stays waiting until it is approved with the
  new nonce; a hand-written approved decision with a stale nonce is ignored.
- Mutation checks: disabling the nonce comparison and removing the clear
  are each caught by one of the two tests.

54 driver tests pass; full suite 762 passed, 19 skipped.
- goal_propose.py: the read-only proposer and evaluator (project-reader
  only), strict JSON parsing for both, prompt rendering with read-only
  .magnolia/entries memory, and a tolerant usage reader for the
  `opencode run --format json` events.
- The driver triage also refuses a proposal whose job budget exceeds the
  remaining goal budget (G2-4), and exposes triage_proposal().
- tests/test_goal_propose.py: G2-1 to G2-12 plus one evaluation schema
  test, 13 tests. Six mutation checks, all caught.
Review fixes for dc336cc.

Blockers:

- read_run_events reuses campaign_runner.workers.parse_run_events, the
  parser the campaign worker already uses. The local parser read an
  Anthropic-style content list that `opencode run --format json` does not
  emit, so every live call would have parsed as empty text. A run that
  reports an error now fails closed; so does text with no usage event. A
  silent zero would let the token and dollar caps stop firing.
- render_proposal_prompt and render_evaluation_prompt now start with their
  system prompt, so the model gets the envelope, the kind and the request
  keys. Before, the constants were dead code.
- metric is optional: an exit-code-only goal renders "metric: none".
- The proposer sees files_at_best, the last goal-test exit and attempts, and
  a bounded tail of the latest goal-test stdout/stderr logs. The driver CLI
  exports MAGNOLIA_GOAL_ID so the adapter can find the goal store.

Should-fix:

- A parse failure raises AdapterError with the spent usage; the driver
  charges it before it fails the round. Same for the evaluator.
- The remaining-budget floats are rounded to 6 places, so 0.3 - 0.1 does not
  reject a valid 0.2 proposal.
- Tests: real NDJSON fixtures (multi-step sums, error event, missing usage),
  wall minutes in the budget rule, an exit-code-only prompt, the baseline log
  excerpt, and usage on a parse failure.

G1 items Antigravity asked for before G3:

- _stop_from_sentinel calls backend.stop() for a file-only STOP.
- The rejected-rollback flag is state["last_decision"]: crash-safe.

Nice-to-have: OPENCODE_DB is overridable, memory skips symlinks, and
parse_proposal checks that kind is a non-empty string.

9/9 mutation checks caught.
The crash-safe rejected-rollback flag from f38ff98 was sticky.
`_step_waiting_rollback_approval` sets `state["last_decision"] =
"rejected"`, and nothing reset it. Every later round that entered
`recorded` was then written as "rejected" and skipped its "continue"
decision in decisions.jsonl.

Every non-rejected path to `recorded` now sets the flag to "continue":
the normal score path and the exit-code-only path in `_step_evaluating`,
`_step_rollback_done`, and the continue branch of `_step_recorded`.
`last_decision` still reads "rejected" in state.json after the rejected
round, as the reviewer asked.

Test: reject a rollback in Round 1, then let Round 2 record normally.
Round 1 says "rejected", Round 2 says "continue", and state.json ends at
"continue". Mutation: removing the reset fails the test.
The driver never runs a job. `goal_backend.py` implements the GoalBackend
contract with the depth-3b front:

- make -> `change submit` of the bounded-change request, with a stable
  source event id, so a crash-resume returns the same Work Item;
- apply -> `change apply` of the completed make;
- rollback -> `change rollback` of the completed apply;
- start -> `change approve` with the front nonce, then `change run`;
- status -> the engine work item state, mapped to queued/running/completed/
  failed;
- usage -> the tokens and cost in the campaign receipt;
- stop -> `engine.stop`.

The front nonce is the same one the goal door shows, so a restart can
re-read it through `pending_nonce` when the in-memory map is empty. A small
`backend/work-items.json` in the goal store keeps (round, step) -> Work Item
idempotent.

Tests: `tests/test_goal_run.py`, 9 tests. G3-1 (the approved make runs
through the executor), G3-2 (the apply binds to the make), G3-3/G3-10 (the
round record and the goal test), G3-9 (budget from the receipts), G3-11
(resume does not duplicate), G3-14 (STOP cancels the job), plus state
mapping, receipt usage, restart reuse and a missing nonce. 5/5 mutation
checks caught.

Partial milestone: G3-4 to G3-8 and G3-12 to G3-13 are driver behaviour and
stay covered by the named G1 tests (mapping in the G3 report).
- `FrontGateway.status` sums the wall minutes of the finished attempts from
  the engine assignment rows (`created_at`, `ended_at`), and `usage()`
  reports them. Before, the wall budget only counted the driver's own time.
- `test_the_backend_runs_a_real_make_through_the_engine` drives one make
  through the real engine on a scratch project, with the existing
  `tests.change_worker:patch` worker double (no model, no quota). It checks
  `make_done`, one job in the budget, the durable work-item map, a non-zero
  wall time, and that the make ran on the campaign copy.

10 tests in `tests/test_goal_run.py`; full suite 794 passed, 19 skipped.
Review fixes for 4479586 and 900a490.

Blockers:

- `FrontGateway.stop` now calls `front.change_stop`, which halts the
  campaign and ends a running executor. `engine.stop` only flipped the
  SQLite row. A terminal item is returned cleanly, so a second stop is
  idempotent.
- The backend no longer self-approves. `start` only runs an item that is
  already queued; a candidate raises "approve it first". The human door is
  `approve_work_item(work_item, nonce)`, which G4 will call and the tests
  call explicitly. `pending_nonce` now returns only a pending approval.
- `_stored_approval` no longer reuses a terminal Work Item. A rollback that
  failed its verification therefore gets a fresh item in the same round.
- Error handling: an unknown Work Item raises BackendError; `status` reads
  the failure reason from `receipt["reason"]` / `receipt["errors"]`;
  `front.FrontError` becomes BackendError at every gateway call;
  `waiting_human` maps to failed instead of an endless poll.
- The driver wraps `backend.start` in the three approved phases, so a start
  failure is a failed round, not a crash.

Should-fix:

- `work-items.json` is written through a temp file and `replace()`.
- `create_apply` checks the returned patch hash against the make's.
- Tests: candidate refusal and running idempotence, rollback retry, a
  different patch, the receipt reason and an unknown item.

14 tests in tests/test_goal_run.py; 9/9 mutation checks caught.
Seven commands in `router_runner/front_goal.py`, dispatched from
`front.py`:

- `goal start` — validate the goal, refuse an existing store unless
  `--force`, archive only a finished store, create the store, run Round 0;
- `goal status` — phase, round, budget, counters, best score, last decision,
  goal test, and the pending nonce while a step waits;
- `goal approve` — the TTY guard, the STOP refusal, the
  (round, step, work_item, nonce) binding, the engine approval with the
  human's nonce, then a detached `goal_driver --once`;
- `goal reject` — record the rejection; the goal continues; spawn `--once`
  unless STOP exists;
- `goal resume` — one fresh `--once` run; refused under STOP;
- `goal stop` — write STOP and stop the running Work Item; no driver lock;
- `goal log` — the round records and the kill ledger.

The front-desk skill gains a "Goal (depth 3c)" section: the front relays the
status and the approval command; it never approves.

`tests/test_front_goal.py`: 11 tests covering G4-1 to G4-12 (G4-3 and G4-8
share the TTY test). 5/5 mutation checks caught.
Review fixes for 2f6173d.

Blockers:

- `goal_stop` stops every Work Item of the current round that can still run:
  the running one, the just-approved queued one, or the one waiting for
  approval. It asks the backend for the state and skips only terminal and
  candidate items. `change_executor` has no STOP sweep, so a queued item
  left alone would run after the goal was stopped.
- The evaluator is wired. `goal_start` passes a `GoalEvaluator` to the
  driver, `goal_driver` gains `--evaluator`, and `spawn_once` passes
  `router_runner.goal_propose:build_evaluator`. Before, the driver fell back
  to the proposer and `_step_evaluating` swallowed the AttributeError.
- `spawn_once` passes its `root` to the child as `MAGNOLIA_GOAL_ROOT`, and
  `build_backend` reads it, so a custom root is not silently replaced by the
  default code root.
- `goal_start` catches `GoalError` (an active-goal lock, for example) and
  returns exit 3 instead of 5.

Should-fix:

- `goal_status` includes `files_at_best` and the pending content hash.
- `goal_log` sorts rounds numerically.
- The front-desk skill explains the 2-versus-3 exit codes and names
  `front goal approve` in the do-not-run list.
- Tests: stop while the driver lock is held, stop a queued item, resume
  (spawn and STOP), reject with `--step` and under STOP, start while another
  goal holds the lock, the evaluator wiring, and the spawn command and root.

17 tests; 9/9 mutation checks caught.
Setup only; nothing here spends quota.

- `pilot/goal-pilot/` is the tracked template of the scratch lane:
  `src/textstats.py` with three bugs, four tests (three failing),
  `tools/goal_score.py` (failed + errored), `goal.json`, `agent.json`,
  `GOAL.md`.
- `pilot/install.py` copies the template to `projects/goal-pilot` and never
  overwrites an existing lane unless `force` is set.
- `pilot/conftest.py` keeps a bare `pytest` from collecting the template.
- `tests/live/test_goal_pilot_live.py`: G5-1 and G5-2 use the real proposer
  and backend (they spend quota); G5-3 and G5-4 use a scripted proposer and
  a fake backend (no spend). All four skip unless `MAGNOLIA_LIVE=1`.
- Runbook: `projects/xiulian/docs/goal-mode-g5-runbook-2026-12-02.md`.

The lane is gitignored; `python -m pilot.install` recreates it.
…b budget

The first live pilot run was killed at round 2 with two prompt gaps:

- round 1: "read_only path does not exist: tests/**". The prompt showed the
  goal's read-only scope as globs under "READ-ONLY PATHS"; the model copied
  them. The request schema needs concrete existing paths.
- round 2: "token budget exceeded: 44820 >= 12000". With no guidance, the
  model asked for a 12k-token job; the worker used 44,820.

The system prompt now says read_only is a concrete file or directory, never a
glob, with an example, and recommends max_tokens 100000, max_wall_minutes 20,
max_cost_usd 0.2. The render heading is "GOAL READ-ONLY GLOBS (scope only)"
and prints the goal caps next to the remaining budget.

Pilot budget: goal max_tokens 200000 -> 600000. The measured proposer usage
was 66,937 tokens for proposal 1 and ~131,000 for proposal 2 (the sum
includes cache reads); 200k allowed only two proposals.

Test: the prompt carries "never a glob", the example, 100000 and the goal
caps.
…ect tests

The second live pilot run failed both rounds on the request's verify:

- round 1: `pytest tests/` -> "file or directory not found: tests/". The
  check materializes only the target files into a temporary copy, so the
  project tests are not there.
- round 2: a multi-line `python -c` -> "verify token holds shell syntax".

The prompt now says verify runs in a temporary copy holding only the
targets, cannot run the project tests, and should be a syntax check such as
`["python", "-m", "py_compile", "<target>"]` or `["python", "-c", "pass"]`.
The rendered prompt carries a concrete example for the goal's first target.

Test: the prompt holds "py_compile" and "temporary copy".
The pilot lost one round per run to a `python -c` script with a semicolon in
the verify. The argv validator refuses any token with shell syntax, so the
proposal was refused before any job existed.

The prompt now says: use a syntax check such as
`["python", "-m", "py_compile", "<target>"]`, never `-c`, because a `-c`
script with a semicolon or a newline is refused.

Test: the prompt carries 'Never use "-c"'.
…-fix

Review fixes for the G5 pilot.

Blockers:

- B1: on completion, `best_score` and `best_round` stayed stale (3.0 / 0).
  `_step_baseline` and `_step_evaluating` now record the passing metric
  through `_record_score` (or set best_score/best_round in the baseline)
  before writing the complete record. `front goal status` is accurate after
  a win.
- B2: the live tests shared one lane without a reset, so G5-2 and G5-4
  started on an already-fixed file. An autouse fixture restores
  `src/textstats.py`, `tests/test_textstats.py` and `tools/goal_score.py`
  from the template before every test; the goal stores are kept.
- B3: G5-1 asserted `tokens <= 200_000`; it now compares against
  `driver.goal.budget`.

Should-fix:

- S1: `goal_score.py` returns the pytest exit code and prints its output
  when pytest fails without a test count, instead of a false 0.
- S2: G5-3 is renamed `test_pilot_kill_on_repeated_failures`; a new
  `test_pilot_kill_on_no_progress` covers three rounds with no improvement
  and asserts the `no_progress_rounds` ledger entry.
- S3: the G5 report and runbook are synced (commit list, 600k, the fixed
  `-c` issue, the cost-cap warning, the real total spend).
- S4: the template's goal.json uses `__PYTHON__`; `install.py` substitutes
  the running interpreter.
- S5: a completion appends `{"decision": "complete"}` to
  `decisions.jsonl`; the file is a complete audit log.

Tests: `test_pilot_assets.py` covers the score script and the installer;
two driver tests cover the completion state and the baseline win.
- SKILL.md: after a job finishes, run "front goal resume"; the --once run
  stops when a job starts. The old text said the phase moves by itself.
- goal_driver: on completion, set best_round to the winning round even when
  the metric only equals an earlier best (a degenerate goal test).
The terms scan rejects the real project name used as a sample in this test.
Replace it with demo_lane. No behaviour change: the test only needs a path.
Brings the 13 master commits (install script, service and MCP fixes,
conflict adjudication, GRES support) into the goal-mode branch so the pull
request merges cleanly.

Conflict resolved in opencode_cc_mem/softwares/bin/magnolia: both the
branch MAG_PIN line and the master MAG_OC_BIN line are kept.
@taojiang9914
taojiang9914 merged commit 5e6f60d into master Dec 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant