feat: add generation-2 request template storage - #1499
Merged
Conversation
Deploying control-layer with
|
| Latest commit: |
2c3d1f1
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://80ff9b23.control-layer.pages.dev |
| Branch Preview URL: | https://peter-template-generation.control-layer.pages.dev |
Contributor
Author
|
Consolidated into #1481 per review direction — the retention PR now carries the full deletion policy across data classes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First PR of the template-generation retention workstream: an expand-only weekly-partitioned generation-2 store for request templates, so template content can eventually be deleted by partition drop and the legacy heap retired as one relation. Stacked on #1481 (retained-response retention), whose journal/bucket/fence machinery the later retirement PRs reuse.
Nothing moves and nothing can be deleted after this PR: no writes are cut over, no lifecycle flags exist yet, and the migration never scans, rewrites, or locks the existing
request_templatesheap.What it adds
request_templates_g2— range-partitioned bycreated_oninto weekly children (request_templates_g2_yIYYYwIW), carrying every legacy column plus the partition key, with the same secondary index shapes. Scheduled deletion for this store will be whole-partition drop, gated on indexed metadata proofs that no file, live batch, or archived batch still references the window.request_template_buckets— one lifecycle row per weekly partition (active → retiring → retired); the read fence for future retirement.request_template_routes— content-freetemplate_id → weekoracle. A route exists only for generation-2 templates; absence means the legacy heap. This is how readers, erasure, and the claim path resolve a template's generation without probing partitions.ensure_request_template_partition(s)— advisory-locked, idempotent weekly partition creation with exact-bounds validation before attach; rejects non-Monday week starts.active_request_templatesis redefined as a UNION across both generations with an identical column shape, so every existing consumer (including the claim path) is generation-transparent before any write moves. The generation-2 arm is empty until cutover and fenced buckets are excluded.Testing
Follow-ups (separate PRs, in order)
Write cutover behind a flag → scheduled input-file retention → batch-archive partition retirement → reference-gated weekly template drops → legacy heap seal-and-drop.
🤖 Generated with Claude Code