Harness Intelligence Wiki
SpecsCLIReview Phase Token Rebuild

Review Phase Token Rebuild Implementation Notes

Implementation Notes

Parent-owned record. Pair: SPEC f717104865da, ARCHITECTURE 12a6d5eef978; PLAN 276c00e3b8ee.

Execution Reconciliation

TaskProviderTask Result input identitiesParent Task GateReconciliationArchitecture CheckpointFinal acceptanceCode Review
T1IP-526skills cb9db646, 8529cbb0; helper blob a1d8e5e1, --version sha256 b95e51b7…passed (cmp identical, mode 755, npm test 380/380)completeA1passpending
T2IP-527skills 203f4d2f; library sha256 2dde6382… (was b6e1d582…)passed (RED missing export → GREEN 8/8; npm test 339/339; only node:crypto import; seven exports)completeA1passpending
T3IP-528skills b352e33, 9685980passed (RED module missing → GREEN 13/13; npm test 351/351)completeA2passpending
T5IP-530skills e8ec5ce (19 files), pushed 979a504..e8ec5cepassed (RED pass_report field → GREEN 47/47; npm test 353/353)completeA3passpending
T6IP-531HI 8534056ee, 93b6c5415, 6c0ad31c3, f3dca2fde, d94709974; sync receipt skills 44489ad1bfd8 (tag sync/review-phase-token-rebuild-44489ad1bfd8)passed (RED publisher executable entry → GREEN 99/99 targeted; apps/cli 834 pass, 1 pre-existing unrelated fail; check pass)completeA4passpending
T7IP-532HI 0fd719735 (18 files), 19a2c67b3, 46f80a4fapassed (health: no new finding, 10 baseline + IMPLEMENTATION-NOTES nav fixed by parent; release classification baseline)completeA4passpending
T8IP-533measurement 3 run ids 20261023T133440Z-563684, 20261023T133430Z-5e5fb5, 20261023T134155Z-9d9f12 (earlier: measurements 1, 2)passed after repairs 1–2 (median 717,084 tokens, 9 turns)completeA4passpending
T4IP-529skills 084eaa5 (26 files)passed (layout AC-025/026; no wait step; no simplify; npm test 338/338)completeA2passpending

Summary

  • review-phase is one 6-step procedure over scripts/review.mjs (prepare, run, retain, status) and the pure scripts/review-contract.mjs; two Axis Runs call the vendored upstream autoreview v0.6.0 with host-engine default and Engine Fallback; one foreground Adjudicator; temporary Pass Report in .devpunks/delivery/<goal>/reviews/.
  • autoreview and review skills removed; delivery-phase consumes pass_report + review_run_id and derives the pass count.
  • Skills main cb9db64..44489ad (pushed); HI branch spec/review-phase-token-rebuild through d94709974 plus this record (pushed).
  • Measured cost: median 717,084 tokens and 9 turns per pass (previous design 25–30M tokens, about 90 gate-subagent turns).

Deviations From Plan

  • Skills pin moved from e8ec5ce to a4ab324 (peer session's requirements-grill/show-me commit on top of ours) so this branch does not revert it; the peer releases that change separately from cherry-pick dc39c4a.
  • Pre-existing failure outside scope: apps/cli/src/features/typescript-semantic-reads/discovery.test.ts misses packages/lints/tsconfig.json (introduced by #275 on main), unrelated to this diff.
  • T5 also removed review_lineage_id, repair_count, report_retention_pending and renamed secondary_architecture_follow_up → secondary_debt in delivery state (nothing produces them now); repair opening is idempotent on review_run_id. Residual wording: implement-spec/references/lifecycle.md:64 "historical review lineage" (harmless; left).
  • T3 reviews a deterministic synthetic commit (git commit-tree, parent = base, tree = head with .devpunks/delivery/**/reviews/ reset to base) through upstream --mode commit, because upstream branch mode cannot exclude paths and always diffs live HEAD (AC-007 wording --mode branch; AC-019 met).
  • T3 exclusive create uses temp file + fs.linkSync (EEXIST-exclusive, crash-safe) instead of openSync('wx').
  • T3 adds prepare flags --spec, --accepted-risk, --human-direction and env HI_REVIEW_PROMPT_DIR, HI_REVIEW_ENGINE_TIMEOUT_SECONDS (900), HI_REVIEW_MAX_ENGINE_PASSES (3, upstream --max-review-passes, the oversize limit). Standalone Pass Reports: .devpunks/delivery/standalone/reviews/<base12>-<head12>-<run_id>.json, ordinal: null.
  • T4 fixes run-dir names (packet.json, standards.json, spec.json, adjudication.json), candidate_ref as JSON path, and root-agent-written subagent_tokens; T3 aligned by parent message.
  • Upstream accepts --prompt-file only inside the reviewed repo (S:3633-3641); review.mjs passes axis guidance as --prompt text (deviation from AC-007 wording, same content).
  • With --max-priority P2, P3 smell observations are mostly omitted by the engine or land in priority_filtered_findings (consistent with Q8/AC-009).
  • T2 validatePassReport uses severity critical | high | medium | low (existing vocabulary), requires lens_result clean | findings (incomplete never counts) and maps secondary_architecture_follow_up to route.secondary_debt.
  • T1 also ships upstream scripts/vendor/LICENSE (MIT notice must travel with the copy); parent-approved scope extension.
  • Plan and SPEC name aa2f8f7a… as the upstream commit; it is the annotated tag object. The tag points to commit 6b38162c6f27792871f9a3c5df4e041eb7c5f15f. vendor/UPSTREAM.md records both.

Surprises and Decisions

  • Skills main carries foreign uncommitted edits (2026-10-23 12:55: requirements-grill/phases/round.md, references/artifact-output.md, show-me/SKILL.md, show-me/UPSTREAM.md, tests/show-me.contract.test.mjs, untracked show-me/references/, tests/fixtures/v43/IP-453/skills/). Workers preserve them; commits stage only owned hunks.

Sanity Checks

CheckResultNotes
A3 checkpoint RAC-1..RAC-5passskills e8ec5ce npm test 353/353; no review_count/verified_retained_ref/autoreview in delivery-phase; ledger entry 1 removed
A2 checkpoint RAC-1..RAC-4passskills npm test 351/351 at 9685980; layout AC-025/026
A4 final closure RAC-1..RAC-9passRAC-6 catalog/publisher tests 80/80; RAC-7 measurement 3; RAC-8 health 10 (baseline); RAC-9 skill evidence rows T4–T7; migration ledger empty (entry 1 removed T5, entry 2 removed T6)
A1 checkpoint RAC-1, RAC-2passhelper bytes = upstream tag blob; library imports only node:crypto; exports exactly AC-006 set

Skill Application Evidence

TaskSkillStatusHow/where
T2tddappliedRED per slice in tests/review-contract.test.mjs
T2codebase-designappliedpure module, seven-export interface
T4writing-for-agentsappliedSKILL.md steps end on JSON-field criteria; references disclosed; positive phrasing (Task Result 2026-10-23)
T3tddappliedCLI-level RED, one test per behaviour, real git + helper, fake engines
T3codebase-designappliedside effects in review.mjs; decisions via library; seam CODEX_BIN/CLAUDE_BIN
T3backend-recoverable-actionsappliedretain: validate → exclusive link publish → pathspec commit → cleanup; crash and hook-failure retries tested
T5writing-for-agentsappliedsingle route table in routing.md; count only from CLI; field lists replaced in place; positive router wording
T6tddappliedpublisher RED/GREEN; pipeline whole-skill removal cases passed at RED (existing STEP-011 behaviour)
T6writing-for-agentsappliedroot.md.tmpl:69 and AGENTS.md:7 rewritten with glossary terms, simplify dropped
T7writing-for-agentsappliedglossary leading words; stale sections replaced in place; routing/budget single source in review.mdx
T1codebase-designappliedhelper unchanged at process seam; byte and blob checks (vendor/UPSTREAM.md)

Acceptance Measurement

Measurement 1 (2026-10-23, skills a4ab324, Claude engine claude-fable-5-1)

PassSubjectTurnsPass-runner tokensAdjudicator subagent_tokens (transcript total)Engine tokens (proxy)Total (AC formula / with full Adjudicator)RouteFindings
A#272 delivery13475,68642,487 (396,787)382,260900,433 / 1,254,733implementation1
B#274 delivery16 (hook detour)646,14850,119 (615,424)340,6611,036,928 / 1,602,233docs_ingest1 (+1 rejected)
C#277 standalone18 (hook detour)761,47647,712 (431,551)132,607941,795 / 1,325,634closeout0 (+1 rejected)
  • Median tokens 0.94M (1.33M with full Adjudicator transcripts): AC-002 token part passes (previous design: 25–30M).
  • Median turns 16: AC-002 turn part fails. Detour-free floor was 13: status, prepare, run, end turn, read run output, start Adjudicator, write subagent_tokens, retain, 2 report reads, load $show-me, read findings, return.
  • AC-001 passes with caveats: Claude usage is always null (upstream records Codex usage only); model records the requested alias; harness subagent_tokens equals the Adjudicator's final-turn context, not its total.
  • AC-003 passes. Background notification resumed every pass-runner. Engine Fallback not exercised (Claude served every attempt).
  • Repair 1 (skills fa8ab42, HI 93b6c5415): retain --subagent-tokens and a compact findings summary in retain output; SKILL.md presents that summary directly (no $show-me load, no report reads). Then re-measure.

Measurement 2 (2026-10-23, skills fa8ab42)

PassSubjectTurnsPass-runner tokensAdjudicator subagent_tokens (transcript total)Engine tokens (proxy)Total (AC formula / full Adjudicator)RouteFindings
A#272 delivery11 (3 optional reads/tool loads)410,43329,752 (113,677)575,5641,015,749 / 1,099,674closeout0
B#274 delivery13 (3 from background-Adjudicator stall)436,26466,009 (1,270,492)345,927848,200 / 2,052,683docs_ingest1 (+2 rejected)
C#277 standalone9320,29131,232 (145,513)153,177504,700 / 618,981closeout0
  • Median tokens 0.85M (1.10M full Adjudicator): pass. Median turns 11: fail by one.
  • Defect: SKILL step 4 does not require a foreground Adjudicator; pass B backgrounded it and its nested completion notification never reached the pass-runner (8 min stall).
  • Repair 2 (skills f0698a1, HI 6c0ad31c3, pushed): step 4 starts the Adjudicator in the foreground; the procedure states that the listed steps are the whole pass (no reference pre-reads, no extra tool loads, no post-retain checks).
  • Operational incident: another session ran git reset to origin on this branch in the main checkout and switched it to main; the 5 unpushed commits were restored from the reflog to 46f80a4fa, pushed, and work continues in worktree ~/.t3/worktrees/harness-intelligence/review-phase-token-rebuild.

Measurement 3 (2026-10-23, skills f0698a1, HI 6c0ad31c3) — accepted

PassSubjectTurnsPass-runner tokensAdjudicator subagent_tokens (transcript total)Engine tokens (proxy)Total (AC formula / full Adjudicator)RouteFindings
A#272 delivery12 (2 from measurement setup)412,14629,903 (85,328)758,0081,200,057 / 1,255,482closeout0
B#274 delivery9321,42357,218 (664,929)338,443717,084 / 1,324,795docs_ingest1 (+2 rejected)
C#277 standalone (superseded for AC-002 by D)8279,88529,566 (113,392)134,953444,404 / 528,230closeout0
D#250/#251 delivery (spec cli/issue-250-251-scoped-delivery-validation)8277,89345,397 (377,690)330,220653,510 / 985,803implementation1
  • Review finding f003 (Pass Report 1): pass C was standalone and does not measure from status. Delivery-mode passes A, B, D: tokens 1,200,057 / 717,084 / 653,510, turns 12 / 9 / 8.
  • AC-002 pass: median 717,084 tokens (1,255,482 with full Adjudicator), median 9 turns over delivery-mode passes.
  • Subject substitutions: #270 blocked by the --dry-run size check (spec axis 14 planned passes, 6.9 MB; AC-003 size limit working); #271 blocked by a defect (symlinked .codex/AGENTS.md in Standards source context, refused by upstream) — repaired in skills, see Code Review section.
  • AC-001 pass with caveats: Claude usage null (upstream records Codex only); model records the requested alias; subagent_tokens is the harness figure (Adjudicator final-turn context).
  • AC-003 pass: no pass stopped. Engine Fallback exercised only in CLI tests (Claude served every live attempt).

Acceptance Audit

ACResultEvidence
AC-001–AC-003passMeasurement 3
AC-004–AC-008, AC-010–AC-012, AC-014, AC-016–AC-023passtests/review-phase-cli.test.mjs (13), tests/review-contract.test.mjs (8); live passes in Measurement 3. AC-007 met with documented deviations (--mode commit on a synthetic commit; --prompt text)
AC-009, AC-013, AC-015, AC-025, AC-026passtests/workflow-boundaries.contract.test.mjs layout and text pins; skills f0698a1
AC-024passvendor/UPSTREAM.md, blob a1d8e5e1 equals upstream
AC-027passT5 contract test; skills e8ec5ce
AC-028passHI publisher/catalog tests; registry build (184 items, no skill-autoreview/skill-review)
AC-029passpipeline.test.ts dropped-skill cases; BASELINE_CHANGELOG.md Unreleased compatibility
AC-030passT7 pages; P4 inspection (no scaffold reviews/ writer)
AC-031passskills npm test 353/353
AC-032passSkill Application Evidence rows T4–T7

Follow-ups Outside Scope

  • Real defect seen by measurement passes on main: apps/cli/src/data/lint/frontend-layers/index.mjs:109 gives one-segment layer targets (@/features, @/composition) layer: null (pass A of measurement 1).
  • apps/wiki/content/docs/project/runbooks/hi-cli-scaffolding.md:589-593 still describes the old .githooks/pre-commit selector (found in all three #274 passes).
  • Pre-existing apps/cli/src/features/typescript-semantic-reads/discovery.test.ts failure (packages/lints/tsconfig.json, #275).

Code Review

PassPass ReportCommitRouteFindingsDisposition
1.devpunks/delivery/review-phase-token-rebuild/reviews/pass-1.json (run 20261023T134752Z-924147)4c1dc57c3implementationf001 standards medium review.mjs:47 shared run root trust; f002 spec low docs simplify claim; f003 spec medium standalone measurement pass; 11 rejected (9 mechanical false positives from en-dash AC ranges, 2 manifest claims)f001 fixed skills fefe8c6 (HI f3dca2fde); f002 fixed HI 57bee6bfb; f003 fixed by delivery-mode pass D
  • Pass 1 ran on this delivery's own diff (88e393523..8d8185774) with HI_REVIEW_MAX_ENGINE_PASSES=5 (planned passes standards 3, spec 4). Cost: Adjudicator 83,686 tokens; engines Claude, one attempt per axis.
  • Focused Repair Validation: skills tests/review-phase-cli.test.mjs 17/17; HI publisher/prompts/pipeline 80/80; apps/cli check pass; wiki health 10 (baseline); synced review.mjs identical to skills fefe8c6. No accepted-risk second pass requested: the repairs harden run-dir trust inside the reviewed script without changing architecture, public contract or scope.
  • Machine note: /tmp/hi-review (created earlier by the old code as 0775) was set to 1777 by the parent.
  • Additional defect found during measurement (symlinked AGENTS.md in source context, upstream refuses symlinked evidence) repaired in skills 44489ad (HI d94709974); proof: CLI test 18/18, skills npm test 358/358, prepare --standalone 6cb35f8cd^..6cb35f8cd (#271) returns blocker: null.
  • Observation outside scope: pass D (#250/#251) reported delivery-phase/phases/closeout.md:18 "run the one local broad run instead" can read as permission to skip CI; left as follow-up.

On this page