Repository navigation
feat(daemon): remote-tool confirmer, pending map, answer RPC; not installed (#4291, 2/3) - #4320
Merged
Merged
Conversation
…PC (not installed) (#4291) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…s tree Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… routing, card write raced against cancel Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
mstomar125
force-pushed
the
issue-4291-confirm-daemon
branch
from
November 20, 2026 09:53
864fa27 to
ca0710c
Compare
mstomar125
added a commit
that referenced
this pull request
Nov 20, 2026
…onfirmer, frontend card (local, not pushed) Remaining: rebase onto the fixed #4320 head and then origin/main; run quality:fix, shape/types/node-types checks, test:changed; mutation batch; PR body. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
mstomar125
added a commit
that referenced
this pull request
Nov 20, 2026
…tive turns (#4291, 3/3) (#4321) * WIP: confirmation card: schema, chat card UI impl, interactive-only confirmer, frontend card (local, not pushed) Remaining: rebase onto the fixed #4320 head and then origin/main; run quality:fix, shape/types/node-types checks, test:changed; mutation batch; PR body. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * feat(agent): record tool programs by group, hardening, card tests (#4291) Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * fix(frontend): card lint and focus rules (#4291) Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * fix: card review round (credential check, delay, foreign cards, forged cards, restart cancel, shared vectors) Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * test: card timing tests use fake timers Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * test: kill the delay and focus mutants with fake timers; refuse message subtypes Co-Authored-By: Claude Sonnet 5.5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 2 of 3 of the remote-tool confirmation wiring (#4291; user ruling 2026-11-20: the confirmation is an in-chat card; design note in the PR 1 description). Builds on #4318 (merged). It is inert: the confirmer is not installed on any turn, so every remote tool whose calls need confirmation is still not offered. PR 3 adds the card (a
ConfirmationUi) and installs the confirmer on interactive turns.Agent lane. This touches
packages/agent(Michael's lane) and the daemon. The user's sign-off for the #4291 remote-tool build stands in for Michael's.What it adds
packages/daemon/src/services/remote_confirmation.rs:PendingConfirmations: the table of questions waiting for an answer, per database. Entry = chat, turn, stored digest, one-shot sender.DaemonCallConfirmer(aCallConfirmer): per question a random id (two OS-random UUIDv4s, 64 hex characters, never reused) -> entry inserted ->ConfirmationUi::present-> wait for the answer, a 120 s timeout, the turn's cancel token or the database shutdown. Anything but an explicit yes is no.answer): accepted only for the exact request id + chat + digest. The digest is compared with the STORED digest of the live request, never recomputed from client parts, and is mandatory (a no needs it too). Unknown / late / duplicate / foreign-chat / wrong-digest answers are refused and leave a pending question pending (a stray answer cannot cancel it). The first valid answer removes the entry and delivers the answer under one lock, so it is single use.clear_turndrops a turn's questions when it ends.AnswerConfirmation(node_id, request_id, digest, allow)gRPC RPC (proto + handler) returns onlyaccepted; every refusal looks the same.LocalAgentServiceImpl::confirmer_for_turn:Nonefor a non-interactive (scheduled / headless) turn and when no card is installed; not called yet.The answer channel (requirement (c)): the peer gate, after review
The RPC is on the daemon's same-user socket, and a program the daemon starts for a tool is the same user, so the handler judges the peer BEFORE it routes or reads the request (a refused peer sees the same answer whatever database header it sent).
How it decides (
nodespace_agent::spawned,SpawnedProcessGate). The daemon RECORDS the pid of every program it starts for a tool: through the sharedspawn_isolated(tool-cli, MCP stdio servers, the ACP engine) and the PTY session spawn. The peer is refused when its process GROUP is a recorded group (a background process, an orphan whose parent has exited, and a grandchild all keep the group), when it is a recorded pid (start time compared, so a reused pid is not mistaken for it), or when a recorded program is among its ancestors. Also refused: the daemon itself, pid 0 (another pid namespace), pid 1, and any peer whose own identity cannot be read. A program the daemon started that is NOT recorded passes (the tray's "Open NodeSpace" starts the app as the daemon's child, so the genuine UI is not refused on that path any more). Groups are forgotten when empty, pids when dead or reused.Launch paths of the genuine UI: installed app (Finder / Dock): passes.
bun run dev:tauri: passes. The app started by the tray: passes (not recorded). CLI and headless runs: there is no answer command. Windows: the named-pipe transport carries no peer pid, so every answer is refused by design (inert there until solved). Linux with/prochidden (hidepid): peers are unreadable, refused.Known limits, stated plainly. A recorded program that leaves its group (
setpgid/setsid) AND whose parent has exited is indistinguishable from any other program of the same user. The fix is the peer's audit token (macOSLOCAL_PEERTOKEN) with a code-signature check against the NodeSpace team id (SecCodeCheckValidity); a debug or unsigned build would need an opt-out. That is planned as a follow-up to PR 3 (not done here). The peer pid is captured when it connects and judged on each request; a connector that has died reads as unknown and is refused. Once the card's request id and digest are stored in the chat node (PR 3), any same-user tool can read them withnodespace get: the id is NOT a secret from tools, the peer gate is the only barrier (a PR 3 acceptance criterion).Also fixed in this round: pid 0 is refused (
<= 1);confirm()races the card's write against the cancel token, shutdown and the timeout (a hung card write cannot hold a turn past its cancellation), and a dropped question ends its card as cancelled; tests with real processes: a recorded program, its grandchild and its orphan after the parent exits are refused; this process and an unrecorded child may answer; the daemon, pid 0, pid 1, no pid and a dead peer are refused; a UDS test drives the real tonic path (peer pid fromUdsConnectInfo-> gate -> handler), with and without a database header.Folded in from the #4318 review
Digest is length-prefixed (SHA-256 over len(text) as u64 BE, text, arguments) with a boundary test (
("a","b\0c")vs("a\0b","c")); a serialisation error refuses the call instead of defaulting; boundary test: arguments of exactly 16384 bytes are asked, 16385 refused; a pinned run following a same-origin 302 asks the resolver nothing more; a pin the address policy blocks (0.0.0.0 forlocalhost) is refused even though it is reachable;is_unsafe_for_logalso covers U+E0100-E01EF and U+180B-180F.PR 3 acceptance criteria (written down here as asked)
The card shows ONLY
arguments_jsonand the summary; it must escape or visualise bidi, zero-width, line/paragraph-separator, tag, variation-selector and other invisible characters in BOTH the summary (destination) andarguments_jsonthrough one shared display-safe function (theis_unsafe_for_logset is currently used only for the whitelist warning log); the credential line is a separate structured field, never parsed from text; the answer carries the digest the daemon sent; other devices see a pending card read-only.Tests and mutants
20 tests in the module (fake UI) plus 3 in the service. Mutants (26 across the two rounds, each killed by a named test or by hanging the test; the one equivalent mutant was pinned by a new unit assertion): digest comparison, empty digest (now doubly guarded), chat comparison, timeout treated as yes, per-chat cap, answer not single use, gate lets the daemon tree through, gate lets unknown peers through, short id, clear_turn too wide, a card that cannot be shown ignored, an accepted answer dropped in a race, interactive check removed, gate skipped in the handler.
a_built_in_tools_result_is_unchangedinagent_loopis a pre-existing flake undercargo test.🤖 Generated with Claude Code