Skip to content

Commit 7ee8bb2

Browse files
authored
fix: complete deterministic guarded-open reviews (#477)
* fix: complete deterministic guarded-open reviews * fix: verify exact event dispositions * fix: require terminal close confirmation * fix: complete locked exact review lifecycle * fix: complete missing exact review items * fix: requeue removed close guards * fix: resume reviews after guard removal * refactor: centralize close guard labels * fix: complete close-exempt reviews * fix: bind synced event routing to exact tuples * test: cover kept-open event tuple drift * fix: hand off exact verdicts after authoritative publish * fix: complete missing exact review status
1 parent a55bf55 commit 7ee8bb2

24 files changed

Lines changed: 1630 additions & 151 deletions

‎.github/workflows/sweep.yml‎

Lines changed: 110 additions & 46 deletions
Large diffs are not rendered by default.

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ checkpoint, and status-only commits are intentionally omitted.
3636
- Required a live `DIRTY` merge conflict and at least 30 days without contributor comments or head activity before publishing or applying low-signal pull-request close verdicts, honoring longer configured stale thresholds and applying the same fail-closed policy to stale-review promotion and trusted close routing.
3737
- Retried successful GitHub CLI JSON-lines responses when their output is truncated, preventing transient list-page corruption from aborting close-apply runs.
3838
- Allowed conflict-free canonical PRs that only need a base update to back duplicate or superseded closures while retaining proof, review, check, draft, and conflict guards.
39+
- Completed exact-item reviews whose captured record matches a deterministic remain-open guard instead of requeueing them indefinitely, carried tuple-verified terminal closes through cleanup, handed ordinary synced verdicts to an executing target-wide serialized router after authoritative publication, and treated repository-confirmed missing items as cleanup-free terminal results, while preserving latest-revision retries for review drift.
40+
- Requeued stale exact-event preflights instead of letting a successful no-disposition publisher route an older verdict.
41+
- Completed locked exact-event intake as a guarded-open result before setup or Codex, preventing review-start comment failures from retrying indefinitely.
42+
- Requeued exact reviews when locked issues or pull requests are unlocked or close-blocking labels are removed, so a guarded-open or close-exempt completion does not delay the next eligible review until unrelated activity.
3943
- Bounded broad reconciliation with batched Git I/O and tuple checkpoints that report progress and resume safely under concurrent state writers.
4044
- Retried tuple-safe broad reconciliation after full push batches lose continuous exact-state races, including candidates that normalize to no changes.
4145
- Serialized explicit workflow-dispatch planners through a non-dropping target queue and accounted for recovery runs by their requested or live shards, preventing overlapping target planning and false 89-shard reservations without undercounting multi-shard retries.

‎README.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,14 @@ separate publish job. They still use the same review and apply code paths, but
414414
only for the selected item number and only with immediate-safe reasons enabled
415415
by default: `implemented_on_main`, `duplicate_or_superseded`, and
416416
`low_signal_unmergeable_pr`.
417+
Deterministic terminal and remain-open outcomes complete in that exact run.
418+
Ordinary synced verdicts publish their exact durable comment immediately, then
419+
queue an executing target-wide comment-router scan. Target-wide serialization
420+
coalesces concurrent handoffs without losing older durable verdicts, while the
421+
review and publication work remains parallel. Direct exact-event viable-issue
422+
implementation dispatch stays disabled; the bounded broad publish/backfill lane
423+
owns that separately revalidated intake. The exact run does not claim an atomic
424+
state-publish-and-route boundary.
417425
`stale_insufficient_info` issue reports and `mostly_implemented_on_main` PR
418426
reports are never applied to young items; apply requires those reports to be at
419427
least 60 days old unless a manual run explicitly changes the threshold.

‎dashboard/worker.ts‎

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
commandTextForClawSweeperFastAck,
33
isClawSweeperReReviewCommandText,
44
} from "../src/repair/comment-command-text.ts";
5+
import { isExactReviewCloseGuardLabel } from "../src/repair/exact-review-guard-labels.ts";
56
import { TRIAGE_ROUTING_GROUPS, triageRoutingGroupsForLabels } from "./triage-routing-groups.ts";
67

78
const ACTIVE_RUN_STATUSES = new Set(["queued", "in_progress", "waiting", "requested", "pending"]);
@@ -111,14 +112,22 @@ const CLAWSWEEPER_STATE_REF = "state";
111112
const DEFAULT_CRABFLEET_URL = "https://crabfleet.openclaw.ai";
112113
const CLUSTER_REPAIR_INTAKE_WORKFLOW = "repair-cluster-intake.yml";
113114
const CLAWSWEEPER_ALLOWED_ASSOCIATIONS = new Set(["OWNER", "MEMBER", "COLLABORATOR"]);
114-
const CLAWSWEEPER_ISSUE_ITEM_ACTIONS = new Set(["opened", "reopened", "edited"]);
115+
const CLAWSWEEPER_ISSUE_ITEM_ACTIONS = new Set([
116+
"opened",
117+
"reopened",
118+
"edited",
119+
"unlocked",
120+
"unlabeled",
121+
]);
115122
const CLAWSWEEPER_PULL_ITEM_ACTIONS = new Set([
116123
"opened",
117124
"reopened",
118125
"synchronize",
119126
"ready_for_review",
120127
"converted_to_draft",
121128
"edited",
129+
"unlocked",
130+
"unlabeled",
122131
]);
123132
const DEFAULT_FAST_ACK_SETTLE_DELAYS_MS = [250, 1500, 10_000];
124133
const inFlightFastAcks = new Map();
@@ -1149,6 +1158,9 @@ function classifyGithubItemWebhook({ event, payload }) {
11491158
if (!CLAWSWEEPER_ISSUE_ITEM_ACTIONS.has(action)) {
11501159
return { accepted: false, reason: "unsupported action" };
11511160
}
1161+
if (action === "unlabeled" && !isCloseGuardLabel(payload.label)) {
1162+
return { accepted: false, reason: "unsupported action" };
1163+
}
11521164
const itemNumber = Number(objectValue(payload.issue).number);
11531165
if (!Number.isInteger(itemNumber) || itemNumber <= 0) {
11541166
return { accepted: false, reason: "missing issue number" };
@@ -1163,14 +1175,17 @@ function classifyGithubItemWebhook({ event, payload }) {
11631175
installationId,
11641176
sourceEvent: "issues",
11651177
sourceAction: action,
1166-
supersedesInProgress: action === "edited",
1178+
supersedesInProgress: ["edited", "unlocked", "unlabeled"].includes(action),
11671179
};
11681180
}
11691181

11701182
if (event === "pull_request") {
11711183
if (!CLAWSWEEPER_PULL_ITEM_ACTIONS.has(action)) {
11721184
return { accepted: false, reason: "unsupported action" };
11731185
}
1186+
if (action === "unlabeled" && !isCloseGuardLabel(payload.label)) {
1187+
return { accepted: false, reason: "unsupported action" };
1188+
}
11741189
const itemNumber = Number(objectValue(payload.pull_request).number);
11751190
if (!Number.isInteger(itemNumber) || itemNumber <= 0) {
11761191
return { accepted: false, reason: "missing pull request number" };
@@ -1185,13 +1200,26 @@ function classifyGithubItemWebhook({ event, payload }) {
11851200
installationId,
11861201
sourceEvent: "pull_request",
11871202
sourceAction: action,
1188-
supersedesInProgress: ["edited", "synchronize", "ready_for_review"].includes(action),
1203+
supersedesInProgress: [
1204+
"edited",
1205+
"synchronize",
1206+
"ready_for_review",
1207+
"unlocked",
1208+
"unlabeled",
1209+
].includes(action),
11891210
};
11901211
}
11911212

11921213
return { accepted: false, reason: "unsupported event" };
11931214
}
11941215

1216+
function isCloseGuardLabel(value) {
1217+
const label = String(objectValue(value).name || "")
1218+
.trim()
1219+
.toLowerCase();
1220+
return isExactReviewCloseGuardLabel(label);
1221+
}
1222+
11951223
function isEligibleGithubWebhookRepository(repo) {
11961224
const targetRepo = String(repo.full_name || "").toLowerCase();
11971225
if (!/^[a-z0-9_.-]+\/[a-z0-9_.-]+$/.test(targetRepo)) return false;

0 commit comments

Comments
 (0)