connor / loot

connor/loot
fromd2258a275c4fab55cd3a68e9c0c47db4f7fc264a970c03cf1174f51249fc54ae → d2258a27
to8e3c7b838a5763f737ebdb569d417288c25b9502bfd85716c550084dc5f63906 → 8e3c7b83

+21 −124

11 # loot
22
33 A from-scratch source-control system.
44
55 **Thesis:** visibility and permissions belong to *content and changes*, not to
66 the *repository*. Commit your `.env`. Keep files private inside a shared repo.
77 Embargo a security fix: merge it, cut the release, reveal the source later.
88
9−This is the unsolved problem in modern version control. Ergonomics (jj already
10−nails them) are a layer for later.
11−
129 ## Security
1310
1411 loot's cryptography is written from scratch and has never been independently
15−reviewed. What each reader — a relay, a forge, a collaborator, the anonymous
16−internet, the git mirror, and anyone holding your `.loot/` directory — can
17−actually read is stated tier by tier at
18−**<https://loot.build/trust>**. Read it before you put anything in a
19−loot repo whose disclosure would hurt you. Two things it says that the pitch
20−does not: the default tier is one a relay reads by design, and path names are
21−never encrypted at any tier.
12+reviewed. What each reader (a relay, a forge, a collaborator, the anonymous
13+internet, the git mirror, anyone holding your `.loot/` directory) can read is
14+stated tier by tier at **<https://loot.build/trust>**. Read it before you put
15+anything in a loot repo whose disclosure would hurt you. In particular, the
16+default tier is one a relay reads by design, and path names are never encrypted
17+at any tier.
2218
23−**Report a vulnerability to <security@loot.build>** — not to the public
24−Discord. One maintainer, best effort, expect days rather than hours. ⚠ This
25−file is not the published route: the GitHub repo is permanently private
26−(ADR 0045/0064), so a `SECURITY.md` here and GitHub's private-advisory button
27−both reach nobody. `/trust` is the route; this section exists for whoever
28−already has repo access.
19+**Report a vulnerability to <security@loot.build>**, not to the public Discord.
20+One maintainer, best effort, expect days rather than hours. This repo is
21+private (ADR 0045/0064), so `/trust` is the published route.
2922
3023 ## What works today
3124
32−The full loop from first init to relay-based collaboration is functional. This
33−block is the CLI's **full verb list** — all 89 verbs, regenerated from
34−`loot --help` rather than curated (a guard test pins it to the dispatch table,
35−so it cannot drift again; #1107):
25+The CLI's full verb list, from `loot --help`:
3626
3727 ```text
3828 abandon absorb adopt apply apply-patch archive attest bisect blame bundle buoy
3929 burn cat
4030 cherry-pick clean clone completions config conflicts converge count-objects
4131 describe diff doctor duplicate edit embargo-status evolog explain ferry
4232 fetch format-patch gates gc grant grant-status grants grep heads id init keygen
4333 lane lanes lock log login manifest maroon merge migrate move new notes op peer pipeline
4434 propose pull
4535 pull-grants purges push range-diff rehome relay remote resolve restore revert runner runners seek serve
4636 shortlog show split squash status surface tag telemetry ticket tickets tutorial undo unlock verify
4737 view whoami
4838 ```
4939
50−`loot <verb> --help` prints any verb's own usage block without running it.
40+`loot <verb> --help` prints any verb's usage without running it.
5141
5242 ### Try it: private `.env` in a shared repo
5343
5444 ```bash
5545 cargo build --release
5646 export PATH="$PWD/target/release:$PATH"
5747
5848 cd $(mktemp -d)
5949 printf 'TOKEN=supersecret\n' > .env
6050 printf '# My Project\n' > README.md
6151 printf '.env restricted=alice\n*.md public\n' > .lootattributes
6252
6353 loot init --identity alice
6454 loot status -m "initial work"
6555 loot surface # alice: restores both README.md and .env
6656
6757 # switch to a non-keyholder to prove it
6858 printf mallory > .loot/identity
6959 rm -f .env README.md
7060 loot surface # mallory: README.md appears; .env stays sealed
7161 ```
7262
73−The `.env` ciphertext lives in `.loot/` the whole time. Mallory cannot decrypt
74−it, and if she snapshots and re-syncs, the sealed file is carried forward
75−untouched — snapshot is visibility-aware.
63+The `.env` ciphertext stays in `.loot/`. Mallory cannot decrypt it, and if she
64+snapshots and re-syncs, the sealed file is carried forward untouched.
7665
7766 ### Sync over a relay
7867
7968 A relay stores and forwards ciphertext it cannot read. Restricted keys never
80−travel in a sync bundle (ADR 0003), so the relay's zero-knowledge property is
81−enforced at the wire level, not by policy.
69+travel in a sync bundle (ADR 0003).
8270
8371 ```bash
8472 # Terminal 1: run a relay
8573 loot serve --dir /tmp/relay --addr 127.0.0.1:4000
8674
8775 # Terminal 2: alice pushes
8876 loot remote add origin http://127.0.0.1:4000
8977 loot push
9078
9179 # Terminal 3: bob pulls (bob only sees public content)
9280 loot clone http://127.0.0.1:4000 ./bob-repo --identity bob
9381 ```
9482
9583 ### Grants: sharing a content key
9684
9785 ```bash
9886 # alice knows bob's public key (from `loot whoami` on bob's machine)
9987 loot peer add bob "ssh-ed25519 AAAA..."
10088
10189 # deliver a sealed grant via the relay
10290 loot grant --relay origin .env bob
10391
10492 # bob fetches and applies it
10593 loot pull-grants # verifies alice's signature, checks peer registry
10694 loot surface # now bob can read .env
10795 ```
10896
10997 ### Embargo: timed reveals
11098
11199 ```bash
112100 # mark a file as embargoed until unix timestamp 1800000000
113101 echo "VULN_DETAILS=CVE-2025-XXXX" > security-fix.txt
114102 printf 'security-fix.txt embargoed=1800000000\n' >> .lootattributes
115103
116104 loot status -m "patch for CVE-2025-XXXX"
117105 loot push # relay holds the ciphertext; key withheld until reveal_at
118106 ```
119107
120108 At `reveal_at`, the next read promotes the key out of escrow, so anyone who
121109 pulls can read it.
122−The seam for a third-party key custodian (network escrow) is designed and ready.
123110
124−## Architecture
125−
126−```text
127−crates/
128− loot-core canonical engine: encrypted DAG, per-content visibility, convergence
129− loot-identity ed25519 keypairs, x25519 ECIES, signed push envelopes, peer registry
130− loot-net relay HTTP server + sync client (stow/negotiate/grant mailbox)
131− loot-cli the `loot` binary — commands are thin verbs over Workspace
132− loot-bench shared 50k-file benchmark workload
133− spike-dag thin shim re-exporting loot-core (bake-off compat)
134− spike-crdt non-canonical CRDT model (retained so the bake-off is reproducible)
135−```
136−
137−### Key modules
138−
139−| Module | What it owns |
140−| --- | --- |
141−| `loot-core::sealed` | Per-content encryption, key custody, embargo, public-content compression (ADR 0003, 0007, 0020) |
142−| `loot-core::converge` | Merger/relay convergence rule — decrypt-then-merge (ADR 0001) |
143−| `loot-core::engine` | Encrypted content-addressed DAG: put/get/record/surface/bundle/apply |
144−| `loot-core::manifest` | Grant audit trail: grantee, grantor pubkeys, timestamps |
145−| `loot-identity` | ed25519 sign/verify, x25519 derive, ECIES seal/unseal, push envelope |
146−| `loot-net::mailbox` | Relay grant mailbox: pubkey-addressed, content-addressed loose blobs |
147−| `loot-cli::workspace` | Ambient repo: identity, clock, persistence, idempotent snapshot |
148−
149−### ADRs (docs/adr/)
150−
151−| # | Decision |
152−| --- | --- |
153−| 0001 | Per-content decrypt-then-merge convergence |
154−| 0002 | Encrypted DAG as the canonical foundation (bake-off winner) |
155−| 0003 | Sealed content module + keyring custody (restricted keys never travel) |
156−| 0004 | Drop plaintext dedup equality oracle |
157−| 0005 | CLI slice, persistence, .lootattributes |
158−| 0006 | JJ-style workspace auto-snapshot |
159−| 0007 | Embargo escrow module |
160−| 0008 | Grant log and targeted key bundles |
161−| 0009 | Two-level revocation |
162−| 0010 | Forward-maroon implementation |
163−| 0011 | Relay stow append-only |
164−| 0012 | Per-object loose storage |
165−| 0013 | Named remotes and grant bundle delivery |
166−| 0014 | Identity keypairs: ed25519 OpenSSH, signed push envelopes |
167−| 0015 | Grant authentication and trust (grantor signs, peer-registry gate) |
168−| 0016 | Identity portability: export/import with passphrase wrapping |
169−| 0017 | RepoStore: one home for the `.loot/` layout |
170−| 0018 | Signed changes: author in id + validity enforcement |
171−| 0019 | Format versioning + compatibility gate (newer reads older) |
172−| 0020 | Compress public content (Zstd); format major → 2 |
173−| 0021 | Object-level "wants" negotiation on push/pull |
174−| 0022 | Concurrent-agent model: docks, harbor, optimistic convergence |
175−| 0023 | Agent-facing machine output: porcelain-first, reconciliation verbs |
176−| 0024 | Resumable transfer via batched, negotiated sync |
111+## Layout
177112
178−See [CONTEXT.md](CONTEXT.md) for the full domain glossary.
113+The engine is `crates/loot-core`, the `loot` binary is `crates/loot-cli`, and
114+the relay and forge deployables are `crates/loot-relayd` and
115+`crates/loot-forge`. [CONTEXT.md](CONTEXT.md) is the domain glossary and
116+`docs/adr/` holds the decisions.
179117
180118 ## Build & test
181119
182120 ```bash
183121 cargo build
184−cargo test # ~25s — includes HTTP relay integration tests
185−cargo test -p loot-core # fast, no I/O, 67 tests
186−```
187−
188−## Command reference
189−
190−```text
191−loot init [--identity <name>] initialize a repo (identity from global config if omitted)
192−loot clone <url> <dir> clone a relay or forge repo into <dir>; ends with a materialized working tree
193−loot config [--local] set <key> <val> set a config value; bare writes the global file (~/.config/loot/config), --local writes this repo's (.loot/config.local, never tracked)
194−loot config --get <key> print one effective value (local over global); exits non-zero when unset
195−loot status [-m <message>] snapshot the working tree into the working change (idempotent)
196−loot describe -m <message> name the working change
197−loot new finalize the working change; start a fresh one
198−loot surface materialize what the current identity may see
199−loot lane new [--name <n>] spawn a sealed lane (isolated tree + tip) over the shared store
200−loot lanes list lanes with their tip, in-flight PR, and status
201−loot log show change history with visibility hints
202−loot gc [--dry-run] prune loose objects no change references
203−loot verify [--accept-loss] [--unreachable] integrity-check the object store (exits 1 on corrupt/missing; --accept-loss records unrecoverable losses; --unreachable also lists objects that are PRESENT and referenced by nothing — deletes nothing, names `loot gc` as the remedy, and never changes the exit status)
204−loot bundle <file> write a sync bundle (ciphertext, no keys)
205−loot apply <file> merge a peer's bundle (idempotent)
206−loot apply-patch <file> [--check] apply a TEXT patch `loot format-patch` wrote — strict, with an ADR 0044 three-way fallback that stops on conflict like `loot apply` does; a path this identity cannot open refuses the whole run, and CRLF is refused where the patch says it lost line endings or would rewrite a CRLF file (ADR 0082). --check reports applicability and writes nothing
207−loot grant <path> <identity> <file> write a targeted grant bundle (file delivery)
208−loot grant --relay <remote> <path> <id> seal and deliver a grant via relay mailbox
209−loot grants [<url>] peek pending grant count (no download)
210−loot pull-grants [<url>] fetch, verify, and apply sealed grants from relay
211−loot maroon [--hard] <path> <identity> cut off <identity> from future access
212−loot migrate <path> <vis-spec> change a path's visibility
213−loot manifest show the grant audit trail (and attestations)
214−loot conflicts list paths needing resolution
215−loot resolve <path> <file> resolve a conflict
216−loot remote add <name> <url> register a relay URL
217−loot push [<url>] publish changes to a relay
218−loot pull [<url>] fetch and merge changes from a relay
219−loot fetch [<url>] ingest from a relay and stop — no merge, no converge, no tree write
220−loot serve [--addr <host:port>] run a relay
221−loot keygen generate an identity keypair
222−loot whoami show identity and public key
223−loot id export <file> export keypair, passphrase-encrypted
224−loot id import <file> import keypair from passphrase-encrypted file
225−loot peer add <name> <pubkey> register a peer's public key
226−loot peer list list known peers
122+cargo test # includes HTTP relay integration tests
123+cargo test -p loot-core # fast, no I/O
227124 ```
228125