Skip to content

Commit 5f4af59

Browse files
authored
feat: split apply health lane reporting (#397)
* feat: split apply health lane reporting * fix: align apply lane skip accounting * fix: align apply lane comment sync accounting
1 parent 279d3bd commit 5f4af59

5 files changed

Lines changed: 232 additions & 8 deletions

File tree

‎dashboard/worker.ts‎

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3580,6 +3580,7 @@ async function readApplyHealthMarker(env, targetRepo) {
35803580
skipped: numberOrNull(health.skipped),
35813581
skip_reasons: skipReasons,
35823582
cursor_required: health.cursor_required === true,
3583+
lanes: applyHealthLanes(health.lanes),
35833584
attention_reasons: Array.isArray(health.attention_reasons)
35843585
? health.attention_reasons
35853586
.map((reason) => String(reason))
@@ -3613,6 +3614,7 @@ async function readApplyHealthMarker(env, targetRepo) {
36133614
skipped: null,
36143615
skip_reasons: {},
36153616
cursor_required: false,
3617+
lanes: emptyApplyHealthLanes(),
36163618
attention_reasons: [],
36173619
cursor: null,
36183620
};
@@ -3628,6 +3630,7 @@ function emptyApplyHealthStatus(targetRepos) {
36283630
updated_at: null,
36293631
skip_reasons: {},
36303632
cursor_required: false,
3633+
lanes: emptyApplyHealthLanes(),
36313634
attention_reasons: [],
36323635
cursor: null,
36333636
})),
@@ -3642,6 +3645,32 @@ function applyHealthNeedsAttention(status) {
36423645
);
36433646
}
36443647

3648+
function applyHealthLanes(value) {
3649+
const source = objectValue(value);
3650+
return {
3651+
closure: applyHealthLane(source.closure),
3652+
comment_sync: applyHealthLane(source.comment_sync),
3653+
};
3654+
}
3655+
3656+
function emptyApplyHealthLanes() {
3657+
return {
3658+
closure: applyHealthLane(null),
3659+
comment_sync: applyHealthLane(null),
3660+
};
3661+
}
3662+
3663+
function applyHealthLane(value) {
3664+
const source = objectValue(value);
3665+
return {
3666+
processed: numberOrNull(source.processed),
3667+
closed: numberOrNull(source.closed),
3668+
comment_synced: numberOrNull(source.comment_synced),
3669+
skipped: numberOrNull(source.skipped),
3670+
skip_reasons: numericRecord(source.skip_reasons),
3671+
};
3672+
}
3673+
36453674
function latestIso(values) {
36463675
const timestamps = values
36473676
.map((value) => Date.parse(value || ""))
@@ -6828,12 +6857,16 @@ function renderApplyHealth(data) {
68286857
const processed = Number.isFinite(item.processed) ? fmt.format(item.processed) : "unknown";
68296858
const closed = Number.isFinite(item.closed) ? fmt.format(item.closed) : "unknown";
68306859
const synced = Number.isFinite(item.comment_synced) ? fmt.format(item.comment_synced) : "unknown";
6860+
const closureProcessed = Number.isFinite(item.lanes?.closure?.processed) ? fmt.format(item.lanes.closure.processed) : processed;
6861+
const syncProcessed = Number.isFinite(item.lanes?.comment_sync?.processed) ? fmt.format(item.lanes.comment_sync.processed) : processed;
6862+
const closureSynced = Number.isFinite(item.lanes?.closure?.comment_synced) ? fmt.format(item.lanes.closure.comment_synced) : "0";
6863+
const syncLaneSynced = Number.isFinite(item.lanes?.comment_sync?.comment_synced) ? fmt.format(item.lanes.comment_sync.comment_synced) : "0";
68316864
return '<div class="apply-health-alert" role="status" title="' + esc(topInfo.summary + " Next: " + topInfo.action) + '">' +
68326865
'<div class="apply-health-heading"><strong>Pruning sweep ' + esc(applyHealthStatusLabel(item.status)) + " - " + esc(item.target_repo || "target repo") + '</strong><span class="pill" title="' + esc("Latest " + applyHealthModeLabel(item.mode) + " status from the sweep-status marker.") + '">' + esc(applyHealthModeLabel(item.mode)) + '</span></div>' +
68336866
'<p>' + esc(applyHealthOperatorSummary(item, topInfo)) + '</p>' +
68346867
'<p class="apply-health-next"><strong>Next check:</strong> ' + esc(topInfo.action) + '</p>' +
68356868
applyHealthActionHtml(action) +
6836-
'<div class="apply-health-meta"><span class="pill" title="Records checked in this pruning window.">' + esc(processed) + ' processed</span><span class="pill" title="Issues or pull requests closed by this window.">' + esc(closed) + ' closed</span><span class="pill" title="Review comments refreshed by this window.">' + esc(synced) + ' comments synced</span>' + cursorPill + reasons + linkClass(item.run_url, "workflow run", "pill run-link") + '</div></div>';
6869+
'<div class="apply-health-meta"><span class="pill" title="Records checked in this pruning window.">' + esc(processed) + ' processed</span><span class="pill" title="' + esc("Closure lane: " + closureProcessed + " records processed; " + closed + " closed.") + '">' + esc(closed) + ' closed</span><span class="pill" title="' + esc("Durable review comments refreshed across lanes: " + synced + ". Closure lane refreshed " + closureSynced + "; comment-sync lane refreshed " + syncLaneSynced + " from " + syncProcessed + " records.") + '">' + esc(synced) + ' comments synced</span>' + cursorPill + reasons + linkClass(item.run_url, "workflow run", "pill run-link") + '</div></div>';
68376870
}).join("");
68386871
}
68396872
function applyHealthNeedsAttention(status) {

‎docs/live-dashboard.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ is absent or a cache event lands in another Cloudflare colo.
128128
- problem-focused pruning alerts from latest sweep status files when apply runs
129129
report blocked or degraded progress, with reason tooltips and maintainer
130130
workflow commands for safe follow-up
131+
- lane-level apply health in status JSON so closure processing and durable
132+
review-comment sync are reported separately even when they share the same
133+
applicator
131134

132135
The Worker fetches job details only for the bounded active-run set, limits that
133136
GitHub fanout to 12 concurrent requests, and caches each run's jobs for 60

‎src/repair/workflow-utils.ts‎

Lines changed: 80 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ type ApplyReportSummary = {
3737
comment_synced: number;
3838
skipped: number;
3939
skip_reasons: Record<string, number>;
40+
lanes: {
41+
closure: ApplyLaneSummary;
42+
comment_sync: ApplyLaneSummary;
43+
};
4044
attention_reasons: string[];
4145
cursor_required: boolean;
4246
cursor: {
@@ -47,6 +51,14 @@ type ApplyReportSummary = {
4751
} | null;
4852
};
4953

54+
type ApplyLaneSummary = {
55+
processed: number;
56+
closed: number;
57+
comment_synced: number;
58+
skipped: number;
59+
skip_reasons: Record<string, number>;
60+
};
61+
5062
const args = parseArgs(process.argv.slice(2));
5163

5264
function runCli(): void {
@@ -281,18 +293,15 @@ export function countActions(reportPath: string, action: string): number {
281293

282294
export function summarizeApplyReport(options: ApplyReportSummaryOptions): ApplyReportSummary {
283295
const actions = readApplyActions(options.reportPath);
296+
const lanes = summarizeApplyLanes(actions, options.mode);
284297
const skipReasons: Record<string, number> = {};
285298
let closed = 0;
286299
let commentSynced = 0;
287300
let skipped = 0;
288301
for (const entry of actions) {
289302
if (entry.action === "closed") closed += 1;
290303
if (reportsReviewCommentSync(entry)) commentSynced += 1;
291-
const productive =
292-
entry.action === "closed" ||
293-
entry.action === "review_comment_synced" ||
294-
(entry.action === "kept_open" && isSuccessfulLabelSyncReason(entry.reason));
295-
if (!productive) {
304+
if (!isProductiveApplyAction(entry)) {
296305
skipped += 1;
297306
skipReasons[entry.action] = (skipReasons[entry.action] || 0) + 1;
298307
}
@@ -354,12 +363,78 @@ export function summarizeApplyReport(options: ApplyReportSummaryOptions): ApplyR
354363
skip_reasons: Object.fromEntries(
355364
Object.entries(skipReasons).sort(([left], [right]) => left.localeCompare(right)),
356365
),
366+
lanes,
357367
attention_reasons: attentionReasons,
358368
cursor_required: options.cursorRequired,
359369
cursor,
360370
};
361371
}
362372

373+
function summarizeApplyLanes(
374+
actions: ApplyAction[],
375+
mode: string,
376+
): { closure: ApplyLaneSummary; comment_sync: ApplyLaneSummary } {
377+
const lanes = {
378+
closure: emptyApplyLaneSummary(),
379+
comment_sync: emptyApplyLaneSummary(),
380+
};
381+
for (const entry of actions) {
382+
const laneName = applyActionLane(entry.action, mode);
383+
const lane = lanes[laneName];
384+
lane.processed += 1;
385+
if (entry.action === "closed") lane.closed += 1;
386+
if (reportsReviewCommentSync(entry)) lane.comment_synced += 1;
387+
if (!isProductiveApplyAction(entry)) {
388+
lane.skipped += 1;
389+
lane.skip_reasons[entry.action] = (lane.skip_reasons[entry.action] || 0) + 1;
390+
}
391+
}
392+
return {
393+
closure: sortApplyLaneSummary(lanes.closure),
394+
comment_sync: sortApplyLaneSummary(lanes.comment_sync),
395+
};
396+
}
397+
398+
function emptyApplyLaneSummary(): ApplyLaneSummary {
399+
return {
400+
processed: 0,
401+
closed: 0,
402+
comment_synced: 0,
403+
skipped: 0,
404+
skip_reasons: {},
405+
};
406+
}
407+
408+
function sortApplyLaneSummary(lane: ApplyLaneSummary): ApplyLaneSummary {
409+
return {
410+
...lane,
411+
skip_reasons: Object.fromEntries(
412+
Object.entries(lane.skip_reasons).sort(([left], [right]) => left.localeCompare(right)),
413+
),
414+
};
415+
}
416+
417+
function applyActionLane(action: string, mode: string): "closure" | "comment_sync" {
418+
if (
419+
String(mode || "").toLowerCase() === "comment_sync" ||
420+
action === "review_comment_synced" ||
421+
action === "skipped_comment_auth" ||
422+
action === "skipped_locked_conversation" ||
423+
action === "skipped_stale_review_comment_sync"
424+
) {
425+
return "comment_sync";
426+
}
427+
return "closure";
428+
}
429+
430+
function isProductiveApplyAction(entry: ApplyAction): boolean {
431+
return (
432+
entry.action === "closed" ||
433+
entry.action === "review_comment_synced" ||
434+
(entry.action === "kept_open" && isSuccessfulLabelSyncReason(entry.reason))
435+
);
436+
}
437+
363438
function applyReportHealthSummary(options: {
364439
status: ApplyReportSummary["status"];
365440
processed: number;

‎test/dashboard-worker.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,24 @@ test("dashboard exposes apply health from sweep status without broad scans", asy
15241524
skip_reasons: {
15251525
skipped_changed_since_review: 2,
15261526
},
1527+
lanes: {
1528+
closure: {
1529+
processed: 2,
1530+
closed: 0,
1531+
comment_synced: 0,
1532+
skipped: 2,
1533+
skip_reasons: {
1534+
skipped_changed_since_review: 2,
1535+
},
1536+
},
1537+
comment_sync: {
1538+
processed: 0,
1539+
closed: 0,
1540+
comment_synced: 0,
1541+
skipped: 0,
1542+
skip_reasons: {},
1543+
},
1544+
},
15271545
attention_reasons: ["cursor_required_but_missing_after_full_window"],
15281546
cursor: null,
15291547
},
@@ -1569,6 +1587,16 @@ test("dashboard exposes apply health from sweep status without broad scans", asy
15691587
assert.deepEqual(status.recent.apply_health.items[0].skip_reasons, {
15701588
skipped_changed_since_review: 2,
15711589
});
1590+
assert.deepEqual(status.recent.apply_health.items[0].lanes.closure, {
1591+
processed: 2,
1592+
closed: 0,
1593+
comment_synced: 0,
1594+
skipped: 2,
1595+
skip_reasons: {
1596+
skipped_changed_since_review: 2,
1597+
},
1598+
});
1599+
assert.equal(status.recent.apply_health.items[0].lanes.comment_sync.processed, 0);
15721600
assert.equal(status.recent.apply_health.items[0].cursor, null);
15731601
} finally {
15741602
globalThis.fetch = originalFetch;

‎test/repair/workflow-utils.test.ts‎

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,16 @@ test("workflow utilities summarize apply health with skip buckets and cursor", (
186186
{ number: 20, action: "review_comment_synced" },
187187
{ number: 30, action: "skipped_changed_since_review" },
188188
{ number: 40, action: "skipped_changed_since_review" },
189+
{
190+
number: 50,
191+
action: "skipped_comment_auth",
192+
reason: "GitHub rejected durable review comment write with Requires authentication",
193+
},
194+
{
195+
number: 60,
196+
action: "skipped_locked_conversation",
197+
reason: "conversation was locked while syncing review comment",
198+
},
189199
]),
190200
);
191201
write(
@@ -208,13 +218,78 @@ test("workflow utilities summarize apply health with skip buckets and cursor", (
208218
});
209219

210220
assert.equal(summary.status, "ok");
211-
assert.equal(summary.processed, 4);
221+
assert.equal(summary.processed, 6);
212222
assert.equal(summary.closed, 1);
213223
assert.equal(summary.comment_synced, 1);
214-
assert.deepEqual(summary.skip_reasons, { skipped_changed_since_review: 2 });
224+
assert.deepEqual(summary.skip_reasons, {
225+
skipped_changed_since_review: 2,
226+
skipped_comment_auth: 1,
227+
skipped_locked_conversation: 1,
228+
});
229+
assert.deepEqual(summary.lanes.closure, {
230+
processed: 3,
231+
closed: 1,
232+
comment_synced: 0,
233+
skipped: 2,
234+
skip_reasons: { skipped_changed_since_review: 2 },
235+
});
236+
assert.deepEqual(summary.lanes.comment_sync, {
237+
processed: 3,
238+
closed: 0,
239+
comment_synced: 1,
240+
skipped: 2,
241+
skip_reasons: {
242+
skipped_comment_auth: 1,
243+
skipped_locked_conversation: 1,
244+
},
245+
});
215246
assert.equal(summary.cursor?.next_after_number, 40);
216247
});
217248

249+
test("workflow utilities summarize comment-sync apply reports separately from closure", () => {
250+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "clawsweeper-workflow-"));
251+
const reportPath = path.join(root, "apply-report.json");
252+
write(
253+
reportPath,
254+
JSON.stringify([
255+
{ number: 10, action: "review_comment_synced" },
256+
{ number: 20, action: "skipped_stale_review_comment_sync" },
257+
{ number: 30, action: "skipped_pr_close_coverage_proof" },
258+
]),
259+
);
260+
261+
const summary = summarizeApplyReport({
262+
reportPath,
263+
targetRepo: "openclaw/openclaw",
264+
mode: "comment_sync",
265+
processedLimit: 25,
266+
closeLimit: null,
267+
cursorPath: path.join(root, "missing-cursor.json"),
268+
cursorRequired: false,
269+
});
270+
271+
assert.equal(summary.mode, "comment_sync");
272+
assert.equal(summary.closed, 0);
273+
assert.equal(summary.comment_synced, 1);
274+
assert.deepEqual(summary.lanes.closure, {
275+
processed: 0,
276+
closed: 0,
277+
comment_synced: 0,
278+
skipped: 0,
279+
skip_reasons: {},
280+
});
281+
assert.deepEqual(summary.lanes.comment_sync, {
282+
processed: 3,
283+
closed: 0,
284+
comment_synced: 1,
285+
skipped: 2,
286+
skip_reasons: {
287+
skipped_pr_close_coverage_proof: 1,
288+
skipped_stale_review_comment_sync: 1,
289+
},
290+
});
291+
});
292+
218293
test("workflow utilities flag full-window close scans without the required cursor", () => {
219294
const root = fs.mkdtempSync(path.join(os.tmpdir(), "clawsweeper-workflow-"));
220295
const reportPath = path.join(root, "apply-report.json");
@@ -323,6 +398,11 @@ test("workflow utilities flag operator-action skips when every result is blocked
323398
"skipped_protected_label",
324399
"skipped_same_author_pair",
325400
]);
401+
assert.equal(summary.lanes.closure.skipped, 10);
402+
assert.equal(summary.lanes.closure.comment_synced, 1);
403+
assert.equal(summary.lanes.closure.skip_reasons.kept_open, 1);
404+
assert.equal(summary.lanes.closure.skip_reasons.retry_pr_close_coverage_proof, 1);
405+
assert.equal(summary.lanes.closure.skip_reasons.skipped_pr_close_coverage_proof, 1);
326406
});
327407

328408
test("workflow utilities keep all-benign skip windows quiet", () => {
@@ -352,6 +432,11 @@ test("workflow utilities keep all-benign skip windows quiet", () => {
352432
skipped_already_closed: 1,
353433
skipped_not_open: 1,
354434
});
435+
assert.equal(summary.lanes.closure.skipped, 2);
436+
assert.deepEqual(summary.lanes.closure.skip_reasons, {
437+
skipped_already_closed: 1,
438+
skipped_not_open: 1,
439+
});
355440
assert.deepEqual(summary.attention_reasons, []);
356441
});
357442

0 commit comments

Comments
 (0)