Retain bounded live liveness materializations#773
Conversation
|
Warning Review limit reached
Next review available in: 23 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughMaterialization descriptors advance to schema v5 and support partial handles with ChangesSchema v5 partial materialization
Bounded live materialization
Resume and resolution behavior
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related issues
Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant MaterializeLiveStrategy
participant BoundedLiveMaterialization
participant PatchCollector
participant StateSession
participant MaterializationWorkspacePort
MaterializeLiveStrategy->>BoundedLiveMaterialization: resolve bounded live materialization
BoundedLiveMaterialization->>PatchCollector: stream liveness patches
BoundedLiveMaterialization->>StateSession: apply node and edge liveness
BoundedLiveMaterialization->>MaterializationWorkspacePort: promote partial roots
BoundedLiveMaterialization-->>MaterializeLiveStrategy: return live resolution
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
Release Preflight
If this PR is from a |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 `@src/domain/services/controllers/BoundedLiveMaterialization.ts`:
- Around line 79-102: Update buildBoundedMaterialization so any failure after
openStateSession succeeds closes the session before propagating the error,
covering both replayLiveness and retainPreparedLiveness failures. Preserve the
existing patchCount === 0 cleanup and successful retention behavior, while
ensuring cleanup does not mask the original error.
In `@src/infrastructure/adapters/GitCasMaterializationStoreValidation.ts`:
- Around line 12-31: Update requireRetainStateHash to enforce the
complete-retain invariant: when request.stateHash is non-null, require
request.roots.replayBasis.status to be 'retained' before allowing validation to
succeed. Reject this invalid combination before stageWorkspaceBundle, while
preserving the existing partial-materialization checks and non-empty stateHash
validation.
In
`@test/unit/domain/services/controllers/MaterializeController.stateSession.test.ts`:
- Line 656: Update the assertion for resolution.materialization to first verify
that the bounded resolution returned a materialization handle, then assert its
stateHash is null. Avoid relying solely on optional chaining so the test fails
when materialization is absent.
🪄 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: 8fa5c899-0d83-412e-a933-f9c356b80ce2
📒 Files selected for processing (24)
CHANGELOG.mddocs/topics/cas-first-memoized-materialization.mdsrc/domain/materialization/MaterializationHandle.tssrc/domain/services/JoinReducerSession.tssrc/domain/services/controllers/BoundedLiveMaterialization.tssrc/domain/services/controllers/MaterializationRetention.tssrc/domain/services/controllers/MaterializeController.tssrc/domain/services/controllers/MaterializeLiveStrategy.tssrc/domain/services/controllers/MaterializedLiveResolution.tssrc/infrastructure/adapters/GitCasMaterializationDescriptor.tssrc/infrastructure/adapters/GitCasMaterializationReplayBasis.tssrc/infrastructure/adapters/GitCasMaterializationStoreAdapter.tssrc/infrastructure/adapters/GitCasMaterializationStoreValidation.tssrc/infrastructure/adapters/GitCasMaterializationStoreWitness.tssrc/ports/MaterializationWorkspacePort.tstest/unit/domain/materialization/MaterializationIdentity.test.tstest/unit/domain/services/JoinReducer.stateSession.test.tstest/unit/domain/services/controllers/BoundedLiveMaterialization.test.tstest/unit/domain/services/controllers/MaterializeController.liveNodeRead.test.tstest/unit/domain/services/controllers/MaterializeController.stateSession.test.tstest/unit/domain/services/controllers/MaterializedLiveResolution.test.tstest/unit/infrastructure/adapters/GitCasMaterializationStoreAdapter.lifecycle.test.tstest/unit/infrastructure/adapters/GitCasMaterializationStoreAdapter.test.tstest/unit/infrastructure/adapters/GitCasMaterializationStoreValidation.test.ts
💤 Files with no reviewable changes (2)
- src/infrastructure/adapters/GitCasMaterializationStoreWitness.ts
- test/unit/infrastructure/adapters/GitCasMaterializationStoreAdapter.lifecycle.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (3)
- GitHub Check: preflight
- GitHub Check: test-node (22)
- GitHub Check: coverage-threshold
🧰 Additional context used
📓 Path-based instructions (5)
src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.{ts,tsx,js,jsx}: Do not introduceany,as any,as unknown as,unknown(outside adapters),Record<string, unknown>(outside adapters),*Likeplaceholder types,JSON.parse/JSON.stringify(outside adapters),fetch(outside adapters),process.env(outside adapters),@ts-ignore, orz.any()in core code; use validated boundary models and ports instead.
Use constructor-injected ports for external capabilities; do not rely on ambient dependencies for I/O, clocks, persistence, or entropy.
Do not createutils.ts,helpers.ts,misc.ts, orcommon.ts; name files after the actual concept they model.
Prefer one file per class, type, or object; if a file accumulates peer concepts, split it.
Keep helper corridors, fake shape trust, transitional duplication, and compile-time theater out of the codebase; runtime-honest TypeScript must reflect actual behavior.
No enum usage; prefer runtime-backed domain forms and unions.
Do not use boolean trap parameters; prefer named option objects or separate methods.
Avoid magic strings or numbers when a named constant should exist.
Keep domain bytes asUint8Array;Bufferbelongs in infrastructure adapters.
Files:
src/ports/MaterializationWorkspacePort.tssrc/infrastructure/adapters/GitCasMaterializationReplayBasis.tssrc/domain/services/controllers/BoundedLiveMaterialization.tssrc/domain/services/controllers/MaterializeController.tssrc/domain/services/controllers/MaterializedLiveResolution.tssrc/domain/services/JoinReducerSession.tssrc/domain/materialization/MaterializationHandle.tssrc/domain/services/controllers/MaterializeLiveStrategy.tssrc/domain/services/controllers/MaterializationRetention.tssrc/infrastructure/adapters/GitCasMaterializationStoreValidation.tssrc/infrastructure/adapters/GitCasMaterializationStoreAdapter.tssrc/infrastructure/adapters/GitCasMaterializationDescriptor.ts
src/ports/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
In
src/ports/**, do not import Node built-ins orsrc/infrastructure/**; ports must stay abstract and depend only on boundary-safe types.
Files:
src/ports/MaterializationWorkspacePort.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,js,jsx}: Do not use direct imports fromsrc/infrastructure/**insrc/domain/**orsrc/ports/**; depend on a port instead.
Do not use direct Node built-ins insrc/domain/**orsrc/ports/**; use a port instead.
Files:
src/ports/MaterializationWorkspacePort.tssrc/infrastructure/adapters/GitCasMaterializationReplayBasis.tstest/unit/domain/materialization/MaterializationIdentity.test.tstest/unit/domain/services/controllers/MaterializeController.liveNodeRead.test.tstest/unit/infrastructure/adapters/GitCasMaterializationStoreValidation.test.tssrc/domain/services/controllers/BoundedLiveMaterialization.tstest/unit/domain/services/JoinReducer.stateSession.test.tstest/unit/domain/services/controllers/MaterializeController.stateSession.test.tssrc/domain/services/controllers/MaterializeController.tssrc/domain/services/controllers/MaterializedLiveResolution.tssrc/domain/services/JoinReducerSession.tssrc/domain/materialization/MaterializationHandle.tstest/unit/domain/services/controllers/MaterializedLiveResolution.test.tstest/unit/domain/services/controllers/BoundedLiveMaterialization.test.tssrc/domain/services/controllers/MaterializeLiveStrategy.tstest/unit/infrastructure/adapters/GitCasMaterializationStoreAdapter.test.tssrc/domain/services/controllers/MaterializationRetention.tssrc/infrastructure/adapters/GitCasMaterializationStoreValidation.tssrc/infrastructure/adapters/GitCasMaterializationStoreAdapter.tssrc/infrastructure/adapters/GitCasMaterializationDescriptor.ts
src/domain/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
src/domain/**/*.{ts,tsx,js,jsx}: Insrc/domain/**, do not useDate.now(),new Date(),Date(),performance.now(),Math.random(),crypto.randomUUID(),crypto.getRandomValues(),setTimeout,setInterval, rawnew Error(...)/new TypeError(...), or direct imports from Node built-ins; time, entropy, and external capabilities must enter through ports or parameters, and domain errors should extendWarpError.
Construct domain objects only in core when doing so establishes validated runtime truth; do not build infrastructure adapters, host APIs, persistence implementations, wall clocks, or entropy sources inside core.
Prefer discriminated unions and explicit result types instead of boolean-flag bags, and model expected failures as return values rather than exceptions.
src/domain/must not import host APIs or Node-specific globals; hexagonal architecture boundaries are mandatory.
Domain code must not use the wall clock directly; time must enter through a port or parameter.
Files:
src/domain/services/controllers/BoundedLiveMaterialization.tssrc/domain/services/controllers/MaterializeController.tssrc/domain/services/controllers/MaterializedLiveResolution.tssrc/domain/services/JoinReducerSession.tssrc/domain/materialization/MaterializationHandle.tssrc/domain/services/controllers/MaterializeLiveStrategy.tssrc/domain/services/controllers/MaterializationRetention.ts
src/domain/**/!(*.test).{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use explicit domain concepts with validated constructors,
Object.freeze, andinstanceofdispatch; domain objects should be runtime-backed nouns, not ad hoc shape bags.
Files:
src/domain/services/controllers/BoundedLiveMaterialization.tssrc/domain/services/controllers/MaterializeController.tssrc/domain/services/controllers/MaterializedLiveResolution.tssrc/domain/services/JoinReducerSession.tssrc/domain/materialization/MaterializationHandle.tssrc/domain/services/controllers/MaterializeLiveStrategy.tssrc/domain/services/controllers/MaterializationRetention.ts
🧠 Learnings (1)
📚 Learning: 2026-03-08T19:50:17.519Z
Learnt from: flyingrobots
Repo: git-stunts/git-warp PR: 65
File: CHANGELOG.md:88-88
Timestamp: 2026-03-08T19:50:17.519Z
Learning: Follow the Keep a Changelog convention for CHANGELOG.md. Allow duplicate subheadings across versions (e.g., '### Added', '### Fixed'). Configure markdownlint MD024 with {"siblings_only": true} to avoid cross-version false positives.
Applied to files:
CHANGELOG.md
🔇 Additional comments (21)
CHANGELOG.md (1)
69-83: LGTM!docs/topics/cas-first-memoized-materialization.md (1)
101-111: LGTM!Also applies to: 146-162, 227-243
src/ports/MaterializationWorkspacePort.ts (1)
17-17: LGTM!test/unit/infrastructure/adapters/GitCasMaterializationStoreValidation.test.ts (1)
14-59: LGTM!src/domain/services/JoinReducerSession.ts (1)
134-165: LGTM!src/domain/services/controllers/BoundedLiveMaterialization.ts (1)
25-49: LGTM!Also applies to: 104-179
test/unit/domain/services/JoinReducer.stateSession.test.ts (1)
121-150: LGTM!test/unit/domain/services/controllers/BoundedLiveMaterialization.test.ts (1)
38-79: LGTM!test/unit/domain/services/controllers/MaterializeController.liveNodeRead.test.ts (1)
15-15: LGTM!Also applies to: 147-157
src/domain/services/controllers/MaterializeController.ts (1)
278-338: LGTM!src/domain/materialization/MaterializationHandle.ts (1)
13-28: LGTM!Also applies to: 69-71
src/infrastructure/adapters/GitCasMaterializationDescriptor.ts (1)
12-19: LGTM!Also applies to: 54-60, 128-145, 238-240
src/infrastructure/adapters/GitCasMaterializationReplayBasis.ts (1)
74-76: LGTM!src/infrastructure/adapters/GitCasMaterializationStoreAdapter.ts (2)
39-39: LGTM!Also applies to: 232-233
168-176: 🗄️ Data Integrity & IntegrationNo change needed.
retain()already rejectsstateHash: nullwith any preserved replay basis beforereplayBasis.stage()runs, and descriptor decoding enforces the same invariant for stale cache entries.test/unit/domain/materialization/MaterializationIdentity.test.ts (1)
202-214: LGTM!test/unit/infrastructure/adapters/GitCasMaterializationStoreAdapter.test.ts (1)
74-74: LGTM!Also applies to: 380-407, 498-504, 718-718
src/domain/services/controllers/MaterializeLiveStrategy.ts (1)
30-31: LGTM!Also applies to: 123-129
src/domain/services/controllers/MaterializationRetention.ts (1)
30-54: LGTM!src/domain/services/controllers/MaterializedLiveResolution.ts (1)
1-41: LGTM!test/unit/domain/services/controllers/MaterializedLiveResolution.test.ts (1)
15-104: LGTM!
Release Preflight
If this PR is from a |
Release Preflight
If this PR is from a |
Summary
WarpStateor adjacencystateHash: nullso bounded roots cannot masquerade as whole-state snapshotsIssue
Refs #738
Test plan
npm run typechecknpm run lintnpm run test:coverage:ci(609 files, 7,357 tests; 92.95% lines)npm run test:local(six stable shards, 589 files, 7,188 tests)npx vitest run test/integration(21 files, 103 tests)ADR checks