Repository navigation
M18 slice 2: token governance — phase metering + footprint/turn levers (#224) - #226
Merged
Merged
Conversation
…#224 step 0) extractTokenUsage now carries turns/cache_read/cache_write (bench caliber total = input+output+cache when no explicit total); buildPhaseCostReport aggregates them and stamps workflow_run_id/change_id; the executor appends one row per phase to .as-xflow/phase-cost-ledger.jsonl on every run, so per-phase acceptance no longer depends on per-run raw trees.
…(M18 #224 step 0) New harness/phase_usage.py joins the workflow execution log's phase windows with pi message_end usage timestamps and emits one row per (run, phase); run.py appends them to phases-<tag>.jsonl next to the runs jsonl, keyed by the cell task id, before the rundir is deleted. This is the metering whose absence forced M18 slice 1 onto proxy metrics.
… lever A) - agent-invoke: a large intake.json now enters phase prompts as a reference (path + bytes + top-level keys + scalar digest) instead of a full pretty-printed inline; small intakes go in compact single-line form. Measured on a 1919-byte intake fixture: 1919 -> 559 bytes. - phase prompt templates: read only the artifacts the phase consumes instead of the whole artifact directory. - B2.status.read: compact JSON separators (same value for parsers); measured 384 -> 305 bytes on a typical status document.
- yolo.yaml: brainstorm and proposal-freeze are lite_skip. Brainstorm is a status transition plus a human-gate stop with no artifacts; proposal-freeze is a status transition over an artifact change-init already scaffolds and plan consumes directly. Verification spine (tdd seals, I6d, J1, J6) and the execute human gate are untouched. Counted on the workflow definition (backend change): lite-executed phases 11 -> 9, human-gate stops per lite run 2 -> 1. - bench AGENTS.md entry: mandated startup drops from five CLI round trips (guide, goal set, doctor, goal audit, validate) to two (goal set, validate); the other three become on-demand diagnostics. - yolo SKILL: drive with one workflow-run invocation per gate stop instead of stepping atoms; planning rules deduped to a pointer at xflow:plan (net file size +487B one-time for the new driving rules).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements M18 slice 2 (#224): metering first, then the two token levers. Verification steps (seals / replay / quality gate / I6d) are untouched — no token is saved by cutting verification.
Step 0 — metering (commits 5d508a9, f6ce7de)
Product side:
phase-costentries and totals now carry six fields:turns,input,output,cache_read,cache_write,total.extractTokenUsagereads turns + cache splits from agent-stream usage (bench total convention when no explicit total: input+output+cache_read+cache_write); bareinput/outputkeys are only accepted as real numbers so payload text is never misread as usage..as-xflow/phase-cost-ledger.jsonlnext tophase-cost.json: one flat row per phase withworkflow_run_id,change_id,phase,status,duration_ms,turns,input,output,cache_read,cache_write,total,recorded_at— joinable to bench runs by run id.Bench side:
bench/swebench/harness/phase_usage.py: buckets each pi assistantmessage_endusage record into workflow phases using thephase_started/phase_completedwindows inexecution.ndjson(timestamps are epoch ms inside the message object); records outside any window go to_outside_workflowso totals still reconcile.run.pywritesphases-<tag>.jsonl(keyed bytask_id) inside the same lock as the runs row, before the cell rundir is deleted; metering failures never fail a cell.test/phase-cost.test.js11/11 (incl. a real executor run asserting the ledger file lands on disk with all fields),bench/swebench/test_phase_usage.py6/6, andtest_phase_usageadded to the harness-isolation module list.Step 1 — Lever A: per-turn footprint (commit 799a0c3)
intake.jsonin every phase prompt (agent-invoke)B2.status.readoutput echoed into promptsindent=2JSONphase-execution.md,phase-artifact.md)New test: a large intake enters the generated phase prompt as a reference and its body is absent (
test/heavy-atoms.test.js, 65/65).Step 2 — Lever B: round trips (commit f9f8650)
workflows/yolo.yaml:brainstormandproposalare nowlite_skip. Brainstorm is a status transition plus a human-gate stop with no artifacts; proposal-freeze is a status transition over an artifactchange-initalready scaffolds andplanconsumes directly. Counted on the workflow definition (backend change, via the repo's own loader): lite-executed phases 11 → 9, human-gate stops per lite run 2 → 1. The verification spine (tdd-red/green seals, I6d, J1, J6),set-in-progress(hosts the repo-doctor readiness check) and theexecutehuman gate are unchanged; the full track is unchanged.AGENTS.mdentry (arms.py): mandated startup drops from 5 CLI round trips (guide, goal set, doctor, goal audit, validate) to 2 (goal set, validate); the other three are demoted to on-demand diagnostics.xflow/yolo/SKILL.md: drive with oneworkflow runinvocation per gate stop instead of stepping atoms; planning rules deduplicated to a pointer atxflow:plan(net +487B one-time, for the new driving rules). Note: the goal-alignment phrase the competitive score greps for is kept on one line — splitting it across lines cost 2 score points in testing.test/lite-track.test.js(41/41 with lite-track-auto).Step 3 — long-tail budget gate: skipped
Per the issue's option: the step-0 ledger now records exactly the data a budget gate would enforce on, but setting budget numbers before slice 3 produces same-caliber phase data would be guessing. Skipped deliberately; the ledger is the deliverable that unblocks it.
Tests
Full suite run in three batches (the runner is fail-fast): 838 tests, 834 pass, 4 fail. All 4 failures are the pre-existing I6d family and fail identically on clean main
e137c87in this VM (A/B verified):test/i6d-acceptance-demo.test.js— 1 fail (same on main)test/xflow-audit.test.js— 3 fails in the I6d assertion-execution gate describe (same 3 on main, 68/71 there too)An intermediate regression (competitive score 100 → 98 via the SKILL.md line wrap above) was caught by
cli-usabilityand fixed; that file is back to 68/68.CI status at open time: not yet checked — do not merge until CI is green.
Refs #224. Rename PR #225 is still open and not merged, so this branch is based on current main
e137c87; if #225 lands first, this branch needs a rebase (it touchesxflow/yolo/SKILL.mdtext only, no bin changes).