Public: anyone can read this; the crew can change it.

Protection test covers the crew falling back to Landlock when bwrap is missing #17125

opened this in answer to

Merged 44h 27m ago, live in production

I added the missing test for the case #16888 introduced: bwrap absent, Landlock working. It passes along with the existing pinned-off test and test/crew-sandbox-floor.test.ts. tsc is clean and the gate prints nothing.

Notes

opened this

I added the missing test for the case #16888 introduced: bwrap absent, Landlock working. It passes along with the existing pinned-off test and test/crew-sandbox-floor.test.ts. tsc is clean and the gate prints nothing. I did not run the broader set of tests scripts/fast.ts names (1275 files, an estimated 107 minutes), so I'm relying on the forge's check for those.

What changed

  • New test in test/protection.test.ts: it starts the crew in-process under a faked bwrap lookup and a faked Landlock probe, with no dependence on the host. It checks that:
    • the footer has no "Reduced protection" line;
    • crew.sandbox.enforced is false;
    • the reason carries the Landlock note and "reads are not hidden".
  • Small seam in src/crew: startCrew takes an optional probeSandbox, declared in runner.ts and used in dispatch.ts. It defaults to sandboxAvailable, so production behaviour is unchanged. The re-probe uses it too. The test passes the real sandboxAvailable with the two fakes, so the actual fallback logic runs.
  • Existing test: the pinned-off test is kept and its timeout raised to 40 s. It timed out at bun's 5 s default here before my change, because it spawns a subprocess.

What I chose not to do

  • No mock.module in a subprocess: I tried it first and it hung, so I used the option instead.
  • No docs/features or src/tui change: the commit line says No door, because only a test seam changed and no page, action, route or tool.
  • No mutation check: I did not confirm the new test goes red when the fallback is removed.

I reused sandboxAvailable's existing injectable parameters and did not write a new probe function.

To try it: bun test test/protection.test.ts

🤖 Generated with Claude Code

Closes #16947

commented

I added the missing test for the case #16888 introduced: bwrap absent, Landlock working. It passes along with the existing pinned-off test and test/crew-sandbox-floor.test.ts. tsc is clean and the gate prints nothing. I did not run the broader set of tests scripts/fast.ts names (1275 files, an estimated 107 minutes), so I'm relying on the forge's check for those.

What changed

  • New test in test/protection.test.ts: it starts the crew in-process under a faked bwrap lookup and a faked Landlock probe, with no dependence on the host. It checks that:
    • the footer has no "Reduced protection" line;
    • crew.sandbox.enforced is false;
    • the reason carries the Landlock note and "reads are not hidden".
  • Small seam in src/crew: startCrew takes an optional probeSandbox, declared in runner.ts and used in dispatch.ts. It defaults to sandboxAvailable, so production behaviour is unchanged. The re-probe uses it too. The test passes the real sandboxAvailable with the two fakes, so the actual fallback logic runs.
  • Existing test: the pinned-off test is kept and its timeout raised to 40 s. It timed out at bun's 5 s default here before my change, because it spawns a subprocess.

What I chose not to do

  • No mock.module in a subprocess: I tried it first and it hung, so I used the option instead.
  • No docs/features or src/tui change: the commit line says No door, because only a test seam changed and no page, action, route or tool.
  • No mutation check: I did not confirm the new test goes red when the fallback is removed.

I reused sandboxAvailable's existing injectable parameters and did not write a new probe function.

To try it: bun test test/protection.test.ts

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs