Skip to content

fix: collapse exact publication on GitHub quota - #1102

Merged
brokemac79 merged 1 commit into
mainfrom
codex/csw-117-github-quota-circuit
Aug 10, 2026
Merged

brokemac79 merged 1 commit into
mainfrom
codex/csw-117-github-quota-circuit

Conversation

@brokemac79

Copy link
Copy Markdown
Contributor

Summary

Contain exact-review publication when GitHub throttles a shared credential pool, instead of rotating queued items through the same exhausted quota. This combines the six CSW-117 remediation items in one stack: reset-aware errors, durable scoped circuits, first-failure batch collapse, bounded public-read fallback, adaptive feedback/operator telemetry, and successful-path request accounting.

Related: #1097 remains separate and unchanged.

Problem

The 2026-08-10 production observation showed a publication backlog while publisher capacity was idle. In the retained sample, 31 throttled batches made 187 member attempts for only 63 unique revisions; 124 attempts (66%) repeated a revision already attempted in a throttled batch. Eight consecutive full batches expired all 64 members. This is shared GitHub quota amplification, not a shortage of publication workers.

The previous path could lose the authoritative reset boundary, retry after a short fallback, and rotate other ready items through the same credential. Artifact preparation also began before the first batch throttle could stop later members, and batch throttle outcomes were not feeding current publication control.

Implementation

  1. Reset-aware quota signals

    • Carries redacted credential scope, retry/reset provenance, and whether the deadline is authoritative.
    • Gives retry-after precedence, preserves x-ratelimit-reset, and applies a stable conservative future deadline when headers are absent or stale.
  2. Durable credential-scoped circuits

    • Persists repository Actions and owner/App circuits without storing token-derived identifiers.
    • Never shortens an existing circuit, excludes blocked owners before bounded admission, preserves healthy owners, schedules recovery, and adds bounded recovery jitter.
  3. First-failure batch collapse

    • Stops later preparation work after the first same-pool artifact or GitHub quota outcome.
    • Releases unattempted members without consuming their retry budget and records byte-offset telemetry so late terminal observations are not lost.
  4. Bounded public-read fallback

    • Keeps approved public reads on the repository credential when healthy and permits one batch-wide target-App fallback when it is not.
    • Retains the repository-pool throttle observation even if that one fallback succeeds; private reads and mutations never cross credentials.
  5. Adaptive feedback and operator telemetry

    • Feeds idempotent throttle receipts into publication control and distinguishes credential blocking from worker-capacity pressure.
    • Projects observer-only circuit/request telemetry through /api/status and Bay; no operational controls are added.
  6. Measured request demand and safe early reductions

    • Records redacted request category/outcome counters with stable producer/byte-range identities and durable seven-day receipts.
    • Checks durable circuits before admission/setup work and prevents same-window duplicate feedback without weakening live mutation guards.

Receipt insertion, dispatcher state, and counters are committed atomically. Fault-injection coverage proves failed state or receipt writes do not leave partial acknowledgement.

Validation

Current base: 75ac66b2b3b7dbf9def8007c52f5f05fac616c3d
Current head: 8d387089c30fbc84bd628f6b56ff629dbb875879

  • pnpm run build:all
  • pnpm run lint
  • pnpm run check:docs
  • pnpm run check:limits
  • git diff --check
  • node --test test/exact-review-publication-batches.test.ts — 63/63 passed
  • Focused CLI, workflow, GitHub retry, and Bay tests passed on the host.
  • Docker-backed Linux proof below — 123/123 passed.

actionlint parsed the changed workflow. It reports five existing/intentional SC2016 informational notices for literal GitHub expressions in single-quoted shell text. A repository-wide run also reports unrelated current-main errors in repair-comment-router.yml and unsupported queue keys in sweep.yml; this patch does not alter those surfaces. The changed Bash path passed its Linux workflow tests.

On native Windows, the workflow test that invokes /bin/bash cannot execute because that path is not a Windows surface. The same path passed in the required Linux container proof.

Real Behavior Proof

Claim: An exhausted GitHub credential pool opens one durable reset-aware circuit, collapses later same-pool work, preserves healthy owners/pools, and resumes after reset with bounded jitter without weakening exact-review fencing, freshness, idempotency, or mutation authorization.

Exercised surface: rate-limit parsing and propagation; exact-review preparation/outcomes; durable queue persistence, admission, alarm, recovery, and status; public-read routing; adaptive control; Bay/status telemetry; receipt atomicity and retention.

Scenario/fixture: deterministic primary/secondary/missing-header throttles; repository exhausted/App healthy; App exhausted/repository healthy; both exhausted; 8-member first-failure collapse; concurrency-in-flight bound; Durable Object restart; 52 blocked owners ahead of a healthy owner; reset recovery; duplicate and late telemetry; receipt/state write fault injection; private/mutating route rejection.

Command/environment: Docker-backed Crabbox local-container, image node:24-bookworm, read-only source bind copied to disposable /tmp/proof, frozen install, build, and focused Node/workflow suites.

Observed result: 123 tests passed with zero failures. No later member was admitted after a shared failure beyond already-in-flight work; unattempted releases did not spend retry budget; the healthy owner beyond the scan limit was admitted; persisted circuits survived restart and recovered after the deadline; duplicate feedback remained idempotent; injected transactional failures left no partial receipt/acknowledgement.

Artifact/trace: provider local-container; lease cbx_8aa5ded88ca0; run slug golden-shrimp; exact head 8d387089c30fbc84bd628f6b56ff629dbb875879; total 32.822s (command 32.714s). The lease auto-stopped normally.

Limits: The proof uses local GitHub-boundary fixtures and does not exhaust a real credential or mutate production. Organic behavior still needs read-only observation across subsequent quota windows. Containing amplification does not prove that all legitimate successful-path demand fits every GitHub pool.

Review closeout

  • Final dirty-patch Codex review: clean; specifically verified pre-admission blocked-owner exclusion and healthy-owner recovery coverage.
  • Final committed-base Codex review: clean; verified scoped propagation, no retry-budget charge for circuit deferral, and telemetry idempotency.
  • Local ClawSweeper committed-range review: complete, Overall correctness: patch is correct, no findings. Artifact: C:\clawsweeper-work\repos\clawsweeper\.git\worktrees\csw-117-github-quota-circuit\clawsweeper\reviews\local-range-1786377440411-17960\0.md.
  • Accepted findings from earlier review passes were fixed and proof/reviews rerun, including late telemetry forwarding, inherited GITHUB_TOKEN, full secondary-limit patterns, repeat revision propagation, stable fallback deadlines, cross-lease identity, bounded receipt retention, fallback observation semantics, transactional receipt/state updates, and blocked-owner scan saturation.

Risks and rollout

  • A misclassified credential scope could defer too much or too little work. Scope tests cover repository-vs-owner isolation and status exposes only redacted classes.
  • Recovery jitter deliberately adds up to 30 seconds after reset to prevent a herd.
  • The workflow change carries the normal GitHub OAuth/workflow-scope review risk.
  • Post-merge verification should observe at least two complete quota windows: no same-pool dispatch before reset, no repeated revision amplification, healthy-owner progress, positive backlog drain, and no dead-letter increase.
  • Ordinary revert is available; no queue rewrite, replay, clear, or manual circuit reset is required.

Documentation

Updated limits, scheduler, and live-dashboard guidance alongside the status/Bay contract. The mandatory documentation/config drift checks pass. CHANGELOG.md is intentionally untouched because release notes are release-owned.

Non-goals

  • Raising publication concurrency or GitHub quota.
  • Adding credentials or installations to evade limits.
  • Removing live freshness/mutation guards.
  • Live queue/DLQ replay, acknowledgement, workflow dispatch/rerun, gate changes, deployment, or production mutation.
  • Changing fix(publication): restore production publisher capacity #1097 or restoring fixed 50/50/50 capacity in this PR.

@clawsweeper

clawsweeper Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@brokemac79

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P1 Urgent regression or broken agent/channel workflow affecting real users now. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 10, 2026
@clawsweeper

clawsweeper Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 10, 2026, 12:16 PM ET / 16:16 UTC.

ClawSweeper review

What this changes

The PR adds reset-aware credential circuits, first-failure batch collapse, and observer-only quota telemetry to exact-review publication.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for normal maintainer review. The PR provides a focused, source-backed quota-containment design with controlled real-behavior proof; no actionable patch defect was found.

Priority: P1
Reviewed head: 8d387089c30fbc84bd628f6b56ff629dbb875879

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong controlled proof and focused coverage support a broad but coherent publication-reliability patch.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body documents exact-head Docker-backed fault-injection proof showing quota collapse, durable recovery, scope isolation, and 123 passing checks.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body documents exact-head Docker-backed fault-injection proof showing quota collapse, durable recovery, scope isolation, and 123 passing checks.
Evidence reviewed 6 items Credential circuit and scope boundary: The PR stores separate repository-Actions and target-App circuit keys, retaining the latest reset deadline per credential pool.
Admission and recovery behavior: Batch departure excludes currently circuit-blocked work, while scheduling includes the earliest circuit deadline for recovery.
Workflow containment: The batch workflow uses one preparation worker and records rate-limit observations and request metrics before durable completion or release.
Findings None None.
Security None None.

How this fits together

Exact-review publication downloads review artifacts and posts outcomes through GitHub while a durable queue controls admission, retries, and recovery. This PR connects GitHub quota signals to that queue and exposes redacted operational status in Bay.

flowchart LR
A[Publication batch] --> B[GitHub requests]
B --> C[Quota signal]
C --> D[Credential circuit]
D --> E[Queue admission and reset recovery]
E --> F[Status API]
F --> G[Bay health context]
Loading

Before merge

  • Resolve merge risk (P1) - A credential-scope or reset-deadline classification error could temporarily defer healthy publication work; the stated post-merge observation across two quota windows remains important.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Code and coverage delta production +1,350/-46; tests +918/-8; docs +77/-13 The broad queue and workflow reliability change is accompanied by substantial focused regression coverage and operational documentation.

Merge-risk options

Maintainer options:

  1. Land with quota-window monitoring (recommended)
    Accept the controlled-proof residual risk and verify reset recovery, healthy-owner progress, backlog drain, and dead-letter stability across two production quota windows.

Technical review

Best possible solution:

Retain the scoped circuit design, land it after normal maintainer approval, and observe two quota windows for healthy-owner progress, backlog drain, and dead-letter stability.

Do we have a high-confidence way to reproduce the issue?

Yes: the PR supplies deterministic quota-fixture scenarios for repository and target-App exhaustion, collapse, persistence, and reset recovery, with current-head source paths matching the claimed behavior.

Is this the best way to solve the issue?

Yes: credential-scoped durable admission and reset recovery directly prevent repeat attempts without conflating quota pressure with worker-capacity pressure.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 75ac66b2b3b7.

Labels

Label changes:

  • add P1: The patch addresses observed GitHub-quota amplification that stalled exact-review publication progress.
  • add merge-risk: 🚨 availability: Incorrect circuit scope or recovery timing could defer publication until the next reset window.
  • add merge-risk: 🚨 automation: The patch changes the exact-review batch workflow, durable queue completion path, and automation telemetry.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body documents exact-head Docker-backed fault-injection proof showing quota collapse, durable recovery, scope isolation, and 123 passing checks.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body documents exact-head Docker-backed fault-injection proof showing quota collapse, durable recovery, scope isolation, and 123 passing checks.

Label justifications:

  • P1: The patch addresses observed GitHub-quota amplification that stalled exact-review publication progress.
  • merge-risk: 🚨 availability: Incorrect circuit scope or recovery timing could defer publication until the next reset window.
  • merge-risk: 🚨 automation: The patch changes the exact-review batch workflow, durable queue completion path, and automation telemetry.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body documents exact-head Docker-backed fault-injection proof showing quota collapse, durable recovery, scope isolation, and 123 passing checks.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body documents exact-head Docker-backed fault-injection proof showing quota collapse, durable recovery, scope isolation, and 123 passing checks.

Evidence

What I checked:

Likely related people:

  • Martin Cleary: Recent current-main publication containment and GitHub quota-headroom commits touch the queue surface extended here. (role: recent area contributor; confidence: high; commits: 50f90eac14f7, 13f8ffdea32a; files: dashboard/exact-review-queue.ts)
  • Peter Steinberger: Recent queue observability and publication-flow commits establish adjacent ownership of the durable publication path. (role: recent adjacent contributor; confidence: medium; commits: e699e83d2707, 621b297eadd5; files: dashboard/exact-review-queue.ts, .github/workflows/exact-review-batch-publish.yml)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Observe two production quota windows after merge, as described in the PR body.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@brokemac79
brokemac79 marked this pull request as ready for review August 10, 2026 16:21
@brokemac79
brokemac79 requested a review from a team as a code owner August 10, 2026 16:21
@brokemac79
brokemac79 merged commit cd48923 into main Aug 10, 2026
24 checks passed
@brokemac79
brokemac79 deleted the codex/csw-117-github-quota-circuit branch August 10, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P1 Urgent regression or broken agent/channel workflow affecting real users now. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant