banger/internal
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
..
api Remove image build --from-image; doctor treats catalog images as OK 2026-04-18 15:54:29 -03:00
buildinfo Stamp shared build metadata into banger binaries 2026-03-22 17:14:06 -03:00
cli vm run --rm: suppress the still-running reminder 2026-04-18 16:10:29 -03:00
config file_sync: config-driven replacement for hardcoded auth sync 2026-04-18 16:40:11 -03:00
daemon file_sync: config-driven replacement for hardcoded auth sync 2026-04-18 16:40:11 -03:00
firecracker Add experimental Void guest workflow and vsock agent 2026-03-19 14:51:25 -03:00
guest Add guest.session.send and vm.workspace.export RPCs 2026-04-14 15:21:50 -03:00
guestconfig Refactor VM lifecycle around capabilities 2026-03-18 19:28:26 -03:00
guestnet Stop using kernel IP autoconfig for runtime VMs 2026-03-21 21:54:18 -03:00
hostnat Move helper NAT management into Go 2026-03-17 15:07:49 -03:00
imagecat publish-golden-image: content-addressed tarball names 2026-04-18 15:26:57 -03:00
imagepull imagepull/BuildExt4: omit positional fs-size; rely on file truncation 2026-04-18 14:58:42 -03:00
kernelcat Prune legacy void/alpine + customize.sh flows 2026-04-18 15:39:53 -03:00
model file_sync: config-driven replacement for hardcoded auth sync 2026-04-18 16:40:11 -03:00
namegen Remove runtime-bundle image dependencies 2026-03-21 18:34:53 -03:00
opencode Wait for real guest vsock health before opencode 2026-03-21 21:14:22 -03:00
paths Phase 1: imagepull package — pull, flatten, ext4 2026-04-16 17:22:13 -03:00
policy Add vsock-backed VM port inspection 2026-03-19 15:52:11 -03:00
rpc Propagate RPC cancellation to daemon requests 2026-03-16 18:28:33 -03:00
sessionstream Add guest sessions and agent VM defaults 2026-04-12 23:48:42 -03:00
store Add guest sessions and agent VM defaults 2026-04-12 23:48:42 -03:00
system Phase B-1: ownership fixup via debugfs pass 2026-04-16 18:04:22 -03:00
toolingplan Bootstrap vm run tooling before attach 2026-03-29 11:38:05 -03:00
vmdns Replace mapdns with daemon DNS 2026-03-17 15:49:35 -03:00
vsockagent Add vsock-backed VM port inspection 2026-03-19 15:52:11 -03:00
webui Remove image build --from-image; doctor treats catalog images as OK 2026-04-18 15:54:29 -03:00