Cut fixed per-iteration dispatch overhead in implement-loop; add the missing standard-mode suite gate #29

Closed
opened 2026-07-17 15:20:05 +02:00 by claude · 0 comments
Collaborator

Motivation

Measured over local workflow-run telemetry (206 implement-loop runs, 2026-06-17..2026-07-17, 2,883 agent dispatches, ~164.5M non-cache-read tokens): cache_creation is 85.7% of real spend — the cost driver is the number of freshly-primed agent contexts (~40–90k real tokens each), not prompt or output length. The mechanical stages are the biggest size-independent block: plan-extract 14.4M (244 dispatches, each re-reading the same plan for one task), finalize 8.0M (pure templating of an already-computed object), preflight 7.5M, tree-check 3.2M.

Separately, an adversarial audit of the pipeline found that standard mode is the only path without an independent end-of-iteration suite gate (mini re-runs the RED test + suite; compiler-driven gates on build + suite; standard's tree-check only counts files).

Measures

  • finalize removed — the script builds the exact stats.json / BLOCKED.md contents as strings (templates single-sourced in the .js); the return value carries them and the orchestrator writes them byte-identical to the same paths. File contracts unchanged (committed stats.json, BLOCKED.md consumed by the tdd decompose path).
  • preflight folded into plan-index, standard mode only — the clean-tree check becomes a preflight_ok schema field evaluated by the script before anything else; mini mode keeps its dedicated preflight dispatch unchanged.
  • adaptive plan-extract mergeplan-index additionally reports a per-task byte estimate; below a conservative total-byte threshold (~20k) one plan-extract-all call replaces the per-task fan-out, above it the fan-out stays. Deterministic guard on both paths: delivered task count must match the index count and no task_text may be empty; a failed extract-all falls back to the fan-out immediately (no single-shot retry). Threshold is on bytes, not task count — truncation (#22: a schema-bound response self-limits to a well-formed prefix) is output-byte-driven. The count-match guard also closes the residual prefix-truncation exposure #22 left in the fan-out's index step.
  • standard end-verify replaces tree-check — a mini-verify-shaped stage: full suite run + untracked-aware git status --porcelain footprint. Gates: suite red → BLOCKED. Closes the audit gap above; makes the three execution paths consistent. Known trade-off: a flaky or environment-red suite now blocks a standard iteration — the same exposure mini-verify already has.
  • severity check in the no-op-repair backstop — today a byte-identical repair diff exits the quality loop as DONE-with-concerns regardless of severity; with an important finding in the set it becomes BLOCKED. Minor-only sets keep the current behaviour.
  • repo-root anchor in all git-reading stage prompts — the carrier gains repo_root (falling back to a git rev-parse --show-toplevel report from the first dispatched stage); the script stamps git -C <root> into quality / spec / verify prompts. This is the remedy validated in #25 (worktree sessions produced false infra_blocked quality reviews and a false no-op BLOCKED from tree-check reading the primary checkout).

Rejected variants (design record)

  • Merging plan-extract into plan-index unconditionally — re-introduces #22; rejected.
  • Hard-gating on impl.applied_changes == false — inverts the #12 invariant (a self-report must never fail a run that did the work; the initial implementer may legitimately no-op while a repair writes the real change); rejected.
  • Sourcing the discard-guard paths from the quality review instead of the snapshot dispatch — loses the git stash create recovery SHA, is footprint-scoped instead of whole-tree, and is stale on held/no-op exits; snapshot stays.
  • Dropping the mini-mode spec review — it is the only scope-creep gate in mini (the quality reviewer is task-text-blind by contract); rejected.
  • Holding minor-only quality findings without the round-0 repair — today that repair actually fixes the minors, so skipping it is a quality trade, not an optimization; rejected.

Expected effect

~9–11% of the corpus's real tokens at equal-or-harder gating (three gates get stricter: extract count-match, standard suite gate, severity-aware backstop). Dispatch floor: mini 7→6, standard ~9+4T→~7+4T.

## Motivation Measured over local workflow-run telemetry (206 implement-loop runs, 2026-06-17..2026-07-17, 2,883 agent dispatches, ~164.5M non-cache-read tokens): cache_creation is 85.7% of real spend — the cost driver is the number of freshly-primed agent contexts (~40–90k real tokens each), not prompt or output length. The mechanical stages are the biggest size-independent block: `plan-extract` 14.4M (244 dispatches, each re-reading the same plan for one task), `finalize` 8.0M (pure templating of an already-computed object), `preflight` 7.5M, `tree-check` 3.2M. Separately, an adversarial audit of the pipeline found that standard mode is the only path without an independent end-of-iteration suite gate (mini re-runs the RED test + suite; compiler-driven gates on build + suite; standard's `tree-check` only counts files). ## Measures - [ ] **finalize removed** — the script builds the exact `stats.json` / `BLOCKED.md` contents as strings (templates single-sourced in the `.js`); the return value carries them and the orchestrator writes them byte-identical to the same paths. File contracts unchanged (committed `stats.json`, `BLOCKED.md` consumed by the tdd decompose path). - [ ] **preflight folded into plan-index, standard mode only** — the clean-tree check becomes a `preflight_ok` schema field evaluated by the script before anything else; mini mode keeps its dedicated preflight dispatch unchanged. - [ ] **adaptive plan-extract merge** — `plan-index` additionally reports a per-task byte estimate; below a conservative total-byte threshold (~20k) one `plan-extract-all` call replaces the per-task fan-out, above it the fan-out stays. Deterministic guard on both paths: delivered task count must match the index count and no `task_text` may be empty; a failed extract-all falls back to the fan-out immediately (no single-shot retry). Threshold is on bytes, not task count — truncation (#22: a schema-bound response self-limits to a well-formed prefix) is output-byte-driven. The count-match guard also closes the residual prefix-truncation exposure #22 left in the fan-out's index step. - [ ] **standard end-verify replaces tree-check** — a mini-verify-shaped stage: full suite run + untracked-aware `git status --porcelain` footprint. Gates: suite red → BLOCKED. Closes the audit gap above; makes the three execution paths consistent. Known trade-off: a flaky or environment-red suite now blocks a standard iteration — the same exposure mini-verify already has. - [ ] **severity check in the no-op-repair backstop** — today a byte-identical repair diff exits the quality loop as DONE-with-concerns regardless of severity; with an `important` finding in the set it becomes BLOCKED. Minor-only sets keep the current behaviour. - [ ] **repo-root anchor in all git-reading stage prompts** — the carrier gains `repo_root` (falling back to a `git rev-parse --show-toplevel` report from the first dispatched stage); the script stamps `git -C <root>` into quality / spec / verify prompts. This is the remedy validated in #25 (worktree sessions produced false `infra_blocked` quality reviews and a false no-op BLOCKED from tree-check reading the primary checkout). ## Rejected variants (design record) - Merging plan-extract into plan-index unconditionally — re-introduces #22; rejected. - Hard-gating on `impl.applied_changes == false` — inverts the #12 invariant (a self-report must never fail a run that did the work; the initial implementer may legitimately no-op while a repair writes the real change); rejected. - Sourcing the discard-guard paths from the quality review instead of the snapshot dispatch — loses the `git stash create` recovery SHA, is footprint-scoped instead of whole-tree, and is stale on held/no-op exits; snapshot stays. - Dropping the mini-mode spec review — it is the only scope-creep gate in mini (the quality reviewer is task-text-blind by contract); rejected. - Holding minor-only quality findings without the round-0 repair — today that repair actually fixes the minors, so skipping it is a quality trade, not an optimization; rejected. ## Expected effect ~9–11% of the corpus's real tokens at equal-or-harder gating (three gates get stricter: extract count-match, standard suite gate, severity-aware backstop). Dispatch floor: mini 7→6, standard ~9+4T→~7+4T.
claude added the feature label 2026-07-17 15:20:05 +02:00
claude self-assigned this 2026-07-17 15:20:05 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Brummel/Skills#29