Repository navigation
feat(containment): add opt-in file watching on macOS - #430
Conversation
## Problem macOS directory watchers that use FSEvents cannot start inside Box. Node can report EMFILE for this service denial. Permitting the service does not give Linux-equivalent filename privacy: events can disclose denied names and activity, including outside the workspace and from past events. ## Solution Add native-file-watching, false by default, to agent, tool, and stdio MCP process tables. Select it independently for each process and its native descendants. Add ContainmentConfig::allow_native_file_watching() and one exact com.apple.FSEvents Mach lookup grant on macOS. Keep automatic runtime-service grants unchanged. Linux accepts the setting without changing enforcement or disclosure; remote HTTP MCP entries refuse it. On macOS, disclose the metadata limitation for each selected process. Keep existing direct content and write restrictions. Document the accepted risk, polling alternative, process selection, and rollback. Selected configurations require record version 33; absent or false settings retain their prior record and containment wire shapes. Broker and live record formats do not change. ## Tests native_file_watching_requires_an_explicit_boolean and native_file_watching_is_off_in_old_wire_and_preserved_when_selected cover the default, type checks, and wire compatibility. native_file_watching_is_versioned_and_selected_per_process and native_file_watching_version_survives_other_feature_selections cover version 33, independent selections, round trips, and version precedence. a_remote_mcp_server_refuses_native_file_watching covers both boolean values. native_file_watching_follows_only_the_selected_process covers propagation and macOS-only disclosure for agents, tools, and local MCP servers. native_file_watching_adds_only_the_exact_fsevents_lookup compares the full agent and leaf profiles with only the selected lookup removed. The shipped-launcher tests an_agent_must_opt_in_before_fsevents_starts, an_opted_in_agent_watches_changes_and_keeps_direct_denials, an_opted_in_tool_watches_without_enabling_its_agent, and an_agent_opt_in_does_not_enable_a_tool cover create, modify, rename, and delete events, strict defaults, process independence, and direct stat/list/read/write/ unlink denials with allowed-access controls. Each new test was checked against a relevant mutation in an isolated scratch checkout. On macOS 26.7.3, both-package all-feature build, scoped all-target/all-feature clippy, root format check, and both-package no-default build passed. Clippy reported zero owned warnings and six existing vendored Shell warnings; the no-default build retains the existing unused render_profile warning. The single scripts/test-all.sh sweep reported 5,105 passed, 1 failed, and 19 ignored. Its only failure was a_record_from_another_format_is_refused, whose old highest-version sentinel collided with the new version 33. The corrected final-source test passed on rerun, as did the final precedence test. All other workspace suites passed. site_manifest passed all 27 tests. The deterministic harness was GREEN: 129 PASS, zero FAIL/ERROR, and 12 declared Linux-only SKIP, with coverage_gate=full. Reported host gaps: no Homebrew Python, no Python or Node within the operator home, no credsd daemon, and a filesystem that refuses non-UTF-8 pathnames. No scripted examples remain; the live SDK tutorial was not run. Linux ARM64 all-target/all-feature check and full build passed in Finch; five Box configuration/boundary tests and the containment wire test passed there. The full Linux native enforcement suite remains for CI. FSEvents metadata privacy remains an explicit accepted limitation. No current Apple report was submitted as part of this change.
|
Assessment: Comment The mechanism is narrow and correct. It adds one exact Assumptions and rules checked that held
The kernel-level native tests, with probes for both granted and refused access, are a strong regression guard. |
Print the existing native file-watching warning for each selected stdio MCP server before the agent starts, even when that server is never invoked. Share the warning text with the launch-time boundary disclosure. The startup regression covers omitted, false, and true selections, independent agent and server settings, warning order, zero server invocations, and Linux silence. Clarify the previously approved exception to the four-input authority test and document when MCP warnings are printed. Validation: scripts/test-all.sh passed (5,107 passed, 0 failed, 19 ignored). The new startup regression failed when only the startup warning was removed. All-feature and no-default builds, workspace fmt, scoped clippy, and the locked site_manifest suite (27 tests) passed. Clippy reported only six unchanged vendored warnings; no-default retained the existing render_profile warning. The deterministic harness was GREEN (129 passed, 12 declared Linux-only skips, 0 failed/errors; full coverage). Linux ARM64 all-target/all-feature locked cargo check passed, including the new test; Linux runtime remains for CI. Host-dependent coverage gaps: no credsd, home-directory Node/Python, Homebrew Python, or non-UTF-8 filename support. No scripted examples remained; the live SDK tutorial was not run.
|
Assessment: Approve 710eb58 resolves both earlier findings: stdio MCP servers now get the warning at startup, and the decision entry records the four-inputs exception. I found no new issues in the 85-line delta. Assumptions and rules checked that held (delta since 9f0e78d)
|
…native-file-watch # Conflicts: # crates/box/src/record/config/mod.rs
Version the watching record in the same chain as every other feature, drop a test that rechecked serde and the config tests, match the boundary and wire tests to their file-attributes siblings, and place the config guide section after the process prose so no existing text changes.
|
Assessment: Approve Since 710eb58, the branch has merged main (#397 took record version 33 for Assumptions and rules checked that held (delta 710eb58 → 603f672)
|
…native-file-watch # Conflicts: # crates/box/src/record/config/mod.rs # docs/user/native-filesystem-policy.md
Restore the process-field wording the README and containment design had, point the MCP guide and architecture note at the config reference instead of repeating it, fold the remote-MCP refusal into the per-process test, and drop the precedence test the version chain now makes redundant.
|
Assessment: Approve Since 603f672, the branch has one change: a merge of main. Main's #437 took record version 34 for box IDs that library callers supply, so the watching record correctly moves to 35. The merge resolution is correct. I have one small follow-up. Suggestion (non-blocking): add Assumptions checked that held (delta 603f672 → e18c648)
|
|
Assessment: Approve Since 603f672, the branch has merged main and added one commit, d2b9fef, which cuts back the docs and folds the tests together. I found nothing to fix. Assumptions and rules checked that held (603f672 → d2b9fef)
|
The switch only gates macOS FSEvents, and Linux ignores it. The shorter key matches file-attributes and the docs' own wording.
|
Reviewed at The mechanism looks right to me, and I found no escape. The setting is opt-in, the Two findings are about the startup disclosure rather than the mechanism. One is a The startup disclosure does not name a host-wide activity counterType: Security | Interpreted Severity: P0 (warrants review)
Human-readable explanationAn operator sets The same grant discloses a third thing, and the warning does not name it. The The counter leaks no name and no file content, so I read the channel itself as low One consequence I did not test. Two boxes on one host could signal each other Reproduction detailsTested: Write a temporary probe that links
Expected: With the setting absent, the counter should not answer, because the Observed with the setting on: The counter read 121867601, then advanced 1462, Observed with the setting absent: The counter returned 0 and the volume Control: The same probe outside any box read the counter and the identifier, Limits: The two-box signaling case did not run. The counter's resolution and A root workload reaches the history delete, and the disclosure does not say soType: Security | Interpreted Severity: P0 (warrants review)
Human-readable explanationThe grant authorizes a workload to open a connection to one named service. Box That service does more than report file changes. It holds seven operations. One of Seatbelt decides one thing here, which is whether the workload may open the Two options look reasonable to me. Name the delete in To be clear about what this is and is not: I am not reporting an escape from the Evidence detailsNo runtime reproduction ran. I did not call the delete operation, and I never ran Tested: Observed, with a probe inside a real box:
Read from the rendered profile, taken from the box's own trampoline configuration: Source-confirmed, from Apple's installed SDK header for this release: the delete Inference, which is the step I did not measure: because Seatbelt authorizes the Limits: Whether the delete then removes history is Apple's behavior and was not No test obtains the service inside a real boxType: Testing | Interpreted Severity: P1 (non-blocking)
Human-readable explanation
No test asks the operating system whether the grant works. So a change that Two further gaps sit beside it. No golden profile renders a file-watching box. And Would it make sense to add the two probe rows before the next change to this Reproduction detailsTested: Extend the existing table with Measured values for those rows:
Control: Keep the uncontained arm. A retired service answers 1102 and a Limits: I ran these arms through a hand-written probe and a local |
Description
Dev servers and build tools watch files so they can reload on each edit. On macOS they use FSEvents, which Box blocks. So inside Box,
next devmisses edits and new routes, and Node reports a misleadingEMFILEerror. The same server works outside Box. The only workaround today is framework-specific polling, such asWATCHPACK_POLLING=1000.This PR adds an opt-in
file-watching = trueon[agent],[tool.<name>], or stdio[mcp.<name>]:false. Each table opts in on its own; the agent's choice does not reach its tools or servers.com.apple.FSEventsMach lookup. Content and write restrictions still apply.falseleaves stored records and wire shapes unchanged.ContainmentConfig::allow_file_watching()is the new crate API.The disclosure is an explicit exception to the four-inputs authority test, recorded in
docs/design/decisions.md. Polling stays the answer when names must stay private.Precedent
file-attributesis the closest match. It is a macOS-only switch that defaults tofalse, has no effect on Linux (which accepts the key), adds afile attributes:line to each process's startup disclosure, and stamps a newer record version.file-watchingfollows the same shape andfile-naming.network.contain_egress = falseis the scope precedent. It grants reach outside policy, so each tool or stdio server opts in on its own table and gets anative egress:disclosure line.file-watchingis per table for the same reason, unlike the box-widefile-attributes, which widens only the process's ownwritegrants.Related Issues
Refs #419. The strict FSEvents metadata isolation requirement remains unresolved.
Type of Change
New feature
Testing
scripts/test-all.sh.cargo fmt --checkand scoped clippy for both changed crates.macOS follow-up validation passed:
render_profilewarning.scripts/test-all.sh: 5,107 passed, zero failed, and 19 ignored. The lockedsite_manifestsuite also passed all 27 tests.test-integ/run.sh: GREEN, with 129 passes, 12 declared Linux-only skips, and zero failures or errors across all 141 expected results. Coverage was full, with no quarantine or integrity problems.Host-dependent coverage gaps were missing credsd, home-directory Node/Python, Homebrew Python, and filesystem support for non-UTF-8 filenames. No scripted examples remained; the live SDK tutorial was not run.
The native macOS launcher tests cover create, modify, rename, delete, default denial, agent/tool selection, and direct stat/list/read/write/unlink refusals with successful allowed-access controls. A profile comparison verifies that only the exact service lookup changes. Configuration tests cover all three process types, version precedence, serialization, remote-MCP refusal, and macOS-only disclosure. A startup regression also checks that an unused MCP server's warning precedes the agent, covers omitted/false/true settings and independent process selections, and expects no warning on Linux. Removing only the startup warning makes that regression fail. Independent mutation review checked each new test.
After merging
main, the full workspace suite ran on Linux aarch64: 170 of 173 targets pass, including everyfile_watchingtest,runtime_mcp_start,config_model, andprofile_conformance. The 3 failures are in files this PR does not touch (box_telemetryOTLP content type,runtime_mcp_policy_stagingcatalog page limit timeout,ingressPID 1 readiness timing).cargo fmt --checkand CI's Clippy invocation pass.The earlier follow-up compiled successfully on Linux ARM64 with
cargo check -p strands-box --all-targets --all-features --lockedin Finch, including the new test. Linux runtime execution of the follow-up remains for CI. No Apple report was submitted.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.