Repository navigation
fix(ci): harden pnpm bulk advisory retries - #137989
Conversation
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.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 4, 2026, 2:50 AM ET / 06:50 UTC. ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherThe 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]
Decision needed
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
Agent review detailsSecurityNone. PR surfaceTests +158, Docs 0, Config -7, Other +17. Total +168 across 6 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Maintainer decision: restore fail-closed 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 Exact-head CI run 33845553313 completed successfully on Local validation: The exact-head security-fast log also records two real 60-second timeouts, backoffs of 1297ms and 2671ms, and success on attempt three. |
|
Merged via squash.
|
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.
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 60000msand 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=highencountered 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:workflowswith 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.