feat: macOS sandbox (SSH, split-DNS, cloud CLIs), runc reaper, TUI composer, MCP and session fixes #72
Loading…
Reference in a new issue
No description provided.
Delete branch "taha/macos-tui-20261111"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.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.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").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.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.- 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).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).