From aea23fb49847941c4e65f14668d0cbc8e64b5728 Mon Sep 17 00:00:00 2001 From: Alexander Erofeev Date: Tue, 10 Nov 2026 13:05:46 +0700 Subject: [PATCH 1/6] docs(format): specify atomic snapshot retention metadata --- .github/labeler-area.yml | 4 + docs/src/format/table/branch_tag.md | 5 + docs/src/format/table/layout.md | 6 + docs/src/format/table/snapshot_retention.md | 241 ++++++ .../table/snapshot_retention.schema.json | 789 ++++++++++++++++++ protos/codegen/src/main.rs | 11 +- protos/snapshot.proto | 32 + protos/snapshot_retention.proto | 17 + rust/lance-table/src/pb/lance.snapshot.rs | 45 + rust/lance/src/pb/lance.dataset.retention.rs | 27 + 10 files changed, 1175 insertions(+), 2 deletions(-) create mode 100644 docs/src/format/table/snapshot_retention.md create mode 100644 docs/src/format/table/snapshot_retention.schema.json create mode 100644 protos/snapshot.proto create mode 100644 protos/snapshot_retention.proto create mode 100644 rust/lance-table/src/pb/lance.snapshot.rs create mode 100644 rust/lance/src/pb/lance.dataset.retention.rs diff --git a/.github/labeler-area.yml b/.github/labeler-area.yml index 135ff50be6d..723a6a395c6 100644 --- a/.github/labeler-area.yml +++ b/.github/labeler-area.yml @@ -37,6 +37,8 @@ A-encoding: A-format: - changed-files: - any-glob-to-any-file: + - "protos/snapshot.proto" + - "protos/snapshot_retention.proto" - "protos/clustering.proto" - "protos/encodings_v2_0.proto" - "protos/encodings_v2_1.proto" @@ -58,6 +60,8 @@ A-format: format-change: - changed-files: - any-glob-to-any-file: + - "protos/snapshot.proto" + - "protos/snapshot_retention.proto" - "protos/clustering.proto" - "protos/encodings_v2_0.proto" - "protos/encodings_v2_1.proto" diff --git a/docs/src/format/table/branch_tag.md b/docs/src/format/table/branch_tag.md index b34149bb3f9..bec6954b4a9 100644 --- a/docs/src/format/table/branch_tag.md +++ b/docs/src/format/table/branch_tag.md @@ -5,6 +5,11 @@ Lance supports branching and tagging for managing multiple independent version histories and creating named references to specific versions. Branches enable parallel development workflows, while tags provide stable named references for important versions. +For tables with [atomic snapshot retention](snapshot_retention.md) activated, +`_refs/retention/state.json` is authoritative for new and changed references. +Its maps overlay the historical files below; tombstones suppress deleted +references. Retention tokens and operation journals are persisted metadata. + ## Branching ### Branch Name diff --git a/docs/src/format/table/layout.md b/docs/src/format/table/layout.md index 58e9f97f473..54570a23e9b 100644 --- a/docs/src/format/table/layout.md +++ b/docs/src/format/table/layout.md @@ -53,6 +53,12 @@ A Lance dataset in its basic form stores all files within the dataset root direc ``` +Activated [atomic snapshot retention](snapshot_retention.md) adds +`_refs/retention/`, containing the authoritative root, permanent per-manifest +retirement records, publication intents, reference journals, exact deletion +plans, and permanent retired-name shards. The root overlays historical tag and +branch metadata. Ordinary inactive tables retain the layout above. + ## Base Path System ### BasePath Message diff --git a/docs/src/format/table/snapshot_retention.md b/docs/src/format/table/snapshot_retention.md new file mode 100644 index 00000000000..e695f050c9d --- /dev/null +++ b/docs/src/format/table/snapshot_retention.md @@ -0,0 +1,241 @@ +# Atomic snapshot retention + +Version 1 is an **unstable**, opt-in table metadata format. It does not change +ordinary table layouts before activation. Its JSON schemas are defined in +[snapshot_retention.schema.json](snapshot_retention.schema.json). Apply the named +`$defs` schema below to each object. Unknown protocol versions, malformed records, +unknown fields, and invalid identities must fail closed. + +## Activation and authority + +Activation requires draining all queries, writers, reference mutations, cleanup, +version expiry, and submitted storage requests. Every later mutating client must +implement this protocol. Activation is permanent. Query acquisition must fail on +an inactive table; it must never activate a table implicitly. Existing handles +and historical manifests cannot enforce this deployment boundary themselves. + +Storage must provide consistent reads and listing, atomic conditional creation, +and conditional replacement against the generation returned by the same GET as +the observed bytes. Activation probes replacement and rejection of a stale +precondition. A backend that ignores conditions is unsupported. A failed probe +may leave `mode: preparing`; this is not activation. The transition to `active` +records the current main head and a fresh nonzero `table_id` UUID. + +`_refs/retention/state.json` is the authoritative `root` object. Each successful +replacement increments `revision` and chooses a fresh nonzero `mutation_id` UUID, +including semantically empty recovery fences. Revisions must not overflow. +This prevents a value from returning to the same bytes after intervening changes. +The record is never deleted or reset. Local implementations serialize replacement +through the persistent sibling `state.json.cas-lock` inode; lock files must never +be deleted while clients can use them. + +A `head` names an exact committed manifest and its optional storage ETag and +commit-store identity. `scheme` is `V1` or `V2`, as defined by manifest naming. +The ETag is an optimization and must not replace content identity. `head: null` +means no committed head has been recorded. Detached versions do not advance it. + +## Addresses and record layout + +Publication, plan, head, retired-name, and chunk paths are normalized +slash-separated addresses relative to the authenticated table root. The empty +address identifies the root. In a per-manifest snapshot record, +`identity.manifest_path` is the canonical physical object-store path including +the root prefix; `manifest_key` is its root-relative address. Plan retirement +identities instead use the root-relative address. Transported SnapshotRef paths +remain resolved paths in their authenticated source store. +Absolute paths, escaping components, and objects outside the root are rejected. +Local aliases must resolve to the same canonical physical root and file addresses, +including when a file was already deleted and only its parents survive. Catalog +names and access-context identifiers must not create independent authorities for +one physical manifest. + +```text +_refs/ + retention/ + state.json root + snapshots/{manifest_hash}.json snapshot + publications/{uuid}/ + manifest private manifest copy + intent.json publication + references-{number}.json array of path strings + plans/{uuid}/ + plan.json plan + files-{number}.json array of plannedFile objects + retired/{shard}.json retired + tag-operations/{uuid}.json operation + branch-operations/{uuid}.json operation + tags/lance-query-{digest}.json diagnostic query projection +``` + +Immutable documents are conditionally created before their root pointer is +published. Replaying the same address is allowed only with identical bytes. +Reference and planned-file chunks contain at most 1,024 entries. Headers and +chunks must belong to the same operation directory. Root IDs must match the +referenced header IDs. Readers validate addresses before following them. + +`manifest_hash` is the lowercase 64-digit BLAKE3 hex digest of the normalized +physical manifest address's UTF-8 bytes. `manifest_key` repeats that address and +must match the addressed object. `shard` is the first four lowercase hex digits +of BLAKE3 of a retired physical path's UTF-8 bytes. Retired-name shards store a +set of exact path strings, not path prefixes. Their revision and mutation ID +follow the root replacement rules; shard tombstones never expire. + +## Persisted snapshot and release tokens + +`protos/snapshot.proto` defines `lance.snapshot.SnapshotRef`, protocol version 1. +`protos/snapshot_retention.proto` defines `lance.dataset.retention.SnapshotRetention`, +protocol version 1. The latter embeds the encoded former in `snapshot`. +These schemas are persisted contracts wherever tokens appear below; they are +also used for execution transport. Neither message contains credentials, +manifest contents, or an authorization capability. + +The manifest digest is 32 BLAKE3 bytes over the complete original manifest file, +including metadata sections, dictionaries, inline transactions, length prefixes, +and footer. Protobuf re-encoding must not substitute for the original file bytes. +The optional manifest identity is the authoritative commit-store identity; +absence means that only the digest supplies content identity. Branch absence +identifies main. A snapshot must name an exact positive version and manifest. + +The snapshot ID is BLAKE3 of the protobuf encoding of its validated known fields, +serialized in field-number order with absent/default proto3 fields omitted. The +retention name is `lance-query-` followed by lowercase hex BLAKE3 of the 32 snapshot +ID bytes followed immediately by the nonempty retention ID's UTF-8 bytes. There +is no separator. Retention IDs identify distinct query lifetimes and must not be +reused after release. + +`protection`, `source_protection`, `old_protection`, and `new_protection` contain +lowercase hexadecimal protobuf release-token bytes. `null` means no protection. +Decode both protocol versions before recovery uses a token. Token validation +alone does not acquire, renew, release, or authorize protection. + +## Tags and branches + +For activated tables the root's `tags` and `branches` maps overlay the historical +files described in [Branch and Tag Specification](branch_tag.md). An absent map +entry falls back to historical metadata. A `null` tag entry is a deletion +tombstone and suppresses that fallback. New activated references need no +`_refs/tags/{name}.json` or `_refs/branches/{name}.json` file. + +Tag `contents` retains the historical tag fields. Branch `contents` retains the +historical branch fields and its `identifier.version_mapping`: an ordered array +of `[parent_version, incarnation_id]` pairs. Each incarnation ID is a 32-digit +UUID hex string. Main has the table UUID as its publication incarnation. A named +branch's publication incarnation is the table UUID, `/`, and compact JSON of its +identifier, preserving the pair order and decimal version encoding. + +A tag mutation writes an `operation` journal before acquiring its new source pin. +It commits against `expected_revision` and includes the new token in the root. +Only after that decision may it release the old token. Tag deletion publishes a +null entry before releasing old protection. `tag` names the affected reference; +branch journals use this field for the branch name too. Missing new or old tokens +mean that side of the mutation does not own protection. + +A branch transitions `creating` → `active` → `retiring` → `deleted`. Creation +holds `source_protection` until its first manifest publication is finalized. Its +`first_version` exceeds the previous incarnation's `max_version`, including +uncertain submitted publications. The watermark must not decrease or overflow. +Retirement fences new publications and pins before scanning surviving references. +A non-null retirement `plan_id` identifies its committed immutable deletion plan. +Recreation changes the identifier; old manifests and old writers must not be +accepted into the new incarnation. Branch paths remain under `tree/{name}/`. + +Query projections use the historical tag schema with metadata keys +`lance.snapshot_retention.snapshot_id` (snapshot ID hex), +`lance.snapshot_retention.manifest_path` (physical address), and +`lance.snapshot_retention.token` (release-token hex). They are diagnostic only. +Missing or stale projections never remove pins. General tag mutation must reject +query projections; only release may remove them. + +## Pins and irreversible retirement + +A `snapshot` object contains the manifest identity and `phase`. An `active` +phase maps each retention name to its 32 snapshot ID bytes. Pin acquisition +conditionally creates or replaces this object. Replaying the same name is valid +only for the same snapshot ID. After pinning, acquisition rereads the exact +original manifest bytes, validates its digest and commit identity, and checks +branch incarnation before acknowledging protection. Failed or uncertain +acquisition preserves the pin for explicit recovery using the saved intent token. + +Release removes only the named pin with the matching snapshot ID. It is +idempotent, including after manifest deletion. The application must stop all +consumers, retries, outstanding reads, and lazy readers before release. Query +pins have no lease, timeout, renewal, or automatic orphan expiry. + +Retirement conditionally changes an unpinned `active` observation to `retiring` +with a fresh `decision_id`. An absent state may be retired directly. A pin or +pin/release cycle since the scan invalidates that observation. `digest: null` +is permitted only for irreversible path retirement discovered through listing; +it never authorizes an acknowledged query pin. `commit_identity: null` means no +authoritative record identity was supplied. Completion changes `retiring` to +`deleted` with the same decision. Neither phase can return to active. These +records remain permanently, even when a manifest delete failed. + +## Publication and latest reads + +Before submitting a manifest, a writer creates a private manifest copy and a +`publication` intent containing all owned physical data, deletion, index, +transaction, managed Blob, FRI, and target manifest references. Foreign roots +require separate owner protection. Every actual handler-generated manifest or +staging name must be registered before that write is submitted. + +The writer stamps manifest configuration keys `lance.snapshot_retention.root`, +`lance.snapshot_retention.publication`, and `lance.snapshot_retention.incarnation` +with the table root, publication UUID, and observed incarnation. It checks new +paths against permanent retired-name shards and all committed plans, then +conditionally adds the publication to the observed root. References inherited +from that root's already validated committed head may be reused. The exact +predecessor observation must still win the root CAS, or be revalidated. Shard +reads may run concurrently. A pending intent protects every recorded reference. + +After the immutable manifest lands, finalization conditionally advances the head +and removes the pending publication. A verified successful commit stays +successful if bookkeeping fails; retain the intent and recover later. A positively +observed retired or changed incarnation still rejects the stale commit. + +Latest reads observe the root once and consider same-branch, same-incarnation +pending publications in descending version order. Resolve each immutable slot and +verify its stamped publication UUID before selecting a landed manifest newer +than the recorded head. Missing slots and slots won by another publication are +ignored. Reads perform no recovery writes. Writers, maintenance, and explicit +recovery may finalize landed publications. A competing immutable commit proves a +pending creation cannot win, allowing its exact intent to be removed. Absence +alone never proves an uncertain write cannot arrive later. + +## Cleanup, recovery, and reuse + +Cleanup observes the root before scanning reachability. It preserves retained +snapshots, all tag and branch sources, and all pending publication references. +It irreversibly retires eligible unpinned manifests against their original pin +observations, writes exact candidate chunks, and conditionally publishes the +plan against the scanned root before deleting any shared object. + +A root conflict caused only by publication registration or finalization may be +revalidated without a full scan: reference contents, phases, source protections, +table identity, mode, and existing plans must be unchanged. Check every added or +changed pending intent and all newly committed manifests against the immutable candidate +chunks. Inspect the attached version suffix after each observed head, including +intermediate commits superseded before readback, and detached manifests; looking +only at the newest head can miss a briefly published reference. Any overlap or any other reference change invalidates the plan. Preserve +the original per-snapshot retirement observations throughout revalidation. + +Before a plan's root pointer can be removed, every candidate name must be added +to its permanent retired-name shard. Physical deletion may then be replayed using +only the committed chunks, preserving shared references and the recorded +retirement decisions. `retired_records` maps decimal version strings to external +commit-store record identities, removed only after their manifest deletion. +Private random data `.lance-stage` copies are never published references and may +be deleted on promotion or abort without a retention lookup. + +Recovery observes journals, then fences `expected_revision` before releasing +unreferenced tokens. An operation that began after that fence keeps its pin. +Journals remain discoverable while a delayed acquisition could still land; +irreversible retirement is required before dropping that release ownership. +Recovery never releases application query pins automatically. Failed deletion +resumes the same plan and cannot reuse retired names. Explicit forced branch +deletion bypasses this contract and requires draining affected clients. + +Inactive tables keep the historical cleanup and branch deletion behavior. They +must not take this protocol's locks or emit retirement records implicitly. +Activated tables must reject uncoordinated version expiry and manifest-path +migration. Deployment upgrades must cover historical handles as well as latest +opens; the root record does not revoke operations already submitted by old code. diff --git a/docs/src/format/table/snapshot_retention.schema.json b/docs/src/format/table/snapshot_retention.schema.json new file mode 100644 index 00000000000..582d2bc77e5 --- /dev/null +++ b/docs/src/format/table/snapshot_retention.schema.json @@ -0,0 +1,789 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "lance-atomic-retention-v1", + "oneOf": [ + { + "$ref": "#/$defs/root" + }, + { + "$ref": "#/$defs/snapshot" + }, + { + "$ref": "#/$defs/publication" + }, + { + "$ref": "#/$defs/plan" + }, + { + "$ref": "#/$defs/retired" + }, + { + "$ref": "#/$defs/operation" + } + ], + "$defs": { + "tagContents": { + "type": "object", + "additionalProperties": false, + "properties": { + "branch": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "version": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + }, + "createdAt": { + "type": "string" + }, + "updatedAt": { + "type": "string" + }, + "manifestSize": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + }, + "metadata": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "required": [ + "branch", + "version", + "manifestSize" + ] + }, + "branchContents": { + "type": "object", + "additionalProperties": false, + "properties": { + "parentBranch": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "identifier": { + "type": "object", + "additionalProperties": false, + "properties": { + "version_mapping": { + "type": "array", + "items": { + "type": "array", + "prefixItems": [ + { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + }, + { + "type": "string" + } + ], + "minItems": 2, + "maxItems": 2 + } + } + }, + "required": [ + "version_mapping" + ] + }, + "parentVersion": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + }, + "createAt": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + }, + "manifestSize": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + }, + "metadata": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "required": [ + "parentBranch", + "identifier", + "parentVersion", + "createAt", + "manifestSize" + ] + }, + "head": { + "type": "object", + "additionalProperties": false, + "properties": { + "version": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + }, + "path": { + "type": "string" + }, + "size": { + "anyOf": [ + { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + }, + { + "type": "null" + } + ] + }, + "scheme": { + "enum": [ + "V1", + "V2" + ] + }, + "e_tag": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "identity": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "version", + "path", + "size", + "scheme", + "e_tag", + "identity" + ] + }, + "tag": { + "type": "object", + "additionalProperties": false, + "properties": { + "contents": { + "$ref": "#/$defs/tagContents" + }, + "protection": { + "type": "string" + } + }, + "required": [ + "contents", + "protection" + ] + }, + "branchPhase": { + "oneOf": [ + { + "type": "object", + "additionalProperties": false, + "properties": { + "phase": { + "const": "creating" + }, + "first_version": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + } + }, + "required": [ + "phase", + "first_version" + ] + }, + { + "type": "object", + "additionalProperties": false, + "properties": { + "phase": { + "const": "active" + } + }, + "required": [ + "phase" + ] + }, + { + "type": "object", + "additionalProperties": false, + "properties": { + "phase": { + "const": "retiring" + }, + "decision_id": { + "type": "string", + "format": "uuid" + }, + "plan_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "phase", + "decision_id", + "plan_id" + ] + }, + { + "type": "object", + "additionalProperties": false, + "properties": { + "phase": { + "const": "deleted" + }, + "decision_id": { + "type": "string", + "format": "uuid" + } + }, + "required": [ + "phase", + "decision_id" + ] + } + ] + }, + "branch": { + "type": "object", + "additionalProperties": false, + "properties": { + "contents": { + "$ref": "#/$defs/branchContents" + }, + "phase": { + "$ref": "#/$defs/branchPhase" + }, + "max_version": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + }, + "first_version": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + }, + "source_protection": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "head": { + "anyOf": [ + { + "$ref": "#/$defs/head" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "contents", + "phase", + "max_version", + "first_version", + "source_protection", + "head" + ] + }, + "publication": { + "type": "object", + "additionalProperties": false, + "properties": { + "id": { + "type": "string", + "format": "uuid" + }, + "base": { + "type": "string" + }, + "branch": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "version": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + }, + "transaction_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ] + }, + "manifest_copy": { + "type": "string" + }, + "reference_chunks": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "id", + "base", + "branch", + "version", + "transaction_id", + "manifest_copy", + "reference_chunks" + ] + }, + "root": { + "type": "object", + "additionalProperties": false, + "properties": { + "protocol_version": { + "const": 1 + }, + "mode": { + "enum": [ + "preparing", + "active" + ] + }, + "revision": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + }, + "mutation_id": { + "type": "string", + "format": "uuid" + }, + "table_id": { + "type": "string", + "format": "uuid" + }, + "head": { + "anyOf": [ + { + "$ref": "#/$defs/head" + }, + { + "type": "null" + } + ] + }, + "tags": { + "type": "object", + "additionalProperties": { + "anyOf": [ + { + "$ref": "#/$defs/tag" + }, + { + "type": "null" + } + ] + } + }, + "branches": { + "type": "object", + "additionalProperties": { + "$ref": "#/$defs/branch" + } + }, + "publications": { + "type": "object", + "additionalProperties": { + "$ref": "#/$defs/publication" + } + }, + "plans": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "required": [ + "protocol_version", + "mode", + "revision", + "mutation_id", + "table_id", + "head", + "tags", + "branches", + "publications", + "plans" + ] + }, + "identity": { + "type": "object", + "additionalProperties": false, + "properties": { + "manifest_path": { + "type": "string" + }, + "digest": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "minItems": 32, + "maxItems": 32 + }, + { + "type": "null" + } + ] + }, + "commit_identity": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "manifest_path", + "digest", + "commit_identity" + ] + }, + "snapshotPhase": { + "oneOf": [ + { + "type": "object", + "additionalProperties": false, + "properties": { + "phase": { + "const": "active" + }, + "pins": { + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "minItems": 32, + "maxItems": 32 + } + } + }, + "required": [ + "phase", + "pins" + ] + }, + { + "type": "object", + "additionalProperties": false, + "properties": { + "phase": { + "const": "retiring" + }, + "decision_id": { + "type": "string", + "format": "uuid" + } + }, + "required": [ + "phase", + "decision_id" + ] + }, + { + "type": "object", + "additionalProperties": false, + "properties": { + "phase": { + "const": "deleted" + }, + "decision_id": { + "type": "string", + "format": "uuid" + } + }, + "required": [ + "phase", + "decision_id" + ] + } + ] + }, + "snapshot": { + "type": "object", + "additionalProperties": false, + "properties": { + "manifest_key": { + "type": "string" + }, + "identity": { + "$ref": "#/$defs/identity" + }, + "revision": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + }, + "mutation_id": { + "type": "string", + "format": "uuid" + }, + "phase": { + "$ref": "#/$defs/snapshotPhase" + } + }, + "required": [ + "manifest_key", + "identity", + "revision", + "mutation_id", + "phase" + ] + }, + "plannedFile": { + "type": "object", + "additionalProperties": false, + "properties": { + "path": { + "type": "string" + }, + "kind": { + "enum": [ + "Data", + "Transaction", + "Deletion", + "Index", + "Manifest", + "TemporaryManifest" + ] + }, + "unverified": { + "type": "boolean" + }, + "size_bytes": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + } + }, + "required": [ + "path", + "kind", + "unverified", + "size_bytes" + ] + }, + "plan": { + "type": "object", + "additionalProperties": false, + "properties": { + "id": { + "type": "string", + "format": "uuid" + }, + "purpose": { + "enum": [ + "cleanup", + "branch_deletion" + ] + }, + "base": { + "type": "string" + }, + "branch": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "chunks": { + "type": "array", + "items": { + "type": "string" + } + }, + "snapshots": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "identity": { + "$ref": "#/$defs/identity" + }, + "decision_id": { + "type": "string", + "format": "uuid" + } + }, + "required": [ + "identity", + "decision_id" + ] + } + }, + "retired_records": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "required": [ + "id", + "purpose", + "base", + "branch", + "chunks", + "snapshots", + "retired_records" + ] + }, + "retired": { + "type": "object", + "additionalProperties": false, + "properties": { + "revision": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + }, + "mutation_id": { + "type": "string", + "format": "uuid" + }, + "paths": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "revision", + "mutation_id", + "paths" + ] + }, + "operation": { + "type": "object", + "additionalProperties": false, + "properties": { + "tag": { + "type": "string" + }, + "expected_revision": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + }, + "old_protection": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "new_protection": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "tag", + "expected_revision", + "old_protection", + "new_protection" + ] + } + } +} diff --git a/protos/codegen/src/main.rs b/protos/codegen/src/main.rs index 1cc00b4f13c..2a81730cbb6 100644 --- a/protos/codegen/src/main.rs +++ b/protos/codegen/src/main.rs @@ -135,6 +135,7 @@ fn generate_table( proto_dir.join("table.proto"), proto_dir.join("transaction/transaction.proto"), proto_dir.join("rowids.proto"), + proto_dir.join("snapshot.proto"), ], &[&proto_dir], )?; @@ -152,7 +153,7 @@ fn generate_table( install_generated( &out_dir, &repo_root.join("rust/lance-table/src/pb"), - &["lance.table.rs", "lance.transaction.rs"], + &["lance.table.rs", "lance.transaction.rs", "lance.snapshot.rs"], check, ) } @@ -228,9 +229,11 @@ fn generate_lance( config.extern_path(".lance.index.pb", "::lance_index::pb"); config.extern_path(".lance.datafusion", "::lance_datafusion::pb"); config.enable_type_names(); + config.bytes([".lance.dataset.retention"]); config.compile_protos( &[ proto_dir.join("ann.proto"), + proto_dir.join("snapshot_retention.proto"), proto_dir.join("fts.proto"), proto_dir.join("cache_diagnostics.proto"), proto_dir.join("merge_analysis.proto"), @@ -240,7 +243,11 @@ fn generate_lance( install_generated( &out_dir, &repo_root.join("rust/lance/src/pb"), - &["lance.pb.rs", "lance.cache.rs"], + &[ + "lance.pb.rs", + "lance.cache.rs", + "lance.dataset.retention.rs", + ], check, ) } diff --git a/protos/snapshot.proto b/protos/snapshot.proto new file mode 100644 index 00000000000..9067f8802a5 --- /dev/null +++ b/protos/snapshot.proto @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright The Lance Authors + +syntax = "proto3"; + +package lance.snapshot; + +/* Reference to an exact table snapshot, also embedded in persisted snapshot + * retention tokens. No manifest contents, credentials, storage bindings, or retention + * rights are transported. Unknown protocol versions must fail. + */ +message SnapshotRef { + uint32 protocol_version = 1; + // Caller-supplied table incarnation and catalog/storage authority. + string table_identity = 2; + // Canonical absolute table root URI, without a branch suffix or credentials. + string table_uri = 3; + // Absent identifies the main branch. Tags and unresolved heads are not accepted. + optional string branch = 4; + uint64 version = 5; + // Exact resolved manifest object path in the source object store. + string manifest_path = 6; + /* BLAKE3 of the complete original manifest file, including index metadata, + * inline transactions, dictionaries, length prefixes, and the footer. + * Hash the original bytes: protobuf re-encoding is not canonical. + */ + bytes manifest_digest = 7; + /* Optional authoritative commit-store record identity. Absent means the + * manifest digest supplies content identity; an ETag is not a substitute. + */ + optional string manifest_identity = 8; +} diff --git a/protos/snapshot_retention.proto b/protos/snapshot_retention.proto new file mode 100644 index 00000000000..69a3d906a46 --- /dev/null +++ b/protos/snapshot_retention.proto @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright The Lance Authors + +syntax = "proto3"; + +package lance.dataset.retention; + +/* Persisted explicit-release snapshot protection token, encoded as hexadecimal + * in table-root references, reference-operation journals, and query projections. + * Decoding does not acquire protection. See the atomic snapshot retention spec. + */ +message SnapshotRetention { + uint32 protocol_version = 1; + // Encoded compact lance.snapshot.SnapshotRef, without manifest contents. + bytes snapshot = 2; + string tag_name = 3; +} diff --git a/rust/lance-table/src/pb/lance.snapshot.rs b/rust/lance-table/src/pb/lance.snapshot.rs new file mode 100644 index 00000000000..f0db900591a --- /dev/null +++ b/rust/lance-table/src/pb/lance.snapshot.rs @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright The Lance Authors + +// This file is @generated by prost-build. +/// Reference to an exact table snapshot, also embedded in persisted snapshot +/// retention tokens. No manifest contents, credentials, storage bindings, or retention +/// rights are transported. Unknown protocol versions must fail. +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct SnapshotRef { + #[prost(uint32, tag = "1")] + pub protocol_version: u32, + /// Caller-supplied table incarnation and catalog/storage authority. + #[prost(string, tag = "2")] + pub table_identity: ::prost::alloc::string::String, + /// Canonical absolute table root URI, without a branch suffix or credentials. + #[prost(string, tag = "3")] + pub table_uri: ::prost::alloc::string::String, + /// Absent identifies the main branch. Tags and unresolved heads are not accepted. + #[prost(string, optional, tag = "4")] + pub branch: ::core::option::Option<::prost::alloc::string::String>, + #[prost(uint64, tag = "5")] + pub version: u64, + /// Exact resolved manifest object path in the source object store. + #[prost(string, tag = "6")] + pub manifest_path: ::prost::alloc::string::String, + /// BLAKE3 of the complete original manifest file, including index metadata, + /// inline transactions, dictionaries, length prefixes, and the footer. + /// Hash the original bytes: protobuf re-encoding is not canonical. + #[prost(bytes = "vec", tag = "7")] + pub manifest_digest: ::prost::alloc::vec::Vec, + /// Optional authoritative commit-store record identity. Absent means the + /// manifest digest supplies content identity; an ETag is not a substitute. + #[prost(string, optional, tag = "8")] + pub manifest_identity: ::core::option::Option<::prost::alloc::string::String>, +} +impl ::prost::Name for SnapshotRef { + const NAME: &'static str = "SnapshotRef"; + const PACKAGE: &'static str = "lance.snapshot"; + fn full_name() -> ::prost::alloc::string::String { + "lance.snapshot.SnapshotRef".into() + } + fn type_url() -> ::prost::alloc::string::String { + "/lance.snapshot.SnapshotRef".into() + } +} diff --git a/rust/lance/src/pb/lance.dataset.retention.rs b/rust/lance/src/pb/lance.dataset.retention.rs new file mode 100644 index 00000000000..37d90f33720 --- /dev/null +++ b/rust/lance/src/pb/lance.dataset.retention.rs @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright The Lance Authors + +// This file is @generated by prost-build. +/// Persisted explicit-release snapshot protection token, encoded as hexadecimal +/// in table-root references, reference-operation journals, and query projections. +/// Decoding does not acquire protection. See the atomic snapshot retention spec. +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct SnapshotRetention { + #[prost(uint32, tag = "1")] + pub protocol_version: u32, + /// Encoded compact lance.snapshot.SnapshotRef, without manifest contents. + #[prost(bytes = "bytes", tag = "2")] + pub snapshot: ::prost::bytes::Bytes, + #[prost(string, tag = "3")] + pub tag_name: ::prost::alloc::string::String, +} +impl ::prost::Name for SnapshotRetention { + const NAME: &'static str = "SnapshotRetention"; + const PACKAGE: &'static str = "lance.dataset.retention"; + fn full_name() -> ::prost::alloc::string::String { + "lance.dataset.retention.SnapshotRetention".into() + } + fn type_url() -> ::prost::alloc::string::String { + "/lance.dataset.retention.SnapshotRetention".into() + } +} From 29e7e877ecc2bf1bdacf5b10b5dbc0e51168ea2b Mon Sep 17 00:00:00 2001 From: Alexander Erofeev Date: Wed, 25 Nov 2026 11:59:59 +0700 Subject: [PATCH 2/6] style(codegen): format the rebased snapshot output list --- protos/codegen/src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/protos/codegen/src/main.rs b/protos/codegen/src/main.rs index 2a81730cbb6..dc5eac41957 100644 --- a/protos/codegen/src/main.rs +++ b/protos/codegen/src/main.rs @@ -153,7 +153,11 @@ fn generate_table( install_generated( &out_dir, &repo_root.join("rust/lance-table/src/pb"), - &["lance.table.rs", "lance.transaction.rs", "lance.snapshot.rs"], + &[ + "lance.table.rs", + "lance.transaction.rs", + "lance.snapshot.rs", + ], check, ) } From e7e15d336d57644f904815928b3bb6ddb38be997 Mon Sep 17 00:00:00 2001 From: Alexander Erofeev Date: Wed, 25 Nov 2026 12:09:57 +0700 Subject: [PATCH 3/6] docs(format): clarify safe publication recovery and snapshot addresses --- docs/src/format/table/snapshot_retention.md | 93 ++++++++++++++++----- 1 file changed, 70 insertions(+), 23 deletions(-) diff --git a/docs/src/format/table/snapshot_retention.md b/docs/src/format/table/snapshot_retention.md index e695f050c9d..e7ddab81f32 100644 --- a/docs/src/format/table/snapshot_retention.md +++ b/docs/src/format/table/snapshot_retention.md @@ -73,12 +73,27 @@ Reference and planned-file chunks contain at most 1,024 entries. Headers and chunks must belong to the same operation directory. Root IDs must match the referenced header IDs. Readers validate addresses before following them. -`manifest_hash` is the lowercase 64-digit BLAKE3 hex digest of the normalized -physical manifest address's UTF-8 bytes. `manifest_key` repeats that address and -must match the addressed object. `shard` is the first four lowercase hex digits -of BLAKE3 of a retired physical path's UTF-8 bytes. Retired-name shards store a -set of exact path strings, not path prefixes. Their revision and mutation ID -follow the root replacement rules; shard tombstones never expire. +`manifest_hash` is the lowercase 64-digit BLAKE3 hex digest of the normalized, +root-relative `manifest_key`'s UTF-8 bytes. The hash input excludes the table root, +URI scheme, bucket, leading slash, JSON quotes, and trailing newline. Joining +`manifest_key` to the authenticated physical root must produce +`identity.manifest_path`. `shard` is the first four lowercase hex digits +of BLAKE3 of a normalized, root-relative retired path's UTF-8 bytes. Retired-name +shards store a set of exact path strings, not path prefixes. Their revision and +mutation ID follow the root replacement rules; shard tombstones never expire. + +For example, a table at `s3://example-bucket/datasets/images.lance` has the +authenticated object-store root `datasets/images.lance`. For its V2 version 1 +manifest: + +- `manifest_key` is `_versions/18446744073709551614.manifest`. +- `identity.manifest_path` is + `datasets/images.lance/_versions/18446744073709551614.manifest`. +- The exact UTF-8 hash input is `_versions/18446744073709551614.manifest`, without + quotes or a newline. Its BLAKE3 hex digest is + `440501a2a475eecc72625ba94bfe75c67dfff11b628b9d88665b601162a04f96`. +- The snapshot record's object-store path is + `datasets/images.lance/_refs/retention/snapshots/440501a2a475eecc72625ba94bfe75c67dfff11b628b9d88665b601162a04f96.json`. ## Persisted snapshot and release tokens @@ -104,8 +119,12 @@ is no separator. Retention IDs identify distinct query lifetimes and must not be reused after release. `protection`, `source_protection`, `old_protection`, and `new_protection` contain -lowercase hexadecimal protobuf release-token bytes. `null` means no protection. -Decode both protocol versions before recovery uses a token. Token validation +lowercase hexadecimal protobuf release-token bytes. A non-null entry in the +root's `tags` map must contain a valid, non-null `protection` token for the +snapshot named by its `contents`. A null map entry is the tag-deletion tombstone, +not an active tag without protection. Branch `source_protection` and operation +journal `old_protection` and `new_protection` may be null when that side owns no +pin. Decode both protocol versions before recovery uses a token. Token validation alone does not acquire, renew, release, or authorize protection. ## Tags and branches @@ -127,8 +146,9 @@ A tag mutation writes an `operation` journal before acquiring its new source pin It commits against `expected_revision` and includes the new token in the root. Only after that decision may it release the old token. Tag deletion publishes a null entry before releasing old protection. `tag` names the affected reference; -branch journals use this field for the branch name too. Missing new or old tokens -mean that side of the mutation does not own protection. +branch journals use this field for the branch name too. Null new or old tokens +in a journal mean that side of the mutation does not own protection; they do not +permit publishing an active tag without a token. A branch transitions `creating` → `active` → `retiring` → `deleted`. Creation holds `source_protection` until its first manifest publication is finalized. Its @@ -187,19 +207,46 @@ from that root's already validated committed head may be reused. The exact predecessor observation must still win the root CAS, or be revalidated. Shard reads may run concurrently. A pending intent protects every recorded reference. -After the immutable manifest lands, finalization conditionally advances the head -and removes the pending publication. A verified successful commit stays -successful if bookkeeping fails; retain the intent and recover later. A positively -observed retired or changed incarnation still rejects the stale commit. - -Latest reads observe the root once and consider same-branch, same-incarnation -pending publications in descending version order. Resolve each immutable slot and -verify its stamped publication UUID before selecting a landed manifest newer -than the recorded head. Missing slots and slots won by another publication are -ignored. Reads perform no recovery writes. Writers, maintenance, and explicit -recovery may finalize landed publications. A competing immutable commit proves a -pending creation cannot win, allowing its exact intent to be removed. Absence -alone never proves an uncertain write cannot arrive later. +After an attached immutable manifest lands, finalization may conditionally +advance the head. Removing its pending publication additionally requires the +write-quiescence evidence defined below. Until then the intent and every recorded +reference remain protected, even after the head advances. A verified successful +commit stays successful if bookkeeping fails; retain the intent and recover +later. A positively observed retired or changed incarnation still rejects the +stale commit, but that rejection does not establish write quiescence. + +Latest reads observe the root once and select same-branch, same-incarnation +pending publications with attached versions before sorting them in descending +version order. An attached version satisfies `1 <= version < 2^63`; a detached +version has bit 63 set and is excluded before this comparison. Resolve each +eligible immutable slot and verify its stamped publication UUID before selecting +a landed manifest newer than the recorded head. Missing slots and slots won by +another publication are ignored only for latest selection. Detached publications still protect their +references and participate in cleanup reachability and recovery. Reads perform +no recovery writes. Writers, maintenance, and explicit recovery may finalize +landed publications subject to the removal rule below. + +### Removing a pending publication + +Before removing an intent and its reference protection, establish that every +submitted manifest or staging write, including retries, has a definitive storage +outcome and that no further writes can be submitted under that publication. +A storage response that definitively completes a request may establish its +outcome. A timeout, connection loss, local cancellation, or process exit does +not establish that a remote request has stopped. The writer must close its +submission and retry paths before conditionally removing the intent from the +root. That root update records established quiescence; it does not fence a +storage request itself. + +Recovery needs equivalent evidence that remains valid after a crash. Version 1 +does not encode such completion evidence in the root, head, or publication +record. When it cannot be established, recovery must retain the pending intent +and every recorded reference, potentially indefinitely. This applies to landed, +missing, and competing slots, and to retired or changed branch incarnations. +Observing a competing immutable manifest establishes only its present ownership: +cleanup can delete it while an earlier conditional write is still outstanding, +allowing that write to land later. Registration-time retired-name checks and root +revision changes do not prevent an already-submitted request from landing. ## Cleanup, recovery, and reuse From b33992c34570244ae3d6cad5f0384fd389467b7f Mon Sep 17 00:00:00 2001 From: Alexander Erofeev Date: Wed, 25 Nov 2026 17:29:15 +0700 Subject: [PATCH 4/6] docs(format): separate retention identity from execution snapshot transport Define a persisted RetainedSnapshot using the authoritative table UUID and root-relative manifest key. Remove the transport SnapshotRef dependency and keep retention protocol vote coverage. --- .github/labeler-area.yml | 2 - docs/src/format/table/snapshot_retention.md | 24 +++++++---- protos/codegen/src/main.rs | 7 +-- protos/snapshot.proto | 32 -------------- protos/snapshot_retention.proto | 20 ++++++++- rust/lance-table/src/pb/lance.snapshot.rs | 45 -------------------- rust/lance/src/pb/lance.dataset.retention.rs | 36 +++++++++++++++- 7 files changed, 71 insertions(+), 95 deletions(-) delete mode 100644 protos/snapshot.proto delete mode 100644 rust/lance-table/src/pb/lance.snapshot.rs diff --git a/.github/labeler-area.yml b/.github/labeler-area.yml index 723a6a395c6..b1679265ace 100644 --- a/.github/labeler-area.yml +++ b/.github/labeler-area.yml @@ -37,7 +37,6 @@ A-encoding: A-format: - changed-files: - any-glob-to-any-file: - - "protos/snapshot.proto" - "protos/snapshot_retention.proto" - "protos/clustering.proto" - "protos/encodings_v2_0.proto" @@ -60,7 +59,6 @@ A-format: format-change: - changed-files: - any-glob-to-any-file: - - "protos/snapshot.proto" - "protos/snapshot_retention.proto" - "protos/clustering.proto" - "protos/encodings_v2_0.proto" diff --git a/docs/src/format/table/snapshot_retention.md b/docs/src/format/table/snapshot_retention.md index e7ddab81f32..951d0b3233b 100644 --- a/docs/src/format/table/snapshot_retention.md +++ b/docs/src/format/table/snapshot_retention.md @@ -41,8 +41,8 @@ slash-separated addresses relative to the authenticated table root. The empty address identifies the root. In a per-manifest snapshot record, `identity.manifest_path` is the canonical physical object-store path including the root prefix; `manifest_key` is its root-relative address. Plan retirement -identities instead use the root-relative address. Transported SnapshotRef paths -remain resolved paths in their authenticated source store. +identities instead use the root-relative address. Persisted release tokens also +use the root-relative `manifest_key`; execution transport addresses are not persisted. Absolute paths, escaping components, and objects outside the root are rejected. Local aliases must resolve to the same canonical physical root and file addresses, including when a file was already deleted and only its parents survive. Catalog @@ -97,12 +97,20 @@ manifest: ## Persisted snapshot and release tokens -`protos/snapshot.proto` defines `lance.snapshot.SnapshotRef`, protocol version 1. `protos/snapshot_retention.proto` defines `lance.dataset.retention.SnapshotRetention`, -protocol version 1. The latter embeds the encoded former in `snapshot`. -These schemas are persisted contracts wherever tokens appear below; they are -also used for execution transport. Neither message contains credentials, -manifest contents, or an authorization capability. +protocol version 1, and its independent `RetainedSnapshot`, protocol version 1. +`SnapshotRetention.snapshot` contains the protobuf encoding of a validated +`RetainedSnapshot`. These messages are persisted contracts. Neither contains +credentials, manifest contents, an absolute table URI, a caller-defined table +identity, or an authorization capability. The execution-only `SnapshotRef` is +not embedded and this specification does not depend on its schema or implementation. + +`RetainedSnapshot.table_id` is the nonzero 16-byte UUID from the authoritative +retention root. Its `manifest_key` is the normalized root-relative manifest +address described above. Resolving that key through the authenticated root must +identify the same manifest as the per-manifest record. A release must validate +the table ID against the root before modifying any pin. Unknown protocol versions, +invalid UUIDs, escaping paths, and missing identity fields are rejected. The manifest digest is 32 BLAKE3 bytes over the complete original manifest file, including metadata sections, dictionaries, inline transactions, length prefixes, @@ -111,7 +119,7 @@ The optional manifest identity is the authoritative commit-store identity; absence means that only the digest supplies content identity. Branch absence identifies main. A snapshot must name an exact positive version and manifest. -The snapshot ID is BLAKE3 of the protobuf encoding of its validated known fields, +The snapshot ID is BLAKE3 of the `RetainedSnapshot` encoding of its validated known fields, serialized in field-number order with absent/default proto3 fields omitted. The retention name is `lance-query-` followed by lowercase hex BLAKE3 of the 32 snapshot ID bytes followed immediately by the nonempty retention ID's UTF-8 bytes. There diff --git a/protos/codegen/src/main.rs b/protos/codegen/src/main.rs index dc5eac41957..3bf943a3a2d 100644 --- a/protos/codegen/src/main.rs +++ b/protos/codegen/src/main.rs @@ -135,7 +135,6 @@ fn generate_table( proto_dir.join("table.proto"), proto_dir.join("transaction/transaction.proto"), proto_dir.join("rowids.proto"), - proto_dir.join("snapshot.proto"), ], &[&proto_dir], )?; @@ -153,11 +152,7 @@ fn generate_table( install_generated( &out_dir, &repo_root.join("rust/lance-table/src/pb"), - &[ - "lance.table.rs", - "lance.transaction.rs", - "lance.snapshot.rs", - ], + &["lance.table.rs", "lance.transaction.rs"], check, ) } diff --git a/protos/snapshot.proto b/protos/snapshot.proto deleted file mode 100644 index 9067f8802a5..00000000000 --- a/protos/snapshot.proto +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: Copyright The Lance Authors - -syntax = "proto3"; - -package lance.snapshot; - -/* Reference to an exact table snapshot, also embedded in persisted snapshot - * retention tokens. No manifest contents, credentials, storage bindings, or retention - * rights are transported. Unknown protocol versions must fail. - */ -message SnapshotRef { - uint32 protocol_version = 1; - // Caller-supplied table incarnation and catalog/storage authority. - string table_identity = 2; - // Canonical absolute table root URI, without a branch suffix or credentials. - string table_uri = 3; - // Absent identifies the main branch. Tags and unresolved heads are not accepted. - optional string branch = 4; - uint64 version = 5; - // Exact resolved manifest object path in the source object store. - string manifest_path = 6; - /* BLAKE3 of the complete original manifest file, including index metadata, - * inline transactions, dictionaries, length prefixes, and the footer. - * Hash the original bytes: protobuf re-encoding is not canonical. - */ - bytes manifest_digest = 7; - /* Optional authoritative commit-store record identity. Absent means the - * manifest digest supplies content identity; an ETag is not a substitute. - */ - optional string manifest_identity = 8; -} diff --git a/protos/snapshot_retention.proto b/protos/snapshot_retention.proto index 69a3d906a46..956220b234c 100644 --- a/protos/snapshot_retention.proto +++ b/protos/snapshot_retention.proto @@ -5,13 +5,31 @@ syntax = "proto3"; package lance.dataset.retention; +/* Persisted identity within an authenticated retention root. It is independent + * of execution SnapshotRef, caller identities, URIs, credentials, and bindings. + */ +message RetainedSnapshot { + uint32 protocol_version = 1; + // Nonzero 16-byte UUID from the authoritative retention root's table_id. + bytes table_id = 2; + // Absent identifies main; otherwise the exact normalized branch name. + optional string branch = 3; + uint64 version = 4; + // Normalized root-relative manifest address, never an absolute path or URI. + string manifest_key = 5; + // Exactly 32 BLAKE3 bytes covering the complete original manifest file. + bytes manifest_digest = 6; + // Optional authoritative commit-store record identity. + optional string manifest_identity = 7; +} + /* Persisted explicit-release snapshot protection token, encoded as hexadecimal * in table-root references, reference-operation journals, and query projections. * Decoding does not acquire protection. See the atomic snapshot retention spec. */ message SnapshotRetention { uint32 protocol_version = 1; - // Encoded compact lance.snapshot.SnapshotRef, without manifest contents. + // Encoded RetainedSnapshot, without manifest contents or execution context. bytes snapshot = 2; string tag_name = 3; } diff --git a/rust/lance-table/src/pb/lance.snapshot.rs b/rust/lance-table/src/pb/lance.snapshot.rs deleted file mode 100644 index f0db900591a..00000000000 --- a/rust/lance-table/src/pb/lance.snapshot.rs +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: Copyright The Lance Authors - -// This file is @generated by prost-build. -/// Reference to an exact table snapshot, also embedded in persisted snapshot -/// retention tokens. No manifest contents, credentials, storage bindings, or retention -/// rights are transported. Unknown protocol versions must fail. -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct SnapshotRef { - #[prost(uint32, tag = "1")] - pub protocol_version: u32, - /// Caller-supplied table incarnation and catalog/storage authority. - #[prost(string, tag = "2")] - pub table_identity: ::prost::alloc::string::String, - /// Canonical absolute table root URI, without a branch suffix or credentials. - #[prost(string, tag = "3")] - pub table_uri: ::prost::alloc::string::String, - /// Absent identifies the main branch. Tags and unresolved heads are not accepted. - #[prost(string, optional, tag = "4")] - pub branch: ::core::option::Option<::prost::alloc::string::String>, - #[prost(uint64, tag = "5")] - pub version: u64, - /// Exact resolved manifest object path in the source object store. - #[prost(string, tag = "6")] - pub manifest_path: ::prost::alloc::string::String, - /// BLAKE3 of the complete original manifest file, including index metadata, - /// inline transactions, dictionaries, length prefixes, and the footer. - /// Hash the original bytes: protobuf re-encoding is not canonical. - #[prost(bytes = "vec", tag = "7")] - pub manifest_digest: ::prost::alloc::vec::Vec, - /// Optional authoritative commit-store record identity. Absent means the - /// manifest digest supplies content identity; an ETag is not a substitute. - #[prost(string, optional, tag = "8")] - pub manifest_identity: ::core::option::Option<::prost::alloc::string::String>, -} -impl ::prost::Name for SnapshotRef { - const NAME: &'static str = "SnapshotRef"; - const PACKAGE: &'static str = "lance.snapshot"; - fn full_name() -> ::prost::alloc::string::String { - "lance.snapshot.SnapshotRef".into() - } - fn type_url() -> ::prost::alloc::string::String { - "/lance.snapshot.SnapshotRef".into() - } -} diff --git a/rust/lance/src/pb/lance.dataset.retention.rs b/rust/lance/src/pb/lance.dataset.retention.rs index 37d90f33720..e3dd0b6c7e3 100644 --- a/rust/lance/src/pb/lance.dataset.retention.rs +++ b/rust/lance/src/pb/lance.dataset.retention.rs @@ -2,6 +2,40 @@ // SPDX-FileCopyrightText: Copyright The Lance Authors // This file is @generated by prost-build. +/// Persisted identity within an authenticated retention root. It is independent +/// of execution SnapshotRef, caller identities, URIs, credentials, and bindings. +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct RetainedSnapshot { + #[prost(uint32, tag = "1")] + pub protocol_version: u32, + /// Nonzero 16-byte UUID from the authoritative retention root's table_id. + #[prost(bytes = "bytes", tag = "2")] + pub table_id: ::prost::bytes::Bytes, + /// Absent identifies main; otherwise the exact normalized branch name. + #[prost(string, optional, tag = "3")] + pub branch: ::core::option::Option<::prost::alloc::string::String>, + #[prost(uint64, tag = "4")] + pub version: u64, + /// Normalized root-relative manifest address, never an absolute path or URI. + #[prost(string, tag = "5")] + pub manifest_key: ::prost::alloc::string::String, + /// Exactly 32 BLAKE3 bytes covering the complete original manifest file. + #[prost(bytes = "bytes", tag = "6")] + pub manifest_digest: ::prost::bytes::Bytes, + /// Optional authoritative commit-store record identity. + #[prost(string, optional, tag = "7")] + pub manifest_identity: ::core::option::Option<::prost::alloc::string::String>, +} +impl ::prost::Name for RetainedSnapshot { + const NAME: &'static str = "RetainedSnapshot"; + const PACKAGE: &'static str = "lance.dataset.retention"; + fn full_name() -> ::prost::alloc::string::String { + "lance.dataset.retention.RetainedSnapshot".into() + } + fn type_url() -> ::prost::alloc::string::String { + "/lance.dataset.retention.RetainedSnapshot".into() + } +} /// Persisted explicit-release snapshot protection token, encoded as hexadecimal /// in table-root references, reference-operation journals, and query projections. /// Decoding does not acquire protection. See the atomic snapshot retention spec. @@ -9,7 +43,7 @@ pub struct SnapshotRetention { #[prost(uint32, tag = "1")] pub protocol_version: u32, - /// Encoded compact lance.snapshot.SnapshotRef, without manifest contents. + /// Encoded RetainedSnapshot, without manifest contents or execution context. #[prost(bytes = "bytes", tag = "2")] pub snapshot: ::prost::bytes::Bytes, #[prost(string, tag = "3")] From 9cfa1d74fd9b68924d4d7b219f62c57f14160da7 Mon Sep 17 00:00:00 2001 From: Alexander Erofeev Date: Wed, 25 Nov 2026 17:35:06 +0700 Subject: [PATCH 5/6] docs(format): specify retained snapshot UUID encoding --- docs/src/format/table/snapshot_retention.md | 5 +++-- protos/snapshot_retention.proto | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/src/format/table/snapshot_retention.md b/docs/src/format/table/snapshot_retention.md index 951d0b3233b..3068e17c331 100644 --- a/docs/src/format/table/snapshot_retention.md +++ b/docs/src/format/table/snapshot_retention.md @@ -106,7 +106,8 @@ identity, or an authorization capability. The execution-only `SnapshotRef` is not embedded and this specification does not depend on its schema or implementation. `RetainedSnapshot.table_id` is the nonzero 16-byte UUID from the authoritative -retention root. Its `manifest_key` is the normalized root-relative manifest +retention root, in network byte order (the UUID text's hexadecimal pairs with +hyphens removed). Its `manifest_key` is the normalized root-relative manifest address described above. Resolving that key through the authenticated root must identify the same manifest as the per-manifest record. A release must validate the table ID against the root before modifying any pin. Unknown protocol versions, @@ -115,7 +116,7 @@ invalid UUIDs, escaping paths, and missing identity fields are rejected. The manifest digest is 32 BLAKE3 bytes over the complete original manifest file, including metadata sections, dictionaries, inline transactions, length prefixes, and footer. Protobuf re-encoding must not substitute for the original file bytes. -The optional manifest identity is the authoritative commit-store identity; +The optional manifest identity is a nonempty authoritative commit-store identity; absence means that only the digest supplies content identity. Branch absence identifies main. A snapshot must name an exact positive version and manifest. diff --git a/protos/snapshot_retention.proto b/protos/snapshot_retention.proto index 956220b234c..3ff23851f53 100644 --- a/protos/snapshot_retention.proto +++ b/protos/snapshot_retention.proto @@ -10,7 +10,7 @@ package lance.dataset.retention; */ message RetainedSnapshot { uint32 protocol_version = 1; - // Nonzero 16-byte UUID from the authoritative retention root's table_id. + // Nonzero 16-byte UUID in network byte order from the retention root's table_id. bytes table_id = 2; // Absent identifies main; otherwise the exact normalized branch name. optional string branch = 3; From 5096ea12885255c1d3077d4750da541bcf617ff2 Mon Sep 17 00:00:00 2001 From: Alexander Erofeev Date: Wed, 25 Nov 2026 17:47:49 +0700 Subject: [PATCH 6/6] chore(proto): refresh isolated retention code generation --- rust/lance/src/pb/lance.dataset.retention.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/lance/src/pb/lance.dataset.retention.rs b/rust/lance/src/pb/lance.dataset.retention.rs index e3dd0b6c7e3..cf81b7d99aa 100644 --- a/rust/lance/src/pb/lance.dataset.retention.rs +++ b/rust/lance/src/pb/lance.dataset.retention.rs @@ -8,7 +8,7 @@ pub struct RetainedSnapshot { #[prost(uint32, tag = "1")] pub protocol_version: u32, - /// Nonzero 16-byte UUID from the authoritative retention root's table_id. + /// Nonzero 16-byte UUID in network byte order from the retention root's table_id. #[prost(bytes = "bytes", tag = "2")] pub table_id: ::prost::bytes::Bytes, /// Absent identifies main; otherwise the exact normalized branch name.