crysk 0.6.1 → 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 (179) hide show
  1. package/README.md +28 -22
  2. package/dist/SKILL-1q3658n0.md +74 -0
  3. package/dist/SKILL-25j4q9b8.md +143 -0
  4. package/dist/SKILL-32cmme3j.md +143 -0
  5. package/dist/SKILL-4747bhne.md +143 -0
  6. package/dist/SKILL-4jc3sv23.md +74 -0
  7. package/dist/SKILL-c0492rch.md +540 -0
  8. package/dist/SKILL-d1nzkhhr.md +74 -0
  9. package/dist/SKILL-f8p7kvx0.md +143 -0
  10. package/dist/SKILL-gxd45g38.md +553 -0
  11. package/dist/SKILL-rec41991.md +66 -0
  12. package/dist/SKILL-zze8zj5g.md +536 -0
  13. package/dist/adjudicator-eckqh14e.md +78 -0
  14. package/dist/ci-admission-qn797a6c.md +128 -0
  15. package/dist/cli.js +18608 -18523
  16. package/dist/consolidate-4xw1pkg7.md +24 -0
  17. package/dist/deep-review-logic-dgr112y1.md +196 -0
  18. package/dist/deep-review-logic-fck5z4xe.md +197 -0
  19. package/dist/deep-review-logic-h1fpamfh.md +192 -0
  20. package/dist/deep-review-logic-m4vk5683.md +196 -0
  21. package/dist/deep-review-logic-z63kmgmc.md +157 -0
  22. package/dist/deep-review-parity-7x7s5d81.md +148 -0
  23. package/dist/deep-review-parity-9wxmynsc.md +115 -0
  24. package/dist/deep-review-parity-bwwe7cx6.md +152 -0
  25. package/dist/deep-review-parity-e50pw3pk.md +117 -0
  26. package/dist/deep-review-parity-ennmm9m1.md +151 -0
  27. package/{prompts/default/deep-review-parity.md → dist/deep-review-parity-h7y6y2he.md} +14 -16
  28. package/dist/deep-review-parity-xg6wy69c.md +151 -0
  29. package/dist/deep-review-reliability-6h3c4gmw.md +125 -0
  30. package/dist/deep-review-reliability-dcjab69x.md +122 -0
  31. package/dist/deep-review-reliability-ec7b5pbk.md +159 -0
  32. package/dist/deep-review-reliability-hvasvmt9.md +153 -0
  33. package/dist/deep-review-reliability-mjnayxmt.md +158 -0
  34. package/dist/deep-review-reliability-mm7fnayf.md +124 -0
  35. package/dist/deep-review-reliability-xk4xvc2w.md +158 -0
  36. package/dist/deep-review-resilience-0esd5qeh.md +148 -0
  37. package/dist/deep-review-resilience-envgcmpy.md +115 -0
  38. package/dist/deep-review-resilience-fgx8ythf.md +151 -0
  39. package/dist/deep-review-resilience-mq5qa6ad.md +152 -0
  40. package/dist/deep-review-resilience-pwh1gawp.md +151 -0
  41. package/dist/deep-review-resilience-s9n21dkx.md +117 -0
  42. package/dist/deep-review-resilience-vz4qskea.md +119 -0
  43. package/dist/deep-review-security-1vwjdc9q.md +205 -0
  44. package/dist/deep-review-security-x1cc1z00.md +205 -0
  45. package/dist/index.js +590 -485
  46. package/dist/opencode-ci-jc8mf4wn.md +106 -0
  47. package/dist/opencode-ci-qrcv7a99.md +106 -0
  48. package/dist/opencode-ci-rdpcc7xc.md +106 -0
  49. package/dist/opencode-ci-yt0k74t0.md +106 -0
  50. package/dist/review-refuter-7qffwtzz.md +77 -0
  51. package/dist/verifier-tyh8r45v.md +40 -0
  52. package/dist/verifier-xf4xj701.md +40 -0
  53. package/dist/workflow-andv2dvm.yml +158 -0
  54. package/package.json +1 -1
  55. package/prompts/consolidate.md +1 -1
  56. package/prompts/default/PROVENANCE.md +6 -0
  57. package/prompts/default/deep-review-logic.md +56 -15
  58. package/prompts/default/deep-review-reliability.md +64 -30
  59. package/prompts/default/deep-review-resilience.md +71 -37
  60. package/prompts/default/deep-review-security.md +205 -0
  61. package/prompts/default/review-refuter.md +1 -1
  62. package/prompts/verifier.md +40 -0
  63. package/skills/crysk/SKILL.md +6 -6
  64. package/skills/crysk-ci-setup/SKILL.md +32 -33
  65. package/skills/crysk-ci-setup/assets/workflow.yml +5 -10
  66. package/skills/crysk-ci-setup/references/ci-admission.md +5 -5
  67. package/skills/crysk-ci-setup/references/opencode-ci.md +6 -6
  68. package/skills/crysk-loop/SKILL.md +37 -54
  69. package/skills/crysk-loop/adjudicator.md +10 -18
  70. package/skills/crysk-pr/SKILL.md +1 -1
  71. package/src/asset-manifest.ts +6 -6
  72. package/src/assets.ts +4 -4
  73. package/src/brand.ts +20 -30
  74. package/src/ci/gates.ts +155 -192
  75. package/src/ci/outcome.ts +4 -31
  76. package/src/ci/platform-limits.ts +135 -0
  77. package/src/ci/platform-report.ts +212 -126
  78. package/src/ci/platform.ts +28 -26
  79. package/src/ci/reporter.ts +25 -26
  80. package/src/ci/review-admission.ts +1 -2
  81. package/src/ci/review-levels.ts +12 -53
  82. package/src/ci/setup.ts +96 -66
  83. package/src/ci/trace-bundle.ts +11 -27
  84. package/src/ci/trace-transcripts.ts +4 -6
  85. package/src/ci/trigger.ts +3 -5
  86. package/src/cli.ts +6 -5
  87. package/src/commands/ci-setup-questions.ts +2 -55
  88. package/src/commands/ci-setup.ts +2 -26
  89. package/src/commands/triage.ts +131 -38
  90. package/src/commands/usage.ts +0 -1
  91. package/src/compare/compare.ts +3 -3
  92. package/src/compare/floor-test.ts +30 -201
  93. package/src/compare/hunter-exam.ts +631 -0
  94. package/src/config/config.ts +6 -30
  95. package/src/diversity/accounting.ts +0 -26
  96. package/src/diversity/benchmark.ts +1 -17
  97. package/src/diversity/identity.ts +0 -14
  98. package/src/diversity/pipeline-integration.ts +0 -29
  99. package/src/doctor.ts +3 -6
  100. package/src/execution/claude-session-trace.ts +7 -2
  101. package/src/execution/contracts.ts +15 -9
  102. package/src/execution/harness.ts +165 -187
  103. package/src/execution/spend-limiter.ts +39 -131
  104. package/src/execution/usage-facts.ts +397 -0
  105. package/src/execution/usage-normalized.ts +33 -86
  106. package/src/harness/materiality-judge.ts +0 -5
  107. package/src/harness/pipeline-plan.ts +0 -3
  108. package/src/harness/replay-rows.ts +0 -5
  109. package/src/harness/route-runner.ts +2 -2
  110. package/src/harness/single-step.ts +3 -9
  111. package/src/index.ts +1 -1
  112. package/src/mcp/preflight.ts +2 -2
  113. package/src/model/catalog.ts +1 -3
  114. package/src/model/free-discovery.ts +11 -78
  115. package/src/model/model-name.ts +16 -5
  116. package/src/model/profiles/claude.ts +1 -2
  117. package/src/model/profiles/openai.ts +1 -2
  118. package/src/model/profiles.ts +2 -3
  119. package/src/model/provider-capabilities.ts +16 -55
  120. package/src/model/routing.ts +39 -36
  121. package/src/pr/admission.ts +6 -6
  122. package/src/pr/answered-findings.ts +8 -4
  123. package/src/pr/ci-publish.ts +0 -2
  124. package/src/pr/discovery.ts +4 -25
  125. package/src/pr/plan.ts +40 -121
  126. package/src/pr/pr-status.ts +14 -2
  127. package/src/pr/pr.ts +1 -1
  128. package/src/pr/preflight.ts +44 -15
  129. package/src/pr/publish-outcome.ts +1 -19
  130. package/src/pr/review-pr.ts +15 -47
  131. package/src/pr/target.ts +76 -82
  132. package/src/production-runtime.ts +52 -114
  133. package/src/progress.ts +0 -54
  134. package/src/rereview/prepare.ts +4 -1
  135. package/src/rereview/state.ts +1 -1
  136. package/src/rereview/verify.ts +15 -9
  137. package/src/review/boundary.ts +5 -8
  138. package/src/review/drafts.ts +3 -3
  139. package/src/review/findings-conformance.ts +1 -1
  140. package/src/review/findings.ts +0 -4
  141. package/src/review/pipeline.ts +194 -407
  142. package/src/review/preflight.ts +175 -201
  143. package/src/review/prompt-set.ts +1 -2
  144. package/src/review/report.ts +2 -162
  145. package/src/review/review.ts +25 -74
  146. package/src/review/route-preflight.ts +19 -35
  147. package/src/review/run.ts +37 -73
  148. package/src/review/size-gate.ts +3 -3
  149. package/src/review/spec.ts +6 -11
  150. package/src/review/step-runner.ts +4 -4
  151. package/src/runner-authority.ts +10 -9
  152. package/src/security/credential-broker.ts +5 -6
  153. package/src/server/preflight.ts +0 -1
  154. package/src/server/server.ts +17 -6
  155. package/src/store/activity.ts +1 -2
  156. package/src/store/backfill-preflight.ts +0 -3
  157. package/src/store/backfill.ts +0 -1
  158. package/src/store/metrics-preflight.ts +4 -14
  159. package/src/store/metrics.ts +5 -5
  160. package/src/store/preflight.ts +0 -13
  161. package/src/store/store.ts +11 -12
  162. package/src/transport-registry.ts +6 -30
  163. package/src/transports/claude-code-cli.ts +149 -215
  164. package/src/transports/opencode-client.ts +4 -24
  165. package/src/transports/opencode-sdk.ts +17 -112
  166. package/src/triage/plain-reply.ts +37 -0
  167. package/src/ui/activity.ts +1 -6
  168. package/src/ui/config-edit.ts +14 -67
  169. package/src/ui/config.ts +3 -8
  170. package/src/ui/plan.ts +11 -198
  171. package/src/ui/progress.ts +3 -49
  172. package/src/ui/result.ts +18 -77
  173. package/src/ui/review-menu.ts +3 -12
  174. package/src/ui/select.ts +9 -79
  175. package/src/updater.ts +1 -1
  176. package/src/usage.ts +1 -7
  177. package/prompts/scout.md +0 -140
  178. package/src/ci/platform-estimate.ts +0 -111
  179. package/src/review/scout.ts +0 -323
@@ -18,7 +18,6 @@ import { wrapBlock } from "./boundary";
18
18
  export const AGENT_NAMES = [
19
19
  "deep-review-reliability",
20
20
  "deep-review-resilience",
21
- "deep-review-parity",
22
21
  "review-refuter",
23
22
  ] as const;
24
23
 
@@ -28,9 +27,9 @@ export const AGENT_NAMES = [
28
27
  // (model-profiles S4).
29
28
  export const ENGINE_PROMPT_FILES = [
30
29
  "consolidate.md",
31
- "scout.md",
32
30
  "summarizer.md",
33
31
  "materiality.md",
32
+ "verifier.md",
34
33
  ] as const;
35
34
  export type EnginePromptFile = (typeof ENGINE_PROMPT_FILES)[number];
36
35
 
@@ -1,13 +1,11 @@
1
1
  // The human-facing half of local mode (ROADMAP B0): a pure renderer that
2
- // turns a findings document into the markdown a developer actually reads, and
3
- // a pure cost estimator that runs BEFORE the money is spent.
2
+ // turns a findings document into the markdown a developer actually reads.
4
3
  //
5
4
  // Pure on purpose — no I/O, no git, no clock. The CLI owns every side effect,
6
5
  // so the report can be re-rendered from an artifact on disk months later and
7
6
  // come out byte-identical (the lab already replays old findings.json files;
8
7
  // a renderer that reached for `new Date()` would make that a lie).
9
8
 
10
- import type { PlatformEstimateBasis } from "#ci/platform-estimate";
11
9
  import { listPaths } from "#git/refs";
12
10
  import type { ResolvedRoutePlan, ResolvedStepRoute } from "#model/routing";
13
11
  import type { PostMinSeverity } from "#pr/post-floor";
@@ -51,133 +49,6 @@ export interface DiffStat {
51
49
  deletions: number;
52
50
  }
53
51
 
54
- export interface CostEstimate {
55
- low: number;
56
- high: number;
57
- // Plain-language statement of how coarse this is, meant to be printed next
58
- // to the numbers so nobody reads the band as a quote.
59
- basis: string;
60
- // Set when the range is the Crysk platform's estimate, not this band: what
61
- // the platform priced it from (src/ci/platform-estimate.ts).
62
- platform?: PlatformEstimateBasis;
63
- }
64
-
65
- // Per-hunter marginal cost, fitted to the measured runs (see BAND below).
66
- // Deliberately three transparent coefficients instead of a regression: with
67
- // this few calibration points anything fancier is false precision.
68
- //
69
- // The base is the load-bearing coefficient, recalibrated 2026-08-11 from
70
- // 0.5 to 1.2: a hunter's floor is reading the TREE and the prompt
71
- // machinery, nearly independent of a small diff. The proof was two PR-mode
72
- // runs of the same 7-file / +21 −8 tree billing $4.74 and $3.92 against a
73
- // $1.19–$2.39 band — both ~2x above the top, the exact under-estimate
74
- // failure this band exists to prevent.
75
- const USD_PER_AGENT_BASE = 1.2;
76
- const USD_PER_CHANGED_LINE = 0.00021;
77
- const USD_PER_FILE = 0.008;
78
-
79
- // Skewed on purpose. Every recorded overrun was an UNDER-estimate, never
80
- // over, so the upper arm is the wider one: a band that is too generous costs
81
- // a second of hesitation, a band that is too tight costs real money.
82
- const BAND_LOW = 0.65;
83
- const BAND_HIGH = 1.4;
84
-
85
- // WHY this function exists at all: the ROADMAP logs two cost overruns in a
86
- // row — "~$21" against an actual bill, and "~$34" against an actual $48.30 —
87
- // and both had the same cause. The estimate was carried over from the
88
- // PREVIOUS arm instead of being computed from the tree about to be reviewed.
89
- // So this estimates from the diff, and only from the diff.
90
- //
91
- // Calibration points, all measured on real runs of the current engine:
92
- // - PR 1682's tree (7 files / +21 −8, 3 hunters + refuter) billed $4.74
93
- // and $3.92 across two runs — the per-agent floor evidence;
94
- // - a 45-file / +2775 −1237 tree with 5 hunters + refuter billed ~$14.78,
95
- // and the same tree was recorded at ~$11/run elsewhere in the campaign;
96
- // - the first B0 local run (5 files / +484, 4 hunters + refuter), $3.68.
97
- // A legacy "~$2.61 small tree" point from before PR mode existed was
98
- // RETIRED by the 1682 evidence: two same-engine runs of a comparable tree
99
- // both landed far above it, and a calibration point the instrument itself
100
- // contradicts is decoration. The ~$11 vs ~$14.78 spread on ONE tree is the
101
- // whole argument for returning a band: the same diff, the same agents, a
102
- // 34% swing. A point estimate here would be a fiction with a decimal point.
103
- //
104
- // The refuter is not a separate term: its cost rides in the coefficients,
105
- // because every calibration run had the refuter leg included and a
106
- // refuter's size tracks how much the hunters found, which tracks diff size.
107
- export function estimateCost(
108
- diffStat: DiffStat,
109
- hunterCount: number,
110
- summarizerEnabled = false,
111
- // ROADMAP-DOORDASH M5. Defaulted OFF so every existing caller keeps its
112
- // band byte-identical, and so a caller that forgets it under-quotes
113
- // nothing it did not already under-quote.
114
- scoutEnabled = false,
115
- // Item 7 O-5a. Default 0 so every existing caller keeps its band
116
- // byte-identical. Priced as its own term (not folded into `agents`) so a
117
- // 40-finding re-review of a 2-file delta is not billed as 40 hunters.
118
- verificationSteps = 0,
119
- // The post-refuter consolidation pass. LAST and defaulted OFF so every
120
- // existing call shape compiles and keeps its band; the product paths pass
121
- // true. One seat, the scout's rule: a claims-only sonnet call costs far
122
- // less than a hunter, and over-quoting is the cheap direction to be wrong.
123
- consolidateEnabled = false,
124
- ): CostEstimate {
125
- const files = Math.max(0, diffStat.files);
126
- const lines =
127
- Math.max(0, diffStat.insertions) + Math.max(0, diffStat.deletions);
128
- // A validated ReviewSpec always carries at least one hunter, so a zero here
129
- // means a caller asked hypothetically. Clamping keeps the band from
130
- // collapsing to $0–$0, which would read as "this is free".
131
- // The scout takes a full agent seat, the summarizer's precedent, and that
132
- // deliberately OVER-quotes: it is diff-only, one attempt, and reads no tree,
133
- // so its true cost is a fraction of a hunter's. Two reasons it gets the seat
134
- // anyway. First, this band's own rule — every recorded overrun was an
135
- // UNDER-estimate, so the generous direction is the cheap one to be wrong in.
136
- // Second, the scout has NO calibration point of its own: M4 billed $37.00
137
- // across six prompt versions, two probe defects and a reverted experiment,
138
- // which is a milestone total and not a per-spawn cost. M6 records cost per
139
- // arm; that is the number this coefficient gets recalibrated from, and until
140
- // it exists an invented per-scout coefficient would be false precision.
141
- const hunterSeats = Math.max(
142
- 0,
143
- hunterCount +
144
- (summarizerEnabled ? 1 : 0) +
145
- (scoutEnabled ? 1 : 0) +
146
- (consolidateEnabled ? 1 : 0),
147
- );
148
- const steps = Math.max(0, verificationSteps);
149
- // A zero-hunter, zero-verify call still needs a band (the hypothetical
150
- // floor). A skip-discovery re-review with N verify steps must NOT inherit
151
- // that floor — that would bill a phantom hunter on top of verification.
152
- const agents = hunterSeats === 0 && steps === 0 ? 1 : hunterSeats;
153
- // Verification is its OWN term (item 7 O-5a), not folded into `agents`:
154
- // a verify step reads one prior finding, not the whole tree, so multiplying
155
- // it by changed-files would price a 40-finding re-review of a 2-file delta
156
- // as if it were 40 hunters. The seat is the same per-agent floor — generous
157
- // on purpose, same direction as the scout.
158
- const mid =
159
- agents *
160
- (USD_PER_AGENT_BASE +
161
- USD_PER_CHANGED_LINE * lines +
162
- USD_PER_FILE * files) +
163
- steps * USD_PER_AGENT_BASE;
164
- return {
165
- low: round2(mid * BAND_LOW),
166
- high: round2(mid * BAND_HIGH),
167
- basis:
168
- "coarse band from measured runs (a 7-file / +21 −8 tree with 3 " +
169
- "hunters + refuter, $3.92–$4.74 across two runs; a 45-file / " +
170
- "+2775 −1237 tree with 5 hunters + refuter, ~$11–$14.78): a " +
171
- "per-agent floor for hunters + refuter" +
172
- `${summarizerEnabled ? " + summarizer" : ""}` +
173
- `${scoutEnabled ? " + scout" : ""}` +
174
- `${consolidateEnabled ? " + consolidation" : ""}` +
175
- `${steps > 0 ? ` + ${steps} verification step(s)` : ""} ` +
176
- "plus changed lines and files. An order-of-magnitude " +
177
- "guide, not a quote — the same tree has billed 34% apart across runs.",
178
- };
179
- }
180
-
181
52
  export interface ReportMeta {
182
53
  repo: string;
183
54
  base: string;
@@ -190,15 +61,6 @@ export interface ReportMeta {
190
61
  // Paths the exclusion filter dropped from the reviewed diff, if any. Stated
191
62
  // in the report because it is a mutation of the input, not a detail.
192
63
  excludedPaths?: string[];
193
- // CASH, and only cash — §8's "Budget enforcement uses cash only". A Claude
194
- // subscription route reports a truthful $0.00 here.
195
- costUsd: number;
196
- // #173 (§8: "Artifacts and reports show cash and notional totals
197
- // separately"). The list-basis figure the run was NOT charged. Absent means
198
- // no segment at all, never a `$0.00` one — a runner that reported no
199
- // normalized usage has no list figure, and printing one it never produced
200
- // is the fabrication the usage slice exists to prevent.
201
- notionalUsd?: number;
202
64
  wallMs: number;
203
65
  // S4: the mode the commit status is set under, which the closing note names.
204
66
  // Absent means advisory: a local run, and any caller that never passes it,
@@ -1596,17 +1458,9 @@ export function blobUrl(
1596
1458
 
1597
1459
  function runLines(doc: FindingsDocument, meta: ReportMeta): string[] {
1598
1460
  const { files, insertions, deletions } = meta.diffStat;
1599
- // #173: cash first and unqualified, notional after it and never without its
1600
- // basis spelled out — §8 allows notional in a report "only when clearly
1601
- // labelled", and two bare dollar figures side by side is precisely the
1602
- // mixing it forbids.
1603
- const notional =
1604
- meta.notionalUsd === undefined
1605
- ? ""
1606
- : ` (${usd(meta.notionalUsd)} at list price, not charged)`;
1607
1461
  const lines = [
1608
1462
  `${files} file${files === 1 ? "" : "s"}, +${insertions} −${deletions}` +
1609
- ` · run ${doc.run_status} · ${usd(meta.costUsd)}${notional} · ${duration(meta.wallMs)}`,
1463
+ ` · run ${doc.run_status} · ${duration(meta.wallMs)}`,
1610
1464
  ];
1611
1465
  const excluded = meta.excludedPaths ?? [];
1612
1466
  if (excluded.length > 0) {
@@ -1625,12 +1479,6 @@ function runLines(doc: FindingsDocument, meta: ReportMeta): string[] {
1625
1479
  `Agents: ${rows.map((r) => `${r.key} ${r.status}`).join(" · ")}`,
1626
1480
  );
1627
1481
  }
1628
- if (!doc.parity_hunter_fired) {
1629
- lines.push("");
1630
- lines.push(
1631
- "The parity hunter did not fire: no changed path matched its trigger.",
1632
- );
1633
- }
1634
1482
  return lines;
1635
1483
  }
1636
1484
 
@@ -1838,10 +1686,6 @@ function oneLine(text: string): string {
1838
1686
  return publishedText(text.replace(/\s+/g, " ").trim());
1839
1687
  }
1840
1688
 
1841
- function usd(amount: number): string {
1842
- return `$${amount.toFixed(2)}`;
1843
- }
1844
-
1845
1689
  // Elapsed time as the compact `3m12s` the CLI's live progress prefixes onto
1846
1690
  // every event line. Floor, never round: 59.9s read as "60s" would tick the
1847
1691
  // minute early. Minutes deliberately never roll into hours — a review past
@@ -1864,10 +1708,6 @@ function duration(ms: number): string {
1864
1708
  : `${minutes}m ${String(seconds).padStart(2, "0")}s`;
1865
1709
  }
1866
1710
 
1867
- function round2(value: number): number {
1868
- return Math.round(value * 100) / 100;
1869
- }
1870
-
1871
1711
  // A step's route as the plan card shows it: the model name it resolved to,
1872
1712
  // which already says its backend (`claude:sonnet-latest`,
1873
1713
  // `opencode:openai/gpt-5`), and its `models` entry's effort when it sets one,
@@ -10,7 +10,6 @@ import os from "node:os";
10
10
  import path from "node:path";
11
11
  import {
12
12
  ingestReviewMetrics,
13
- notionalCostInput,
14
13
  persistCanonicalReview,
15
14
  pipelineConfigInput,
16
15
  } from "#config/config";
@@ -23,8 +22,6 @@ import {
23
22
  resolveRepoRoot,
24
23
  } from "#git/git";
25
24
  import { engineIdentity } from "#git/identity";
26
- import { countFreeRouteSteps } from "#model/free-discovery";
27
- import { planRoutes } from "#model/routing";
28
25
  import { reviewPr } from "#pr/review-pr";
29
26
  import { reviewExitCode } from "#review/exit-code";
30
27
  import type { Telemetry } from "#review/findings";
@@ -38,12 +35,10 @@ import {
38
35
  resolveMaxConcurrentSteps,
39
36
  resolveSharedPrefix,
40
37
  } from "#review/preflight";
41
- import { estimateCost } from "#review/report";
42
38
  import {
43
39
  isBundledAgentsDir,
44
40
  pipelineConsolidateInput,
45
41
  pipelineMaterialityInput,
46
- pipelineScoutInput,
47
42
  pipelineSummarizerInput,
48
43
  } from "#review/route-preflight";
49
44
  import {
@@ -54,7 +49,6 @@ import {
54
49
  loadRunConfig,
55
50
  NO_INSTRUCTIONS_NOTICE,
56
51
  prepareRunnerForRoute,
57
- resolveParityFires,
58
52
  resolvePipelineRoute,
59
53
  resolvePromptSet,
60
54
  resolveReviewInstructions,
@@ -78,7 +72,6 @@ import {
78
72
  import { log, styleEnabled } from "#ui/primitives";
79
73
  import { applySizeGate, confirm, startProgressRenderer } from "#ui/progress";
80
74
  import { renderResult } from "#ui/result";
81
- import { freeBillingMode } from "#ui/select";
82
75
  import { CliError } from "../errors";
83
76
  import { prheroLayout } from "../home-preflight";
84
77
  import { readLocalIgnoreRules } from "../ignore-read";
@@ -103,15 +96,13 @@ export async function review(options: CliOptions): Promise<number> {
103
96
  // Two layers since C5, folded by loadEffectiveConfig into the one
104
97
  // LocalConfig everything below already expected. The --config missing-file
105
98
  // error and the boundary rules live there.
106
- const { loaded, config, summary, scout, post, profile } = await loadRunConfig(
107
- {
108
- root: repoRoot,
109
- home: os.homedir(),
110
- configFlag: options.config,
111
- options,
112
- },
113
- );
114
- options = { ...options, scout, post };
99
+ const { loaded, config, summary, post, profile } = await loadRunConfig({
100
+ root: repoRoot,
101
+ home: os.homedir(),
102
+ configFlag: options.config,
103
+ options,
104
+ });
105
+ options = { ...options, post };
115
106
  // S5: the Claude credential this run uses, chosen once, here, from
116
107
  // `credentials.claude` and what is set. Every runner, binding and child below
117
108
  // reads its env, which holds that one credential and no other.
@@ -197,8 +188,8 @@ export async function review(options: CliOptions): Promise<number> {
197
188
  const { runDir, repoId } = await createRunDir(options, repoRoot, headSha);
198
189
  const diffPath = path.join(runDir, "diff.patch");
199
190
  // diffFromSha, never baseSha: see resolveDiffFrom. The numstat below uses
200
- // the same endpoint on purpose — a cost estimate computed over a wider range
201
- // than the one being reviewed is a bill that arrives from nowhere.
191
+ // the same endpoint on purpose — a stat computed over a wider range than
192
+ // the one being reviewed would describe a different review.
202
193
  const diff = await git(repoRoot, ["diff", `${diffFromSha}..${headSha}`]);
203
194
  if (!diff.ok) throw new CliError(`git diff failed: ${diff.stderr}`);
204
195
  if (diff.stdout.trim().length === 0) {
@@ -238,23 +229,9 @@ export async function review(options: CliOptions): Promise<number> {
238
229
  const codegraphAvailable = existsSync(path.join(repoRoot, ".codegraph"));
239
230
  await writeMcpConfig(mcpConfigPath, codegraphAvailable);
240
231
 
241
- // 11 — the plan. Triggers read the EFFECTIVE diff, the same bytes the
242
- // pipeline will read back from diff.patch: a conditional hunter must never
243
- // fire on a path no hunter was given.
244
- const parityFires = resolveParityFires(
245
- effectiveDiff.patch,
246
- config.parity_trigger_paths,
247
- );
248
- const activeHunters = selectActiveHunters(spec.agents, parityFires);
232
+ // 11 — the plan.
233
+ const activeHunters = selectActiveHunters(spec.agents);
249
234
  const hunterCount = activeHunters.length;
250
- const estimate = estimateCost(
251
- diffStat,
252
- hunterCount,
253
- summary.enabled,
254
- options.scout,
255
- 0,
256
- true,
257
- );
258
235
  const productionRoute = await resolvePipelineRoute({
259
236
  modelsConfigured: routingConfigured(config),
260
237
  workspaceRoot: repoRoot,
@@ -270,19 +247,6 @@ export async function review(options: CliOptions): Promise<number> {
270
247
  });
271
248
  const routePlan = productionRoute?.routePlan;
272
249
  const productionAdmission = productionRoute?.productionAdmission;
273
- // Read off the admission above, which already decided every free verdict:
274
- // this adds no probe. Absent without routing, so the band stays.
275
- const freeRoute =
276
- routePlan === undefined || productionAdmission === undefined
277
- ? undefined
278
- : await countFreeRouteSteps({
279
- steps: planRoutes(routePlan),
280
- probe: productionAdmission.freeModelProbe,
281
- // The CRYSK_OPENCODE_* names admission bound each route's kind with,
282
- // so the card counts free exactly the routes admission probed (U3).
283
- openCodeSecretNames:
284
- productionAdmission.authorityOptions.openCodeSecretNames,
285
- });
286
250
  // Named rather than inlined into renderPlan: the same context is what the
287
251
  // confirm menu's "Show details" renders, and building it twice would risk
288
252
  // the card and the details view disagreeing about the run they describe.
@@ -301,17 +265,13 @@ export async function review(options: CliOptions): Promise<number> {
301
265
  runDir,
302
266
  config,
303
267
  summary,
304
- parityFires,
305
268
  codegraphAvailable,
306
- estimate,
307
- hunterCount,
308
269
  // Evaluated above (step 9) and ENFORCED below at step 13, unchanged;
309
270
  // the plan only prints the verdict, last, where the decision is made.
310
271
  sizeGate,
311
272
  droppedPaths: effectiveDiff.droppedPaths,
312
273
  configProvenance: configProvenanceOf(loaded, agentsDirSource),
313
274
  ...(routePlan === undefined ? {} : { routePlan }),
314
- ...(freeRoute === undefined ? {} : { freeRoute }),
315
275
  };
316
276
  for (const line of renderPlan(planContext, styleEnabled())) log(line);
317
277
 
@@ -344,7 +304,7 @@ export async function review(options: CliOptions): Promise<number> {
344
304
  productionAdmission,
345
305
  });
346
306
 
347
- // 13 — the size gate, BEFORE the cost band's confirm() for the unattended
307
+ // 13 — the size gate, BEFORE the confirm prompt for the unattended
348
308
  // path. The watcher spawns with --yes, so a gate that lived only inside
349
309
  // that confirmation would never fire in the one place — unattended spend
350
310
  // — it exists to protect. An interactive TTY is offered Continue/Cancel
@@ -356,12 +316,8 @@ export async function review(options: CliOptions): Promise<number> {
356
316
  // without --pr), so the "don't post" option is not offered and the choice's
357
317
  // `post` field carries nothing local mode could act on.
358
318
  if (!options.yes) {
359
- const choice = await confirm(
360
- estimate.low,
361
- estimate.high,
362
- false,
363
- () => planDetails(planContext, styleEnabled()),
364
- freeRoute,
319
+ const choice = await confirm(false, () =>
320
+ planDetails(planContext, styleEnabled()),
365
321
  );
366
322
  if (choice.kind === "cancel") {
367
323
  log("aborted; nothing was spent.");
@@ -371,7 +327,7 @@ export async function review(options: CliOptions): Promise<number> {
371
327
 
372
328
  // 15 — run, with live progress: the expectation line up front, then one
373
329
  // stderr line per pipeline event (plus a TTY heartbeat between them).
374
- log(reviewingLine(hunterCount, summary, options));
330
+ log(reviewingLine(hunterCount, summary));
375
331
  const started = performance.now();
376
332
  const progress = startProgressRenderer(
377
333
  started,
@@ -392,16 +348,16 @@ export async function review(options: CliOptions): Promise<number> {
392
348
  // same signal and refuses to start another attempt. Two controllers would
393
349
  // leave the ceiling unable to stop the steps it is waiting on.
394
350
  const ceilingController = new AbortController();
395
- // Local mode has no PR, so the materiality judge reads the reviewed head's
396
- // commit subject as the title (S9). Only asked for when the gate is on, so
397
- // a run with it off spawns exactly the processes it always did. A failed
398
- // read leaves it absent and the pipeline renders its fallback.
351
+ // Local mode has no PR, so the reviewed head's commit subject stands in as
352
+ // the title: the hunters read it as the change's stated intent (S10) and
353
+ // the materiality judge as its title (S9). Local mode has no description.
354
+ // Asked for on every run, so the hunters' request does not depend on the
355
+ // judge being on. A failed read leaves it absent: the hunters get no intent
356
+ // section and the judge's pipeline renders its fallback.
399
357
  let prTitle: string | undefined;
400
- if (resolveMaterialityGate(config)) {
401
- const subject = await git(repoRoot, ["log", "-1", "--format=%s", headSha]);
402
- if (subject.ok && subject.stdout.trim() !== "") {
403
- prTitle = subject.stdout.trim();
404
- }
358
+ const subject = await git(repoRoot, ["log", "-1", "--format=%s", headSha]);
359
+ if (subject.ok && subject.stdout.trim() !== "") {
360
+ prTitle = subject.stdout.trim();
405
361
  }
406
362
  let productionRuntime: ProductionRuntime | undefined;
407
363
  try {
@@ -440,11 +396,10 @@ export async function review(options: CliOptions): Promise<number> {
440
396
  mcpConfigPath,
441
397
  hopBudget: options.hopBudget,
442
398
  ...(options.model ? { model: options.model } : {}),
443
- parityTriggerPaths: config.parity_trigger_paths,
399
+ parityTriggerPaths: [],
444
400
  suspicionPriors: config.suspicion_priors,
445
401
  modelProfile: profile,
446
402
  ...pipelineSummarizerInput(summary, { profile }),
447
- ...pipelineScoutInput(options, { profile }),
448
403
  ...pipelineConsolidateInput({ profile }),
449
404
  ...pipelineMaterialityInput(config, { profile }),
450
405
  ...(prTitle === undefined ? {} : { prTitle }),
@@ -524,11 +479,7 @@ export async function review(options: CliOptions): Promise<number> {
524
479
  const links = await localResultLinks(repoRoot, headSha);
525
480
  for (const line of renderResult({
526
481
  doc,
527
- costUsd: result.usage.cost_usd_est,
528
- ...notionalCostInput(result),
529
- ...(freeRoute === undefined ? {} : { billing: freeBillingMode(freeRoute) }),
530
482
  wallMs,
531
- estimate: { low: estimate.low, high: estimate.high },
532
483
  runDir,
533
484
  artifacts: [path.basename(reportPath), path.basename(findingsPath)],
534
485
  ...(links === undefined ? {} : { links }),
@@ -88,12 +88,12 @@ export function enginePromptPath(
88
88
  switch (file) {
89
89
  case "consolidate.md":
90
90
  return assets.consolidatePromptPath;
91
- case "scout.md":
92
- return assets.scoutPromptPath;
93
91
  case "summarizer.md":
94
92
  return assets.summarizerPromptPath;
95
93
  case "materiality.md":
96
94
  return assets.materialityPromptPath;
95
+ case "verifier.md":
96
+ return assets.verifierPromptPath;
97
97
  }
98
98
  }
99
99
 
@@ -119,32 +119,7 @@ export function pipelineSummarizerInput(
119
119
  : {};
120
120
  }
121
121
 
122
- // The scout's prompt is ENGINE-owned and lives outside the agents dir, on
123
- // purpose and twice over (§3.7): a `review-scout.md` dropped in the agents dir
124
- // without a spec entry is a hard CliError, and a new prompt-set directory
125
- // holding byte-identical hunter files would be a new fingerprint — which is
126
- // exactly the one-variable property M6 needs to be true by construction rather
127
- // than argued. `prompts/` is the door the summarizer already walked through.
128
- export function pipelineScoutInput(
129
- options: Pick<CliOptions, "scout" | "scoutModel">,
130
- prompts: RunPromptOptions,
131
- ):
132
- | { scout: { promptPath: string; model?: string; bundled: true } }
133
- | Record<string, never> {
134
- return options.scout
135
- ? {
136
- scout: {
137
- promptPath: enginePromptPath("scout.md", prompts),
138
- ...(options.scoutModel === undefined
139
- ? {}
140
- : { model: options.scoutModel }),
141
- bundled: true,
142
- },
143
- }
144
- : {};
145
- }
146
-
147
- // The consolidation pass is ENGINE-owned like the scout, and on by default in
122
+ // The consolidation pass is ENGINE-owned like the summarizer, and on by default in
148
123
  // both product paths (local and PR/CI) with no flag: it was measured as a net
149
124
  // gain on the Martian 50 (lab bench/METRICS.md 2026-10-27), and a failed pass
150
125
  // falls back to the unconsolidated findings. The lab's direct `runPipeline`
@@ -160,6 +135,20 @@ export function pipelineConsolidateInput(prompts: RunPromptOptions): {
160
135
  };
161
136
  }
162
137
 
138
+ // The re-review verifier's body is ENGINE-owned like the consolidation
139
+ // prompt. The verifier asks whether an earlier finding's defect is still
140
+ // present at the current head, which is not the refuter's question, so it does
141
+ // not run under the refuter's body. Only the body is its own: model, effort,
142
+ // tools and route stay the refuter agent's (`runVerify`), so a custom
143
+ // `review-refuter.md` still sets those and no longer shapes what the
144
+ // verifier is told. Outside the agents dir on purpose: a `review-verifier.md`
145
+ // there would fall under the two-way rule and break every custom directory.
146
+ export function pipelineVerifierInput(prompts: RunPromptOptions): {
147
+ verifier: { promptPath: string };
148
+ } {
149
+ return { verifier: { promptPath: enginePromptPath("verifier.md", prompts) } };
150
+ }
151
+
163
152
  // The materiality gate (odd/tasks/materiality-gate.md) is ENGINE-owned like
164
153
  // the consolidation pass but OFF by default: it is config-only
165
154
  // (`materiality_gate`), and absent means today's pipeline, byte for byte. The
@@ -201,10 +190,9 @@ export async function buildCliRoutePlan(params: {
201
190
  models?: ModelsConfig;
202
191
  summary: SummarySettings;
203
192
  summarizerEnabled?: boolean;
204
- scoutEnabled?: boolean;
205
193
  // Defaults ON, like the stage itself in both product paths; a re-review
206
- // that skips discovery passes false, the scout's condition, so the plan
207
- // never carries a route for a step that will not run.
194
+ // that skips discovery passes false, so the plan never carries a route for a
195
+ // step that will not run.
208
196
  consolidateEnabled?: boolean;
209
197
  // Defaults OFF, unlike consolidation: the gate is opt-in, and a judge key in
210
198
  // the plan changes its fingerprint, so absent must mean today's plan.
@@ -215,7 +203,6 @@ export async function buildCliRoutePlan(params: {
215
203
  profile: ModelProfile;
216
204
  }): Promise<ResolvedRoutePlan> {
217
205
  const summarizerEnabled = params.summarizerEnabled ?? params.summary.enabled;
218
- const scoutEnabled = params.scoutEnabled ?? params.options.scout;
219
206
  const consolidateEnabled = params.consolidateEnabled ?? true;
220
207
  // The root prompts are the engine's own (pipeline*Input marks them), so
221
208
  // their frontmatter is not read: the profile holds their seat (S3), the
@@ -230,9 +217,6 @@ export async function buildCliRoutePlan(params: {
230
217
  ...(summarizerEnabled
231
218
  ? { summarizer: { model: params.summary.model, bundled: true } }
232
219
  : {}),
233
- ...(scoutEnabled
234
- ? { scout: { model: params.options.scoutModel, bundled: true } }
235
- : {}),
236
220
  ...(consolidateEnabled ? { consolidate: { bundled: true } } : {}),
237
221
  ...(params.materialityEnabled === true
238
222
  ? { materiality: true as const }