Skip to content

Commit 3d09c5f

Browse files
authored
fix(reconcile): survive GitHub throttling in stuck-run remediation (#1144)
Fixes the reconcile lane dying under GitHub installation throttling: runs 31627576607 and 31629653366 failed when stuck-run remediation's first discovery request took a 403 rate-limit and exited 1, blocking the dead-letter drain stages behind it for the whole cycle. Remediation now classifies rate-limit/abuse throttles during discovery or mid-remediation as a graceful skip (shared classifier extracted to operator-skip-reasons.mjs - no forked logic; emits skip_reasons.github_throttled) while real errors still exit 1. The workflow isolates remediation with continue-on-error and re-fails after both reconcile stages, so the DLQ drain never sits behind opportunistic housekeeping; absent-inventory uploads are ignored. Proof: Docker-backed Crabbox receipt at this exact head (docs/proof/remediation-throttle-skip/), red (old child exits 1 on throttled 403) / green (6/6: new child exits 0 + skip line, persistent 5xx still exits 1 after bounded retries, workflow-shape checks). Verdict clean (Findings: None) on ab5e594.
1 parent e0dc544 commit 3d09c5f

14 files changed

Lines changed: 815 additions & 66 deletions

‎.github/workflows/exact-review-dead-letter-reconcile.yml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ jobs:
7979
echo "restored queued-run zombie state from artifact ${artifact_id}"
8080
8181
- name: Remediate demonstrably stuck queued runs
82+
id: remediate
83+
continue-on-error: true
8284
env:
8385
EXECUTE: ${{ github.event_name == 'schedule' && 'true' || github.event.inputs.execute }}
8486
GITHUB_TOKEN: ${{ github.token }}
@@ -153,6 +155,12 @@ jobs:
153155
fi
154156
node scripts/exact-review-dead-letter-operator.mjs "${args[@]}"
155157
158+
- name: Fail if queued-run remediation failed
159+
if: ${{ always() && steps.remediate.outcome == 'failure' }}
160+
run: |
161+
echo "Queued-run remediation failed after dead-letter reconciliation completed" >&2
162+
exit 1
163+
156164
- name: Upload sanitized inventory
157165
if: always()
158166
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
@@ -164,5 +172,5 @@ jobs:
164172
.artifacts/exact-review-dlq/stuck-queued-runs.json
165173
.artifacts/exact-review-dlq/stuck-queued-zombies.json
166174
include-hidden-files: true
167-
if-no-files-found: error
175+
if-no-files-found: ignore
168176
retention-days: 14
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Remediation throttle skip proof
2+
3+
- Status: historical proof
4+
- Owner: ClawSweeper maintainers
5+
- Source of truth: `scripts/stuck-queued-run-remediation.mjs`, `scripts/operator-skip-reasons.mjs`, and `.github/workflows/exact-review-dead-letter-reconcile.yml`
6+
- Base revision: `openclaw/clawsweeper@e0dc54438e5e346f573af5e6d2cb07c6c1620a8f`
7+
- Update when: the remediation throttle contract, dead-letter workflow ordering, or focused loopback fixtures change
8+
9+
The proof claim is that GitHub rate-limit and abuse throttles are an operator-visible graceful skip for opportunistic queued-run remediation, including after earlier cancellations, while persistent 5xx and authorization failures remain hard failures. The exercised surface is the production CLI routed through its real `GITHUB_API_URL` seam to loopback HTTP listeners, plus the parsed production workflow.
10+
11+
[`red-green-transcript.txt`](red-green-transcript.txt) records the original macOS red test-only run against the base production script and the green focused run. [`container-transcript.txt`](container-transcript.txt) records the required repeat of that same suite inside Docker-backed Crabbox. The fixtures cover a 403 installation rate-limit body, a 429 secondary-rate-limit response after one successful cancellation, a non-throttle 403, persistent 503 responses with three attempts, an invalid inventory shape, and the workflow sequencing/upload contract. No live credentials or external mutations are used.
12+
13+
The source-blind behavior contract is in [`behavior-contract.md`](behavior-contract.md). All five clauses passed through the operator CLI/workflow artifact surfaces. Anti-cheat probes varied both status and body, distinguished authorization from throttling, retained a completed mutation before the mid-run skip, and verified the persistent failure path.
14+
15+
The container repeat used Crabbox `provider=local-container`, image `node:24-bookworm`, and `--fresh-pr openclaw/clawsweeper#1144` on lease `cbx_efa770db5e6d` (`quick-crab-b89a`). RED reproduced the merge-base child exit 1. GREEN passed all six focused scenarios, including the throttled child exit 0 and structured `skip_reasons.github_throttled` event, persistent 5xx child exit 1, and workflow-shape assertions. [`container-provenance.json`](container-provenance.json) freezes the run metadata; [`container-secret-scan.json`](container-secret-scan.json) records the transcript scan. [`run-container-proof.sh`](run-container-proof.sh) is the executed launcher.
16+
17+
OpenClaw Bay is unaffected: this changes only an internal housekeeping CLI and workflow sequencing, with no dashboard data contract or observer surface change. No dashboard files were touched, so no Bay update or real-Worker receipt is needed.
18+
19+
Limits: the transport is loopback HTTP rather than live GitHub, and workflow behavior is validated structurally rather than by dispatching the production schedule. The evidence commit adds only this proof material after tested source head `98fae30ad6336f525b654e90f961e6909b5f61e7`; no runtime or workflow change follows the receipt.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Behavior Contract
2+
3+
## User-Visible Goal
4+
5+
Opportunistic stuck-run remediation must yield to GitHub throttling without preventing the scheduled dead-letter reconcile cycle, while authentication failures, persistent server failures, and malformed responses remain hard failures.
6+
7+
## Target
8+
9+
- Type: operator CLI and GitHub Actions workflow artifact
10+
- Launch or access: `node scripts/stuck-queued-run-remediation.mjs` through the focused loopback test and parsed `.github/workflows/exact-review-dead-letter-reconcile.yml`
11+
- Allowed fixtures and credential source: loopback HTTP listeners through `GITHUB_API_URL`; synthetic placeholder token only
12+
13+
## User Tasks
14+
15+
1. Run discovery when GitHub returns a rate-limit 403.
16+
2. Run discovery when GitHub returns a persistent 503 or a non-throttle 403.
17+
3. Run execute mode when one cancellation succeeds and the next request is throttled.
18+
4. Inspect the workflow ordering and artifact-upload policy.
19+
20+
## Expected Observable Behavior
21+
22+
- A discovery throttle exits 0 and emits one JSON line with `skip_reasons.github_throttled`, phase, and request path.
23+
- Persistent 5xx retries three times and exits 1; a non-throttle 403 exits 1 without retry.
24+
- A throttle after a successful cancellation retains that action, stops further remediation, emits the skip reason, and exits 0.
25+
- The workflow lets both dead-letter reconcile stages run after a remediation failure, then fails honestly; absent inventory files do not create a second upload failure.
26+
27+
## Anti-Cheat Probes
28+
29+
- Vary the throttle signal between a 403 rate-limit body and HTTP 429 secondary-rate-limit response.
30+
- Replace the throttle body with an authorization error and verify it does not skip.
31+
- Replace the throttle response with persistent 503 and verify the bounded retry plus hard failure.
32+
- Exercise throttling after a prior mutation rather than only on the first request.
33+
34+
## Evidence Required
35+
36+
- Red/green Node test transcript showing exit status and named scenarios.
37+
- Focused workflow-shape assertion in the green run.
38+
- Docker-backed Crabbox `local-container` provenance for the reviewed source head.
39+
- Secret scan of the committed transcript.
40+
41+
## Out Of Scope
42+
43+
- Live GitHub cancellation mutations.
44+
- Cloudflare Worker, dashboard, or OpenClaw Bay behavior.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"schema": "clawsweeper-crabbox-proof-provenance/v1",
3+
"claim": "The remediation throttle red/green scenario suite passes on the reviewed PR head inside a Docker-backed Crabbox local-container while the merge-base production script reproduces the old failure.",
4+
"tested_source_head": "98fae30ad6336f525b654e90f961e6909b5f61e7",
5+
"merge_base": "e0dc54438e5e346f573af5e6d2cb07c6c1620a8f",
6+
"crabbox": {
7+
"cli_version": "0.38.3-5-g2a79805d",
8+
"provider": "local-container",
9+
"lease_id": "cbx_efa770db5e6d",
10+
"lease_slug": "quick-crab-b89a",
11+
"run_id": null,
12+
"machine_type": "node_24-bookworm",
13+
"container_image": "node:24-bookworm",
14+
"container_engine": "Docker 29.4.0",
15+
"checkout": "--fresh-pr openclaw/clawsweeper#1144",
16+
"workdir": "/work/crabbox/cbx_efa770db5e6d/fresh-pr-openclaw-clawsweeper-1144",
17+
"exit_code": 0,
18+
"run_status": "succeeded",
19+
"lease_stopped": true
20+
},
21+
"runtime": {
22+
"node": "v24.19.0",
23+
"pnpm": "11.10.0"
24+
},
25+
"timing_ms": {
26+
"sync": 10727,
27+
"command": 4920,
28+
"total": 15648,
29+
"command_phases": [
30+
{ "name": "user-command", "ms": 1894 },
31+
{ "name": "install", "ms": 2128 },
32+
{ "name": "red", "ms": 156 },
33+
{ "name": "green", "ms": 741 }
34+
]
35+
},
36+
"result": {
37+
"red_test_exit": 1,
38+
"old_production_throttled_child_exit": 1,
39+
"green_test_exit": 0,
40+
"focused_scenarios": 6,
41+
"focused_scenarios_passed": 6,
42+
"new_production_throttled_child_exit": 0,
43+
"asserted_skip_line": {
44+
"event": "stuck_queued_remediation_skipped",
45+
"skip_reasons": { "github_throttled": 1 },
46+
"phase": "discovery",
47+
"request_path": "/actions/runs?status=queued&per_page=100&page=1"
48+
},
49+
"persistent_5xx_child_exit": 1,
50+
"persistent_5xx_attempts": 3,
51+
"workflow_shape": "pass",
52+
"production_script_restored": true,
53+
"proof_marker": "PROOF_EXIT=0",
54+
"transcript": {
55+
"path": "docs/proof/remediation-throttle-skip/container-transcript.txt",
56+
"bytes": 4325,
57+
"sha256": "9164bc9f37c2e9f815261c4174dd5e94a99661da909d422d3fd878b5e65e65c1",
58+
"secret_scan": "docs/proof/remediation-throttle-skip/container-secret-scan.json"
59+
},
60+
"launcher": {
61+
"path": "docs/proof/remediation-throttle-skip/run-container-proof.sh",
62+
"bytes": 3635,
63+
"sha256": "7e702a4322269238884b60e8594deeda82ec34b1b7aec909ed2d06719b7768a6"
64+
}
65+
},
66+
"discarded_attempts": [
67+
{
68+
"lease_id": "cbx_12a0f57a1b2c",
69+
"lease_slug": "amber-hermit",
70+
"exit_code": 128,
71+
"reason": "The pre-existing proof named a non-existent base SHA; the launcher stopped before dependency installation or tests.",
72+
"lease_stopped": true
73+
},
74+
{
75+
"lease_id": "cbx_38a3bb9d35e3",
76+
"lease_slug": "coral-prawn-c06a",
77+
"exit_code": 1,
78+
"reason": "The evidence extractor expected TAP ok lines, but Node 24 emitted the Unicode spec reporter; RED ran and GREEN executed before the extractor rejected the output format.",
79+
"lease_stopped": true
80+
}
81+
],
82+
"limits": [
83+
"The GitHub API is a loopback fixture; no production workflow run was cancelled.",
84+
"Workflow behavior is parsed and asserted structurally rather than proven by dispatching the production schedule.",
85+
"The receipt-containing evidence commit changes proof files only; the tested runtime and workflow source remain the recorded source head."
86+
]
87+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"schema": "clawsweeper-proof-secret-scan/v1",
3+
"scanner": "trufflehog 3.96.0",
4+
"command": "trufflehog filesystem docs/proof/remediation-throttle-skip/container-transcript.txt --results=verified,unknown --json",
5+
"source": {
6+
"path": "docs/proof/remediation-throttle-skip/container-transcript.txt",
7+
"bytes": 4325,
8+
"sha256": "9164bc9f37c2e9f815261c4174dd5e94a99661da909d422d3fd878b5e65e65c1"
9+
},
10+
"result": {
11+
"exit_code": 0,
12+
"verified_secrets": 0,
13+
"unverified_secrets": 0
14+
}
15+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
Remediation throttle skip Docker-backed proof
2+
provider=local-container
3+
image=node:24-bookworm
4+
checkout_head=98fae30ad6336f525b654e90f961e6909b5f61e7
5+
expected_head=98fae30ad6336f525b654e90f961e6909b5f61e7
6+
base_head=e0dc54438e5e346f573af5e6d2cb07c6c1620a8f
7+
node=v24.19.0
8+
Installing [email protected]...
9+
pnpm=11.10.0
10+
docker=host-backed local-container
11+
12+
CRABBOX_PHASE:install
13+
? Verifying lockfile against supply-chain policies (79 entries)...
14+
Lockfile is up to date, resolution step is skipped
15+
Progress: resolved 1, reused 0, downloaded 0, added 0
16+
Packages: +19
17+
+++++++++++++++++++
18+
19+
╭───────────────────────────────────────────────╮
20+
│ │
21+
│ Update available! 11.10.0 → 11.21.0. │
22+
│ Changelog: https://pnpm.io/v/11.21.0 │
23+
│ To update, run: corepack use [email protected] │
24+
│ │
25+
╰───────────────────────────────────────────────╯
26+
27+
✓ Lockfile passes supply-chain policies (79 entries in 716ms)
28+
Progress: resolved 19, reused 0, downloaded 16, added 16
29+
Progress: resolved 19, reused 0, downloaded 19, added 19, done
30+
31+
dependencies:
32+
+ typescript 7.0.2
33+
+ yaml 2.9.0
34+
35+
devDependencies:
36+
+ @types/node 24.13.3
37+
+ markdown-it 15.0.0
38+
+ oxfmt 0.58.0
39+
+ oxlint 1.73.0
40+
+ oxlint-tsgolint 0.24.0
41+
42+
Done in 2s using pnpm v11.10.0
43+
44+
CRABBOX_PHASE:red
45+
RED: PR test fixture against merge-base production script
46+
command=node --test --test-name-pattern=discovery_GitHub_throttling test/stuck-queued-run-remediation.test.ts
47+
✖ discovery GitHub throttling exits successfully with a structured skip reason (58.77242ms)
48+
ℹ tests 1
49+
ℹ suites 0
50+
ℹ pass 0
51+
ℹ fail 1
52+
ℹ cancelled 0
53+
ℹ skipped 0
54+
ℹ todo 0
55+
ℹ duration_ms 130.638469
56+
✖ discovery GitHub throttling exits successfully with a structured skip reason (58.77242ms)
57+
AssertionError [ERR_ASSERTION]: GET /actions/runs?status=queued&per_page=100&page=1 returned 403: {"message":"API rate limit exceeded for installation"}
58+
59+
60+
1 !== 0
61+
62+
at TestContext.<anonymous> (file:///work/crabbox/cbx_efa770db5e6d/fresh-pr-openclaw-clawsweeper-1144/test/stuck-queued-run-remediation.test.ts:222:12)
63+
at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
64+
at async Test.run (node:internal/test_runner/test:1389:7)
65+
at async startSubtestAfterBootstrap (node:internal/test_runner/harness:387:3) {
66+
generatedMessage: false,
67+
code: 'ERR_ASSERTION',
68+
actual: 1,
69+
expected: 0,
70+
operator: 'strictEqual',
71+
diff: 'simple'
72+
}
73+
red_test_exit=1
74+
old_production_child_exit=1 (reported by the failed assertion above)
75+
76+
CRABBOX_PHASE:green
77+
GREEN: PR implementation plus workflow isolation
78+
command=node --test --test-name-pattern=discovery GitHub throttling|persistent discovery 5xx|non-throttle discovery 403|unexpected discovery response shape|mid-remediation throttling|queued workflow remediation test/stuck-queued-run-remediation.test.ts test/review-reliability-workflow.test.ts
79+
✔ queued workflow remediation shares the guarded dead-letter cadence (8.372814ms)
80+
✔ discovery GitHub throttling exits successfully with a structured skip reason (55.655359ms)
81+
✔ persistent discovery 5xx still exits unsuccessfully after bounded retry (400.823133ms)
82+
✔ a non-throttle discovery 403 remains a hard failure (55.087567ms)
83+
✔ an unexpected discovery response shape remains a hard failure (46.30671ms)
84+
✔ mid-remediation throttling stops after completed actions and exits successfully (81.621181ms)
85+
ℹ tests 6
86+
ℹ suites 0
87+
ℹ pass 6
88+
ℹ fail 0
89+
ℹ cancelled 0
90+
ℹ skipped 0
91+
ℹ todo 0
92+
ℹ duration_ms 716.575159
93+
green_test_exit=0
94+
new_production_throttled_child_exit=0 (asserted by passing scenario)
95+
asserted_skip_line={"event":"stuck_queued_remediation_skipped","skip_reasons":{"github_throttled":1},"phase":"discovery","request_path":"/actions/runs?status=queued&per_page=100&page=1"}
96+
persistent_5xx_child_exit=1 (asserted after three bounded attempts)
97+
workflow_shape=pass (remediation isolated; both reconcile stages precede deferred failure; absent artifacts ignored)
98+
production_script_restored=true
99+
PROOF_EXIT=0
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Remediation throttle skip red/green transcript
2+
Base: openclaw/clawsweeper@e0dc54438e5e346f573af5e6d2cb07c6c1620a8f
3+
Environment: Node v24.19.0, macOS, loopback HTTP via GITHUB_API_URL
4+
5+
RED (test-only patch; production script still at base behavior)
6+
$ node --test --test-name-pattern='discovery GitHub throttling' test/stuck-queued-run-remediation.test.ts
7+
exit_code=1
8+
not ok - discovery GitHub throttling exits successfully with a structured skip reason
9+
AssertionError [ERR_ASSERTION]: GET /actions/runs?status=queued&per_page=100&page=1 returned 403: {"message":"API rate limit exceeded for installation"}
10+
1 !== 0
11+
tests 1
12+
pass 0
13+
fail 1
14+
15+
GREEN (implementation plus workflow isolation)
16+
$ node --test --test-name-pattern='discovery GitHub throttling|persistent discovery 5xx|non-throttle discovery 403|unexpected discovery response shape|mid-remediation throttling|queued workflow remediation' test/stuck-queued-run-remediation.test.ts test/review-reliability-workflow.test.ts
17+
exit_code=0
18+
ok - queued workflow remediation shares the guarded dead-letter cadence
19+
ok - discovery GitHub throttling exits successfully with a structured skip reason
20+
ok - persistent discovery 5xx still exits unsuccessfully after bounded retry
21+
ok - a non-throttle discovery 403 remains a hard failure
22+
ok - an unexpected discovery response shape remains a hard failure
23+
ok - mid-remediation throttling stops after completed actions and exits successfully
24+
tests 6
25+
pass 6
26+
fail 0

0 commit comments

Comments
 (0)