manifest.Build snapshots `ours` once before Pull applies any writes. A local
edit landing after that snapshot but before writeEntry looked unchanged
(oursCh false) and got overwritten with the hub version verbatim, with no
conflict copy — the edit's bytes ended up in no file and no snapshot.
Re-stat/re-hash the on-disk file right before a hub-only write would apply
and compare it against the entry manifest.Build captured. A mismatch routes
through the existing preserve-as-conflict path instead of clobbering. Only
checked when hub is about to write over a path `ours` already knew about —
a pure hub-only add has nothing on disk yet to race with.
This narrows the window, it doesn't close it: a rename at pull.go:424-451
still isn't atomic with this check. A real fix needs a filesystem-level
lock or lease around the whole pull, tracked separately.
Includes the untracked repro (zz_repro_stale_ours_test.go) that found this.
Push always treated the local .devignore/secret-guard-filtered manifest as
the FULL shared head, even on a whole-share mount — so a device with its own
--exclude for a path silently deleted that path from every other device's
copy on their next pull.
splice() now merges local entries over the parent head instead of the parent
head being consulted only for sub-path mounts: a parent-head path missing
from the local manifest is carried forward when the local ignore rules are
why it's invisible (excluded from view, not deleted). It is NOT carried
forward when the secret guard blocked it (the guard's job is to keep that
content out of the head) or when it's genuinely gone from disk with no
ignore rule hiding it (a real delete must still delete).
under()/strip() already treat subpath="" as "the whole path space," so this
is one code path for both mount kinds, not a special case bolted onto the
old one.
Includes the two repro tests (deduped from a near-copy) and a new delete-case
regression proving the fix didn't make real deletes un-deletable.
- add loadGuard(dir) helper in cmd/devbox/main.go; replaces all 4
secret.New(nil) calls in publish/mount/restore/deploy so user's
[secrets] extra_patterns from config.toml are enforced on CLI upload
paths (was only enforced by the daemon — security leak)
- SaveState: switch from fixed .tmp suffix to os.CreateTemp(.state-*.tmp)
mirroring SaveDaemon, eliminating concurrent-write corruption
Content-addressed snapshots can appear as prunable in two shares simultaneously.
The old inline manifestChunks call inside the prune loop read the blob after the
first share's iteration had already deleted it, returning ErrNotFound → nil hashes
→ DeleteSnapshot decremented nothing → chunk stayed at refcount 1 and leaked
forever. Pre-enumerate all chunk lists once before the deletion loop so both
(share,id) decrements always fire with the correct hash list.
No change to dry-run path: it never deletes blobs so ErrNotFound cannot occur there.
- ctxKey/deviceKey *string holder pattern; AccessLogMiddleware allocates holder, injects into ctx, logs devID (or "-" for anon) as final field
- auth now sets the holder after resolving deviceID — comment updated to match reality
- TestAccessLogDeviceID: healthz logs "-", authed /v1/head logs the real device id; captures global log.Writer()
Every connected client daemon holds a long-lived /v1/events SSE stream, and
http.Server.Shutdown waits for connections to go idle — which these never do —
so a graceful shutdown always burned the full 10s drain timeout (felt on every
hub redeploy with clients connected). RegisterOnShutdown now signals the broker
to return every active /v1/events handler, so shutdown completes near-instantly.
Test: TestCloseEventStreams (live stream returns promptly after the hook).
Round 8 was 0 GO — the codebase is mined out; this is the reversed no-go.
The live hub already returns 401 for /v1/invite/revoke (M8a deployed), so that
marker no longer proves a swap took — it'd pass even on the old binary. /healthz
is the clean old→new discriminator (pre-round-1 hub 404s it; new code 200s with
version), plus a /readyz DB-ping check. Used this to verify the 7-round redeploy.
`backup` does VACUUM INTO (DB snapshot) then copies the blob tree; a concurrent
gc sweep could delete a blob the snapshot references between those steps,
producing a backup that's internally inconsistent — a dangling ref you'd only
discover on restore. Now gc sweeps (the --gc-every ticker AND `gc`) and `backup`
take an exclusive flock on <data>/.lock, so they can't overlap. Dry-run gc skips
the lock (read-only, must not block a long backup). unix flock (auto-released on
crash); no-op stub on non-unix (the hub ships linux/darwin).
Test: TestDataLockMutualExclusion. Cross-builds clean for windows + linux/arm64.
Events() used a bare &http.Client{} (zero timeouts) — a black-holed TCP connect
blocked the daemon's reconnect loop forever (backoff only fires on stream
error/close, not a stuck connect). The bare client existed to dodge round-1's
30s TOTAL timeout on c.hc; round 2 removed that, so c.hc now bounds dial/TLS
with NO total timeout — exactly right for a long-lived SSE stream — and is
proxy-aware. One-line swap.
- fsck now also flags dangling snapshots (manifest → missing blob)
- status says when the daemon isn't running (no silent stale state)
(transport HTTP_PROXY regression fix restores standard env behavior — no doc knob)
- internal/transport/client.go: replace bare &http.Transport{} with
DefaultTransport.Clone() so HTTP_PROXY/HTTPS_PROXY/NO_PROXY, ForceAttemptHTTP2,
IdleConnTimeout, and ExpectContinueTimeout are preserved; only intentionally-tuned
fields (DialContext, TLSHandshakeTimeout, ResponseHeaderTimeout, DisableCompression,
MaxIdleConnsPerHost) are overridden.
- cmd/devbox/main.go: statusCmd disk path now calls control.DialState once upfront;
prints "⚠️ daemon not running — showing last-known disk state (run: devbox start)"
when daemon is absent so users aren't silently misled.
- Tests: TestTransportHonorsProxyEnv asserts Proxy!=nil + ForceAttemptHTTP2=true;
TestStatusDaemonNotRunning asserts warning appears on joined-but-no-daemon device.
Trust boundary: handlePush previously verified that every hash in req.Chunks
existed in the blob store, but it trusted req.Chunks as the authoritative list
of chunks the pushed manifest references. A buggy or malicious client could:
(a) Push a manifest referencing chunk C while omitting C from req.Chunks →
hub commits a snapshot whose manifest references a blob that may not
exist → every subsequent pull 404s on C (dangling snapshot).
(b) Include in req.Chunks a chunk not referenced by the manifest →
refcount is bumped for a blob GC can never safely collect (phantom ref).
Fix: after confirming the manifest blob is present, we now fetch + unmarshal
it and derive the DISTINCT chunk hash set directly from Manifest.Entries[*].Chunks.
Each hash in that set is verified to exist in the store; any missing hash rejects
the push with 409 (same status as before). Only manifest-referenced hashes are
passed to db.AddSnapshot() for refcounting.
Size hint: meta.ChunkRef.Size is used only for metrics/dashboard totals and is
stored once (first INSERT; ON CONFLICT only bumps refcount, not size). GC
decisions are made on refcount, not size. We keep req.Chunks as a size-hint
lookup (reqSizes map): if the client is honest the size is correct; if a hash is
absent from req.Chunks the size defaults to 0, which is harmless.
Happy-path unchanged: an honest client (syncer.go) always derives req.Chunks
from the same manifest, so all hashes are present with correct sizes.
Tests: TestHubHappyPath updated to push a real manifest JSON (required now that
the hub parses it); TestPushManifestChunkIntegrity asserts the malicious pattern
is rejected and the head does not advance, then confirms an honest push succeeds.
- status now surfaces per-mount last sync error (+ last_err in --json)
- serve: version/dashboard in startup log, non-loopback --listen warning, graceful SIGTERM shutdown
- warn when --listen is non-loopback (plain HTTP, cleartext bearer tokens)
- startup log now includes build version + dashboard on/off state
- serve blocks on SIGTERM/Interrupt; 10s drain window before exit
- hoist dashboard http.Server so shutdown also drains it
- table-test isLoopback (IPv4, IPv6, empty host, non-loopback variants)
Track lastErr per mount (mirroring lastSync pattern), cleared on
success so a recovered mount shows clean. Errors from LoadIgnoreWith,
Pull, and Sync all land in the map and surface through StateSnapshot
into 'devbox status' (human ⚠️ warning) and --json (last_err field).
- hub: backup <dir> (DR), serve --metrics-token / --access-log, device ls [--json]
(corrected the old aspirational `device list` row → real `device ls`), gc --keep-days
- client: doctor now also warns on clock skew vs the hub (>30s)
- 🩺 `doctor --json`: structured check report for cron/monitoring; still exits
non-zero on ❌ (collects checks into a slice, JSON path suppresses the human lines).
- 🗑️ `conflicts --rm`: delete every `.conflict-` copy after review (lazy cleanup,
not a resolver). Only touches conflict copies — real files untouched.
- ⏱️ `status` shows per-mount last-sync age ("synced 12s ago" / "not synced yet")
from a daemon-tracked timestamp (control.MountState.LastSyncUnix); also in --json.
- 🙈 the reversed no-go: `settings.sync.ignore_defaults` (opt-in, default off) layers
a built-in junk set (node_modules, .git, target, dist, build, .venv, __pycache__,
.next, .DS_Store) onto the matcher — don't ship gigabytes of regenerable junk over
the now-live WAN. Reuses round-1 --exclude plumbing; honored by daemon + publish.
Tests: doctor --json valid+exit-code, conflicts --rm deletes only conflicts,
ignore.Defaults match. go test ./... -race + vet clean.
- 📊 /metrics gains real WAN observability counters beyond the 4 gauges:
blob bytes in/out (the bandwidth signal now the hub is internet-reachable)
plus pushes/conflicts totals for sync churn. Atomic, incremented at the
blob + push handlers.
- 🩺 /healthz now reports the build version ("ok <version>") so a deploy can
curl-verify the new binary is actually live (SetVersion wired in serve).
Test: TestMetricsCountersAndHealthVersion (version in healthz; bytes_in/out
move on a real PUT/GET).
Now the hub is WAN-reachable, the transfer path needed real hardening:
- ⏱️ request timeout fix: replaced the 30s TOTAL http.Client.Timeout (which
killed a 256MiB blob mid-transfer over a slow link) with granular dial / TLS /
response-header timeouts + TCP keepalive. Body transfer is no longer wall-clocked.
- 🔁 retry + exponential backoff on transient blob transfers (network / 5xx),
3 attempts; 4xx fails fast. Blob GET/PUT are content-addressed (idempotent),
so retry is safe; control calls are left alone.
- 🚀 parallel blob uploads (push) and parallel chunk downloads (pull reassembly),
bounded pools (8), sharing the existing rate limiter. WAN is RTT-bound — this
keeps the pipe full instead of one-blob-at-a-time.
- 🗜️ download (response) gzip: round 1 compressed only uploads, but a clone is
download-heavy. Client negotiates gzip explicitly (so the rate limiter counts
wire bytes), hub streams the response through gzip, client decompresses
bomb-safely. Gated by the same settings.transfer.compress flag.
Tests: retry transient-then-success + 4xx-no-retry, gzip download round-trip.
All existing push/pull round-trips green under -race (refactors behavior-preserving).
The "changed my mind" feature: deferred as YAGNI on a LAN, but the hub is now
WAN-reachable (port-forwarded), so over-the-internet sync is a real path and
compression earns its keep.
- client (settings.transfer.compress, default off): gzip a blob upload only
when it actually shrinks — incompressible chunks (media, encrypted) go raw so
we never inflate the wire. Sets Content-Encoding: gzip. Wired into the daemon
sync loop and the initial `publish` upload.
- hub: decompresses gzip uploads before hashing, so dedup + content-address
integrity are unchanged. Bomb-safe — caps BOTH the compressed stream
(MaxBytesReader) and the decompressed size (LimitReader), rejecting a gzip
header over a non-gzip body.
Tests: client gzip-when-smaller / raw-when-not, hub decompress round-trip +
bad-gzip rejection. go test ./... -race clean, go vet clean.
Five device-side wins from the feature review:
- 🤖 `--json` on status/log/conflicts: machine-readable output for fleet
scripting/monitoring. status prefers live daemon state (paused +
base-snapshot), falls back to disk; not-joined → {"joined":false}.
- 🌊 streaming chunker: chunk.SplitReader feeds FastCDC from an io.Reader so
the manifest build no longer slurps whole files into RAM — a multi-GB file
can't OOM the daemon. Identical boundaries/hashes (proven vs fragmented reads).
- ⏱️ `devbox pause --for 2h`: control socket carries a duration; the daemon
schedules an auto-resume timer. Re-pause replaces it; plain pause/resume
cancel it (no surprise resume).
- 🙈 per-mount `devbox mount --exclude <pat>`: device-local ignore layered on
the shared .devignore (LoadIgnoreWith) — skip a local build dir without
touching the shared file. Honored by daemon sync, restore, and deploy.
- 🎛️ rescan cadence is now settings.sync.rescan_seconds (was a hardcoded 60s
const) — tune the watcher fallback per machine without a rebuild.
#6 (doctor non-zero exit) was already shipped — doctor returns an error on ❌.
Tests: SplitReader-vs-buffered, PauseFor auto-resume + cancel, wire duration,
LoadIgnoreWith layering, status/conflicts --json. go test ./... -race clean.