Skip to content

fix(containment): allow executable memory on Linux so JIT runtimes run - #488

Merged
pgrayy merged 12 commits into
mainfrom
feature/pgrayy/linux-jit-memory
Nov 19, 2026
Merged

pgrayy merged 12 commits into
mainfrom
feature/pgrayy/linux-jit-memory

Conversation

@pgrayy

@pgrayy pgrayy commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Description

On Linux, Node, Java and Bun fail inside a box. A JIT runtime writes the code it compiles into memory and then runs it. Box's seccomp restriction filter refused writable memory that becomes executable. V8 and the JVM treated that refusal as fatal (Node exits 133 with Check failed: 12 == errno), and Bun dropped to its interpreter, which made a loop about 30x slower in my test. So npm, npx, vite, vitest, Maven and Gradle didn't work on Linux.

This permits writable executable memory by default on every Linux process. There is no key and no config. The filter stops mediating mmap with PROT_WRITE|PROT_EXEC and mprotect with PROT_EXEC; both now go straight through.

Everything else that touches executable memory stays refused, for every process:

  • pkey_mprotect
  • memfd_create
  • descriptor execveat
  • noexec mounts

So the kernel never maps or starts a file outside the process's exec grants. A process can run code it writes into its own memory, though, and a runtime that calls native code (Python ctypes, Java FFM) can copy a readable program into memory and run it. For such a runtime, a read grant on a program works like an exec grant. The system-call filter, filesystem grants, and network policy still apply to that code.

Why default-on, not a key. A read-only Node tool needs this too, so a per-table key would force almost every table to set it, and a leaf that writes files could already write a script and run it through its own interpreter. The key added surface without adding safety. Linux stays stricter than macOS even so: macOS has no counterpart rule, because Seatbelt does not govern anonymous memory.

Interface changes (frozen surfaces)

None. The earlier draft of this PR added an executable-memory key and a ContainmentConfig::allow_executable_memory() method; both are gone. box.toml, the record version, and the containment config surface are unchanged. An existing box keeps its exact bytes and record version.

Not in this change

Related Issues

Closes #42

Type of Change

Bug fix

Testing

Tests:

  • crates/containment/tests/executable_memory_linux.rs runs a probe in a real box through the trampoline. The probe writes a small machine-code function (aarch64 and x86_64), runs it, and reports what else the kernel allows. The box runs the generated code (generated_code_returned: 42) while pkey_mprotect, memfd_create, an IPv6 socket, and an ungranted path all stay refused in the same process.
  • writable_memory_can_become_executable (namespace) asserts mmap W|X and mprotect R|X are permitted while pkey_mprotect is refused. It replaces the two tests that pinned the old mmap rule.
  • raw_fork_preserves_child_restrictions (x86-64) checked the restriction filter with an executable mprotect, which is now permitted. It now uses a nonzero setpgid, which only the restriction filter refuses.

End to end, with strands-box run on Graviton (AL2023, kernel 6.18) and the official Node v22.22.2 build as the agent, a default box with no key prints 2 object (1 + 1 and typeof WebAssembly). Before this change the same box exited 133 with Check failed: 12 == (*__errno_location ()).

Suites run on that host:

  • cargo test -p strands-box-containment --all-features --lib -- backend::linux: passed
  • cargo test -p strands-box-containment --all-features --test executable_memory_linux --test x86_syscalls_linux: passed
  • cargo test -p strands-box --lib -- record:: run::contain: passed
  • cargo fmt --all -- --check and cargo clippy --workspace --all-targets --all-features -- -D warnings: clean

Not run on this host: macOS, and anything x86-64 (no cross C compiler), including raw_fork_preserves_child_restrictions.

  • 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

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.

AI-assisted PR

… agent on Linux

A JIT runtime writes the code it compiles into memory and then runs it.
Linux's restriction filter refused that memory in every sandbox, so Node
and the JVM aborted and Bun fell back to its interpreter.

A tool or stdio MCP server now maps writable and executable memory, set
beside broad exec. The agent keeps the rule unless `[agent]` sets
`executable-memory = true`, which needs record version 36. Only the
`mmap` and `mprotect` rules lift; `memfd_create`, descriptor `execveat`,
`pkey_mprotect`, and the `noexec` mounts stay refused.

Refs #42
Comment thread crates/box/src/run/contain/boundary.rs Resolved
@github-actions

Copy link
Copy Markdown

Suggestion (non-blocking): this change makes two statements in crates/box/AGENTS.md false, and the diff does not update them. The root AGENTS.md doc-review rule covers "prose the diff makes wrong".

Example:

  • crates/box/AGENTS.md:477-485 explains why the Linux agent's 14 execve-able paths against 5 grants are "a premise gap rather than a hole": "None can run workload-authored bytes, because W^X's noexec refuses the mapping." With [agent] executable-memory = true, the agent can run bytes it authored in anonymous memory. The bullet therefore no longer holds for that agent, and it still says not to restate it more broadly.
  • crates/box/AGENTS.md:1042-1048 (open findings, "a leaf is wider than the agent's box") lists the residuals of a leaf. It says the leaf loses W^X only "on macOS … over its own writable grants". On Linux, every leaf now also loses route 3 (anonymous RWX memory).

Suggestion: Qualify the first bullet: "…unless [agent] sets executable-memory; see the decision entry." Add the Linux route-3 lift to the leaf residuals list. The containment AGENTS.md W^X paragraph already does this, so the two crates would agree.

@github-actions

Copy link
Copy Markdown

Assessment: Request Changes

The filter change itself is correct and tightly scoped: only the mmap/mprotect route-3 rules lift. The open question is scope. The leaf-wide lift rests on a rationale that a read-only leaf breaks, so it needs explicit maintainer approval or a narrower condition (see the inline comment).

Details Checked and held
  • SyscallPolicy::compile skip: SYS_mmap and SYS_mprotect each appear once in MEDIATED. pkey_mprotect, memfd_create and execveat keep their rules. I ran executable_memory_linux on x86-64 (kernel 7.0, after allowing unprivileged userns on the runner) and it passes, which covers the architecture the PR did not run.
  • ProcessSpec::validate: [tool.*] refuses the key, and [mcp.*] refuses it through deny_unknown_fields. Only [agent] takes it.
  • record_version: 36 takes precedence over 35 and keeps file-watching. Records without the key keep 21, and the wire field is skipped when false, so existing ContainmentConfig bytes do not change.
  • Every runtime-reach call site (command/run.rs, hosted.rs tool spawn and MCP start) passes Leaf or Agent as intended. The disclosure is Linux-only, and an MCP server shows it when it starts (hosted.rs:649).
  • Children inherit the filter: an agent without the key still refuses JIT for the programs it runs directly. A tool that the Shell spawns gets the leaf filter.
  • Frozen surfaces (box.toml key, the ContainmentConfig method) are declared in the description.

The real-box probe test and the end-to-end Node evidence make the filter change easy to trust.

Every leaf mapped executable memory, on the premise that broad exec
already runs what a leaf writes. A leaf with no writable grant had no
place to run bytes it wrote, so the lift widened it, and every stored
box gained it on resume.

`executable-memory` is now a per-process key on `[agent]`, each
`[tool.<name>]`, and each stdio `[mcp.<name>]`, off by default, as
`file-watching` is. An unstarted MCP server discloses it at startup.
The two per-process switches share one boundary test and one record
test.

Refs #42
@pgrayy pgrayy changed the title feat(containment): permit executable memory for tools and an opted-in agent on Linux feat(containment): let a process table select executable memory on Linux Nov 17, 2026
@pgrayy

pgrayy commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

Both points are addressed in d4c512f:

  • crates/box/AGENTS.md: the bullet about the Linux agent's execve-able paths now says that a process whose table selects executable-memory can run bytes it writes into memory, and links the decision entry. The leaf residuals list now names the lifted memory rule for a leaf that selects the key.
  • Scope: leaves no longer get executable memory by default. Details are in the inline thread.

Thanks for running executable_memory_linux on x86-64. That covers the architecture I couldn't test.

AI-assisted comment

@github-actions

Copy link
Copy Markdown

Assessment: Approve (re-review of d4c512f)

Both earlier findings are addressed. executable-memory is now an opt-in per table, off by default, on [agent], [tool.<name>] and stdio [mcp.<name>], which matches the shape proposed in #42. The crates/box/AGENTS.md statements now name the key. I found no new issues.

Checked and held at d4c512f
  • Cases that reach the new spec.executable_memory branch. These are a read-only tool with no key (rules kept), a tool that sets the key and its descendants such as npm → node (lifted, inherited), and a stdio MCP server that sets the key (lifted from its own contained.spec, and disclosed at startup and when it starts). Also covered are an agent with the key whose tool runs through the Shell (the tool needs its own key, as the docs say), stored records v21–35 (unchanged), and remote http MCP (refuses the key).
  • record_version reaches 36 from any agent, tool, or contained-MCP spec, both at configure time (mod.rs:513) and when a record is parsed.
  • Docs. No reference to the old decision anchor or to "already has it" remains.
  • Tests run on x86-64 (kernel 7.0).
    • cargo test -p strands-box --all-features --lib -- record:: run::contain: 468 passed.
    • executable_memory_linux: 2 passed.
    • cargo clippy -p strands-box-containment -p strands-box --all-targets --all-features -- -D warnings and cargo fmt --all -- --check: clean.
    • The boundary tests need the workspace binaries built first.
    • The containment probe needs unprivileged user namespaces, which this runner blocks by default; I allowed them for the run.

Folding both switches into one table-driven test keeps file watching and executable memory pinned to the same per-process contract.

Name the syscall list for what it holds, state the key's reach where
allow_file_watching states its own, and give both per-process record
tests the same Switch shape as the boundary test.

Refs #42
@github-actions

Copy link
Copy Markdown

Assessment: Approve (re-review of cab44ed)

Compared with d4c512f, this commit only renames things and edits doc comments and prose. EXECUTABLE_MEMORY is renamed to EXECUTABLE_MEMORY_SYSCALLS, and it still holds SYS_mmap and SYS_mprotect. The skip condition in SyscallPolicy::compile is unchanged. The test binding is renamed from selected_in to is_selected. The doc comments on ContainmentConfig and the decision entry are reworded, and they still state the same per-table scope and FFI cost. The approval from my earlier review still holds.

On x86-64 (kernel 7.0) I re-ran cargo test -p strands-box --all-features --lib -- record:: run::contain (468 passed) and executable_memory_linux (2 passed). cargo clippy -D warnings on both crates and cargo fmt --check are clean.

…jit-memory

# Conflicts:
#	crates/box/src/record/config/mod.rs
#	docs/user/native-filesystem-policy.md
@github-actions

Copy link
Copy Markdown

Assessment: Approve (re-review of 5191c96, the merge of main)

main brought in TELEMETRY_EXPORT_RECORD_VERSION = 36, and the merge resolves the clash correctly. EXECUTABLE_MEMORY_RECORD_VERSION moves to 37:

  • In record_version, executable memory is checked first, then telemetry export, then file watching. A box that selects both keeps both and is stamped 37.
  • Both versions are in the accepted list in Record::parse.
  • The foreign-version test now uses EXECUTABLE_MEMORY_RECORD_VERSION + 1 (38), so it still checks a version that really is unknown.
  • The per-process switch test expects 37.
  • docs/user/native-filesystem-policy.md:132 says 37.
  • No source or doc file still says executable memory needs 36.

The merge does not touch any other file of this feature.

I re-ran the tests on x86-64:

  • cargo test -p strands-box --all-features --lib -- record:: run::contain: 482 passed.
  • executable_memory_linux: 2 passed.
  • cargo clippy -D warnings on both crates and cargo fmt --check: clean.

Small non-blocking fix: the PR description still says "Selecting it requires record version 36" and "only [agent]" takes the key. Updating both to match the code would keep the squash history accurate.

…jit-memory

# Conflicts:
#	crates/box/src/record/config/mod.rs
Comment thread docs/design/decisions.md Resolved
@github-actions

Copy link
Copy Markdown

Assessment: Approve (re-review of 55ca776, the second merge of main)

This time main brought in MONTY_OFF_RECORD_VERSION = 37. The merge handles the clash the same way as before: EXECUTABLE_MEMORY_RECORD_VERSION moves to 38.

  • In record_version, executable memory is checked first, then telemetry export, then Monty off, then file watching. A box that selects several of these keeps every selection and is stamped 38.
  • 37 and 38 are both in the accepted list in Record::parse.
  • The foreign-version test uses EXECUTABLE_MEMORY_RECORD_VERSION + 1, which is now 39, so it still checks an unknown version.
  • The per-process switch test expects 38.
  • docs/user/native-filesystem-policy.md:132 says 38.

The other changes from main don't touch this feature:

  • Boundary::translate is still called from the same five sites, so a process gets executable memory only from its own table.
  • syscall.rs only adds fork to the permit table. The MEDIATED entries for mmap and mprotect are unchanged, so EXECUTABLE_MEMORY_SYSCALLS still matches them.
  • A box with monty = false sends a bare python3 to a declared [tool.python3]. That tool gets executable memory only if its table sets the key, and the key's disclosure already names the ctypes cost.

I re-ran on x86-64:

  • cargo test -p strands-box --all-features --lib -- record:: run::contain: 484 passed.
  • executable_memory_linux: 2 passed.
  • The syscall unit tests: 28 passed.
  • cargo clippy -D warnings on both crates and cargo fmt --check: clean.

Non-blocking: the "Interface changes" section of the PR description still says "requires record version 36". The code now uses 38.

@kevin-orellana kevin-orellana 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.

The configuration guide explains the capability, but it does not show the new startup warning or explain when it appears. Could we add that example and update the architecture’s startup description, as .agents/references/doc-updates.md requires?

The pull-request description also says selecting this setting requires saved-state format version 36, while the implementation and committed version guide use 38. Could we update the description to match?

Comment thread crates/containment/src/config.rs Resolved
…jit-memory

# Conflicts:
#	crates/box/src/record/config/mod.rs
#	docs/user/native-filesystem-policy.md
@github-actions

Copy link
Copy Markdown

Assessment: Approve (re-review of d1958f7, the merge of main through #523)

This commit only merges main. #499 adds SECRET_SOURCE_RECORD_VERSION = 39, so EXECUTABLE_MEMORY_RECORD_VERSION moves to 40. Every place that depends on the number agrees:

  • record_version still checks executable memory first.
  • Record::parse accepts both 39 and 40.
  • The foreign-version test uses 41.
  • The per-process switch test expects 40.
  • config.md:502, native-filesystem-policy.md:212, and the PR description all say 40.

The merge doesn't touch syscall.rs or namespace/mod.rs, and the six Boundary::translate call sites are unchanged.

Results on x86-64:

  • cargo test -p strands-box --all-features --lib -- record:: run::contain: 539 passed.
  • executable_memory_linux: 2 passed.
  • cargo clippy -D warnings on both crates and cargo fmt --check: clean.

The approval covers the opt-in design as it stands at this head. @kevin-orellana now recommends removing the key and allowing executable memory by default on Linux. If the PR changes to that design, it's a different change and needs a fresh review. Besides the points in my earlier comment, it would reverse two things this repository writes down:

  • the W^X route-3 rule in crates/containment/AGENTS.md, along with its test route_three_write_then_execute_is_refused;
  • the premise statements in crates/box/AGENTS.md that this PR has just qualified.

The root AGENTS.md asks for explicit approval of a premise change like this.

Reviewers preferred the simpler design: drop the `executable-memory`
key and let a box map writable and executable memory on every Linux
process, so a JIT runtime runs without configuration.

The filter no longer mediates `mmap` or `mprotect`; `pkey_mprotect`,
`memfd_create`, descriptor `execveat`, and the `noexec` mounts stay
refused, so the box still governs which program files run. Generated
code is bound by the same system-call filter, filesystem grants, and
network policy. This gives up a hardening measure, not an authority,
and matches macOS, whose Seatbelt does not govern anonymous memory.

Removes the `box.toml` key, its record version, and the startup
disclosure. `a_box_runs_generated_code_that_stays_contained` runs code
the process wrote and checks it stays contained; a lib-level test pins
the filter directly.

Refs #42
@pgrayy pgrayy changed the title feat(containment): let a process table select executable memory on Linux fix(containment): allow executable memory on Linux so JIT runtimes run Nov 19, 2026
@pgrayy

pgrayy commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Done in 1866973. The executable-memory key, its ContainmentConfig::allow_executable_memory() method, and the record-version bump are all gone, so box.toml and the containment surface are back to what they were. Writable executable memory is now permitted by default on every Linux process; only mmap W|X and mprotect R|X stop being mediated.

The containment stays, and a permanent test proves it. executable_memory_linux.rs runs a probe in a real box through the trampoline: it writes a small machine-code function (aarch64 and x86_64), runs it, and in the same process checks the rest of the sandbox. The box runs the generated code (generated_code_returned: 42) while pkey_mprotect, memfd_create, an IPv6 socket, and an ungranted path all stay refused. writable_memory_can_become_executable covers the syscall rules directly, and x86_syscalls_linux.rs's FORK_CHILD_CONTAINED shows a forked child is still contained now that an executable mprotect is permitted.

Agreed on the trade-off you flagged: this gives up a hardening measure, and we haven't quantified the kernel-exploit effect. pkey_mprotect, memfd_create, descriptor execveat, and noexec mounts stay refused, so the process can run only code it writes into its own memory, not code from anywhere its mount view does not admit. The docs now say this.

@github-actions

Copy link
Copy Markdown

Assessment: Comment (fresh review of 1866973, which switches to executable memory by default on every Linux process)

The code change is correct and minimal. I have one documentation finding, inline: the claim that the box "still governs which program files run" is false for runtimes that can call native code.

Checked and held at 1866973
  • Filter: MEDIATED drops only the mmap and mprotect entries, and write_execute_mmap_rules goes with them. pkey_mprotect keeps add_execute_rules in the restriction filter and stays outside the permit filter. memfd_create, execveat, and the noexec mounts are unchanged.
  • Surface rollback: executable-memory, allow_executable_memory(), the wire field, and EXECUTABLE_MEMORY_RECORD_VERSION are all gone. The foreign-version test uses SECRET_SOURCE_RECORD_VERSION + 1. Nothing else in source, docs, or the manifest still names the key or its anchors.
  • Stored boxes: a v21–39 record resumes with the relaxed filter, and no record change is needed because nothing new is stored. An older build simply refuses JIT again.
  • What still stays closed: a file-backed PROT_EXEC mapping from a noexec mount still returns EPERM, which I checked in the box. /proc stays read-only, so proc_mem_cannot_write_executable_memory still passes.
  • Premise approval: the change to W^X route 3 follows @kevin-orellana's explicit recommendation. crates/containment/AGENTS.md (W^X section), crates/box/AGENTS.md:717, linux-enforcement.md, platform-differences.md, and the decision entry are all updated.
  • Tests on x86-64:
    • executable_memory_linux (2), x86_syscalls_linux (4), supervisor_memory_linux (3), loader_dependencies_linux (1), and writable_library_admission_linux (12) all pass.
    • The containment backend::linux lib tests pass: 364.

Two leftovers to clean up while you're here:

  • The view.rs:130 comment still says /proc is read-only "so /proc/*/mem cannot write through the executable-memory syscall restrictions". It should now give the supervisor-memory reason.
  • The test-workload scripts still pass --jitless as a workaround that Linux no longer needs.

Comment thread docs/user/config.md Resolved
- The raw-fork test probed the restriction filter with an executable
  mprotect, which is now permitted, so it no longer checked that filter.
  It now uses a nonzero setpgid, which the permit filter admits and the
  restriction filter refuses. The anonymous mapping it needed is gone,
  and FORK_CHILD_DENIED is back to its value on main.
- Drop a_read_execute_mapping_is_still_permitted and the plain writable
  mapping check: both bounded the removed mmap rule.
- State the real reason pkey_mprotect stays refused: it pairs with the
  unpermitted pkey_alloc.
- Fix comments the change made stale (view.rs /proc, the V8 note) and
  revert unrelated rewording in architecture.md and
  native-filesystem-policy.md.
- run_generated_code is a safe fn; its caller has no precondition.
The docs said the box "still governs which program files run". The
kernel still never maps or starts a file outside the exec grants, but a
runtime that calls native code can copy a readable program into memory
and run it. Say so in config.md and the decision entry.
@pgrayy

pgrayy commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Thanks. On the two leftovers:

  • view.rs:130: fixed in dfc7c94. The comment now gives the /proc/*/mem reason: those writes ignore page protections and can reach another process's memory.
  • --jitless in test-workload: leaving it for a follow-up PR. Node with --jitless still runs after this change, so nothing breaks. Removing it changes what the agent suite measures, and that suite only runs from a maintainer-approved dispatch. A small follow-up can ask for that run on its own. It should also drop the F29 F64 residuals from workload-node.

dfc7c94 also changed two tests:

  • raw_fork_preserves_child_restrictions checked the restriction filter with an executable mprotect, which is now permitted. It now uses a nonzero setpgid, which only the restriction filter refuses, and FORK_CHILD_DENIED is back to 45. This one is x86-64 only and I couldn't run it here, so please confirm it on x86-64.
  • a_read_execute_mapping_is_still_permitted and the plain-writable-mapping check are removed, because both only bounded the mmap rule that is gone.

@github-actions

Copy link
Copy Markdown

Assessment: Approve (re-review of 8d60bc4)

The last open item is fixed. 8d60bc4 changes only docs. docs/user/config.md and docs/design/decisions.md now say the kernel never maps or starts a file outside the exec grants. They also say that a runtime that calls native code can copy a readable program into memory and run it, so a read grant on a program works like an exec grant. That matches what the in-box probe showed at 1866973: a direct PROT_EXEC map of the file got EPERM, and running its copied bytes returned 42. No doc still says "governs which program files run".

The code is unchanged since dfc7c94, where I last ran the tests: the containment tests, the strands-box record::/run::contain tests, clippy, and fmt all passed. So I did not re-run them for this docs-only commit.

@github-actions

Copy link
Copy Markdown

Assessment: Comment (re-review of dfc7c94)

This commit tightens tests and wording around the default-on design, and the code side holds:

  • writable_memory_can_become_executable now checks one W|X page with mmap, mprotect(R|X) and pkey_mprotect. That covers what the deleted a_read_execute_mapping_is_still_permitted checked, because mmap is no longer mediated at all. Nothing still refers to the removed test.
  • x86_syscalls_linux now proves the restriction filter survives a raw fork with setpgid(getpid(), 0). Before, it used the executable mprotect that is now permitted, so it no longer exercised that filter. Code 45 means the permit filter and the restriction filter each returned EPERM.
  • The view.rs:130 comment now gives the /proc/*/mem reason, and the pkey_mprotect reason now ties it to pkey_alloc.

Results on x86-64:

  • executable_memory_linux (2), x86_syscalls_linux (4), supervisor_memory_linux (3): all pass.
  • Containment backend::linux lib tests: 363 passed.
  • strands-box record:: and run::contain tests: 539 passed.
  • cargo clippy -D warnings on both crates and cargo fmt --check: clean.

The one open item is still the "governs which program files run" sentence in config.md and decisions.md. See the reply in that thread.

@pgrayy
pgrayy enabled auto-merge (squash) November 19, 2026 15:34
@pgrayy
pgrayy merged commit f7af148 into main Nov 19, 2026
24 checks passed
@pgrayy
pgrayy deleted the feature/pgrayy/linux-jit-memory branch November 19, 2026 15:50
SaiAbhishek98 pushed a commit to SaiAbhishek98/agentcore-cli that referenced this pull request Nov 20, 2026
## Problem

Build downloaded the ffi shim (box-ffi-python3.14, release
0.1.11-linux-preview.2), staged it in `.box-dist/ffi`, and put it first
in the Runtime `PYTHONPATH` of the agent and of each leaf on the Runtime
Python. The shim was necessary because Box Core refused executable
memory on Linux. box 0.1.11-mquang.preview.9 has Box Core 78e752b0, with
[strands-agents/box#488](strands-agents/box#488),
so the Python of the Runtime runs in a box with no shim.

## Solution

This commit has the shim removal of
[aws#2867](aws#2867)
([e8069dd](aws@e8069dd)
and [baa1fe0](aws@baa1fe0)),
so that the PR that merges second has a small conflict:

- `boxRelease.json` pins only `box`. `FFI_RELEASE`, its cache, and its
  download go. `bump-box-release.ts` accepts only `--box`.
- `stageBoxCodeZip` stages no `ffi` folder, and `.box-dist` names no
  `ffi` folder.
- The README says what the zip contains with no shim.

The part of e8069dd in `runtimeCodeZipRunner` is not necessary here,
because the derivation gives the Runtime `PYTHONPATH`. The derivation
changes as follows:

- The additions rule adds no shim. An `[agent]` with no `PYTHONPATH`
  gets the code folder on CodeZip.
- The paths rule adds no shim at the start for a leaf. It keeps each entry one
  time, and keeps the code folder at the end of the `PYTHONPATH` of
  `[agent]` and of each leaf on the Runtime Python.

The template tables of `old-renderer-tables.json` are recorded again
from the renderer of aws#2867 at f40ebce. Only the 102
`PYTHONPATH` values change, to `${{ inputs.code.dir }}`.

## Tests

- additions.test.ts: "keeps a PYTHONPATH of the user as it is, on
  CodeZip and on a container", "gives an [agent] with no PYTHONPATH the
  code folder on CodeZip, and none on a container", and the tests on
  the recorded tables.
- paths.test.ts: "keeps the code folder in the PYTHONPATH of [agent]
  and of a leaf on the Runtime Python, one time", and "ends a leaf's own
  PYTHONPATH with the code folder, and adds none to [agent] or a leaf
  with no Python".
- boxCodeZip.test.ts and boxRelease.test.ts, as in aws#2867.
SaiAbhishek98 pushed a commit to SaiAbhishek98/agentcore-cli that referenced this pull request Nov 20, 2026
…hine that it has no build for

## Problem

The CLI pinned box 0.1.11-linux-preview.7. Its Box Core refused
executable memory on Linux, so the ffi shim was necessary for a CodeZip agent. The
previous commit removes the shim. The user selected
[box 0.1.11-mquang.preview.9](https://github.com/mquang-amazon/box-releases/releases/tag/v0.1.11-mquang.preview.9):
staging-boxy b0846169 with
[strands-agents/staging-boxy#549](https://github.com/strands-agents/staging-boxy/pull/549),
on Box Core 78e752b0 with
[strands-agents/box#488](strands-agents/box#488).
It does not have strands-agents/box#537.

That release has only the Linux arm64 build. Each install hint named
only the release page of the pin, so on macOS the hint gave a page with
no build for the machine.

## Solution

- `bun scripts/bump-box-release.ts --box 0.1.11-mquang.preview.9` wrote
  `boxRelease.json` from the SHA256SUMS.txt of the release. The file is
  the same as in
  [3934bbe](aws@3934bbe) of
  [aws#2867](aws#2867).
- `BOX_MINIMUM_RELEASE_PAGE` is the release page of
  `BOX_MINIMUM_VERSION` (0.1.11-linux-preview.7), which has a macOS build.
- `BOX_OTHER_MACHINE_HINT` says to use that box, or a subsequent
  release with a build for the machine, when the pinned release has none.
  `BOX_INSTALL_HINT` and each install hint of the profile resolver end
  with it.
- The local box is not compared to the pin. A macOS box
  0.1.11-linux-preview.7 on PATH stays correct for `agentcore dev` and
  for the profile checks of build.
- The README, the guide, and the comment on the tools of `@box/base`
  name the new pin. The packs of preview.9 are the same as the packs of
  preview.7, so `@box/base` has one tool, `uname`.

## Tests

- boxRelease.test.ts: "box is at least the first release that reads the
  profiles the CLI writes" (semver sorts 0.1.11-mquang.preview.9 after
  0.1.11-linux-preview.7), and "the install hint names the pinned
  release, and the first release for a machine it has no build for".
- boxProfileResolver.test.ts: each install hint of the resolver.
- The SHA-256 of the archive that curl downloaded into a new empty
  folder agreed with SHA256SUMS.txt
  (5b0f8802fb1c5cbc22db4bfcefc9061e048e931c972584350ebce6c1b15da884).
  A `diff -r` of the resources of preview.7 and preview.9 found no
  difference.
SaiAbhishek98 pushed a commit to aws/agentcore-cli that referenced this pull request Nov 20, 2026
## Problem

Build downloaded the ffi shim (box-ffi-python3.14, release
0.1.11-linux-preview.2), staged it in `.box-dist/ffi`, and put it first
in the Runtime `PYTHONPATH` of the agent and of each leaf on the Runtime
Python. The shim was necessary because Box Core refused executable
memory on Linux. box 0.1.11-mquang.preview.9 has Box Core 78e752b0, with
[strands-agents/box#488](strands-agents/box#488),
so the Python of the Runtime runs in a box with no shim.

## Solution

This commit has the shim removal of
[#2867](#2867)
([e8069dd](e8069dd)
and [baa1fe0](baa1fe0)),
so that the PR that merges second has a small conflict:

- `boxRelease.json` pins only `box`. `FFI_RELEASE`, its cache, and its
  download go. `bump-box-release.ts` accepts only `--box`.
- `stageBoxCodeZip` stages no `ffi` folder, and `.box-dist` names no
  `ffi` folder.
- The README says what the zip contains with no shim.

The part of e8069dd in `runtimeCodeZipRunner` is not necessary here,
because the derivation gives the Runtime `PYTHONPATH`. The derivation
changes as follows:

- The additions rule adds no shim. An `[agent]` with no `PYTHONPATH`
  gets the code folder on CodeZip.
- The paths rule adds no shim at the start for a leaf. It keeps each entry one
  time, and keeps the code folder at the end of the `PYTHONPATH` of
  `[agent]` and of each leaf on the Runtime Python.

The template tables of `old-renderer-tables.json` are recorded again
from the renderer of #2867 at f40ebce. Only the 102
`PYTHONPATH` values change, to `${{ inputs.code.dir }}`.

## Tests

- additions.test.ts: "keeps a PYTHONPATH of the user as it is, on
  CodeZip and on a container", "gives an [agent] with no PYTHONPATH the
  code folder on CodeZip, and none on a container", and the tests on
  the recorded tables.
- paths.test.ts: "keeps the code folder in the PYTHONPATH of [agent]
  and of a leaf on the Runtime Python, one time", and "ends a leaf's own
  PYTHONPATH with the code folder, and adds none to [agent] or a leaf
  with no Python".
- boxCodeZip.test.ts and boxRelease.test.ts, as in #2867.

Dev port: dev removed the shim in 264da50, so this port keeps the dev
boxRelease.json, boxRelease.ts, boxCodeZip.ts, README, and their tests.
It takes only the change of the rules: no shim, and the code folder at
the end of each Runtime PYTHONPATH. The fixture of this branch has no
shim already.

(cherry picked from commit 6ce7363)
SaiAbhishek98 pushed a commit to aws/agentcore-cli that referenced this pull request Nov 20, 2026
…hine that it has no build for

## Problem

The CLI pinned box 0.1.11-linux-preview.7. Its Box Core refused
executable memory on Linux, so the ffi shim was necessary for a CodeZip agent. The
previous commit removes the shim. The user selected
[box 0.1.11-mquang.preview.9](https://github.com/mquang-amazon/box-releases/releases/tag/v0.1.11-mquang.preview.9):
staging-boxy b0846169 with
[strands-agents/staging-boxy#549](https://github.com/strands-agents/staging-boxy/pull/549),
on Box Core 78e752b0 with
[strands-agents/box#488](strands-agents/box#488).
It does not have strands-agents/box#537.

That release has only the Linux arm64 build. Each install hint named
only the release page of the pin, so on macOS the hint gave a page with
no build for the machine.

## Solution

- `bun scripts/bump-box-release.ts --box 0.1.11-mquang.preview.9` wrote
  `boxRelease.json` from the SHA256SUMS.txt of the release. The file is
  the same as in
  [3934bbe](3934bbe) of
  [#2867](#2867).
- `BOX_MINIMUM_RELEASE_PAGE` is the release page of
  `BOX_MINIMUM_VERSION` (0.1.11-linux-preview.7), which has a macOS build.
- `BOX_OTHER_MACHINE_HINT` says to use that box, or a subsequent
  release with a build for the machine, when the pinned release has none.
  `BOX_INSTALL_HINT` and each install hint of the profile resolver end
  with it.
- The local box is not compared to the pin. A macOS box
  0.1.11-linux-preview.7 on PATH stays correct for `agentcore dev` and
  for the profile checks of build.
- The README, the guide, and the comment on the tools of `@box/base`
  name the new pin. The packs of preview.9 are the same as the packs of
  preview.7, so `@box/base` has one tool, `uname`.

## Tests

- boxRelease.test.ts: "box is at least the first release that reads the
  profiles the CLI writes" (semver sorts 0.1.11-mquang.preview.9 after
  0.1.11-linux-preview.7), and "the install hint names the pinned
  release, and the first release for a machine it has no build for".
- boxProfileResolver.test.ts: each install hint of the resolver.
- The SHA-256 of the archive that curl downloaded into a new empty
  folder agreed with SHA256SUMS.txt
  (5b0f8802fb1c5cbc22db4bfcefc9061e048e931c972584350ebce6c1b15da884).
  A `diff -r` of the resources of preview.7 and preview.9 found no
  difference.

Dev port: dev pins 0.1.11-mquang.preview.9 already (7de308e), so this
port keeps the dev boxRelease.json and the dev text of the pin. It takes
BOX_MINIMUM_RELEASE_PAGE, BOX_OTHER_MACHINE_HINT, the hints that end
with it, their tests, and the README sentence on the macOS box.

(cherry picked from commit 853a8a5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spike: JIT runtimes under write-xor-execute in the Linux agent sandbox

3 participants