Skip to content

feat(protocol)!: name the delegate on approvals and add the session off switch (DA6) - #152

Merged
lg2m merged 1 commit into
mainfrom
feat/eng-862-da6-delegate-surfaces
Sep 24, 2026
Merged

lg2m merged 1 commit into
mainfrom
feat/eng-862-da6-delegate-surfaces

Conversation

@lg2m

@lg2m lg2m commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Last slice of the delegated-approval plan (ENG-862). Against main; nothing is stacked on it. When this merges the plan is closed.

User-visible behavior

You can see who decided. A settled call now says who settled it: in the TUI the expanded call detail reads approved by jev / approved by reviewer / approved for session / denied by you, and a delegate's denial shows on the row as denied by jev or denied by reviewer. When a delegate passed the hold to you, the approval prompt says why (reviewer passed to you: … or delegate timed out: …). qq run --format text prints [tool] NAME approved by jev; JSONL carries "delegate": "jev" | "reviewer" on tool_approval_resolved.

You can stop delegating for one session. /delegate in the TUI (rows: configured, by_mode, on, off) changes who settles the focused session's held calls for the rest of that session. It takes effect at the next held call — running sessions included — writes nothing to .qq/config.ron, and children spawned afterwards inherit it. The status badge reads MODE · delegate off while an override is set.

Design

  • Protocol 27 → 28 (breaking; root ledger row added). ApprovalDelegate and DelegateIdentity move to qq-protocol as the one source; qq-core re-exports them. New: optional delegate on tool_approval_resolved (only beside the two reviewer resolutions); advisory event tool_approval_escalated { tool_call_id, delegate?, reason } for an escalate, an advisory deny under ask, or the delegate clock running out (no identity), written only while the call is still awaiting approval so a lost race publishes nothing; set_approval_delegate / approval_delegate_set on /v1/sessions/approval-delegate; optional SessionSummary.approval_delegate; /delegate reserved. Goldens under v28/ and headless/v28/; harbor trace fixtures bumped.
  • Why a protocol change: the plan left this to DA6. A supervisor reading a headless stream cannot otherwise tell Jev's decision from reviewer_model's, and the plan's acceptance ("headless output names the delegate on the approval event") requires it.
  • Store schema 35 → 36: nullable sessions.approval_delegate. load_approval_policy returns it with the mode and grants; the gate applies override.unwrap_or(configured) per hold. No authority check on the command: the mode is the ceiling and every value asks at least as much of a human as the configured choice could.
  • Client state: who settled a call lives beside its timing (ToolCallTiming.settled), bounded and evicted with the body; the escalation reason joins the hold's ApprovalPreview and leaves with the hold.
  • The plan's separate docs/runbooks/delegated-approval.md was not written: the operator text fits guide/permissions.md § "Who decides a held call" and runbooks/jev.md already covers the Jev lane. docs/design/delegated-approval.md is deleted — every section is now as-built in tools.md, protocol.md, and ADR-0041 — as the plan required.

Verification

  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets --all-features -- -D warnings: clean
  • cargo test --workspace: all green (719 core, 323 TUI, 226 root, protocol goldens, headless goldens, harbor fixtures)
  • New tests — core: the_session_off_switch_withdraws_the_reviewer_at_the_next_hold_without_a_restart, a_session_delegate_override_reaches_the_reviewer_under_ask_and_children_inherit_it, setting_the_delegate_on_an_unknown_session_is_refused, a_reviewer_escalation_is_published_with_its_reason_before_the_human_is_asked, an_advisory_denial_under_ask_is_published_as_an_escalation_naming_the_delegate; the DA2 delegate-clock test now asserts the cut-off escalation. Protocol: round-trips for the command, outcome, resolution field, and escalation event; four new goldens. Client: a_reviewer_resolution_records_who_settled_the_call_and_evicts_with_it, an_escalation_lands_on_the_pending_holds_preview_and_nowhere_else. TUI: delegate_picker_switches_the_focused_session_off_and_reports_the_receipt, delegate_picker_needs_a_focused_session. Headless: a_delegated_approval_names_the_delegate_in_jsonl_and_text. Migrations re-pinned to 36.

Performance / compatibility

Hot path: one extra nullable column read in the per-hold policy query (already one round trip) and one advisory event write on the escalation path (not the approve/deny path). Existing stores migrate in place (one ALTER TABLE ADD COLUMN). Breaking: older clients reject the new command, outcome, event tag, and summary field; version negotiation refuses a 27/28 pair, as for every prior bump.

Refs ENG-862

…ff switch (DA6)

An operator could not see who settled a held call or stop delegating for
one session without editing config and restarting. This is the last
delegated-approval slice; it closes the plan.

Protocol 27 -> 28:
- `ApprovalDelegate` and `DelegateIdentity` move to qq-protocol as the one
  source (`by_mode|on|off`, `reviewer|jev`); qq-core re-exports them.
- `tool_approval_resolved` gains optional `delegate` beside
  `approved_by_reviewer` / `denied_by_reviewer`, so a supervisor can tell
  Jev's decision from the reviewer model's from the stream alone.
- New advisory `tool_approval_escalated { tool_call_id, delegate?, reason }`
  when a delegate passes: an escalate, an advisory deny under `ask`, or the
  delegate clock running out (no identity). Written only while the call is
  still awaiting approval.
- New `set_approval_delegate { session_id, delegate? }` on
  `/v1/sessions/approval-delegate` with `approval_delegate_set`; optional
  `SessionSummary.approval_delegate` carries the override. `/delegate`
  reserved as a client slash command.
- Goldens under v28/ and headless/v28/; harbor trace fixtures bumped.

Store schema 35 -> 36: nullable `sessions.approval_delegate`. The gate reads
`session override or configured` at each hold, so the switch takes effect at
a running session's next held call with no restart and no config write.
Spawned children inherit the parent's override. No authority check: the mode
stays the ceiling.

TUI: `/delegate` picker (configured, by_mode, on, off; needs a focused
session). Status badge reads `MODE . delegate off` while overridden. The
client keeps who settled each call beside its timing; expanded detail shows
`approved by jev` / `approved for session` / `denied by you`, a delegate
denial's row reads `denied by jev|reviewer`, and the approval block shows
why a delegate passed. Headless text prints `[tool] NAME approved by jev`
and `[tool] reviewer passed to the human: ...`.

Docs: tools.md (session override, wire identity), protocol.md (version 28,
route, command, resolution text), guide/tui.md, guide/permissions.md,
ADR-0041 s6; docs/design/delegated-approval.md deleted as the plan required
(fully absorbed); plan status, ledger, root ledger row for the bump.

BREAKING: PROTOCOL_VERSION 28. Older clients reject the new command, outcome,
event tag, and summary field; version negotiation refuses the pair.

Verification: cargo test --workspace, fmt --check, clippy -D warnings.

Refs ENG-862
@lg2m
lg2m merged commit 30a3923 into main Sep 24, 2026
4 checks passed
@lg2m
lg2m deleted the feat/eng-862-da6-delegate-surfaces branch September 24, 2026 02:32
lg2m added a commit that referenced this pull request Sep 24, 2026
Every slice of docs/plans/delegated-approval.md is on main (#125, #133,
#135, #143, #144, #150, #123, #152). The plan's own acceptance 5 says it is
deleted once shipped and the ledger remains as the receipt; this does that.

- Delete docs/plans/delegated-approval.md. The goal, slice table, and
  acceptance checklist move to the head of the ledger so it stands alone;
  index rows in docs/README.md, docs/plans/README.md, and
  docs/plans/progress/README.md point at the as-built text and the receipt.
- Close acceptance 2's blocked-host half, which only had a test under `full`
  with no delegate: `a_blocked_host_never_reaches_the_delegate_even_when_one_would_approve`
  runs under `auto` with `approval_delegate: on` and a Jev-attributed
  reviewer that would approve, and asserts the link-local fetch is denied
  with no hold, no escalation, no reviewer call, and no delegate host grant.
- Acceptance 3 (one week of real use) stays open until 2026-09-30; the
  ledger records the two queries to run and the entry to write.

Verification: cargo test --workspace, fmt --check, clippy -D warnings.

Refs ENG-862
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.

1 participant