Skip to content

Commit 5f1eab2

Browse files
committed
fix(operator): attribute recovery revalidation errors per target
1 parent badec42 commit 5f1eab2

4 files changed

Lines changed: 91 additions & 27 deletions

File tree

‎docs/proof/parked-reconcile-skip-reasons/README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ command, transport, response mix, and proof limits.
7373
## Gates
7474

7575
- `pnpm run build:all`: passed
76-
- `pnpm run test:no-build`: 3,317 tests; 3,308 passed, 9 skipped, 0 failed
76+
- `pnpm run test:no-build`: 3,318 tests; 3,309 passed, 9 skipped, 0 failed
7777
- `pnpm run lint`: passed
7878
- `pnpm run format:check`: passed
7979
- `pnpm run check:active-surface`: passed
@@ -91,10 +91,10 @@ after-fix head receives a separate fresh-PR container run after push.
9191
## Limits and Bay impact
9292

9393
This production observation proves the token-boundary diagnosis and the successful-target summary.
94-
The focused operator tests cover per-target standard-reconcile attribution, reason classification,
95-
bounded samples, credential and control-byte sanitization, and output truncation. The replay did not
96-
mutate production queue state and cannot prove the production Worker's signed list route beyond the
97-
immutable uploaded artifact.
94+
The focused operator tests cover per-target standard-reconcile discovery and recovery-revalidation
95+
attribution, reason classification, bounded samples, credential and control-byte sanitization, and
96+
output truncation. The replay did not mutate production queue state and cannot prove the production
97+
Worker's signed list route beyond the immutable uploaded artifact.
9898

9999
OpenClaw Bay is unaffected. The change adds diagnostic fields to an operator-only JSON summary; it
100100
does not change lifecycle publication, dashboard data, or the observer-only Bay surface.

‎docs/proof/parked-reconcile-skip-reasons/after-fix-error-trace-provenance.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"schema": "clawsweeper-real-boundary-proof-provenance/v1",
33
"claim": "The current source-tree operator attributes loopback GitHub issue lookup failures per parked target while replaying the immutable 20-row production inventory read-only.",
4-
"generated_at": "2026-08-11T03:04:21.562Z",
4+
"generated_at": "2026-08-11T03:36:07.839Z",
55
"source": {
66
"run_id": 31449984643,
77
"run_url": "https://github.com/openclaw/clawsweeper/actions/runs/31449984643",
@@ -13,7 +13,7 @@
1313
},
1414
"execution": {
1515
"operator": "scripts/exact-review-dead-letter-operator.mjs",
16-
"operator_sha256": "481e1fe8e8a1fa2eb9c7b46dc0e23e501ab5b4c80d45c10d64b690d763a2e683",
16+
"operator_sha256": "65142cf590de47947dd9dd6c6086f51883f7cc68c6b7397141e6afcbe7957930",
1717
"command": "node scripts/exact-review-dead-letter-operator.mjs --action reconcile-parked --max-targets 100 --max-recoveries 5 --output <temporary-path>",
1818
"execute": false,
1919
"transport": "real Node HTTP listener bound to 127.0.0.1 on an ephemeral port",

‎scripts/exact-review-dead-letter-operator.mjs‎

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -427,21 +427,12 @@ async function reconcileDeadLetters({ inventory, queueUrl, secret, args, progres
427427
identities = await inspectCanonicalTargets(selectedGroups, args.maxTargets);
428428
} catch (error) {
429429
if (error instanceof CanonicalTargetInspectionError) {
430-
recordInspectionSkips(summary, error.failedTargets, error.cause ?? error);
431-
recordInspectionSkips(
432-
summary,
433-
error.inspectedTargets,
434-
new Error(
435-
"canonical target was inspected but reconciliation aborted after another target inspection failed",
436-
),
437-
);
438-
recordInspectionSkips(
439-
summary,
440-
error.notInspectedTargets,
441-
new Error(
442-
"canonical target was not inspected because canonical discovery aborted after another target inspection failed",
443-
),
444-
);
430+
recordAbortedInspectionSkips(summary, {
431+
inspectedTargets: error.inspectedTargets,
432+
failedTargets: error.failedTargets,
433+
notInspectedTargets: error.notInspectedTargets,
434+
error: error.cause ?? error,
435+
});
445436
} else {
446437
recordInspectionSkips(
447438
summary,
@@ -634,16 +625,21 @@ async function reconcileDeadLetters({ inventory, queueUrl, secret, args, progres
634625

635626
refreshBlockedInventory();
636627
if (recoveries.length) {
637-
for (const recovery of recoveries) {
628+
for (const [index, recovery] of recoveries.entries()) {
638629
let current;
639630
try {
640631
current = await inspectRecoveryTarget(recovery.canonicalTarget);
641632
} catch (error) {
642-
recordInspectionSkips(
643-
summary,
644-
recoveries.map((candidate) => candidate.canonicalTarget),
633+
recordAbortedInspectionSkips(summary, {
634+
inspectedTargets: recoveries
635+
.slice(0, index)
636+
.map((candidate) => candidate.canonicalTarget),
637+
failedTargets: [recovery.canonicalTarget],
638+
notInspectedTargets: recoveries
639+
.slice(index + 1)
640+
.map((candidate) => candidate.canonicalTarget),
645641
error,
646-
);
642+
});
647643
summary.skipped_targets += recoveries.length;
648644
printResult(summary);
649645
return;
@@ -1348,6 +1344,27 @@ function recordInspectionSkips(summary, targets, error) {
13481344
}
13491345
}
13501346

1347+
function recordAbortedInspectionSkips(
1348+
summary,
1349+
{ inspectedTargets, failedTargets, notInspectedTargets, error },
1350+
) {
1351+
recordInspectionSkips(summary, failedTargets, error);
1352+
recordInspectionSkips(
1353+
summary,
1354+
inspectedTargets,
1355+
new Error(
1356+
"canonical target was inspected but reconciliation aborted after another target inspection failed",
1357+
),
1358+
);
1359+
recordInspectionSkips(
1360+
summary,
1361+
notInspectedTargets,
1362+
new Error(
1363+
"canonical target was not inspected because canonical discovery aborted after another target inspection failed",
1364+
),
1365+
);
1366+
}
1367+
13511368
function sanitizeSkipReason(error) {
13521369
const raw = error instanceof Error ? error.message : String(error);
13531370
const redacted = raw

‎test/exact-review-dead-letter-operator.test.ts‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,6 +2361,50 @@ test("serial canonical discovery attributes a failure only to the target that th
23612361
assert.equal(scenario.resolutions.length, 0);
23622362
});
23632363

2364+
test("serial recovery revalidation attributes a failure only to the target that threw", async () => {
2365+
const scenario = await automaticReconcileScenario({
2366+
rows: [
2367+
row("first", "publication:first", 1, "retry_exhausted", true, "eligible", "openclaw/repo#1"),
2368+
row(
2369+
"second",
2370+
"publication:second",
2371+
2,
2372+
"retry_exhausted",
2373+
true,
2374+
"eligible",
2375+
"openclaw/repo#2",
2376+
),
2377+
row("third", "publication:third", 3, "retry_exhausted", true, "eligible", "openclaw/repo#3"),
2378+
],
2379+
failTargetOnInspection: 1,
2380+
failedStatus: 403,
2381+
});
2382+
2383+
assert.equal(scenario.first.code, 0, scenario.first.stderr);
2384+
const summary = JSON.parse(scenario.first.stdout);
2385+
assert.deepEqual(summary.skip_reasons, { http_403: 1, not_inspected_abort: 2 });
2386+
assert.deepEqual(summary.skip_samples, [
2387+
{
2388+
target: "openclaw/repo#1",
2389+
reason: "live target check failed for openclaw/repo#1 (403)",
2390+
},
2391+
{
2392+
target: "openclaw/repo#2",
2393+
reason:
2394+
"canonical target was not inspected because canonical discovery aborted after another target inspection failed",
2395+
},
2396+
{
2397+
target: "openclaw/repo#3",
2398+
reason:
2399+
"canonical target was not inspected because canonical discovery aborted after another target inspection failed",
2400+
},
2401+
]);
2402+
assert.equal(summary.skipped_targets, 3);
2403+
assert.equal(scenario.restRequests, 4);
2404+
assert.equal(scenario.recoveries.length, 0);
2405+
assert.equal(scenario.resolutions.length, 0);
2406+
});
2407+
23642408
test("automatic recovery refuses a pull request whose current head has advanced", async () => {
23652409
const item = row(
23662410
"stale",
@@ -2419,6 +2463,7 @@ async function automaticReconcileScenario(options) {
24192463
let inventoryRequests = 0;
24202464
let graphqlRequests = 0;
24212465
let restRequests = 0;
2466+
const restRequestsByNumber = new Map();
24222467
let duplicateFailurePending = options.failFirstDuplicateCleanup === true;
24232468
let duplicateSkipsRemaining =
24242469
options.skipDuplicateCleanupCount ?? Number(options.skipFirstDuplicateCleanup === true);
@@ -2486,6 +2531,7 @@ async function automaticReconcileScenario(options) {
24862531
if (request.url?.startsWith("/repos/")) {
24872532
restRequests += 1;
24882533
const number = Number(request.url.split("/").at(-1));
2534+
restRequestsByNumber.set(number, (restRequestsByNumber.get(number) || 0) + 1);
24892535
if (request.url.includes("/pulls/")) {
24902536
response.writeHead(200, { "content-type": "application/json" });
24912537
response.end(
@@ -2504,6 +2550,7 @@ async function automaticReconcileScenario(options) {
25042550
if (
25052551
(options.failedRepository &&
25062552
request.url.includes(`/${options.failedRepository}/issues/`)) ||
2553+
(options.failTargetOnInspection === number && restRequestsByNumber.get(number) >= 2) ||
25072554
(options.failTargetAfterCleanup === number && resolutions.length >= 2)
25082555
) {
25092556
response.writeHead(options.failedStatus ?? 503, { "content-type": "application/json" });

0 commit comments

Comments
 (0)