Commit graph

13 commits

Author SHA1 Message Date
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
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
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
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