@farmslot/review-dispatch 0.12.0 → 0.14.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.
- package/CHANGELOG.md +10 -0
- package/README.md +32 -0
- package/dist/checklist-progress.d.ts +17 -1
- package/dist/checklist-progress.d.ts.map +1 -1
- package/dist/checklist-progress.js +60 -0
- package/dist/checklist-progress.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/native-worker-target.d.ts +54 -0
- package/dist/native-worker-target.d.ts.map +1 -0
- package/dist/native-worker-target.js +184 -0
- package/dist/native-worker-target.js.map +1 -0
- package/dist/review-gate-refresh.d.ts +11 -0
- package/dist/review-gate-refresh.d.ts.map +1 -0
- package/dist/review-gate-refresh.js +19 -0
- package/dist/review-gate-refresh.js.map +1 -0
- package/dist/review-history-timeline.d.ts +40 -0
- package/dist/review-history-timeline.d.ts.map +1 -0
- package/dist/review-history-timeline.js +117 -0
- package/dist/review-history-timeline.js.map +1 -0
- package/dist/review-history.d.ts +35 -3
- package/dist/review-history.d.ts.map +1 -1
- package/dist/review-history.js +384 -48
- package/dist/review-history.js.map +1 -1
- package/dist/run-activity.d.ts +8 -1
- package/dist/run-activity.d.ts.map +1 -1
- package/dist/run-activity.js +20 -10
- package/dist/run-activity.js.map +1 -1
- package/dist/run-checklist-progress.d.ts +22 -0
- package/dist/run-checklist-progress.d.ts.map +1 -0
- package/dist/run-checklist-progress.js +68 -0
- package/dist/run-checklist-progress.js.map +1 -0
- package/dist/run-review-failures.d.ts +8 -0
- package/dist/run-review-failures.d.ts.map +1 -0
- package/dist/run-review-failures.js +49 -0
- package/dist/run-review-failures.js.map +1 -0
- package/package.json +2 -2
package/dist/review-history.js
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
|
-
import { deriveChecklistStepDurations, extractRunArtifactManifest, isTerminalRunStatus, observedReviewSessionContinuity, reviewChainForRun, } from '@farmslot/protocol';
|
|
1
|
+
import { deriveChecklistStepDurations, digestRecipeDocument, extractRunArtifactManifest, isTerminalRunStatus, observedReviewSessionContinuity, reviewChainForRun, reviewResultForRun, } from '@farmslot/protocol';
|
|
2
|
+
import { reviewHistoryTimeline } from './review-history-timeline.js';
|
|
2
3
|
import { runActivityView, runReviewActivityContext } from './run-activity.js';
|
|
4
|
+
import { reviewAttemptFailureReason } from './run-review-failures.js';
|
|
5
|
+
/** Transport generations invalidate requests, not facts already read from the same owner. */
|
|
6
|
+
export function reviewHistoryCacheScope(runId, authority) {
|
|
7
|
+
return JSON.stringify([
|
|
8
|
+
authority.gatewayUrl,
|
|
9
|
+
authority.profileId ?? null,
|
|
10
|
+
authority.principalId,
|
|
11
|
+
runId,
|
|
12
|
+
]);
|
|
13
|
+
}
|
|
14
|
+
function reviewUsageLabel(usage) {
|
|
15
|
+
if (!usage)
|
|
16
|
+
return null;
|
|
17
|
+
if (usage.source === 'unavailable')
|
|
18
|
+
return 'Usage unavailable';
|
|
19
|
+
const parts = [
|
|
20
|
+
usage.turns != null ? `${usage.turns} turns` : null,
|
|
21
|
+
usage.totalTokens != null ? `${usage.totalTokens.toLocaleString()} tokens` : null,
|
|
22
|
+
usage.costUsd != null ? `$${usage.costUsd.toFixed(4)}` : null,
|
|
23
|
+
].filter(Boolean);
|
|
24
|
+
return parts.length ? parts.join(' · ') : 'Usage measured';
|
|
25
|
+
}
|
|
26
|
+
/** Keep recorded history readable during a refresh outage, while exposing the failed read. */
|
|
27
|
+
export function mergeReviewHistoryArtifacts(previous, next) {
|
|
28
|
+
return {
|
|
29
|
+
...previous,
|
|
30
|
+
...Object.fromEntries(Object.entries(next).map(([path, value]) => [
|
|
31
|
+
path,
|
|
32
|
+
value.error && previous[path]?.content !== undefined
|
|
33
|
+
? { ...previous[path], error: value.error }
|
|
34
|
+
: value,
|
|
35
|
+
])),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
3
38
|
function isRecord(value) {
|
|
4
39
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
5
40
|
}
|
|
@@ -59,11 +94,15 @@ function findings(value) {
|
|
|
59
94
|
const title = text(issue.title) ?? firstLine.match(/^.*?[.!?](?=\s|$)/)?.[0] ?? firstLine;
|
|
60
95
|
return [
|
|
61
96
|
{
|
|
97
|
+
id: text(issue.id) ?? digestRecipeDocument({ file: issue.file ?? issue.path, title }),
|
|
62
98
|
title,
|
|
63
99
|
details: body.startsWith(title) ? body.slice(title.length).trim() : body,
|
|
64
100
|
severity: text(issue.severity) ?? priority?.[1] ?? 'Severity not recorded',
|
|
65
101
|
file: text(issue.file) ?? text(issue.path) ?? 'General finding',
|
|
66
102
|
line: number(issue.line),
|
|
103
|
+
status: 'new',
|
|
104
|
+
statusLabel: 'New',
|
|
105
|
+
resolvedBy: null,
|
|
67
106
|
},
|
|
68
107
|
];
|
|
69
108
|
});
|
|
@@ -84,6 +123,9 @@ export function reviewHistoryArtifactPaths(run) {
|
|
|
84
123
|
.flatMap(reviewHistoryArtifactPathsForActor)),
|
|
85
124
|
];
|
|
86
125
|
}
|
|
126
|
+
function recoveredSnapshotKey(actor) {
|
|
127
|
+
return `history:${actor.id}:${actor.reviewLoopNumber ?? 0}:${actor.deliveryBaselineRef ?? actor.pipelineVisualReviewInput?.headSha ?? ''}:snapshot`;
|
|
128
|
+
}
|
|
87
129
|
function readyReviews(run) {
|
|
88
130
|
const live = run.engineState?.publishGate?.reviews;
|
|
89
131
|
if (live?.length)
|
|
@@ -94,8 +136,25 @@ function readyReviews(run) {
|
|
|
94
136
|
return [];
|
|
95
137
|
}
|
|
96
138
|
export function reviewHistoryView(run, artifacts = {}, chain = reviewChainForRun(run)) {
|
|
97
|
-
const
|
|
139
|
+
const result = reviewResultForRun(run);
|
|
140
|
+
const staticActors = new Set((run.agentContexts ?? [])
|
|
141
|
+
.filter((context) => context.role === 'review' && !context.reviewLoopNumber && run.flowType === 'review-pr')
|
|
142
|
+
.map((context) => context.id));
|
|
143
|
+
const contexts = (run.agentContexts ?? [])
|
|
144
|
+
.filter((context) => context.role === 'review')
|
|
145
|
+
.flatMap((context) => staticActors.has(context.id)
|
|
146
|
+
? [
|
|
147
|
+
{
|
|
148
|
+
...context,
|
|
149
|
+
reviewId: context.reviewId ?? `workspace-review-${run.id}`,
|
|
150
|
+
reviewLoopNumber: 1,
|
|
151
|
+
},
|
|
152
|
+
]
|
|
153
|
+
: context.reviewId && context.reviewLoopNumber
|
|
154
|
+
? [context]
|
|
155
|
+
: []);
|
|
98
156
|
const reviews = readyReviews(run);
|
|
157
|
+
const useGit = artifacts['history:git']?.content === 'enabled';
|
|
99
158
|
const retainedPaths = new Set(extractRunArtifactManifest(run).map((entry) => entry.path));
|
|
100
159
|
const currentActor = runActivityView(run)?.kind === 'worker-fix' ? runReviewActivityContext(run) : null;
|
|
101
160
|
const fixingActor = currentActor?.role === 'review-fix' ? currentActor : null;
|
|
@@ -136,14 +195,52 @@ export function reviewHistoryView(run, artifacts = {}, chain = reviewChainForRun
|
|
|
136
195
|
...stepAttempts.map((entry, index) => number(entry.loopNumber) ?? index + 1),
|
|
137
196
|
]),
|
|
138
197
|
].sort((a, b) => a - b);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
198
|
+
// Replays can restart the loop counter. A context is an attempt, not another copy of loop 1.
|
|
199
|
+
const sources = loops
|
|
200
|
+
.flatMap((loop) => {
|
|
201
|
+
const matching = actors.filter((context) => context.reviewLoopNumber === loop);
|
|
202
|
+
return matching.length
|
|
203
|
+
? matching.map((actor) => ({ loop, actor }))
|
|
204
|
+
: [{ loop, actor: undefined }];
|
|
205
|
+
})
|
|
206
|
+
.sort((left, right) => (left.actor?.startedAt ?? '').localeCompare(right.actor?.startedAt ?? '') ||
|
|
207
|
+
left.loop - right.loop);
|
|
208
|
+
let roundNumber = 0;
|
|
209
|
+
const rounds = sources.map(({ loop, actor }) => {
|
|
210
|
+
roundNumber = Math.max(roundNumber + 1, loop);
|
|
211
|
+
const sameLoop = actors.filter((context) => context.reviewLoopNumber === loop);
|
|
212
|
+
const ownsAttempt = (entry, entryLoop) => {
|
|
213
|
+
if (!actor)
|
|
214
|
+
return entryLoop === loop;
|
|
215
|
+
if (actor.status === 'failed' && entry.verdict !== 'failed')
|
|
216
|
+
return false;
|
|
217
|
+
if (entry.startedAt && actor.completedAt && entry.startedAt > actor.completedAt)
|
|
218
|
+
return false;
|
|
219
|
+
if (entry.completedAt && actor.startedAt && entry.completedAt < actor.startedAt)
|
|
220
|
+
return false;
|
|
221
|
+
if (entry.headSha &&
|
|
222
|
+
actor.deliveryBaselineRef &&
|
|
223
|
+
entry.headSha !== actor.deliveryBaselineRef)
|
|
224
|
+
return false;
|
|
225
|
+
const sameHead = entry.headSha && entry.headSha === actor.deliveryBaselineRef;
|
|
226
|
+
if (entryLoop !== loop && !sameHead)
|
|
227
|
+
return false;
|
|
228
|
+
return (sameLoop.length === 1 ||
|
|
229
|
+
(entry.startedAt
|
|
230
|
+
? entry.startedAt >= (actor.startedAt ?? '') &&
|
|
231
|
+
(!actor.completedAt || entry.startedAt <= actor.completedAt)
|
|
232
|
+
: sameLoop.at(-1)?.id === actor.id));
|
|
233
|
+
};
|
|
234
|
+
const recordedAttempt = attempts
|
|
235
|
+
.filter((entry) => ownsAttempt({ ...entry, headSha: entry.reviewSnapshot?.headSha ?? undefined }, entry.loopNumber))
|
|
236
|
+
.at(-1);
|
|
145
237
|
const recordedRaw = stepAttempts
|
|
146
|
-
.filter((entry, index) => (
|
|
238
|
+
.filter((entry, index) => ownsAttempt({
|
|
239
|
+
startedAt: text(entry.startedAt) ?? undefined,
|
|
240
|
+
completedAt: text(entry.completedAt) ?? undefined,
|
|
241
|
+
verdict: text(entry.verdict) ?? undefined,
|
|
242
|
+
headSha: text(record(entry.reviewSnapshot)?.headSha) ?? undefined,
|
|
243
|
+
}, number(entry.loopNumber) ?? index + 1))
|
|
147
244
|
.at(-1);
|
|
148
245
|
const newerActive = actor &&
|
|
149
246
|
['working', 'launching', 'waiting'].includes(actor.status) &&
|
|
@@ -156,20 +253,85 @@ export function reviewHistoryView(run, artifacts = {}, chain = reviewChainForRun
|
|
|
156
253
|
const saved = actor?.reviewResultFile && (!newerActive || actor.reviewResultValidatedAt)
|
|
157
254
|
? artifact(artifacts, actor.reviewResultFile)
|
|
158
255
|
: null;
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
256
|
+
const staticResult = actor && staticActors.has(actor.id) ? result : null;
|
|
257
|
+
const storedSnapshot = attempt?.reviewSnapshot ?? record(raw?.reviewSnapshot) ?? staticResult?.reviewSnapshot;
|
|
258
|
+
const recordedSnapshot = storedSnapshot ?? artifact(artifacts, `${dir}/review-diff-stat.json`);
|
|
259
|
+
const expectedHead = actor?.deliveryBaselineRef ?? actor?.pipelineVisualReviewInput?.headSha;
|
|
260
|
+
const overwritten = !storedSnapshot &&
|
|
261
|
+
actor?.completedAt &&
|
|
262
|
+
text(recordedSnapshot?.capturedAt) &&
|
|
263
|
+
String(recordedSnapshot?.capturedAt) > actor.completedAt;
|
|
264
|
+
const snapshot = (overwritten || (expectedHead && recordedSnapshot?.headSha !== expectedHead)
|
|
265
|
+
? null
|
|
266
|
+
: recordedSnapshot) ?? (actor ? artifact(artifacts, recoveredSnapshotKey(actor)) : null);
|
|
267
|
+
const storedFix = attempt?.fixDelta ?? record(raw?.fixDelta);
|
|
268
|
+
const candidateFix = storedFix ?? artifact(artifacts, `${dir}/fix-delta-stat.json`);
|
|
269
|
+
const fix = (!storedFix &&
|
|
270
|
+
actor?.completedAt &&
|
|
271
|
+
text(candidateFix?.capturedAt) &&
|
|
272
|
+
String(candidateFix?.capturedAt) > actor.completedAt) ||
|
|
273
|
+
(expectedHead &&
|
|
274
|
+
candidateFix &&
|
|
275
|
+
(candidateFix.fixHeadSha ?? candidateFix.headSha) !== expectedHead)
|
|
276
|
+
? null
|
|
277
|
+
: candidateFix;
|
|
278
|
+
const issueValue = attempt?.issues ?? raw?.issues ?? saved?.issues ?? staticResult?.lineComments;
|
|
166
279
|
const issueRows = findings(issueValue);
|
|
167
280
|
const startedAt = attempt?.startedAt ??
|
|
168
281
|
text(raw?.startedAt) ??
|
|
169
|
-
actor?.attemptStartedAt ??
|
|
170
282
|
actor?.startedAt ??
|
|
283
|
+
actor?.attemptStartedAt ??
|
|
284
|
+
null;
|
|
285
|
+
const completedAt = attempt?.completedAt ??
|
|
286
|
+
text(raw?.completedAt) ??
|
|
287
|
+
actor?.completedAt ??
|
|
288
|
+
(staticResult ? run.steps.find((entry) => entry.name === 'monitor')?.completedAt : null) ??
|
|
171
289
|
null;
|
|
172
|
-
const
|
|
290
|
+
const previousCompletedAt = actors
|
|
291
|
+
.filter((candidate) => candidate.id !== actor?.id &&
|
|
292
|
+
candidate.completedAt &&
|
|
293
|
+
startedAt &&
|
|
294
|
+
candidate.completedAt <= startedAt)
|
|
295
|
+
.map((candidate) => candidate.completedAt)
|
|
296
|
+
.filter((value) => Boolean(value))
|
|
297
|
+
.sort()
|
|
298
|
+
.at(-1);
|
|
299
|
+
const previousActor = actors
|
|
300
|
+
.filter((candidate) => candidate.id !== actor?.id &&
|
|
301
|
+
candidate.completedAt &&
|
|
302
|
+
startedAt &&
|
|
303
|
+
candidate.completedAt <= startedAt)
|
|
304
|
+
.sort((left, right) => (left.completedAt ?? '').localeCompare(right.completedAt ?? ''))
|
|
305
|
+
.at(-1);
|
|
306
|
+
const previousHead = previousActor?.deliveryBaselineRef ?? previousActor?.pipelineVisualReviewInput?.headSha;
|
|
307
|
+
const headSha = text(snapshot?.headSha) ?? expectedHead ?? null;
|
|
308
|
+
const reconstructedFix = !fix && previousHead && headSha && previousHead !== headSha;
|
|
309
|
+
const fixBaseSha = text(fix?.fixBaseSha ?? fix?.baseSha) ?? (reconstructedFix ? previousHead : null);
|
|
310
|
+
const fixHeadSha = text(fix?.fixHeadSha ?? fix?.headSha) ?? (reconstructedFix ? headSha : null);
|
|
311
|
+
const fixDiffPath = useGit && fixBaseSha && fixHeadSha
|
|
312
|
+
? `history:git:${fixBaseSha}:${fixHeadSha}.diff`
|
|
313
|
+
: (text(fix?.diffPath) ??
|
|
314
|
+
(reconstructedFix && actor ? `history:${actor.id}:fix.diff` : null));
|
|
315
|
+
const reviewBaseSha = text(snapshot?.baseSha);
|
|
316
|
+
const diffPath = useGit && reviewBaseSha && headSha
|
|
317
|
+
? `history:git:${reviewBaseSha}:${headSha}.diff`
|
|
318
|
+
: text(snapshot?.diffPath);
|
|
319
|
+
const completedFix = previousCompletedAt && startedAt
|
|
320
|
+
? (run.agentContexts ?? [])
|
|
321
|
+
.filter((candidate) => candidate.role === 'review-fix' &&
|
|
322
|
+
(candidate.completedAt ?? text(fix?.capturedAt)) &&
|
|
323
|
+
(candidate.promptDeliveryStartedAt ?? candidate.startedAt ?? '') >
|
|
324
|
+
previousCompletedAt &&
|
|
325
|
+
(candidate.completedAt ?? text(fix?.capturedAt) ?? '') <= startedAt)
|
|
326
|
+
.sort((left, right) => (left.completedAt ?? '').localeCompare(right.completedAt ?? ''))
|
|
327
|
+
.at(-1)
|
|
328
|
+
: undefined;
|
|
329
|
+
const firstFix = previousCompletedAt && startedAt
|
|
330
|
+
? run.agentContexts?.find((candidate) => candidate.role === 'review-fix' &&
|
|
331
|
+
candidate.startedAt &&
|
|
332
|
+
candidate.startedAt > previousCompletedAt &&
|
|
333
|
+
candidate.startedAt <= startedAt)
|
|
334
|
+
: undefined;
|
|
173
335
|
const segment = attempt?.timeline?.find((entry) => entry.kind === 'worker-fix');
|
|
174
336
|
const rawSegment = (Array.isArray(raw?.timeline) ? raw.timeline.map(record).filter(isRecord) : segments).find((entry) => entry.kind === 'worker-fix' && (number(entry.loopNumber) ?? loop) === loop);
|
|
175
337
|
const fixing = fixingActor &&
|
|
@@ -178,31 +340,67 @@ export function reviewHistoryView(run, artifacts = {}, chain = reviewChainForRun
|
|
|
178
340
|
: latestReviewActor?.reviewId === id)
|
|
179
341
|
? fixingActor
|
|
180
342
|
: null;
|
|
181
|
-
const latest = loop === loops.at(-1);
|
|
182
343
|
const initialMode = loop === 1 && id === `pipeline-review-${run.id}`
|
|
183
344
|
? record(run.steps.find((step) => step.name === 'review')?.inputs?.reviewSelection)?.mode
|
|
184
345
|
: null;
|
|
185
|
-
const mode = attempt?.mode ??
|
|
346
|
+
const mode = attempt?.mode ??
|
|
347
|
+
text(raw?.mode) ??
|
|
348
|
+
text(saved?.mode) ??
|
|
349
|
+
staticResult?.session?.mode ??
|
|
350
|
+
(actor?.reviewFallback
|
|
351
|
+
? 'cold'
|
|
352
|
+
: actor?.nativeSession?.handoffFrom
|
|
353
|
+
? 'warm'
|
|
354
|
+
: actor?.nativeSession
|
|
355
|
+
? 'cold'
|
|
356
|
+
: null) ??
|
|
357
|
+
(actor && staticActors.has(actor.id)
|
|
358
|
+
? (run.reviewMode ?? run.repeatReviewContext?.mode)
|
|
359
|
+
: null) ??
|
|
360
|
+
initialMode;
|
|
186
361
|
const recorded = Array.isArray(issueValue);
|
|
187
362
|
const verdict = attempt?.verdict ??
|
|
188
363
|
text(raw?.verdict) ??
|
|
364
|
+
staticResult?.recommendation ??
|
|
189
365
|
(actor?.status === 'failed' ? 'failed' : text(saved?.verdict)) ??
|
|
190
366
|
(actor?.status === 'complete' ? 'Result not recorded' : 'pending');
|
|
367
|
+
const failureReason = verdict === 'failed'
|
|
368
|
+
? (attempt?.reason ??
|
|
369
|
+
text(raw?.reason) ??
|
|
370
|
+
(actor ? reviewAttemptFailureReason(run, actor) : null))
|
|
371
|
+
: null;
|
|
191
372
|
const unresolved = attempt?.unresolvedCount ??
|
|
192
373
|
number(raw?.unresolvedCount) ??
|
|
193
374
|
(recorded ? issueRows.length : null);
|
|
194
375
|
return {
|
|
195
|
-
key: `${id}:${loop}`,
|
|
376
|
+
key: actor?.id ?? `${id}:${loop}`,
|
|
196
377
|
reviewId: id,
|
|
197
378
|
loopNumber: loop,
|
|
379
|
+
roundNumber,
|
|
198
380
|
runner: actor?.runner ?? review?.runner ?? text(step?.outputs?.runner) ?? 'Unknown runner',
|
|
199
381
|
model: actor?.model ?? review?.model ?? text(step?.outputs?.model) ?? 'default',
|
|
200
382
|
mode: mode === 'warm' || mode === 'cold' ? mode : null,
|
|
201
|
-
modeLabel: mode === 'warm' || mode === 'cold' ? mode.toUpperCase() : 'Mode
|
|
383
|
+
modeLabel: mode === 'warm' || mode === 'cold' ? mode.toUpperCase() : 'Mode unavailable',
|
|
202
384
|
verdict,
|
|
385
|
+
verdictTone: ['pass', 'APPROVE'].includes(verdict)
|
|
386
|
+
? 'ok'
|
|
387
|
+
: verdict === 'failed'
|
|
388
|
+
? 'fail'
|
|
389
|
+
: verdict === 'pending'
|
|
390
|
+
? 'running'
|
|
391
|
+
: 'warn',
|
|
392
|
+
failureReason,
|
|
203
393
|
startedAt,
|
|
204
394
|
completedAt,
|
|
205
395
|
durationMs: duration(startedAt, completedAt),
|
|
396
|
+
usageLabel: reviewUsageLabel(attempt?.usage ??
|
|
397
|
+
(review &&
|
|
398
|
+
ownsAttempt({ ...review, headSha: review.reviewSnapshot?.headSha ?? undefined }, review.loopNumber)
|
|
399
|
+
? review.usage
|
|
400
|
+
: undefined)),
|
|
401
|
+
headSha,
|
|
402
|
+
reviewBaseSha,
|
|
403
|
+
resultRecorded: recorded,
|
|
206
404
|
unresolvedCount: unresolved,
|
|
207
405
|
unresolvedLabel: unresolved !== null
|
|
208
406
|
? `${unresolved} unresolved`
|
|
@@ -215,32 +413,54 @@ export function reviewHistoryView(run, artifacts = {}, chain = reviewChainForRun
|
|
|
215
413
|
: 'No findings recorded in this round.'
|
|
216
414
|
: verdict === 'pending'
|
|
217
415
|
? 'Review is running. Findings appear when it finishes.'
|
|
218
|
-
:
|
|
416
|
+
: verdict === 'failed'
|
|
417
|
+
? 'Review failed before producing findings.'
|
|
418
|
+
: 'Findings unavailable',
|
|
219
419
|
findings: issueRows,
|
|
220
|
-
earlierAttempts:
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
reviewRange: range(snapshot?.baseSha, snapshot?.headSha) ?? 'SHA unavailable',
|
|
226
|
-
fixRange: range(fix?.fixBaseSha ?? fix?.baseSha, fix?.fixHeadSha ?? fix?.headSha),
|
|
420
|
+
earlierAttempts: [],
|
|
421
|
+
reviewRange: range(snapshot?.baseSha, snapshot?.headSha) ??
|
|
422
|
+
actor?.deliveryBaselineRef?.slice(0, 7) ??
|
|
423
|
+
'Head pending',
|
|
424
|
+
fixRange: range(fixBaseSha, fixHeadSha),
|
|
227
425
|
fixStat: fixStat(fix),
|
|
228
426
|
fixDurationMs: segment?.durationMs ??
|
|
229
427
|
number(rawSegment?.durationMs) ??
|
|
230
|
-
duration(segment?.startedAt ?? text(rawSegment?.startedAt), segment?.completedAt ?? text(rawSegment?.completedAt))
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
428
|
+
duration(segment?.startedAt ?? text(rawSegment?.startedAt), segment?.completedAt ?? text(rawSegment?.completedAt)) ??
|
|
429
|
+
duration(completedFix?.promptDeliveryStartedAt ??
|
|
430
|
+
completedFix?.startedAt ??
|
|
431
|
+
completedFix?.attemptStartedAt ??
|
|
432
|
+
null, completedFix?.completedAt ?? text(fix?.capturedAt)),
|
|
433
|
+
fixStartedAt: segment?.startedAt ??
|
|
434
|
+
text(rawSegment?.startedAt) ??
|
|
435
|
+
completedFix?.promptDeliveryStartedAt ??
|
|
436
|
+
completedFix?.startedAt ??
|
|
437
|
+
firstFix?.startedAt ??
|
|
438
|
+
null,
|
|
439
|
+
fixCompletedAt: segment?.completedAt ??
|
|
440
|
+
text(rawSegment?.completedAt) ??
|
|
441
|
+
completedFix?.completedAt ??
|
|
442
|
+
text(fix?.capturedAt),
|
|
443
|
+
fixFiles: [
|
|
444
|
+
...(artifacts[String(fixDiffPath)]?.content ?? '').matchAll(/^diff --git a\/.+ b\/(.+)$/gm),
|
|
445
|
+
].map((match) => match[1]),
|
|
446
|
+
fixRunning: Boolean(actor?.id === latestReviewActor?.id && fixing),
|
|
447
|
+
activeFixStartedAt: actor?.id === latestReviewActor?.id
|
|
448
|
+
? (fixing?.promptDeliveryStartedAt ??
|
|
449
|
+
fixing?.attemptStartedAt ??
|
|
450
|
+
fixing?.startedAt ??
|
|
451
|
+
null)
|
|
243
452
|
: null,
|
|
453
|
+
hasFix: Boolean(fix || reconstructedFix || segment || rawSegment || completedFix),
|
|
454
|
+
diffPath,
|
|
455
|
+
diffReconstructed: useGit || record(snapshot)?.reconstructed === true,
|
|
456
|
+
diffText: diffPath ? (artifacts[String(diffPath)]?.content ?? null) : null,
|
|
457
|
+
reviewDiffRetained: retainedPaths.has(String(snapshot?.diffPath)),
|
|
458
|
+
fixDiffPath,
|
|
459
|
+
fixDiffText: fixDiffPath ? (artifacts[String(fixDiffPath)]?.content ?? null) : null,
|
|
460
|
+
fixDiffError: fixDiffPath ? (artifacts[String(fixDiffPath)]?.error ?? null) : null,
|
|
461
|
+
fixBaseSha,
|
|
462
|
+
fixHeadSha,
|
|
463
|
+
fixReconstructed: Boolean(reconstructedFix || (useGit && fixBaseSha && fixHeadSha)),
|
|
244
464
|
validationDepth: attempt?.validationDepth ??
|
|
245
465
|
text(raw?.validationDepth) ??
|
|
246
466
|
review?.validationDepth ??
|
|
@@ -248,7 +468,9 @@ export function reviewHistoryView(run, artifacts = {}, chain = reviewChainForRun
|
|
|
248
468
|
timing: deriveChecklistStepDurations(attempt?.checklistTiming, startedAt ?? undefined),
|
|
249
469
|
unavailable: [
|
|
250
470
|
...reviewHistoryArtifactPathsForActor(actor),
|
|
251
|
-
...(
|
|
471
|
+
...(actor ? [recoveredSnapshotKey(actor)] : []),
|
|
472
|
+
...(fixDiffPath ? [fixDiffPath] : []),
|
|
473
|
+
...(diffPath ? [diffPath] : []),
|
|
252
474
|
].flatMap((path) => (artifacts[path]?.error ? [artifacts[path].error] : [])),
|
|
253
475
|
};
|
|
254
476
|
});
|
|
@@ -281,6 +503,19 @@ export function reviewHistoryView(run, artifacts = {}, chain = reviewChainForRun
|
|
|
281
503
|
});
|
|
282
504
|
}
|
|
283
505
|
const roundCount = checks.reduce((sum, check) => sum + check.rounds.length, 0);
|
|
506
|
+
const replayStep = run.steps.find((step) => step.name === 'review' && step.status === 'running');
|
|
507
|
+
const activeReplay = run.status === 'reviewing' &&
|
|
508
|
+
(run.engineState?.generation ?? 0) > 0 &&
|
|
509
|
+
replayStep?.startedAt &&
|
|
510
|
+
latestReviewActor?.completedAt &&
|
|
511
|
+
replayStep.startedAt > latestReviewActor.completedAt &&
|
|
512
|
+
!contexts.some((context) => ['launching', 'working', 'waiting'].includes(context.status))
|
|
513
|
+
? {
|
|
514
|
+
roundNumber: Math.max(...checks.flatMap((check) => check.rounds.map((round) => round.roundNumber))) +
|
|
515
|
+
1,
|
|
516
|
+
startedAt: replayStep.startedAt,
|
|
517
|
+
}
|
|
518
|
+
: null;
|
|
284
519
|
const summary = [
|
|
285
520
|
chain.length ? `${chain.length} diff generation${chain.length === 1 ? '' : 's'}` : '',
|
|
286
521
|
`${checks.length} review check${checks.length === 1 ? '' : 's'}`,
|
|
@@ -292,6 +527,7 @@ export function reviewHistoryView(run, artifacts = {}, chain = reviewChainForRun
|
|
|
292
527
|
checks,
|
|
293
528
|
segments,
|
|
294
529
|
roundCount,
|
|
530
|
+
activeReplay,
|
|
295
531
|
summary,
|
|
296
532
|
chain: chain.map((entry) => ({
|
|
297
533
|
...entry,
|
|
@@ -299,6 +535,7 @@ export function reviewHistoryView(run, artifacts = {}, chain = reviewChainForRun
|
|
|
299
535
|
range: range(entry.baseSha, entry.headSha) ?? 'SHA unavailable',
|
|
300
536
|
diffPath: entry.artifactRefs.find((artifact) => artifact.path.endsWith('.diff'))?.path ?? null,
|
|
301
537
|
})),
|
|
538
|
+
events: reviewHistoryTimeline(run, checks.flatMap((check) => check.rounds)),
|
|
302
539
|
};
|
|
303
540
|
}
|
|
304
541
|
function reviewHistoryArtifactPathsForActor(actor) {
|
|
@@ -313,15 +550,45 @@ function reviewHistoryArtifactPathsForActor(actor) {
|
|
|
313
550
|
...(actor.reviewLoopNumber > 1 ? [`${dir}/fix-delta-stat.json`] : []),
|
|
314
551
|
].filter((path) => Boolean(path));
|
|
315
552
|
}
|
|
553
|
+
function historyAttemptIdentity(value) {
|
|
554
|
+
const attempt = record(value);
|
|
555
|
+
return [
|
|
556
|
+
attempt?.loopNumber,
|
|
557
|
+
attempt?.mode,
|
|
558
|
+
attempt?.verdict,
|
|
559
|
+
attempt?.unresolvedCount,
|
|
560
|
+
attempt?.startedAt,
|
|
561
|
+
attempt?.completedAt,
|
|
562
|
+
attempt?.reviewSnapshot,
|
|
563
|
+
attempt?.fixDelta,
|
|
564
|
+
attempt?.artifactPaths,
|
|
565
|
+
];
|
|
566
|
+
}
|
|
316
567
|
/** Refresh on retained round changes, without rereading files for unrelated run heartbeats. */
|
|
317
568
|
export function reviewHistoryIdentity(run) {
|
|
318
569
|
return JSON.stringify([
|
|
319
570
|
run.id,
|
|
320
|
-
|
|
571
|
+
run.reviewResult,
|
|
572
|
+
run.reviewMode,
|
|
573
|
+
run.reviewRoundSettlements,
|
|
574
|
+
readyReviews(run).map((review) => [
|
|
575
|
+
review.id,
|
|
576
|
+
review.runner,
|
|
577
|
+
review.model,
|
|
578
|
+
review.source,
|
|
579
|
+
review.stale,
|
|
580
|
+
historyAttemptIdentity(review),
|
|
581
|
+
review.attempts?.map(historyAttemptIdentity),
|
|
582
|
+
]),
|
|
321
583
|
run.steps
|
|
322
584
|
.filter((step) => step.name.includes('review'))
|
|
323
585
|
.map((step) => [
|
|
324
|
-
step.
|
|
586
|
+
step.status,
|
|
587
|
+
step.startedAt,
|
|
588
|
+
step.completedAt,
|
|
589
|
+
Array.isArray(step.outputs?.attempts)
|
|
590
|
+
? step.outputs.attempts.map(historyAttemptIdentity)
|
|
591
|
+
: undefined,
|
|
325
592
|
step.outputs?.timeline,
|
|
326
593
|
step.outputs?.reviewId,
|
|
327
594
|
step.outputs?.runner,
|
|
@@ -337,11 +604,15 @@ export function reviewHistoryIdentity(run) {
|
|
|
337
604
|
context.reviewResultFile,
|
|
338
605
|
context.artifactScope,
|
|
339
606
|
context.attemptStartedAt,
|
|
607
|
+
context.startedAt,
|
|
608
|
+
context.completedAt,
|
|
609
|
+
context.deliveryBaselineRef,
|
|
610
|
+
context.nativeSession?.handoffFrom,
|
|
340
611
|
]),
|
|
341
612
|
]);
|
|
342
613
|
}
|
|
343
614
|
/** One loader for both clients; the transport owns authentication and checks farm identity. */
|
|
344
|
-
export async function loadReviewHistoryArtifacts(run, read, readLive) {
|
|
615
|
+
export async function loadReviewHistoryArtifacts(run, read, readLive, readDiff) {
|
|
345
616
|
const readPaths = async (paths) => {
|
|
346
617
|
const settled = await Promise.allSettled(paths.map(async (path) => {
|
|
347
618
|
const retained = await read(path);
|
|
@@ -377,9 +648,74 @@ export async function loadReviewHistoryArtifacts(run, read, readLive) {
|
|
|
377
648
|
}));
|
|
378
649
|
};
|
|
379
650
|
const metadata = await readPaths(reviewHistoryArtifactPaths(run));
|
|
651
|
+
if (readDiff && !isTerminalRunStatus(run.status))
|
|
652
|
+
metadata['history:git'] = { content: 'enabled' };
|
|
653
|
+
if (readLive && readDiff && !isTerminalRunStatus(run.status)) {
|
|
654
|
+
const rounds = reviewHistoryView(run, metadata).checks.flatMap((check) => check.rounds);
|
|
655
|
+
const recoveryRounds = rounds.filter((round) => !round.diffPath);
|
|
656
|
+
const recoveries = await Promise.allSettled(recoveryRounds.map(async (round) => {
|
|
657
|
+
const actor = run.agentContexts?.find((context) => context.id === round.key &&
|
|
658
|
+
context.runId === run.id &&
|
|
659
|
+
context.slotId === run.slotId &&
|
|
660
|
+
context.taskFile &&
|
|
661
|
+
!['working', 'launching'].includes(context.status));
|
|
662
|
+
if (!actor?.slotId || !actor.taskFile)
|
|
663
|
+
return;
|
|
664
|
+
const task = await readLive({ slotId: actor.slotId, path: actor.taskFile });
|
|
665
|
+
// These are engine-written frozen input headers, not reviewer transcript/output.
|
|
666
|
+
const match = /## COLD review range\s+Review the complete PR diff ([a-f0-9]{40})\.\.([a-f0-9]{40}) in /.exec(task) ?? /- Exact review range: `([a-f0-9]{40})\.\.([a-f0-9]{40})`/.exec(task);
|
|
667
|
+
if (!match || (round.headSha && match[2] !== round.headSha))
|
|
668
|
+
return;
|
|
669
|
+
metadata[recoveredSnapshotKey(actor)] = {
|
|
670
|
+
content: JSON.stringify({
|
|
671
|
+
source: 'local-git',
|
|
672
|
+
baseSha: match[1],
|
|
673
|
+
headSha: match[2],
|
|
674
|
+
reconstructed: true,
|
|
675
|
+
}),
|
|
676
|
+
};
|
|
677
|
+
}));
|
|
678
|
+
recoveries.forEach((result, index) => {
|
|
679
|
+
if (result.status === 'rejected') {
|
|
680
|
+
const actor = run.agentContexts?.find((context) => context.id === recoveryRounds[index].key);
|
|
681
|
+
if (actor)
|
|
682
|
+
metadata[recoveredSnapshotKey(actor)] = {
|
|
683
|
+
error: result.reason instanceof Error ? result.reason.message : String(result.reason),
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
if (readDiff && metadata['history:git']) {
|
|
689
|
+
const requests = new Map();
|
|
690
|
+
for (const round of reviewHistoryView(run, metadata).checks.flatMap((check) => check.rounds)) {
|
|
691
|
+
for (const [path, base, head] of [
|
|
692
|
+
[round.diffPath, round.reviewBaseSha, round.headSha],
|
|
693
|
+
[round.fixDiffPath, round.fixBaseSha, round.fixHeadSha],
|
|
694
|
+
]) {
|
|
695
|
+
if (path?.startsWith('history:git:') && base && head)
|
|
696
|
+
requests.set(path, {
|
|
697
|
+
slotId: run.slotId ?? '',
|
|
698
|
+
...(run.slotId ? {} : { runId: run.id }),
|
|
699
|
+
base,
|
|
700
|
+
head,
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
const entries = [...requests];
|
|
705
|
+
const results = await Promise.allSettled(entries.map(([, params]) => readDiff(params)));
|
|
706
|
+
entries.forEach(([path], index) => {
|
|
707
|
+
const value = results[index];
|
|
708
|
+
metadata[path] =
|
|
709
|
+
value.status === 'fulfilled'
|
|
710
|
+
? { content: value.value }
|
|
711
|
+
: { error: value.reason instanceof Error ? value.reason.message : String(value.reason) };
|
|
712
|
+
});
|
|
713
|
+
}
|
|
380
714
|
// Reuse each platform's existing diff viewer for changed files, instead of another diff parser.
|
|
381
715
|
const diffs = [
|
|
382
|
-
...new Set(reviewHistoryView(run, metadata).checks.flatMap((check) => check.rounds.flatMap((round) =>
|
|
716
|
+
...new Set(reviewHistoryView(run, metadata).checks.flatMap((check) => check.rounds.flatMap((round) => [round.fixDiffPath, round.diffPath]
|
|
717
|
+
.filter((path) => !path?.startsWith('history:'))
|
|
718
|
+
.filter((path) => Boolean(path))))),
|
|
383
719
|
];
|
|
384
720
|
return { ...metadata, ...(await readPaths(diffs)) };
|
|
385
721
|
}
|