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]
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]
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.
- 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.
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
- 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
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)
- 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
- 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)