reflake 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. {reflake-0.2.0 → reflake-0.2.1}/.gitignore +3 -0
  2. {reflake-0.2.0 → reflake-0.2.1}/CHANGELOG.md +131 -0
  3. {reflake-0.2.0 → reflake-0.2.1}/PKG-INFO +97 -28
  4. {reflake-0.2.0 → reflake-0.2.1}/README.md +96 -27
  5. {reflake-0.2.0 → reflake-0.2.1}/pyproject.toml +6 -1
  6. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/__init__.py +4 -12
  7. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/cli.py +111 -58
  8. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/__init__.py +5 -16
  9. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/client_state.py +0 -16
  10. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/config.py +5 -0
  11. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/domain/__init__.py +4 -0
  12. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/domain/errors.py +20 -0
  13. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/domain/models.py +0 -2
  14. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/entry_codec.py +0 -56
  15. reflake-0.2.1/src/reflake/core/manifest.py +47 -0
  16. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/objects/__init__.py +0 -6
  17. reflake-0.2.1/src/reflake/core/objects/backends.py +91 -0
  18. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/objects/base.py +11 -2
  19. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/objects/footer.py +77 -16
  20. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/objects/local.py +9 -3
  21. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/objects/query.py +82 -43
  22. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/objects/s3.py +26 -9
  23. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/objects/transfer.py +48 -9
  24. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/objects/tree.py +0 -11
  25. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/query/catalog.py +3 -0
  26. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/query/pruning.py +41 -11
  27. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/repository.py +53 -89
  28. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/repository_ops.py +111 -60
  29. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/repository_support.py +35 -51
  30. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/repository_sync.py +102 -50
  31. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/services/__init__.py +2 -3
  32. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/services/refs.py +20 -7
  33. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/services/staging.py +7 -1
  34. reflake-0.2.1/src/reflake/core/services/tree.py +1505 -0
  35. reflake-0.2.1/src/reflake/core/services/tree_inspect.py +250 -0
  36. reflake-0.2.0/src/reflake/core/manifest.py +0 -174
  37. reflake-0.2.0/src/reflake/core/objects/backends.py +0 -160
  38. reflake-0.2.0/src/reflake/core/objects/derived.py +0 -71
  39. reflake-0.2.0/src/reflake/core/services/tree.py +0 -926
  40. reflake-0.2.0/src/reflake/core/services/tree_inspect.py +0 -185
  41. {reflake-0.2.0 → reflake-0.2.1}/LICENSE +0 -0
  42. {reflake-0.2.0 → reflake-0.2.1}/NOTICE +0 -0
  43. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/hashing.py +0 -0
  44. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/layout.py +0 -0
  45. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/objects/source.py +0 -0
  46. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/query/__init__.py +0 -0
  47. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/services/entries.py +0 -0
  48. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/core/vfs/__init__.py +0 -0
  49. {reflake-0.2.0 → reflake-0.2.1}/src/reflake/py.typed +0 -0
@@ -162,3 +162,6 @@ cython_debug/
162
162
  # and can be added to the global gitignore or merged into this file. For a more nuclear
163
163
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
164
164
  #.idea/
165
+
166
+ # Reflake runtime state (never commit a repository into the source tree)
167
+ .reflake/
@@ -6,8 +6,139 @@ The format is based on Keep a Changelog, and Reflake currently tracks changes be
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## [0.2.1] - 2026-09-10
10
+
11
+ ### Deprecated
12
+
13
+ - **v0.2.0** is deprecated and superseded by 0.2.1 — it corrupts full commits
14
+ in directories with more than 10k entries (sharded directories). See the
15
+ notice under 0.2.0 below.
16
+
17
+ ### Fixed
18
+
19
+ - **`identity promote` keeps parquet footer stats.** Promotion rewrote
20
+ pointer entries with the plain-blob kind, so an `mp` entry (stats attached)
21
+ became `b` and every promoted file silently lost its row-group statistics —
22
+ pruning stopped working on exactly the files that had been prepared for it.
23
+ - **Nested shards can no longer be written.** Rebuilding a shard body through
24
+ the general builder re-sharded it once the range held `MAX_TREE_ENTRIES + 1`
25
+ entries, producing shard pointers inside a shard; later operations then saw
26
+ duplicate/misplaced names. Shard bodies are now written as plain nodes, and
27
+ an overflowing range splits into two balanced sibling shards.
28
+ - **A staged file can replace a directory (and vice versa) in one splice.**
29
+ The splice loop kept the existing subtree and then appended the new leaf,
30
+ writing a node with two identical names (unparseable tree stream).
31
+ - **Sharded directories no longer corrupt full commits.** A directory with
32
+ more than 10k entries is stored as name-range shard subtrees; the full
33
+ commit path merged parent *shard pointers* as if they were named children.
34
+ Depending on which file changed, this either silently dropped parent-only
35
+ entries or produced duplicate paths and an unsorted tree stream (breaking
36
+ `verify`, `promote`, and analytical indexing). Parent-directory resolution
37
+ now expands shards to real children, and `_prune_tree` tests removal
38
+ prefixes against real names. Regression suite: `tests/test_sharded_directories.py`.
39
+ - **Opening a repository no longer mutates it.** `RefManager` used to write
40
+ an empty ref for the default branch, which also "created" nonexistent S3
41
+ prefixes on open. Missing branches are now *unborn*: staging works, the ref
42
+ is created by the first commit (CAS `expected=None`).
43
+ - **`verify` is strictly read-only.** Dry-run audits no longer build or write
44
+ tree objects; only `promote` materializes and commits.
45
+ - **Path-prefix matching is component-aware everywhere.** Tree walks, VFS
46
+ listings, and staged overlays now use the same rule as `rm`/`mv`
47
+ (`a/b` matches `a/b` and `a/b/…`, never `a/bc`), so staged and committed
48
+ paths can no longer disagree.
49
+ - **CLI usage errors exit 1**, not 2 (2 is reserved for retryable conflicts).
50
+ Sync endpoint misuse raises `TransferEndpointError` instead of `TypeError`.
51
+ - **`log` shows the full parent DAG** (merged-in commits are no longer
52
+ hidden by a first-parent-only walk).
53
+ - **`restore --path <dir>` restores directory prefixes**, and unknown paths
54
+ fail with exit 3 instead of silently restoring nothing.
55
+ - **Blob reads are hash-verified** (`read_blob`/`cat`/`restore`), and s5cmd
56
+ batch downloads re-hash blobs after transfer; s5cmd failures surface as
57
+ `StorageUnavailableError` (never `CalledProcessError`).
58
+ - **Pruning parser**: `AND` inside quoted literals is no longer a clause
59
+ separator, and binary/INT96 min-max bounds are dropped instead of compared
60
+ in the wrong domain (pruning stays conservative).
61
+ - **GC walks shared subtrees once** (per-tree leaf-reference memo) instead of
62
+ re-walking the tree DAG per commit.
63
+ - **Tree cache eviction** no longer stops at the first pinned entry.
64
+ - **Merge base is the nearest common ancestor.** `merge` used to walk the
65
+ first-parent chain, so merging after a shared commit could report false
66
+ conflicts for files that only one side had touched since the divergence.
67
+ The new walk is generation-ordered over both frontiers and stops at the
68
+ first commit reachable from both sides.
69
+
70
+ ### Changed
71
+
72
+ - **Commits, splices, merges, diffs and prunes touch O(changed paths).**
73
+ - Unchanged directory nodes (and, in sharded directories, unchanged shard
74
+ bodies) are detected by content hash and never written: committing one
75
+ changed file in a 50-directory repository now PUTs 2 tree nodes instead
76
+ of 51. Full commits that change nothing PUT none.
77
+ - Staged adds/removals in a sharded directory rewrite only the shard whose
78
+ name range contains the touched paths (binary search per name), and
79
+ removal pruning tests removal prefixes against shard ranges before
80
+ loading anything.
81
+ - Merging branches that changed different ranges of the same huge
82
+ directory compares shard pointers pairwise and reads no shard bodies at
83
+ all; only ranges that both sides changed are descended into.
84
+ - `identity promote` splices materialized entries into the existing tree
85
+ instead of rebuilding it from a flattened walk.
86
+ - **New or changed worktree files are hashed in parallel** (up to 8 workers;
87
+ blake3 releases the GIL), measured at ~2.5x on a 20k-file ingest.
88
+ - **`trust_mtime` config key** (off by default): reuse a content entry whose
89
+ size *and* `mtime_ns` match the worktree file without re-hashing it. Trade
90
+ -off: a same-size, same-mtime edit is not detected.
91
+ - **`query prune` accepts a footer cache.** Footer stats are
92
+ content-addressed, so repeat scans of the same revision read no footers at
93
+ all.
94
+ - **GC deletes in batches** (`DeleteObjects`, up to 1000 keys per request)
95
+ instead of one request per object.
96
+ - **Analytical index keeps its CSV ingestion.** Benchmarked: 50k rows take
97
+ ~0.3s via the manifest CSV but ~46s via parametrized `INSERT`s (even in 10k
98
+ batches) on the pinned DuckDB, so the intermediate CSV is the fast path,
99
+ not a shortcut.
100
+
101
+ - **`merge` is tree-level and O(changed directories).** It compares
102
+ content-addressed subtree hashes and short-circuits whenever a directory is
103
+ unchanged on one side, so the tree is never flattened: merging two branches
104
+ that each changed one file in a 10k-entry / 400-directory repository costs
105
+ 2 tree reads and 1 tree write (previously every directory was re-walked and
106
+ re-materialized). Conflict rules are unchanged: one-sided changes win,
107
+ delete/modify and file↔directory shape changes conflict with the offending
108
+ paths, and identical add/add is accepted.
109
+ - **`verify`/`promote` are now nested under `reflake identity`** (breaking CLI
110
+ change): `reflake identity verify` (read-only audit; exit 1 while
111
+ unverifiable entries remain) and `reflake identity promote` (materialize
112
+ blobs + promotion commit). The library methods `repo.verify()` /
113
+ `repo.promote()` are unchanged, and the JSON payloads keep their fields.
114
+ - **Transfer planning is adaptive**: small plans probe object existence
115
+ per object; plans above 64 candidates list the destination inventory once
116
+ per object kind (one paginated listing instead of N HEAD requests). Commit
117
+ collection uses the same strategy.
118
+ - **`commit` warns about unverifiable revisions when staged pointer entries
119
+ are committed**, not only when the repository default identity is `pointer`.
120
+ - **Benchmarks are excluded from the default test run** (`pytest -m benchmark`
121
+ to run them); CI runs `-m "not integration and not benchmark"`.
122
+
123
+ ### Removed
124
+
125
+ - Top-level `reflake verify` / `reflake promote` (moved under `identity`).
126
+ - Dead v1-era surface: `ManifestReader`/`ManifestWriter`/`build_manifest_entries`,
127
+ `LocalStorageBackend`/`StorageBackend`, the derived-manifest block index
128
+ (`derived.py`, `lookup_derived_entry`), `merge_sorted_streams`,
129
+ `Entry.from_dict`, `SUPPORTED_IDENTITY_MODES`, `StageStatus.modified`, and
130
+ `TreeCache.pin`/`unpin`.
131
+ - `PLAN_PROGRESS.md` (stale duplicate of `docs/architecture.md`).
132
+ - Stale v1-era `.reflake/` state that had been committed into the source tree
133
+ (`config.json`, refs, staging leftovers). `.reflake/` is now git-ignored:
134
+ runtime state must never be committed.
135
+
9
136
  ## [0.2.0] - 2026-09-08
10
137
 
138
+ > **Deprecated — superseded by 0.2.1.** This release corrupts full commits in
139
+ > directories with more than 10k entries (sharded directories) and can drop
140
+ > parquet footer statistics on `identity promote`. Use 0.2.1 or later.
141
+
11
142
  ### Breaking pre-1.0 cleanup
12
143
 
13
144
  No backcompat is kept for anything below — this is the last window for it.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: reflake
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A client-first, object-storage-first data versioning engine
5
5
  Project-URL: Repository, https://github.com/londogard/reflake
6
6
  Project-URL: Documentation, https://github.com/londogard/reflake#readme
@@ -746,14 +746,15 @@ Reflake separates data into three layers:
746
746
 
747
747
  | Area | Commands |
748
748
  |---|---|
749
- | Ingest | `init`, `add`, `commit [--staged]`, `verify` (audit), `promote` |
749
+ | Ingest | `init`, `add`, `commit [--staged]` |
750
+ | Identity | `identity verify` (read-only audit), `identity promote` (materialize) |
750
751
  | Inspect | `status`, `log`, `diff`, `list` (`ls`), `cat`, `branches`, `reflog` |
751
752
  | Branch | `branch`, `checkout`, `merge` (fast-forward + 3-way metadata merge) |
752
753
  | Mutate | `rm`, `mv`, `gc [--prune]`, `restore` |
753
754
  | Sync | `push`, `pull`, `fetch`, `transfer` |
754
755
  | Analyze | `query build` (DuckDB/Parquet), `query prune` (row-group pruning) |
755
756
 
756
- Exit codes: `0` ok · `1` usage/validation (including `verify` with remaining pointer entries) · `2` conflict, retryable (CAS race, non-fast-forward, merge conflict) · `3` missing ref/object.
757
+ Exit codes: `0` ok · `1` usage/validation (including `identity verify` with remaining pointer entries) · `2` conflict, retryable (CAS race, non-fast-forward, merge conflict) · `3` missing ref/object.
757
758
 
758
759
  ## Guardrails (Strict)
759
760
 
@@ -799,8 +800,8 @@ uv run reflake --repo /tmp/reflake-demo commit -m "initial"
799
800
  # Stage an S3 prefix as pointer entries, then commit the staged additions
800
801
  uv run reflake --repo /tmp/reflake-demo add --identity pointer --as imports/bootstrap s3://my-bucket/bootstrap
801
802
  uv run reflake --repo /tmp/reflake-demo commit --staged -m "metadata import"
802
- uv run reflake --repo /tmp/reflake-demo verify
803
- uv run reflake --repo /tmp/reflake-demo promote
803
+ uv run reflake --repo /tmp/reflake-demo identity verify
804
+ uv run reflake --repo /tmp/reflake-demo identity promote
804
805
 
805
806
  # branch-scoped staged flow
806
807
  uv run reflake --repo /tmp/reflake-demo branch feature
@@ -862,21 +863,23 @@ This is useful for large bootstrap imports where strong content verification can
862
863
 
863
864
  Pointer (`pointer`) revisions are **unverifiable**: the entry's
864
865
  identity is derived from path and size, not from content bytes. Until you run
865
- `reflake promote`, Reflake cannot prove that the content at `source_uri` matches
866
- what was originally imported.
866
+ `reflake identity promote`, Reflake cannot prove that the content at
867
+ `source_uri` matches what was originally imported.
867
868
 
868
869
  **Warnings.** The CLI emits a warning to stderr whenever you stage with
869
870
  `--identity pointer` or commit a repository whose identity is configured to `pointer`,
870
- and `verify` reports how many unverifiable entries remain (exiting non-zero).
871
+ and `identity verify` reports how many unverifiable entries remain (exiting
872
+ non-zero).
871
873
 
872
874
  **Source-retention policy.** Because pointer entries have no canonical
873
875
  blob, you **must** retain the source objects at their original `source_uri`
874
- until the entry has been promoted via `reflake promote`. If a source object is
876
+ until the entry has been promoted via `reflake identity promote`. If a source
877
+ object is
875
878
  deleted, overwritten, or moved before promotion, the corresponding
876
879
  entry becomes irrecoverable — no content can be read and no hash can be
877
880
  validated.
878
881
 
879
- **Promotion to verifiable.** Run `reflake promote` to read every pointer
882
+ **Promotion to verifiable.** Run `reflake identity promote` to read every pointer
880
883
  entry's source blob, compute a content hash, store the canonical blob,
881
884
  and rewrite the entry in `content` mode. After promotion the source
882
885
  retention requirement is lifted for those entries.
@@ -888,20 +891,26 @@ retention requirement is lifted for those entries.
888
891
  | Pointer | `pointer` | `null` | ✅ (from `source_uri`) | ❌ | ✅ |
889
892
  | Verified | `content` | hash | ✅ (from `blobs/`) | ✅ | ❌ |
890
893
 
891
- ## Verify And Promote Commands
894
+ ## Identity: Audit And Promotion
892
895
 
893
- `reflake verify` is a read-only audit: it reports how many pointer entries of the current branch would be promoted, and exits non-zero while any remain:
896
+ Entry identity has two modes (`content` / `pointer`), so both commands that
897
+ reason about it live under `reflake identity`.
898
+
899
+ `reflake identity verify` is a read-only audit: it reports how many pointer
900
+ entries of the current branch would be promoted, and exits non-zero while any
901
+ remain:
894
902
 
895
903
  ```bash
896
- uv run reflake --repo /tmp/reflake-demo verify
897
- uv run reflake --repo /tmp/reflake-demo verify --path images --path logs/2026
904
+ uv run reflake --repo /tmp/reflake-demo identity verify
905
+ uv run reflake --repo /tmp/reflake-demo identity verify --path images --path logs/2026
898
906
  ```
899
907
 
900
- `reflake promote` materializes canonical blobs and writes a promotion commit (only when at least one entry is promoted):
908
+ `reflake identity promote` materializes canonical blobs and writes a promotion
909
+ commit (only when at least one entry is promoted):
901
910
 
902
911
  ```bash
903
- uv run reflake --repo /tmp/reflake-demo promote
904
- uv run reflake --repo /tmp/reflake-demo promote --path images --path logs/2026
912
+ uv run reflake --repo /tmp/reflake-demo identity promote
913
+ uv run reflake --repo /tmp/reflake-demo identity promote --path images --path logs/2026
905
914
  ```
906
915
 
907
916
  - Both audit all entries by default (or selected path prefixes with `--path`).
@@ -916,12 +925,12 @@ uv run reflake --repo /tmp/reflake-demo add --as imports/new-batch /tmp/random/n
916
925
  uv run reflake --repo /tmp/reflake-demo add --identity pointer --as imports/bootstrap.csv s3://my-bucket/bootstrap.csv
917
926
  uv run reflake --repo /tmp/reflake-demo add --identity pointer --as imports/bootstrap s3://my-bucket/bootstrap
918
927
  uv run reflake --repo /tmp/reflake-demo commit --staged -m "add one file"
919
- uv run reflake --repo /tmp/reflake-demo promote --path images --path root.txt
928
+ uv run reflake --repo /tmp/reflake-demo identity promote --path images --path root.txt
920
929
  ```
921
930
 
922
931
  - `add` + `commit --staged` preserves the current branch manifest and reads bytes only for staged additions.
923
932
  - `add` accepts repo-relative files, arbitrary local files, local directories, single S3 objects, and S3 prefixes; `--as` maps a single file/object to one logical path or remaps a directory/prefix under a destination prefix.
924
- - `promote` reads bytes only for selected pointer entries that still need canonical blobs.
933
+ - `identity promote` reads bytes only for selected pointer entries that still need canonical blobs.
925
934
  - Existing entries are preserved without re-uploading unchanged blob content.
926
935
 
927
936
  ## Merge Command
@@ -952,6 +961,33 @@ uv run reflake --repo /tmp/reflake-demo commit --staged -m "remove old logs and
952
961
  - `mv` accepts a file path or prefix and rewrites matching logical paths.
953
962
  - `reflake status` shows staged removals and renames before `reflake commit --staged`.
954
963
 
964
+ ## Commits, Deletions, And Branch Switching
965
+
966
+ A full `commit` treats the working tree as an **overlay** on the committed tree:
967
+ files present on disk join the commit, and committed entries stay in the
968
+ commit even if the file is missing locally. Deletion is never inferred from
969
+ the filesystem — it is an explicit metadata operation:
970
+
971
+ ```bash
972
+ uv run reflake --repo /tmp/reflake-demo rm old-prefix # stage the removal
973
+ uv run reflake --repo /tmp/reflake-demo commit --staged -m "drop old-prefix"
974
+ ```
975
+
976
+ This is deliberate (an S3-first engine cannot know whether a missing local
977
+ file means "deleted" or "never materialized"), which is why `reflake status`
978
+ compares the working tree against the committed tree: you see exactly what a
979
+ commit would add or change, and stage removals for everything else.
980
+
981
+ Symlinks are neither followed nor stored: the worktree walk skips them (it
982
+ never escapes the repository root). Store the target's bytes, or stage the
983
+ external file explicitly with `add --as`.
984
+
985
+ `reflake checkout <branch>` only **points the client at another branch**
986
+ (`refs/HEAD`); it never rewrites the working tree. Materializing data is an
987
+ explicit, separate step: `restore <ref>` (optionally `--path <dir>`), `pull`,
988
+ `cat`, or the read-only VFS. Files are only ever downloaded because you asked
989
+ for them.
990
+
955
991
  ## Sync (push/pull/fetch)
956
992
 
957
993
  ```bash
@@ -961,6 +997,7 @@ uv run reflake --repo . fetch s3://my-bucket/datasets/demo
961
997
  ```
962
998
 
963
999
  - Objects transfer plan-first: the exact missing set (commits, trees, footers, blobs) is computed, then executed via `boto3` per-object or batched through [`s5cmd`](https://github.com/peak/s5cmd) when configured (`config set transfer_backend s5cmd`).
1000
+ - Planning is adaptive: small plans probe object existence one by one; plans over ~64 objects list the destination's object ids once per kind instead of issuing N HEAD requests.
964
1001
  - Divergent history is rejected before any bytes move (`NonFastForwardError`); the final ref update is a CAS, so concurrent pushes surface conflicts instead of overwriting.
965
1002
  - Push after a local merge transfers the entire merged lineage, including both parents' commits.
966
1003
  - S3-compatible endpoints (MinIO, Ministack, …) configured via `reflake init --backend s3 --s3-endpoint …` (or `config set s3.endpoint_url …`) are honored for repository operations; direct `s3://` remotes use the ambient AWS configuration chain.
@@ -987,6 +1024,33 @@ With `config set parquet_footer true`, parquet ingests also capture compact foot
987
1024
  uv run reflake --repo /tmp/reflake-demo query prune <ref> images/ --where "id >= 100 AND active = true"
988
1025
  ```
989
1026
 
1027
+ `query prune` reuses a footer cache inside the index directory: footers are
1028
+ content-addressed, so scanning the same revision twice reads nothing further.
1029
+ Stats survive `identity promote` — promoting an `mp` entry yields `bp`, never a
1030
+ statless plain blob.
1031
+
1032
+ ## Commit Cost Model
1033
+
1034
+ Commits, splices, merges, diffs and prunes are proportional to what changed,
1035
+ not to the size of the tree:
1036
+
1037
+ - Tree nodes are content-addressed and written with `IfNoneMatch`: unchanged
1038
+ directories (and, inside sharded directories, unchanged shard bodies) are
1039
+ detected by hash and never re-written. Committing one changed file in a
1040
+ 50-directory repository puts 2 tree objects; a full commit that changes
1041
+ nothing puts none.
1042
+ - Directories above 10k entries are stored as name-range shards. A staged
1043
+ add or removal rewrites only the shard whose range contains the touched
1044
+ paths (binary search per name), and merges compare shard pointers pairwise,
1045
+ reading shard bodies only where both sides changed the same range.
1046
+ - New or changed worktree files are hashed in parallel (up to 8 workers;
1047
+ blake3 releases the GIL).
1048
+ - With `config set trust_mtime true`, a worktree file whose size *and*
1049
+ `mtime_ns` match the committed entry is reused without hashing. Trade-off:
1050
+ a same-size, same-mtime edit is not detected — off by default.
1051
+ - GC issues batched `DeleteObjects` calls (up to 1000 keys each) instead of
1052
+ one request per object.
1053
+
990
1054
  ## `fsspec` URI Example
991
1055
 
992
1056
  ```python
@@ -1013,8 +1077,8 @@ repo = open_repository("/tmp/reflake-demo") # fails unless initialized
1013
1077
  repo = open_repository("s3://my-bucket/datasets/demo") # remote (lazy)
1014
1078
 
1015
1079
  commit_id = repo.commit("snapshot")
1016
- repo.verify() # read-only audit of pointer entries
1017
- repo.promote() # materialize blobs + commit
1080
+ repo.verify() # read-only audit of pointer entries (CLI: identity verify)
1081
+ repo.promote() # materialize blobs + commit (CLI: identity promote)
1018
1082
  repo.merge("feature", "main")
1019
1083
  ```
1020
1084
 
@@ -1025,7 +1089,8 @@ Public, stable surface (everything else is internal and may change):
1025
1089
  - reads: `ReflakeFileSystem`, `ReflakeURI`
1026
1090
  - sync: `push`, `pull`, `fetch`
1027
1091
  - errors: `ReflakeError` and subclasses (`RefConflictError`,
1028
- `NonFastForwardError`, `UnknownRefError`, …)
1092
+ `NonFastForwardError`, `UnknownRefError`, `BlobIntegrityError`,
1093
+ `TransferEndpointError`, …)
1029
1094
 
1030
1095
  `core.services`, `core.objects`, `core.query` internals and the store
1031
1096
  protocols are not covered by stability guarantees. Read paths (`diff`,
@@ -1053,23 +1118,27 @@ guaranteed to stay in sync because both derive from that single mapping.
1053
1118
 
1054
1119
  There are no locks. Every shared mutation goes through compare-and-swap:
1055
1120
 
1056
- - Local repos use version tokens (mtime+size) checked before writing.
1121
+ - Local repos serialise CAS through an OS file lock (`flock`/`msvcrt`) and write atomically (temp file + rename).
1057
1122
  - S3 repos use conditional `PutObject` (`IfMatch`/`IfNoneMatch`) so the check-and-write is atomic server-side.
1058
1123
  - `commit --staged` re-applies its overlay onto the new parent and retries on conflict; other mutations surface `RefConflictError` with both commit ids.
1124
+ - Opening a repository never mutates it: a branch with no ref yet is *unborn* (staging works, the first `commit` creates the ref).
1059
1125
 
1060
1126
  ## Mandatory Validation Coverage
1061
1127
 
1062
1128
  Current tests cover required invariants:
1063
1129
 
1064
- - Metadata-only diff reads no blob payloads.
1065
- - Manifest generation for 100k entries stays under RAM cap.
1130
+ - Metadata-only diff, remove, and move read no blob payloads; `identity verify` (dry run) writes no objects at all.
1131
+ - Sharded directories (>10k entries) survive full commits without duplicate or lost entries.
1132
+ - Build a 100k-entry tree under a RAM cap (benchmark, see below).
1066
1133
  - `reflake://my_data@main/test.csv` resolves and returns expected bytes.
1067
- - Staged commits stay correct regardless of path sort order; merged lineages survive push/pull.
1134
+ - Staged commits stay correct regardless of path sort order; merged lineages survive push/pull; blob reads are hash-verified.
1068
1135
 
1069
- Run test suite:
1136
+ Run the test suite:
1070
1137
 
1071
1138
  ```bash
1072
- uv run pytest tests
1139
+ uv run pytest tests # fast suite (benchmarks excluded)
1140
+ uv run pytest tests -m benchmark # wall-clock/memory benchmarks
1141
+ uv run pytest tests -m integration # needs a real S3 endpoint (see below)
1073
1142
  ```
1074
1143
 
1075
1144
  ## S3 Integration Tests
@@ -53,14 +53,15 @@ Reflake separates data into three layers:
53
53
 
54
54
  | Area | Commands |
55
55
  |---|---|
56
- | Ingest | `init`, `add`, `commit [--staged]`, `verify` (audit), `promote` |
56
+ | Ingest | `init`, `add`, `commit [--staged]` |
57
+ | Identity | `identity verify` (read-only audit), `identity promote` (materialize) |
57
58
  | Inspect | `status`, `log`, `diff`, `list` (`ls`), `cat`, `branches`, `reflog` |
58
59
  | Branch | `branch`, `checkout`, `merge` (fast-forward + 3-way metadata merge) |
59
60
  | Mutate | `rm`, `mv`, `gc [--prune]`, `restore` |
60
61
  | Sync | `push`, `pull`, `fetch`, `transfer` |
61
62
  | Analyze | `query build` (DuckDB/Parquet), `query prune` (row-group pruning) |
62
63
 
63
- Exit codes: `0` ok · `1` usage/validation (including `verify` with remaining pointer entries) · `2` conflict, retryable (CAS race, non-fast-forward, merge conflict) · `3` missing ref/object.
64
+ Exit codes: `0` ok · `1` usage/validation (including `identity verify` with remaining pointer entries) · `2` conflict, retryable (CAS race, non-fast-forward, merge conflict) · `3` missing ref/object.
64
65
 
65
66
  ## Guardrails (Strict)
66
67
 
@@ -106,8 +107,8 @@ uv run reflake --repo /tmp/reflake-demo commit -m "initial"
106
107
  # Stage an S3 prefix as pointer entries, then commit the staged additions
107
108
  uv run reflake --repo /tmp/reflake-demo add --identity pointer --as imports/bootstrap s3://my-bucket/bootstrap
108
109
  uv run reflake --repo /tmp/reflake-demo commit --staged -m "metadata import"
109
- uv run reflake --repo /tmp/reflake-demo verify
110
- uv run reflake --repo /tmp/reflake-demo promote
110
+ uv run reflake --repo /tmp/reflake-demo identity verify
111
+ uv run reflake --repo /tmp/reflake-demo identity promote
111
112
 
112
113
  # branch-scoped staged flow
113
114
  uv run reflake --repo /tmp/reflake-demo branch feature
@@ -169,21 +170,23 @@ This is useful for large bootstrap imports where strong content verification can
169
170
 
170
171
  Pointer (`pointer`) revisions are **unverifiable**: the entry's
171
172
  identity is derived from path and size, not from content bytes. Until you run
172
- `reflake promote`, Reflake cannot prove that the content at `source_uri` matches
173
- what was originally imported.
173
+ `reflake identity promote`, Reflake cannot prove that the content at
174
+ `source_uri` matches what was originally imported.
174
175
 
175
176
  **Warnings.** The CLI emits a warning to stderr whenever you stage with
176
177
  `--identity pointer` or commit a repository whose identity is configured to `pointer`,
177
- and `verify` reports how many unverifiable entries remain (exiting non-zero).
178
+ and `identity verify` reports how many unverifiable entries remain (exiting
179
+ non-zero).
178
180
 
179
181
  **Source-retention policy.** Because pointer entries have no canonical
180
182
  blob, you **must** retain the source objects at their original `source_uri`
181
- until the entry has been promoted via `reflake promote`. If a source object is
183
+ until the entry has been promoted via `reflake identity promote`. If a source
184
+ object is
182
185
  deleted, overwritten, or moved before promotion, the corresponding
183
186
  entry becomes irrecoverable — no content can be read and no hash can be
184
187
  validated.
185
188
 
186
- **Promotion to verifiable.** Run `reflake promote` to read every pointer
189
+ **Promotion to verifiable.** Run `reflake identity promote` to read every pointer
187
190
  entry's source blob, compute a content hash, store the canonical blob,
188
191
  and rewrite the entry in `content` mode. After promotion the source
189
192
  retention requirement is lifted for those entries.
@@ -195,20 +198,26 @@ retention requirement is lifted for those entries.
195
198
  | Pointer | `pointer` | `null` | ✅ (from `source_uri`) | ❌ | ✅ |
196
199
  | Verified | `content` | hash | ✅ (from `blobs/`) | ✅ | ❌ |
197
200
 
198
- ## Verify And Promote Commands
201
+ ## Identity: Audit And Promotion
199
202
 
200
- `reflake verify` is a read-only audit: it reports how many pointer entries of the current branch would be promoted, and exits non-zero while any remain:
203
+ Entry identity has two modes (`content` / `pointer`), so both commands that
204
+ reason about it live under `reflake identity`.
205
+
206
+ `reflake identity verify` is a read-only audit: it reports how many pointer
207
+ entries of the current branch would be promoted, and exits non-zero while any
208
+ remain:
201
209
 
202
210
  ```bash
203
- uv run reflake --repo /tmp/reflake-demo verify
204
- uv run reflake --repo /tmp/reflake-demo verify --path images --path logs/2026
211
+ uv run reflake --repo /tmp/reflake-demo identity verify
212
+ uv run reflake --repo /tmp/reflake-demo identity verify --path images --path logs/2026
205
213
  ```
206
214
 
207
- `reflake promote` materializes canonical blobs and writes a promotion commit (only when at least one entry is promoted):
215
+ `reflake identity promote` materializes canonical blobs and writes a promotion
216
+ commit (only when at least one entry is promoted):
208
217
 
209
218
  ```bash
210
- uv run reflake --repo /tmp/reflake-demo promote
211
- uv run reflake --repo /tmp/reflake-demo promote --path images --path logs/2026
219
+ uv run reflake --repo /tmp/reflake-demo identity promote
220
+ uv run reflake --repo /tmp/reflake-demo identity promote --path images --path logs/2026
212
221
  ```
213
222
 
214
223
  - Both audit all entries by default (or selected path prefixes with `--path`).
@@ -223,12 +232,12 @@ uv run reflake --repo /tmp/reflake-demo add --as imports/new-batch /tmp/random/n
223
232
  uv run reflake --repo /tmp/reflake-demo add --identity pointer --as imports/bootstrap.csv s3://my-bucket/bootstrap.csv
224
233
  uv run reflake --repo /tmp/reflake-demo add --identity pointer --as imports/bootstrap s3://my-bucket/bootstrap
225
234
  uv run reflake --repo /tmp/reflake-demo commit --staged -m "add one file"
226
- uv run reflake --repo /tmp/reflake-demo promote --path images --path root.txt
235
+ uv run reflake --repo /tmp/reflake-demo identity promote --path images --path root.txt
227
236
  ```
228
237
 
229
238
  - `add` + `commit --staged` preserves the current branch manifest and reads bytes only for staged additions.
230
239
  - `add` accepts repo-relative files, arbitrary local files, local directories, single S3 objects, and S3 prefixes; `--as` maps a single file/object to one logical path or remaps a directory/prefix under a destination prefix.
231
- - `promote` reads bytes only for selected pointer entries that still need canonical blobs.
240
+ - `identity promote` reads bytes only for selected pointer entries that still need canonical blobs.
232
241
  - Existing entries are preserved without re-uploading unchanged blob content.
233
242
 
234
243
  ## Merge Command
@@ -259,6 +268,33 @@ uv run reflake --repo /tmp/reflake-demo commit --staged -m "remove old logs and
259
268
  - `mv` accepts a file path or prefix and rewrites matching logical paths.
260
269
  - `reflake status` shows staged removals and renames before `reflake commit --staged`.
261
270
 
271
+ ## Commits, Deletions, And Branch Switching
272
+
273
+ A full `commit` treats the working tree as an **overlay** on the committed tree:
274
+ files present on disk join the commit, and committed entries stay in the
275
+ commit even if the file is missing locally. Deletion is never inferred from
276
+ the filesystem — it is an explicit metadata operation:
277
+
278
+ ```bash
279
+ uv run reflake --repo /tmp/reflake-demo rm old-prefix # stage the removal
280
+ uv run reflake --repo /tmp/reflake-demo commit --staged -m "drop old-prefix"
281
+ ```
282
+
283
+ This is deliberate (an S3-first engine cannot know whether a missing local
284
+ file means "deleted" or "never materialized"), which is why `reflake status`
285
+ compares the working tree against the committed tree: you see exactly what a
286
+ commit would add or change, and stage removals for everything else.
287
+
288
+ Symlinks are neither followed nor stored: the worktree walk skips them (it
289
+ never escapes the repository root). Store the target's bytes, or stage the
290
+ external file explicitly with `add --as`.
291
+
292
+ `reflake checkout <branch>` only **points the client at another branch**
293
+ (`refs/HEAD`); it never rewrites the working tree. Materializing data is an
294
+ explicit, separate step: `restore <ref>` (optionally `--path <dir>`), `pull`,
295
+ `cat`, or the read-only VFS. Files are only ever downloaded because you asked
296
+ for them.
297
+
262
298
  ## Sync (push/pull/fetch)
263
299
 
264
300
  ```bash
@@ -268,6 +304,7 @@ uv run reflake --repo . fetch s3://my-bucket/datasets/demo
268
304
  ```
269
305
 
270
306
  - Objects transfer plan-first: the exact missing set (commits, trees, footers, blobs) is computed, then executed via `boto3` per-object or batched through [`s5cmd`](https://github.com/peak/s5cmd) when configured (`config set transfer_backend s5cmd`).
307
+ - Planning is adaptive: small plans probe object existence one by one; plans over ~64 objects list the destination's object ids once per kind instead of issuing N HEAD requests.
271
308
  - Divergent history is rejected before any bytes move (`NonFastForwardError`); the final ref update is a CAS, so concurrent pushes surface conflicts instead of overwriting.
272
309
  - Push after a local merge transfers the entire merged lineage, including both parents' commits.
273
310
  - S3-compatible endpoints (MinIO, Ministack, …) configured via `reflake init --backend s3 --s3-endpoint …` (or `config set s3.endpoint_url …`) are honored for repository operations; direct `s3://` remotes use the ambient AWS configuration chain.
@@ -294,6 +331,33 @@ With `config set parquet_footer true`, parquet ingests also capture compact foot
294
331
  uv run reflake --repo /tmp/reflake-demo query prune <ref> images/ --where "id >= 100 AND active = true"
295
332
  ```
296
333
 
334
+ `query prune` reuses a footer cache inside the index directory: footers are
335
+ content-addressed, so scanning the same revision twice reads nothing further.
336
+ Stats survive `identity promote` — promoting an `mp` entry yields `bp`, never a
337
+ statless plain blob.
338
+
339
+ ## Commit Cost Model
340
+
341
+ Commits, splices, merges, diffs and prunes are proportional to what changed,
342
+ not to the size of the tree:
343
+
344
+ - Tree nodes are content-addressed and written with `IfNoneMatch`: unchanged
345
+ directories (and, inside sharded directories, unchanged shard bodies) are
346
+ detected by hash and never re-written. Committing one changed file in a
347
+ 50-directory repository puts 2 tree objects; a full commit that changes
348
+ nothing puts none.
349
+ - Directories above 10k entries are stored as name-range shards. A staged
350
+ add or removal rewrites only the shard whose range contains the touched
351
+ paths (binary search per name), and merges compare shard pointers pairwise,
352
+ reading shard bodies only where both sides changed the same range.
353
+ - New or changed worktree files are hashed in parallel (up to 8 workers;
354
+ blake3 releases the GIL).
355
+ - With `config set trust_mtime true`, a worktree file whose size *and*
356
+ `mtime_ns` match the committed entry is reused without hashing. Trade-off:
357
+ a same-size, same-mtime edit is not detected — off by default.
358
+ - GC issues batched `DeleteObjects` calls (up to 1000 keys each) instead of
359
+ one request per object.
360
+
297
361
  ## `fsspec` URI Example
298
362
 
299
363
  ```python
@@ -320,8 +384,8 @@ repo = open_repository("/tmp/reflake-demo") # fails unless initialized
320
384
  repo = open_repository("s3://my-bucket/datasets/demo") # remote (lazy)
321
385
 
322
386
  commit_id = repo.commit("snapshot")
323
- repo.verify() # read-only audit of pointer entries
324
- repo.promote() # materialize blobs + commit
387
+ repo.verify() # read-only audit of pointer entries (CLI: identity verify)
388
+ repo.promote() # materialize blobs + commit (CLI: identity promote)
325
389
  repo.merge("feature", "main")
326
390
  ```
327
391
 
@@ -332,7 +396,8 @@ Public, stable surface (everything else is internal and may change):
332
396
  - reads: `ReflakeFileSystem`, `ReflakeURI`
333
397
  - sync: `push`, `pull`, `fetch`
334
398
  - errors: `ReflakeError` and subclasses (`RefConflictError`,
335
- `NonFastForwardError`, `UnknownRefError`, …)
399
+ `NonFastForwardError`, `UnknownRefError`, `BlobIntegrityError`,
400
+ `TransferEndpointError`, …)
336
401
 
337
402
  `core.services`, `core.objects`, `core.query` internals and the store
338
403
  protocols are not covered by stability guarantees. Read paths (`diff`,
@@ -360,23 +425,27 @@ guaranteed to stay in sync because both derive from that single mapping.
360
425
 
361
426
  There are no locks. Every shared mutation goes through compare-and-swap:
362
427
 
363
- - Local repos use version tokens (mtime+size) checked before writing.
428
+ - Local repos serialise CAS through an OS file lock (`flock`/`msvcrt`) and write atomically (temp file + rename).
364
429
  - S3 repos use conditional `PutObject` (`IfMatch`/`IfNoneMatch`) so the check-and-write is atomic server-side.
365
430
  - `commit --staged` re-applies its overlay onto the new parent and retries on conflict; other mutations surface `RefConflictError` with both commit ids.
431
+ - Opening a repository never mutates it: a branch with no ref yet is *unborn* (staging works, the first `commit` creates the ref).
366
432
 
367
433
  ## Mandatory Validation Coverage
368
434
 
369
435
  Current tests cover required invariants:
370
436
 
371
- - Metadata-only diff reads no blob payloads.
372
- - Manifest generation for 100k entries stays under RAM cap.
437
+ - Metadata-only diff, remove, and move read no blob payloads; `identity verify` (dry run) writes no objects at all.
438
+ - Sharded directories (>10k entries) survive full commits without duplicate or lost entries.
439
+ - Build a 100k-entry tree under a RAM cap (benchmark, see below).
373
440
  - `reflake://my_data@main/test.csv` resolves and returns expected bytes.
374
- - Staged commits stay correct regardless of path sort order; merged lineages survive push/pull.
441
+ - Staged commits stay correct regardless of path sort order; merged lineages survive push/pull; blob reads are hash-verified.
375
442
 
376
- Run test suite:
443
+ Run the test suite:
377
444
 
378
445
  ```bash
379
- uv run pytest tests
446
+ uv run pytest tests # fast suite (benchmarks excluded)
447
+ uv run pytest tests -m benchmark # wall-clock/memory benchmarks
448
+ uv run pytest tests -m integration # needs a real S3 endpoint (see below)
380
449
  ```
381
450
 
382
451
  ## S3 Integration Tests
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "reflake"
3
- version = "0.2.0"
3
+ version = "0.2.1"
4
4
  description = "A client-first, object-storage-first data versioning engine"
5
5
  readme = "README.md"
6
6
  authors = [{ name = "Hampus Londögård", email = "hampus.londogard@gmail.com" }]
@@ -73,6 +73,11 @@ project-includes = ["src/reflake"]
73
73
  project-excludes = ["tests/"]
74
74
 
75
75
  [tool.pytest.ini_options]
76
+ # Benchmarks (wall-clock/memory asserts) are excluded from the default run:
77
+ # they are environment-sensitive and would make CI flaky. Run them explicitly
78
+ # with `uv run pytest -m benchmark` (or combine with integration tests).
79
+ addopts = "-m 'not benchmark'"
76
80
  markers = [
77
81
  "integration: tests that require a real S3-compatible service such as Ministack",
82
+ "benchmark: wall-clock or memory benchmarks (excluded unless selected)",
78
83
  ]