Skip to content

fix(quota): bound snapshot persistence under sustained updates - #7666

Merged
lidge-jun merged 10 commits into
lidge-jun:devfrom
luvs01:fix/quota-persist-starvation
Oct 25, 2026
Merged

lidge-jun merged 10 commits into
lidge-jun:devfrom
luvs01:fix/quota-persist-starvation

Conversation

@luvs01

@luvs01 luvs01 commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Prevent sustained quota observations from indefinitely postponing snapshot writes. Both Codex and provider writers retain the 250 ms idle debounce and add a one-second maximum scheduled delay measured with a monotonic clock. Each write snapshots the latest state; account removal, cancellation, home changes and write failures preserve the correct pending deadline.

Identity checks, quota calculations, snapshot format and atomic replacement are unchanged. The bound applies to scheduling, not event-loop latency or crash durability. Source commit: c938424b8d84e2a27756ff6198d512594ffef37b.

Verification

  • Current head 2f7674987d32e5991a4fe82826d60e1d4258e75c normally merges the dev baseline and shared chore(test): align Bun runner with the 1.4.4 security baseline #7627. Runtime and test runner both use Bun 1.4.4. The dev comparison is nine quota/registration/documentation files plus eleven shared transition files.
  • Official Windows Bun 1.4.4, CI=true bun test --isolate --timeout 60000, fresh processes for codex-quota-persistence.test.ts and provider-account-quota-persistence.test.ts: 18 passed / 0 failed / 46 assertions.
  • Layout and membership-oracle checks add 3 passed / 5 assertions: 21 passed / 0 failed / 0 skipped / 51 assertions in total. Reference TypeScript, official structure and skill checks, and twenty-file privacy/size/diff checks passed. Every recorded unit returned native exit 0 and complete child output.
  • Independent review verified that the registration conflict retains both quota persistence and new dev sync/account-slot entries. Both writer implementations, both regression tests and the quota contract remain byte-identical to the reviewed originals. Matching dependency inputs and installed packages were verified without reinstalling.
  • Earlier real-clock probes showed persisted state advancing during continuous observations while the original implementation deferred writes until a quiet period. Earlier Bun 1.4.3 CI is retained only as historical evidence, not as validation of this 1.4.4 head.
  • PR CI on this exact head completed SUCCESS: 17 successful jobs and 6 conditional skips, including the aggregate ci check. The skipped jobs do not establish native Windows/macOS matrix execution.
  • Focused local checks used the shared-host resource exception to avoid repeating unrelated suites. Live-provider behavior and the complete native-platform matrix remain unverified. No live installation, account or setting changed.
  • This is ready for review, not merge approval. Remaining enforce-target and metadata checks, maintainer review and any required security acceptance are tracked separately before merge. If the still-unmerged chore(test): align Bun runner with the 1.4.4 security baseline #7627 runner transition is introduced ahead of its parent, its exact-candidate full cross-platform promotion proof remains required; the PR CI result above does not supply that proof.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Co-authored-by: luvs01 27862058+luvs01@users.noreply.github.com

Summary by CodeRabbit

  • Bug Fixes

    • Quota snapshots now persist after a 250 ms idle period, with repeated updates limited to a one-second maximum delay. Clearing quotas cancels pending writes, and disk-write failures remain non-blocking.
    • Buffered uploads now handle early server responses before the request body has finished sending.
  • Chores

    • Updated the test-runner Bun version to 1.4.4, matching the shipped runtime.
  • Tests

    • Added coverage for quota persistence timing and cancellation, Bun runner selection, and early upload responses.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 2f76749 and b8cf17b.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 0aeaf0c and 2f76749.

Files selected for processing: 20
  • .github/actions/setup-project-bun/action.yml
  • .github/workflows/ci.yml
  • CONTRIBUTING.md
  • Dockerfile
  • docs-site/src/content/docs/contributing.md
  • package.json
  • scripts/test-layout/layout-codex-collision.json
  • src/codex/quota.ts
  • src/providers/account-quota-disk.ts
  • structure/INDEX.md
  • structure/manifest.json
  • structure/quota-snapshots.md
  • structure/runtime.md
  • tests/ci-workflows/ci-scope-gaps.test.ts
  • tests/ci-workflows/install-scripts.test.ts
  • tests/claude-integration/claude-picker-upload.test.ts
  • tests/codex-integration/codex-quota-persistence.test.ts
  • tests/fixtures/test-layout-expected.json
  • tests/providers/provider-account-quota-persistence.test.ts
  • tests/test-layout-tooling.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Walkthrough

Quota snapshot writes now retain a 250 ms idle debounce and cap repeated postponement at one second. The test-runner Bun pin changes from 1.4.3 to 1.4.4. Tests also cover runner selection and early responses to buffered uploads.

Changes: Quota snapshot persistence

Layer / File(s) Summary
Bounded write deferral
src/codex/quota.ts, src/providers/account-quota-disk.ts
Both persistence paths track when a pending write begins. Repeated updates defer the write for no more than one second, while retaining the 250 ms debounce. Clearing all Codex quotas and cancelling provider persistence reset the pending interval.
Persistence tests and documentation
tests/codex-integration/codex-quota-persistence.test.ts, tests/providers/provider-account-quota-persistence.test.ts, scripts/test-layout/layout-codex-collision.json, tests/fixtures/test-layout-expected.json, structure/quota-snapshots.md, structure/INDEX.md, structure/manifest.json
Tests cover debounce deadlines, sustained updates, clearing or cancelling pending writes, home changes, and failed writes. The structure documents describe the persistence behavior and its tests; the layout files register the Codex persistence test.

Bun test-runner version

Layer / File(s) Summary
Runner pin and role validation
package.json, tests/test-layout-tooling.test.ts, tests/ci-workflows/install-scripts.test.ts, tests/ci-workflows/ci-scope-gaps.test.ts, .github/actions/setup-project-bun/action.yml, .github/workflows/ci.yml, CONTRIBUTING.md, Dockerfile, docs-site/src/content/docs/contributing.md, structure/runtime.md
The testRunnerBun pin changes to 1.4.4. Tests cover matching and differing caller versions and a mismatched override. Comments and documentation describe independent runtime and test-runner validation and require a successful full cross-platform lane=all run on the exact candidate head for promotion.

Buffered upload early-response test

Layer / File(s) Summary
Early-response fixture and assertion
tests/claude-integration/claude-picker-upload.test.ts
The fixture adds a half-open TLS server mode that records whether an early reply was flushed before the request body completed. The buffered-upload test uses this mode and checks that condition.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • lidge-jun/opencodex#7587 — This change bounds quota snapshot write deferral and preserves the latest snapshot. It does not implement the issue’s alternate-route or desktop transport design.

Possibly related PRs

Merge Risk: Minimal · up to 2f767

No concrete issue identified here blocks merging; the documented cross-platform promotion check remains a separate readiness step.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 8 files. (12 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(quota): bound snapshot persistence under sustained updates" matches the main change. The PR adds a one-second maximum deferral to the 250 ms debounce for Codex and provider quota snapsh…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(quota): bound snapshot persistence under sustained updates" matches the main change. The PR adds a one-second maximum deferral to the 250 ms debounce for Codex and provider quota snapshot writes (src/codex/quota.ts and src/providers/account-quota-disk.ts), so sustained updates no longer postpone writes indefinitely. The rest of the changeset (Bun 1.4.3 to 1.4.4 pin updates, CI and docs comments, layout map entries) is supporting or unrelated housekeeping that the title does not need to cover.

Full details: Docstring Coverage

Explanation

Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 8 files. (12 skipped: 12 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Oct 24, 2026
@luvs01
luvs01 marked this pull request as ready for review October 24, 2026 19:28
…rsist-starvation

# Conflicts:
#	tests/claude-integration/claude-picker-upload.test.ts
@lidge-jun

Copy link
Copy Markdown
Owner

Integration evidence (owner decision decision:b607a677, approved): after #7627 landed the maintainer merged origin/dev into this branch, leaving only this PR's own change (quota snapshot persistence (src/codex/quota.ts, src/providers/account-quota-disk.ts)); independent gpt-6.1-sol review PASS at exact head b8cf17b. Exact-head PR CI run 40156518426 and exact-head ci.yml lane=all run 40156837380 (maintainer mirror branch at this SHA) both succeeded.

Static merge simulation on current dev 323a5e1 (this Mac): dev=323a5e11772c38c15b271d23c7696c5947bb97da base=323a5e11772c38c15b271d23c7696c5947bb97da pr_files= 9 overlap=[]; merge clean; install exit=0; gui install exit=0; tsc exit=0; tsc doctor exit=0; structure:check exit=0; privacy:scan exit=0; layout+ratchet guards exit=0 54 pass 0 fail ;

Merged by the triage manager as maintainer integration (MAINTAINERS.md, dev only) with green exact-head PR CI, an independent review PASS, and the owner's approval of this bundle.

@lidge-jun
lidge-jun merged commit ac65aa7 into lidge-jun:dev Oct 25, 2026
62 of 63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants