lastlight-core 0.26.0 → 0.27.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 (123) hide show
  1. package/config/default.yaml +302 -5
  2. package/dist/admin/docker.js.map +1 -1
  3. package/dist/admin/sessions.js.map +1 -1
  4. package/dist/admin/tail.js.map +1 -1
  5. package/dist/config/config.d.ts +18 -4
  6. package/dist/config/config.js +122 -9
  7. package/dist/config/config.js.map +1 -1
  8. package/dist/config/repo-config.js.map +1 -1
  9. package/dist/connectors/messaging/session-manager.js.map +1 -1
  10. package/dist/connectors/slack/connector.js.map +1 -1
  11. package/dist/cron/dependabot-discovery.js.map +1 -1
  12. package/dist/cron/review-discovery.js.map +1 -1
  13. package/dist/engine/agent-executor.d.ts +25 -1
  14. package/dist/engine/agent-executor.js +41 -1
  15. package/dist/engine/agent-executor.js.map +1 -1
  16. package/dist/engine/chat/chat-prompt.js.map +1 -1
  17. package/dist/engine/chat/chat-runner.js.map +1 -1
  18. package/dist/engine/event-shim.d.ts +18 -0
  19. package/dist/engine/event-shim.js +2 -0
  20. package/dist/engine/event-shim.js.map +1 -1
  21. package/dist/engine/executors/orchestrator.d.ts +92 -1
  22. package/dist/engine/executors/orchestrator.js +144 -46
  23. package/dist/engine/executors/orchestrator.js.map +1 -1
  24. package/dist/engine/executors/shared.js.map +1 -1
  25. package/dist/engine/fix-harvest.js.map +1 -1
  26. package/dist/engine/github/github.d.ts +59 -0
  27. package/dist/engine/github/github.js +72 -0
  28. package/dist/engine/github/github.js.map +1 -1
  29. package/dist/engine/github/installations.js.map +1 -1
  30. package/dist/engine/github/review-poster.d.ts +388 -9
  31. package/dist/engine/github/review-poster.js +550 -50
  32. package/dist/engine/github/review-poster.js.map +1 -1
  33. package/dist/engine/github/team-visibility.js.map +1 -1
  34. package/dist/engine/llm.js.map +1 -1
  35. package/dist/engine/pr-decisions.d.ts +13 -5
  36. package/dist/engine/pr-decisions.js +204 -5
  37. package/dist/engine/pr-decisions.js.map +1 -1
  38. package/dist/engine/pr-state.d.ts +58 -0
  39. package/dist/engine/pr-state.js +64 -0
  40. package/dist/engine/pr-state.js.map +1 -1
  41. package/dist/engine/review-spec.d.ts +264 -0
  42. package/dist/engine/review-spec.js +723 -0
  43. package/dist/engine/review-spec.js.map +1 -0
  44. package/dist/engine/router.js.map +1 -1
  45. package/dist/engine/screen/classifier.js.map +1 -1
  46. package/dist/engine/screen/screen.js.map +1 -1
  47. package/dist/evals-api.d.ts +3 -0
  48. package/dist/evals-api.js +20 -0
  49. package/dist/evals-api.js.map +1 -1
  50. package/dist/index.js +39 -4
  51. package/dist/index.js.map +1 -1
  52. package/dist/notify/digest-blocks.js.map +1 -1
  53. package/dist/notify/model.js.map +1 -1
  54. package/dist/notify/transports/github.js.map +1 -1
  55. package/dist/notify/transports/slack.js.map +1 -1
  56. package/dist/sandbox/artifact-backend.js.map +1 -1
  57. package/dist/sandbox/artifact-store.js.map +1 -1
  58. package/dist/sandbox/docker.d.ts +23 -4
  59. package/dist/sandbox/docker.js +1 -1
  60. package/dist/sandbox/docker.js.map +1 -1
  61. package/dist/sandbox/egress-allowlist.js.map +1 -1
  62. package/dist/sandbox/k8s/agent-context-registry.js.map +1 -1
  63. package/dist/sandbox/k8s/client.js.map +1 -1
  64. package/dist/sandbox/k8s/kubernetes-sandbox.js.map +1 -1
  65. package/dist/sandbox/k8s/resource-name.js.map +1 -1
  66. package/dist/sandbox/k8s/run-id.js.map +1 -1
  67. package/dist/sandbox/k8s/run-secrets.js.map +1 -1
  68. package/dist/sandbox/k8s/skill-bundle.js.map +1 -1
  69. package/dist/sandbox/k8s/workspace-provisioner.js +10 -2
  70. package/dist/sandbox/k8s/workspace-provisioner.js.map +1 -1
  71. package/dist/sandbox/sandbox.d.ts +20 -0
  72. package/dist/sandbox/sandbox.js +27 -6
  73. package/dist/sandbox/sandbox.js.map +1 -1
  74. package/dist/session-log.js.map +1 -1
  75. package/dist/state/approval-store.js.map +1 -1
  76. package/dist/state/build-assets.js.map +1 -1
  77. package/dist/state/cron-run-store.js.map +1 -1
  78. package/dist/state/data-migrate.d.ts +135 -0
  79. package/dist/state/data-migrate.js +309 -0
  80. package/dist/state/data-migrate.js.map +1 -0
  81. package/dist/state/db.d.ts +24 -3
  82. package/dist/state/db.js +41 -11
  83. package/dist/state/db.js.map +1 -1
  84. package/dist/state/execution-store.js.map +1 -1
  85. package/dist/state/feedback-store.js.map +1 -1
  86. package/dist/state/pg-client.d.ts +44 -0
  87. package/dist/state/pg-client.js +81 -0
  88. package/dist/state/pg-client.js.map +1 -0
  89. package/dist/state/schema/pg.d.ts +15 -15
  90. package/dist/state/schema/sqlite.d.ts +15 -15
  91. package/dist/state/state-cli.d.ts +8 -0
  92. package/dist/state/state-cli.js +247 -0
  93. package/dist/state/state-cli.js.map +1 -0
  94. package/dist/state/team-store.js.map +1 -1
  95. package/dist/state/user-store.js.map +1 -1
  96. package/dist/state/workflow-run-store.js.map +1 -1
  97. package/dist/telemetry/index.js.map +1 -1
  98. package/dist/workflows/handlers/fanout.d.ts +157 -0
  99. package/dist/workflows/handlers/fanout.js +663 -0
  100. package/dist/workflows/handlers/fanout.js.map +1 -0
  101. package/dist/workflows/handlers/post-review.d.ts +98 -8
  102. package/dist/workflows/handlers/post-review.js +391 -20
  103. package/dist/workflows/handlers/post-review.js.map +1 -1
  104. package/dist/workflows/runner.js +33 -0
  105. package/dist/workflows/runner.js.map +1 -1
  106. package/dist/workflows/simple.js.map +1 -1
  107. package/docker-compose.yml +50 -0
  108. package/package.json +22 -12
  109. package/sandbox.Dockerfile +54 -0
  110. package/skills/code-review/SKILL.md +98 -13
  111. package/skills/pr-review/SKILL.md +97 -21
  112. package/skills/pr-review/references/findings-schema.md +37 -6
  113. package/workflows/pr-review.yaml +567 -0
  114. package/workflows/prompts/dependabot-pr-merge.md +22 -2
  115. package/workflows/prompts/review-adjudicate.md +323 -0
  116. package/workflows/prompts/review-falsify.md +149 -0
  117. package/workflows/prompts/review.md +80 -0
  118. package/workflows/prompts/survey-contract.md +109 -0
  119. package/workflows/prompts/survey-enforcement.md +126 -0
  120. package/workflows/prompts/survey-security.md +118 -0
  121. package/workflows/prompts/survey-spec.md +110 -0
  122. package/workflows/prompts/survey-state.md +143 -0
  123. package/workflows/prompts/survey-tests.md +99 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fanout.js","sourceRoot":"","sources":["../../../src/workflows/handlers/fanout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AAkBnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAIlE,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACpF,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,sBAAsB,GAAmC;IAC7D,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,CAAC;IACP,UAAU,EAAE,CAAC;CACd,CAAC;AAEF,6FAA6F;AAC7F,MAAM,0BAA0B,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,UAAmB,EAAE,CAAC;AAE7E;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AAG,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC"}
@@ -31,6 +31,31 @@ export interface PostReviewRunScope {
31
31
  export declare function resolveReviewGitHubClient(runConfig: {
32
32
  githubApiBaseUrl?: string;
33
33
  }): GitHubClient;
34
+ /**
35
+ * Which hypothesis ids in `<dir>/hypotheses/*.jsonl` are clean discharges.
36
+ *
37
+ * **`undefined` means there is no `hypotheses/` directory at all** — the
38
+ * shipped two-phase reviewer, and every arm that runs no evidence pipeline. The
39
+ * caller passes it straight through, so no pipeline ⇒ byte-identical output.
40
+ * (An empty set behaves identically by construction: `every` over a non-empty
41
+ * id list against an empty set is false. The distinction is kept for the log.)
42
+ *
43
+ * Identity is assigned exactly as `code-facts`' `readHypothesisSet` assigns it,
44
+ * because the ids in `findings[].hypotheses[]` came out of that reader's own
45
+ * `--ledger`: canonical **`<family>-NNN`**, family from the FILENAME (the
46
+ * survey branch owns its file, so the name is authoritative in a way a
47
+ * self-reported field is not), ordinal from position in an append-only file.
48
+ * A model-declared `id` is honoured as an **alias** only when exactly one row
49
+ * claims it and it shadows no canonical id — an ambiguous alias resolves to
50
+ * nothing, which leaves the finding on the confidence path rather than crediting
51
+ * whichever file sorted first.
52
+ *
53
+ * Parsing is defensive throughout: a torn final line on a killed run is normal
54
+ * and must not throw. Note that a line that parses to a non-object still
55
+ * consumes its ordinal, because `readHypothesisSet` counts it — an ordinal that
56
+ * drifted from the ledger's would mis-resolve every later citation in the file.
57
+ */
58
+ export declare function readCleanDischarges(dir: string): ReadonlySet<string> | undefined;
34
59
  /**
35
60
  * The `type: post-review` phase — the one workflow body genuinely coupled to
36
61
  * GitHub, lifted out of the engine into an app-registered {@link PhaseTypeHandler}.
@@ -109,18 +134,83 @@ export declare class GitHubPostReviewHandler implements PhaseTypeHandler {
109
134
  private staleAgainstCurrentHead;
110
135
  /** Host path of the run's repo checkout — mirrors sandbox/index.ts layout. */
111
136
  private resolveHostRepoDir;
137
+ /**
138
+ * The attention budget, or `undefined` when the evidence pipeline is off.
139
+ *
140
+ * Operator-layer config, matching the `verdict` strip and
141
+ * `staleAgainstCurrentHead` — `review.analysis` is operator-only anyway, so
142
+ * the repo-clamped block cannot disagree with it.
143
+ */
144
+ private attentionBoundary;
145
+ /**
146
+ * Is the review evidence pipeline on FOR THIS RUN?
147
+ *
148
+ * Two authorities, and the second one is why this is a method rather than a
149
+ * `getRuntimeConfig()` read at each site. The process-global runtime config is
150
+ * the production authority. But `analysisEnabled` on the run CONTEXT is what
151
+ * every gated phase in `pr-review.yaml` actually keys off — `specContext`
152
+ * projects it, and only when the run's own effective review config had
153
+ * `analysis.enabled`. So the context is the run-scoped truth, and reading only
154
+ * the global one makes this handler disagree with the twelve phases upstream
155
+ * of it about whether the pipeline ran.
156
+ *
157
+ * **Measured 2026-08-22, and it silently cost a whole arm.** The eval harness
158
+ * threads the arm's `review:` policy through `prContextPatch` and never
159
+ * populates the runtime config, so a pipeline-ON eval run had all twelve
160
+ * analysis phases fire and then hit a `post-review` that believed the pipeline
161
+ * was off: the attention boundary was inert (every `internal`-tier finding
162
+ * POSTED, no inline cap, no family thresholds) and the split verdict was
163
+ * stripped. Twenty findings posted where the shipped configuration would have
164
+ * posted eleven — a precision number describing a deployment that does not
165
+ * exist.
166
+ *
167
+ * The inertness guarantee is unchanged: `specContext` returns `{}` when
168
+ * analysis is off, so `analysisEnabled` is ABSENT — not `false` — on every
169
+ * deployment that has not opted in, and neither authority can be satisfied.
170
+ */
171
+ private analysisEnabled;
172
+ /**
173
+ * Write what happened to each finding — its tier, and why.
174
+ *
175
+ * [WP6](../../../../../docs/plans/deterministic-pr-levers.md#adjudication-and-the-attention-boundary-wp6)'s
176
+ * AC1b asks for this in a `review_findings` table, and that table is
177
+ * [WP7](../../../../../docs/plans/deterministic-pr-levers.md#review-memory-wp7)'s
178
+ * — which depends on WP6, so it does not exist yet. **Decided deliberately
179
+ * (2026-08-22): scope the record to the run's own workspace for now** rather
180
+ * than pull a schema change forward for a consumer that has not been written,
181
+ * on a table whose shape would be a guess.
182
+ *
183
+ * What it buys today is the thing that separates an attention boundary from
184
+ * v2's suppressor: *"what did we know and not say?"* is answerable. Without a
185
+ * record the `internal` tier is a dark drop, and a dark drop is the defect
186
+ * this whole work package exists to avoid re-introducing.
187
+ *
188
+ * Best-effort — a failure here must never stop a review posting.
189
+ */
190
+ private recordDisposition;
191
+ /**
192
+ * Read a head-side file for the anchor cascade's step 2. Best-effort by
193
+ * design: a miss just means the excerpt is not found there and the cascade
194
+ * moves on to relocation.
195
+ *
196
+ * **The path comes from a model**, so it is confined to the checkout the same
197
+ * way every other path in this handler is — `resolve` then a prefix check, not
198
+ * a `..` denylist. Size-capped because the excerpt scan is O(file) and a
199
+ * findings.json naming a vendored bundle should cost nothing.
200
+ */
201
+ private readHeadFile;
112
202
  /** Build the GitHub client for the post: token+baseUrl in evals, App auth in prod. */
113
203
  private buildReviewClient;
114
204
  private gitHeadSha;
115
- /** Compute the base…head diff locally and parse it into a commentable set. */
116
- private gitCommentableDiff;
205
+ /** Compute the base…head diff locally and parse it into per-file hunks. */
206
+ private gitDiffFiles;
117
207
  private diffFailed;
118
- /** Fetch the PR's diff from the GitHub API and parse it into a commentable
119
- * set — the fallback when there's no local checkout (k8s). GitHub's PR diff
120
- * is the same merge-base…head diff the local three-dot path targets, so the
121
- * anchor set is identical. Best-effort: any failure returns null and every
122
- * finding demotes to the body (the review still posts). */
123
- private apiCommentableDiff;
208
+ /** Fetch the PR's diff from the GitHub API and parse it into per-file hunks —
209
+ * the fallback when there's no local checkout (k8s). GitHub's PR diff is the
210
+ * same merge-base…head diff the local three-dot path targets, so the anchor
211
+ * set is identical. Best-effort: any failure returns null and every finding
212
+ * demotes to the body (the review still posts). */
213
+ private apiDiffFiles;
124
214
  }
125
215
  /** Build the app-registered `post-review` phase-type handler for a run. */
126
216
  export declare function makePostReviewHandler(run: PostReviewRunScope, reporter: PhaseReporter): PhaseTypeHandler;
@@ -1,9 +1,10 @@
1
1
  import { execFileSync } from "node:child_process";
2
- import { existsSync, readFileSync } from "node:fs";
3
- import { join, resolve } from "node:path";
2
+ import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
3
+ import { basename, join, resolve, sep } from "node:path";
4
4
  import { GitHubClient } from "../../engine/github/github.js";
5
- import { buildReview, buildBodyOnlyReview, parseDiff, } from "../../engine/github/review-poster.js";
5
+ import { anchorFindings, buildReview, buildBodyOnlyReview, commentableOf, parseDiffFiles, worstAxis, } from "../../engine/github/review-poster.js";
6
6
  import { getRuntimeConfig } from "../../config/config.js";
7
+ import { defaultReviewConfig } from "lastlight-shared/config-types";
7
8
  import { hasMaterialChange } from "../../engine/pr-decisions.js";
8
9
  import { logger } from "../../logging/logger.js";
9
10
  const log = logger("post-review");
@@ -40,6 +41,160 @@ export function resolveReviewGitHubClient(runConfig) {
40
41
  privateKeyPath: process.env.GITHUB_APP_PRIVATE_KEY_PATH || "",
41
42
  });
42
43
  }
44
+ /**
45
+ * Is this hypothesis row a CLEAN DISCHARGE — the pass saying *"I looked, I
46
+ * quote the line, and it is fine"*?
47
+ *
48
+ * Two conditions, and each one is defensive about a shape that was actually
49
+ * measured on disk:
50
+ *
51
+ * 1. **`discharge` OR `status`, case-insensitively**, mirroring `codeOf` in
52
+ * `code-facts`' `discharge.ts` so the gate and the boundary can never
53
+ * disagree about whether a row was discharged. Rows are heterogeneous: some
54
+ * carry neither (the `spec` pass's invented `{verdict, rationale, path,
55
+ * line, obligation}` shape), and a dead family writes `{status:
56
+ * "notMeasured"}`. Neither is a QUOTE, so neither is clean.
57
+ * 2. **`failureScenario` PRESENT and explicitly `null`**, not merely absent —
58
+ * and this is the load-bearing half. The rule being read is the row shape's
59
+ * own contract, *"on a clean QUOTE write `failureScenario: null`"*, so it is
60
+ * a SELF-REPORT: a row that never wrote the key made no report at all.
61
+ *
62
+ * Measured, and it decides the `--contract minimal` question. Across the two
63
+ * preserved 2026-08-22 runs (the pre-`full` contract, which never asked for
64
+ * the field) **37 rows are `QUOTE` with no `failureScenario` key, and every
65
+ * single one is from `spec.jsonl`'s invented `{claim, status, path, line,
66
+ * evidence}` shape** — a shape with nowhere to record a scenario, so its
67
+ * silence carries no information. Under the `full` contract of 2026-08-23,
68
+ * 71 of 78 clean rows write the key explicitly. Requiring it therefore costs
69
+ * **zero findings** on the full-contract runs (17 / 14 / 7 demoted either
70
+ * way) and makes the rule a **true no-op** on every minimal-contract run,
71
+ * where the loose reading would have silently demoted 28 findings on the
72
+ * strength of a field nobody asked for.
73
+ */
74
+ function isCleanDischarge(row) {
75
+ if (!row || typeof row !== "object" || Array.isArray(row))
76
+ return false;
77
+ const r = row;
78
+ const raw = r.discharge ?? r.status;
79
+ if (typeof raw !== "string" || raw.trim().toUpperCase() !== "QUOTE")
80
+ return false;
81
+ return "failureScenario" in r && r.failureScenario === null;
82
+ }
83
+ /**
84
+ * Which hypothesis ids in `<dir>/hypotheses/*.jsonl` are clean discharges.
85
+ *
86
+ * **`undefined` means there is no `hypotheses/` directory at all** — the
87
+ * shipped two-phase reviewer, and every arm that runs no evidence pipeline. The
88
+ * caller passes it straight through, so no pipeline ⇒ byte-identical output.
89
+ * (An empty set behaves identically by construction: `every` over a non-empty
90
+ * id list against an empty set is false. The distinction is kept for the log.)
91
+ *
92
+ * Identity is assigned exactly as `code-facts`' `readHypothesisSet` assigns it,
93
+ * because the ids in `findings[].hypotheses[]` came out of that reader's own
94
+ * `--ledger`: canonical **`<family>-NNN`**, family from the FILENAME (the
95
+ * survey branch owns its file, so the name is authoritative in a way a
96
+ * self-reported field is not), ordinal from position in an append-only file.
97
+ * A model-declared `id` is honoured as an **alias** only when exactly one row
98
+ * claims it and it shadows no canonical id — an ambiguous alias resolves to
99
+ * nothing, which leaves the finding on the confidence path rather than crediting
100
+ * whichever file sorted first.
101
+ *
102
+ * Parsing is defensive throughout: a torn final line on a killed run is normal
103
+ * and must not throw. Note that a line that parses to a non-object still
104
+ * consumes its ordinal, because `readHypothesisSet` counts it — an ordinal that
105
+ * drifted from the ledger's would mis-resolve every later citation in the file.
106
+ */
107
+ export function readCleanDischarges(dir) {
108
+ let files;
109
+ try {
110
+ files = readdirSync(join(dir, "hypotheses"))
111
+ .filter((f) => f.endsWith(".jsonl"))
112
+ .sort();
113
+ }
114
+ catch {
115
+ // No `hypotheses/` directory — the surveys never ran. Not an empty set:
116
+ // "nobody looked" and "looked, found none clean" are different facts.
117
+ return undefined;
118
+ }
119
+ const cleanCanonical = new Set();
120
+ const canonical = new Set();
121
+ /** A model-declared id → every canonical id claiming it. */
122
+ const claims = new Map();
123
+ for (const file of files) {
124
+ const family = basename(file, ".jsonl");
125
+ let rows;
126
+ try {
127
+ rows = readFileSync(join(dir, "hypotheses", file), "utf8")
128
+ .split("\n")
129
+ .map((line) => line.trim())
130
+ .filter((line) => line.length > 0)
131
+ .flatMap((line) => {
132
+ try {
133
+ return [JSON.parse(line)];
134
+ }
135
+ catch {
136
+ return []; // a torn final line on a killed run is normal
137
+ }
138
+ });
139
+ }
140
+ catch {
141
+ continue; // unreadable file — the other families still count
142
+ }
143
+ rows.forEach((row, index) => {
144
+ const id = `${family}-${String(index + 1).padStart(3, "0")}`;
145
+ canonical.add(id);
146
+ if (isCleanDischarge(row))
147
+ cleanCanonical.add(id);
148
+ const declared = row?.id;
149
+ if (typeof declared === "string" && declared.length > 0 && declared !== id) {
150
+ claims.set(declared, [...(claims.get(declared) ?? []), id]);
151
+ }
152
+ });
153
+ }
154
+ const clean = new Set(cleanCanonical);
155
+ for (const [declared, claimedBy] of claims) {
156
+ // Canonical always wins, and an id two rows claim credits neither.
157
+ if (canonical.has(declared) || claimedBy.length !== 1)
158
+ continue;
159
+ if (cleanCanonical.has(claimedBy[0]))
160
+ clean.add(declared);
161
+ }
162
+ return clean;
163
+ }
164
+ /**
165
+ * Parse one context-projected boundary number back off its string form.
166
+ * The projection is `specContext`'s (`pr-decisions.ts`); garbage degrades to
167
+ * the caller's default — the direction `config.ts` coerces the same keys.
168
+ */
169
+ function toBudget(v, fallback) {
170
+ const n = Number(v);
171
+ return Number.isFinite(n) && n >= 0 ? Math.floor(n) : fallback;
172
+ }
173
+ /** Like {@link toBudget} but fractional — `internalFloor` is a 0..1 bar. */
174
+ function toFloor(v, fallback) {
175
+ const n = Number(v);
176
+ return Number.isFinite(n) && n >= 0 ? n : fallback;
177
+ }
178
+ /** The one JSON-valued context key; an unparseable value means "no bars". */
179
+ function parseThresholds(v) {
180
+ if (typeof v !== "string" || v === "")
181
+ return {};
182
+ try {
183
+ const parsed = JSON.parse(v);
184
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
185
+ return {};
186
+ const out = {};
187
+ for (const [k, val] of Object.entries(parsed)) {
188
+ const n = Number(val);
189
+ if (Number.isFinite(n))
190
+ out[k] = n;
191
+ }
192
+ return out;
193
+ }
194
+ catch {
195
+ return {};
196
+ }
197
+ }
43
198
  /**
44
199
  * The `type: post-review` phase — the one workflow body genuinely coupled to
45
200
  * GitHub, lifted out of the engine into an app-registered {@link PhaseTypeHandler}.
@@ -116,6 +271,24 @@ export class GitHubPostReviewHandler {
116
271
  // phase didn't honour its contract — surface it, don't post silently.
117
272
  return fail(`post-review: could not read findings (${findingsPath}): ${msg}`);
118
273
  }
274
+ // The split verdict (#271 fix 7) only exists when the evidence pipeline is
275
+ // on. Dropping it here rather than trusting nothing to write it is what
276
+ // makes locked decision 8 STRUCTURAL: with `review.analysis.enabled: false`
277
+ // a findings file that carries a `verdict` — a forked prompt, an overlay
278
+ // that got ahead of its config, a model improvising the field — cannot
279
+ // change the event this deployment would have posted yesterday.
280
+ //
281
+ // Operator-layer config on purpose, matching `staleAgainstCurrentHead`
282
+ // below: this runs in-process against a run whose repo-clamped block is not
283
+ // threaded here, and `review.analysis` is operator-only anyway, so the two
284
+ // cannot disagree.
285
+ if (!this.analysisEnabled() && doc.verdict) {
286
+ log.info("Ignoring a split verdict: review.analysis is disabled", {
287
+ repo: `${owner}/${repo}`,
288
+ prNumber,
289
+ });
290
+ doc = { ...doc, verdict: undefined };
291
+ }
119
292
  if (doc.skip) {
120
293
  return succeed(`skipped: ${doc.summary || "agent skipped review"}`);
121
294
  }
@@ -158,13 +331,55 @@ export class GitHubPostReviewHandler {
158
331
  // harness) runs a guaranteed-to-fail `git diff` that dumps a usage block and
159
332
  // a FALSE "demoting all findings to the body" on every run — before the API
160
333
  // fallback silently rescues the findings.
161
- let commentable = localHeadSha && baseRef ? this.gitCommentableDiff(hostRepoDir, baseRef) : null;
334
+ let files = localHeadSha && baseRef ? this.gitDiffFiles(hostRepoDir, baseRef) : null;
162
335
  // No local checkout (or no base ref) — fall back to GitHub's own PR diff
163
336
  // (the same merge-base diff) so findings still anchor inline on k8s instead
164
337
  // of demoting to the body.
165
- if (!commentable)
166
- commentable = await this.apiCommentableDiff(github, owner, repo, prNumber);
167
- const review = buildReview(doc, commentable);
338
+ if (!files)
339
+ files = await this.apiDiffFiles(github, owner, repo, prNumber);
340
+ const commentable = files ? commentableOf(files) : null;
341
+ // WP6a — derive each finding's anchor from its verbatim `existingCode`
342
+ // before anything partitions on `line`. A finding whose analysis is right
343
+ // and whose arithmetic is off by two is otherwise demoted to the body, which
344
+ // is the full price of a wrong answer for a counting slip. Inert on a
345
+ // findings.json whose entries carry no excerpt: `anchorFindings` returns
346
+ // them untouched, so this cannot move a deployment that has not opted in.
347
+ if (files) {
348
+ const anchored = anchorFindings(Array.isArray(doc.findings) ? doc.findings : [], files, localHeadSha ? (p) => this.readHeadFile(hostRepoDir, p) : undefined);
349
+ if (anchored.stats.hunk || anchored.stats.file || anchored.stats.relocated) {
350
+ log.info("Anchored findings from their code excerpts", {
351
+ repo: `${owner}/${repo}`,
352
+ prNumber,
353
+ ...anchored.stats,
354
+ });
355
+ }
356
+ doc = { ...doc, findings: anchored.findings };
357
+ }
358
+ // WP6b — the attention boundary, and it exists ONLY when the evidence
359
+ // pipeline is on. `undefined` here is not a default, it is the whole
360
+ // inertness guarantee: `buildReview` takes its pre-WP6b branch and a
361
+ // deployment that never opted in gets no cap, no thresholds and no
362
+ // `internal` tier, whatever a findings.json happens to carry.
363
+ const boundary = this.attentionBoundary();
364
+ // The anti-finding rule (below). Read ONLY when a boundary exists, so a
365
+ // deployment that never opted in does not even stat the directory — the
366
+ // same inertness discipline the boundary itself keeps.
367
+ const clean = boundary
368
+ ? readCleanDischarges(join(hostRepoDir, ".lastlight", "pr-review"))
369
+ : undefined;
370
+ const review = buildReview(doc, commentable, boundary, clean);
371
+ if (boundary && review.tiered) {
372
+ const antiFindings = review.tiered.internal.filter((r) => r.reason === "clean-discharge").length;
373
+ if (clean?.size || antiFindings) {
374
+ log.info("Withheld findings whose evidence is entirely clean discharges", {
375
+ repo: `${owner}/${repo}`,
376
+ prNumber,
377
+ cleanHypotheses: clean?.size ?? 0,
378
+ antiFindings,
379
+ });
380
+ }
381
+ this.recordDisposition(hostRepoDir, boundary, review.tiered);
382
+ }
168
383
  const repeat = this.repeatOfLastReview(history.latest, review);
169
384
  if (repeat) {
170
385
  log.info("Skipping a duplicate review post", { repo: `${owner}/${repo}`, prNumber, summary: repeat });
@@ -177,14 +392,27 @@ export class GitHubPostReviewHandler {
177
392
  comments: review.comments,
178
393
  commitId: headSha,
179
394
  });
180
- return succeed(`posted review: ${review.inlineCount} inline, ${review.demotedCount} in body, event=${review.event}`);
395
+ // Name the downgrade in the ledger row when the split verdict caused one.
396
+ // Without it "event=COMMENT" on a doc whose `event` says APPROVE reads as
397
+ // a bug rather than as the axis floor doing its job.
398
+ const downgraded = doc.event === "APPROVE" && review.event !== "APPROVE" && worstAxis(doc.verdict) === "fail"
399
+ ? `, downgraded from APPROVE by verdict spec=${doc.verdict?.spec ?? "-"}/standards=${doc.verdict?.standards ?? "-"}`
400
+ : "";
401
+ // The `internal` count is reported even when it is zero, and only when a
402
+ // boundary applied: "recorded, not posted" is a number nobody can read off
403
+ // the review itself, and leaving it out of the one line the ledger keeps
404
+ // is how a dark drop would look exactly like a quiet review.
405
+ const withheld = review.tiered ? `, ${review.internalCount} recorded-only` : "";
406
+ return succeed(`posted review: ${review.inlineCount} inline, ${review.demotedCount} in body${withheld}, event=${review.event}${downgraded}`);
181
407
  }
182
408
  catch (err) {
183
409
  const msg = err instanceof Error ? err.message : String(err);
184
410
  log.warn("Inline review POST failed; retrying body-only", { err });
185
411
  // Off-diff anchors (e.g. a stale diff) 422 — retry with everything in the
186
412
  // body so the review still lands.
187
- const bodyOnly = buildBodyOnlyReview(doc);
413
+ // The tiering, when there was one: the retry must not republish what the
414
+ // boundary recorded-and-withheld just because GitHub rejected an anchor.
415
+ const bodyOnly = buildBodyOnlyReview(doc, review.tiered);
188
416
  try {
189
417
  await github.createPullRequestReview(owner, repo, prNumber, {
190
418
  body: bodyOnly.body,
@@ -296,6 +524,149 @@ export class GitHubPostReviewHandler {
296
524
  return workDir;
297
525
  return repoDir;
298
526
  }
527
+ /**
528
+ * The attention budget, or `undefined` when the evidence pipeline is off.
529
+ *
530
+ * Operator-layer config, matching the `verdict` strip and
531
+ * `staleAgainstCurrentHead` — `review.analysis` is operator-only anyway, so
532
+ * the repo-clamped block cannot disagree with it.
533
+ */
534
+ attentionBoundary() {
535
+ if (!this.analysisEnabled())
536
+ return undefined;
537
+ // The RUN CONTEXT is the first authority, for the same reason
538
+ // `analysisEnabled()` reads it: the eval harness threads the arm's
539
+ // `review:` policy through the context and never populates the
540
+ // process-global runtime config, so a boundary read only off
541
+ // `getRuntimeConfig()` silently applies the packaged defaults to every
542
+ // eval arm — found on this pipeline's own PR after three repeats of an
543
+ // arm that pinned `maxBodyComments: null` each recorded 5–14
544
+ // `body-budget` demotions. `specContext` projects all four fields
545
+ // together, so their presence is atomic; production projects them from
546
+ // the same runtime config this fallback reads, so the two authorities
547
+ // cannot disagree there.
548
+ const ctx = this.run.ctx;
549
+ if (typeof ctx.maxInlineComments === "string") {
550
+ return {
551
+ maxInlineComments: toBudget(ctx.maxInlineComments, defaultReviewConfig().analysis.maxInlineComments),
552
+ thresholds: parseThresholds(ctx.boundaryThresholds),
553
+ internalFloor: toFloor(ctx.internalFloor, defaultReviewConfig().analysis.internalFloor),
554
+ // `"null"` is the literal the projection writes for the documented
555
+ // "unlimited body overflow" value; anything else degrades to the
556
+ // shipped default, the same direction `config.ts` coerces garbage —
557
+ // and read from the same authority, so the two cannot drift apart when
558
+ // the default moves.
559
+ maxBodyComments: ctx.maxBodyComments === "null"
560
+ ? null
561
+ : toBudget(ctx.maxBodyComments, defaultReviewConfig().analysis.maxBodyComments ?? 0),
562
+ };
563
+ }
564
+ const analysis = getRuntimeConfig()?.review?.analysis ?? defaultReviewConfig().analysis;
565
+ return {
566
+ maxInlineComments: analysis.maxInlineComments,
567
+ thresholds: analysis.thresholds ?? {},
568
+ internalFloor: analysis.internalFloor,
569
+ // Nullable on purpose — `null` is the documented "unlimited body
570
+ // overflow" value, so it must survive this projection rather than be
571
+ // defaulted away. `??` here would erase the operator's explicit choice.
572
+ maxBodyComments: analysis.maxBodyComments,
573
+ };
574
+ }
575
+ /**
576
+ * Is the review evidence pipeline on FOR THIS RUN?
577
+ *
578
+ * Two authorities, and the second one is why this is a method rather than a
579
+ * `getRuntimeConfig()` read at each site. The process-global runtime config is
580
+ * the production authority. But `analysisEnabled` on the run CONTEXT is what
581
+ * every gated phase in `pr-review.yaml` actually keys off — `specContext`
582
+ * projects it, and only when the run's own effective review config had
583
+ * `analysis.enabled`. So the context is the run-scoped truth, and reading only
584
+ * the global one makes this handler disagree with the twelve phases upstream
585
+ * of it about whether the pipeline ran.
586
+ *
587
+ * **Measured 2026-08-22, and it silently cost a whole arm.** The eval harness
588
+ * threads the arm's `review:` policy through `prContextPatch` and never
589
+ * populates the runtime config, so a pipeline-ON eval run had all twelve
590
+ * analysis phases fire and then hit a `post-review` that believed the pipeline
591
+ * was off: the attention boundary was inert (every `internal`-tier finding
592
+ * POSTED, no inline cap, no family thresholds) and the split verdict was
593
+ * stripped. Twenty findings posted where the shipped configuration would have
594
+ * posted eleven — a precision number describing a deployment that does not
595
+ * exist.
596
+ *
597
+ * The inertness guarantee is unchanged: `specContext` returns `{}` when
598
+ * analysis is off, so `analysisEnabled` is ABSENT — not `false` — on every
599
+ * deployment that has not opted in, and neither authority can be satisfied.
600
+ */
601
+ analysisEnabled() {
602
+ if (getRuntimeConfig()?.review?.analysis?.enabled)
603
+ return true;
604
+ return this.run.ctx.analysisEnabled === "true";
605
+ }
606
+ /**
607
+ * Write what happened to each finding — its tier, and why.
608
+ *
609
+ * [WP6](../../../../../docs/plans/deterministic-pr-levers.md#adjudication-and-the-attention-boundary-wp6)'s
610
+ * AC1b asks for this in a `review_findings` table, and that table is
611
+ * [WP7](../../../../../docs/plans/deterministic-pr-levers.md#review-memory-wp7)'s
612
+ * — which depends on WP6, so it does not exist yet. **Decided deliberately
613
+ * (2026-08-22): scope the record to the run's own workspace for now** rather
614
+ * than pull a schema change forward for a consumer that has not been written,
615
+ * on a table whose shape would be a guess.
616
+ *
617
+ * What it buys today is the thing that separates an attention boundary from
618
+ * v2's suppressor: *"what did we know and not say?"* is answerable. Without a
619
+ * record the `internal` tier is a dark drop, and a dark drop is the defect
620
+ * this whole work package exists to avoid re-introducing.
621
+ *
622
+ * Best-effort — a failure here must never stop a review posting.
623
+ */
624
+ recordDisposition(repoDir, boundary, tiered) {
625
+ try {
626
+ const rows = [
627
+ ...tiered.inline.map((f) => ({ tier: "inline", reason: null, finding: f })),
628
+ ...tiered.body.map((d) => ({ tier: "body", reason: d.reason, finding: d.finding })),
629
+ // `reason` is the same machine token the body tier carries, not prose:
630
+ // the sibling eval harness reads this file, and "below the internal
631
+ // floor" as a sentence made the three causes of a withheld finding
632
+ // indistinguishable to anything but a human.
633
+ ...tiered.internal.map((r) => ({
634
+ tier: "internal",
635
+ reason: r.reason,
636
+ finding: r.finding,
637
+ })),
638
+ ];
639
+ writeFileSync(join(repoDir, ".lastlight", "pr-review", "disposition.json"), JSON.stringify({ generatedAt: new Date().toISOString(), boundary, findings: rows }, null, 2));
640
+ }
641
+ catch (err) {
642
+ log.warn("Could not record the finding disposition", { err });
643
+ }
644
+ }
645
+ /**
646
+ * Read a head-side file for the anchor cascade's step 2. Best-effort by
647
+ * design: a miss just means the excerpt is not found there and the cascade
648
+ * moves on to relocation.
649
+ *
650
+ * **The path comes from a model**, so it is confined to the checkout the same
651
+ * way every other path in this handler is — `resolve` then a prefix check, not
652
+ * a `..` denylist. Size-capped because the excerpt scan is O(file) and a
653
+ * findings.json naming a vendored bundle should cost nothing.
654
+ */
655
+ readHeadFile(repoDir, relPath) {
656
+ try {
657
+ const root = resolve(repoDir);
658
+ const full = resolve(root, relPath);
659
+ if (full !== root && !full.startsWith(root + sep))
660
+ return null;
661
+ const st = statSync(full);
662
+ if (!st.isFile() || st.size > 2 * 1024 * 1024)
663
+ return null;
664
+ return readFileSync(full, "utf8");
665
+ }
666
+ catch {
667
+ return null;
668
+ }
669
+ }
299
670
  /** Build the GitHub client for the post: token+baseUrl in evals, App auth in prod. */
300
671
  buildReviewClient() {
301
672
  return resolveReviewGitHubClient(this.run.config);
@@ -314,8 +685,8 @@ export class GitHubPostReviewHandler {
314
685
  return undefined;
315
686
  }
316
687
  }
317
- /** Compute the base…head diff locally and parse it into a commentable set. */
318
- gitCommentableDiff(repoDir, baseRef) {
688
+ /** Compute the base…head diff locally and parse it into per-file hunks. */
689
+ gitDiffFiles(repoDir, baseRef) {
319
690
  const git = (...args) => execFileSync("git", ["-C", repoDir, ...args], { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });
320
691
  const tryGit = (...args) => {
321
692
  try {
@@ -328,14 +699,14 @@ export class GitHubPostReviewHandler {
328
699
  // The three-dot (merge-base…head) diff mirrors GitHub's own PR diff exactly,
329
700
  // so it's the ideal anchor set — but it needs the merge-base present locally,
330
701
  // which a shallow `--depth 1 --single-branch` pr-review clone doesn't have.
331
- const threeDot = () => parseDiff(git("diff", `origin/${baseRef}...HEAD`));
702
+ const threeDot = () => parseDiffFiles(git("diff", `origin/${baseRef}...HEAD`));
332
703
  // Two-dot compares the two end trees directly — no history walk — so it works
333
704
  // on ANY clone depth (down to depth 1). It's a *superset* of the three-dot
334
705
  // diff (it also shows changes the base picked up since the PR forked), which
335
706
  // is a safe over-approximation for anchoring: the agent's findings sit on the
336
707
  // PR's own changed lines (⊆ three-dot ⊆ two-dot), and any stray off-diff
337
708
  // anchor is caught by the body-only POST retry.
338
- const twoDot = () => parseDiff(git("diff", `origin/${baseRef}`, "HEAD"));
709
+ const twoDot = () => parseDiffFiles(git("diff", `origin/${baseRef}`, "HEAD"));
339
710
  // Materialize origin/<base> as a real remote-tracking ref (a single-branch
340
711
  // clone's refspec only covers the PR branch, so a bare `fetch origin <base>`
341
712
  // updates FETCH_HEAD but may not create origin/<base>).
@@ -385,14 +756,14 @@ export class GitHubPostReviewHandler {
385
756
  log.warn("Could not compute commentable diff; demoting all findings to the body", { reason: msg });
386
757
  return null;
387
758
  }
388
- /** Fetch the PR's diff from the GitHub API and parse it into a commentable
389
- * set — the fallback when there's no local checkout (k8s). GitHub's PR diff
390
- * is the same merge-base…head diff the local three-dot path targets, so the
391
- * anchor set is identical. Best-effort: any failure returns null and every
392
- * finding demotes to the body (the review still posts). */
393
- async apiCommentableDiff(github, owner, repo, prNumber) {
759
+ /** Fetch the PR's diff from the GitHub API and parse it into per-file hunks —
760
+ * the fallback when there's no local checkout (k8s). GitHub's PR diff is the
761
+ * same merge-base…head diff the local three-dot path targets, so the anchor
762
+ * set is identical. Best-effort: any failure returns null and every finding
763
+ * demotes to the body (the review still posts). */
764
+ async apiDiffFiles(github, owner, repo, prNumber) {
394
765
  try {
395
- return parseDiff(await github.getPullRequestDiff(owner, repo, prNumber));
766
+ return parseDiffFiles(await github.getPullRequestDiff(owner, repo, prNumber));
396
767
  }
397
768
  catch (err) {
398
769
  return this.diffFailed(err instanceof Error ? err.message : String(err));