Skip to content

feat: add Linux filesystem policy operations - #193

Merged
kevin-orellana merged 18 commits into
mainfrom
feature/linux-native-operations
Nov 17, 2026
Merged

kevin-orellana merged 18 commits into
mainfrom
feature/linux-native-operations

Conversation

@kevin-orellana

@kevin-orellana kevin-orellana commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Human readable section

Problem: A Linux program can reach the paths granted by its Box configuration without a separate policy check for each file operation. Rules that govern reads, moves, and deletes therefore miss operations made directly by the program, rather than through Strands Shell.

Solution: Connect those direct, or native, file operations to Box's policy engine and shared history. Keep the existing path restrictions as an outer limit. This PR implements the operation checks and launch integration; #188 enables them in ordinary feature-enabled builds.

Example: A policy permits moving a file to an unused name but denies writing at that destination. The move succeeds. If a file already occupies the destination, replacement also needs destination write and delete permission. Denying the move at the destination blocks either case.

Trade-off: Linux activation remains limited to private test builds in this PR. The shared macOS adapter also changes: policies for directory opens must use enumerate, while regular-file reads keep read_content. A directory rename still requires the source read_content check on both platforms.

Description

This PR targets main. The launch and kernel prerequisites, #186 and #191, are merged. #188 remains the separate activation PR.

Operation checks and launch integration

  • Check opens, file creation, deletion, renames, directory creation and removal, symbolic-link creation, and path-based truncation. Resolve paths inside the workload's filesystem view and apply operations to the approved file or directory identity.
  • Connect agents, declared tools, and local Model Context Protocol (MCP) servers to the same policy engine and durable history. Prepare the kernel checks before runtime threads start, while preserving the existing readiness-callback order.
  • Use one kernel notification listener. The containment supervisor receives the notifications, answers filesystem-information queries, and forwards native operations to Box's policy worker over a private socket. The supervisor is the forwarding client; Box is the server. Box validates and answers native requests but does not compete to receive notifications.
  • Retain one pending notification when the forwarding socket is full. Wait for writable space while checking whether the workload has exited. A closed peer, invalid connection, or incomplete send still stops supervision. The intercepted operation never continues without its required policy decision.
  • Add the workload registration handshake, deadlines, shutdown handling, ARM64 C workloads, and regression coverage. Keep the Linux adapter behind the private box_native_adapter_tests compiler setting, including in ordinary --all-features builds. Linux x86-64 selection remains refused.

Shared notification routing. The containment supervisor answers statfs filesystem-information queries locally and forwards selected native operations to Box. Policy and the file-operation broker run in the same trusted Box process. A denied check prevents the operation; a full forwarding buffer pauses forwarding without discarding the pending request.

A native program issues a supported filesystem call. The kernel pauses it and notifies the containment supervisor, the sole notification receiver. The supervisor answers statfs information queries with filtered values. It forwards native-operation requests to policy checks inside Box. If all required checks allow, the broker in that same Box process attempts the operation and returns its result. If any check denies, the operation returns an error without being performed. When forwarding fills, the supervisor retains one request and waits for space. Native policy checks require a selected Linux ARM64 workload; filesystem grants still apply.

Editable diagram source

Policy decisions and compatibility

  • Every rename retains all permission checks. Source reads use read_content; source and destination each need move permission. Replacing an existing destination also requires write and delete permission there. Moving to an unused name does not require destination write permission.
  • One successful rename records one completed move. The completion belongs to the destination. For example, a rule that blocks reads after two completed moves permits a read after one rename and blocks it after two.
  • An abandoned check has no outcome. If a later permission check denies the operation, earlier checks remain request-only because no filesystem effect ran. Actual filesystem failures still record errors. Outcome paths retain the same policy-visible spelling as their requests, including home-relative paths.
  • Directory listing and directory renaming remain distinct. Directory opens use enumerate. Allowing listing does not satisfy the source read_content check required for a directory rename.

These semantics are the approved behavior changes. The PR adds no public Rust signature, configuration key, record version, or policy action. It also shares the selection predicate between configuration and runtime, documents unsafe-call requirements, and preserves the existing path, directory, and replacement-race assertions.

The documentation explains the Linux enforcement design, policy behavior and limits, and native test setup.

Related Issues

#127 tracks the Linux adapter. #186 and #191 are merged prerequisites; #188 activates this implementation. Review and merge #193 into main before retargeting #188 to main.

Cloud deployment qualification remains in the Linux cloud follow-up. Performance qualification remains separate. Human re-review is still required; the forwarding defect reported in the original review is repaired in this head.

Type of Change

New feature

Testing

November 16 latest-main integration

Merge commit: b9c63c08701b805397bb6d138471361bab911fd3. Tested source tree: e7ffb4b845855ed7b97d89089fdb8664586d0e25. Included main revision: 8c56aa80523884f3729a9bd1593a8efb7a9cbf8d.

This second merge incorporates the subsequent macOS file-watching changes from main. The only manual conflict resolution retains both the existing native-policy selection test and the incoming file-watching record-version test. It does not change native notification routing.

Formatting, ordinary strict workspace lint, and strict package lint with the private adapter enabled passed. Focused validation on the unchanged tree produced these results:

  • The ordinary Box configuration and startup selection reported 376 passes, including two script tests that returned early because the containment helper executable was missing beside the test binary. After building and installing that helper, both tests passed an exact rerun with their allow and deny behavior exercised.
  • Two portable containment file-watching cases and one Model Context Protocol (MCP) startup case passed.
  • The private-adapter Box selection initially reported 308 passes and 71 failures, plus the same two early returns. Seventy failures explicitly reported a missing containment helper; one reported a generic assertion failure. After building and installing the required helpers, the identical selection passed all 379 tests, including the two mechanism tests, with no failures, ignores, or skips. All three forwarding tests also passed. No source change was made between these runs.

The full-workspace, deterministic, no-default-feature, and full native kernel integration suites were not rerun on this final tree. Results below for a455afd apply to the first merge earlier today. That earlier workspace failure remains recorded. These focused passes do not establish release-profile, cloud, or macOS runtime qualification.

Earlier November 16 integration: a455afd

Merge commit: a455afdefabd344efb607c8eaa457a767d296221. Tested source tree: f69685c264e6062cdba960763212bf5cb1aae69a.

This update incorporates main at cb099d1d70027670fd96dc09a0c0d2be19beb49b. The conflict resolution preserves the caller-supplied Box identity (RunOptions::box_id) and upstream Shell adapter from main. It retains Linux native setup before runtime creation and registration of selected workloads. Notification routing and the private activation setting remain unchanged.

The ordinary build, formatting check, and strict package and whole-workspace Clippy checks passed. Whole-workspace lint used cargo clippy --workspace --locked --all-targets --all-features -- -D warnings.

The completed cargo test --workspace --locked --all-features --no-fail-fast run failed: 3,823 tests passed, three failed, and 16 were ignored. These totals sum the printed Rust test summaries, not unique assertions or checks inside the custom library harness. All 16 ignored-test declarations match the merged main revision. The failures were:

  • The Model Context Protocol (MCP) cancellation byte-limit test exceeded its 10-second deadline before observing the expected byte-limit error.
  • The MCP catalog page-limit test timed out while receiving a response. The output does not identify which initialization or paging step timed out.
  • The policy observer timing test measured a decision-time ratio of 2.24, above its 1.5 limit. Its preceding check confirmed delivery of all 1,000 records.

Each failed test passed an isolated, exact single-test rerun on the unchanged candidate and the same control on main at cb099d1. These six passes do not establish the cause or make the original full-workspace run a pass.

The deterministic integration gate (bash test-integ/run.sh --locked) reported GREEN with full manifest accounting: 131 passed and ten explicitly macOS-only rows skipped, out of 141 rows. It tested the debug, all-features Box executable with SHA256 591c89086de7f9d10d03a04f69c56e379bec2af0c70e70e5d893d95756241ea4, bound to the tested tree above. The harness builds itself in release mode; Box ran in debug mode. This is local Linux evidence, not release-profile or cloud qualification.

Compilation with the private adapter enabled passed. The two mechanism tests and three forwarding tests passed, with no skips. The ordinary workspace run selected zero tests in each of the four native kernel integration binaries because their required private compiler settings were absent. Neither those zero-test results nor the five focused tests establish a fresh run of the full native kernel integration suites.

The builds without default features passed on both this candidate and main at cb099d1. All 69 warnings match exactly, including their titles, source paths, and line and column locations. This comparison found no new warnings.

Portable Box identity configuration and storage tests passed. Caller-supplied Box identity end-to-end coverage is macOS-only and still requires hosted CI. The manual software development kit (SDK) tutorial was not run. The original full-workspace failure remains unresolved; this is not a blanket validation pass.

Earlier validation: 892a834 and separately named revisions

All results below belong to the stated earlier revisions. They do not establish a pass for the November 16 integration. References below to the CI-only follow-up, hosted checks, current forwarding step, or earlier lint limits retain their original historical scope.

Follow-up revision: 892a834a83935a1f6a78b75a4f616d8850e85379, tree 551b8afb7f5b563364cd42145637c5c713bf7c03. Local validation ran on an ARM64 Linux development host with Rust 1.98.1.

This follow-up changes only CI and documentation. The exact new CI command passed all three forwarding tests at 892a834. The earlier operations package checks below ran at b6b286c; the activation results identify their #188 revision separately. No Rust source or dependencies changed in this follow-up.

Hosted checks passed in run 43468356105, attempt 2. GitHub built merge revision 43a4d991118c3fea178a8d2451b64f186bf2376a: this PR head merged into main at 70eb3af. The Linux test job and final CI gate passed in attempt 2. Previously successful jobs were retained from attempt 1. The retry ran all three forwarding regressions successfully.

Attempt 1 failed when an unchanged test could not start its command-forwarding helper (Text file busy). The same test and helper source passed at b6b286c, tested against the same main revision. On retry, the complete helper suite passed all nine tests. The initial failure remains recorded; its underlying cause is unproved.

Check Result and scope
Forwarding CI step (892a834, local and hosted) 3 passed, zero failed, zero ignored on the development host. The exact workflow command and its shell failure handling passed. A zero-match control exited 1, proving that an incorrect filter cannot pass silently. The hosted step also passed all three tests in both attempts; none were ignored.
Earlier local operations branch checks (b6b286c) All 695 containment tests and 27 documentation-manifest tests passed. The containment all-feature build, strict containment Clippy with --no-deps, and containment formatting passed.
Forwarding regressions Three tests using the real supervisor fail with the old behavior and pass with the repair. They cover recovery without lost or duplicated requests, receiver closure, and workload exit while the socket is full. The earlier behavior controls ran through the activation build. The current focused run also passes on this branch with its private activation switch enabled.
Normal-build burst controls A freshly rebuilt activation baseline at 0bf1a0c failed all three bursts of 384 permitted reads. Repaired normal binaries passed all three and a 384-denial case. Every child completed; expected bytes, unchanged files, and process cleanup were checked. Outside-Box, disabled-feature, and 32-operation controls passed.
Activation integration #188 at f35e465 passed all 85 selected privileged tests, including permanent 384-child regressions. These results exercise the implementation from this PR.
Earlier local activation run (f35e465) Not green: 2,225 passed, three failed, seven ignored. The three unchanged alias-startup tests failed with Text file busy. The same nine-test executable and alias then passed serially. The retry does not make the original invocation pass. See #188 for details.

The hosted Linux workspace run retains 20 ignored test entries and two existing execution omissions: the real credential-daemon fixture and the executable-alias read-protection assertion. The alias write assertions ran. These limits match the passing b6b286c control; they are separate from the three forwarding regressions, which all ran without ignores.

The burst runs establish the tested behavior under load, not a performance benchmark. They do not qualify cloud deployment, x86 native interception, or signed macOS interception. Earlier cross-platform and full-package evidence remains in the historical section.

  • I ran the relevant suites (just check, or cargo test --workspace --all-features)
  • If I touched Rust, I ran cargo fmt --all and cargo clippy --workspace --all-targets --all-features -- -D warnings

The suite checkbox records the full-workspace execution on a455afd, which failed as detailed above; it does not claim a final-tree full-suite pass. Formatting and strict whole-workspace Clippy passed on the final tree. The matched 69-warning no-default comparison belongs to a455afd; that build was not repeated on the final tree. Earlier hosted checks, scoped lint runs, and six vendored Shell diagnostics retain their historical scope.

Commands for the forwarding follow-up and earlier operations checks

The current forwarding step uses this command and requires a three-pass result in its captured log:

RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }--cfg box_native_adapter_tests" cargo test --locked -p strands-box-containment --lib --all-features backend::linux::namespace::filesystem_queries::forwarding_tests:: -- --test-threads=1

The broader operations checks at b6b286c used:

cargo build --locked -p strands-box-containment --all-features
cargo test --locked -p strands-box-containment --all-features
cargo clippy --no-deps --locked -p strands-box-containment --all-targets --all-features -- -D warnings
cargo fmt -p strands-box-containment --check
cargo test -p strands-box --test site_manifest --locked --all-features

The real-supervisor and burst controls exercise these changes through the activation build, as distinguished in the results table.

The diagram was exported with pinned draw.io 32.4.1 at scale 2 and border 20. A control export matched the committed reference PNG byte for byte. Both diagrams passed layout checks and visual inspection at reviewer width.

Historical validation: November 12 and earlier revisions

These dated results do not establish a current-head pass. Preserve their original scope and limitations.

November 12 main refresh

Head 0567e33b0ebc460274e83dab9516ced7ff240bd4 includes main at a2cf46ed6a9ea0a8144101bfdef3f2406390952b through an additive merge. The published commit history is preserved. The operations diff against the refreshed main branch preserves the prior feature changes.

Validated source tree: cceadbf1172b9f34a2cf7fff58bb54f7ef88c5bb. Tests ran on an ARM64 Linux development host with Rust 1.98.1.

  • The locked, all-feature test run for strands-box, strands-box-containment, and strands-box-policy passed: 2,886 passed, zero failed, and 15 ignored.
  • All-feature builds, strict Clippy for the Box and containment packages with --no-deps, and formatting checks passed.

Whole-dependency strict Clippy reports six existing diagnostics in the vendored Shell package, whose source matches main exactly. No lint allowances were added.

The separate queue reproduction used the prior activation head e8824597bc7f084465f900edba1dfc0f30af4c8a: 384 synchronized, permitted file opens terminated Box in all three attempts. The same workload passed outside Box and with native policy disabled; 32-operation allow and deny controls also passed. The forwarding code is unchanged by this refresh, but the 384-operation reproduction was not rerun against these refreshed heads. At this November 12 checkpoint, the defect remained unresolved. The November 13 repair and its before/after controls supersede that status.

This refresh does not establish native-interception support on x86, signed macOS interception, or cloud qualification. Cloud qualification belongs to the Linux cloud follow-up. Performance qualification remains separate.

November 11 integration update

Operations commit 56b4aae integrates main at a41332d, including its experimental x86 baseline. Its source tree is 90a29cb5. Independent composition review checks that the main changes and the native implementation are both preserved. The old combined implementation failed application startup because Linux rejected its second notification listener. The shared-listener implementation passes allowed-read and denied-read coexistence tests while filesystem-information sanitization remains active.

  • The complete ordinary Box and containment package run passed 2,189 tests, with seven existing ignores and no failures, at the earlier shared-listener tree c8d48e49.
  • Native directory and path suites passed 44 tests at c8d48e49. The policy-semantic suite passed all 12 tests at aa70502f. The only final source change adjusts a configuration unit-test fixture for unsupported architectures; production code is unchanged. Seven notification tests and six supervisor tests passed.
  • Deliberately broken implementations failed the new framing, operation-validation, socket-validation, and bounded-backpressure tests. Restoring the old integration made both startup controls fail with EBUSY.
  • The deterministic containment harness passed 131 cases at c8d48e49, with ten declared macOS-only skips and no failures.
  • After the final architecture restriction, compilation, all-target strict lint for the changed packages, all 231 configuration tests, and formatting passed. Whole-dependency strict lint reports six warnings in unchanged vendored Shell code; no lint allowances were added.

The latest Shell/native comparison passed all 66 workload assertions. The tested path-history and move-count rules now agree. One intentional decision difference remains: Linux requires write permission to replace the destination; Shell currently does not. All 66 historical event snapshots still fail against current records, which include request identifiers added on main; those snapshots were preserved.

Independent before/after tests and deliberately restored defects confirm that the new history tests detect both repairs. Native policy denials now leave earlier checks request-only, matching Shell. The two new denial regressions fail before the repair and pass after it. Real rename and open failures retain their error history. An independent reviewer reran all four new tests successfully at 8fd570e3, before the final main merge and architecture restriction. This integration does not claim complete event-history parity.

Native x86 testing first exposed a C-object link failure. After that build repair, the new startup regression failed before the architecture restriction and passed after it. All five x86 startup tests and 231 configuration tests now pass, as does all-target strict lint for the changed packages. The disabled-feature control passed.

This does not qualify native interception on x86. macOS signed interception, cloud qualification, and performance testing were not rerun.

Earlier reviewed operations head

Historical head: 4c2957e55b14e094e3aa662c9d58ed81e60b2671.

Check Result
Linux native operations 45 tests passed: 17 directory cases, 25 path cases, and three policy-semantic tests containing 12 scoped-policy scenarios.
macOS adapter All 18 adapter tests passed, including the C decoder and Rust directory-operation mapping. All 18 also pass with the older-SDK loader branch selected using the current SDK. No new signed kernel interception run occurred.
Defect-restoration checks All five defect-restoration checks compiled and failed the intended test: three Linux checks and two macOS checks. The older-SDK test failure also reproduced before its fix.
Deterministic containment 120 passed, zero failures or errors, and nine declared macOS-only skips. The full coverage and integrity checks passed.
Shared selection The existing inheritance and opt-out regression passed against both configuration and normalized records.
Build, lint, and formatting Native build, native all-target Clippy, ordinary all-target compilation, formatting, and the feature-disabled build passed. Native Clippy reports no owned Box warnings and six existing vendored-shell warnings. The feature-disabled build retains 66 existing containment dead-code warnings.
Ordinary crate tests All ordinary test targets completed across bounded runs. The initial all-feature run reached its 420-second cap while progressing; the remaining seven targets then passed all 58 tests. The documentation-test command passed with zero tests present. No single complete invocation is claimed.
Independent review The repository feature-critic review found no unresolved code findings after the macOS SDK-guard correction.

The first directory-policy fixture used a string where the schema requires Box::FsReadOperation. The corrected typed policies passed. Independent review found that the new macOS test initially depended on the loader SDK guard. The pure decoder now compiles outside that guard; both conditional branches pass without weakening assertions. An ordinary build initially reused stale compiler-check configuration; rerunning the build script produced a clean all-target check. These were validation setup failures, not product fixes.

Prior operation evidence

Prior checks below cover the earlier implementation or assembled stack, as labeled. They do not establish fresh coverage of the current fixes.

Check Result
Updated contained tests All 42 path and directory tests passed in the assembled final stack. Five captures now have a 60-second deadline.
Selection regression controls The baseline and restored selection test passed. Four implementation mutations each compiled and failed that assertion, covering inherited local MCP selection and default inheritance in configuration and normalized records.
Prior operation coverage 20 kernel/broker tests and 17 replacement-race tests passed at 6ef6c23. Their production implementation remains unchanged.
Subprocess timeout control The unchanged helper stopped and reaped a stalled child after 60 seconds. The new callers preserve closed standard input.
Strict lint and formatting Ordinary and native all-target lint passed at final stack head 58d0fc2, without new lint allowances. Formatting passed.
Feature-disabled build Passed at d0b3933. Its only subsequent change restricts a test helper's visibility.

Historical full-stack gates and limits

The workspace log reports 4,520 passing tests, zero failures, and 17 ignores at b5d4841, before these test and documentation repairs. The script printed its success footer. The remote disconnect lost its process exit status, so that status remains unavailable. Three host-dependent skip messages remain explicit in the review evidence.

The deterministic containment run recorded 119 passes, one failure, and nine macOS-only skips across all 129 cases. CN-L-02 failed while comparing canonical and noncanonical home paths in the harness. The identical failure reproduced against freshly built main revision e0af331, using the byte-identical harness sources. This is a baseline harness failure, not an introduced regression. That historical run was RED; it was not a qualification pass.

The manual SDK example was not run: its documented setup requires macOS, Homebrew Python, and a Bedrock API key. Fresh execution covered ARM64 Linux. Earlier macOS compilation evidence remains a separate, prior-revision result. Cloud native qualification and performance testing remain deferred.

Earlier independent reviewers applied the repository's feature-critic checklist before those commits. Two weak test assertions, missing capture deadlines, missing warning documentation, and missing unsafe-code explanations were repaired. A helper visibility lint introduced during those repairs was also fixed.

Authorization and identity-policy investigation was excluded. Full security sign-off, formal human approval, hosted checks, and merge approval remain outstanding. See current Checks and Reviews before merging.

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • My changes generate no new warnings

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

keorel and others added 6 commits October 27, 2026 19:04
## Problem

The Linux native adapter needs a containment handoff argument. Mixing its interface migration with the adapter obscures review of existing launch behavior.

## Solution

Add the approved fourth optional argument to Containment::apply and migrate every backend and caller. Callers pass None. A supplied handoff returns UnsupportedCapability before backend selection. Update the public documentation. Include the dependent review branch in the existing CI pull-request filter.

## Tests

Box and containment all-feature suites passed 1,513 tests with six existing ignores. The library callback executable passed, including its callback-created configuration case. an_unavailable_native_handoff_refuses_before_backend_selection checks the refusal and selection order. Build, formatting, diff checks, and strict owned-crate Clippy passed. Independent review found no remaining issues. No baseline test or assertion was removed. Full workspace and native macOS checks were not rerun on this standalone branch. Hosted checks and cloud qualification remain separate.
## Problem

The complete Linux native adapter is too large for one focused review.
Its low-level mechanisms need independent executable coverage before product activation.

## Solution

Stage notification handling, descriptor transfer, kernel identity guards, and capability cleanup behind the private kernel test build.
Keep product entry points at their preparation behavior. Preserve existing component assertions and defer the broker-dependent probe test to the operation layer.
Add staging bases to the existing continuous integration trigger and document component execution.

## Tests

All 15 kernel component tests passed on ARM64 Linux with loader capabilities.
Configuration tests passed with the product adapter unavailable.
The copied-path test checks truncation at NUL and refusal of unterminated input.
The disabled-guard test checks removal of active loader capabilities while retaining other capability bits.
Formatting and strict owned all-target Clippy passed. Independent split and test-harness review verified this tree.
Hosted checks and formal approval remain pending. This change does not establish cloud qualification.
## Problem

Kernel mechanisms alone do not translate workload file requests into policy operations.
The complete adapter also needs a reviewable stage before normal product activation.

## Solution

Add the file-operation broker and its contained workload tests.
Compile the shared launch path only with the private box_native_adapter_tests switch.
Normal builds retain the existing unsupported-feature refusal, including the containment facade refusal before backend selection.
Keep every moved path, directory, and replacement-race assertion unchanged.
Document the test build and retain the public product activation for the final dependent change.

## Tests

ARM64 Linux passed 20 kernel and broker units, 42 contained path and directory tests, and 17 replacement-race tests.
Normal all-feature builds passed 136 configuration tests and the unavailable-handoff refusal regression.
A normal baseline workload exited successfully, while native selection retained its existing platform-unavailable error.
Feature-disabled builds, formatting, strict owned Clippy, and workspace Clippy with repository allowances passed.
Independent review verified all moved test bodies, private gates, and unchanged public interfaces.
Hosted checks and formal approval remain pending. Cloud native qualification and performance are separate work.
@github-actions

Copy link
Copy Markdown

Assessment: Comment

The native broker is carefully built and deny-by-default: it pins the O_PATH handle, re-verifies that the host and captured Box views resolve to the same (dev, ino) before acting, refuses symlink/magic-link escapes, and falls back to EACCES/EOPNOTSUPP on anything unsupported. The whole module and its fault-injection stay behind the private box_native_adapter_tests cfg, so normal and --all-features builds keep the unsupported-feature refusal, and the interface freeze is respected (no new fully-public surface). Two small suggestions inline; neither blocks.

Review Categories

Nice work on the host-vs-Box identity check and the extensive path/directory/race integration suites.

@ferdingler ferdingler left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a discrepancy between macOS and Linux with this change. For instance, an operator could allow writes to a destination but forbid moving files into it. Linux currently allows that move, while macOS blocks it because it checks move permission on both ends.

@ferdingler

Copy link
Copy Markdown
Collaborator

There’s also the reverse case: Linux requires destination write permission for a new name, while macOS doesn’t.

@ferdingler

Copy link
Copy Markdown
Collaborator

One more thing: Is there a reason we classify a directory open as "listing" on Linux but we classify it as "content reading" on macOS? Both use the general fs:read action so that's fine, but they have different operation in the context keys.

@github-actions

Copy link
Copy Markdown

Assessment: Comment (re-review at 4c2957e)

Since 6ef6c23, both earlier suggestions are fixed. broker.rs now has a // SAFETY: note on every unsafe block. Selection now goes through one helper, process::uses_native_filesystem. The rename checks also match macOS now: fs:move on source and destination, plus delete and write only when the destination is replaced. One small point about how directory renames are defined is inline; it doesn't block the merge.

Checked and held
  • Rename with an existing destination checks RemoveFile. This holds because directory destinations are refused, and renameat2 with any flags is refused, which covers RENAME_EXCHANGE.
  • Rename to a new name runs with RENAME_NOREPLACE, so a destination created after the check can't be overwritten without a check.
  • macOS directory opens now map to Enumerate and regular-file opens to ReadContent, matching the Linux broker's directory open path.
  • The new linux_native_policy_semantics suite covers move-only versus replacement, and covers listing versus content reads. It's included in the documented test command.
  • No new public surface. Everything new is still behind box_native_adapter_tests.

Base automatically changed from feature/linux-native-kernel to main October 30, 2026 06:42
@kevin-orellana
kevin-orellana enabled auto-merge (squash) October 30, 2026 06:45
@github-actions

Copy link
Copy Markdown

Assessment: Comment (re-review at 0567e33)

This merge only brings in main's [gateway] upgrade_http work, along with egress and policy changes. Nothing changed between 56b4aae and 0567e33 under crates/containment/, crates/box/src/run/linux_enforcement/, or build.rs. The changes in run/contain are test fixtures. Two earlier points are unchanged and still apply: the open forwarding-backpressure thread (filesystem_queries.rs:207, the supervisor exits 125 once about 278 forwarded requests are pending), and the directory-rename check (broker.rs:904). There are no new findings.

Checked and held
  • Gateway and native together: a non-empty upgrade_http stamps version 32. Load accepts version 32 and keeps experimental_features. Process validation still requires the global native setting before any per-process override.
  • The new gateway field on Record and ConfigFile is serde-defaulted and validated at both parse and load, so records without it still load.
  • On x86-64, native activation is still refused at config validation.

@github-actions

Copy link
Copy Markdown

Assessment: Comment (re-review at b6b286c)

b6b286c fixes the forwarding-backpressure finding the way I suggested. When the send fails with EAGAIN, the supervisor keeps that one request and polls only the forwarding socket for write space. It stops receiving new notifications, so they stay queued in the kernel, and it still checks the reaper every 50 ms. The fix itself is correct. The remaining gap is that nothing runs its tests (inline). The directory-rename point at broker.rs:904 is now settled: the user docs state that a directory rename checks read_content.

Checked and held
  • Socket fills, then Box drains it: POLLOUT fires, the same request is sent once, and pending is cleared. The ordering test checks that no request is lost or repeated.
  • Box closes the socket while a request is pending: POLLHUP/POLLERR stops supervision with BrokenPipe.
  • The workload exits while a request is pending: waitpid(WNOHANG) runs on every iteration, so the reaper's exit status (37 in the test) is preserved.
  • No busy loop: Unix-socket POLLOUT waits until at most a quarter of the send buffer is in use. A spurious WouldBlock on retry keeps the request.
  • A partial write or EPIPE still ends supervision, and the forward_request unit test still finds WouldBlock without blocking.
  • The crates/containment/AGENTS.md premise was updated to match the new behavior. The design doc states that statfs answers also wait behind the pending request.

@github-actions

Copy link
Copy Markdown

Assessment: Approve (re-review at 892a834; no new comments)

892a834 resolves my last open finding. Linux CI now runs the three forwarding-saturation tests with --cfg box_native_adapter_tests, and docs/dev/linux-native-tests.md now describes the wait-on-full-buffer behavior correctly.

Checked and held
  • I ran the exact CI command locally (RUSTFLAGS="-C debuginfo=0 --cfg box_native_adapter_tests"). The test path is correct, all 3 tests pass, and the output contains the exact test result: ok. 3 passed; 0 failed; 0 ignored; line that the grep -F gate looks for.
  • Cost: a cold build plus the test run took about 53s and about 740 MB of target space, which is small next to the disk ceiling the workflow comments mention.
  • The step's if: conditions do the right thing. It runs on default PR runs, including after a failed workspace step (!cancelled()). It is skipped for filtered dispatches and on macOS. pipefail plus the grep catches both a cargo failure and a filter that matches zero tests.
  • RUSTFLAGS keeps the workflow's -C debuginfo=0, and the log is uploaded with the existing artifact.
  • The README and dev-guide text match the code: a full buffer makes the supervisor wait, and a closed connection, invalid descriptor, or partial send ends supervision.

ferdingler
ferdingler previously approved these changes Nov 13, 2026
@github-actions

Copy link
Copy Markdown

Assessment: Approve (re-review at b9c63c0; no new comments)

Since 892a834, the only new commits are two merges of main: a455afd brings in cb099d1 and b9c63c0 brings in 8c56aa8. A --remerge-diff shows the conflicts were resolved mechanically in four places. command/mod.rs and command/run.rs now pass box_id through, hosted.rs keeps main's box_shell::HostSpawner body and adds the Linux native cfg, and the record/config/mod.rs tests close the native test before the file-watching test. In the spawn closure, the PR side had changed only cfgs, so the resolution drops nothing.

Checked and held
  • feat(filesystem): let a read entry name a link to a file #456, a read entry that names a link to a file, with native on: Linux binds the target file at the link's name, so the broker pins a regular file there, not a link. It then canonicalizes on the host to the target and checks that the host and Box (dev, ino) match, which a bind mount keeps. Policy is judged on the target path, which matches grant.resolved.
  • fix(containment): permit copy_file_range and sendfile on Linux #451, copy_file_range/sendfile: both act on descriptors and are not in native_filesystem::OPERATIONS. They only reach descriptors that already passed a broker-checked openat.
  • feat(containment): add opt-in file watching on macOS #430, file-watching: it is a separate per-process field, and uses_native_filesystem/selected are unchanged. On macOS, a watcher's directory open maps to enumerate, as the new "Filesystem operation meanings" section says.
  • feat(box): accept an optional box ID from library callers, and generate one as today when absent #437, a library-supplied box ID: both the native and non-native prepare_contract paths pass it to settle_identity.
  • Local runs on x86_64: with --cfg box_native_adapter_tests, forwarding_tests passed 3/3 and cargo check --tests succeeded. The linux_enforcement/native/record::config lib tests passed 271. The 4 failures were native_egress boundary tests that fail the same way on main here, because the strands-box-sock-alias/trampoline binaries were not built, so they are not caused by this PR. Hosted Lint and Containment (arm64, macOS) pass. Unit Tests were still running when I checked.

The conflict resolutions are clean and keep each side's intent.

@kevin-orellana
kevin-orellana merged commit 5ed679f into main Nov 17, 2026
31 of 34 checks passed
@kevin-orellana
kevin-orellana deleted the feature/linux-native-operations branch November 17, 2026 06:46
freeqaz added a commit to freeqaz/box that referenced this pull request Nov 18, 2026
Brings the containment fix that permits kill and rt_sigtimedwait for a
workload that runs an init such as tini (dc1d8e8). Without it a workload
started under tini dies at start.

The fix branch sits on upstream 5ed679f (the v0.2.3 release commit), so
this merge also brings in the four upstream commits after 941fd27, the
base of dogfood/main:

- e8b4ced docs(design): add path locations design doc (strands-agents#461)
- aa18761 test(shell): pin that `sh FILE` is decided as `shell:exec` on
  `sh` (strands-agents#472)
- 1ccd68a feat: add Linux x86-64 release downloads (strands-agents#475)
- 5ed679f feat: add Linux filesystem policy operations (strands-agents#193)

No conflicts. Git merged crates/box/{AGENTS.md,Cargo.toml},
crates/box/src/command/run.rs, crates/box/src/record/config/mod.rs,
crates/box/src/run/contain/boundary.rs, crates/box/src/run/hosted.rs and
docs/user/native-filesystem-policy.md automatically.
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.

3 participants