Skip to content

Commit baf9ddb

Browse files
brokemac79steipete
andauthored
feat: classify apply skip next actions (#395)
* feat: classify apply skip next actions * fix: classify apply recovery actions --------- Co-authored-by: Peter Steinberger <[email protected]>
1 parent 5f4af59 commit baf9ddb

5 files changed

Lines changed: 416 additions & 9 deletions

File tree

‎dashboard/worker.ts‎

Lines changed: 103 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3561,6 +3561,7 @@ async function readApplyHealthMarker(env, targetRepo) {
35613561
const status = parseJsonObject(decodeGithubContent(content?.content)) || {};
35623562
const health = objectValue(status.apply_health);
35633563
const skipReasons = numericRecord(health.skip_reasons);
3564+
const nextActions = applyHealthNextActions(health.next_actions);
35643565
const cursor = objectValue(health.cursor);
35653566
return {
35663567
target_repo: nullableString(status.target_repo) || targetRepo,
@@ -3581,6 +3582,8 @@ async function readApplyHealthMarker(env, targetRepo) {
35813582
skip_reasons: skipReasons,
35823583
cursor_required: health.cursor_required === true,
35833584
lanes: applyHealthLanes(health.lanes),
3585+
next_actions: nextActions,
3586+
next_action_buckets: numericRecord(health.next_action_buckets),
35843587
attention_reasons: Array.isArray(health.attention_reasons)
35853588
? health.attention_reasons
35863589
.map((reason) => String(reason))
@@ -3615,6 +3618,8 @@ async function readApplyHealthMarker(env, targetRepo) {
36153618
skip_reasons: {},
36163619
cursor_required: false,
36173620
lanes: emptyApplyHealthLanes(),
3621+
next_actions: [],
3622+
next_action_buckets: {},
36183623
attention_reasons: [],
36193624
cursor: null,
36203625
};
@@ -3631,6 +3636,8 @@ function emptyApplyHealthStatus(targetRepos) {
36313636
skip_reasons: {},
36323637
cursor_required: false,
36333638
lanes: emptyApplyHealthLanes(),
3639+
next_actions: [],
3640+
next_action_buckets: {},
36343641
attention_reasons: [],
36353642
cursor: null,
36363643
})),
@@ -3671,6 +3678,27 @@ function applyHealthLane(value) {
36713678
};
36723679
}
36733680

3681+
function applyHealthNextActions(value) {
3682+
if (!Array.isArray(value)) return [];
3683+
return value
3684+
.map((entry) => {
3685+
const source = objectValue(entry);
3686+
const reason = nullableString(source.reason);
3687+
if (!reason) return null;
3688+
return {
3689+
reason,
3690+
count: numberOrNull(source.count),
3691+
bucket: nullableString(source.bucket),
3692+
owner: nullableString(source.owner),
3693+
retryable: Boolean(source.retryable),
3694+
label: nullableString(source.label),
3695+
summary: nullableString(source.summary),
3696+
next_step: nullableString(source.next_step),
3697+
};
3698+
})
3699+
.filter(Boolean)
3700+
.slice(0, 12);
3701+
}
36743702
function latestIso(values) {
36753703
const timestamps = values
36763704
.map((value) => Date.parse(value || ""))
@@ -6840,13 +6868,14 @@ function renderApplyHealth(data) {
68406868
}
68416869
target.innerHTML = items.map(item => {
68426870
const topReason = applyHealthPrimaryReason(item);
6843-
const topInfo = applyHealthReasonInfo(topReason);
6871+
const topInfo = applyHealthReasonInfo(topReason, item);
68446872
const action = applyHealthRecommendedAction(item, topReason);
68456873
const reasons = applyHealthReasonEntries(item)
68466874
.slice(0, 4)
6847-
.map(([reason, count]) => applyHealthReasonPill(reason, count))
6875+
.map(([reason, count]) => applyHealthReasonPill(reason, count, item))
68486876
.join("");
68496877
const showCursor = item.cursor_required || Boolean(item.cursor?.next_after_number);
6878+
const buckets = applyHealthNextActionBucketPills(item);
68506879
const cursor = item.cursor?.next_after_number ? "cursor #" + item.cursor.next_after_number : "cursor missing";
68516880
const cursorTitle = item.cursor?.next_after_number
68526881
? "Rotation cursor was recorded; the next pruning run should continue after this item."
@@ -6866,7 +6895,7 @@ function renderApplyHealth(data) {
68666895
'<p>' + esc(applyHealthOperatorSummary(item, topInfo)) + '</p>' +
68676896
'<p class="apply-health-next"><strong>Next check:</strong> ' + esc(topInfo.action) + '</p>' +
68686897
applyHealthActionHtml(action) +
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>';
6898+
'<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 + buckets + linkClass(item.run_url, "workflow run", "pill run-link") + '</div></div>';
68706899
}).join("");
68716900
}
68726901
function applyHealthNeedsAttention(status) {
@@ -6904,11 +6933,43 @@ function applyHealthReasonEntries(item) {
69046933
function applyHealthPrimaryReason(item) {
69056934
return applyHealthReasonEntries(item)[0]?.[0] || item.status || "";
69066935
}
6907-
function applyHealthReasonPill(reason, count) {
6908-
const info = applyHealthReasonInfo(reason);
6936+
function applyHealthReasonPill(reason, count, item) {
6937+
const info = applyHealthReasonInfo(reason, item);
69096938
const countText = Number.isFinite(count) ? " " + fmt.format(count) : "";
69106939
return '<span class="pill apply-health-reason" title="' + esc(info.summary + " Next: " + info.action) + '">' + esc(info.label + countText) + '</span>';
69116940
}
6941+
function applyHealthNextActionForReason(item, reason) {
6942+
return (item.next_actions || []).find(action => action.reason === reason) || null;
6943+
}
6944+
function applyHealthNextActionBucketPills(item) {
6945+
const buckets = item.next_action_buckets || {};
6946+
const entries = Object.entries(buckets)
6947+
.filter(([, count]) => Number.isFinite(count) && count > 0)
6948+
.sort((left, right) => Number(right[1]) - Number(left[1]));
6949+
if (entries.length < 2) return "";
6950+
const total = entries.reduce((sum, [, count]) => sum + Number(count), 0);
6951+
const summary = entries
6952+
.slice(0, 4)
6953+
.map(([bucket, count]) => applyHealthBucketLabel(bucket) + " " + fmt.format(Number(count)))
6954+
.join("; ");
6955+
return '<span class="pill apply-health-reason" title="' + esc("Follow-up buckets: " + summary) + '">' + esc("follow-ups " + fmt.format(total)) + '</span>';
6956+
}
6957+
function applyHealthBucketLabel(bucket) {
6958+
const labels = {
6959+
already_resolved: "already resolved",
6960+
close_coverage_proof: "needs close proof",
6961+
conversation_unlock: "unlock conversation",
6962+
defer_until_closing_pr: "defer for PR state",
6963+
inspect: "inspect skips",
6964+
live_state_recovery: "live check recovery",
6965+
maintainer_review: "maintainer decision",
6966+
report_quality_repair: "repair review report",
6967+
review_refresh: "refresh reviews",
6968+
run_budget: "runtime budget",
6969+
stable_skip: "stable skips",
6970+
};
6971+
return labels[bucket] || applyHealthReasonLabel(bucket);
6972+
}
69126973
function applyHealthActionHtml(action) {
69136974
if (!action) return "";
69146975
const command = action.command || "";
@@ -6921,6 +6982,7 @@ function applyHealthRecommendedAction(item, reason) {
69216982
const targetRepo = String(item.target_repo || "openclaw/openclaw");
69226983
const mode = String(item.mode || "").toLowerCase();
69236984
const workflowUrl = "https://github.com/openclaw/clawsweeper/actions/workflows/sweep.yml";
6985+
const nextAction = applyHealthNextActionForReason(item, reason);
69246986
if (reason === "cursor_required_but_missing_after_full_window") {
69256987
return {
69266988
title: "Maintainer action: inspect the current run before rerunning, because a missing cursor can make the next run repeat the same window.",
@@ -6931,16 +6993,40 @@ function applyHealthRecommendedAction(item, reason) {
69316993
}
69326994
if (reason === "skipped_changed_since_review") {
69336995
return {
6934-
title: "Maintainer action: refresh review records before trying to close changed items.",
6996+
title: "Maintainer action: " + (nextAction?.next_step || "refresh review records before trying to close changed items."),
69356997
command: "gh workflow run sweep.yml --repo openclaw/clawsweeper -f target_repo=" + targetRepo + " -f apply_existing=false",
69366998
url: workflowUrl,
69376999
linkLabel: "open workflow",
69387000
};
69397001
}
69407002
if (reason === "skipped_pr_close_coverage_proof") {
69417003
return {
6942-
title: "Maintainer action: add close-coverage proof before retrying PR pruning.",
6943-
detail: "Add or refresh close-coverage proof, then rerun the close lane.",
7004+
title: "Maintainer action: " + (nextAction?.next_step || "add close-coverage proof before retrying PR pruning."),
7005+
detail: nextAction?.next_step || "Add or refresh close-coverage proof, then rerun the close lane.",
7006+
url: item.run_url || workflowUrl,
7007+
linkLabel: item.run_url ? "open run" : "open workflow",
7008+
};
7009+
}
7010+
if (nextAction && !nextAction.retryable) {
7011+
return {
7012+
title: "Maintainer action: " + (nextAction.next_step || "inspect this stable or policy-gated skip before rerunning."),
7013+
detail: nextAction.next_step || "No automatic rerun is recommended for this skip bucket.",
7014+
url: item.run_url || workflowUrl,
7015+
linkLabel: item.run_url ? "open run" : "open workflow",
7016+
};
7017+
}
7018+
if (nextAction && nextAction.bucket === "report_quality_repair") {
7019+
return {
7020+
title: "Maintainer action: " + (nextAction.next_step || "repair or refresh the review report."),
7021+
detail: nextAction.next_step || "Queue report-quality repair or re-review before retrying apply.",
7022+
url: item.run_url || workflowUrl,
7023+
linkLabel: item.run_url ? "open run" : "open workflow",
7024+
};
7025+
}
7026+
if (nextAction) {
7027+
return {
7028+
title: "Maintainer action: " + (nextAction.next_step || "inspect this follow-up before rerunning."),
7029+
detail: nextAction.next_step || "Inspect this follow-up bucket before retrying apply.",
69447030
url: item.run_url || workflowUrl,
69457031
linkLabel: item.run_url ? "open run" : "open workflow",
69467032
};
@@ -6961,7 +7047,15 @@ function applyHealthRecommendedAction(item, reason) {
69617047
linkLabel: "open workflow",
69627048
};
69637049
}
6964-
function applyHealthReasonInfo(reason) {
7050+
function applyHealthReasonInfo(reason, item) {
7051+
const nextAction = item ? applyHealthNextActionForReason(item, reason) : null;
7052+
if (nextAction?.label || nextAction?.summary || nextAction?.next_step) {
7053+
return {
7054+
label: nextAction.label || applyHealthReasonLabel(reason),
7055+
summary: nextAction.summary || "ClawSweeper classified this skip bucket with a deterministic follow-up.",
7056+
action: nextAction.next_step || "Inspect this follow-up bucket before rerunning.",
7057+
};
7058+
}
69657059
const value = String(reason || "");
69667060
if (value === "cursor_required_but_missing_after_full_window") {
69677061
return {

‎docs/live-dashboard.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ is absent or a cache event lands in another Cloudflare colo.
131131
- lane-level apply health in status JSON so closure processing and durable
132132
review-comment sync are reported separately even when they share the same
133133
applicator
134+
- skip next-action buckets in apply health JSON so stale reviews, missing close
135+
proof, protected labels, stable skips, invalid reports, and open closing PRs
136+
are discoverable without reading individual item records
134137

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

0 commit comments

Comments
 (0)