lastlight-core 0.37.0 → 0.38.1

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.
@@ -0,0 +1,152 @@
1
+ export declare const REVIEW_LEDGER_VERSION = 1;
2
+ export declare const REVIEW_LEDGER_SCRATCH_KEY = "reviewLedger";
3
+ /** Findings kept at most — a bound on the run row, not a policy. */
4
+ export declare const MAX_LEDGER_FINDINGS = 80;
5
+ /** Units kept at most — `units.json`'s own ceiling, plus the `pr` unit. */
6
+ export declare const MAX_LEDGER_UNITS = 151;
7
+ /**
8
+ * Width of one line hash — code-facts' `LINE_HASH_CHARS` (6 base64url chars),
9
+ * restated because core does not depend on code-facts.
10
+ */
11
+ export declare const LEDGER_LINE_HASH_CHARS = 6;
12
+ /**
13
+ * Line-hash characters kept at most (5,000 lines). Measured on lastlight#424,
14
+ * a 2,000-line PR: ~4.5 KB. Over it the LARGEST files go first — a file with
15
+ * no recorded lines is judged by its unit's delta instead (a softer gate,
16
+ * never a missing one).
17
+ */
18
+ export declare const MAX_LEDGER_LINE_CHARS = 30000;
19
+ export type LedgerStatus = "open" | "withheld" | "addressed" | "resolved";
20
+ export type LedgerTier = "inline" | "body" | "internal";
21
+ export interface LedgerFinding {
22
+ /** sha1 of the path and the normalised quoted code — see {@link findingFingerprint}. */
23
+ fp: string;
24
+ path: string;
25
+ line: number | null;
26
+ /** The quoted code, trimmed and capped — what the fingerprint and the "addressed" test read. */
27
+ excerpt: string;
28
+ title: string;
29
+ severity: string | null;
30
+ importance: string | null;
31
+ tier: LedgerTier;
32
+ /** The poster's demotion / internal reason, as `disposition.json` records it. */
33
+ reason: string | null;
34
+ status: LedgerStatus;
35
+ /** The head this finding was first produced at, and last re-produced or carried at. */
36
+ foundAt: string | null;
37
+ lastSeenAt: string | null;
38
+ /** The head whose review closed it — set with `addressed` / `resolved`. */
39
+ closedAt?: string | null;
40
+ }
41
+ export interface LedgerUnit {
42
+ key: string;
43
+ contentSha: string | null;
44
+ }
45
+ export interface ReviewLedger {
46
+ version: typeof REVIEW_LEDGER_VERSION;
47
+ /** The head the latest fold ran at. */
48
+ head: string | null;
49
+ at: string;
50
+ /** Reviews folded in, ever. */
51
+ rounds: number;
52
+ units: LedgerUnit[];
53
+ /**
54
+ * Per file, the line hashes (code-facts' `lineHash`, 6 base64url chars each,
55
+ * concatenated) of every non-trivial line the last review's units covered —
56
+ * the convergence gate's evidence that a finding's code was already there.
57
+ * Replaced with `units`. Absent on a ledger written before it.
58
+ */
59
+ lines?: Record<string, string>;
60
+ findings: LedgerFinding[];
61
+ /** Set when a cap dropped entries. */
62
+ truncated?: boolean;
63
+ }
64
+ /** The poster's disposition of one finding — `disposition.json`'s row. */
65
+ export interface DispositionRow {
66
+ tier: LedgerTier;
67
+ reason: string | null;
68
+ finding: {
69
+ path?: string;
70
+ line?: number;
71
+ existingCode?: string;
72
+ title?: string;
73
+ severity?: string;
74
+ importance?: string;
75
+ };
76
+ }
77
+ /** One review thread, the fields `getPullRequestDiscussion` returns. */
78
+ export interface LedgerThread {
79
+ path: string;
80
+ isResolved: boolean;
81
+ isOutdated: boolean;
82
+ comments: {
83
+ author: string;
84
+ isBot: boolean;
85
+ body: string;
86
+ }[];
87
+ }
88
+ /**
89
+ * A finding's identity across rounds: its file and the code it quotes,
90
+ * whitespace-normalised. A finding with no quote falls back to its title —
91
+ * the one case where prose decides, and the weakest identity there is.
92
+ */
93
+ export declare function findingFingerprint(path: string, existingCode: string | undefined, title: string | undefined): string;
94
+ /**
95
+ * Read a ledger back off JSON that outlives the build that wrote it: anything
96
+ * that is not recognisably a ledger is `null`, and a malformed entry is dropped
97
+ * rather than failing the read.
98
+ */
99
+ export declare function coerceLedger(value: unknown): ReviewLedger | null;
100
+ export interface FoldInput {
101
+ prior: ReviewLedger | null;
102
+ /** The head this review ran at. */
103
+ head: string | null;
104
+ /** This review's units (`units.json`); `null` when it cut none — the prior units carry. */
105
+ units: LedgerUnit[] | null;
106
+ /** This review's per-file line hashes, read with the units; `null` carries the prior ones. */
107
+ lines?: Record<string, string> | null;
108
+ /** This review's dispositions; `[]` when it produced no finding. */
109
+ dispositions: readonly DispositionRow[];
110
+ /**
111
+ * Is this quoted code still in this file at this head? `null` = cannot tell
112
+ * (no checkout) — the entry keeps its status.
113
+ */
114
+ excerptPresent: (path: string, excerpt: string) => boolean | null;
115
+ /** The PR's review threads; `null` when the read failed — no entry is resolved from them. */
116
+ threads: readonly LedgerThread[] | null;
117
+ /** GraphQL's name for the bot (no `[bot]` suffix). */
118
+ bot: string;
119
+ now?: string;
120
+ }
121
+ /** Fold one review into the ledger. Pure. */
122
+ export declare function foldReviewLedger(input: FoldInput): ReviewLedger;
123
+ /**
124
+ * Open findings an EARLIER review posted — what a re-review must neither post
125
+ * again nor call good to merge over.
126
+ */
127
+ export declare function carriedOpen(ledger: ReviewLedger | null): LedgerFinding[];
128
+ /** The fingerprints of {@link carriedOpen} — `post-review`'s deterministic "already raised" test. */
129
+ export declare function openFingerprints(ledger: ReviewLedger | null): Set<string>;
130
+ /** `prior-review.json` for code-facts' `units --prior`, or `null` with nothing to compare. */
131
+ export declare function priorReviewOf(ledger: ReviewLedger | null): {
132
+ version: 1;
133
+ head: string | null;
134
+ units: LedgerUnit[];
135
+ files?: Record<string, string>;
136
+ } | null;
137
+ /**
138
+ * The re-review status lines that open the posted summary, rendered in code:
139
+ * what an earlier review posted that this head addressed or a maintainer
140
+ * resolved, and what is still open. Only POSTED findings are named — a
141
+ * withheld finding was never shown, so it is never "fixed" either. The line
142
+ * prefixes are the ones `review-summary.ts`'s ledger grammar reads.
143
+ */
144
+ export declare function renderLedgerStatus(ledger: ReviewLedger): string;
145
+ /**
146
+ * The ledger as the `select` prompt sees it: what earlier reviews already
147
+ * posted and is still open, so a site re-finding one of them marks it
148
+ * `alreadyRaised` instead of posting it again. Withheld entries are listed
149
+ * apart: they were never shown to the author, so re-raising one is a choice,
150
+ * not a duplicate. Empty string when there is nothing to say.
151
+ */
152
+ export declare function renderLedgerForSelect(ledger: ReviewLedger | null): string;
@@ -0,0 +1,302 @@
1
+ /**
2
+ * The PR's review ledger — what our reviews of this PR found, what became of
3
+ * each finding, and which code they had already covered (issue #429).
4
+ *
5
+ * Re-reviews kept raising new points on code that had not changed since the
6
+ * first review (46% of later-round comments, nearform PRs, Sept 2026), because
7
+ * nothing carried from one round to the next but the GitHub review itself: the
8
+ * withheld findings were overwritten with the workspace, `select` was asked
9
+ * to spot its own earlier points in the rendered discussion, and the sites
10
+ * pipeline re-sampled the whole PR every round. This is the memory.
11
+ *
12
+ * **It is a field of the snapshot, never a store beside it** — the PR journal's
13
+ * rule (`pr-notes.ts`). `post-review` folds the run's dispositions into the
14
+ * ledger it was dispatched with and writes the result to the run's
15
+ * `scratch.reviewLedger`; the next dispatch reads it back onto
16
+ * `PrState.reviewLedger` (`deriveReviewLedger`). No table, no migration.
17
+ *
18
+ * Two halves:
19
+ *
20
+ * - `units` — `{key, contentSha}` of every unit the last review cut, so the
21
+ * next one can tell which code it already had (`prior-review.json`,
22
+ * code-facts' `review-delta.ts`). Replaced wholesale by each review that cut
23
+ * units; carried untouched by one that did not.
24
+ * - `findings` — every finding a review produced, posted or not, keyed by a
25
+ * FINGERPRINT of its file and the code it quotes (`existingCode`, the anchor
26
+ * of record). Title and body are model prose and never part of identity.
27
+ *
28
+ * Status comes only from structured signals, never from reply text (the
29
+ * notes' "hints, never instructions" rule — PR content can come from outside
30
+ * contributors):
31
+ *
32
+ * - `open` — posted, and its quoted code is still there;
33
+ * - `withheld` — recorded, never posted (a nit, the attention boundary, the
34
+ * convergence gate) — kept so a later round cannot "discover" it;
35
+ * - `addressed` — its quoted code is gone from the file at this head;
36
+ * - `resolved` — a maintainer resolved our thread on it.
37
+ *
38
+ * Closed entries (`addressed`, `resolved`) are kept for exactly the round that
39
+ * closed them — the round whose summary says so — and dropped by the next
40
+ * fold. Open and withheld entries are never evicted by age; a hard cap keeps
41
+ * the run row bounded, dropping withheld before open, and says so.
42
+ */
43
+ import { createHash } from "node:crypto";
44
+ export const REVIEW_LEDGER_VERSION = 1;
45
+ export const REVIEW_LEDGER_SCRATCH_KEY = "reviewLedger";
46
+ /** Findings kept at most — a bound on the run row, not a policy. */
47
+ export const MAX_LEDGER_FINDINGS = 80;
48
+ /** Units kept at most — `units.json`'s own ceiling, plus the `pr` unit. */
49
+ export const MAX_LEDGER_UNITS = 151;
50
+ /**
51
+ * Width of one line hash — code-facts' `LINE_HASH_CHARS` (6 base64url chars),
52
+ * restated because core does not depend on code-facts.
53
+ */
54
+ export const LEDGER_LINE_HASH_CHARS = 6;
55
+ /**
56
+ * Line-hash characters kept at most (5,000 lines). Measured on lastlight#424,
57
+ * a 2,000-line PR: ~4.5 KB. Over it the LARGEST files go first — a file with
58
+ * no recorded lines is judged by its unit's delta instead (a softer gate,
59
+ * never a missing one).
60
+ */
61
+ export const MAX_LEDGER_LINE_CHARS = 30_000;
62
+ const MAX_EXCERPT = 160;
63
+ const MAX_TITLE = 160;
64
+ function normaliseCode(code) {
65
+ return code
66
+ .split("\n")
67
+ .map((l) => l.trim())
68
+ .filter(Boolean)
69
+ .join("\n");
70
+ }
71
+ /**
72
+ * A finding's identity across rounds: its file and the code it quotes,
73
+ * whitespace-normalised. A finding with no quote falls back to its title —
74
+ * the one case where prose decides, and the weakest identity there is.
75
+ */
76
+ export function findingFingerprint(path, existingCode, title) {
77
+ const code = existingCode ? normaliseCode(existingCode) : "";
78
+ const basis = code ? `code\0${code}` : `title\0${(title ?? "").trim().toLowerCase()}`;
79
+ return createHash("sha1").update(`${path}\0${basis}`).digest("hex").slice(0, 16);
80
+ }
81
+ const POSTED = new Set(["inline", "body"]);
82
+ const isPosted = (f) => POSTED.has(f.tier);
83
+ /**
84
+ * Read a ledger back off JSON that outlives the build that wrote it: anything
85
+ * that is not recognisably a ledger is `null`, and a malformed entry is dropped
86
+ * rather than failing the read.
87
+ */
88
+ export function coerceLedger(value) {
89
+ if (!value || typeof value !== "object")
90
+ return null;
91
+ const v = value;
92
+ if (v.version !== REVIEW_LEDGER_VERSION || !Array.isArray(v.findings) || !Array.isArray(v.units))
93
+ return null;
94
+ const str = (x) => (typeof x === "string" ? x : null);
95
+ const findings = [];
96
+ for (const raw of v.findings) {
97
+ if (!raw || typeof raw !== "object")
98
+ continue;
99
+ const f = raw;
100
+ if (typeof f.fp !== "string" || typeof f.path !== "string" || typeof f.status !== "string")
101
+ continue;
102
+ if (!["open", "withheld", "addressed", "resolved"].includes(f.status))
103
+ continue;
104
+ findings.push({
105
+ fp: f.fp,
106
+ path: f.path,
107
+ line: typeof f.line === "number" ? f.line : null,
108
+ excerpt: str(f.excerpt) ?? "",
109
+ title: str(f.title) ?? "",
110
+ severity: str(f.severity),
111
+ importance: str(f.importance),
112
+ tier: f.tier === "inline" || f.tier === "body" ? f.tier : "internal",
113
+ reason: str(f.reason),
114
+ status: f.status,
115
+ foundAt: str(f.foundAt),
116
+ lastSeenAt: str(f.lastSeenAt),
117
+ ...(f.closedAt !== undefined ? { closedAt: str(f.closedAt) } : {}),
118
+ });
119
+ }
120
+ const units = v.units
121
+ .filter((u) => !!u && typeof u === "object" && typeof u.key === "string")
122
+ .map((u) => ({ key: u.key, contentSha: str(u.contentSha) }));
123
+ const lines = v.lines && typeof v.lines === "object" && !Array.isArray(v.lines)
124
+ ? Object.fromEntries(Object.entries(v.lines).filter((e) => typeof e[1] === "string"))
125
+ : null;
126
+ return {
127
+ version: REVIEW_LEDGER_VERSION,
128
+ head: str(v.head),
129
+ at: str(v.at) ?? new Date(0).toISOString(),
130
+ rounds: typeof v.rounds === "number" ? v.rounds : 0,
131
+ units,
132
+ ...(lines ? { lines } : {}),
133
+ findings,
134
+ ...(v.truncated === true ? { truncated: true } : {}),
135
+ };
136
+ }
137
+ /** Is a bot thread about this ledger finding? Same file, and our first comment carries its title. */
138
+ function threadFor(f, threads, bot) {
139
+ if (!f.title)
140
+ return undefined;
141
+ return threads.find((t) => {
142
+ const first = t.comments[0];
143
+ return t.path === f.path && !!first?.isBot && first.author === bot && first.body.includes(f.title);
144
+ });
145
+ }
146
+ /** Fold one review into the ledger. Pure. */
147
+ export function foldReviewLedger(input) {
148
+ const head = input.head;
149
+ // Closed entries were reported by the round that closed them; they go now.
150
+ const carried = (input.prior?.findings ?? []).filter((f) => f.status === "open" || f.status === "withheld").map((f) => ({ ...f }));
151
+ for (const f of carried) {
152
+ const thread = input.threads ? threadFor(f, input.threads, input.bot) : undefined;
153
+ if (f.status === "open" && thread?.isResolved) {
154
+ f.status = "resolved";
155
+ f.closedAt = head;
156
+ continue;
157
+ }
158
+ if (f.excerpt && input.excerptPresent(f.path, f.excerpt) === false) {
159
+ f.status = "addressed";
160
+ f.closedAt = head;
161
+ }
162
+ }
163
+ const byFp = new Map(carried.map((f) => [f.fp, f]));
164
+ const fresh = [];
165
+ for (const row of input.dispositions) {
166
+ const d = row.finding;
167
+ if (!d.path)
168
+ continue;
169
+ const fp = findingFingerprint(d.path, d.existingCode, d.title);
170
+ const known = byFp.get(fp);
171
+ if (known && (known.status === "open" || known.status === "withheld")) {
172
+ known.lastSeenAt = head;
173
+ // Withheld last time, posted now: it is open from here on.
174
+ if (known.status === "withheld" && POSTED.has(row.tier)) {
175
+ known.status = "open";
176
+ known.tier = row.tier;
177
+ known.reason = row.reason;
178
+ }
179
+ continue;
180
+ }
181
+ const entry = {
182
+ fp,
183
+ path: d.path,
184
+ line: typeof d.line === "number" ? d.line : null,
185
+ excerpt: normaliseCode(d.existingCode ?? "").slice(0, MAX_EXCERPT),
186
+ title: (d.title ?? "").slice(0, MAX_TITLE),
187
+ severity: d.severity ?? null,
188
+ importance: d.importance ?? null,
189
+ tier: row.tier,
190
+ reason: row.reason,
191
+ status: POSTED.has(row.tier) ? "open" : "withheld",
192
+ foundAt: head,
193
+ lastSeenAt: head,
194
+ };
195
+ byFp.set(fp, entry);
196
+ fresh.push(entry);
197
+ }
198
+ const { findings, truncated } = bound([...carried, ...fresh]);
199
+ const units = (input.units ?? input.prior?.units ?? []).slice(0, MAX_LEDGER_UNITS);
200
+ const lineSource = input.units ? (input.lines ?? null) : (input.prior?.lines ?? null);
201
+ const lines = lineSource ? boundLines(lineSource) : null;
202
+ return {
203
+ version: REVIEW_LEDGER_VERSION,
204
+ head,
205
+ at: input.now ?? new Date().toISOString(),
206
+ rounds: (input.prior?.rounds ?? 0) + 1,
207
+ units,
208
+ ...(lines ? { lines: lines.lines } : {}),
209
+ findings,
210
+ ...(truncated || lines?.truncated || (input.units?.length ?? 0) > MAX_LEDGER_UNITS ? { truncated: true } : {}),
211
+ };
212
+ }
213
+ /** Keep the line hashes under {@link MAX_LEDGER_LINE_CHARS}, dropping the largest files first. */
214
+ function boundLines(lines) {
215
+ const entries = Object.entries(lines);
216
+ let total = entries.reduce((n, [, v]) => n + v.length, 0);
217
+ if (total <= MAX_LEDGER_LINE_CHARS)
218
+ return { lines, truncated: false };
219
+ const kept = new Map(entries);
220
+ for (const [path, v] of [...entries].sort((a, b) => b[1].length - a[1].length)) {
221
+ if (total <= MAX_LEDGER_LINE_CHARS)
222
+ break;
223
+ kept.delete(path);
224
+ total -= v.length;
225
+ }
226
+ return { lines: Object.fromEntries(kept), truncated: true };
227
+ }
228
+ const KEEP_ORDER = { open: 0, addressed: 1, resolved: 1, withheld: 2 };
229
+ const IMPORTANCE_ORDER = { "must-fix": 0, "worth-mentioning": 1, nit: 2 };
230
+ function bound(findings) {
231
+ if (findings.length <= MAX_LEDGER_FINDINGS)
232
+ return { findings, truncated: false };
233
+ const ranked = findings
234
+ .map((f, i) => ({ f, i }))
235
+ .sort((a, b) => KEEP_ORDER[a.f.status] - KEEP_ORDER[b.f.status] ||
236
+ (IMPORTANCE_ORDER[a.f.importance ?? ""] ?? 1) - (IMPORTANCE_ORDER[b.f.importance ?? ""] ?? 1) ||
237
+ a.i - b.i);
238
+ const keep = new Set(ranked.slice(0, MAX_LEDGER_FINDINGS).map((r) => r.i));
239
+ return { findings: findings.filter((_, i) => keep.has(i)), truncated: true };
240
+ }
241
+ /**
242
+ * Open findings an EARLIER review posted — what a re-review must neither post
243
+ * again nor call good to merge over.
244
+ */
245
+ export function carriedOpen(ledger) {
246
+ return (ledger?.findings ?? []).filter((f) => f.status === "open" && isPosted(f));
247
+ }
248
+ /** The fingerprints of {@link carriedOpen} — `post-review`'s deterministic "already raised" test. */
249
+ export function openFingerprints(ledger) {
250
+ return new Set(carriedOpen(ledger).map((f) => f.fp));
251
+ }
252
+ /** `prior-review.json` for code-facts' `units --prior`, or `null` with nothing to compare. */
253
+ export function priorReviewOf(ledger) {
254
+ if (!ledger || ledger.units.length === 0)
255
+ return null;
256
+ return { version: 1, head: ledger.head, units: ledger.units, ...(ledger.lines ? { files: ledger.lines } : {}) };
257
+ }
258
+ function listTitles(fs, max = 5) {
259
+ const shown = fs.slice(0, max).map((f) => `${f.title || "(untitled)"} (\`${f.path}\`)`);
260
+ return `${shown.join("; ")}${fs.length > max ? `; and ${fs.length - max} more` : ""}`;
261
+ }
262
+ /**
263
+ * The re-review status lines that open the posted summary, rendered in code:
264
+ * what an earlier review posted that this head addressed or a maintainer
265
+ * resolved, and what is still open. Only POSTED findings are named — a
266
+ * withheld finding was never shown, so it is never "fixed" either. The line
267
+ * prefixes are the ones `review-summary.ts`'s ledger grammar reads.
268
+ */
269
+ export function renderLedgerStatus(ledger) {
270
+ const head = ledger.head;
271
+ const closed = ledger.findings.filter((f) => isPosted(f) && (f.status === "addressed" || f.status === "resolved") && f.closedAt === head);
272
+ const open = ledger.findings.filter((f) => isPosted(f) && f.status === "open" && f.foundAt !== head);
273
+ const lines = [];
274
+ if (closed.length)
275
+ lines.push(`**Addressed since the last review:** ${listTitles(closed)}`);
276
+ if (open.length)
277
+ lines.push(`**Still open:** ${listTitles(open)}`);
278
+ return lines.join("\n");
279
+ }
280
+ /**
281
+ * The ledger as the `select` prompt sees it: what earlier reviews already
282
+ * posted and is still open, so a site re-finding one of them marks it
283
+ * `alreadyRaised` instead of posting it again. Withheld entries are listed
284
+ * apart: they were never shown to the author, so re-raising one is a choice,
285
+ * not a duplicate. Empty string when there is nothing to say.
286
+ */
287
+ export function renderLedgerForSelect(ledger) {
288
+ if (!ledger)
289
+ return "";
290
+ const open = carriedOpen(ledger);
291
+ const withheld = ledger.findings.filter((f) => f.status === "withheld");
292
+ if (!open.length && !withheld.length)
293
+ return "";
294
+ const row = (f) => `- \`${f.path}${f.line ? `:${f.line}` : ""}\` [${f.importance ?? f.severity ?? "?"}] ${f.title}${f.excerpt ? ` — quotes \`${f.excerpt.split("\n")[0].slice(0, 80)}\`` : ""}`;
295
+ const parts = [];
296
+ if (open.length)
297
+ parts.push("Posted by an earlier review and still open:", ...open.slice(0, 30).map(row));
298
+ if (withheld.length)
299
+ parts.push("", "Found by an earlier review but never posted:", ...withheld.slice(0, 20).map(row));
300
+ return parts.join("\n");
301
+ }
302
+ //# sourceMappingURL=review-ledger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-ledger.js","sourceRoot":"","sources":["../../src/engine/review-ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,yBAAyB,GAAG,cAAc,CAAC;AAExD,oEAAoE;AACpE,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AACtC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACxC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAC5C,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,SAAS,GAAG,GAAG,CAAC;AAyEtB,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,IAAI;SACR,KAAK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AChD,MAAM,GAAG,GAAG,CAAC,CAAgB,EAAE,EAAE,CAC/B,OAAO,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,QAAQ,IAAI,GAAG,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAChL,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,IAAI,IAAI,CAAC,MAAM;QAAE,KAAK,CAAC,IAAI,CAAC,6CAA6C,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1G,IAAI,QAAQ,CAAC,MAAM;QAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,8CAA8C,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACvH,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -23,10 +23,13 @@ export type { TemplateContext } from "./workflows/templates.js";
23
23
  export { resolveRepoRunConfig } from "./workflows/simple.js";
24
24
  export type { RunRepoConfig, RepoRunConfigOptions } from "./workflows/simple.js";
25
25
  export { invalidateRepoLayer } from "./config/repo-config.js";
26
- export { renderContext, mayMerge } from "./engine/pr-decisions.js";
26
+ export { renderContext, mayMerge, reviewLedgerContext } from "./engine/pr-decisions.js";
27
27
  export type { PrState } from "./engine/pr-state.js";
28
28
  export type { CiFailureReport, CiJobFailure } from "./engine/github/github.js";
29
- export { resolveSpecContext } from "./engine/pr-state.js";
29
+ export { resolveSpecContext, deriveReviewLedger } from "./engine/pr-state.js";
30
+ export { coerceLedger, carriedOpen, findingFingerprint, foldReviewLedger, priorReviewOf, renderLedgerForSelect, renderLedgerStatus, REVIEW_LEDGER_SCRATCH_KEY, } from "./engine/review-ledger.js";
31
+ export type { LedgerFinding, LedgerStatus, LedgerUnit, ReviewLedger } from "./engine/review-ledger.js";
32
+ export { REVIEW_COVERAGE_SCRATCH_KEY } from "./workflows/handlers/post-review.js";
30
33
  export { resolveReviewGitHubClient } from "./workflows/handlers/post-review.js";
31
34
  export type { GitHubClient } from "./engine/github/github.js";
32
35
  export { parseAttemptMarkers, parseDiagnosisMarker, parseFixOutcomeMarker, DIAGNOSIS_CLASSES, } from "./engine/fix-markers.js";
package/dist/evals-api.js CHANGED
@@ -48,7 +48,7 @@ export { invalidateRepoLayer } from "./config/repo-config.js";
48
48
  // and what a run CONCLUDED is a marker line in the phase output, which only
49
49
  // these parsers read correctly (`lastMarkerLine` recognises `<TAG>:`, not a
50
50
  // bare mention — see `fix-markers.ts`).
51
- export { renderContext, mayMerge } from "./engine/pr-decisions.js";
51
+ export { renderContext, mayMerge, reviewLedgerContext } from "./engine/pr-decisions.js";
52
52
  // The `spec` axis's two ends, and the client that reads them.
53
53
  //
54
54
  // `renderContext` above projects a snapshot the harness FABRICATES. That is the
@@ -67,7 +67,13 @@ export { renderContext, mayMerge } from "./engine/pr-decisions.js";
67
67
  // does at the choke point. The fake grows the GraphQL route rather than the
68
68
  // harness growing a copy of the resolver — its stated convention, and the same
69
69
  // call it already made for `enablePullRequestAutoMerge`.
70
- export { resolveSpecContext } from "./engine/pr-state.js";
70
+ export { resolveSpecContext, deriveReviewLedger } from "./engine/pr-state.js";
71
+ // Issue #429 — the PR's review ledger. A multi-round eval case carries it
72
+ // from one round to the next exactly as production does: the run's
73
+ // `scratch.reviewLedger` (written by `post-review`) becomes the next round's
74
+ // `PrState.reviewLedger`, through the same derivation.
75
+ export { coerceLedger, carriedOpen, findingFingerprint, foldReviewLedger, priorReviewOf, renderLedgerForSelect, renderLedgerStatus, REVIEW_LEDGER_SCRATCH_KEY, } from "./engine/review-ledger.js";
76
+ export { REVIEW_COVERAGE_SCRATCH_KEY } from "./workflows/handlers/post-review.js";
71
77
  export { resolveReviewGitHubClient } from "./workflows/handlers/post-review.js";
72
78
  export { parseAttemptMarkers, parseDiagnosisMarker, parseFixOutcomeMarker, DIAGNOSIS_CLASSES, } from "./engine/fix-markers.js";
73
79
  // The two policy blocks the same prompts render as `{{fix.maxAttempts}}` /
@@ -1 +1 @@
1
- {"version":3,"file":"evals-api.js","sourceRoot":"","sources":["../src/evals-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,+EAA+E;AAC/E,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAExF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAKpD,+EAA+E;AAC/E,4EAA4E;AAC5E,gFAAgF;AAChF,2EAA2E;AAC3E,2EAA2E;AAC3E,mEAAmE;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,+EAA+E;AAC/E,EAAE;AACF,yEAAyE;AACzE,2EAA2E;AAC3E,0EAA0E;AAC1E,8EAA8E;AAC9E,0EAA0E;AAC1E,mEAAmE;AACnE,qEAAqE;AACrE,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,8EAA8E;AAC9E,+EAA+E;AAC/E,2EAA2E;AAC3E,4EAA4E;AAC5E,0CAA0C;AAC1C,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,4EAA4E;AAC5E,4EAA4E;AAC5E,wCAAwC;AACxC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,0B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AClF,6EAA6E;AAC7E,4DAA4D;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/index.js CHANGED
@@ -41,7 +41,7 @@ import { GitHubClient } from "./engine/github/github.js";
41
41
  import { setInstallationRepos, isManagedRepo, unmanagedReposInContext } from "./managed-repos.js";
42
42
  import { screenForInjection, flagPrefix } from "./engine/screen/screen.js";
43
43
  import { runSimpleWorkflow, resolveRepoRunConfig, prepopulatesPrHeadRef, isPrFixShaped, } from "./workflows/simple.js";
44
- import { resolvePrState, resolveSpecContext, prScopedWorkflows, } from "./engine/pr-state.js";
44
+ import { resolvePrState, resolveSpecContext, prScopedWorkflows, prStateForRun, } from "./engine/pr-state.js";
45
45
  import { renderContext } from "./engine/pr-decisions.js";
46
46
  import { applyBuildDispatchGate } from "./engine/build-gate.js";
47
47
  import { REVIEW_WORKFLOW, bindQueuedReviewCheck, installReviewCheckObserver, openAndBindReviewCheck, } from "./engine/review-check.js";
@@ -731,7 +731,8 @@ async function main() {
731
731
  await resolveSpecContext(prState, { github });
732
732
  }
733
733
  Object.assign(extra, renderContext(prState, repoConfig?.fix ?? config.fix, repoConfig?.dependencies ?? config.dependencies, reviewConfig));
734
- extra.prState = prState;
734
+ // The review ledger rides only on review rows (issue #429, `prStateForRun`).
735
+ extra.prState = prStateForRun(prState, workflowName);
735
736
  // Beside the snapshot, and deliberately not inside it (see the resolution
736
737
  // above). Scoped to PR-scoped runs because they are the only ones with a
737
738
  // reader — `post-review`, whose `resolveReviewPost` needs to tell a