Repository navigation
Description
Version
develop at 584d63a. Item 4 of the not-fixed list of #858. DESIGN DECISION (small): options and my recommendation below; I will not implement before the owner answers.
Operating system
Linux (bubblewrap).
What happened?
Sessions are append-only JSONL (design rule). With the default location <workspace>/.tole/sessions a sandboxed command cannot touch them: the command profile binds .tole read-only (PROTECTED = [".git", ".tole"], sandbox/command.rs, #849). The location can be moved with -s/--sessions-dir or the config key sessions_dir (a low-risk key a project config may set; there is no environment variable; the default is .tole/sessions under the cwd, main.rs, config/apply.rs). A sessions directory INSIDE the workspace but OUTSIDE .tole (for example -s ./sessions) is part of the writable workspace in the sandbox, so a sandboxed run_command, job_start, verify command or stop gate can rewrite or delete past entries. That undermines the append-only claim and the resume/replay evidence for that setup (the entries are what tole resume, the audit and the cost report read). A sessions dir outside the workspace is not in the sandbox's view and is fine. Reported as a note on #858 (agreed there, report only).
Callers (grep): the resolved settings.sessions_dir feeds sessions_dir in main.rs (run, chat, resume, mission, sessions, status) and sessions_dir_override (serve, acp, tui); session/host.rs::sessions_dir_for(cwd) gives .tole/sessions for cron runs. command::protect_plan(ws) is the one place the protected paths are decided (callers: build and recheck_plan in sandbox/command.rs, command_tests.rs, tests/command_sandbox.rs); its input is the workspace only.
What did you expect to happen?
The sessions directory, wherever it is, is never writable by a sandboxed command.
Options
A. Refuse. When any command consumer is on and the resolved sessions dir is inside the workspace but not under .tole, refuse at startup (and at the launch, since consumers and the dir are known there) with a message naming the dir and the remedy (use the default, or a directory outside the workspace). Simple, no mount changes. Cost: a setup that used -s ./sessions with consumers on must move it; the error says how.
B. Protect it. Pass the sessions dir to the command profile as an extra read-only path next to .git and .tole (a new set_protected_extra next to set_consumers, resolved like the others: must be an existing directory, no link in its chain, else the launch is refused, like .tole). tole itself writes the sessions OUTSIDE the sandbox (host process), so a read-only bind inside does not break it. Needs a new input in tole-core (an optional path in Env/the consumer settings), a bounded change in protect_plan/build/recheck_plan, and tests of each refusal.
C. Document only. State the residual in docs/sandbox-design.md §9.3 and the threat model.
Recommendation
B, with the same fail-closed rules as the other protected paths (and A's refusal as its fallback when the directory cannot be bound: a link, not a directory, or overlapping .git). The default location keeps working unchanged, tole-core stays platform-agnostic (a path in, no I/O beyond what protect_plan already does). If the owner prefers the smaller change, A.
Tests (if B is chosen)
Real-bwrap: a sandboxed command in a workspace whose sessions dir is ./sessions cannot write, rename or remove a file in it (host tree compared before and after, like the #849 tests); a sessions dir that is a symlink or overlaps .git refuses the launch and nothing runs; unit tests of the plan; the default location unchanged. Rerun: command_tests.rs, command_sandbox.rs, verify_sandbox.rs, stopgate_sandbox.rs, config_apply.rs, layering.rs. Each must fail without the fix.
Activity
test(sandbox): the sessions-dir sandbox tests need shell-tools (#866)
fix(sandbox): resolve the sessions dir and gitdir pointers the way th…