Skip to content

fix(ci): harden pnpm bulk advisory retries - #137989

Merged
steipete merged 1 commit into
mainfrom
codex/pnpm-audit-bulk-retries
Sep 4, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/pnpm-audit-bulk-retries

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Related: #137716 (initial timeout retry), #137825 (bounded transport retries), #137881 (ordinary CI outage policy), #137960 (whole-graph audit and CI budget).

What Problem This Solves

Resolves a problem where dependency audits stop before a flapping npm registry recovers, or immediately reject a rate-limit response without honoring its retry window. The shared audit request also lacked a default total deadline and attempt diagnostics.

Why This Change Was Made

Extend the existing request owner to four attempts with exponential, jittered backoff for timeouts, native fetch failures, 5xx, and 429. Honor Retry-After seconds and HTTP dates on retryable HTTP responses. A four-minute ceiling includes request/body time and waits; a shorter caller budget still wins. If a requested wait cannot fit, stop without retrying early. Preserve response validation, permanent HTTP failure precedence, and error classification when a delayed backoff exhausts the deadline.

No dependency, configuration flag, or helper layer is added. The request owner grows by 17 lines while the CI wrapper shrinks by seven; the growth implements Retry-After, the bounded default deadline, and per-attempt diagnostics in the existing owner. Whole-graph requests and the independently audited release-tool graphs remain intact.

User Impact

Local and release dependency audits can recover through mixed transient failures and still exit non-zero when npm cannot provide a valid result. Logs identify failed attempts, waits, recovery, and exhaustion.

Maintainer decision (recorded on the PR): restore fail-closed security-fast as explicitly requested: use the bounded four-minute retry budget and propagate every non-zero exit, including unavailable coverage (exit 2). This intentionally replaces the warning-only ordinary-CI handling introduced by #137881 and #137960; their whole-graph requests, validation, summaries, and separate scheduled audit remain. The existing --ci flag still provides a shorter diagnostic budget for manual use.

Evidence

Historical security-fast failures contain Bulk advisory request exceeded timeout of 60000ms and exit 1:

Seven newly added regression cases failed against the pre-fix request implementation. The executable CI exit matrix also failed on exit 2 before the workflow change (CI returned 0), then passed when CI propagated the failure. The final focused suite covers mixed 503/timeout sequences, recovery and persistent failure in both audit callers, Retry-After seconds/dates, waits exceeding the budget, stalled body cancellation, and preserving hard errors when scheduling overruns the deadline.

Live proof: node scripts/pre-commit/pnpm-audit-prod.mjs --audit-level=high encountered three consecutive 60-second timeouts, then succeeded on attempt four within the total budget. It reported no matching high-or-higher npm bulk advisories; this is npm-only coverage, not comprehensive vulnerability clearance.

Protocol reference: RFC 9110, Retry-After.

Native CLI fault injection against a local HTTP server also exercised 503 → timeout → 503 → timeout: exactly four requests, empty stdout, and exit 2 with the failure marker.

Validation:

  • pnpm test test/scripts/pnpm-audit-prod.test.ts test/scripts/dependency-vulnerability-gate.test.ts — 110 passing tests.

  • Adding test/scripts/ci-security-fast-workflow.test.ts — 118 passing tests across all three files.

  • pnpm check:workflows with installed Python 3.12 — passed actionlint, zizmor, and repository workflow guards. The first attempt used macOS Python 3.9, which could not install the pinned pre-commit version.

  • Codex autoreview of the final six-file diff — no actionable P0–P2 findings.

  • pnpm check:changed — passed on the final six-file change.

  • Exact-head CI 33845553313 passed on 22074b1a37e5d75b2633337243cda2f3cef264be, including security-fast and both Windows jobs.

The exact-head security-fast log also records two real 60-second timeouts, backoffs of 1297ms and 2671ms, and success on attempt three.

Recover flapping npm audit requests with four attempts, Retry-After, a total deadline, and attempt logs. Restore fail-closed security-fast and prove recovery and persistent failure through both audit callers.
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts labels Sep 4, 2026
@steipete
steipete marked this pull request as ready for review September 4, 2026 06:43
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Sep 4, 2026
@steipete steipete self-assigned this Sep 4, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. 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 Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 2:50 AM ET / 06:50 UTC.

ClawSweeper review

What this changes

The PR adds four-attempt, Retry-After-aware npm advisory retries under a four-minute budget and makes unavailable advisory coverage fail the ordinary CI job.

Merge readiness

⛔ Blocked before merge - 6 items remain

Keep this maintainer-owned PR open for an explicit decision on reversing current ordinary-CI outage policy. The retry implementation is bounded and shared by both audit callers, with no introduced correctness defect found in the reviewed diff.

Priority: P2
Reviewed head: 22074b1a37e5d75b2633337243cda2f3cef264be
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The shared retry implementation and focused boundary coverage are solid, with the remaining blocker being an intentional CI-policy choice rather than a patch defect.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable to the contributor-proof gate because the repository state identifies this as a MEMBER-authored PR; the body nevertheless records a live audit run and real local HTTP fault injection tied to the changed audit entrypoint.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable to the contributor-proof gate because the repository state identifies this as a MEMBER-authored PR; the body nevertheless records a live audit run and real local HTTP fault injection tied to the changed audit entrypoint.
Evidence reviewed 6 items Introduced workflow change: The verified PR-introduced hunk replaces the exit-2 warning conversion with direct audit execution, so unavailable advisory coverage now fails security-fast.
Current-main policy: Current main still invokes the audit with --ci and explicitly converts exit 2 into an incomplete-coverage warning, establishing that this PR intentionally reverses a documented, live policy.
Shared retry owner: The changed owner bounds all request, body-read, and backoff time under one deadline, retries transport failures, 5xx, and 429 responses, and preserves non-retryable failures.
Findings None None.
Security None None.

How this fits together

The security-fast workflow runs the production dependency audit against npm’s advisory endpoint, then passes its exit result to the CI aggregate gate. The shared audit request owner is also used by release dependency checks.

flowchart LR
  A[Dependency graph] --> B[Production audit]
  B --> C[npm advisory endpoint]
  C --> D[Retry and deadline policy]
  D --> E[Audit exit status]
  E --> F[security-fast CI job]
  F --> G[CI aggregate gate]
Loading

Decision needed

Question Recommendation
Should ordinary security-fast CI block a pull request when npm advisory coverage remains unavailable after the bounded four-minute retry budget? Restore fail-closed CI: Accept the bounded outage delay so incomplete advisory coverage prevents the aggregate CI gate from passing.

Why: The branch deliberately reverses current main’s recently documented warning-only policy, and source review cannot determine the intended security-versus-CI-availability tradeoff.

Before merge

  • Resolve merge risk (P0) - Restoring fail-closed exit handling means an npm advisory outage can block otherwise healthy PR CI after the four-minute retry budget, reversing current main’s documented warning-and-continue policy.
  • Resolve merge risk (P1) - Production tooling is net +10 lines; the extra deadline, Retry-After, and diagnostics logic has a concrete owner-boundary purpose, but the CI availability tradeoff still needs an owner decision.
  • Resolve merge risk (P1) - External npm/HTTP contract and claimed live-run evidence could not be independently retrieved from this review environment because DNS resolution failed; this is a reviewer limitation, not missing contributor proof.
  • Complete next step (P1) - Record the CI/security owner decision on restoring fail-closed handling for unavailable npm advisory coverage before merge.
  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Tests +158, Docs 0, Config -7, Other +17. Total +168 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 226 68 +158
Docs 1 4 4 0
Config 1 1 8 -7
Generated 0 0 0 0
Other 1 35 18 +17
Total 6 266 98 +168

Review metrics

Metric Value Why it matters
Production versus test LOC production +10 net; tests +158 net; docs 0 net The production growth implements the shared retry/deadline policy, while most added lines exercise retry, deadline, and workflow-boundary behavior.

Merge-risk options

Maintainer options:

  1. Confirm fail-closed outage handling (recommended)
    Record that ordinary CI should block after bounded retry exhaustion, then let exact-head CI complete normally.
  2. Keep the current warning policy
    Retain current main’s explicit incomplete-coverage warning path if preserving PR throughput during npm outages is the intended policy.

Technical review

Best possible solution:

Keep retry and response handling in the shared audit owner, and land the fail-closed workflow change only after the CI/security owner records that advisory completeness outweighs outage-induced PR blocking.

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

Yes, source-reproducible: current main’s shared owner stops after three attempts and ordinary CI converts unavailable coverage to success, while the introduced owner and workflow modify those exact paths. The reported live behavior was not rerun in this read-only review environment.

Is this the best way to solve the issue?

Unclear: centralizing retry behavior in the shared owner is the right technical boundary for both consumers, but changing ordinary CI from warning-only to fail-closed requires an explicit owner choice.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3b19d3db23e4.

Labels

Label changes:

  • add P2: This is a bounded CI dependency-audit reliability and policy change with maintainer-facing impact.
  • add merge-risk: 🚨 automation: The introduced workflow hunk changes whether an npm advisory outage causes the ordinary CI gate to fail.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable to the contributor-proof gate because the repository state identifies this as a MEMBER-authored PR; the body nevertheless records a live audit run and real local HTTP fault injection tied to the changed audit entrypoint.

Label justifications:

  • P2: This is a bounded CI dependency-audit reliability and policy change with maintainer-facing impact.
  • merge-risk: 🚨 automation: The introduced workflow hunk changes whether an npm advisory outage causes the ordinary CI gate to fail.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable to the contributor-proof gate because the repository state identifies this as a MEMBER-authored PR; the body nevertheless records a live audit run and real local HTTP fault injection tied to the changed audit entrypoint.

Evidence

What I checked:

  • Introduced workflow change: The verified PR-introduced hunk replaces the exit-2 warning conversion with direct audit execution, so unavailable advisory coverage now fails security-fast. (.github/workflows/ci.yml:1925, 22074b1a37e5)
  • Current-main policy: Current main still invokes the audit with --ci and explicitly converts exit 2 into an incomplete-coverage warning, establishing that this PR intentionally reverses a documented, live policy. (.github/workflows/ci.yml:1925, 3b19d3db23e4)
  • Shared retry owner: The changed owner bounds all request, body-read, and backoff time under one deadline, retries transport failures, 5xx, and 429 responses, and preserves non-retryable failures. (scripts/pre-commit/pnpm-audit-prod.mjs:884, 22074b1a37e5)
  • Sibling release caller: The release dependency-vulnerability gate delegates its non-empty advisory payloads to the same fetch owner, so this is not a production-audit-only retry path. (scripts/dependency-vulnerability-gate.mts:82, 22074b1a37e5)
  • Boundary coverage: The changed tests exercise flapping 503/timeout recovery, Retry-After seconds and dates, deadline-exceeding waits, four-attempt exhaustion, both audit callers, and workflow exit propagation. (test/scripts/pnpm-audit-prod.test.ts:327, 22074b1a37e5)
  • External-contract inspection limitation: The diff directly implements npm/HTTP retry behavior, but this review environment could not retrieve missing historical blobs or external source because its promisor remote could not resolve github.com; the PR-body live and RFC claims were therefore not independently rechecked.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Record the maintainer decision on whether incomplete advisory coverage must block ordinary CI.

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.

@steipete

steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Maintainer decision: restore fail-closed security-fast. The requested fix-and-land scope explicitly requires the gate to remain fail-closed and the script to exit non-zero after retry exhaustion. We accept that a persistent npm outage can block otherwise healthy CI after the bounded four-minute budget. This intentionally replaces the recently introduced warning-only caller policy.

This addresses the review's maintainer-decision and rank-up request. The net +10 production/tooling lines (+17 in the request owner, −7 in the CI wrapper) implement the requested Retry-After, deadline, and diagnostics behavior without a new helper layer or configuration option.

The review environment's DNS limitation was covered independently by the lead: RFC 9110's Retry-After contract was read directly; a live production-lock audit recovered on attempt four after three real 60-second timeouts; and a native CLI run against an injected 503 → timeout → 503 → timeout HTTP server made exactly four requests, emitted no success output, and exited 2. The updated executable workflow test proves that exit 2 now fails CI. No correctness or security findings remain in ClawSweeper or the independent P0–P2 autoreview.

Exact-head CI run 33845553313 completed successfully on 22074b1a37e5d75b2633337243cda2f3cef264be, including security-fast and both Windows jobs. No CI bypass is used.

Local validation: pnpm test test/scripts/pnpm-audit-prod.test.ts test/scripts/dependency-vulnerability-gate.test.ts passed 110 tests; adding test/scripts/ci-security-fast-workflow.test.ts passed all 118. pnpm check:changed and pnpm check:workflows (installed Python 3.12) passed. Final Codex autoreview found no actionable P0–P2 findings. The latest-main rebase was patch-identical. No known proof gaps remain for the changed request and CI failure boundaries.

The exact-head security-fast log also records two real 60-second timeouts, backoffs of 1297ms and 2671ms, and success on attempt three.

@steipete
steipete merged commit e63a414 into main Sep 4, 2026
221 checks passed
@steipete
steipete deleted the codex/pnpm-audit-bulk-retries branch September 4, 2026 07:00
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: M 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