crysk 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +27 -23
  2. package/dist/SKILL-1q3658n0.md +74 -0
  3. package/dist/SKILL-25j4q9b8.md +143 -0
  4. package/dist/SKILL-4747bhne.md +143 -0
  5. package/dist/SKILL-4jc3sv23.md +74 -0
  6. package/dist/SKILL-c0492rch.md +540 -0
  7. package/dist/SKILL-d1nzkhhr.md +74 -0
  8. package/dist/SKILL-f8p7kvx0.md +143 -0
  9. package/dist/SKILL-gxd45g38.md +553 -0
  10. package/dist/SKILL-rec41991.md +66 -0
  11. package/dist/SKILL-zze8zj5g.md +536 -0
  12. package/dist/cli.js +24658 -24654
  13. package/dist/index.js +492 -463
  14. package/dist/opencode-ci-qrcv7a99.md +106 -0
  15. package/dist/opencode-ci-rdpcc7xc.md +106 -0
  16. package/dist/opencode-ci-yt0k74t0.md +106 -0
  17. package/dist/workflow-andv2dvm.yml +158 -0
  18. package/package.json +1 -1
  19. package/prompts/default/PROVENANCE.md +1 -0
  20. package/skills/crysk/SKILL.md +6 -6
  21. package/skills/crysk-ci-setup/SKILL.md +32 -33
  22. package/skills/crysk-ci-setup/assets/workflow.yml +5 -10
  23. package/skills/crysk-ci-setup/references/ci-admission.md +5 -5
  24. package/skills/crysk-ci-setup/references/opencode-ci.md +6 -6
  25. package/skills/crysk-loop/SKILL.md +37 -54
  26. package/skills/crysk-pr/SKILL.md +1 -1
  27. package/src/asset-manifest.ts +0 -6
  28. package/src/assets.ts +1 -4
  29. package/src/brand.ts +20 -30
  30. package/src/ci/gates.ts +155 -201
  31. package/src/ci/outcome.ts +4 -31
  32. package/src/ci/platform-limits.ts +135 -0
  33. package/src/ci/platform-report.ts +212 -126
  34. package/src/ci/platform.ts +28 -26
  35. package/src/ci/reporter.ts +25 -26
  36. package/src/ci/review-admission.ts +1 -2
  37. package/src/ci/review-levels.ts +12 -53
  38. package/src/ci/setup.ts +96 -66
  39. package/src/ci/trace-bundle.ts +11 -27
  40. package/src/ci/trace-transcripts.ts +4 -6
  41. package/src/ci/trigger.ts +3 -5
  42. package/src/cli.ts +6 -5
  43. package/src/commands/ci-setup-questions.ts +2 -55
  44. package/src/commands/ci-setup.ts +2 -26
  45. package/src/commands/triage.ts +131 -38
  46. package/src/commands/usage.ts +0 -1
  47. package/src/compare/compare.ts +3 -3
  48. package/src/compare/floor-test.ts +30 -201
  49. package/src/config/config.ts +6 -30
  50. package/src/diversity/accounting.ts +0 -26
  51. package/src/diversity/benchmark.ts +1 -17
  52. package/src/diversity/identity.ts +0 -14
  53. package/src/diversity/pipeline-integration.ts +0 -29
  54. package/src/doctor.ts +3 -6
  55. package/src/execution/claude-session-trace.ts +7 -2
  56. package/src/execution/contracts.ts +15 -9
  57. package/src/execution/harness.ts +165 -187
  58. package/src/execution/spend-limiter.ts +39 -131
  59. package/src/execution/usage-facts.ts +397 -0
  60. package/src/execution/usage-normalized.ts +33 -86
  61. package/src/harness/materiality-judge.ts +0 -5
  62. package/src/harness/pipeline-plan.ts +0 -3
  63. package/src/harness/replay-rows.ts +0 -5
  64. package/src/harness/route-runner.ts +2 -2
  65. package/src/harness/single-step.ts +3 -9
  66. package/src/index.ts +1 -1
  67. package/src/mcp/preflight.ts +2 -2
  68. package/src/model/catalog.ts +1 -3
  69. package/src/model/free-discovery.ts +11 -78
  70. package/src/model/model-name.ts +14 -4
  71. package/src/model/profiles/claude.ts +1 -2
  72. package/src/model/profiles/openai.ts +1 -2
  73. package/src/model/profiles.ts +1 -2
  74. package/src/model/provider-capabilities.ts +16 -55
  75. package/src/model/routing.ts +39 -36
  76. package/src/pr/admission.ts +6 -6
  77. package/src/pr/answered-findings.ts +8 -4
  78. package/src/pr/ci-publish.ts +0 -2
  79. package/src/pr/discovery.ts +4 -25
  80. package/src/pr/plan.ts +40 -121
  81. package/src/pr/pr-status.ts +14 -2
  82. package/src/pr/preflight.ts +15 -12
  83. package/src/pr/publish-outcome.ts +1 -19
  84. package/src/pr/review-pr.ts +10 -47
  85. package/src/pr/target.ts +76 -82
  86. package/src/production-runtime.ts +52 -114
  87. package/src/progress.ts +0 -54
  88. package/src/rereview/prepare.ts +4 -1
  89. package/src/rereview/state.ts +1 -1
  90. package/src/review/boundary.ts +4 -8
  91. package/src/review/drafts.ts +3 -3
  92. package/src/review/findings-conformance.ts +1 -1
  93. package/src/review/findings.ts +0 -4
  94. package/src/review/pipeline.ts +57 -395
  95. package/src/review/preflight.ts +162 -201
  96. package/src/review/prompt-set.ts +0 -2
  97. package/src/review/report.ts +2 -162
  98. package/src/review/review.ts +16 -65
  99. package/src/review/route-preflight.ts +3 -35
  100. package/src/review/run.ts +37 -73
  101. package/src/review/size-gate.ts +3 -3
  102. package/src/review/spec.ts +6 -11
  103. package/src/review/step-runner.ts +4 -4
  104. package/src/runner-authority.ts +10 -9
  105. package/src/security/credential-broker.ts +5 -6
  106. package/src/server/preflight.ts +0 -1
  107. package/src/server/server.ts +17 -6
  108. package/src/store/activity.ts +1 -2
  109. package/src/store/backfill-preflight.ts +0 -3
  110. package/src/store/backfill.ts +0 -1
  111. package/src/store/metrics-preflight.ts +4 -14
  112. package/src/store/metrics.ts +5 -5
  113. package/src/store/preflight.ts +0 -13
  114. package/src/store/store.ts +11 -12
  115. package/src/transport-registry.ts +6 -30
  116. package/src/transports/claude-code-cli.ts +149 -215
  117. package/src/transports/opencode-client.ts +4 -24
  118. package/src/transports/opencode-sdk.ts +17 -112
  119. package/src/triage/plain-reply.ts +37 -0
  120. package/src/ui/activity.ts +1 -6
  121. package/src/ui/config-edit.ts +14 -67
  122. package/src/ui/config.ts +3 -8
  123. package/src/ui/plan.ts +11 -198
  124. package/src/ui/progress.ts +3 -49
  125. package/src/ui/result.ts +18 -77
  126. package/src/ui/review-menu.ts +3 -12
  127. package/src/ui/select.ts +9 -79
  128. package/src/updater.ts +1 -1
  129. package/src/usage.ts +1 -7
  130. package/prompts/default/deep-review-parity.md +0 -152
  131. package/prompts/scout.md +0 -140
  132. package/src/ci/platform-estimate.ts +0 -111
  133. package/src/review/scout.ts +0 -323
@@ -4,7 +4,7 @@
4
4
  // assembly) deterministic and testable here, and spends model tokens only on
5
5
  // the hunts and the refutation themselves.
6
6
 
7
- import { existsSync } from "node:fs";
7
+ import { existsSync, readFileSync } from "node:fs";
8
8
  import { chmod, mkdir, realpath } from "node:fs/promises";
9
9
  import path from "node:path";
10
10
  import {
@@ -136,7 +136,6 @@ import type { InternalCapabilityReport } from "../diversity/admission";
136
136
  import type { BenchmarkTarget } from "../diversity/identity";
137
137
  import {
138
138
  assertDiversityLegRoutes,
139
- assertDiversitySpendUnderCap,
140
139
  buildDiversityPipelineRecord,
141
140
  type DiversityExecutionContext,
142
141
  diversityDebugFromLedger,
@@ -172,6 +171,10 @@ import {
172
171
  attemptLogPath,
173
172
  settlementReceiptPath,
174
173
  } from "../execution/step-artifacts";
174
+ import {
175
+ type AttemptUsageFacts,
176
+ usageFactsPath,
177
+ } from "../execution/usage-facts";
175
178
  import type { NormalizedUsage } from "../execution/usage-normalized";
176
179
  import { sumNormalizedUsage } from "../execution/usage-normalized";
177
180
  import { redactEvidenceText } from "../security/evidence-redaction";
@@ -195,13 +198,6 @@ import {
195
198
  NO_REVIEW_INSTRUCTIONS,
196
199
  ownerPolicyText,
197
200
  } from "./preflight";
198
- import {
199
- capScoutLeads,
200
- renderLeadsBlock,
201
- type ScoutLead,
202
- scoutPrompt,
203
- validateScoutLeads,
204
- } from "./scout";
205
201
  import type { ExcludedPath } from "./size-gate";
206
202
  import {
207
203
  DEFAULT_STEP_MAX_ATTEMPTS,
@@ -289,7 +285,7 @@ export interface PipelineInput {
289
285
  // beside `pipelineTimeoutMs` and is injectable for the same reason: without
290
286
  // it every ceiling test would sleep 8.5 real seconds.
291
287
  ceilingGraceMs?: number;
292
- // `bundled` on the summarizer, scout and consolidate inputs (set by the
288
+ // `bundled` on the summarizer and consolidate inputs (set by the
293
289
  // product paths' pipeline*Input, #review/route-preflight) marks the engine's
294
290
  // own prompt, resolved through the active profile's prompt set: its model
295
291
  // and effort then come from the profile, never from its frontmatter
@@ -298,22 +294,14 @@ export interface PipelineInput {
298
294
  // Optional engine-owned summary step. It is deliberately outside ReviewSpec:
299
295
  // this prompt is bundled with pr-hero, not part of the benchmarked agent set.
300
296
  summarizer?: { promptPath: string; model?: string; bundled?: boolean };
301
- // Optional engine-owned scout step (ROADMAP-DOORDASH M5,
302
- // `docs/scout-design.md` §3.3). Outside ReviewSpec for the summarizer's
303
- // reason and one more of its own: `ReviewSpec.role` is
304
- // `"hunter" | "refuter"` with a runtime guard, so a scout cannot be a spec
305
- // entry without widening that union — and widening it would re-fingerprint
306
- // the prompt set, which is exactly what M6's one-variable property forbids.
307
- // ABSENT means the control pipeline, byte for byte.
308
- scout?: { promptPath: string; model?: string; bundled?: boolean };
309
297
  // Optional engine-owned consolidation pass over the POSTED findings, after
310
298
  // the refuter (prompts/consolidate.md, measured on the Martian 50: F1
311
299
  // 39.7 -> 42.3, lab bench/METRICS.md 2026-10-27). Opt-in on the engine input
312
300
  // so the lab's direct `runPipeline` callers are unchanged; the CLI and PR
313
301
  // paths turn it on. ABSENT means no consolidation step and findings exactly
314
302
  // as before; pipeline.json still carries a `consolidation` record
315
- // (`enabled: false`, `status: "skipped"`), the scout's rule, so the two
316
- // arms are told apart from the artifact alone.
303
+ // (`enabled: false`, `status: "skipped"`), so the two arms are told apart
304
+ // from the artifact alone.
317
305
  consolidate?: { promptPath: string; model?: string; bundled?: boolean };
318
306
  // The re-review verifier's own body (prompts/verifier.md), engine-owned.
319
307
  // The product's PR path passes it. ABSENT means the verify steps render the
@@ -324,7 +312,7 @@ export interface PipelineInput {
324
312
  // Optional engine-owned materiality gate (odd/tasks/materiality-gate.md):
325
313
  // an isolated judge reads every finding that would post as blocking and
326
314
  // demotes the immaterial ones to advisory. ABSENT means no judge step and
327
- // findings exactly as before (the scout's rule); pipeline.json still
315
+ // findings exactly as before; pipeline.json still
328
316
  // carries a `materiality` record (`enabled: false`, `status: "skipped"`).
329
317
  // No `model` seat on purpose: the judge runs only on a model it was
330
318
  // measured on (sonnet by default, opus through `models.judge`), and neither
@@ -397,7 +385,7 @@ export interface PipelineInput {
397
385
  // config's, as the routing config used to.
398
386
  routePlan?: ResolvedRoutePlan;
399
387
  models?: ModelsConfig;
400
- // Item 7: skip hunter (and scout) fan-out. A re-review whose restricted
388
+ // Item 7: skip hunter fan-out. A re-review whose restricted
401
389
  // delta is empty still classifies and verifies (C6); spawning hunters on
402
390
  // an empty patch would bill a first-review for nothing. Absent = run
403
391
  // hunters, so every existing caller stays byte-identical.
@@ -515,18 +503,6 @@ export type PipelineProgressEvent =
515
503
  // Same contract as hunter-finished's reason.
516
504
  reason?: string;
517
505
  }
518
- // The scout is the one AWAITED stage between "the run started" and the
519
- // first hunter spawn, and M4 measured it at 86-600s. Without a started
520
- // event that is up to ten minutes of a paid run looking hung — the exact
521
- // incident the progress tap was built for (see PipelineDeps.onProgress).
522
- | { kind: "scout-started"; model: string }
523
- | {
524
- kind: "scout-finished";
525
- ok: boolean;
526
- durationMs: number;
527
- // Leads DELIVERED to the hunters, post-cap. Absent for a failed step.
528
- leads?: number;
529
- }
530
506
  // A step about to be retried. Until this existed a retrying hunter looked
531
507
  // merely slow: `attempts` was counted in PerAgentUsage after the fact, which
532
508
  // is a post-mortem, never a live signal. OBSERVATION ONLY — the runner's
@@ -616,7 +592,6 @@ export interface PerAgentUsage {
616
592
  duration_ms: number;
617
593
  tokens_in: number;
618
594
  tokens_out: number;
619
- cost_usd_est: number;
620
595
  attempts: number;
621
596
  status: string;
622
597
  // Why a failed step failed, in the provider's own words: the transport's one-line
@@ -633,17 +608,14 @@ export interface PipelineResult {
633
608
  usage: SessionUsage;
634
609
  // #173: the run-level normalized rollup, the SAME object `pipeline.json`
635
610
  // publishes as its `usage_v2` key — handed to the caller so the terminal and
636
- // report.md can show cash and notional apart (§8: "Artifacts and reports
637
- // show cash and notional totals separately"). The legacy `usage` above
638
- // projects `cashCostUsd` only, and on a Claude subscription route that is a
639
- // truthful $0.00 with the list-basis figure living here instead.
611
+ // report.md can show the run's tokens and credential class.
640
612
  //
641
613
  // Taken off `state.usageTotalV2` rather than re-accumulated for the display
642
614
  // path: a second tally is the "parallel mechanism able to disagree with
643
615
  // per_agent" the per-step usage join site already refuses. Absent — never
644
616
  // zeroed — when no step reported normalized usage, because the display
645
- // surfaces key on `undefined` to omit their notional row, and a fabricated
646
- // zero would print a list-price claim for a run that produced none.
617
+ // surfaces key on `undefined` to omit their usage row, and a fabricated
618
+ // zero would print a claim for a run that produced none.
647
619
  usageV2?: NormalizedUsage;
648
620
  // True only when ALL hunter steps failed — nothing was hunted. A single
649
621
  // hunter failure is a partial run (prose Step 4: "proceed with whatever
@@ -948,17 +920,10 @@ const SUMMARY_OUTPUT_CONTRACT = [
948
920
  "The score_reason is 1-2 sentences explaining that advisory score.",
949
921
  ].join("\n");
950
922
 
951
- // `leadsBlock` defaults to the EMPTY STRING and an empty block contributes
952
- // nothing — not a separator, not a blank line (§3.8). That is what makes M6's
953
- // control arm a control arm: scout off, and scout on returning zero leads,
954
- // must both produce the byte-identical prompt an unled run produces. C4's
955
- // wrapBlock preserves that property by returning "" for empty content, so an
956
- // empty leads block still leaves no trace — not even an empty tag pair.
957
- //
958
- // Both non-engine blocks here are wrapped in the run's nonced boundary tags
923
+ // The non-engine blocks here are wrapped in the run's nonced boundary tags
959
924
  // (`docs/c4-preamble-design.md` §3.3-§3.4): the patch is the PR author's, and
960
- // the leads are model prose derived from it. `nonce` sits ahead of the
961
- // defaulted parameter so a caller cannot reach this composer without one.
925
+ // so is the intent. `nonce` sits ahead of the defaulted parameter so a caller
926
+ // cannot reach this composer without one.
962
927
  // The codegraph mandate, appended only when the run's MCP registry grants
963
928
  // codegraph (`codegraphGranted`).
964
929
  //
@@ -1012,7 +977,7 @@ async function codegraphGranted(mcpConfigPath: string): Promise<boolean> {
1012
977
  //
1013
978
  // WHY the hunters and nobody else: the refuter judges a claim against the code
1014
979
  // alone, so that an author cannot talk it out of a finding by saying the
1015
- // behaviour is intentional. The summarizer, scout, consolidation and
980
+ // behaviour is intentional. The summarizer, consolidation and
1016
981
  // adjudicator work from the diff or the findings and never see it either.
1017
982
  //
1018
983
  // WHY it renders to NOTHING when both are absent: a hunter's request without
@@ -1086,10 +1051,8 @@ function hunterPrompt(
1086
1051
  nonce: string,
1087
1052
  toolsEnabled: boolean,
1088
1053
  codegraph: boolean,
1089
- leadsBlock = "",
1090
1054
  intent: PrIntent = { title: "", description: "" },
1091
1055
  ): string {
1092
- const wrappedLeads = wrapBlock("scout_leads", nonce, leadsBlock);
1093
1056
  const wrappedTitle = wrapBlock("pr_title", nonce, intent.title);
1094
1057
  const wrappedDescription = wrapBlock(
1095
1058
  "pr_description",
@@ -1118,9 +1081,6 @@ function hunterPrompt(
1118
1081
  "`hops_used` and `hop_trail` are self-reported and may be cross-checked",
1119
1082
  "against this run's telemetry MCP-call counts.",
1120
1083
  "",
1121
- // Leads sit LAST before the contract so the diff is still what the hunter
1122
- // reads first (§3.8's block order).
1123
- ...(wrappedLeads.length === 0 ? [] : [wrappedLeads, ""]),
1124
1084
  hunterOutputContract(toolsEnabled),
1125
1085
  ].join("\n");
1126
1086
  }
@@ -1234,12 +1194,12 @@ function agentRoleEffort(input: PipelineInput, agent: AgentSpec): Effort {
1234
1194
  // profile's route for its role, never its frontmatter (S3), so the step
1235
1195
  // agrees with the plan (buildResolvedRoutePlan's `bundled`). Unmarked, its
1236
1196
  // frontmatter holds both seats; `profileFallback` says whether the profile
1237
- // still backs an absent `model:` there (scout, consolidate) or not
1197
+ // still backs an absent `model:` there (consolidate) or not
1238
1198
  // (summarizer, which has always failed without one).
1239
1199
  function enginePromptChoice(
1240
1200
  input: PipelineInput,
1241
1201
  prompt: { bundled?: boolean },
1242
- role: "summary" | "scout" | "consolidate",
1202
+ role: "summary" | "consolidate",
1243
1203
  parsed: ParsedAgent,
1244
1204
  profileFallback: boolean,
1245
1205
  ): { model?: string; effort?: Effort } {
@@ -1308,18 +1268,17 @@ interface StepMeta {
1308
1268
  outPath: string;
1309
1269
  // D1-10c. Stamped at CONSTRUCTION as "unsettled" and overwritten when the
1310
1270
  // step settles, so every row in a v1.0.0 plan answers "did this run" without
1311
- // the reader inferring anything from an absent key — ScoutRecord's rule below
1312
- // ("the key is missing" is indistinguishable from "this run predates the
1313
- // key"), applied to the eight steps that never had it.
1271
+ // the reader inferring anything from an absent key — ConsolidationRecord's rule
1272
+ // below ("the key is missing" is indistinguishable from "this run predates
1273
+ // the key"), applied to the eight steps that never had it.
1314
1274
  //
1315
1275
  // WHY "unsettled" and not "not-run" or "skipped":
1316
1276
  // - "not-run" would LIE about the commonest case. When the pipeline ceiling
1317
1277
  // fires, the steps in flight had already been spawned and had already
1318
1278
  // burned tokens; they simply never came back before the snapshot. A row
1319
1279
  // claiming they never ran contradicts their own attempt logs on disk.
1320
- // - "skipped" is taken, three declarations down, and means something else:
1321
- // ScoutRecord uses it for "the flag was off, the stage was never asked
1322
- // for". Two neighbouring records spelling one word two ways is how a
1280
+ // - "skipped" is taken, below, and means something else:
1281
+ // ConsolidationRecord uses it for "the stage was never asked for". Two neighbouring records spelling one word two ways is how a
1323
1282
  // reader learns the wrong meaning.
1324
1283
  // "unsettled" is true of both reachable cases — never spawned, and spawned
1325
1284
  // but abandoned — and claims nothing beyond "no terminal verdict reached
@@ -1348,6 +1307,10 @@ interface StepMeta {
1348
1307
  // relative to the run dir. Absent when none were copied, so a failed
1349
1308
  // capture names no file and a pipeline.json from before traces still parses.
1350
1309
  tracePaths?: string[];
1310
+ // platform-owned-cost T6: what each attempt measured per model request, as the
1311
+ // harness wrote it (execution/usage-facts.ts), in attempt order. The platform
1312
+ // report copies it into its `usage_facts`. Absent when no attempt wrote one.
1313
+ usage_facts?: AttemptUsageFacts[];
1351
1314
  // D1-08 PR2 (§8): the step's normalized usage, attached by recordSettlement
1352
1315
  // — the single existing usage join site (D1-10c's own comment: a second
1353
1316
  // pass over `state.steps` "would be a parallel mechanism able to disagree
@@ -1387,34 +1350,8 @@ interface StepMeta {
1387
1350
  }>;
1388
1351
  }
1389
1352
 
1390
- // pipeline.json's `scout` key (§3.9). Written on EVERY run, including one
1391
- // with no scout at all: M6 has to be able to tell the two arms apart from the
1392
- // artifact alone, and "the key is missing" is indistinguishable from "this run
1393
- // predates the key".
1394
- interface ScoutRecord {
1395
- enabled: boolean;
1396
- model?: string;
1397
- // "skipped" is the flag being off. "failed" and "ok" both mean the stage
1398
- // was asked for — a failed scout is a CONTROL-arm run wearing a scout-arm
1399
- // flag, and §3.6's M6 rule excludes and re-runs it on exactly this field.
1400
- status: "ok" | "failed" | "skipped";
1401
- // DELIVERED leads, post-cap — the number the hunters actually saw.
1402
- leads_count: number;
1403
- // Leads the caps dropped. A truncation that fires routinely is a PROMPT
1404
- // defect to fix, never a cap to raise (§3.8), so it is recorded per run
1405
- // rather than left to a probe nobody re-runs.
1406
- leads_truncated: number;
1407
- // `why` sentences the 240-char cap cut. Additive beyond §3.9's list, and
1408
- // deliberately: M5 INHERITS this defect from M4 (it fired in most runs), and
1409
- // a defect nothing counts in production is a defect nobody notices.
1410
- why_truncated: number;
1411
- prompt_sha256?: string;
1412
- duration_ms: number;
1413
- }
1414
-
1415
- // pipeline.json's `consolidation` key, written on every run for ScoutRecord's
1416
- // reason: "the key is missing" is indistinguishable from "this run predates
1417
- // the key". "skipped" means the stage was not asked for (or the ceiling cut
1353
+ // pipeline.json's `consolidation` key, written on every run: "the key is
1354
+ // missing" is indistinguishable from "this run predates the key". "skipped" means the stage was not asked for (or the ceiling cut
1418
1355
  // the run first); "passthrough" means it was asked for and had nothing it
1419
1356
  // could safely do (no posted findings, or a claim carrying the nonce), so it
1420
1357
  // never spawned; "failed" means it was asked for and its plan was not applied.
@@ -1433,8 +1370,8 @@ interface ConsolidationRecord {
1433
1370
  duration_ms: number;
1434
1371
  }
1435
1372
 
1436
- // pipeline.json's `materiality` key, written on every run for ScoutRecord's
1437
- // reason: "the key is missing" is indistinguishable from "this run predates
1373
+ // pipeline.json's `materiality` key, written on every run for
1374
+ // ConsolidationRecord's reason: "the key is missing" is indistinguishable from "this run predates
1438
1375
  // the key". "skipped" means the gate was not asked for; "ceiling" means it was
1439
1376
  // asked for and the pipeline ceiling (or its budget) stood it down before it
1440
1377
  // spawned; "unsupported_route" means the judge would not have run the
@@ -1473,7 +1410,6 @@ interface RunState {
1473
1410
  // after the hunters', and a captured undefined would silently disable the
1474
1411
  // check on exactly the leg that motivated the issue.
1475
1412
  resolveProofRef?: (candidate: string) => boolean;
1476
- scout?: ScoutRecord;
1477
1413
  consolidation?: ConsolidationRecord;
1478
1414
  // Set only by a consolidation step that returned a VALID plan. finish()
1479
1415
  // applies it; the ceiling path reaches finish() without one and so never
@@ -1568,7 +1504,7 @@ interface RunState {
1568
1504
  // D1-08 PR2: the run-level rollup of every step's normalized usage, summed
1569
1505
  // via `accumulateUsageV2` alongside each existing `usageTotal` accumulation
1570
1506
  // site. `undefined` until the first step reports `usageV2` — seeding it
1571
- // with a billingMode/costSource-less zero would force `sumNormalizedUsage`
1507
+ // with a billingMode-less zero would force `sumNormalizedUsage`
1572
1508
  // to collapse the run's real billing mode to "unknown" on the first sum.
1573
1509
  usageTotalV2?: NormalizedUsage;
1574
1510
  steps: StepMeta[];
@@ -1828,15 +1764,6 @@ async function execute(
1828
1764
  // ignore if not readable
1829
1765
  }
1830
1766
  }
1831
- let scoutFrontmatter: string | undefined;
1832
- if (input.scout && input.scout.bundled !== true) {
1833
- try {
1834
- const parsed = await parseAgentFile(input.scout.promptPath);
1835
- scoutFrontmatter = parsed.model;
1836
- } catch {
1837
- // ignore if not readable
1838
- }
1839
- }
1840
1767
  let consolidateFrontmatter: string | undefined;
1841
1768
  if (input.consolidate && input.consolidate.bundled !== true) {
1842
1769
  try {
@@ -1863,15 +1790,6 @@ async function execute(
1863
1790
  bundled: input.summarizer.bundled === true,
1864
1791
  },
1865
1792
  }),
1866
- ...(input.scout === undefined
1867
- ? {}
1868
- : {
1869
- scout: {
1870
- model: input.scout.model,
1871
- frontmatterModel: scoutFrontmatter,
1872
- bundled: input.scout.bundled === true,
1873
- },
1874
- }),
1875
1793
  ...(input.consolidate === undefined
1876
1794
  ? {}
1877
1795
  : {
@@ -1977,8 +1895,7 @@ async function execute(
1977
1895
 
1978
1896
  // Step 3a — the run's boundary nonce (C4 O-3.3). HERE, once, and identical
1979
1897
  // for every step of this run: a per-step nonce would give each step a
1980
- // different prompt for the same bytes, and M6's control arm is a byte
1981
- // comparison. Drawn against exactly the blocks that already exist — the
1898
+ // different prompt for the same bytes, and runs are compared byte for byte. Drawn against exactly the blocks that already exist — the
1982
1899
  // patch, the operator gotchas, the operator priors, the author's intent —
1983
1900
  // because those are the only ones whose content is fixed before the draw.
1984
1901
  // `renderPriorsBlock` is called here and again inside `renderAgentBody` on
@@ -2004,19 +1921,6 @@ async function execute(
2004
1921
 
2005
1922
  const stepsDir = path.join(input.runDir, "steps");
2006
1923
 
2007
- // Step 3b — the scout (ROADMAP-DOORDASH M5). Here and not elsewhere: after
2008
- // `patch` and the trigger decision exist, strictly before the hunter
2009
- // composition loop that consumes its leads. It is AWAITED, unlike the
2010
- // summarizer, which puts it on the critical path — the cost this design
2011
- // states out loud (§3.9) rather than hiding.
2012
- // A ceiling that fired before the scout was even spawned skips it and hunts
2013
- // without leads — the control pipeline's shape, which is a degraded run, not
2014
- // a broken one.
2015
- const leadsBlock =
2016
- skipDiscovery || ceilingAborted(deps, state)
2017
- ? ""
2018
- : await runScout(input, deps, state, patch, stepsDir, boundaryNonce);
2019
-
2020
1924
  // Step 4 — hunter fan-out.
2021
1925
  const stepTimeoutMs = input.stepTimeoutMs ?? DEFAULT_STEP_TIMEOUT_MS;
2022
1926
  // §5.3 admission, checked BEFORE the composition loop and not at the join:
@@ -2053,7 +1957,6 @@ async function execute(
2053
1957
  boundaryNonce,
2054
1958
  agent.tools.length > 0,
2055
1959
  codegraph && agent.tools.includes(CODEGRAPH_TOOL),
2056
- leadsBlock,
2057
1960
  prIntent,
2058
1961
  );
2059
1962
  // The rendered body is written run-dir-side as an audit artifact: the
@@ -2454,7 +2357,6 @@ async function execute(
2454
2357
  ),
2455
2358
  };
2456
2359
  state.diversity = diversityCtx;
2457
- assertDiversitySpendUnderCap(plan, diversityCtx.ledger);
2458
2360
  }
2459
2361
  if (result.status !== "ok") {
2460
2362
  state.hunterFailures++;
@@ -2897,7 +2799,7 @@ async function runRefuter(
2897
2799
  state.verdicts.set(id, "inconclusive");
2898
2800
  }
2899
2801
  // The spec carries ONE refuter agent, so its telemetry stays one row —
2900
- // token and cost fields summed across the steps it fanned into, which keeps
2802
+ // token fields summed across the steps it fanned into, which keeps
2901
2803
  // `per_agent` totals reconcilable against the run total. `duration_ms` is the
2902
2804
  // one field that cannot be summed: it reports the leg's measured elapsed
2903
2805
  // time. `attempts` IS a sum on purpose — N steps have no single attempt
@@ -2909,7 +2811,6 @@ async function runRefuter(
2909
2811
  duration_ms: legElapsedMs,
2910
2812
  tokens_in: usage.tokens_in,
2911
2813
  tokens_out: usage.tokens_out,
2912
- cost_usd_est: usage.cost_usd_est,
2913
2814
  attempts,
2914
2815
  status: anyFailed ? "failed" : "ok",
2915
2816
  ...(anyFailed ? firstFailureDetail(settled) : {}),
@@ -3104,7 +3005,6 @@ async function runVerify(
3104
3005
  duration_ms: legElapsedMs,
3105
3006
  tokens_in: usage.tokens_in,
3106
3007
  tokens_out: usage.tokens_out,
3107
- cost_usd_est: usage.cost_usd_est,
3108
3008
  attempts,
3109
3009
  status: anyFailed ? "failed" : "ok",
3110
3010
  ...(anyFailed ? firstFailureDetail(settled) : {}),
@@ -3258,7 +3158,6 @@ async function runAdjudicate(
3258
3158
  duration_ms: legElapsedMs,
3259
3159
  tokens_in: usage.tokens_in,
3260
3160
  tokens_out: usage.tokens_out,
3261
- cost_usd_est: usage.cost_usd_est,
3262
3161
  attempts,
3263
3162
  status: anyFailed ? "failed" : "ok",
3264
3163
  ...(anyFailed ? firstFailureDetail(settled) : {}),
@@ -3268,251 +3167,9 @@ async function runAdjudicate(
3268
3167
  return outcomes;
3269
3168
  }
3270
3169
 
3271
- // The scout's non-hunter budgets (§3.5 mechanism 4), and the one number here
3272
- // that departs from the ratified design: §3.5 says "a 5-minute watchdog",
3273
- // copying the summarizer. M4 then MEASURED the stage at 86-600s across 60
3274
- // spawns and raised its own probe watchdog from 10 to 15 minutes on that
3275
- // evidence (§3.10bis). A 5-minute ceiling would reap runs the only data we
3276
- // have calls normal, so the measurement wins over the estimate that preceded
3277
- // it. One attempt is unchanged: a scout that could not answer once has
3278
- // nothing the run needs badly enough to pay twice for.
3279
- const SCOUT_TIMEOUT_MS = 15 * 60 * 1000;
3280
-
3281
- // Last resort in the model chain, and it exists because `prompts/scout.md`
3282
- // deliberately carries NO `model:` frontmatter: that file is M4's ratified
3283
- // artifact (sha256 68a81d26081e, v5), and adding a line to it would move the
3284
- // sha the milestone recorded for a prompt whose body nothing changed.
3285
- //
3286
- // The value is not a taste call either. M4 ran every one of its 60 measured
3287
- // spawns on sonnet (`scripts/scout-probe.ts` defaults to it and never reads
3288
- // the prompt's frontmatter), and M6's whole control corpus is sonnet (§1.2) —
3289
- // so this is the model the scout has actually been measured on, and the model
3290
- // the A/B will run it on. `--scout-model` is the documented exit; the cheap
3291
- // tier is its own later experiment (§3.13), not a variable inside M6. Read
3292
- // from the `claude` profile, which holds the value now (model-profiles S2).
3293
- export const DEFAULT_SCOUT_MODEL = profileModelAlias(
3294
- profileRoute(FALLBACK_PROFILE, "scout").model,
3295
- );
3296
-
3297
- // Runs the scout and returns the block to append to every hunter prompt —
3298
- // the EMPTY STRING whenever there is nothing to append, which covers all four
3299
- // quiet paths: the flag is off, the prompt file would not parse, the step
3300
- // failed, and the scout honestly found nothing.
3301
- //
3302
- // FAIL-OPEN, and it is the load-bearing property (§3.6): nothing in here sets
3303
- // `state.partial`. A run without a scout is the CONTROL pipeline, which is by
3304
- // definition complete — it cannot have lost a finding it was never going to
3305
- // produce. #42's incompleteness notice is about a review that lost a hunter or
3306
- // the refuter, which is a different thing and stays untouched. What this must
3307
- // never be is SILENT, so the failure lands in `pipeline.json` (`status`), in
3308
- // `per_agent.scout`, and on the progress tap.
3309
- async function runScout(
3310
- input: PipelineInput,
3311
- deps: PipelineDeps,
3312
- state: RunState,
3313
- patch: string,
3314
- stepsDir: string,
3315
- nonce: string,
3316
- ): Promise<string> {
3317
- if (!input.scout) {
3318
- state.scout = {
3319
- enabled: false,
3320
- status: "skipped",
3321
- leads_count: 0,
3322
- leads_truncated: 0,
3323
- why_truncated: 0,
3324
- duration_ms: 0,
3325
- };
3326
- return "";
3327
- }
3328
-
3329
- const name = "scout";
3330
- const systemPromptPath = path.join(stepsDir, `${name}.system.md`);
3331
- // The RAW validated leads, pre-cap, beside every other step's output — the
3332
- // runner writes it. Capping happens in the driver afterwards, so the
3333
- // artifact records what the scout SAID and pipeline.json records what the
3334
- // hunters were given; collapsing the two would delete the evidence that a
3335
- // cap fired at all.
3336
- const outPath = path.join(stepsDir, `${name}.leads.json`);
3337
- const meta: StepMeta = {
3338
- name,
3339
- model: input.scout.model ?? input.model ?? "unresolved",
3340
- effort: profileRoleEffort(activeProfile(input), "scout"),
3341
- // FORCED to empty here, never read from the prompt file's frontmatter.
3342
- // §3.5 mechanism 1 — "the scout cannot open a file, grep, or walk a call
3343
- // graph" — is the guarantee this whole design rests on, and a guarantee a
3344
- // prompt edit can revoke is not a guarantee. `model:` in that frontmatter
3345
- // is still honoured; `tools:` is not.
3346
- tools: [],
3347
- systemPromptPath,
3348
- outPath,
3349
- // Same construction-time default `stepMeta()` stamps; this meta is built by
3350
- // hand because the scout resolves its model and tools as it goes.
3351
- status: "unsettled",
3352
- };
3353
- const record: ScoutRecord = {
3354
- enabled: true,
3355
- model: meta.model,
3356
- // Pessimistic default: every early return below is a failure, and only
3357
- // the delivered path overwrites it.
3358
- status: "failed",
3359
- leads_count: 0,
3360
- leads_truncated: 0,
3361
- why_truncated: 0,
3362
- duration_ms: 0,
3363
- };
3364
- state.scout = record;
3365
- const startedAt = Date.now();
3366
-
3367
- const abandon = (error?: unknown): string => {
3368
- // Status only. `attempts` and the two pointers are NOT cleared here on
3369
- // purpose: `abandon` is reached by three different roads — a prompt file
3370
- // that never parsed, a runner that threw, and a step that SETTLED and then
3371
- // failed (or delivered leads that forged the nonce). On that third road a
3372
- // paid attempt really ran and really wrote its log and receipt, and those
3373
- // are already recorded by the time this runs. Overwriting them with
3374
- // "nothing happened" would erase the only evidence separating a scout that
3375
- // burned money from one that never spawned. A pre-attempt failure has
3376
- // none of those artifacts, so the reason lands on the step itself (#199)
3377
- // and is not written over a reason recordSettlement already kept.
3378
- if (
3379
- (meta.attempts === undefined || meta.attempts < 1) &&
3380
- meta.failure === undefined
3381
- ) {
3382
- recordStepFailure(meta, error ?? "scout failed before its first attempt");
3383
- } else {
3384
- meta.status = "failed";
3385
- }
3386
- state.perAgent.scout ??= failedAgentEntry();
3387
- record.duration_ms = Date.now() - startedAt;
3388
- emit(deps, {
3389
- kind: "scout-finished",
3390
- ok: false,
3391
- durationMs: record.duration_ms,
3392
- });
3393
- return "";
3394
- };
3395
-
3396
- let spec: StepSpec;
3397
- try {
3398
- // Read once, hashed and parsed from the same bytes: a fingerprint over a
3399
- // second read could disagree with the prompt that actually ran.
3400
- const raw = await Bun.file(input.scout.promptPath).text();
3401
- const agent = parseAgentSource(raw);
3402
- await writeSystemPrompt(systemPromptPath, agent.body);
3403
- // Precedence, the JD rule extended one seat: --model > --scout-model >
3404
- // the prompt's frontmatter > the active profile's scout. The profile sits
3405
- // LAST so a frontmatter model added later still outranks it, unless the
3406
- // prompt is the engine's own (`bundled`), whose seat is the profile's.
3407
- const own = enginePromptChoice(input, input.scout, "scout", agent, true);
3408
- meta.model = resolveModel(
3409
- input,
3410
- input.scout.model,
3411
- own.model,
3412
- input.scout.promptPath,
3413
- );
3414
- record.model = meta.model;
3415
- const scoutEffort = stepEffortFields(
3416
- state.routePlan,
3417
- name,
3418
- own.effort,
3419
- profileRoleEffort(activeProfile(input), "scout"),
3420
- );
3421
- meta.effort = scoutEffort.effort;
3422
- // FULL sha256, not the 12 chars the probe prints: the probe's artifact
3423
- // stores the full digest too, so a pipeline.json and a scout-probe.json
3424
- // naming the same prompt say the same string.
3425
- record.prompt_sha256 = new Bun.CryptoHasher("sha256")
3426
- .update(raw)
3427
- .digest("hex");
3428
- spec = {
3429
- name,
3430
- systemPromptPath,
3431
- prompt: scoutPrompt(patch, nonce),
3432
- tools: meta.tools,
3433
- mcpConfigPath: input.mcpConfigPath,
3434
- model: meta.model,
3435
- ...scoutEffort,
3436
- cwd: input.worktree,
3437
- outPath,
3438
- timeoutMs: SCOUT_TIMEOUT_MS,
3439
- maxAttempts: 1,
3440
- ...stepRouteFields(state.routePlan, name),
3441
- parse: (finalText) => {
3442
- const extracted = extractJsonObject(finalText);
3443
- if (extracted === undefined) {
3444
- throw new Error("scout final message has no JSON object");
3445
- }
3446
- return validateScoutLeads(extracted);
3447
- },
3448
- onRetry: (info) => emit(deps, { kind: "step-retry", ...info }),
3449
- };
3450
- } catch (error) {
3451
- // A missing or malformed prompt file. The step still appears in the plan
3452
- // with status "failed": a stage that was asked for and never spawned must
3453
- // be visible, or the artifact reads like the flag was off.
3454
- state.steps.push(meta);
3455
- return abandon(error);
3456
- }
3457
-
3458
- if (spec.route !== undefined) {
3459
- meta.route = spec.route;
3460
- Object.assign(meta, routeEffortFields(spec.route));
3461
- const routedModel = effectiveExecutionModel(spec);
3462
- meta.model = routedModel;
3463
- record.model = routedModel;
3464
- }
3465
- state.steps.push(meta);
3466
- emit(deps, { kind: "scout-started", model: meta.model });
3467
-
3468
- let result: StepResult;
3469
- try {
3470
- result = await deps.runner.run(spec);
3471
- } catch (error) {
3472
- return abandon(error);
3473
- }
3474
- // Usage lands in BOTH seats whatever the verdict — a failed step still
3475
- // burned tokens, and a run whose bill excludes them under-reports the arm's
3476
- // cost, which is one of the numbers M6 exists to compare.
3477
- state.perAgent.scout = perAgentEntry(result);
3478
- // BEFORE the verdict branches below, so every road that ends in `abandon`
3479
- // still carries the attempt count and pointers of the session that ran.
3480
- recordSettlement(meta, result, input.runDir);
3481
- // The model that ran, when the scout fell back to another (S4).
3482
- record.model = meta.model;
3483
- state.usageTotal = sumUsage(state.usageTotal, result.usage);
3484
- accumulateUsageV2(state, result);
3485
- if (result.status !== "ok") return abandon();
3486
-
3487
- const capped = capScoutLeads(result.output as ScoutLead[]);
3488
- const block = renderLeadsBlock(capped.leads);
3489
- // The leads are written by a model that READ the nonce in its own prompt, so
3490
- // a `why` sentence quoting the patch's boundary tag back at us is the real
3491
- // way this trips — not a random 1-in-2^32 draw. The nonce cannot be
3492
- // re-drawn here (the scout's paid spawn already carried it, and every step
3493
- // of a run must share one), so the leads are dropped and the run continues
3494
- // as the unled CONTROL pipeline. Routed through `abandon` on purpose: the
3495
- // hunters were not led, which is exactly what a failed scout means, and
3496
- // `abandon` is what already records that in all three places.
3497
- if (blockForgesNonce(block, nonce)) return abandon();
3498
- meta.status = "ok";
3499
- record.status = "ok";
3500
- record.leads_count = capped.leads.length;
3501
- record.leads_truncated = capped.dropped;
3502
- record.why_truncated = capped.whyTruncated;
3503
- record.duration_ms = Date.now() - startedAt;
3504
- emit(deps, {
3505
- kind: "scout-finished",
3506
- ok: true,
3507
- durationMs: record.duration_ms,
3508
- leads: capped.leads.length,
3509
- });
3510
- return renderLeadsBlock(capped.leads);
3511
- }
3512
-
3513
3170
  // The consolidator's budgets, copied from the measurement that justified the
3514
3171
  // stage (scripts/consolidate-replay.ts): one claims-only call, so ten minutes
3515
- // is generous, and two attempts because unlike the scout a lost answer here
3172
+ // is generous, and two attempts because a lost answer here
3516
3173
  // is a lost precision gain on findings the run already paid for.
3517
3174
  const CONSOLIDATE_TIMEOUT_MS = 10 * 60 * 1000;
3518
3175
  const CONSOLIDATE_MAX_ATTEMPTS = 2;
@@ -3632,9 +3289,9 @@ async function runConsolidation(
3632
3289
  name,
3633
3290
  model: input.consolidate.model ?? input.model ?? "unresolved",
3634
3291
  effort: defaultEffortForRole("other"),
3635
- // FORCED to empty, never read from the prompt's frontmatter, for the
3636
- // scout's reason: the stage is measured as claims-only, and a guarantee a
3637
- // prompt edit can revoke is not a guarantee.
3292
+ // FORCED to empty, never read from the prompt's frontmatter: the stage is
3293
+ // measured as claims-only, and a guarantee a prompt edit can revoke is not
3294
+ // a guarantee.
3638
3295
  tools: [],
3639
3296
  systemPromptPath,
3640
3297
  outPath,
@@ -3644,8 +3301,8 @@ async function runConsolidation(
3644
3301
  const startedAt = Date.now();
3645
3302
 
3646
3303
  const abandon = (reason: string, error?: unknown): void => {
3647
- // The scout's rule: keep the attempt count and pointers of a session that
3648
- // really ran; only a pre-attempt failure lands its reason on the step.
3304
+ // Keep the attempt count and pointers of a session that really ran; only a
3305
+ // pre-attempt failure lands its reason on the step.
3649
3306
  if (
3650
3307
  (meta.attempts === undefined || meta.attempts < 1) &&
3651
3308
  meta.failure === undefined
@@ -4019,9 +3676,8 @@ async function runMaterialityJudge(
4019
3676
  systemPromptPath,
4020
3677
  prompt,
4021
3678
  // FORCED to empty, never read from the prompt's frontmatter, for the
4022
- // scout's and the consolidation pass's reason: the judge is measured
4023
- // without tools, and a guarantee a prompt edit can revoke is not a
4024
- // guarantee.
3679
+ // consolidation pass's reason: the judge is measured without tools, and a
3680
+ // guarantee a prompt edit can revoke is not a guarantee.
4025
3681
  tools: [],
4026
3682
  mcpConfigPath,
4027
3683
  // PINNED, never `input.model` or the frontmatter: the measured judge is
@@ -4083,7 +3739,6 @@ async function runMaterialityJudge(
4083
3739
  duration_ms: Date.now() - startedAt,
4084
3740
  tokens_in: usage.tokens_in,
4085
3741
  tokens_out: usage.tokens_out,
4086
- cost_usd_est: usage.cost_usd_est,
4087
3742
  attempts,
4088
3743
  status: record.failed > 0 ? "failed" : "ok",
4089
3744
  ...(record.failed > 0 ? firstFailureDetail(settled) : {}),
@@ -4399,7 +4054,6 @@ function collectUnresolvedSpend(state: RunState): UnresolvedSpend[] {
4399
4054
  step: step.name,
4400
4055
  bucketId: reservation.bucketId,
4401
4056
  reservationId: reservation.reservationId,
4402
- knownUsd: reservation.knownUsd,
4403
4057
  });
4404
4058
  }
4405
4059
  }
@@ -4478,14 +4132,13 @@ async function writePipelinePlan(
4478
4132
  ...(state.boundaryNonce === undefined
4479
4133
  ? {}
4480
4134
  : { boundary_nonce: state.boundaryNonce }),
4481
- ...(state.scout === undefined ? {} : { scout: state.scout }),
4482
4135
  ...(state.consolidation === undefined
4483
4136
  ? {}
4484
4137
  : { consolidation: state.consolidation }),
4485
- // Unconditional, unlike the two above: every road to this write (the
4138
+ // Unconditional, unlike the one above: every road to this write (the
4486
4139
  // gotchas early return included) records whether the gate was asked for.
4487
4140
  materiality: state.materiality ?? skippedMateriality(input, state),
4488
- // `--shared-prefix` arm identity, read off the artifact like `scout`: a run
4141
+ // `--shared-prefix` arm identity, read off the artifact: a run
4489
4142
  // whose hunters all sit in groups of one has no warm-up row to tell it
4490
4143
  // from control. Absent means the control layout, byte for byte.
4491
4144
  ...(input.sharedPrefix === true ? { shared_prefix: true } : {}),
@@ -4673,7 +4326,6 @@ function perAgentEntry(result: StepResult): PerAgentUsage {
4673
4326
  duration_ms: result.usage.wall_ms,
4674
4327
  tokens_in: result.usage.tokens_in,
4675
4328
  tokens_out: result.usage.tokens_out,
4676
- cost_usd_est: result.usage.cost_usd_est,
4677
4329
  attempts: result.attempts,
4678
4330
  status: result.status,
4679
4331
  ...detailField(result.status === "ok" ? undefined : result),
@@ -4707,7 +4359,6 @@ function failedAgentEntry(): PerAgentUsage {
4707
4359
  duration_ms: 0,
4708
4360
  tokens_in: 0,
4709
4361
  tokens_out: 0,
4710
- cost_usd_est: 0,
4711
4362
  attempts: 0,
4712
4363
  status: "failed",
4713
4364
  };
@@ -4784,7 +4435,7 @@ function stepMeta(spec: StepSpec): StepMeta {
4784
4435
  tools: spec.tools,
4785
4436
  systemPromptPath: spec.systemPromptPath,
4786
4437
  outPath: spec.outPath,
4787
- // Pessimistic at construction, exactly like ScoutRecord's `status`: a step
4438
+ // Pessimistic at construction: a step
4788
4439
  // is pushed into the plan BEFORE it is spawned, and the ceiling can
4789
4440
  // snapshot at any instant after that. Only a settled step overwrites this.
4790
4441
  status: "unsettled",
@@ -4906,6 +4557,17 @@ function recordSettlement(
4906
4557
  }
4907
4558
  }
4908
4559
  if (tracePaths.length > 0) meta.tracePaths = tracePaths;
4560
+ const usageFacts: AttemptUsageFacts[] = [];
4561
+ for (let attempt = 1; attempt <= result.attempts; attempt++) {
4562
+ const file = usageFactsPath(meta.outPath, meta.name, attempt);
4563
+ if (!existsSync(file)) continue;
4564
+ try {
4565
+ usageFacts.push(JSON.parse(readFileSync(file, "utf8")));
4566
+ } catch {
4567
+ // The harness writes it atomically; an unreadable one names no requests.
4568
+ }
4569
+ }
4570
+ if (usageFacts.length > 0) meta.usage_facts = usageFacts;
4909
4571
  }
4910
4572
 
4911
4573
  // A step that reached a terminal verdict WITHOUT a StepResult: the spec never