feat: noncurrent lifecycle compilation, candidates and attempts - #1371
Conversation
5ba207b to
941d84d
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The new keyset pagination cursor/order appears non-unique (archivedAt+name only), which can cause skipped/duplicated rows across pages in multi-version scenarios.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR introduces foundational pieces for noncurrent object lifecycle execution: compiling enabled noncurrent-expiration rules against a frozen UTC snapshot (including dominated-rule pruning), building a bounded DB page query for candidates, and adding a durable “continuation” journal to resume multi-step delete batches safely.
Changes:
- Add lifecycle schema types/constants for evaluation pages, candidates, cursors, and durable continuation/journaling.
- Implement lifecycle continuation creation/decoding and state transitions for staging batches, arming attempts, recording artifact outcomes, and committing/advancing.
- Add SQL statement builder + decoders for noncurrent lifecycle candidate paging, including BC timestamp binding and microsecond-sensitive cursor handling.
File summaries
| File | Description |
|---|---|
| src/storage/schemas/lifecycle.ts | Adds lifecycle evaluation + continuation/journal schema types and constants. |
| src/storage/lifecycle/index.ts | Exposes the new continuation module via the lifecycle barrel export. |
| src/storage/lifecycle/continuation.ts | Implements durable continuation decoding and batch/attempt transition helpers. |
| src/storage/lifecycle/continuation.test.ts | Adds coverage for continuation decoding constraints and transition invariants. |
| src/storage/lifecycle/configuration.ts | Adds enabled-rule detection and compilation of evaluation rules from frozen snapshot time. |
| src/storage/lifecycle/configuration.test.ts | Adds tests for cutoff computation, dominated-rule pruning, and DST independence. |
| src/storage/database/lifecycle.ts | Adds the noncurrent lifecycle evaluation page SQL builder and row decoders. |
| src/storage/database/lifecycle.test.ts | Adds tests for BC timestamp parameterization, query shape, and decoding behaviors. |
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage Report for CI Build 34399180467Coverage increased (+0.1%) to 82.463%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
|
@claude review always |
There was a problem hiding this comment.
🟡 Changes recommended
The new lifecycle rule compilation currently allows out-of-contract noncurrentDays/newerNoncurrentVersions values, which can silently alter retention semantics or produce rules that later fail at query-build time.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
src/storage/lifecycle/configuration.ts:153
- noncurrentCutoffAt validates noncurrentDays up to Number.MAX_SAFE_INTEGER, but the lifecycle contract elsewhere bounds this field to LIFECYCLE_MAX_NONCURRENT_DAYS (2^31-1). Using MAX_SAFE_INTEGER can silently accept out-of-contract configs and compile them to '-infinity', changing retention semantics. Align the bound with LIFECYCLE_MAX_NONCURRENT_DAYS.
assertIntegerInRange(noncurrentDays, 1, Number.MAX_SAFE_INTEGER, 'NoncurrentDays')
- Files reviewed: 8/8 changed files
- Comments generated: 1
- Review effort level: Lite
941d84d to
93fe733
Compare
93fe733 to
58d6eee
Compare
58d6eee to
ecdbd99
Compare
ecdbd99 to
2d66bfc
Compare
2d66bfc to
f5919cb
Compare
Signed-off-by: Ferhat Elmas <elmas.ferhat@gmail.com>
f5919cb to
b6026c6
Compare
What kind of change does this PR introduce?
feat
What is the new behavior?