Skip to content

feat: add --snapshot and --nfs-opts flags#66

Merged
jamestexas merged 4 commits intomainfrom
feat/snapshot-nfs-opts
Mar 5, 2026
Merged

feat: add --snapshot and --nfs-opts flags#66
jamestexas merged 4 commits intomainfrom
feat/snapshot-nfs-opts

Conversation

@jamestexas
Copy link
Copy Markdown
Contributor

Summary

  • --snapshot: copies .db sources to temp before mounting for true sandbox isolation (non-.db paths already snapshot implicitly)
  • --nfs-opts: appends custom NFS mount options to defaults (e.g. rsize=32768,wsize=32768)
  • mount.Options struct added to public API so external consumers can pass NFS options

Breaking

mount.NFS() now takes *Options as third arg — pass nil for defaults. x-ray needs a one-liner update.

Test plan

  • 6 unit tests for BuildMountOpts (darwin/linux, writable, extra opts, unsupported OS)
  • 5 unit tests for snapshot copy (content integrity, isolation, empty file, missing source, path format)
  • Full test suite passes (task test)
  • Manual: mache --snapshot -d foo.db /tmp/mnt mounts from temp copy

🤖 Generated with Claude Code

--snapshot copies .db sources to a temp file before mounting, providing
true isolation (the agent reads a snapshot, not the live source DB).
Non-.db paths already snapshot implicitly (MemoryStore or temp index).

--nfs-opts lets users append custom NFS mount options (e.g. rsize,wsize)
to the defaults. Refactors BuildMountOpts as a testable exported function.

Public mount.Options struct added so external consumers (x-ray) can pass
NFS options through mount.NFS(). Breaking: mount.NFS() now takes *Options
as third arg (pass nil for defaults).

Signed-off-by: jamestexas <18285880+jamestexas@users.noreply.github.com>
@jamestexas jamestexas force-pushed the feat/snapshot-nfs-opts branch from f6c80c5 to 8658650 Compare March 5, 2026 17:31
--snapshot now copies both .db files AND source directories to temp
before mounting. Directory copy skips .git, node_modules, target, etc.
Write-back in agent mode now splices into the snapshot copy, not the
original source files — true sandbox isolation.

--agent now implies --snapshot by default, so agent mode always
operates on a copy. The snapshot is cleaned up on unmount.

Signed-off-by: jamestexas <18285880+jamestexas@users.noreply.github.com>
1. Writable snapshots preserved on unmount (agent edits survive).
   Prints diff/rsync/discard commands. Read-only snapshots still
   auto-cleaned.

2. agentMetadata.Source updated to snapshot path after copy, so
   PROMPT.txt shows the sandbox path, not the original source.

3. --snapshot=false overrides agent mode default (uses
   cmd.Flags().Changed to detect explicit user intent).

4. NFS server binds to 127.0.0.1 (was 0.0.0.0). SECURITY.md
   documents NullAuthHandler and localhost-only scope.

5. dirSize() warns before copying directories >1GB. Shared
   shouldSkipDir() keeps skip lists in sync between copyDir/dirSize.

6. --snapshot help text documents non-atomic copy limitation.

Bonus: mache clean now removes orphaned snapshots (snap-<PID>-*
where PID is dead).

Signed-off-by: jamestexas <18285880+jamestexas@users.noreply.github.com>
The prompt now explicitly explains "do this, not that" — agents should
read source files per-construct, not cat entire .go files. Includes:

- Table-based quick reference for common commands
- Clear "do/don't" section to override cat-the-whole-file habits
- Snapshot sandbox context: tells agent it's on an isolated copy
- Mode displayed as "Writable (snapshot sandbox)" not just "true"
- Editing workflow as numbered steps with diagnostics check

Signed-off-by: jamestexas <18285880+jamestexas@users.noreply.github.com>
@jamestexas jamestexas merged commit 254958c into main Mar 5, 2026
13 checks passed
@jamestexas jamestexas deleted the feat/snapshot-nfs-opts branch March 5, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant