Skip to content

feat(sandbox): startup profile hash, optional-fallback ledger entry, verbose argv, credential list (#750) - #876

Merged
ajianaz merged 3 commits into
developfrom
feat/750-sandbox-startup-ledger
Nov 16, 2026
Merged

ajianaz merged 3 commits into
developfrom
feat/750-sandbox-startup-ledger

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What

The remaining logging scope of #750: the profile hash in the startup line, a ledger record when an optional sandbox falls back to no sandbox, verbose logging of the sandboxed launch command line, a wider credential list for the doctor SENSITIVE marker, and the design note corrected where it was stale.

Why

docs/sandbox-design.md §10 and §11 promised a ledger entry per optional fallback and a --verbose launch line, and #750 asked for the profile hash in the startup log and ~/.config/gh in the credential list. None of it existed: the fallback only produced a stderr warning, and the hash went only to the lock and the ledger. The startup line also named the default profile even for a server bound to its own profile.

Changes

  • Startup line (sandbox/report.rs): mcp[x]: sandboxed (profile <name> sha256:<12 hex>, mode m), using profile_for(name) (the profile the server really runs in). The whole line is sanitized to one line.
  • Fallback ledger entry: new sandbox::fallback_reason (true exactly where plan falls back; plan is unchanged), plugin_lock::fallback_ledger_line (sandbox_fallback: server, profile, profile_hash, reason of at most 300 sanitized characters, at), and Gate::record_fallback called from Gate::check on a trusted admission. One appended line per server and gate. No fold treats it as an approval, a revoke or a profile record. Never recorded for required, unattended runs, skipped or remote servers, or a working backend. The reason comes from the lock source split on whitespace (documented as an approximation).
  • Command consumers: no ledger or session entry, on purpose. They have no ledger, and a tool does not reach the session log. The stderr warning and the doctor line stay, and the design note now says so.
  • Verbose argv: no --verbose flag exists, so the existing TOLE_VERBOSE switch (chore(cli): quiet startup — demote per-run "binary not found" notices #435) is reused, now defined once in core and aliased by tole-cli. redact_argv prints the bwrap command line to stderr only (MCP servers at first start, command consumers per command), redacting the process secret set, values of secret-shaped flags (--token x, --api-key=x) and NAME=VALUE arguments with a secret-shaped name (API_KEY=x, -e API_KEY=x, --env=API_KEY=x). A secret tole does not know under an innocent name is not recognised (documented).
  • Credential list: adds .config/gh, .config/glab-cli, .config/op, .password-store, .npmrc, .pypirc, .cargo/credentials and .cargo/credentials.toml.
  • Docs: design note §6.1 "not built" line, §10 and §11 rewritten to what is built; threat model, CHANGELOG and docs/epics.md updated. README status is not stale.

Callers and impact (grep, verified by hand): startup_line is called by log_startup_once (mcp.rs start_server) and report_tests.rs. Gate::check is called by tool_roster.rs (two sites, connect-time admit). command_prepared is the one place command.rs gets the sandboxed argv. New pub items are additive. Tests to rerun: sandbox::report, sandbox::tests, plugin_lock::tests, plugin::gate::tests, command_sandbox*, mcp_sandbox*, quiet_startup.

Testing

  • cargo fmt --all --check, clippy --workspace --all-targets --all-features -D warnings, clippy for --no-default-features (core, cli, tui) and cli with shell-tools only, and cargo check -p tole-core --no-default-features --tests: clean, also after merging develop (fix(sandbox): harden the git tool, which runs on the host, when a command consumer is on (#748) #873).
  • cargo test --no-fail-fast with TOLE_REQUIRE_BWRAP=1 in three profiles: default workspace (2647 passed), --no-default-features core and cli (2008), shell-tools only (2289); no failures.
  • Fail-first: I neutered each change by hand and the new tests failed, then I restored it. The neutered changes were the hash and sanitize in the startup line, the credential list, the argv redaction, fallback_reason's mode and unattended check, the ledger-line sanitize, the gate call, the once-per-server dedupe and the NAME=VALUE rule.
  • Core parity test: fallback_reason agrees with plan for every mode × backend × attendance × skip combination.
  • Adversarial self-review covered log injection (newline and ESC in names, reasons and argv), secret leakage into the ledger and logs, append-only (earlier ledger text asserted as a prefix), and fallback never becoming possible where plan refuses.
  • A pre-PR independent agent review of the branch diff reported NO BLOCKER (it checked that plan is untouched, that every ledger fold ignores the new event, JSON escaping against forged lines, no --setenv leak of server env values, additive public API). The later NAME=VALUE redaction commit was read by the coordinator. CI: all checks green, Cora Review "No issues found" on the final head; the one Test failure seen (tui_streams_approves_cancels_and_leaves_an_ordinary_session, a TUI pty timeout) passed on re-run. cora is not installed here, so scripts/review-local.sh was not run; the CI Cora Review is the gate.

…acks in the plugin ledger, add TOLE_VERBOSE launch logging (#750)

The start-up line of a sandboxed MCP server now names the profile the server runs in with a short hash, as one sanitized line. An optional server that starts unsandboxed is recorded as a sandbox_fallback line in the plugin ledger, once per server and session. TOLE_VERBOSE=1 prints the redacted bwrap command line to stderr. The doctor SENSITIVE marker covers more credential locations. Design note, threat model, changelog and epics are corrected to match.
…n the verbose launch line (#750)

A positional NAME=VALUE (API_KEY=x), one after -e, and --env=NAME=VALUE are redacted like secret-shaped flags. The fallback reason's whitespace split of the lock source is documented as an approximation.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit d02bf14 into develop Nov 16, 2026
33 of 34 checks passed
@ajianaz
ajianaz deleted the feat/750-sandbox-startup-ledger branch November 20, 2026 08:35
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.

2 participants