Skip to content

docs(plan): define Studio chat approvals and exact plan control - #1888

Merged
samuv merged 6 commits into
mainfrom
plan/studio-chat-approvals-review-escape
Sep 25, 2026
Merged

samuv merged 6 commits into
mainfrom
plan/studio-chat-approvals-review-escape

Conversation

@samuv

@samuv samuv commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Tracking: #1848

Summary

This independent Plan / Interface PR defines the Architectural, Split contract for Studio's inline tool approvals, plan review, external authorization panels, and layered Escape behavior. It adds the acceptance plan and ADR 0366, and updates ADR 0347's supersession note. This PR contains no implementation.

The plan consumes #1847's transcript and composer interface, now merged through #1880 and #1886: run deliveries, transcript anchors, preview callback, and exact active-run target. #1847 owns the base transcript and composer; #1848 owns approval and review interactions within them. #1850 owns the shared side-panel frame. #1776 owns the offline Playwright harness for the browser approval journey.

Architectural decision

A session-only Session.resolvePlan(verdict) can select a newer parked ask after a browser card goes stale. ADR 0366 adds ResolvePlanAsk with the authorized session ID, expected durable run ID, exact ask ID, and explicit verdict. The daemon validates all three identities and plan origin before consuming the ask. Duplicate, stale, ordinary, and retracted asks cannot fall forward to a successor.

The review identified a second risk: mecatui and SDK query() already send their own proceed prompt after a live plan_approved result. A normal prompt therefore defaults to client-owned continuation. Studio opts into server-owned continuation at run start through Prompt.server_owned_plan_continuation = 4, its HTTP mirror, and the published SDK run option. An exact live plan verdict is refused on a run without that opt-in; an in-stream plan verdict is refused on an opted-in run. Restored awaiting asks have no live stream owner and use the server-owned exact control. The reserved proceed run takes priority over a competing prompt or scheduler start, and its reservation is released on every path.

If an accepted server-owned approval reaches StopPlanApproved but the proceed run cannot start while the daemon still holds the session lease, activity records and publishes one safe, session-scoped plan.continuation_failed event (Event.plan_continuation_failure = 26) correlated to the approved plan run and ask. It carries no raw error or content and does not invent a second terminal result. If the process or session lease is lost before the event can be recorded, the former owner publishes no failure and the outcome remains uncertain. The daemon feature exact_plan_ask_control is advertised only when the strict control, run-start opt-in, and failure projection work on both transports. Studio uses the npm-published SDK and never falls back to session-only approval.

Interaction contract

  • Inline tool asks show event arguments and bounded Edit/Write diffs, with raw arguments reachable. Optional PermissionAsk.call_id = 6 and SDK callId attach an ask to a tool row only on an exact same-run match. Unmatched child and older-server asks use separate cards. This ID affects presentation only. Ordinary Allow once, Always allow, and Deny use the existing exact run-and-ask route.
  • Plan review shows the PresentPlan text and note. Approve & run, Auto-accept edits, and Iterate map to distinct verdicts. Missing plan text disables approval. Studio claims execution only after observing the new run; a known start failure is shown from activity.
  • External MCP authorization uses its separate session/authorization-ID lifecycle. A clicked BFF link redirects to a fresh validated HTTP(S) presentation URL. Recheck and Cancel surface the SDK flow. Escape closes the panel without cancelling authorization.
  • With a focused dialog or menu, the first Escape closes only that overlay. Later presses each consume one action in order: selection, pending ask with explicit deny, side panel, live run, then guarded draft clear after a released second press within 500 ms.
  • The optional developer steer trace uses observed event metadata only and exposes no text, arguments, URLs, headers, or credentials.

Delivery and verification

The directing human waived #1848's plan-merge gate and requested implementation stacked on #1886 above #1880; both parent PRs have since merged, so #1909 now targets main. They separately authorized the optional call-ID projection and, after the #1888/#1909 review, the direct continuation-ownership and failure-event amendment to this still-proposed plan and ADR. Further explicit identifier amendments assign ADR 0366, PermissionAsk.call_id = 6, and Event.plan_continuation_failure = 26 after other in-flight work claimed the earlier numbers. A subsequent explicit review amendment clarifies that lease loss leaves an uncertain handoff; the former owner cannot write or publish an authoritative failure after losing ownership. The implementation remains partial in #1909; the new daemon/SDK surface must land and be published before Studio enables plan verdicts. #1885 is independent delegated-activity planning.

The amended plan retains 13 acceptance criteria across five scenarios. The acceptance-plan checker, git diff --check, and CGO_ENABLED=0 task docs passed, including the strict links and anchors. The CGO-free docs command avoids a local macOS SDK linker fault in an existing Go example test. Runtime, SDK release, Studio, browser, site, and race gates belong to the implementation candidate. user-docs/building/deployment/studio.md owns the eventual public behavior. A human merges this PR; it does not close #1848.

@samuv
samuv force-pushed the plan/studio-chat-approvals-review-escape branch from 9c2dc42 to 870c40b Compare September 24, 2026 16:54
@samuv samuv self-assigned this Sep 24, 2026
samuv added a commit that referenced this pull request Sep 25, 2026
Directing-human-authorized amendment from plan PR #1888 commit 0ed45ac.

Co-Authored-By: Codex <[email protected]>

Signed-off-by: Samuele Verzi <[email protected]>
@peppescg

Copy link
Copy Markdown
Contributor

Plan and ADR review: #1888

A dedicated, identity-bound ResolvePlanAsk is a genuine Architectural decision, and ADR 0362 is the right vehicle for it. The number is free: only this PR and #1909 use 0362.

Needs changes

  1. The double-continuation rule is missing. Under ADR 0069, the client that owns the stream fires the proceed prompt itself after plan_approved. Existing clients do this: mecatui in cmd/mecatui/ui/update.go (submitProceedPrompt) and the SDK query() in sdk/typescript/src/query.ts. ADR 0362 Decision 2 makes the server start "exactly one fresh proceed run" on a live allow. If Studio (or a second tab) resolves a plan ask on a live run owned by one of those clients, both sides try to continue:

    The ADR needs an explicit rule. Options include refusing a live ResolvePlanAsk on runs with a self-continuing owner, or signalling to the owner that continuation is server-owned.

  2. Continuation-start failure must reach the user. Decision 2 says a failure is "reported as failure or uncertainty". Please make it a durable or published terminal, not just an operator log line. That is what the legacy approvePlan does with its synthetic EvResult{StopError}.

Nits

  • Supersession not recorded: ADR 0362 supersedes part of ADR 0347, but 0347's Superseded by: line still says none.
  • Scope: Decision 4's Studio BFF route detail is feature-level and could live in the acceptance plan instead of the ADR.
  • Merge order: feat(studio): add exact plan control and authorization review prerequisite #1909 carries byte-identical copies of the ADR and plan; only the plan's Status line differs. Whichever PR lands second gets a trivial conflict on that line.

samuv added a commit that referenced this pull request Sep 25, 2026
Address the #1888 and #1909 review with a run-start opt-in and a correlated continuation-start failure event.

Co-Authored-By: Codex <[email protected]>

Signed-off-by: Samuele Verzi <[email protected]>
samuv and others added 6 commits September 25, 2026 14:39
Record the directing-human-approved public call ID projection and safe unanchored fallback after AC1.1 contract drift.

Co-Authored-By: Codex <[email protected]>

Signed-off-by: Samuele Verzi <[email protected]>
Address the #1888 and #1909 review with a run-start opt-in and a correlated continuation-start failure event.

Co-Authored-By: Codex <[email protected]>

Signed-off-by: Samuele Verzi <[email protected]>
Keep daemon failed_precondition at HTTP 412 and let Studio map it to the product 409 response.

Co-Authored-By: Codex <[email protected]>

Signed-off-by: Samuele Verzi <[email protected]>
Keep known start failures durable under a held session lease. After ownership loss, the former daemon leaves the outcome uncertain and publishes no unrecorded failure.

Co-Authored-By: Codex <[email protected]>
Signed-off-by: Samuele Verzi <[email protected]>
Use ADR 0366 and allocate PermissionAsk.call_id and Event.plan_continuation_failure after existing protocol fields.

Signed-off-by: Samuele Verzi <[email protected]>
Co-Authored-By: Codex <[email protected]>
@samuv
samuv force-pushed the plan/studio-chat-approvals-review-escape branch from 4025bec to 740e23e Compare September 25, 2026 12:40
samuv added a commit that referenced this pull request Sep 25, 2026
Directing-human-authorized amendment from plan PR #1888 commit 0ed45ac.

Co-Authored-By: Codex <[email protected]>

Signed-off-by: Samuele Verzi <[email protected]>
samuv added a commit that referenced this pull request Sep 25, 2026
Mirror the authorized #1888 review amendment on the implementation stack and align the plan index.

Co-Authored-By: Codex <[email protected]>

Signed-off-by: Samuele Verzi <[email protected]>
samuv added a commit that referenced this pull request Sep 25, 2026
Directing-human-authorized amendment from plan PR #1888 commit 0ed45ac.

Co-Authored-By: Codex <[email protected]>

Signed-off-by: Samuele Verzi <[email protected]>
samuv added a commit that referenced this pull request Sep 25, 2026
Mirror the authorized #1888 review amendment on the implementation stack and align the plan index.

Co-Authored-By: Codex <[email protected]>

Signed-off-by: Samuele Verzi <[email protected]>

@peppescg peppescg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Both design gaps from my earlier review are resolved in ADR 0366:

  • Double continuation: continuation ownership is now an explicit run-start opt-in (server_owned_plan_continuation). mecatui and SDK query() runs stay client-owned, and a second client can't force a competing continuation through the strict control.
  • Failed continuation start: it is now a durable, published, content-safe plan.continuation_failed event, with no append after lease loss.

The rest also checks out:

  • The reservation is released exactly once on every terminal or removal path.
  • ADR 0347's Superseded by: line is updated.
  • 0366 is free on main.
  • ADR 0366 and the ADR README are byte-identical to the copies in #1909. The plan differs only in its Status line, so whichever PR lands second gets a trivial conflict there.

One non-blocking suggestion

Decision 3 and AC2.2 give the reserved continuation priority over "a competing prompt or scheduler start". #1909 shows a third entry path: RetryFailedRun deregisters the terminal plan run without honouring the reservation (see my review there). Please word it as "any run-entry path (prompt, scheduler, failed-step retry)", so the implementation and its proofs are held to the complete set.

@samuv
samuv merged commit 98dfad2 into main Sep 25, 2026
31 checks passed
@samuv
samuv deleted the plan/studio-chat-approvals-review-escape branch September 25, 2026 13:33
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Sep 25, 2026
2 tasks
jbeda added a commit that referenced this pull request Sep 25, 2026
…mit-coauthor-guidance

* origin/main: (32 commits)
  docs: plan optional native Kubernetes execution provider (#1579)
  feat(mecatui): restore session status metrics (#1891)
  docs(plan): bound agent inventory viewport (#1946)
  docs: include user-docs in matlatl and use local documentation links (#1934)
  feat(mecatui): bound sessions inventory (#1944)
  feat(studio): show session delegation activity (#1907)
  docs(plan): define Studio session activity (#1885)
  Release TypeScript SDK v0.4.0 (#1940)
  Release v0.0.41 (#1941)
  docs(mecatui): plan bounded sessions inventory (#1906)
  feat(studio): add exact plan control and authorization review prerequisite (#1909)
  test(app): eliminate real ToolHive probe deadline wait (#1937)
  docs(plan): define Studio chat approvals and exact plan control (#1888)
  test(sdk): enforce SDK/TUI high-level parity (#1471) (#1917)
  docs(plan): propose SDK high-level parity coverage (#1471) (#1916)
  docs: improve gRPC schema table readability (#1842)
  test(app): eliminate real waits in durable learning tests (#1933)
  feat(studio): align chat transcript and composer (#1886)
  docs(plan): define Studio chat transcript and composer (#1880)
  feat: correlate provider requests with the root session (#1883)
  ...
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.

Studio chat: inline approvals, plan review, and Escape behavior

2 participants