Skip to content

feat: write history retention rule before cleanup deletes - #10964

Draft
wjones127 wants to merge 8 commits into
lance-format:mainfrom
wjones127:will/history-retention-impl
Draft

wjones127 wants to merge 8 commits into
lance-format:mainfrom
wjones127:will/history-retention-impl

Conversation

@wjones127

@wjones127 wjones127 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #10924 (format spec); review only the last commit.

Summary

Cleanup reads tags and branches once, then deletes, so a tag, branch, or restore published mid-run can point at a deleted version (#10499). This implements the history retention rule from #10924.

cleanup / expire_versions:  plan -> write _retention/{n+1}.json (merged with current rule)
                            -> re-list tags, branches, pins; keep newly referenced versions
                            -> delete -> drop superseded rule files and stale pins
tag create/update, branch create:  write ref -> read rule -> roll back if expired
restore / restore_from:            write pin -> read rule -> commit (pin stays until stale)
  • Rule files are written with put-if-not-exists and always merged with the current rule, so expiration never goes backwards. A missing or malformed file expires nothing.
  • Cleanup makes no commits; the rule lives beside the manifests.
  • Pins are kept like tags but never trigger the tagged-version error. A restore keeps its pin after committing, since a cleanup that planned earlier cannot see the restored version; pins older than 24 hours are ignored, and runs that delete versions remove them.
  • After writing the rule, cleanup compares branches by name and root, so a new tag, branch, or pin on a branch root that the plan released still keeps that version.
  • _retention is added to the reserved dataset directories, so a branch cannot be named foo/_retention.

Not in this PR:

  • A break-glass API to overwrite the rule (the spec allows one); follow-up.
  • A test where a reference appears between cleanup's rule write and its deletes. That path reuses the bucket-survivor code in process_manifest_file, but nothing exercises it end to end yet.

Evidence

New tests in dataset::history_retention:

  • tag_create_and_update_respect_rule, branch_create_rejects_expired_version: expired targets fail with VersionNotFound and leave no ref behind.
  • restore_respects_rule_and_keeps_its_pin_after_committing: restoring an expired version fails and removes its pin; a successful restore leaves its target pinned.
  • a_new_reference_on_a_released_branch_root_is_unplanned: a new tag or branch on a released branch root counts as new.
  • cleanup_writes_rule_without_committing: cleanup leaves the latest version unchanged and writes {expiredBefore: 4, retained: [2]} for a tagged v2.
  • cleanup_keeps_pinned_versions_until_the_pin_is_stale, writes_merge_with_the_current_rule, malformed_current_file_expires_nothing.

Merge Risk

Door: one-way. Writes new on-disk files (_retention/, _refs/pins/) that later releases must keep reading.
Blast Radius: format, concurrency (cleanup, expire_versions, tags, branches, restore).

Refs #10499

🤖 Generated with Claude Code

wjones127 and others added 4 commits November 10, 2026 23:31
Config keys made every deleting cleanup commit a version. Store the rule
in per-branch _retention/{n}.json files written with put-if-not-exists,
make expiration monotonic, and pin restore targets while restoring.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added A-format On-disk format: protos and format spec docs format-change A change to the format spec, which requires a vote. Remove if minor (e.g. fixing typo). enhancement New feature or request labels Nov 11, 2026
@wjones127
wjones127 force-pushed the will/history-retention-impl branch from c4e31cc to 187efa0 Compare November 11, 2026 22:43
@wjones127
wjones127 force-pushed the will/history-retention-impl branch from 187efa0 to 3ffd09e Compare November 11, 2026 22:57
wjones127 and others added 2 commits November 11, 2026 23:16
Cleanup and expire_versions write a per-branch _retention/{n}.json rule
before deleting, then keep versions that tags, branches, or restore pins
started referencing during the run. Tag and branch creation check the
rule after writing the ref; restore pins its target while it commits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-format On-disk format: protos and format spec docs enhancement New feature or request format-change A change to the format spec, which requires a vote. Remove if minor (e.g. fixing typo).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant