reflake 0.2.1__tar.gz → 0.3.0__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 (47) hide show
  1. {reflake-0.2.1 → reflake-0.3.0}/CHANGELOG.md +124 -0
  2. {reflake-0.2.1 → reflake-0.3.0}/PKG-INFO +109 -14
  3. {reflake-0.2.1 → reflake-0.3.0}/README.md +108 -13
  4. {reflake-0.2.1 → reflake-0.3.0}/pyproject.toml +1 -1
  5. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/__init__.py +68 -87
  6. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/cli.py +256 -25
  7. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/__init__.py +8 -0
  8. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/client_state.py +14 -4
  9. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/config.py +4 -0
  10. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/domain/__init__.py +6 -0
  11. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/domain/errors.py +17 -0
  12. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/domain/models.py +25 -1
  13. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/entry_codec.py +59 -14
  14. reflake-0.3.0/src/reflake/core/ignore.py +111 -0
  15. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/layout.py +11 -0
  16. reflake-0.3.0/src/reflake/core/manifest.py +70 -0
  17. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/objects/__init__.py +4 -0
  18. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/objects/backends.py +2 -0
  19. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/objects/base.py +28 -7
  20. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/objects/local.py +57 -4
  21. reflake-0.3.0/src/reflake/core/objects/multipart.py +187 -0
  22. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/objects/s3.py +93 -29
  23. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/objects/source.py +55 -2
  24. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/objects/transfer.py +2 -6
  25. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/objects/tree.py +36 -0
  26. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/repository.py +159 -25
  27. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/repository_ops.py +164 -8
  28. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/repository_support.py +64 -4
  29. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/repository_sync.py +24 -13
  30. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/services/entries.py +18 -7
  31. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/services/refs.py +75 -14
  32. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/services/staging.py +27 -9
  33. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/services/tree.py +70 -4
  34. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/services/tree_inspect.py +11 -2
  35. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/vfs/__init__.py +8 -2
  36. reflake-0.2.1/src/reflake/core/manifest.py +0 -47
  37. {reflake-0.2.1 → reflake-0.3.0}/.gitignore +0 -0
  38. {reflake-0.2.1 → reflake-0.3.0}/LICENSE +0 -0
  39. {reflake-0.2.1 → reflake-0.3.0}/NOTICE +0 -0
  40. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/hashing.py +0 -0
  41. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/objects/footer.py +0 -0
  42. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/objects/query.py +0 -0
  43. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/query/__init__.py +0 -0
  44. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/query/catalog.py +0 -0
  45. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/query/pruning.py +0 -0
  46. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/core/services/__init__.py +0 -0
  47. {reflake-0.2.1 → reflake-0.3.0}/src/reflake/py.typed +0 -0
@@ -6,6 +6,130 @@ The format is based on Keep a Changelog, and Reflake currently tracks changes be
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## [0.3.0] - 2026-09-24
10
+
11
+ ### Added
12
+
13
+ - **Invariant fuzz test** (`tests/test_invariants.py`): randomized sequences of
14
+ commit / staged add / rm / mv / reset / branch / merge with tree sharding
15
+ forced on; after every step it asserts that every reachable commit and tree
16
+ parses, is duplicate-free, and references only existing objects. It found
17
+ the branch-namespace collision fixed below on its first run.
18
+ - **`scripts/profile_gc.py`**: GC benchmark harness (orphan-heavy and
19
+ reachable-heavy modes, optional tracemalloc live/peak accounting).
20
+ - **Nightly benchmark job** in CI (`schedule` + `workflow_dispatch`, excluded
21
+ from PR runs); the S3 integration job already runs on every push/PR.
22
+ - **`reflake reset <ref>`** — move a branch pointer to any existing commit or
23
+ ref (undo/redo) with a compare-and-set, without touching the worktree.
24
+ Staged changes survive (with a warning); every move lands in the reflog.
25
+ Library: `ReflakeRepository.reset()` returning `ResetResult`.
26
+ - **`reflake branch -d/--delete <name>`** — delete a branch by CAS-ing its ref
27
+ to unborn; the name can be re-created afterwards. Deleting the current
28
+ branch is refused.
29
+ - **Hierarchical branch names** (`feature/nightly-ingest`). Client-state
30
+ filenames encode the name (`feature%2Fx`), local ref listing recurses, and
31
+ the new validator rejects empty/`.`/`..`/leading-dot/consecutive-dot
32
+ segments.
33
+ - **`identity verify --drift`** — metadata-only drift detection for pointer
34
+ entries: one HEAD per entry, never a source byte read. Pointer entries
35
+ imported from S3 now record the source ETag (optional trailing field on
36
+ `m`/`mp` tree lines), and drift compares size + ETag (or last-modified for
37
+ local-file sources).
38
+ - **`--ref <branch>` for `identity verify` / `identity promote`**, so a shared
39
+ branch can be audited without changing the client's current branch.
40
+ - **Ignore rules**: worktree walks skip `.reflake/` and `.git/` by default and
41
+ honor `.reflakeignore` (comments, `!` re-include, directory patterns,
42
+ `*`/`?`/`**`, anchored patterns). Explicitly named paths are always staged.
43
+ - **GC grace window**: `gc --prune` never deletes objects younger than
44
+ `gc_grace_seconds` (config, default 24h; `--grace-seconds` overrides),
45
+ closing the mark-and-sweep race with a writer that has published objects
46
+ but not yet CAS'd its ref. Unknown ages are treated as young; the CLI and
47
+ JSON report `skipped_young`.
48
+ - **Multipart uploads and streaming downloads** for large blobs (64 MiB
49
+ threshold): files are never buffered whole, the 5 GiB single-PUT ceiling is
50
+ gone, and stream uploads verify the content hash *before* completing the
51
+ upload (a mismatch aborts).
52
+ - **`restore` streams and verifies**: blobs are hashed while streaming into a
53
+ temp file and renamed into place only when the digest matches.
54
+ - `--json` support for `branch`, `checkout`, `init`, `config`, `restore`,
55
+ `reset`, and `transfer` (all structured commands are now covered).
56
+ - New domain errors `SourceNotFoundError` (missing source input) and
57
+ `CorruptCommitError` (unparseable commit object).
58
+
59
+ ### Changed
60
+
61
+ - **The GC sweep is streaming and bounded.** `gc` accepts an `inventory`
62
+ existence source (`ObjectInventory`, defaulting to the repository store —
63
+ the seam a future S3 Inventory adapter plugs into), tests membership
64
+ against the reachable sets *as it lists*, and deletes in ≤1000-key batches
65
+ on the way through. There is no `dict(stored)`/`set(stored)` copy and no
66
+ per-subtree leaf-ref memo any more: leaf references are harvested once per
67
+ unique tree node, so memory is proportional to the reachable sets, not to
68
+ the store listing or to `files × depth`.
69
+ - Sweeps are idempotent and re-runnable: there is no cursor state to corrupt,
70
+ and an entry a crashed sweep skipped is found by the next one. Leaking
71
+ garbage is allowed; deleting live data never is.
72
+ - Local blob shards are snapshotted per directory while listing so deleting
73
+ during iteration cannot skip siblings; emptied shard directories are
74
+ removed best-effort.
75
+ - Sync planning (`push`/`pull`) walks the tree DAG once per unique node
76
+ (shared seen set) instead of re-walking it per commit.
77
+ - **A missing *source* now exits 1 (validation), not 3** — exit 3 is reserved
78
+ for missing repository refs/objects; the runbook and README say so.
79
+ - **Tree nodes are validated before they are written** (sorted, duplicate-free,
80
+ single-component names): an invalid node can no longer be published and
81
+ poisoned by a ref, the second shard-class corruption bug this guards
82
+ against.
83
+ - `mv` refuses a destination whose parent path is a file, instead of
84
+ silently replacing that leaf; staging a path and a path below it (`a` and
85
+ `a/b`) is rejected at `add`.
86
+ - Staged local sources record size + mtime; `commit` warns when a staged
87
+ source changed before the commit (staging is a recipe — the commit contains
88
+ commit-time bytes).
89
+ - Ancestor checks, merge-base, `log` ordering and sync sorting derive
90
+ generations for commits that predate the `generation` field instead of
91
+ treating "missing" as zero.
92
+ - S3 source access (`add s3://…`, pointer reads/promotes) reuses the S3-backed
93
+ repository's configured client/endpoint instead of building a default
94
+ client.
95
+ - Tree caches are shared per store (one parsed copy per tree object per
96
+ process instead of four independent caches).
97
+ - Interrupted multipart uploads are aborted (no orphaned parts).
98
+
99
+ ### Fixed
100
+
101
+ - **Staged splice corruption (P0): a staged directory (or `mv`) landing on a
102
+ committed leaf wrote a node with two entries of the same name.** The commit
103
+ succeeded and the branch head became unparseable for every reader. Both
104
+ shape-change directions now replace correctly, and the new write-time
105
+ validation turns any future occurrence into a loud error before the ref
106
+ moves.
107
+ - **S3 GC could never see blobs or commits.** Empty object ids built listing
108
+ prefixes through `blob_relpath()`/`""`, producing `blobs/.` and
109
+ `commits/.json` — prefixes that match nothing. `gc --prune` on S3 silently
110
+ reported zero blob/commit orphans, and large sync plans treated every
111
+ existing blob as missing (re-upload attempts that `IfNoneMatch` then
112
+ discarded). Empty ids now yield clean directory prefixes (`blobs/`,
113
+ `commits/`, …), with a regression test.
114
+ - **Branch namespace collisions.** Creating `feature` next to `feature/x`
115
+ crashed with `IsADirectoryError` on local repositories (reading a ref path
116
+ that is a directory) and was silently permitted on S3, diverging the two
117
+ backends. Both orders are now rejected up front with a clear `ValueError`,
118
+ and `read_branch_ref` treats a directory entry as "no such ref" rather than
119
+ crashing.
120
+ - `S3ObjectStore.write_blob_file`/`write_blob_stream` no longer load whole
121
+ objects into memory (transfer backend `upload` used `Path.read_bytes()`).
122
+ - `ReflakeRepository.log` still lists legacy histories after the generation
123
+ change (root commits legitimately have generation 0).
124
+
125
+ ### Removed
126
+
127
+ - **The package root re-exports only the documented stable surface** (stores,
128
+ protocols, codec, pruning internals, config helpers); import internals from
129
+ `reflake.core` explicitly if you need them.
130
+ - `write_branch_ref` is no longer part of the `RefCas` protocol — every ref
131
+ mutation must go through compare-and-set.
132
+
9
133
  ## [0.2.1] - 2026-09-10
10
134
 
11
135
  ### Deprecated
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: reflake
3
- Version: 0.2.1
3
+ Version: 0.3.0
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
@@ -747,14 +747,20 @@ Reflake separates data into three layers:
747
747
  | Area | Commands |
748
748
  |---|---|
749
749
  | Ingest | `init`, `add`, `commit [--staged]` |
750
- | Identity | `identity verify` (read-only audit), `identity promote` (materialize) |
750
+ | Identity | `identity verify [--drift] [--ref]` (read-only audit), `identity promote [--ref]` (materialize) |
751
751
  | Inspect | `status`, `log`, `diff`, `list` (`ls`), `cat`, `branches`, `reflog` |
752
- | Branch | `branch`, `checkout`, `merge` (fast-forward + 3-way metadata merge) |
753
- | Mutate | `rm`, `mv`, `gc [--prune]`, `restore` |
752
+ | Branch | `branch [-d]`, `checkout`, `merge` (fast-forward + 3-way metadata merge), `reset` (undo/redo) |
753
+ | Mutate | `rm`, `mv`, `gc [--prune] [--grace-seconds N]`, `restore` |
754
754
  | Sync | `push`, `pull`, `fetch`, `transfer` |
755
755
  | Analyze | `query build` (DuckDB/Parquet), `query prune` (row-group pruning) |
756
756
 
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
+ Worktree walks honor `.reflakeignore` (plus built-in `.reflake/` and `.git/`)
758
+ unless a path is named explicitly.
759
+
760
+ Exit codes: `0` ok · `1` usage/validation (unknown/missing **source** inputs,
761
+ `identity verify` with remaining pointer entries or detected drift) · `2`
762
+ conflict, retryable (CAS race, non-fast-forward, merge conflict) · `3` missing
763
+ repository ref/object. Every command with structured output honors `--json`.
758
764
 
759
765
  ## Guardrails (Strict)
760
766
 
@@ -891,6 +897,24 @@ retention requirement is lifted for those entries.
891
897
  | Pointer | `pointer` | `null` | ✅ (from `source_uri`) | ❌ | ✅ |
892
898
  | Verified | `content` | hash | ✅ (from `blobs/`) | ✅ | ❌ |
893
899
 
900
+ ### Drift detection (metadata-only)
901
+
902
+ Pointer entries imported from S3 record the source object's size,
903
+ last-modified time, and ETag (the optional trailing field on `m`/`mp` tree
904
+ lines). `reflake identity verify --drift` then compares those recorded values
905
+ against the source with **one metadata request per entry — never a byte
906
+ read**, and exits non-zero when a source was overwritten, resized, or
907
+ deleted:
908
+
909
+ ```bash
910
+ uv run reflake --repo s3://my-bucket/datasets/demo identity verify --drift
911
+ ```
912
+
913
+ Drift detection is a best-effort metadata comparison (local-file sources have
914
+ no ETag, so size + mtime are used there); it proves *change*, not content
915
+ equality. `identity promote` remains the only way to make a pointer entry
916
+ verifiable.
917
+
894
918
  ## Identity: Audit And Promotion
895
919
 
896
920
  Entry identity has two modes (`content` / `pointer`), so both commands that
@@ -903,6 +927,7 @@ remain:
903
927
  ```bash
904
928
  uv run reflake --repo /tmp/reflake-demo identity verify
905
929
  uv run reflake --repo /tmp/reflake-demo identity verify --path images --path logs/2026
930
+ uv run reflake --repo /tmp/reflake-demo identity verify --ref feature --drift
906
931
  ```
907
932
 
908
933
  `reflake identity promote` materializes canonical blobs and writes a promotion
@@ -913,7 +938,8 @@ uv run reflake --repo /tmp/reflake-demo identity promote
913
938
  uv run reflake --repo /tmp/reflake-demo identity promote --path images --path logs/2026
914
939
  ```
915
940
 
916
- - Both audit all entries by default (or selected path prefixes with `--path`).
941
+ - Both commands accept `--ref <branch>` (default: current branch) and audit all
942
+ entries by default (or selected path prefixes with `--path`).
917
943
  - Promotion reads bytes from each entry's `source_uri`, computes the content hash, and stores canonical blob content.
918
944
 
919
945
  ## Incremental Ingress
@@ -982,11 +1008,61 @@ Symlinks are neither followed nor stored: the worktree walk skips them (it
982
1008
  never escapes the repository root). Store the target's bytes, or stage the
983
1009
  external file explicitly with `add --as`.
984
1010
 
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.
1011
+ `reflake checkout <branch>` only **points the client at another branch** (a
1012
+ client-local symbolic ref); it never rewrites the working tree. Materializing
1013
+ data is an explicit, separate step: `restore <ref>` (optionally `--path <dir>`),
1014
+ `pull`, `cat`, or the read-only VFS. Files are only ever downloaded because you
1015
+ asked for them.
1016
+
1017
+ ### Staging semantics: a recipe, not a snapshot
1018
+
1019
+ `add` records a *recipe* (logical path + source), not frozen bytes: content is
1020
+ read when you commit. If a staged source changes in between, the commit
1021
+ contains the bytes **at commit time** — the CLI warns loudly (`Staged
1022
+ source(s) changed since \`add\``) rather than committing silently.
1023
+
1024
+ ### Branch names, and deleting branches
1025
+
1026
+ Branch names may be hierarchical (`feature/nightly-ingest`). `reflake branch
1027
+ draft -d` deletes a branch by CAS-ing its ref to *unborn* — a concurrent
1028
+ advance surfaces as a conflict instead of losing an update, and the name can
1029
+ be re-created with `reflake branch draft`.
1030
+
1031
+ ## Ignore Rules
1032
+
1033
+ Worktree walks (`commit`, `status`, `add <dir>`) skip:
1034
+
1035
+ - `.reflake/` and `.git/` (built-in, so a dataset repository never swallows
1036
+ git's metadata);
1037
+ - anything matched by `.reflakeignore` in the tree root (the file itself is
1038
+ tracked);
1039
+ - a path named explicitly on the command line is always staged — explicit
1040
+ wins.
1041
+
1042
+ `.reflakeignore` syntax: one glob per line, `#` comments, `!` to re-include,
1043
+ trailing `/` for directories, `*`/`?` don't cross `/`, `**` does, and a
1044
+ pattern containing `/` is anchored to the tree root.
1045
+
1046
+ ```gitignore
1047
+ scratch/
1048
+ *.tmp
1049
+ **/*.parquet.bak
1050
+ !important.tmp
1051
+ ```
1052
+
1053
+ ## Undo: `reset`
1054
+
1055
+ `reset` moves a branch pointer to any existing commit or ref (backwards or
1056
+ forwards) with a CAS, without touching the worktree:
1057
+
1058
+ ```bash
1059
+ uv run reflake --repo /tmp/reflake-demo log # find the commit you want
1060
+ uv run reflake --repo /tmp/reflake-demo reset <commit>
1061
+ uv run reflake --repo /tmp/reflake-demo reset main # also accepts refs
1062
+ ```
1063
+
1064
+ Staged changes are kept (a warning reminds you that `commit --staged` will now
1065
+ apply them onto the new parent). Every move is recorded in `reflake reflog`.
990
1066
 
991
1067
  ## Sync (push/pull/fetch)
992
1068
 
@@ -1000,7 +1076,8 @@ uv run reflake --repo . fetch s3://my-bucket/datasets/demo
1000
1076
  - 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.
1001
1077
  - Divergent history is rejected before any bytes move (`NonFastForwardError`); the final ref update is a CAS, so concurrent pushes surface conflicts instead of overwriting.
1002
1078
  - Push after a local merge transfers the entire merged lineage, including both parents' commits.
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.
1079
+ - Large blobs stream: uploads above 64 MiB use multipart (never a single 5 GiB-capped PUT, never a whole file in memory), downloads stream to disk, and `restore` verifies hashes while streaming into a temp file before renaming it into place.
1080
+ - S3-compatible endpoints (MinIO, Ministack, …) configured via `reflake init --backend s3 --s3-endpoint …` (or `config set s3.endpoint_url …`) are honored for repository operations **and** for `add s3://…` source access on S3-backed repositories.
1004
1081
 
1005
1082
  ## Analytical Index (Derived, Disposable)
1006
1083
 
@@ -1105,14 +1182,32 @@ Reflake creates `.reflake/` under each dataset root:
1105
1182
  - `trees/` - Merkle tree nodes (sorted JSONL, content-addressed)
1106
1183
  - `footers/` - parquet footer-stats objects (when enabled)
1107
1184
  - `commits/` - commit metadata objects
1108
- - `refs/heads/` - branch pointers only (CAS-updated)
1109
- - `refs/HEAD` - symbolic active branch reference (default `main`)
1185
+ - `refs/heads/` - branch pointers only (CAS-updated, `feature/x` allowed)
1186
+ - `refs/HEAD` - **client-local** symbolic active branch reference (never shared)
1110
1187
  - `state/` - client-local branch snapshots (never shared, never a ref)
1111
1188
  - `staging/`, `cache/`, `index/`, `reflog/` - client-local state
1112
1189
 
1113
1190
  Every object kind has exactly one physical location, defined by
1114
1191
  `layout.object_relative_key()` — the local filesystem and the S3 key space are
1115
1192
  guaranteed to stay in sync because both derive from that single mapping.
1193
+ Client-state filenames encode branch names (`feature/x` → `feature%2Fx`), so
1194
+ hierarchical branches can never collide with each other on disk.
1195
+
1196
+ ## Garbage Collection Safety
1197
+
1198
+ `reflake gc` is audit-only by default. `--prune` never deletes objects younger
1199
+ than a grace window (`gc_grace_seconds`, default 24h; override with
1200
+ `--grace-seconds N`), because a concurrent writer publishes immutable objects
1201
+ *before* it CASes its ref: without the window, mark-and-sweep would race that
1202
+ window and delete live data. Unknown object ages are treated as young.
1203
+
1204
+ The sweep streams the store listing, tests reachability as it goes, and
1205
+ deletes in 1000-key batches, so memory stays proportional to the *reachable*
1206
+ object set rather than to the store size. The listing comes from a pluggable
1207
+ existence source (the seam a future S3 Inventory adapter plugs into). Sweeps
1208
+ are idempotent — re-run one instead of resuming it; an entry a crashed sweep
1209
+ missed is simply found next time. Run `gc` (audit) before pruning in a shared
1210
+ repository, as always.
1116
1211
 
1117
1212
  ## Concurrency Model
1118
1213
 
@@ -54,14 +54,20 @@ Reflake separates data into three layers:
54
54
  | Area | Commands |
55
55
  |---|---|
56
56
  | Ingest | `init`, `add`, `commit [--staged]` |
57
- | Identity | `identity verify` (read-only audit), `identity promote` (materialize) |
57
+ | Identity | `identity verify [--drift] [--ref]` (read-only audit), `identity promote [--ref]` (materialize) |
58
58
  | Inspect | `status`, `log`, `diff`, `list` (`ls`), `cat`, `branches`, `reflog` |
59
- | Branch | `branch`, `checkout`, `merge` (fast-forward + 3-way metadata merge) |
60
- | Mutate | `rm`, `mv`, `gc [--prune]`, `restore` |
59
+ | Branch | `branch [-d]`, `checkout`, `merge` (fast-forward + 3-way metadata merge), `reset` (undo/redo) |
60
+ | Mutate | `rm`, `mv`, `gc [--prune] [--grace-seconds N]`, `restore` |
61
61
  | Sync | `push`, `pull`, `fetch`, `transfer` |
62
62
  | Analyze | `query build` (DuckDB/Parquet), `query prune` (row-group pruning) |
63
63
 
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
+ Worktree walks honor `.reflakeignore` (plus built-in `.reflake/` and `.git/`)
65
+ unless a path is named explicitly.
66
+
67
+ Exit codes: `0` ok · `1` usage/validation (unknown/missing **source** inputs,
68
+ `identity verify` with remaining pointer entries or detected drift) · `2`
69
+ conflict, retryable (CAS race, non-fast-forward, merge conflict) · `3` missing
70
+ repository ref/object. Every command with structured output honors `--json`.
65
71
 
66
72
  ## Guardrails (Strict)
67
73
 
@@ -198,6 +204,24 @@ retention requirement is lifted for those entries.
198
204
  | Pointer | `pointer` | `null` | ✅ (from `source_uri`) | ❌ | ✅ |
199
205
  | Verified | `content` | hash | ✅ (from `blobs/`) | ✅ | ❌ |
200
206
 
207
+ ### Drift detection (metadata-only)
208
+
209
+ Pointer entries imported from S3 record the source object's size,
210
+ last-modified time, and ETag (the optional trailing field on `m`/`mp` tree
211
+ lines). `reflake identity verify --drift` then compares those recorded values
212
+ against the source with **one metadata request per entry — never a byte
213
+ read**, and exits non-zero when a source was overwritten, resized, or
214
+ deleted:
215
+
216
+ ```bash
217
+ uv run reflake --repo s3://my-bucket/datasets/demo identity verify --drift
218
+ ```
219
+
220
+ Drift detection is a best-effort metadata comparison (local-file sources have
221
+ no ETag, so size + mtime are used there); it proves *change*, not content
222
+ equality. `identity promote` remains the only way to make a pointer entry
223
+ verifiable.
224
+
201
225
  ## Identity: Audit And Promotion
202
226
 
203
227
  Entry identity has two modes (`content` / `pointer`), so both commands that
@@ -210,6 +234,7 @@ remain:
210
234
  ```bash
211
235
  uv run reflake --repo /tmp/reflake-demo identity verify
212
236
  uv run reflake --repo /tmp/reflake-demo identity verify --path images --path logs/2026
237
+ uv run reflake --repo /tmp/reflake-demo identity verify --ref feature --drift
213
238
  ```
214
239
 
215
240
  `reflake identity promote` materializes canonical blobs and writes a promotion
@@ -220,7 +245,8 @@ uv run reflake --repo /tmp/reflake-demo identity promote
220
245
  uv run reflake --repo /tmp/reflake-demo identity promote --path images --path logs/2026
221
246
  ```
222
247
 
223
- - Both audit all entries by default (or selected path prefixes with `--path`).
248
+ - Both commands accept `--ref <branch>` (default: current branch) and audit all
249
+ entries by default (or selected path prefixes with `--path`).
224
250
  - Promotion reads bytes from each entry's `source_uri`, computes the content hash, and stores canonical blob content.
225
251
 
226
252
  ## Incremental Ingress
@@ -289,11 +315,61 @@ Symlinks are neither followed nor stored: the worktree walk skips them (it
289
315
  never escapes the repository root). Store the target's bytes, or stage the
290
316
  external file explicitly with `add --as`.
291
317
 
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.
318
+ `reflake checkout <branch>` only **points the client at another branch** (a
319
+ client-local symbolic ref); it never rewrites the working tree. Materializing
320
+ data is an explicit, separate step: `restore <ref>` (optionally `--path <dir>`),
321
+ `pull`, `cat`, or the read-only VFS. Files are only ever downloaded because you
322
+ asked for them.
323
+
324
+ ### Staging semantics: a recipe, not a snapshot
325
+
326
+ `add` records a *recipe* (logical path + source), not frozen bytes: content is
327
+ read when you commit. If a staged source changes in between, the commit
328
+ contains the bytes **at commit time** — the CLI warns loudly (`Staged
329
+ source(s) changed since \`add\``) rather than committing silently.
330
+
331
+ ### Branch names, and deleting branches
332
+
333
+ Branch names may be hierarchical (`feature/nightly-ingest`). `reflake branch
334
+ draft -d` deletes a branch by CAS-ing its ref to *unborn* — a concurrent
335
+ advance surfaces as a conflict instead of losing an update, and the name can
336
+ be re-created with `reflake branch draft`.
337
+
338
+ ## Ignore Rules
339
+
340
+ Worktree walks (`commit`, `status`, `add <dir>`) skip:
341
+
342
+ - `.reflake/` and `.git/` (built-in, so a dataset repository never swallows
343
+ git's metadata);
344
+ - anything matched by `.reflakeignore` in the tree root (the file itself is
345
+ tracked);
346
+ - a path named explicitly on the command line is always staged — explicit
347
+ wins.
348
+
349
+ `.reflakeignore` syntax: one glob per line, `#` comments, `!` to re-include,
350
+ trailing `/` for directories, `*`/`?` don't cross `/`, `**` does, and a
351
+ pattern containing `/` is anchored to the tree root.
352
+
353
+ ```gitignore
354
+ scratch/
355
+ *.tmp
356
+ **/*.parquet.bak
357
+ !important.tmp
358
+ ```
359
+
360
+ ## Undo: `reset`
361
+
362
+ `reset` moves a branch pointer to any existing commit or ref (backwards or
363
+ forwards) with a CAS, without touching the worktree:
364
+
365
+ ```bash
366
+ uv run reflake --repo /tmp/reflake-demo log # find the commit you want
367
+ uv run reflake --repo /tmp/reflake-demo reset <commit>
368
+ uv run reflake --repo /tmp/reflake-demo reset main # also accepts refs
369
+ ```
370
+
371
+ Staged changes are kept (a warning reminds you that `commit --staged` will now
372
+ apply them onto the new parent). Every move is recorded in `reflake reflog`.
297
373
 
298
374
  ## Sync (push/pull/fetch)
299
375
 
@@ -307,7 +383,8 @@ uv run reflake --repo . fetch s3://my-bucket/datasets/demo
307
383
  - 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.
308
384
  - Divergent history is rejected before any bytes move (`NonFastForwardError`); the final ref update is a CAS, so concurrent pushes surface conflicts instead of overwriting.
309
385
  - Push after a local merge transfers the entire merged lineage, including both parents' commits.
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.
386
+ - Large blobs stream: uploads above 64 MiB use multipart (never a single 5 GiB-capped PUT, never a whole file in memory), downloads stream to disk, and `restore` verifies hashes while streaming into a temp file before renaming it into place.
387
+ - S3-compatible endpoints (MinIO, Ministack, …) configured via `reflake init --backend s3 --s3-endpoint …` (or `config set s3.endpoint_url …`) are honored for repository operations **and** for `add s3://…` source access on S3-backed repositories.
311
388
 
312
389
  ## Analytical Index (Derived, Disposable)
313
390
 
@@ -412,14 +489,32 @@ Reflake creates `.reflake/` under each dataset root:
412
489
  - `trees/` - Merkle tree nodes (sorted JSONL, content-addressed)
413
490
  - `footers/` - parquet footer-stats objects (when enabled)
414
491
  - `commits/` - commit metadata objects
415
- - `refs/heads/` - branch pointers only (CAS-updated)
416
- - `refs/HEAD` - symbolic active branch reference (default `main`)
492
+ - `refs/heads/` - branch pointers only (CAS-updated, `feature/x` allowed)
493
+ - `refs/HEAD` - **client-local** symbolic active branch reference (never shared)
417
494
  - `state/` - client-local branch snapshots (never shared, never a ref)
418
495
  - `staging/`, `cache/`, `index/`, `reflog/` - client-local state
419
496
 
420
497
  Every object kind has exactly one physical location, defined by
421
498
  `layout.object_relative_key()` — the local filesystem and the S3 key space are
422
499
  guaranteed to stay in sync because both derive from that single mapping.
500
+ Client-state filenames encode branch names (`feature/x` → `feature%2Fx`), so
501
+ hierarchical branches can never collide with each other on disk.
502
+
503
+ ## Garbage Collection Safety
504
+
505
+ `reflake gc` is audit-only by default. `--prune` never deletes objects younger
506
+ than a grace window (`gc_grace_seconds`, default 24h; override with
507
+ `--grace-seconds N`), because a concurrent writer publishes immutable objects
508
+ *before* it CASes its ref: without the window, mark-and-sweep would race that
509
+ window and delete live data. Unknown object ages are treated as young.
510
+
511
+ The sweep streams the store listing, tests reachability as it goes, and
512
+ deletes in 1000-key batches, so memory stays proportional to the *reachable*
513
+ object set rather than to the store size. The listing comes from a pluggable
514
+ existence source (the seam a future S3 Inventory adapter plugs into). Sweeps
515
+ are idempotent — re-run one instead of resuming it; an entry a crashed sweep
516
+ missed is simply found next time. Run `gc` (audit) before pruning in a shared
517
+ repository, as always.
423
518
 
424
519
  ## Concurrency Model
425
520
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "reflake"
3
- version = "0.2.1"
3
+ version = "0.3.0"
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" }]