Skip to content

Batch page retention in staging workspaces - #100

Merged
flyingrobots merged 2 commits into
mainfrom
fix/batched-page-retention
Jul 26, 2026
Merged

Batch page retention in staging workspaces#100
flyingrobots merged 2 commits into
mainfrom
fix/batched-page-retention

Conversation

@flyingrobots

Copy link
Copy Markdown
Member

Adds workspace.pages.putBatch() so bounded page groups receive ordered, exact retention witnesses from one workspace generation instead of one growing root-set rewrite per page.

The 8,188-page synthetic witness completes in 15.546 seconds with 8.27 MiB of loose scratch objects; the prior per-page path reached only 5,213 pages in 75 minutes and produced about 1.16 GiB.

Validated by all 13 release gates: 6,841 Node/Bun/Deno tests, public type compatibility, examples, lint, build stamp, and npm pack dry-run.

Closes #99.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@flyingrobots, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: de693684-1573-40a1-8b49-06d7ad3c5753

📥 Commits

Reviewing files that changed from the base of the PR and between 6dba2ba and 18d3c9e.

📒 Files selected for processing (1)
  • test/unit/domain/services/StagingWorkspace.test.js
📝 Walkthrough

Walkthrough

Adds workspace.pages.putBatch() with bounded ordered staging, single-generation retention witnesses, failure handling, public TypeScript typing, documentation, design records, and unit/integration coverage for limits, pruning, and release.

Changes

Batched page retention

Layer / File(s) Summary
Batch API contract and design
docs/API.md, docs/design/..., index.d.ts, CHANGELOG.md, README.md
Defines workspace.pages.putBatch() options, ordered retained results, shared generations, deduplication, design scope, verification, and public typing.
Workspace batch staging and retention
src/domain/services/StagingWorkspace.js, src/domain/services/StagingWorkspaceRegistry.js
Adds queued batch staging, handle resolution, single-generation installation, witness mapping, error handling, and dependency validation.
Batch retention and lifecycle validation
test/unit/domain/services/StagingWorkspace.test.js, test/integration/staging-workspace.test.js
Covers ordered retention, generation consistency, limits, installation failures, pruning, and workspace release cleanup.

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

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant StagingWorkspace
  participant PageService
  participant WorkspaceRef
  Client->>StagingWorkspace: pages.putBatch(options)
  StagingWorkspace->>PageService: stage bounded page batch
  PageService-->>StagingWorkspace: ordered pages with handles
  StagingWorkspace->>PageService: resolve page handles
  StagingWorkspace->>WorkspaceRef: install targets in one generation
  WorkspaceRef-->>StagingWorkspace: generation witnesses
  StagingWorkspace-->>Client: retained pages
Loading

Possibly related PRs

Suggested reviewers: git-stunts

Poem

I thumped out a batch in one tidy bound,
With witnesses tucked where roots could be found.
Pages marched in order, generation bright,
Pruning kept them safe through the night.
Then release made the garden clean—
Hop, hop, a well-retained scene!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing the required template sections for Design/Proof, Validation, and Release Impact. Add the required headings and fill in Linked Issue, Design/Proof, Validation, and Release Impact details in the repository template format.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: batched page retention in staging workspaces.
Linked Issues check ✅ Passed The PR implements the batched putBatch workflow, ordered retained witnesses, limits, failures, docs, and tests required by #99.
Out of Scope Changes check ✅ Passed I don't see a clearly unrelated feature change; the docs, tests, and small refactors support the batched retention work.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/unit/domain/services/StagingWorkspace.test.js`:
- Around line 89-93: The staging order assertion must validate results against
independently derived input handles rather than values from the returned staged
array. Update the test around the staged batch assertion to compare each
returned page with the corresponding source page’s handle, ensuring reordered
results such as second-first-second cannot pass.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ed7959af-093b-4809-8aec-44751e96fe36

📥 Commits

Reviewing files that changed from the base of the PR and between d446d97 and 6dba2ba.

📒 Files selected for processing (11)
  • CHANGELOG.md
  • README.md
  • docs/API.md
  • docs/design/0054-batched-page-retention/batched-page-retention.md
  • docs/design/0054-batched-page-retention/witness/verification.md
  • docs/design/README.md
  • index.d.ts
  • src/domain/services/StagingWorkspace.js
  • src/domain/services/StagingWorkspaceRegistry.js
  • test/integration/staging-workspace.test.js
  • test/unit/domain/services/StagingWorkspace.test.js
📜 Review details
🧰 Additional context used
📓 Path-based instructions (3)
docs/design/**

📄 CodeRabbit inference engine (AGENTS.md)

Use docs/design/ directory for durable design contracts and proof plans

Files:

  • docs/design/README.md
  • docs/design/0054-batched-page-retention/witness/verification.md
  • docs/design/0054-batched-page-retention/batched-page-retention.md
CHANGELOG.md

📄 CodeRabbit inference engine (AGENTS.md)

Use CHANGELOG.md to record the historical truth of merged behavior

Files:

  • CHANGELOG.md
README.md

📄 CodeRabbit inference engine (AGENTS.md)

Use README.md as the public front door, core value prop, and quick start documentation

Files:

  • README.md
🧠 Learnings (3)
📚 Learning: 2026-03-30T19:53:48.000Z
Learnt from: flyingrobots
Repo: git-stunts/git-cas PR: 29
File: docs/design/TR-010-planning-index-consistency-review.md:121-131
Timestamp: 2026-03-30T19:53:48.000Z
Learning: In this repo, CHANGELOG.md entries should be user-facing and descriptive (bullet points) rather than cycle-ID headings (e.g., use a phrase like “Planning-index consistency review” instead of a “TR-010 — …” heading). When searching the changelog, don’t rely on grepping for cycle IDs (e.g., “TR-010”) because it may cause false negatives; search for the descriptive keywords/phrases from the bullet entries instead.

Applied to files:

  • CHANGELOG.md
📚 Learning: 2026-07-13T17:00:46.222Z
Learnt from: flyingrobots
Repo: git-stunts/git-cas PR: 65
File: src/domain/helpers/isCanonicalCollectionKey.js:21-35
Timestamp: 2026-07-13T17:00:46.222Z
Learning: In git-stunts/git-cas, the codebase is intended to run on multiple JavaScript runtimes (Node, Bun, and Deno), not just Node. During code review, don’t suggest replacing existing portable helper logic with newer Node-only built-ins (e.g., Node 20+ APIs like `String.prototype.isWellFormed()`) unless the change preserves Bun/Deno compatibility (via portable/polyfill implementations or safe runtime gating). If a file includes manual implementations (such as `src/domain/helpers/isCanonicalCollectionKey.js`), treat them as intentional to avoid requiring a higher host built-in baseline.

Applied to files:

  • src/domain/services/StagingWorkspaceRegistry.js
  • src/domain/services/StagingWorkspace.js
📚 Learning: 2026-02-28T19:21:13.982Z
Learnt from: flyingrobots
Repo: git-stunts/git-cas PR: 15
File: test/unit/domain/services/CasService.envelope.test.js:326-330
Timestamp: 2026-02-28T19:21:13.982Z
Learning: In fuzz tests for cryptographic operations, use a seeded PRNG (e.g., xorshift32) for control-flow variables such as plaintext size selection and recipient index selection to ensure reproducibility. Continue to use randomBytes() for cryptographic keys and nonces to preserve realistic randomness and avoid security anti-patterns. This guideline applies to test files that perform fuzz testing of crypto logic; implement a consistent seed setup (e.g., fixed seed in test initialization) and document the rationale to enable deterministic replays across runs.

Applied to files:

  • test/integration/staging-workspace.test.js
  • test/unit/domain/services/StagingWorkspace.test.js
🔇 Additional comments (11)
docs/design/0054-batched-page-retention/batched-page-retention.md (1)

1-300: LGTM!

docs/design/0054-batched-page-retention/witness/verification.md (1)

1-62: LGTM!

docs/design/README.md (1)

14-14: LGTM!

docs/API.md (1)

1345-1350: LGTM!

Also applies to: 1381-1381, 1391-1395

index.d.ts (1)

1640-1642: LGTM!

CHANGELOG.md (1)

10-16: LGTM!

README.md (1)

151-155: LGTM!

src/domain/services/StagingWorkspace.js (1)

64-64: LGTM!

Also applies to: 209-269, 575-575

src/domain/services/StagingWorkspaceRegistry.js (1)

27-33: LGTM!

Also applies to: 375-378

test/unit/domain/services/StagingWorkspace.test.js (1)

158-196: LGTM!

test/integration/staging-workspace.test.js (1)

70-75: LGTM!

Also applies to: 117-155, 227-229

Comment thread test/unit/domain/services/StagingWorkspace.test.js Outdated
@flyingrobots
flyingrobots merged commit e6c58f1 into main Jul 26, 2026
6 checks passed
@flyingrobots
flyingrobots deleted the fix/batched-page-retention branch July 26, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Batch page retention in staging workspaces

1 participant