Commit graph

8 commits

Author SHA1 Message Date
11fe999ca2 feat(transfer): opt-in gzip blob compression for WAN sync 🌐🗜️
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.
2026-06-30 12:34:27 -05:00
03469958d3 chore: prep for public release — MIT license + github.com module path 🌍⚖️
Some checks are pending
CI / vet-build-test (push) Waiting to run
- LICENSE: MIT (enables the adoption push; public repo was all-rights-reserved).
- go.mod + all imports: git.shoemoney.ai/shoemoney/devbox -> github.com/shoemoney/devbox,
  so outsiders can 'go install github.com/shoemoney/devbox/cmd/devbox@latest'. Forgejo
  stays the self-hosted home; the registry (devbox-hub) + public dist (devbox-dist) are
  unchanged. vet + build + go test -race all green after the rename.
- README: document the go install path.

Security: full git-history scan (manual blob sweep + gitleaks, 84 commits) found
ZERO secrets — Forgejo token never committed, no keys/passwords/private keys.
2026-06-23 19:19:09 -05:00
fd873a02c3 feat(M8a): device-facing invites with privilege attenuation ✉️🔐
Completes M8a's collaboration surface. A member mints an invite; the
invitee redeems it through the EXISTING /v1/join proof-of-possession flow
and lands enrolled + assigned the bound principal + granted the bound role.

- migration #3: invites table (token_hash → principal/share/role/+s),
  chains 0→1→2→3 — verified on a copy of the real hub DB.
- POST /v1/invite (authed) enforces ATTENUATION server-side via the pure,
  unit-tested meta.MayGrant: never grant above your own role, never touch a
  principal who outranks you, viewers can't grant, editors need +s. On a
  legacy share the inviter is seeded as owner before the explicit flip so
  they (and their same-principal devices) never self-lock-out.
- /v1/join applies a redeemed invite's binding (plain token = v1 join).
- transport.Invite + devbox invite <share> <principal> <role> [--reshare].

Tests: MayGrant attenuation matrix, invite binding round-trip, and the
end-to-end TestInviteFlow (owner invites → flip preserves owner → invitee
redeems into editor → editor-without-+s denied). 18 pkgs -race green;
linux/amd64 + windows cross-build.
2026-06-23 11:31:29 -05:00
68d25dfd38 feat(M8a): GET /v1/members + devbox members — read the role grants 👥📖
The read companion to devbox-hub member set/rm/list. Additive: new
PathMembers endpoint (authed; reads stay open in M8a — gating is M9),
proto.Member/MembersResponse, transport Members(), and a devbox members
<share> client command that prints 'legacy share' or the role grants
(principal, role, +s). Role name<->level mapping moved to meta
(ParseRole/RoleName) and the devbox-hub CLI deduped onto it; new
meta.ACLMode(share). Test: legacy reads empty, a grant flips it explicit
and lists bob/editor/+s. 18 pkgs -race green; windows cross-builds.
2026-06-23 11:23:13 -05:00
81fbc5c81a feat(M8a): principals + per-share roles + write enforcement 👥🔐
V2-SPEC §5.2 (write-side, staged before read-side M9). Migration #2 (rides
the M8 runner, chains 0→1→2 — verified on real .10 data, version 2, all
counts preserved):

- principals table + devices.principal_id (every v1 device backfills to one
  synthetic 'owner' principal — byte-identical to v1 until a share opts in).
- members(share, principal_id, role, can_reshare) + shares.acl_mode. A share
  with zero grants is 'legacy' (every device an implicit owner = v1); the
  first grant flips it to 'explicit' = deny-by-default.
- EffectiveRole(device, share) resolves device→principal→role; legacy⇒owner.
- Push write gate: role>=editor AND the access.writable clamp (which can only
  REMOVE write). Legacy shares reduce to the v1 writable bit exactly.
- devbox-hub member set/rm/list + principal <device> <principal> admin CLI —
  the populate path, so the role layer has a real consumer now (no dead code).

Tests: legacy↔explicit lifecycle, deny-by-default, viewer<editor, HTTP push
gate (403 unmembered/viewer, opens at editor). 18 pkgs -race green; hub
cross-compiles linux/amd64; windows builds.
2026-06-23 11:09:32 -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
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
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