Commit graph

53 commits

Author SHA1 Message Date
9a9321adf7 feat(M8): migration runner + per-(share,id) snapshots 🏗️🔑
The v2 foundation (V2-SPEC §5.1). Two things land:

- PRAGMA user_version migration runner in internal/hub/meta: ordered,
  append-only, each step in its own txn with the version bump LAST so a
  crash rolls back cleanly. Backs up an existing DB to <path>.pre-v2.bak
  (VACUUM INTO) before migrating; refuses a DB written by a newer build.
  Every later v2 schema change rides this.

- Re-key snapshots from a GLOBAL id PK to per-(share, id). v1's global id
  meant identical content pushed to two shares collided on one row, so the
  second share never counted its chunk refcounts (undercount) and recorded
  no snapshot row. Per-share rows fix the refcount and let each share own
  its history. Wire id/Head stays the manifest hash — clients unchanged.
  Migration also backfills any share head left rowless by the v1 idempotent
  push, restoring the head-has-a-row invariant. GC reworked to prune per
  (share, id), decrementing each share's chunks and freeing a shared
  manifest blob at most once.

Tests: cross-share refcount, migration versioning + refuse-newer, and a
realistic populated-v1 -> v2 upgrade (data preserved, backup written,
head backfill). All 17 pkgs -race green; hub cross-compiles linux/amd64.

Deferred to M8-3 (conflict sidecar): restore/deploy conflict-copy — a naive
version breaks restore-reproduces-snapshot; it needs the base/ancestor
awareness the sidecar introduces. snapshot_chunks edge table deferred to
M9 (no consumer yet; the runner makes adding it a one-line migration).
2026-06-23 10:46:26 -05:00
bcfd8e5a4f docs(v2): full v2 design spec — teams, E2E, P2P, HA, merge, TUI 🔮📐
Researched (6 parallel agents, grounded in v1 code + prior art) and synthesized
docs/V2-SPEC.md: vision, the two architectural forks (add-don't-replace),
6 theme designs with concrete schema/proto deltas + crash-safe migrations, a
dependency-ordered M8→M11 roadmap, and a risks table. Key throughline:
convergent encryption is the lynchpin that lets E2E coexist with dedup AND P2P.
Ponytail guard: captured ≠ committed — only M8 (refcount fix + migration runner
+ principals/roles + control socket) is justified now; M9–M11 are demand-driven.
Linked from the README roadmap.
2026-06-23 05:06:59 -05:00
f3f24feea9 harden: domain-separate the join challenge + inline pidfile wrapper (ponytail) 🪪♻️
Ponytail review of the hardening batch:
- JoinChallenge was a bare token||pubkey concat — unambiguous only because
  ed25519 keys are fixed 32 bytes. Now domain-separated + NUL-delimited
  ('devbox-join\0<token>\0<pubkey>') so the boundary is explicit regardless of
  key length, and the sig can't collide with any other devbox signing use.
- inlined the one-caller pidfileContents() into writePid.
(Kept the Linux /proc start-time guard: the daemon's real home is the Pi
cluster, where PID-reuse-after-crash is a genuine window; the magic field index
is already a named const. Declined the flock rewrite of fleet-verified code.)
2026-06-23 03:25:28 -05:00
b7b9459cca docs: sync README — badge bump, M7.5/M7.6 in summary, new Security section 🔐📊
- status badge: 'v1 complete · M0–M7' → '🛡️ v1 · audited + hardened'
- Go badge 1.22+ → 1.26+ (matches go.mod)
- top milestone summary now carries M7.5 (audit) + M7.6 (hardening), consistent
  with the detailed table
- new '🔐 Security & Durability' section (table + a mermaid of the integrity/path
  guard chain) + TOC entry — showcases the audit/hardening honestly under the
  single-owner threat model
2026-06-23 03:22:20 -05:00
edbae06c3d test: drop tautological byte-cap invariant test (ponytail) ♻️
Per ponytail review of the hardening batch: TestHubByteCapsAreSane only fails on
a deliberate const edit (not a real bug) and its comment described timeouts it
never tested. The happy-path limits test carries the regression weight.
2026-06-23 03:17:32 -05:00
2c9c33787f docs: M7.6 hardening complete (fsync, DoS caps, pidfile, join PoP) 🛡️📊 2026-06-23 03:10:27 -05:00
04f94d7730 harden(auth): require proof-of-possession on join 🪪🔐
The device id is derived from the pubkey in JoinRequest, but the hub never
checked the joiner actually held that key — anyone with a token could enroll
claiming another device's identity. Now the client signs JoinChallenge(token,
pubkey) with its ed25519 private key and the hub verifies it (ed25519.Verify)
BEFORE redeeming the token — so a bad request can't burn a legitimate one-time
token either. proto gains a Signature field + the shared JoinChallenge helper.
Regression test: garbage/missing/wrong-key sigs all 401, token survives, valid
join enrolls.
2026-06-23 03:08:23 -05:00
f9c33d49d1 harden(pidfile): guard against PID reuse with a start-time token 🆔
A crashed daemon's PID can be recycled by an unrelated process, so the bare-PID
pidfile let 'devbox stop' SIGTERM a stranger and 'devbox start' refuse over a
reused PID. The pidfile now records '<pid> <starttoken>' (Linux /proc/<pid>/stat
field 22 start time); runningPid only treats the PID as our daemon when the
token still matches. Falls back to bare-PID liveness where the token is
unverifiable (non-Linux) — no regression. Verified on real linux/arm64.
[fanned-out subagent: harden-pidfile]
2026-06-23 03:00:30 -05:00
fd361e811e harden(dos): bound request bodies + add hub server timeouts 🚪🛡️
The hub read request bodies with unbounded io.ReadAll / json.Decode and ran
http.ListenAndServe with zero timeouts — a single client could OOM it or hold
connections open (slowloris). Now:
- handleBlob caps the body at 256 MiB, decode() caps JSON at 8 MiB, both via
  http.MaxBytesReader -> 413 when exceeded.
- serve uses an http.Server with ReadHeaderTimeout/ReadTimeout/IdleTimeout +
  MaxHeaderBytes. WriteTimeout intentionally unset so the long-lived /v1/events
  SSE stream isn't killed. [fanned-out subagent: harden-dos]
2026-06-23 02:59:53 -05:00
4b6a4b97b2 harden(durability): fsync atomic writes before publishing the rename 💽
A power loss between rename and the data hitting disk could leave a truncated/
empty file despite the atomic rename — breaking 'never lose a byte'. Now both
atomic-write paths f.Sync() the temp file before rename and best-effort fsync
the parent dir after (so the rename entry is durable too):
- internal/syncer/pull.go atomicWrite (pulled file content)
- internal/hub/blobstore Disk.Put (stored blobs)
Dir fsync is best-effort (unsupported on Windows). [fanned-out subagent: harden-fsync]
2026-06-23 02:59:26 -05:00
5a42661522 docs: record the M7.5 security/data-loss audit pass + deferred hardening 🔐📊 2026-06-23 02:41:38 -05:00
56b8be924b fix(daemon): stagger rescans, guard jitter panic, tighten backoff reset 🔁⚙️
- rescan tickers for all mounts started in lockstep, so every 60s they rebuilt
  manifests simultaneously (self-synchronized load spike on big trees). Stagger
  the first tick by a random offset.
- jittered() called rand.Int63n(int64(d/2)) which panics for sub-2ns durations
  (d/2==0). Guard it. (Latent: a panic in a recover-less goroutine.)
- healthyStream was 2min — 4x larger than typical SSE recycle (~30-60s), so a
  recycled-but-healthy stream never reset backoff and sat at the 30s ceiling.
  Lowered to 20s. Regression test for the jitter panic.
2026-06-23 02:38:46 -05:00
9ad2a9da74 fix(dataloss): make hub GC safe against cross-share refcount undercount 🩸🗑️
Snapshots are content-addressed with a GLOBAL id, so two shares with identical
content collide on one snapshots row and the idempotent push skips the refcount
bump — a chunk two share heads both need ends up refcount=1. The old GC then
pruned the 'old' snapshot for one share and freed chunks/manifests the OTHER
share's live head still pointed at. Permanent cross-share data loss.

Rework runGC as mark-and-sweep from every share's live snapshots as roots:
nothing reachable from a kept snapshot is ever deleted, whatever the refcounts
say. Never prune a snapshot that is any share's head. Plus hardening:
- DeleteSnapshot floors refcount at 0 and only decrements if the row existed
  (no negative counts from a double-delete).
- DeleteChunkRow is now conditional (WHERE refcount<=0) and reports if it
  deleted, so a push that re-references a chunk mid-GC isn't corrupted.
Cross-share repro test + existing single-share GC test both green.

Deferred to v2 (documented): proper per-(share,id) refcount accounting — needs
a schema migration of the live hub; the ground-truth GC makes it safe meanwhile.
2026-06-23 02:35:43 -05:00
57ebed35b5 fix(dataloss): don't clobber a .devignore'd/guarded local file on pull 🩸🛟
The pull merge compared the hub against 'ours' = a .devignore/secret-guard
FILTERED manifest. A file still on disk but excluded from 'ours' looked like a
local delete, so a hub edit to that path hit 'case tOK && !oOK' and overwrote
the on-disk bytes with NO conflict copy — silently destroying ignored configs
and the very .env/keys the guard exists to protect (a teammate pushing .env
could wipe your local secret).

Now: in that branch, stat the real file first; if it's actually present,
preserve it as a .conflict-<host>-<ts> copy before applying the hub version —
honoring the 'never lose a byte' promise. Regression test proves the local
bytes survive.
2026-06-23 02:28:51 -05:00
c864461fa1 fix(sec): contain manifest paths + verify blob integrity on download 🛡️🧊
Two ways a buggy/malicious hub could corrupt the local tree:
- writeEntry/deleteFile joined hub-supplied Entry.Path into root with no
  containment check, so '../../.ssh/authorized_keys' wrote/deleted OUTSIDE the
  mount. New safeJoin() uses filepath.IsLocal to refuse absolute/.. /escaping
  paths before any write or delete.
- GetBlob returned bytes with only an HTTP-status check. Blobs (chunks AND
  manifests) are content-addressed, so now verify chunk.Hash(body)==hash —
  a corrupt/truncated transfer or hostile hub can't write wrong content
  undetected. (manifest ID == chunk.Hash(Marshal()), so the check holds there.)
Regression tests for both.
2026-06-23 02:24:32 -05:00
96fd6018a9 fix(sec): block blob-hash path traversal (arbitrary file read) 🔓🛡️
GET /v1/blob/{hash} and /v1/have passed the URL hash straight into filepath.Join
in the blob store. Go's ServeMux URL-decodes %2f/%2e in the wildcard, so
'..%2f..%2f..%2fetc%2fpasswd' (or a hash starting with '..') escaped the blob
root — any enrolled device could read arbitrary files incl. the hub token DB.

Defense in depth:
- hub: validHash() rejects non-(64 hex) keys at the HTTP boundary (404 on GET,
  400 on /have) before any store call.
- blobstore: safeKey() rejects keys that aren't a bare, separator-free filename
  in Has/Get/Put/Delete — the sink can't be escaped even if a caller forgets.
e2e + unit regression tests for both layers.
2026-06-23 02:21:03 -05:00
7366ab757c fix(sec): secret guard no longer leaks creds — case-insensitive + more patterns 🔑🛡️
Audit found the guard silently uploads real credentials:
- patterns were case-sensitive: .ENV / KEY.PEM / ID_RSA / Server.Key all passed
  through on macOS/Windows. New ignore.CompileFold compiles the guard deny-list
  case-insensitively (.devignore stays case-sensitive, gitignore semantics).
- added *.env and .envrc (prod.env / config.env hold the same secrets as .env).
- .aws/credentials and .ssh/id_* were root-anchored — a nested copy leaked; now
  **/ depth-matched.
Regression test covers all three.
2026-06-23 02:15:28 -05:00
3700e4a491 docs: note the M7 rescan fallback (dead-watcher resilience) 📊🔁 2026-06-23 01:54:41 -05:00
88aa53064f feat(M7): periodic rescan fallback for dead/limited watchers 🔁🍓
The v1 daemon only re-syncs a mount on a watcher event or a hub event. If the
watcher can't start (inotify max_user_instances/max_user_watches exhausted on a
big Pi tree — PRD risk #1) the mount silently stops pushing local edits.

Add a 60s per-mount rescan ticker that nudges a sync regardless, so a mount
reconverges even with no working watcher. Watcher-start failure now logs the
fallback + points at 'devbox doctor' instead of going quiet.

Fleet-verified on linux/arm64: with fs.inotify.max_user_instances=0 (watcher
dead) a local edit still propagated to a peer via the rescan tick.
scripts/m7-fleet-verify.sh exercises the full M7 surface + this rescan path.
2026-06-23 01:53:24 -05:00
cfdd2f16a2 docs: correct stale M2/M3 comments (SSE shipped, conflict handling live) 📝 2026-06-23 01:45:50 -05:00
552349104a feat(M7): round out the CLI — unmount, ignore, conflicts + v1-complete docs 🎉
- devbox unmount <share>: drop a share's mount(s) from config + state (files stay)
- devbox ignore <pattern>: append to ./.devignore
- devbox conflicts: list .conflict-* copies across all mounts
- README: mark M0–M7 done / v1 feature-complete; fix stale roadmap grid; annotate
  pause/resume/peers as planned (need daemon IPC / a hub peers endpoint)

All fleet-verified on hueb (.3) against the hub on .10.
2026-06-23 01:43:46 -05:00
5bfccdb297 fix(M7): review fixes — pidfile O_EXCL, publish race, backoff reset 🐛
Code-review pass on M6.5+M7:
- pidfile: claim via O_CREATE|O_EXCL and arbitrate live-vs-stale, so two
  `devbox start` invocations can't both win the guard and run concurrently
- hub: serialize publish (publishMu) so a case-clash check + create is atomic;
  reject share names ending in '.' (Windows strips it → silent collision)
- daemon: reset SSE backoff only after a genuinely healthy stream (2m), not the
  30s ceiling, so a hub that recycles connections doesn't pin a 30s event lag
- document that restore/deploy's delete pass is ignore/guard-filtered on purpose
  (never delete a user's gitignored runtime files or local secrets)
- test: pidfile claim/refuse/stale-reclaim arbitration
2026-06-23 01:37:58 -05:00
6e3ddee1e6 refactor(M7): cmp.Or for editor env, share hooks.Executable (ponytail) ♻️ 2026-06-23 01:32:22 -05:00
bf40d209c1 feat(M7): devbox doctor, stop, and hook edit/list 🩺⏹️🪝
- devbox doctor: checks identity/join, hub reachability + bearer acceptance,
  bash for hooks, fsnotify watcher (catches inotify exhaustion), and each mount's
  writability; exits non-zero on any failure
- devbox stop + pidfile: start writes ~/.config/devbox/daemon.pid and refuses a
  second daemon; stop SIGTERMs it (liveness-checked, cleans stale pidfiles)
- devbox hook edit <share> <event>: scaffolds an executable, documented bash
  sample then opens $EDITOR/$VISUAL; hook list shows installed vs available
- hooks: AllEvents/IsEvent/Dir/Sample helpers
2026-06-23 01:30:49 -05:00
38766fdcd5 feat(M7): SSE reconnect backoff + share-name validation 🛡️
- daemon: exponential backoff (1s→30s) + ±25% jitter on SSE reconnect so a fleet
  that drops together doesn't reconnect in lockstep; a long-lived stream resets it
- hub: ValidateShareName rejects path separators, traversal, control/non-ASCII
  chars, reserved Windows device names (CON/NUL/COM1…), and case-clashes with an
  existing share (Foo vs foo would collide on case-insensitive filesystems)
- tests for both
2026-06-23 01:26:04 -05:00
4e194ea342 docs: M6.5 deploy done (fleet-verified), M7 next 📊🚀 2026-06-23 01:20:35 -05:00
2c6dba2dd2 feat(M6.5): devbox deploy — pin a mount to a snapshot (no push) 🚀
deploy applies a snapshot's manifest to a mount's local dir WITHOUT pushing a
new head — blue/green for /var/www boxes. History stays untouched; the mount is
pinned (config.Mount.Pinned) so the daemon won't live-advance it back to head.
Re-mount clears the pin.

- syncer.Deploy + shared applySnapshot helper (Restore now reuses it)
- config.Mount.Pinned; daemon skips pinned mounts
- CLI: devbox deploy <share> <snapshot> (prefers the --ro mount); status shows pinned
- test: deploy applies v1 while hub head stays v2 (the no-push property)
2026-06-23 01:17:20 -05:00
b6651d4abb docs: M6 versioning done (fleet-verified), M6.5 next 📊🕰️ 2026-06-23 01:05:48 -05:00
41bd4d103e fix(M6): devbox log prints full snapshot id (round-trips to restore) 2026-06-23 01:02:56 -05:00
6d0453d8e3 feat(M6): versioning — log, restore, hub gc 🕰️
- devbox log <share>: hub GET /v1/log (meta.SnapshotLog newest-first), client.Log
- devbox restore <share> <snapshot> [path]: snapshot id == manifest blob hash, so
  syncer.Restore fetches the old manifest, rewrites the file(s) (+deletes extras for
  a whole-tree restore), and pushes -> itself a new reversible snapshot
- devbox-hub gc [--keep N]: prune snapshots beyond the newest N (never the head),
  decrement chunk refcounts, sweep refcount<=0 chunks + manifest blobs from the store
- meta: SnapshotLog, ShareNames, DeletableSnapshots (rowid tiebreaker), DeleteSnapshot
  (tx + refcount--), UnreferencedChunks, DeleteChunkRow
- tests: log order/limit, deletable keeps head+newest, refcount decrement, whole-tree
  + single-path restore, gc end-to-end (old unique chunks freed, head intact)
2026-06-23 01:01:54 -05:00
c17a5da9c5 docs: M5 hooks done (fleet-verified), M6 next 📊🪝 2026-06-23 00:50:40 -05:00
613de19818 feat(M5): lifecycle hooks 🪝
- internal/hooks: Runner finds <mount>/.devbox/hooks/<event>, runs via bash (or
  .ps1->pwsh), injects DEVBOX_EVENT/MOUNT/SHARE/HOST/REMOTE/SNAPSHOT/CHANGED_FILES,
  60s timeout (WaitDelay bounds post-kill cleanup), pre-* non-zero exit = veto
- syncer fires pre-push/post-push (in Push) + pre-pull/post-pull/on-conflict (in
  Pull); pre-* veto -> PullResult/Result.Vetoed -> Sync skips, waits for next nudge
- daemon builds a Runner per mount; cmd mount/publish pass nil (daemon drives hooks)
- tests: env+changed-files injection, absent=no-op, pre-* veto, 60s timeout kill,
  post-pull fires with changed list, pre-push vetoes (head not advanced)
2026-06-23 00:48:16 -05:00
931fd30432 docs: M4 done (sub-path mounts + bandwidth cap), M5 next 📊 2026-06-23 00:38:04 -05:00
512e7f8b73 feat(M4): sub-path mounts 🎯
- mount share/subpath into any local dir; Pull filters+strips the share manifest
  to the subpath, Push splices the local subtree back into the full share head
  (entries outside the subpath preserved) so a partial mount never drops the rest
- declares all full-manifest chunks for correct hub refcounts (hub chunks size 0)
- cmd: 'devbox mount projects/p22/backend /var/www'; daemon threads Subpath
- state keyed by share+subpath+local
- test: sub-path mount sees only its subtree (stripped); editing+pushing from it
  preserves docs/ and root.txt elsewhere in the share
2026-06-23 00:36:11 -05:00
6532c510f5 feat(M4) + harden: bandwidth cap + M3 review fixes 🔒🛡️
Bandwidth cap (M4):
- transport rate-limited blob up/download (golang.org/x/time/rate); config.toml
  [transfer].max_kbps; daemon applies it per mount; [secrets].extra_patterns too

M3 ponytail review fixes (data-loss + resilience):
- C1: conflict-copy names use nanoseconds + collision probe — second-granularity
  timestamps could collide and os.Rename would overwrite a copy (lost edit)
- C3: pull resilience — a filesystem clash (file<->dir) skips that path instead of
  aborting the whole batch; network errors still abort+retry. PullResult.Skipped
- C2(partial): manifest skips .devbox-tmp-* (atomic-write temp files never sync).
  Kept conflict-copy propagation (design + Dropbox: losing edit survives device death)
- dedup: manifest.SameContent shared (was duplicated in pull)
- tests: file<->dir clash skips one path not the mount; rate-limit throttles
2026-06-23 00:29:50 -05:00
1712bb26f3 docs: M3 done — live two-way sync fleet-verified 🔄✨ 2026-06-23 00:16:52 -05:00
dd0db590c7 feat(M3): live two-way sync — SSE fan-out + daemon + mount 🔄
- pkg/proto + internal/hub/events.go: SSE /v1/events with a broker; hub broadcasts
  on genuine head ADVANCE only (idempotent re-push doesn't broadcast -> no storm)
- transport.Client.Events: SSE consumer (timeout-less, ctx-cancelled)
- internal/daemon: per-mount loop funnels watcher + SSE triggers into a serialized
  Sync; read-only mounts pull-only; base snapshot persisted in state.json
- cmd/devbox: 'mount <share> <dir> [--ro]' (clone+sync) and 'start' (foreground daemon)
- fix: serialize chunk.Split — jotfs/fastcdc-go mutates a package global in
  NewChunker, racing under concurrent chunking (caught by -race)
- test: two live daemons, an edit on one reaches the other automatically (race-clean)
2026-06-23 00:12:39 -05:00
a951d4ab2f feat(M3): pull + 3-way merge engine — converge without losing a byte 🔱
- internal/syncer Pull: fetch hub head manifest, 3-way merge vs base + local tree:
  hub-only changes apply (write/delete), local-only stay, both-changed keeps hub
  canonical + preserves the local edit as path.conflict-<host>-<ts>.ext
- delete-vs-edit always keeps the edit; identical concurrent edits don't conflict
- Sync: pull->merge->push with conflict-retry loop (converges under races)
- atomic file writes; chunk reassembly via GetBlob
- tests: two devices concurrent-edit -> conflict copy propagates to BOTH, zero data
  loss; hub delete propagates to clones
2026-06-23 00:01:06 -05:00
3cfef72a88 harden(M2->M3): parent-aware push + hashed bearers + blob download 🔐
From the M2 ponytail review (the load-bearing findings):
- hub push now enforces parent==head: re-push=idempotent, parent==head=fast-forward,
  else Conflict (never clobbers head) — the foundation M3 conflict resolution needs
- bearers stored as sha256 (like join tokens), no plaintext creds at rest / timing oracle
- GET /v1/blob/{hash} download + client.GetBlob — pull needs it
- randHex propagates crypto/rand errors (no silent low-entropy tokens)
- syncer/publish are head-aware and surface conflicts
- tests: conflict-when-behind (head not clobbered), manifest download+parse

Kept rw-by-default (intentional single-owner v1 per spec §6).
2026-06-22 23:54:55 -05:00
3a0513de5b chore: fleet deploy scripts + systemd unit 🚚
- deploy/devbox-hub.service: reboot-persistent systemd unit (the one live on .10)
- deploy/redeploy-hub.sh: cross-compile linux/amd64 + ship + restart hub
- deploy/redeploy-client.sh: build + push client to fleet macs
Captures the by-hand deploy flow so redeploys (every M3 endpoint) are one command.
2026-06-22 23:46:53 -05:00
9e1159bec0 docs: M2 done + deployed; M3 in progress 📊🛰️ 2026-06-22 23:44:46 -05:00
55175fa2ac feat(M2): hub server + transport client + push engine + CLI 🛰️
- internal/hub: HTTP server (join/publish/have/blob/push/head/metrics), bearer auth,
  blob hash-verify, hand-rolled Prometheus /metrics (no dep)
- internal/transport: device HTTP client for the full wire contract
- internal/syncer: device push engine (build manifest -> upload missing blobs ->
  commit snapshot) + .devignore loader; in-process e2e test (join->publish->push)
- meta: idempotent AddSnapshot (content-addressed re-push advances head, no double
  refcount) + busy_timeout for multi-process CLI access
- cmd/devbox-hub: serve/token/readonly/revoke; cmd/devbox: real join + publish/push
- config: persist bearer + device id

Verified end-to-end with real binaries: secret blocked, node_modules ignored,
re-publish dedups to 0 uploads.
2026-06-22 23:40:18 -05:00
f6e1f91d67 feat(M2): wire protocol foundation 🔌
- pkg/proto: hub<->device wire types + endpoint paths (join/publish/have/blob/push/head/metrics)
- manifest: Marshal/Unmarshal (JSON); ID = BLAKE3 of canonical bytes = blob key = snapshot id
- meta: bearer-token column + IssueBearer/DeviceByBearer + Count (for /metrics)
- identity: FingerprintOf(pubkey) so hub derives the same device id the device does
2026-06-22 23:30:01 -05:00
3884f732b5 feat(M2): SQLite hub metadata store 🗄️
- internal/hub/meta: pure-Go modernc.org/sqlite (no CGO -> trivial cross-compile)
- schema: devices, tokens, shares, access(writable bit), snapshots, chunks(refcount)
- AddSnapshot in a tx: insert + bump distinct-chunk refcounts + advance share head
- single access knob = per-(device,share) writable; tokens redeem-once + expiry
- tests: device lifecycle, token redeem-once/expiry, writable default+override,
  shares/snapshots/refcounts (dedup within + across snapshots)
2026-06-22 23:24:55 -05:00
1522004e48 fix: foundation hardening from review pass 🛡️
- chunk.Split returns ([]Chunk, error); stop conflating read errors with EOF
  (latent now, would silently corrupt snapshots once streaming) + manifest propagates
- watch: stop+drain timer before Reset — kills the classic race where a buffered
  tick leaks a premature pre-debounce signal (would sync half-written files)
- config.SaveDaemon + identity.Save now atomic (temp+rename) — no truncated config
- secret guard blocks a regular file literally named 'secrets' (dir-pattern slip)
- identity.Load validates PEM block type; devbox status surfaces config read errors
2026-06-22 23:24:55 -05:00
9788442f32 feat(M2): content-addressed BlobStore (disk CAS) 🧊
- internal/hub/blobstore: Store interface (Has/Put/Get/Delete) + Disk impl
- sharded root/<first2>/<hash>, atomic put (temp+rename, never over-existing),
  idempotent, ErrNotFound sentinel — the open-core seam (S3/R2 later)
- tests: roundtrip, idempotent, missing-errors, no temp leftovers
2026-06-22 23:16:51 -05:00
546270d4f4 docs: mark M0+M1 done, M2 in progress 📊 2026-06-22 23:14:32 -05:00
4792c2609d feat(M1): debounced recursive fsnotify watcher 👁️
- internal/watch: fsnotify wrapper, coalesces bursts via debounce timer, auto-
  subscribes newly-created subdirs, single Events() signal channel
- tests pass under -race: detect change, pick up new subdir, coalesce burst

Completes M1 — full watch -> filter -> chunk -> manifest -> diff pipeline.
2026-06-22 23:12:30 -05:00
c2bfb5eac7 feat(M1): ignore + chunk + secret + manifest 👀
- internal/ignore: gitignore-syntax .devignore matcher (stdlib, last-match-wins,
  ** / negation / anchoring, always-ignore .devbox/)
- internal/chunk: FastCDC (jotfs/fastcdc-go) + BLAKE3 (zeebo/blake3); Split/Hash,
  dedup-localizes-edits verified (~98% reuse on mid-blob edit)
- internal/secret: default-on deny-list guard (reuses ignore matcher); .env/keys/
  certs/secrets blocked, .env.example allowed, user extras + negation un-block
- internal/manifest: tree walk -> filter (ignore + secret) -> chunk -> content-
  addressed manifest (ID = BLAKE3) + Diff (added/modified/deleted) + blocked list

Full filter->chunk->manifest->diff pipeline tested green.
2026-06-22 23:10:21 -05:00
79f91597ad feat(M0): skeleton — cobra CLI, Ed25519 identity, machine config 🦴
- cmd/devbox: join/status/version + stubbed start/stop/publish
- cmd/devbox-hub: version + stubbed serve/token
- internal/identity: Ed25519 keypair gen/save/load (0600), fingerprint
- internal/config: daemon.toml read/write (hub + mounts), XDG-aware dir
- tests: identity round-trip/idempotent, config round-trip

devbox join now generates a device identity and records the hub locally.
2026-06-22 23:01:00 -05:00