Skip to content

Commit e17e094

Browse files
authored
fix(publication): restore retryable classification for throttled publications (#1168)
Fixes a real regression the "automerge quota-fixture" check caught on main: throttled publications (403 rate-limit / 429) were classified permanent_failure instead of retryable_failure, routing throttle victims toward the permanent dead-letter path instead of the transient retry budget - the exact failure class #1089 fixed at the start of this effort. The check was red on main because it was RIGHT. The publisher now preserves quota metadata through the publication path and restores retryable classification: 403/429 cases assert [1,1] requests with retryable_failure; delete paths [0,0]. Introduced during the quota campaign refactors; the fixture (asserting classification, not just counts) was the only gate that saw it. Proof: red/green on the exact fixture, full gates green including the previously-red automerge check, Crabbox local-container receipt at this head, machine-verified provenance. Verdict clean (no findings, proof sufficient) on 0014afe.
1 parent bf762f3 commit e17e094

5 files changed

Lines changed: 205 additions & 1 deletion

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Automerge quota publication proof
2+
3+
The automerge quota fixture already observed the intended one-request fail-fast behavior, but exact-event publication misclassified the clean apply yield introduced by #1166. A GitHub 403 or 429 became two `skipped_runtime_budget` apply records (the interrupted item and continuation sentinel); `publish-event-result` did not recognize that proof and converted it into `permanent_failure/unknown_failure`.
4+
5+
The fix preserves the structured rate-limit metadata in the apply-yield reason and reconstructs the quota error at the exact-publication boundary. Both HTTP cases must make one authenticated GET, make no DELETE request, exit the publisher honestly, and record `retryable_failure/github_rate_limit` in the workflow outputs and durable batch result.
6+
7+
`run-proof.sh` obtains the commit, tree, and merge-base objects programmatically, cross-checks all three with `git cat-file`, runs the real GitHub CLI over the fixture's owned Unix-socket HTTP server, validates the generated summary with static `jq`, and runs the full repository gate.
8+
9+
OpenClaw Bay is unaffected because this restores an internal exact-publication failure classification; no queue, workflow, status, telemetry, dashboard, or public observer contract changes.
10+
11+
Limits: GitHub traffic is deterministic loopback traffic using synthetic credentials. The proof does not mutate production GitHub, Worker, queue, comment, label, close, merge, deployment, or workflow state. The receipt commit adds proof metadata only after the tested runtime commit.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"schema_version": 1,
3+
"recorded_at": "2026-08-14T10:42:27Z",
4+
"provider": "local-container",
5+
"lease_id": "cbx_c6ed44beacf2",
6+
"lease_slug": "crimson-prawn-01cd",
7+
"container_runtime": "docker",
8+
"image": "clawsweeper-automerge-e2e-base:quota-fixture",
9+
"machine_type": "clawsweeper-automerge-e2e-base_quota-fixture",
10+
"lease_stopped": true,
11+
"tested_head_sha": "e1b0e27e5fd8045ce65da1fdcdcfc6c145d1e8d0",
12+
"tested_head_tree": "d9fc824102d7521547b062b5152d8f6cd3d193a0",
13+
"base_sha": "bf762f3f6f9e8ee89fc31a260053dabe257a7103",
14+
"cat_file_cross_check": {
15+
"head_commit": true,
16+
"head_tree": true,
17+
"base_commit": true
18+
},
19+
"runtime": {
20+
"architecture": "arm64",
21+
"node": "v24.15.0",
22+
"pnpm": "11.10.0",
23+
"transport": "actual gh HTTP over an owned Unix socket"
24+
},
25+
"timing_ms": {
26+
"sync": 937,
27+
"command": 116171,
28+
"total": 117144,
29+
"install": 2471,
30+
"build": 1511,
31+
"quota_fixture": 716,
32+
"full_gate": 107917,
33+
"receipt": 351
34+
},
35+
"quota_fixture": {
36+
"statuses": [403, 429],
37+
"requests": [1, 1],
38+
"publisher_exits": [1, 1],
39+
"completion_kinds": ["retryable_failure", "retryable_failure"],
40+
"failure_kinds": ["github_rate_limit", "github_rate_limit"],
41+
"batch_kinds": ["retryable_failure", "retryable_failure"],
42+
"cleanup_deletes": [0, 0],
43+
"static_jq": true
44+
},
45+
"full_gate": {
46+
"command": "pnpm run check",
47+
"exit_code": 0,
48+
"tests": 3463,
49+
"passed": 3455,
50+
"failed": 0,
51+
"skipped": 8
52+
},
53+
"pre_commit_autoreview": {
54+
"command": "autoreview --mode local --stream-engine-output --parallel-tests 'pnpm run check'",
55+
"exit_code": 0,
56+
"accepted_or_actionable_findings": 0,
57+
"result": "autoreview clean: no accepted/actionable findings reported"
58+
},
59+
"limits": [
60+
"The GitHub API was a deterministic Unix-socket loopback fixture with synthetic credentials.",
61+
"No production GitHub, Worker, queue, deployment, or workflow state was mutated.",
62+
"The receipt commit adds proof metadata only after the tested runtime tree."
63+
],
64+
"cleanup": {
65+
"successful_lease_absent_from_local_container_list": true,
66+
"failed_owned_leases_absent_from_local_container_list": true,
67+
"unrelated_preexisting_exited_lease_untouched": true
68+
}
69+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
expected_head="${1:?expected head is required}"
5+
expected_base="${2:?expected merge base is required}"
6+
output_dir="${AUTOMERGE_QUOTA_PROOF_OUTPUT:-.artifacts/fix-automerge-quota-fixture}"
7+
8+
actual_head="$(git rev-parse HEAD)"
9+
head_tree="$(git rev-parse "${actual_head}^{tree}")"
10+
merge_base="$(git merge-base HEAD origin/main)"
11+
12+
test "$actual_head" = "$expected_head"
13+
test "$merge_base" = "$expected_base"
14+
git cat-file -e "${actual_head}^{commit}"
15+
git cat-file -e "${head_tree}^{tree}"
16+
git cat-file -e "${merge_base}^{commit}"
17+
18+
echo CRABBOX_PHASE:install
19+
corepack prepare [email protected] --activate
20+
pnpm install --frozen-lockfile
21+
22+
echo CRABBOX_PHASE:build
23+
pnpm run build:node
24+
25+
echo CRABBOX_PHASE:quota_fixture
26+
mkdir -p "$output_dir"
27+
node scripts/e2e/automerge.mjs \
28+
--scenario github-api-quota-fail-fast \
29+
--fixture tiny \
30+
--output "$output_dir/automerge"
31+
32+
summary="$output_dir/automerge/tiny/github-api-quota-fail-fast/summary.json"
33+
jq -e '
34+
.status == "passed" and
35+
.fixture == "tiny" and
36+
.scenario == "github-api-quota-fail-fast" and
37+
.container == true and
38+
.transport == "actual gh HTTP over an owned Unix socket" and
39+
[.results[].http_status] == [403, 429] and
40+
(.results | all(
41+
.requests == 1 and
42+
.request.method == "GET" and
43+
(.request.path | endswith("/repos/openclaw/openclaw/issues/42")) and
44+
.request.authenticated == true and
45+
.publisher_exit == 1 and
46+
.completion_kind == "retryable_failure" and
47+
.failure_kind == "github_rate_limit" and
48+
.batch_kind == "retryable_failure" and
49+
.cleanup_deletes == 0
50+
))
51+
' "$summary" >/dev/null
52+
53+
echo CRABBOX_PHASE:full_gate
54+
pnpm run check
55+
56+
echo CRABBOX_PHASE:receipt
57+
jq -n \
58+
--arg head_sha "$actual_head" \
59+
--arg head_tree "$head_tree" \
60+
--arg base_sha "$merge_base" \
61+
--arg node_version "$(node --version)" \
62+
--arg pnpm_version "$(pnpm --version)" \
63+
--slurpfile result "$summary" \
64+
'{
65+
schema_version: 1,
66+
tested_head_sha: $head_sha,
67+
tested_head_tree: $head_tree,
68+
base_sha: $base_sha,
69+
cat_file_cross_check: {
70+
head_commit: true,
71+
head_tree: true,
72+
base_commit: true
73+
},
74+
runtime: {
75+
node: $node_version,
76+
pnpm: $pnpm_version,
77+
transport: $result[0].transport
78+
},
79+
quota_fixture: {
80+
statuses: [$result[0].results[].http_status],
81+
requests: [$result[0].results[].requests],
82+
publisher_exits: [$result[0].results[].publisher_exit],
83+
completion_kinds: [$result[0].results[].completion_kind],
84+
failure_kinds: [$result[0].results[].failure_kind],
85+
batch_kinds: [$result[0].results[].batch_kind],
86+
cleanup_deletes: [$result[0].results[].cleanup_deletes]
87+
},
88+
full_gate: {
89+
command: "pnpm run check",
90+
exit_code: 0
91+
},
92+
limits: [
93+
"The GitHub API was a deterministic Unix-socket loopback fixture with synthetic credentials.",
94+
"No production GitHub, Worker, queue, deployment, or workflow state was mutated.",
95+
"The receipt commit adds proof metadata only after the tested runtime tree."
96+
]
97+
}' > "$output_dir/container-receipt.json"
98+
99+
jq -e '
100+
.schema_version == 1 and
101+
(.tested_head_sha | test("^[0-9a-f]{40}$")) and
102+
(.tested_head_tree | test("^[0-9a-f]{40}$")) and
103+
(.base_sha | test("^[0-9a-f]{40}$")) and
104+
.cat_file_cross_check == {head_commit:true, head_tree:true, base_commit:true} and
105+
.quota_fixture.statuses == [403, 429] and
106+
.quota_fixture.requests == [1, 1] and
107+
.quota_fixture.publisher_exits == [1, 1] and
108+
.quota_fixture.completion_kinds == ["retryable_failure", "retryable_failure"] and
109+
.quota_fixture.failure_kinds == ["github_rate_limit", "github_rate_limit"] and
110+
.quota_fixture.batch_kinds == ["retryable_failure", "retryable_failure"] and
111+
.quota_fixture.cleanup_deletes == [0, 0] and
112+
.full_gate.exit_code == 0
113+
' "$output_dir/container-receipt.json" >/dev/null
114+
115+
cat "$output_dir/container-receipt.json"
116+
echo "AUTOMERGE_QUOTA_FIXTURE_PROOF_OK head=$actual_head base=$merge_base"

‎src/clawsweeper-command-operations.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ export function createCommandOperations(dependencies: CreateCommandOperationsDep
599599
// returns the interrupted item to the next scheduled window. Failing
600600
// loudly here only discarded the rest of the scan window.
601601
runtimeBudget.onYield(
602-
`GitHub rate limited until ${error.retryAt}; apply resumes next cycle`,
602+
`GitHub rate limited until ${error.retryAt}; credential scope ${error.scope}; reset source ${error.provenance}; apply resumes next cycle`,
603603
);
604604
return;
605605
}

‎src/repair/publish-event-result.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,14 @@ async function publishEventResult(options: EventOptions): Promise<void> {
229229
exactEventPublication: options.exactEventPublication,
230230
legacyTuplelessReviewLease,
231231
});
232+
const rateLimitYield = exactActions.find(
233+
(action) =>
234+
action.action === "skipped_runtime_budget" &&
235+
/GitHub(?: API)? rate limited until/i.test(action.reason),
236+
);
237+
if (rateLimitYield) {
238+
throw new GitHubRateLimitError(new Error(rateLimitYield.reason));
239+
}
232240
if (options.exactEventPublication && legacyTuplelessReviewLease) {
233241
console.log(
234242
`Requeueing ${options.targetRepo}#${options.itemNumber}: legacy exact artifact lacks its durable review lease tuple`,

0 commit comments

Comments
 (0)