Skip to content

refactor(mounts): extract host bind-mount logic into sandbox/mounts package - #44

Merged
neurolabs merged 1 commit into
mainfrom
refactor/mounts-package
Aug 31, 2026
Merged

refactor(mounts): extract host bind-mount logic into sandbox/mounts package#44
neurolabs merged 1 commit into
mainfrom
refactor/mounts-package

Conversation

@neurolabs

Copy link
Copy Markdown
Member

Description

Refactors the mount subsystem introduced in #42 out of internal/sandbox/options into its own internal/sandbox/mounts package, mirroring the existing internal/sandbox/network precedent for self-contained, domain-specific config types.

Triggered by discussion on #42, the hand-rolled mount shape parser (decodeMount switch) is replaced with mapstructure decoding: a string -> BindMount decode hook handles the short form (target: ~/.m2), and ResolveBindMounts remains the validation layer (path existence, ~ expansion, target conflicts, duplicates). Decoding is fully lenient — unknown fields are ignored.

The managed mount-point constants (VMHomeDir, WorkspaceMountPath, TmpMountPath) move with the subsystem so the dependency direction stays options -> mounts, and options no longer imports mapstructure.

Why not decode via viper's Unmarshal

A note for reviewers: the mounts map is decoded from v.Get("mounts") rather than through viper.Unmarshal because viper flattens dotted guest paths (e.g. /home/dev/.m2 into nested keys), which would corrupt the map keys. This is documented on the Config.Mounts field.

Checklist

  • make check passes (fmt, lint, test)
  • Tests added/updated
  • Internal refactor only — no behavior change, so no README/docs/CHANGELOG update warranted

…ackage

Refactors the mount subsystem introduced in #42 out of internal/sandbox/options
into its own package, mirroring the internal/sandbox/network precedent. Decode
now delegates shape parsing to mapstructure with a string->BindMount hook
(fully lenient, no unknown-field rejection), leaving ResolveBindMounts as the
validation layer.

The managed mount-point constants (VMHomeDir, WorkspaceMountPath, TmpMountPath)
move with the subsystem so the dependency direction stays options -> mounts.

Also documents in AGENTS.md how to finalize a sandbox session.
@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.73%. Comparing base (b13e77b) to head (69c70f9).

Files with missing lines Patch % Lines
internal/sandbox/mounts/mounts.go 88.23% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #44      +/-   ##
==========================================
- Coverage   88.80%   88.73%   -0.07%     
==========================================
  Files          87       87              
  Lines        5314     5299      -15     
==========================================
- Hits         4719     4702      -17     
- Misses        413      414       +1     
- Partials      182      183       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@neurolabs
neurolabs merged commit 5a5897c into main Aug 31, 2026
6 checks passed
@neurolabs
neurolabs requested a review from magro August 31, 2026 13:43
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