feat: macOS sandbox (SSH, split-DNS, cloud CLIs), runc reaper, TUI composer, MCP and session fixes #72

Merged
kreato merged 44 commits from taha/macos-tui-20261111 into main 2026-11-11 19:11:06 +00:00 AGit
Contributor

On top of main (86c3dfc6), 31 commits; supersedes PRs #70 and #71. SANDBOX: network.ssh broker for ssh/scp/git from the macOS sandbox; split-DNS private endpoints via network.private (per name or per resolved address, nothing re-resolves between check and dial); revoked or denied network grants close live CONNECT tunnels; network.private/network.ssh host grants match case-insensitively (an EKS endpoint copied from a kubeconfig was refused); TrustedEnvironment carries KUBECONFIG/AWS_CONFIG_FILE/... to the Seatbelt worker; git always uses the generated config; runc containers left by a dead daemon are reaped at start; seccomp allows creat; macOS curl and NIX_CONFIG; kernel names survive a sandbox replacement; saml2aws config recognition. TUI: Ctrl+C draft survives an accepted command suggestion; no space after an @ mention, one after a completed command (web too); keybindings that bind nothing are logged to daemon.log instead of the terminal; sessions panel header describes the highlighted session; tests pin undo/redo and click-to-caret. APP: deleting a session deletes its subagent sessions; read-only (NixOS) MCP servers can be disabled for one session and its subagents at runtime; startup model discovery is cached for the next start (nanogpt). SMOKE: scripts/smoke-seatbelt-cloud.sh runs cloud CLIs in a throwaway daemon's sandbox. On macOS 27 with the VPN up aws, aws sts, saml2aws, gcloud, kubectl (incl. get ns on a private EKS), helm, k9s, talosctl and gh pass; docker fails (binary under /Applications/Docker.app is not readable). VALIDATION: build, vet, gofmt, plugin API, web stamp, deadcode green; -race suites green run alone (internal/app 936s exceeds check.sh's 10m default timeout); every fix has a regression test that fails on the old code.

On top of main (86c3dfc6), 31 commits; supersedes PRs #70 and #71. SANDBOX: network.ssh broker for ssh/scp/git from the macOS sandbox; split-DNS private endpoints via network.private (per name or per resolved address, nothing re-resolves between check and dial); revoked or denied network grants close live CONNECT tunnels; network.private/network.ssh host grants match case-insensitively (an EKS endpoint copied from a kubeconfig was refused); TrustedEnvironment carries KUBECONFIG/AWS_CONFIG_FILE/... to the Seatbelt worker; git always uses the generated config; runc containers left by a dead daemon are reaped at start; seccomp allows creat; macOS curl and NIX_CONFIG; kernel names survive a sandbox replacement; saml2aws config recognition. TUI: Ctrl+C draft survives an accepted command suggestion; no space after an @ mention, one after a completed command (web too); keybindings that bind nothing are logged to daemon.log instead of the terminal; sessions panel header describes the highlighted session; tests pin undo/redo and click-to-caret. APP: deleting a session deletes its subagent sessions; read-only (NixOS) MCP servers can be disabled for one session and its subagents at runtime; startup model discovery is cached for the next start (nanogpt). SMOKE: scripts/smoke-seatbelt-cloud.sh runs cloud CLIs in a throwaway daemon's sandbox. On macOS 27 with the VPN up aws, aws sts, saml2aws, gcloud, kubectl (incl. get ns on a private EKS), helm, k9s, talosctl and gh pass; docker fails (binary under /Applications/Docker.app is not readable). VALIDATION: build, vet, gofmt, plugin API, web stamp, deadcode green; -race suites green run alone (internal/app 936s exceeds check.sh's 10m default timeout); every fix has a regression test that fails on the old code.
Taha added 31 commits 2026-11-11 16:12:41 +00:00
GNU tar 1.35 creates an archive with the legacy creat(2) syscall instead of
openat. The runc allow-list omitted it, so `tar -cf out.tar dir` failed inside
every runc sandbox with "Cannot open: Operation not permitted" while
extraction worked. creat(p, m) is open(p, O_WRONLY|O_CREAT|O_TRUNC, m) and
open is already allowed, so this widens nothing.

TestRuncSeccompAllowsCreatForGNUTar fails without the entry.
Several suites were red on hosts without the paths or terminal the tests
assumed (NixOS, minimal containers), for environment reasons rather than
behaviour:

- cmd/yazi: syscall.Getsid has no Linux binding, so the package's tests did
  not build there; use golang.org/x/sys/unix.Getsid.
- internal/sshtunnel: resolve bash with exec.LookPath instead of writing a
  #!/bin/bash shebang.
- internal/tui2/app: theme.Load quantizes colours from COLORTERM/TERM, and
  useTheme loaded the theme before pinning them, so the Sixel palette test
  compared against its own 256-colour approximation; pin truecolor first.
- internal/sandbox: build the seed tar with archive/tar (host GNU tar creates
  archives through creat(2), which a seccomp allow-list may refuse), and make
  the fake runc answer `state` with the pid JSON Start unmarshals.
- internal/tool/sandboxed: resolve echo with exec.LookPath instead of the
  literal /bin/echo.

No assertion changed.
The Seatbelt worker may open no direct socket and has no DNS resolver, so
ssh, scp, rsync and git over SSH could not reach any host from the macOS
sandbox. Add a network.ssh permission naming one exact host:port and an SSH
route on the session broker: a ProxyCommand helper asks the authenticated
loopback broker to tunnel to the destination, the broker authorizes it
against an exact standing grant per connection, re-resolves the name and
refuses private answers (a private SSH host needs network.private).

- Patterns and one-time grants are refused rather than weakened.
- host.ssh carries the live agent socket the Linux sandbox mounts
  (SSH_AUTH_SOCK, ssh_config IdentityAgent, ~/.1password/agent.sock) and a
  sandbox-owned copy of the public ssh files; no private key is copied and a
  missing agent socket aborts the start instead of running without it.
- The tunnel wraps both io.Copy ends so Go's WriteTo/ReaderFrom fast paths
  cannot bypass the relay, and every broker hook is installed before the
  proxy serves (data race found under -race).
- A CONNECT whose name answers only privately now falls back to an exact
  network.private host:port grant and the 403/502 bodies name what to ask for.
Expose the new permission where a grant is requested: the sandboxed tool canonicalizes a network.ssh resource (host:port, bare host means 22) before it reaches the store, the Python kernel request_access accepts it, and the web approval prompt describes it. The committed web build is regenerated from web/src.
Seatbelt takes no mounts, so the runc grant loop built a spec the macOS
worker silently ignored and host.ssh never reached it. Apply host.ssh grants
to the Seatbelt spec's ssh fields instead, remove the ssh copy on a rebuild
without the grant, clear the approval on deny, list network.ssh among the
permission choices with the session scope the enforcement table requires,
and teach the guide the host.ssh + network.ssh pair. The permission-choices
test now runs against a temporary HOME with a live agent socket instead of
the developer's real one. Document the macOS SSH flow.
saml2aws reads ~/.saml2aws (through SAML2AWS_CONFIGFILE) and writes
credentials into ~/.aws, so a sandboxed `saml2aws` now requests both like aws
does and the harness points SAML2AWS_CONFIGFILE at the approved file. Add a
"Cloud CLIs" section to docs/sandbox.md: which grant each tool needs, that
config directories are read-only so interactive logins must run on the host,
device-code logins, and how each backend enforces the network side.
Each runc sandbox is a container whose init sleeps forever. A daemon that
exits normally deletes them, but one that is killed, OOMs or crashes left
every container it held running on the host as an sh + sleep 3600 pair, and
nothing reclaimed them: PruneManaged and yazi sandbox prune skip running
containers by design and run only from the CLI.

- At daemon start on the runc backend, ReapOrphans deletes the yazi-*
  containers nothing owns, running or stopped. A container is kept while its
  project in-use lock is held (a live worker of any daemon), while its bundle
  is younger than two minutes (a start that has not taken the lock yet), or
  when the caller owns its session; bundles go through removeWithin.
- Start deletes the container when runc create fails or its state cannot be
  parsed; both paths used to return without a delete.
- Destroy runs under WithoutCancel plus a 60 s bound, so a cancelled caller
  cannot drop the delete.
- Sandbox Stop/Close errors are logged with the session id instead of being
  discarded with `_ =`.

TestRuncStartDestroysTheContainerWhenItsStateIsUnreadable fails without the
delete; TestRuncReapOrphansDestroysOnlyUnownedContainers fails when the
reaper ignores the lock or grace window, or reaps only stopped rows.
Three things a macOS session hit in practice:

- /usr/bin/curl is built on LibreSSL, which opens
  /private/etc/ssl/openssl.cnf at start. The profile granted only metadata on
  /private/etc/ssl plus cert.pem, so curl failed with "Auto configuration
  failed" before any request. Allow reading that one file.
- The runc worker runs with NIX_CONFIG enabling nix-command and flakes, and
  the system prompt offers `nix shell nixpkgs#<pkg>`, but the Seatbelt worker
  env omitted it, so every `nix shell` failed for a disabled feature. Give it
  the same NIX_CONFIG. Whether a multi-user Nix install then works in the
  sandbox (read-only store, no daemon socket) is not verified.
- The model probed DNS with getaddrinfo and dig and listed the parent of a
  granted file. Say in the execution prompt that name resolution goes
  through the broker's proxy and that a file grant does not expose its
  directory; no DNS access is added.

TestSeatbeltProfileAllowsLibreSSLConfig fails with the old profile;
TestSeatbeltCommandCarriesNixConfig (darwin) asserts the worker env.
Every sandboxed session lost its Python variables when its runtime was
replaced (after a filesystem, host.ssh or network approval): the activation
parked the teardown snapshot's restore on the host-side Python tool, then
closed that tool and swapped in the sandbox's own, which had no pending
restore and no restore callback. The snapshot listed the names as saved and
the next cell answered NameError. Read the snapshot first and apply it to the
tool the session actually runs; an unreadable snapshot now leaves a
[kernel restore] note for the agent instead of only a stderr line.

Two triggers of that loss are removed as well:

- network.private no longer rebuilds the Seatbelt worker: the session broker
  reads the store on every CONNECT, so a grant reaches the live worker
  without a replacement (the broker is started at every activation).
- The command-access error no longer says "approve it, then run the same
  command again". A retry before the decision re-raised the same request,
  and after approval it hit the rebuild guard; the answer now says the
  command did not run and the decision arrives as a notice.

The remote-endpoint kernel still restores nothing after a replacement; that
path is unchanged here.
After ~/.kube/config was approved, kubectl in the macOS sandbox still saw no
config: KUBECONFIG and friends were set only on the runc path, the Seatbelt
worker's HOME is the sandbox home, and Seatbelt refuses spec.Environment.
The model had to export the variables by hand.

Add Specification.TrustedEnvironment, a channel for daemon-computed
configuration pointers that the Seatbelt backend merges into the worker's
trusted base environment. Each approved filesystem grant carries its own
assignments (configEnvForPath), so the worker replacement that applies a new
grant also sets its variable. ValidateTrustedEnvironment refuses malformed or
duplicate entries and every variable the sandbox owns - HOME, PATH, TMPDIR,
the proxy and agent variables, NIX_CONFIG, GIT_*, DYLD_*, LD_*, YAZI_* - and
the activation leaves those out, so a ~/.gitconfig grant cannot replace the
sandbox's own git config. The guide no longer tells the model to pass
--kubeconfig on macOS.

TestValidateTrustedEnvironmentRefusesVariablesTheSandboxOwns pins the
refusals.
A kubectl session on macOS could not reach an EKS API whose public DNS name
a VPN resolves to private addresses. With a network.url grant the broker
took the public route and refused the private answers with an opaque 502;
network.private grants for the two resolved IPs never matched a CONNECT that
names the host, so the only way through was dialing the IP by hand with
--tls-server-name.

- A DNS name whose every answer is non-public is served by a
  network.private grant for the connected host:port, or by one grant per
  resolved address; every answer must be covered. The name is resolved once
  and the answers are pinned, so nothing re-resolves between the check and
  the dial, and no lookup is spent when no network.private grant applies.
- A network.url grant alone never reaches a private address; mixed public and
  private answers never dial; an explicit deny or a one-time row beats the
  fallback.
- Plain HTTP fills the scheme's default port, so http://10.0.0.70/x can use a
  10.0.0.70:80 grant.
- The refusal names the rows to ask for (the host:port and each resolved
  address) and carries nothing else.

The private_route_fallback_test.go tests fail with the old routing (seven of
them assert behaviour the old code did not have).
TestSandboxedSessionRunsItsFirstCellWithTheTeardownSnapshotRestored runs a
sandboxed activation over a teardown snapshot with a real kernel and checks
that the first cell sees the restored name. It needs one seam: the backend
construction moves verbatim into openSandboxBackend, and a test may stand in
a hermetic backend through Service.sandboxBackend (nil in production), the
same way openProcesses stands in for the process manager.

With session_runtime.go and the sandboxed Python tool from before the fix,
the first cell fails with NameError and restored=[].
body: The broker kept an established CONNECT tunnel open until the worker was
replaced, and network grants no longer replace the worker: denying or
revoking network.private, network.ssh or network.url left the connection it
backed relaying. The service already deleted or denied grants.

- registerTunnel records what authorized the tunnel (the network.url origin,
  the network.ssh destination, the private host row or the per-address rows
  behind the pinned answers).
- NetworkBroker.RevalidateTunnels re-runs those store decisions without ever
  resolving DNS again and closes tunnels the current grant set no longer
  backs, then drops pooled connections; the service calls it after every
  stored network decision and in grant deletion, outside s.mu.
- A refused one-time scope, a lost per-address row and a store failure all
  close rather than ride on.
- resolvePrivateAnswers no longer leaks the resolver server from the wrapped
  lookup error into the 403 body; the body names the destination only.
- A network.ssh grant naming a public IP literal is honoured: CONNECT
  consults it for public literals too, so the grant the refusal previously
  told the agent to ask for actually worked.
- fec0::/10 (deprecated IPv6 site-local) is classified non-public.

TestTunnelRevalidate* behave the old way with the app wiring reverted;
TestConnectTunnelCloses* and TestSessionProxyConnect* close their paths.
Docs: revocation closes tunnels named per finding.
The sandbox generates its own git config and points GIT_CONFIG_GLOBAL at it,
so the host's pager, aliases, credential helpers, includes and URL rewrites
stay out and commits are signed through the daemon. But a filesystem.read
grant on ~/.gitconfig or ~/.config/git/config re-pointed GIT_CONFIG_GLOBAL at
the host file on the runc backend (configEnvForPath had a git rule and
gitEnvironment kept a granted value), which silently dropped the signing
helper and brought all of that back. Git never needs such a grant.

Drop the git rules: a grant on those files now only makes them readable. The
Seatbelt trusted environment already refuses GIT_*. An operator-set value in
the sandbox environment is still honoured.

TestConfigEnvForPath fails with the old rules.
While browsing /resume the header above the roster always described this
client - its cwd and the endpoints summary - so it said nothing about the
session the cursor was about to open. When the cursor rests on another
session, the endpoints line now carries that session's creation date, model,
cost, message count and endpoint, and the cwd line shows its working
directory (the endpoint's directory for a session on an SSH endpoint). The
current session, an empty roster and a search with no match keep the
client's own header. The height never changes, so the roster does not jump,
and the highlighted row is part of the header memo key so a cursor move
repaints it.

agents.view.list rows gain CreatedAt from the session store. The generated
plugin surface is unchanged: it types the result as a generic array.

header_session_test.go and agents_view_created_test.go fail against the old
header and roster.
A draft parked with Ctrl+C survived typing, pasting and running a slash
command, but accepting a suggestion from the command menu (Enter or Tab on
"/mo") went through Composer.SetText, which always dropped the parked clear,
so Up after the command no longer restored the draft.

SetText now keeps the parked draft when the new text is a command line, the
same rule typing and pasting follow.

TestAcceptedCommandSuggestionKeepsTheParkedDraft fails without the fix.
Accepting an @ file suggestion appended a space, so a completed directory
(@only/ ) ended the mention and the next keystroke started a new word instead
of searching inside it. The path is now inserted bare.

Completing a slash command only appended a space when the command declared
usage text; commands whose argument choices come from slashHints (/mcp and
others) got none, so their sub-command menu did not open until the user
typed the space. Every completed command now gets one.

TestSlashCompletionAppendsTheArgumentSpace, TestFileMentionAcceptLeavesThePathBare
and TestTypingPastAnAcceptedDirectoryDescends fail on the old code.
The web composer appended a space after an accepted file or directory
mention, so a completed @only/ ended the mention and the next character did
not search inside it. It now matches the terminal composer: the reference is
inserted bare and the cursor stays on it.

The updated mentions test and the new directory case fail on the old
applyMention. The committed web build is regenerated.
The daemon's startup discovery pass published each provider's answer only
into the live catalog, and the service's stored-credential pass skips the
providers that plan asks, so the six-hour catalog cache was written only by
/refresh. nanogpt's bundled entry has no models, so a start whose discovery
failed or ran past its budget showed no nanogpt models until /refresh.

runDiscoveryJob now stores a successful answer through StoreCatalogCache
(also when the total budget discards it from the live catalog), so the next
start serves the list from disk. Context windows stay the discovered ones.

TestStartupDiscoveryPersistsTheListForTheNextStart fails without the fix.
A user reported that Ctrl+Z does not restore deleted selected text. The
editor's undo stack covers that path (replaceSpan records before every
delete); these tests drive it through Root.key, the composer and the editor
so a future interception of Ctrl+Z cannot break it silently, and the
keybindings page now documents undo, redo and the Ctrl+Shift+Z terminal
caveat.

With Editor.undo/redo stubbed out the three tests fail.
A click in the composer already moves the caret on the press
(Root.MouseDown -> editor.SelectAt), across soft wraps, wide runes, the
prompt prefix and a scrolled view, and a click after a drag clears the
selection. Six tests now drive that through Root so a missed dispatch hunk
cannot drop it silently, and docs/tui-queue-and-selection.md describes it.
session.delete stopped and archived the subagents below the deleted
session, then deleted only the parent row. The delete cascaded their
relations away, so every child (and grandchild) survived as an archived
session with no parent and showed up as an independent top-level row in
the sessions menu.

deleteDescendantSessions now removes the descendant rows deepest first
after their runtimes are stopped, drops their caches and session grants,
tombstones them in the agent registry and publishes a Deleted
subagent_update. The TUI and the web app share the method.

TestSessionDeleteDeletesDescendants fails on the old code ("session child
survived the parent delete"); TestDeletingAParentStopsItsChildren now
expects the child row gone instead of archived.
The command-suggestion test predates the trailing space a completed command now gets; it expects "/model " and types the argument without its own space.
An id in keybindings.json that no handler claims was reported on stderr on
every start, above the TUI. A key name Parse does not accept was skipped
silently. Both now go to the daemon log next to the file
(<state dir>/daemon.log) as "keybindings: ..." lines, one per entry, and
nothing is printed when yazi starts. keymap.LoadReport returns the skipped
spellings; Load is unchanged. A keybindings.json that is not valid JSON still
warns on stderr: it reverts every binding, which the user must see.

TestLoadKeybindingsWarnsOnUnknownIds and
TestLoadKeybindingsLogsKeyNamesThatAreNotKeys fail on the old code.
MCP servers that come from the deployment (NixOS) are project-sourced and
their settings file is read-only, so /mcp enable and /mcp disable failed
with "project MCP settings are read-only" and mcp.disable with "project
connections are display-only".

For such a connection the decision is now kept in daemon memory, keyed by
the session that made it. A session's effective state walks its parent
chain and honours the nearest decision, so the session and every subagent
below it lose the server (prompt listing, mcp.list_tools/call_tool, sandbox
seeding, the /mcp panel), while a sibling or a new top-level session starts
with the configured state. Nothing is written to disk; deleting the session
(or its parent) forgets the decision, and a restarted daemon starts clean.
User-sourced connections keep their persistent disable. The handlers now
read the session_id the generated schema already declares; the TUI and the
CLI (--session) send it, and a call without one is refused with a message
saying it needs a session. /mcp remove on a managed server still refuses and
points at /mcp disable.

The new tests in mcp_runtime_override_test.go fail on the old code ("invalid
metadata request", "project connections are display-only") and against a
daemon-wide override ("sibling session lost the managed connection").
Containers accumulated on Linux because a daemon that died without
Service.Close (crash, SIGKILL, a stop timeout) left its sessions' runc
containers running, and nothing reaped them; the startup reaper on this
branch does. Its wiring in New had no seam and no test. Config.reapOrphans
is an unexported seam (the acpSpawn pattern) and two tests pin that New
reaps at start.

With the reap call removed, TestStartupReapsOrphanContainersLeftByDeadDaemons
fails ("startup reaper never ran").
scripts/smoke-seatbelt-cloud.sh starts an isolated daemon (its own state dir
and socket, never the user's), creates a sandboxed session through yazi rpc
and runs read-only commands of each installed cloud CLI (aws, saml2aws,
gcloud, kubectl, helm, k9s, talosctl, gh, az) in it, printing PASS, FAIL or
SKIP per tool. docs/sandbox.md describes how to run it on a Mac and the gaps
the audit found (keychain credential helpers, the docker socket, gRPC that
ignores the proxy).

seatbelt_config_env_darwin_test.go checks on macOS that an approved config
pointer (KUBECONFIG and the rest) reaches a real confined worker and that no
other host variable leaks; it compiles here with GOOS=darwin.
A first run on a Mac reported every probe as failed although the commands
ran fine in the sandbox:

- the rpc stream also carries session.event notifications (the finished
  process queues a follow-up turn whose provider error is not the probe's);
  the script now reads only the answer line for its request id;
- the command output field is "Output", and a command's Status carries its
  own "error" ("exit status 253"), which was taken for an RPC error;
- the throwaway daemon loaded the user's config.json and plugins (a trusted
  plugin runs unsandboxed); it now gets its own empty config and plugin
  directory under its state dir;
- probes that need credentials or a reachable cluster (aws sts, kubectl get
  ns) run on the host first and are skipped when they fail there too.

On macOS 27 the run now passes every read-only probe (aws, saml2aws, gcloud,
kubectl, helm, k9s, talosctl, gh); docker fails because its binary lives in
/Applications/Docker.app, which the Seatbelt profile does not let the worker
read.
--keep left the throwaway daemon running after the script exited; it now keeps only the state directory.
On a Mac with the VPN up, kubectl in the Seatbelt sandbox was refused by the
broker ("network URL is not approved") although a network.private grant for
the EKS API server was in place. The grant kept the endpoint's upper-case
spelling from the kubeconfig, the broker asks with the name lowercased
(NormalizePrivateDestination), and MatchResource compared them exactly. DNS
names are case-insensitive; host:port grants for network.private and
network.ssh now match that way. Filesystem paths stay case-sensitive.

With the grant lowercased the same run listed the cluster's namespaces.
TestNetworkHostGrantsMatchCaseInsensitively fails on the old code.
Sandboxed commands do not inherit the shell's AWS_PROFILE and need exact
network grants, so the aws sts and kubectl get ns probes could only be
skipped. SMOKE_AWS_PROFILE, SMOKE_NETWORK_URL and SMOKE_NETWORK_PRIVATE pass
them in (granted only in the throwaway daemon's store), and SMOKE_EXTRA runs
one more command for diagnosis. docs/sandbox.md describes them and the macOS
result.
host.ssh and commit signing looked for the agent in SSH_AUTH_SOCK, the first
IdentityAgent line of ~/.ssh/config, then ~/.1password/agent.sock. On macOS
1Password serves its agent from
~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock and
nothing links it into ~/.1password; the link that made it work on the test
Mac was made by hand. And an IdentityAgent kept in an Include'd file (the
user's ~/.ssh/overrides/1password.conf) was never read.

The macOS default socket is now a fallback after ~/.1password/agent.sock,
and the ssh_config reader follows Include (relative to ~/.ssh, globs in
order, ssh's depth limit), keeps a quoted path with spaces whole and accepts
Keyword=value. docs/sandbox.md lists the order.

TestSSHConfigIdentityAgentFollowsIncludeAndQuotes and
TestAgentSocketInHomeFindsTheMacOS1PasswordDefault fail on the old code.
SMOKE_HOST_SSH=agent and SMOKE_NETWORK_SSH=host:port grant them in the throwaway daemon, so an ssh probe (SMOKE_EXTRA) can reach the agent and a destination.
OpenSSH resolves ~ and its default config and known_hosts paths from the
passwd home, not $HOME. In a Seatbelt worker HOME is the sandbox home, so a
plain ssh (and git/rsync over ssh) read /Users/<user>/.ssh/config instead of
the generated config that routes every host through the broker: `ssh -G`
showed no proxycommand and `ssh -T git@github.com` failed with "Could not
resolve hostname". With -F the same command authenticated through the broker
and 1Password, but still tried to append to the host's known_hosts.

- The generated block pins UserKnownHostsFile and GlobalKnownHostsFile to the
  sandbox home's absolute path, never ~.
- ssh, scp and sftp wrappers go first on the worker PATH (only when the ssh
  transport is applied) and exec the real client with -F "$HOME/.ssh/config".
  A caller's own -F among the options is honoured; a -F after the destination
  (a remote command's argument) is not mistaken for one. git and rsync run
  ssh from PATH and are covered.
- The smoke script's --help no longer cuts the Environment section.

Linux is unchanged (the container's passwd home is $HOME).
TestWriteSSHProxyConfigPinsKnownHostsToTheSandboxHome,
TestWriteSSHProxyConfigInstallsSSHClientWrappers and
TestSSHWrapperRunsTheRealClientWithTheSandboxConfig fail on the old code.
The header renders the session's creation time in the reader's local zone
(sessionFacts formats CreatedAt.Local()), but the test asserted the UTC
wall clock, so it failed on any machine outside UTC. The test now pins
time.Local to a fixed +09:00 zone (restored in cleanup) and expects the
converted time, which also proves the local-time rendering.

The old test fails under TZ=Asia/Tokyo; the new one fails if the renderer
formats in UTC.
Since the web composer inserts a mention with no trailing space, the
accepted token was still under the cursor and the file menu reopened, so the
next Enter re-selected a file instead of sending the message. The composer
now holds the accepted draft (mentionAt takes a hold, the TUI's suggestHold
twin) and keeps the menu closed until the draft is edited. The committed web
build is regenerated.

The new mentions test fails on the old mentionAt.
- network.ssh: AuthorizeSSHDestination compared the matched grant to the
  destination byte for byte after the case-insensitive match, so an
  upper-case grant was refused. It uses EqualFold now.
- A host with both a network.url and a network.private grant was refused
  when its name resolved publicly ("network.private cannot authorize a public
  destination"); the approved public origin now serves it. A failed lookup
  still reports "did not resolve on the host" without the resolver details.
- A tunnel the dial-time private recovery served was registered with the
  public route's grant, so revoking network.private left it open; it is
  registered with the network.private grant that served it.
- The startup reaper could destroy a live container of another daemon
  sharing the state directory (no lock held, past the grace window). Each
  container now records its daemon (pid and kernel start time) in its
  bundle; one with a record is reaped only once that daemon is provably gone.
  Containers from before the record are still reaped by the lock and grace
  rules, so the leaks from older daemons are cleaned on the first start.
- A ~/.ssh or .config/yazi-ssh symlink planted inside the sandbox home failed
  every later start of the session; the daemon replaces it now instead of
  refusing or writing through it.
- docs/sandbox.md gains a Breaking changes section (network.ssh per
  destination on macOS, the wrapped ssh config, a missing agent no longer
  fails the start, fec0::/10 is private, case-insensitive host grants).

Each fix has a test that fails on the old code (TestRuncReapOrphans...
fails because the sibling daemon's container is reaped).
- Deleting a session removed its subagent rows one by one and the parent
  last; a failure midway left part of the tree deleted and the parent in
  place. store.DeleteSessionTree deletes the descendants deepest first and
  the root in one transaction; runtimes are still stopped before it and the
  in-memory cleanup and Deleted events follow only its success. The docs say
  that subagent transcripts are removed permanently with their parent.
- The runtime MCP override: a plugin could set it for any session; mcp.disable
  is now a plugin write method (sessions:write) and a plugin may act only for
  a session it is bound to (one it subscribed to or registered a tool for).
  A per-session disable no longer disconnects the shared client of every
  other session; it only stops routing for the disabled lineage. The unused
  mcpSessionEnabled is gone. mcp.disable on a read-only connection without a
  session_id still refuses, now with an explicit code and message, documented
  as a behaviour change.
- network.ssh and network.private grants are normalized at the daemon
  boundary (sandbox.permissions.put / replace_global, which the CLI uses), so
  `yazi sandbox permissions set network.ssh host` stores host:22 instead of a
  grant that never matches; an invalid destination is refused.

Each fix has a test that fails on the old code
(TestSessionDeleteTreeIsAtomicOnMidTreeFailure, the mcp_* binding, shared
client and compat tests, TestSandboxPermissionsNormalize*).
The count of queued messages sat in the status row, far from the queue block
it counts. It now leads the block's last row, keeping its ╰─ glyph:
"╰─ 2 queued · Alt+Up to browse and edit queued messages". The status row no
longer carries it.

TestQueuePaintsInlineAboveComposer and TestStatusRowMatchesOldSplit fail on
the old layout.
- A CONNECT authorized just before a deny registered its tunnel after
  RevalidateTunnels had taken its snapshot and rode the revoked grant until
  the next permission change. After registering, the broker re-checks that
  tunnel's grant once and refuses the CONNECT before answering 200.
- A RuncBackend.Start that failed after creating the bundle left it on disk
  with its ownership record; the failure path removes it.

A row whose bundle resolves outside the state directory is still never
reaped: nothing can prove it is an orphan.
TestConnectTunnelRegisteredAfterADenyLandsIsRefused and
TestRuncStartFailureDoesNotLeakTheBundle fail on the old code.
Security review:
- events.subscribe bound a plugin to any session it named, under read-only
  scopes, and that binding authorized mcp.disable for the session. A
  subscription binds now only when the plugin holds strict sessions:write.
- mcp.disable on a user-sourced connection let a plugin persist a
  daemon-wide disable, ignoring the session; plugin callers are refused on
  that branch, as for mcp.add and mcp.update.
- The /mcp management verb recorded a runtime override for a foreign session
  without the check mcp.disable makes; it makes it now.

Concurrency review:
- setMCPRuntimeEnabled mutated a per-session map that lineage readers read
  after releasing s.mu (a fatal concurrent map access under load); the
  override is published as immutable snapshots.
- A subagent spawned while its parent was being deleted was removed by the
  tree transaction but skipped by the in-memory cleanup, which used the walk
  taken before it. DeleteSessionTree returns the ids it deleted and the
  cleanup and events follow that list.
- Publishing a plugin generation wiped the bindings its plugins made during
  initialize; the reset is gone (a binding only counts under sessions:write,
  which the write gate re-checks on every call).
- Deleting a session left the root's own plugin bindings for an id reuse;
  they are dropped. A grant cleanup failure after the rows are gone is logged
  with the session id instead of failing the finished delete.

Each fix has a test that fails on the old code
(mcp_override_gate_regression_test.go, mcp_gate_concurrency_regression_test.go,
the store tree tests).
Final review of PR #72:
- mkdirSSHDirReplace looked at the deepest directory first and returned when
  it was a real one, so a link at an upper component (the sandbox home's
  .config pointing at another project's home) went unseen and the daemon
  wrote ssh_proxy.py and the wrappers through it, or removed a file there. It
  now walks every component from the sandbox home down, replacing a link or a
  non-directory (ENOTDIR included) with a real 0700 directory and never
  following one; a .config link to a file no longer blocks the start.
- A yazi-daemon.json that exists but cannot be read as a record was treated
  as missing and fell back to the lock and grace rules; it now keeps the
  container. Only a missing record uses the fallback.
- Host grants for network.private and network.ssh lowercased the whole
  pattern, changing glob ranges such as [A-Z]; only the literal text is
  folded now.

TestWriteSSHProxyConfig...planted .config link, the corrupt-record reaper
case and the [A-Z] pattern case fail on the old code.
Only transcript prose was sanitized. Subagent names, @ file-mention entries
(file names), header facts and markdown link text reached the terminal
verbatim through Canvas.SetLink/Draw, the direct cell constructors
(headerLine, lineBuf.add, markdown addLink) and the encoder's writeRow, so a
name like "evil\x1b[2J" cleared the screen; C1 controls passed both as raw
bytes and as UTF-8 U+009B.

render.Clean replaces C0, DEL and C1 with U+FFFD (wide glyphs, emoji and
combining marks unchanged) where text becomes cells, and writeRow applies it
again as the last boundary. Escapes the renderer emits itself (styles, OSC 8
links) never pass through it. A raw tab that reaches a cell shows as U+FFFD;
the intended tab expansions are unchanged. Parity goldens are unchanged; the
render line budget is raised to the measured size.

Five tests fail on the old code (e.g. Draw("evil\x1b[2J") left U+001B in
the frame).
Final review of PR #72:
- A plugin with the admin grant could still disable a user's MCP server for
  every session and drop its token with mcp.update, or delete it with
  mcp.remove (also before this branch). Plugin callers are now refused for
  every daemon-wide MCP settings write: mcp.add, mcp.update, mcp.remove,
  mcp.set_global_server, mcp.flush_settings and /mcp enable|disable|remove on
  a user-sourced connection. Reads, the binding-gated session override and
  every client path are unchanged. Behaviour change for plugins: registering
  even an HTTP MCP connection now needs the user (docs/plugin-api.md).
- mcp.reload restarted the shared client behind a session's runtime disable;
  it refuses for a disabled lineage.
- A grant cleanup failure after a session delete left grants for a reused id;
  the delete retries once and the daemon prunes session grants of sessions
  that no longer exist at start.
- Plugin session bindings survived a reload; they are tagged by generation
  and dropped when that generation retires, while the new generation's
  initialize-time bindings stay.

Each fix has a test that fails on the old code (mcp_daemon_write_gate_test.go,
grant_sweep_test.go, plugin_binding_reload_test.go, the reload case). Three
existing plugin MCP tests now expect the broader refusal; the coordinator's
own executable and secret-reference refusals stay asserted.
kreato merged commit 15f9a572dc into main 2026-11-11 19:11:06 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kreato/yazi!72
No description provided.