Files
devvm/internal/cli/docgen
w3cjandClaude Opus 5.5 f2a8ddd404 refactor: write every file whole through state, and make private folders with state.PrivateDir
internal/state is the one writer of whole files outside the proxy:
state.WriteFileMode joins state.WriteFile for another mode (0700 for
the QEMU wrapper and Docker's copies of devvm's Linux build), and
state.PrivateDir makes a folder the user's alone (700), refusing a file
or a symbolic link there, as vmssh's runDir did.

- Deleted: both writeOwn (backend's build proxy, Docker's egress), lima's
  writeFile (the Seatbelt profile, the QEMU wrapper, the start record),
  vmssh's writeWhole and runDir, Docker's copyFile, the Linux build
  fetch's temporary file (fetch.Open's body is read whole, its SHA-256
  checked, then written with state.WriteFileMode), and Resolve's
  .tmp-and-rename loop. The host's mise stays fetch.Download's.
- os.WriteFile to state.WriteFile: tools (Resolve's and lockVersions'
  mise.toml, the checked file, the tools build's files), sshagent (two),
  ubuntu's checksum files, docgen's pages and backendtest's fake tool
  images.
- state.PrivateDir for nine MkdirAll and Chmod pairs (eleven folders):
  the run log's two, tools' logs, secrets, netpolicy's CA, run, logs and
  socket folder, lima's run folder and the exports folder. MakePrivate
  and ~/.ssh keep following a link: where they live is the user's choice.
- The proxy's writers are one, writeAtomic: the login files' writeJSON
  and the Nix cache's size file use it, its temporary files named
  .<name>.tmp-* as state's are.
- forbidigo bans os.WriteFile outside internal/state, internal/proxy,
  internal/msg/gen, internal/stubtest and tests, with its line in
  testdata/lint/forbidigo.go.

Tests: TestWriteFileMode, TestPrivateDir (a symbolic link to a folder
refused, its folder's mode unchanged), TestWriteAtomic; mode checks on
the Seatbelt profile and Docker's Linux build copy. Coverage baselines
raised: lima, netpolicy, proxy, secrets, ui.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 15:50:40 -07:00
..