banger/internal/daemon
Thales Maciel 0933deaeb1
file_sync: config-driven replacement for hardcoded auth sync
Replace the three hardcoded host→guest credential syncs (opencode,
claude, pi) with a generic `[[file_sync]]` config list. Default is
empty — users opt in to exactly what they want synced, with no
surprise about which tools banger "supports".

```toml
[[file_sync]]
host = "~/.local/share/opencode/auth.json"
guest = "~/.local/share/opencode/auth.json"

[[file_sync]]
host = "~/.aws"          # directories are copied recursively
guest = "~/.aws"

[[file_sync]]
host = "~/bin/my-script"
guest = "~/bin/my-script"
mode = "0755"            # optional; default 0600 for files
```

Semantics:
- Host `~/...` expands against the host user's $HOME. Absolute host
  paths are used as-is.
- Guest must live under `~/` or `/root/...` — banger's work disk is
  mounted at /root in the guest, so that's the syncable namespace.
  Anything outside is rejected at config load.
- Validation at config load: reject empty paths, relative paths,
  `..` traversal, `~user/...`, malformed mode strings. Errors name
  the offending entry index.
- Missing host paths are a soft skip with a warn log (existing
  behaviour). Other errors (read, mkdir, install) abort VM create.
- File entries: `install -o 0 -g 0 -m <mode>` (default 0600).
- Directory entries: walked in Go; each source file is installed
  with its own source permissions preserved. The entry's `mode` is
  ignored for directories.

Removed (all dead after this):
- `ensureOpencodeAuthOnWorkDisk`, `ensureClaudeAuthOnWorkDisk`,
  `ensurePiAuthOnWorkDisk`, the shared `ensureAuthFileOnWorkDisk`,
  their `warn*Skipped` helpers, `resolveHost{Opencode,Claude,Pi}AuthPath`,
  and the work-disk relative-path + default display-path constants.
- The capability hook registering the three syncs now calls the
  generic `runFileSync` once.

Seven tests exercising the old codepath deleted; six new tests cover
the new runFileSync (no-op on empty config, file copy, custom mode,
missing-host-skip, overwrite, recursive directory). Config-layer
test adds happy-path parsing and a case-per-shape table of invalid
entries (empty, relative host, guest outside /root, '..' traversal,
`~user`, bad mode).

README updated: replaces the "Credential sync" section with a
"File sync" section showing the new config shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 16:40:11 -03:00
..
dmsnap Extract opstate and dmsnap into subpackages 2026-04-15 16:02:43 -03:00
fcproc Extract fcproc subpackage for firecracker process helpers 2026-04-15 16:11:39 -03:00
imagemgr Remove image build --from-image; doctor treats catalog images as OK 2026-04-18 15:54:29 -03:00
opstate Extract opstate and dmsnap into subpackages 2026-04-15 16:02:43 -03:00
session Add lint targets, fix gofmt drift, broaden Makefile build inputs 2026-04-16 16:49:17 -03:00
workspace Extract workspace subpackage with pure repo helpers 2026-04-15 16:37:19 -03:00
ARCHITECTURE.md Remove image build --from-image; doctor treats catalog images as OK 2026-04-18 15:54:29 -03:00
autopull_test.go vm create: auto-pull image and kernel from catalogs if missing 2026-04-18 15:10:26 -03:00
capabilities.go file_sync: config-driven replacement for hardcoded auth sync 2026-04-18 16:40:11 -03:00
capabilities_test.go Manage image artifacts and show VM create progress 2026-03-21 14:48:01 -03:00
daemon.go Remove image build --from-image; doctor treats catalog images as OK 2026-04-18 15:54:29 -03:00
daemon_test.go Remove image build --from-image; doctor treats catalog images as OK 2026-04-18 15:54:29 -03:00
dashboard.go Serve a local web UI from bangerd 2026-03-21 16:47:47 -03:00
dns_routing.go Route .vm DNS through systemd-resolved 2026-03-22 15:07:22 -03:00
dns_routing_test.go Route .vm DNS through systemd-resolved 2026-03-22 15:07:22 -03:00
doc.go Remove image build --from-image; doctor treats catalog images as OK 2026-04-18 15:54:29 -03:00
doctor.go Remove image build --from-image; doctor treats catalog images as OK 2026-04-18 15:54:29 -03:00
fastpath_test.go Manage image artifacts and show VM create progress 2026-03-21 14:48:01 -03:00
guest_sessions.go Extract workspace subpackage with pure repo helpers 2026-04-15 16:37:19 -03:00
guest_sessions_test.go Extract session subpackage with pure guest-session helpers 2026-04-15 16:33:12 -03:00
image_seed.go Manage image artifacts and show VM create progress 2026-03-21 14:48:01 -03:00
images.go Remove image build --from-image; doctor treats catalog images as OK 2026-04-18 15:54:29 -03:00
images_pull.go vm create: auto-pull image and kernel from catalogs if missing 2026-04-18 15:10:26 -03:00
images_pull_bundle_test.go image pull: dispatch to imagecat bundle path before OCI 2026-04-17 15:43:33 -03:00
images_pull_test.go Phase B-2: pre-inject banger guest agents into pulled rootfs 2026-04-16 18:08:56 -03:00
kernels.go Phase 4: remote catalog + banger kernel pull 2026-04-16 15:05:42 -03:00
kernels_test.go Phase 4: remote catalog + banger kernel pull 2026-04-16 15:05:42 -03:00
logger.go Speed up VM create with work seeds 2026-03-18 21:22:12 -03:00
logger_test.go Remove image build --from-image; doctor treats catalog images as OK 2026-04-18 15:54:29 -03:00
nat.go Move helper NAT management into Go 2026-03-17 15:07:49 -03:00
nat_test.go Move helper NAT management into Go 2026-03-17 15:07:49 -03:00
opencode.go Generic kernel + init= boot path for OCI-pulled images 2026-04-16 20:12:56 -03:00
ports.go Refine vm ports output 2026-03-19 18:21:04 -03:00
preflight.go Remove image build --from-image; doctor treats catalog images as OK 2026-04-18 15:54:29 -03:00
runtime_assets.go Remove runtime-bundle image dependencies 2026-03-21 18:34:53 -03:00
session_attach.go Extract session subpackage with pure guest-session helpers 2026-04-15 16:33:12 -03:00
session_controller.go Extract session subpackage with pure guest-session helpers 2026-04-15 16:33:12 -03:00
session_lifecycle.go Extract session subpackage with pure guest-session helpers 2026-04-15 16:33:12 -03:00
session_stream.go Extract session subpackage with pure guest-session helpers 2026-04-15 16:33:12 -03:00
snapshot.go Extract opstate and dmsnap into subpackages 2026-04-15 16:02:43 -03:00
snapshot_test.go Harden VM stop cleanup for stale snapshots 2026-03-18 12:28:15 -03:00
ssh_client_config.go Configure direct SSH access for .vm hosts 2026-03-22 16:48:42 -03:00
ssh_client_config_test.go Configure direct SSH access for .vm hosts 2026-03-22 16:48:42 -03:00
tap_pool.go Move subsystem state/locks off Daemon into owning types 2026-04-15 15:58:33 -03:00
vm.go Extract fcproc subpackage for firecracker process helpers 2026-04-15 16:11:39 -03:00
vm_authsync.go file_sync: config-driven replacement for hardcoded auth sync 2026-04-18 16:40:11 -03:00
vm_create.go vm create: auto-pull image and kernel from catalogs if missing 2026-04-18 15:10:26 -03:00
vm_create_ops.go Add lint targets, fix gofmt drift, broaden Makefile build inputs 2026-04-16 16:49:17 -03:00
vm_disk.go Split internal/daemon vm.go and guest_sessions.go by concern 2026-04-15 15:47:08 -03:00
vm_lifecycle.go vm_lifecycle: drop systemd.mask=dev-{ttyS0,vdb}.device 2026-04-18 14:58:42 -03:00
vm_locks.go Move subsystem state/locks off Daemon into owning types 2026-04-15 15:58:33 -03:00
vm_set.go Split internal/daemon vm.go and guest_sessions.go by concern 2026-04-15 15:47:08 -03:00
vm_stats.go Split internal/daemon vm.go and guest_sessions.go by concern 2026-04-15 15:47:08 -03:00
vm_test.go file_sync: config-driven replacement for hardcoded auth sync 2026-04-18 16:40:11 -03:00
web.go Serve a local web UI from bangerd 2026-03-21 16:47:47 -03:00
workspace.go Extract workspace subpackage with pure repo helpers 2026-04-15 16:37:19 -03:00
workspace_test.go workspace.export: add base_commit to capture worker git commits 2026-04-14 16:13:05 -03:00