Repository navigation
fix(quota): preserve recovery across concurrent sessions - #176602
Conversation
Keep independent bindings readable during non-evicting sibling writes while retaining key, namespace, and unknown-outcome denial at the publication owner. Reproduce the race with a real pending SQLite worker write.
Compare the failed WHAM observation start with the current persisted success timestamp so delayed exhaustion cannot restore a cleared block. Cover shared, inherited, and personal credential owners.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
Codex review: needs real behavior proof before merge. What this changesThis PR scopes pending binding-write denial and prevents delayed WHAM failures from overwriting newer successful quota recovery. Example: A WHAM check for openai:primary starts at 12:00:00, a request succeeds at 12:00:01, and the older check reports one hour of exhaustion at 12:00:02.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenanceRegression provenance — suspected predecessor, not a causality claim: source commit Possible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 3 items remain Keep this PR: it addresses two current concurrency failures through existing owners, and no definite introduced code defect was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherPlugin-state publication supplies committed binding facts to effect guards, while auth-profile reducers combine provider observations with persisted credential health. flowchart TD
A[Concurrent sessions] --> B[Plugin state worker]
B --> C[Scoped publication owner]
C --> D[Binding effect guards]
A --> E[WHAM observation]
E --> F[Auth usage reducer]
F --> G[Persisted profile health]
Technical reviewBest possible solution: Keep the scoped guard in the existing publication owner and reject stale quota observations in the shared persisted-health reducer. Do we have a high-confidence way to reproduce the issue? Current-main source exposes both failure paths, and the supplied regressions target them through real storage owners; no target code was executed during this read-only review. Is this the best way to solve the issue? The implementation uses existing publication and health owners, preserves namespace-wide eviction and database-wide uncertainty denial, and avoids restoring broad quota fingerprints or introducing a new counter. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against df67a23ada9e. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: No concrete authorization bypass, credential exposure, or supply-chain regression was found. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +80, Tests +122, Docs +5. Total +207 across 11 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 18, 2026, 7:25 PM ET / 23:25 UTC. |
|
Current-head proof is complete for The original Gateway quota-reset file passes all 9 scenarios under Node 24.19 on an exact-head Blacksmith Testbox clone, with verified source hashes and wrapper/remote exit 0. The five targeted ClickClack production-service cases also pass with real SQLite state: unchanged authority reaches the channel update, revoked/replaced authority rejects before it with zero update calls, pending/unknown settlement denies session targets, and stale reverse indexes reject old routes. External channel calls are stubbed; this is production-path in-process proof rather than a live-server claim. The independent sibling-write regression supplies the concurrent scope proof at the same publication owner. Broad PR CI is green, both isolated reviews are clean at P0–P2, and no inherited-failure exception is needed. No concrete code/security finding was reported; the requested effect-boundary evidence is now supplied. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…6602) * fix(plugin-state): scope publication settlement to the read binding Keep independent bindings readable during non-evicting sibling writes while retaining key, namespace, and unknown-outcome denial at the publication owner. Reproduce the race with a real pending SQLite worker write. * fix(quota): keep newer success over stale exhaustion Compare the failed WHAM observation start with the current persisted success timestamp so delayed exhaustion cannot restore a cleared block. Cover shared, inherited, and personal credential owners.
What Problem This Solves
Concurrent Codex sessions could fail quota recovery because a pending write to one session binding denied reads of another binding. Separately, an older exhausted WHAM response could re-block a credential after a newer successful request.
User Impact
Independent session bindings remain readable during non-evicting sibling writes, and a newer successful request keeps its recovered quota state when an older failure probe finally replies. Relevant pending writes and uncertain outcomes still deny effect guards.
Why This Change Was Made
#171458 replaced repeated binding/revocation reads with owner-published facts and correctly denied queued or unknown writes. Its database-wide pending guard also rejected unrelated bindings. The same publication owner now records each known write scope: a non-evicting keyed write denies that key, an eviction-capable write denies its namespace, and unscoped native/compound writes retain database-wide denial. Unknown settlement remains denied for the database identity until restart. Receipt publication, rollback, expiry, and final lifecycle checks stay with their existing owners.
#174632 removed broad WHAM health fingerprints and explicitly accepted late quota observations superseding newer health. The existing Gateway regression demonstrates a real failure in that accepted edge. The failure reducer now compares the probe's start timestamp with the current persisted
lastProbeAt, which successful use advances for shared, inherited, and personal credentials. This preserves ordering without restoring whole-store fingerprints, extra reads, or a new generation counter.lastUsedremains selection-owned and is intentionally unchanged by inherited success.The fixes have separate commits and share the quota-reset concurrency proof. No schema, storage format, retention, dependency, configuration, or service lifecycle changes.
Evidence
On baseline main
5e8ac91fbf6with only the new tests added, the independent-binding regression fails withPlugin state authority is unavailable(1 failed, 1 eviction control passed). All three quota ownership regressions fail because the held exhausted response reinstalls a block over newer successful health.On exact head
bb06a1b1e4124f83879121982f87feb6d05f49a3:OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs test/e2e/qa-lab/runtime/quota-reset.e2e.test.ts --maxWorkers=1— 9 passed, wrapper and remote command exit 0, Node 24.19 on Blacksmith Testbox. A fresh clone's full head and hashes of every changed file plus the target test were verified before execution. This is the external Testbox command result; lease cleanup may cancel the hosting workflow.service-state-persistence.test.ts, using real SQLite owners and stubbed external channel calls. Unchanged published authority reachesupdateChannel; revoked/replaced authority rejects before it and asserts no update call. Pending/unknown settlement denies session targets, and stale reverse indexes reject previous routes. These complement the deterministic sibling-write scope regression; no live ClickClack server is claimed.PR CI run 39175283306 is green on this head. Its changed-test selection does not include the original Gateway file, which is covered by the explicit Node proof above. No inherited-failure exception is needed.