Repository navigation
feat(serve): delegate and discuss for server sessions (#994) - #1348
Merged
Merged
Conversation
The size guard only lets session/host.rs shrink, and the next change to the server session host needs a few lines there. The module roster_tests moves unchanged except for its paths (it used only the public API of the host) and the start-up calls the entrypoint makes; the guard's entries for the file and for the crate go down by the moved 165 lines.
Owner decision of 2026-11-29 on #994: a session hosted by `tole serve` or `tole acp` gets delegate, delegate_poll, discuss, discuss_status and discuss_stop, built by the shared assembly like the CLI faces' (AGENTS.md section 6, one capability, every face). - FacePolicy::SERVER_SESSION is AgentsPolicy::Delegating (the Classic variant stays for embedders). - session::owner_delegation holds the owner's Setup (profiles, `[delegation]` limits, data dir), installed once at start-up by `tole serve` and `tole acp` from the user config through registry::install_owner_setup; the session host and the serve mission registry read it from there and from nowhere else. An unset cell is an error, not a default. - A discussion that a session's `discuss` tool drives is registered in the process, so GET /discussions/{id} says `running` and the owner's resume and stop cannot start a second driver next to it. - docs/faces.md: the five rows are `policy` with a reason, none points at a closed issue; face_parity passes. No route is added (the device-token scope is untouched), every call stays Risk::Write behind the server's approval queue, a plan-mode server or session registers none of the tools, and a delegated child's own approvals reach the `GET /approvals` list as dap-* rows that only a full token answers. Tests: tests/server_delegation.rs (roster, plan mode, approval gate, the machine guard queues a server session's child and starts no process, the discussion registry), tests/server_delegation_unset.rs (no setup, no session), tests/serve_delegated_child_e2e.rs (real `tole serve`: the start is an approval, the child's approval is listed, a read-only token gets 403, the full token lets the child proceed; a plan-mode server has none of the tools). The guard's entry for the crate ends 89 lines below develop's.
The threat model gets a section for the new surface with its residuals (one goal budget per session host instance, the 64-log scan of GET /approvals, a child outliving the server, the serve token as approval authority), the mobile-control and approving-delegated-work pages say where a server session's children and discussions show up, and the README tool table, the epics status and the CHANGELOG name the behavior change.
- A child no longer inherits an allow entry that starts more children. A server session hands its delegation host the allow list plus `!agent_start`, `!delegate` and `!discuss` when a positive pattern covers one of them (owner_delegation::inheritable): an owner's `--allow agent_start` used to cover only the session, because a classic child had no agent tools, and is now the alias of `delegate`. - `consult` is enforced: a consult child is launched with `--plan-mode` on every face (it was only a discussion participant), so "consult never writes" holds because no Write tool exists. Shared code, so the CLI faces change too. - The registration of a model-started discussion ends with its driver's thread by a drop guard, so a panic or a thread that cannot start does not leave it running for the life of the process. - A serve that drains (REST and --transport mcp) sends SIGTERM to the process groups of the children its sessions started (delegation::spawned, recorded with pid and start time and the host's own kill function, no new unsafe). - A dap-* row and its decision are redacted with the egress set an apr-* row uses (serve_delegation::egress). Tests that fail before: server_delegation (inheritance), delegate_children (consult argv, terminate_all), discuss_registry (started through DiscussTool, panic path), serve_delegated_child_e2e (SIGTERM ends the child), serve_delegation_e2e (a merged secret), server_roster (plan-mode absence is no longer vacuous: a data dir makes the tools present first). server_delegation is one test with a TestDir, so no tole-* directory is left.
The CHANGELOG no longer says nothing is looser: it lists exactly what changes for an existing config (spawning allow entries are not inherited by a child, a stopped serve ends its children, a dap row is redacted with the egress set, and a consult child runs in plan mode on every face). The threat model gets a row for each finding, marks the per-session goal budget, the 64-log scan and the expiry of MCP and ACP child approvals as accepted residuals, and says that tole acp has no drain and a CLI session keeps its children.
…round 1 (#994) The layering test wants an ALIASES entry for the new top-level re-export spawned, and the test that an ordinary delegate child is not a participant used a consult child, which is now launched in plan mode on purpose: it uses an execute child, which still shows that the restrictions hang on the participant task only. The spawned registry takes a type alias for clippy.
…tdown (#994) A consult child is launched with --plan-mode, but main.rs refused that flag for anything but a discussion participant, so a real ordinary consult child died before its first model call. spawned::may_plan lifts the refusal for a delegated child as well (the delegation log and node its launch sets; the participant marker and its approver behavior are untouched) and a plain mission in plan mode stays refused. tests/delegate_consult_real.rs runs the real binary. - spawned: a pid of 0 or 1 and a lease without a start time are never recorded, and the group signal refuses a pgid of 0 or 1, so the server's own group is never signalled; each child gets one SIGTERM and, after 5 seconds, one SIGKILL; a leader that is gone leaves its group to be ended too; tole acp ends its children once when its editor closes the pipe. - consult with a role is refused at the start (plan mode has no handoff tool). - The face policy tests move to tests/face_policy.rs (same names) and gain the server session's no-worktrees assertion; the delegate_children tests are serialized and reap their children; the serve harness stops a serve that delegated with SIGTERM so no parked child outlives a failed test. - CHANGELOG and threat model: which faces end their children, that an owner's allow for delegate, discuss or * never authorises nested delegation on a server, that consult children lose every Write tool on every face, and the arithmetic of what bounds one goal.
#994) The serve drain sent SIGTERM and left at once, so the SIGKILL escalation never ran. It now waits (within its own grace) until the recorded child groups are gone, escalates after 5 seconds, and kills what is left when the grace ends (REST and --transport mcp). A gone leader's group is ours only while it has a non-zombie member, so zombie-only groups are forgotten instead of re-signalled and the signalled count is exact. Docs: BREAKING entry for the consult and allow-list changes, the carve arithmetic (the tenth child is refused), the non-unix caveat, which faces end their children, todo_write stays in a consult child. Tests: a child that ignores SIGTERM, the zombie group, the reused pid, serial() drop order, the harness drain only for a running serve, and the disk-queue test zeroing every other threshold. Two lease tests move to tests/ledger_leases.rs.
🔍 Cora AI Code ReviewReview powered by cora-code · BYOK · MIT |
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.
What
Server (
tole serve, andtole acp, which shares the policy) sessions get the toolsdelegate,delegate_poll,discuss,discuss_statusanddiscuss_stop, through the shared assembly (owner decision B on #994, 2026-11-29). The fivedocs/faces.mdrows that saiddrift #945are nowpolicyrows with their reasons;cargo test -p tole-cli --test face_paritypasses.Why
Server sessions are what the desktop, the phone and the gateway drive. A person there could start and follow a discussion over the
/discussionsroutes, but a model in the session could not delegate or discuss, so the capability existed on one face only (AGENTS.md section 6, "one capability, every face"). Closes #994.Changes
FacePolicy::SERVER_SESSIONisAgentsPolicy::Delegating(theClassicvariant stays, a published enum keeps its variants).session/owner_delegation.rs(same shape asowner_mcp): the owner's profiles,[delegation]limits and data dir, set once at startup bytole serveandtole acpthroughregistry::install_owner_setup, never from a request or from the served repository (the config layering takesdelegationandprofilesfrom the user layer only). A host that forgets to set it fails to open a session instead of running without limits.serve/scope.rsis untouched). Starting a child or a discussion is a tool call inside a prompt (POST, full scope). A child's own approvals are the existing durable queue:GET /approvalslistsdap-*rows andPOST /approvals/{id}/decisionanswers them; a read-only device token gets 403 on both.Risk::Write: anapr-approval in the server queue unless the owner typed--allow delegate; no--trustpreset covers them. The three Destructive layers and "MCP tools are always Write" are unchanged. A plan-mode server or session has none of the five tools.agent_start,delegateanddiscuss(owner_delegation::inheritable), so a child can never start grandchildren without the owner: the owner's own--allow delegatestill covers the session's own starts. The CLI faces are unchanged.consultchildren really are read-only now (--plan-mode, shared code, so the CLI faces change too):main.rsaccepts--plan-modefor a delegated child (the delegation log and node its launch sets), not only for a discussion participant, and a plaintole mission --plan-modeis still refused. A consult child with aroleis refused at start. These are breaking changes for existing CLI users and the CHANGELOG lists them under BREAKING.discuss::owner::driven_by_session, with a drop guard), soGET /discussions/{id}no longer reports itinterruptedand the owner's resume cannot start a second driver.dap-rows are redacted with the egress secret set (fix(serve,acp): error answers carry storage and provider error text with no wire redaction; the process secret set is replaced on every turn #1314), likeapr-rows.tole serve(REST and--transport mcp) ends the children it spawned during its drain (SIGTERM, then SIGKILL after a grace; only a child whose lease, pid plus start time, is still the same live process; dead groups are pruned; pid 0 and 1 are never signalled);tole acpsends one SIGTERM when stdin closes; a CLI session and a server killed with SIGKILL do not. Nothing is promised on non-unix.docs/faces.md,docs/threat-model.md(a row per surface with the residuals),docs/mobile-control.md,docs/approving-delegated-work.md, README,docs/epics.md, CHANGELOG. The design note is kept out of the repository.tole-clicrate 84445 on the earlier base to 84189 now): whole-file moves of public-API test modules totests/(session/host.rsroster tests totests/server_roster.rs, theassemble.rsface-policy tests totests/face_policy.rs,delegation/serve_delegation_tests.rsis untouched, two lease tests totests/ledger_leases.rs), same test names.This PR is larger than the usual 15 to 20 files (45 files, 10 commits stacked in order: a pure test move, the feature with its tests and
faces.md, then review rounds). They do not split cleanly: the feature, the shutdown hardening and the consult fix rest on each other, and splitting would leave adevelopwhere server sessions can delegate without the limits or the fixes.Callers and impact (
cora callers/impact/affected, each verified by grep):FacePolicy::SERVER_SESSIONis read by the roster assembly and the session host;install_owner_mcphad two call sites (tole serve,tole acp), replaced byinstall_owner_setup;delegate::launchis shared by every face;check_*,jailedand the guard paths are not touched.Testing
tests/server_delegation.rs,server_delegation_unset.rs,serve_delegated_child_e2e.rs(the realtole serveand a scripted provider:delegatestops at anapr-approval; after the owner allows it, the child's Write appears inGET /approvalsasdap-*; a read-only token gets 403 on allow and deny and the request stays pending; the full token allows it and the child writes the file; a--plan-modeserver lists none of the five tools; a SIGTERM to the server ends its child),serve_delegation_e2e.rs,delegate_children.rs(fake child binary),delegate_consult_real.rs(the REALtolebinary: a consult child started throughdelegatereaches its model with no write tools, and a plain mission with--plan-modeis refused),discuss_registry.rs,ledger_leases.rs,face_policy.rs,server_roster.rs(moved). Mutation checks:SERVER_SESSIONset toAgentsPolicy::Nonefailsface_parity, both serve e2e tests and three of the fiveserver_delegationtests; withmay_planreverteddelegate_consult_realfails by timeout; withinheritableneutralised,server_delegationfails; with the kill removed the shutdown test fails.cargo fmt, clippy-D warningsfortole-cliin the default,--no-default-featuresand--no-default-features --features shell-toolsprofiles; the full--libsuite and 19 integration test binaries (layering,hermetic_audit,face_parity,server_*,serve_*,serve_shutdown,acp_*,delegated_approval_e2e,agents,participant_mission_e2e...) pass;scripts/arch-check.shok;cora review --staged --no-llmno issues. In the workers' root containerassemble_golden(noghin the roster) and the twomission_e2esecrets tests fail identically on a cleandevelop; CI is the check.--allow delegatecovers onlydelegate), device tokens (read-only gets 403, no new data beyond what it could read), resource bounds (about nine to ten children per goal by the step carve 200, 100, 50, 25, 13, 6, 3, 2, 1; a model cannot reopen its own session; an unanswereddap-request expires to a denial and nothing auto-approves), plan mode (the five tools absent), ACP and MCP (child approvals expire to a denial afterapproval_secs), kill on shutdown (pid-reuse lease check, only own children). The should-fix items were all fixed: nested delegation through an inheritedagent_start,consultnot read-only, the discussion drop guard, vacuous or leaking tests, the egress union ondap-rows, kill on shutdown.scripts/review-local.sh --agent, fresh read-only agents), two rounds: round 1 found a CRITICAL that the security reviews had not (consult children could not start at all, becausemain.rsrefused--plan-modefor anything but a discussion participant and the earlier tests used faketolescripts): fixed with a real-binary test; pid 0 could have madekill(-0)signal the server's own process group: fixed; round 2 verified the fixes and found minor items (the drain exited right after SIGTERM so the SIGKILL escalation was dead code, dead groups were never pruned,todo_writestays in a plan-mode child, doc arithmetic), all fixed.GET /approvalsscans at most 64 delegation logs (a pending child request can go unlisted and then expires to a denial: fail-closed);dap-rows lack the feat(core): plain-language action summary in the shared approval row #1041 action summary (rendering drift); MCP and ACP child approvals expire to a denial;tole acpsends SIGTERM only; a child that leaves its process group bysetsidis not reached; nothing is ended on non-unix.