Repository navigation
feat(studio): add exact plan control and authorization review prerequisite - #1909
Conversation
2dfa798 to
3a233a3
Compare
Implementation review: #1909CI is green. The identity checks are solid:
Needs changes
Minor
Scope note: the PR delivers the daemon and SDK half plus Scenario 3. The plan card, inline ordinary-ask card, Escape layering and steer trace (AC1.x, 2.1, 2.3, 4.x, 5.x) are still to come. That matches the "prerequisite" title and the rollout order, and nothing overclaims. |
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]>
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]>
7c9f61b to
0007e78
Compare
peppescg
left a comment
There was a problem hiding this comment.
Re-reviewed head b99ad336. Most of my earlier findings are fixed:
- Reservation leak:
removeRunStatenow releases the reservation exactly once, andstartRunContentLockedrefuses a competing entry underpersistMu. - Double continuation: there is a run-start opt-in on gRPC and HTTP. A non-opted live ask is refused without being consumed, and an in-stream plan frame on an opted-in run is refused.
- Failed continuation start:
plan.continuation_failedis appended and published, content-safe, and lease-gated. Without an event log the feature is not advertised. - Proceed-run start: it now runs in a goroutine.
- Studio side: the uncertain-state key, the
destination.hrefredirect and the README status are all fixed.
Also verified:
- Lock order, lease and owner checks are correct.
- Guardrail reconciliation is correct.
- Proto field numbers don't collide, and
task generateleaves no diff. api:checkand the CHANGELOG are correct.- The ADR 0027 inventory rows are present.
- The tests run under
-raceover real gRPC and HTTP relays.
Blocking
RetryFailedRundestroys an accepted plan continuation. Ininternal/adapter/server/service.go(RetryFailedRun), a registered run whose snapshot is terminal isderegistered. This happens before the eligibility check and without the reservation guard thatstartRunContentLockednow has.- Scenario:
- An opted-in plan run reaches
StopPlanApproved. - Before its relay calls
finishRelayRun, a caller invokesRetryFailedRun(for example, a retry click). removeRunStaterecordsplan.continuation_failed, attributed to the retry caller, and releases the reservation.- The retry returns "not eligible".
- The relay then finds no reservation, so the approved proceed run never starts.
- An opted-in plan run reaches
- Reproduction: copy the "priority over a competing prompt" subtest and swap
StartRunContentforRetryFailedRun. The event log then showsresult, plan.continuation_failed, andwaitExactPlanProceedfails. - Why it matters: this violates ADR 0366 Decision 3.
- Scope: the other
deregistercallers (approvePlan,autoApproveContinuation, and the two inmcp_authorization.go) only remove runs they started themselves, so this is the only gap. - Fix: apply the same reservation guard, ideally through one helper shared with
startRunContentLocked, and add a regression test.
- Scenario:
Minor
- The start-failure WARN drops the cause.
exact_plan_ask.go:283doesn't logerrfromstartRunContentLocked, so operators can't see why the proceed run failed. The event must stay content-safe; the diagnostic doesn't have to. Also consider downgrading it, since the event already owns the fact. - "Refresh activity" can silently do nothing.
refreshAuthorizationActivityonly bumpsreconnectGeneration, and the watch effect returns early when!watchable. Scenario: a Cancel commits on the daemon but its response is lost, and the session goes idle. The card then stays "Pending" with both actions disabled until reload. With nobeforeCursor, the refresh replays without the reconciliation callback, so a still-pending handoff can't clear either. Either disable the button when a refresh can't run, or report "no newer activity". - A resumed refresh can duplicate transcript content. The current messages are kept, and events after
beforeCursorare replayed with a fresh deduplicator. If the control stream had already rendered part of the continuation run, its tool rows or text appear twice. No test covers a continuation that had rendered output before the failure. - Hardening: the presentation route has no same-origin check. The GET under
/api/v1/.../presentationisn't covered by the same-origin check that guards mutations. A cross-site top-level link, where the Lax cookie is sent, still gets a 302 to a fresh authorization page. The only legitimate caller is the same-origin<a target=_blank>, so requiringSec-Fetch-Site: same-originis cheap. - Minor: the relay defer still takes
runEntryMusynchronously. It runscompleteRelayunder that lock (exact_plan_ask.go:250-264), so the old stream's close can wait behind another holder of that session's entry lock.
Nit
PlanContinuationFailureEventPayload.planRunIdandaskIdshow as "(undocumented)" in the threeetc/*.api.mdreports.
b99ad33 to
977e291
Compare
Co-Authored-By: OpenAI Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Co-Authored-By: OpenAI Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Present authorization status on the originating tool call, redirect through a fresh BFF presentation URL, and stream exact recheck or cancel flows with their continuation events. Co-Authored-By: Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Bind plan verdicts to the authorized run and pending ask, preserve plan provenance, and start one server-owned proceed run after an accepted plan terminal. Publish strict gRPC and HTTP controls and durable tool-call correlation in the generated contracts. Co-Authored-By: Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Add feature-gated plan verdict control with run and ask echo checks across gRPC and HTTP. Project optional permission ask call IDs and update the public SDK reports and method reference. Co-Authored-By: Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Co-Authored-By: OpenAI Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
…rols Co-Authored-By: Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Co-Authored-By: OpenAI Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Read the live run state under the service lock in both exact plan ask paths, preserving the existing exact run and ask rechecks. Co-Authored-By: OpenAI Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Key uncertainty to its handoff, refresh from the last observed durable cursor, and preserve separate runless authorization statuses. Redirect using the validated presentation URL and document the recovery action. Co-Authored-By: Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Require a streamed authorization status to match the pending review card’s call before confirming a control. A mismatched status now leaves the outcome uncertain and blocks duplicate controls until activity is reconciled. Co-Authored-By: Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Co-Authored-By: Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Signed-off-by: Samuele Verzi <[email protected]> Co-Authored-By: Codex <[email protected]>
Co-Authored-By: Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Co-Authored-By: Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Consolidate run stream handling for chat and authorization routes. Co-Authored-By: OpenAI Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Co-Authored-By: OpenAI Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Co-Authored-By: OpenAI Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Co-Authored-By: OpenAI Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Share the terminal run admission guard across prompts and failed-step retries so a completed plan run cannot be removed while its exact allow has reserved a proceed run. Cover the blocked terminal relay and record a content-safe start failure code in diagnostics. Co-Authored-By: OpenAI Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Co-Authored-By: OpenAI Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Signed-off-by: Samuele Verzi <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]>
Signed-off-by: Samuele Verzi <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]>
Signed-off-by: Samuele Verzi <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]>
Signed-off-by: Samuele Verzi <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]>
Signed-off-by: Samuele Verzi <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]>
Keep parent approval correlation metadata safe across child and parent call ID collisions. Flush accepted verdicts before parent terminal events, including cancelled and abandoned children, and mirror sequenced events to the injected sink. Signed-off-by: Samuele Verzi <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]>
b51a407 to
610c56a
Compare
Keep stale routes retractable, requeue aborted approval emits, and emit final child verdicts outside the registry lock. Return stale compatibility approval errors and mirror sequenced child events to the sink. Signed-off-by: Samuele Verzi <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]>
Mirror accepted child approvals before releasing the child emission gate, then allow the terminal result to follow. Pin concurrent close order and child abort behavior. Signed-off-by: Samuele Verzi <[email protected]> Co-Authored-By: Codex <[email protected]>
Wait for the parent terminal to remain blocked while the accepted approval sink callback is parked. This makes the prior mirror-after-unlock ordering fail reliably. Signed-off-by: Samuele Verzi <[email protected]> Co-Authored-By: Codex <[email protected]>
Exercise routeResolution directly in child router tests and retain accepted, duplicate, and stale verdict assertions. Signed-off-by: Samuele Verzi <[email protected]> Co-Authored-By: Codex <[email protected]>
|
Addressed the requested changes on the rebased #1909 head
The relay defer still waits synchronously for This is still the partial daemon/SDK and authorization slice described in the PR, with the remaining Studio approval and review controls awaiting a published SDK release. The PR remains open for human review; it is not a completed #1848 implementation. CI on |
peppescg
left a comment
There was a problem hiding this comment.
Approving. The RetryFailedRun blocker is fixed. The remaining points are minor, so they can be addressed in a follow-up PR if needed.
Record that #1909 supplied authorization prerequisites while #1848 layered Escape browser work is still pending. Keep the #1850 acceptance contract proposed and its frame ownership unchanged. Co-Authored-By: OpenAI Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
…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) ...
Tracking: #1848
Stage and approved contract
Implementation, release prerequisite. This PR targets
mainand is based on the merged Plan / Interface PR #1888, merge commit98dfad2e1bed66809f68b104c4f207df2d2b1dda. The plan is in progress on this branch. The directing human previously waived the plan-merge gate while #1888 was open and authorized the direct call-ID, server-owned continuation, lease-loss, ADR-number, and protobuf-field amendments; those amendments are included in the merged plan and ADR 0366.Included
ResolvePlanAskgRPC and HTTP controls bind a verdict to the authorized session, expected run, pending root plan ask, and explicit verdict. Stale, duplicate, ordinary, and child asks cannot approve a successor. OptionalPermissionAsk.call_id = 6projects the durable call ID for presentation correlation only, never verdict authority.Prompt.server_owned_plan_continuation = 4, its HTTP mirror, and the SDK run option. Unopted live asks reject strict verdicts without consuming them; opted-in live asks reject in-stream plan approval. Existing mecatui and SDKquery()keep client-owned continuation.plan.continuation_failedevent (Event.plan_continuation_failure = 26) while the daemon holds the lease. After lease loss the former owner emits no failure and the outcome remains uncertain. The original plan run retains one terminal result. Without an event log, the strict feature and opted-in starts are unavailable.Acceptance status and dependency
AC2.2, AC3.1, and AC3.2 are complete in this slice. AC1.1's call-ID projection and AC2.3's SDK control and run-start option are enabling work; their browser interactions remain pending. Ordinary inline approvals, plan-review submission and continuation UI, layered Escape, shortcut hints, steer trace, and the #1776 offline browser journey remain in five pending #1848 tasks. This PR does not close #1848 or mark the plan
landed.Studio consumes npm-published SDK packages under ADR 0351. The published
@stacklok-oss/[email protected]lacks these new controls and projection. The remaining Studio browser controls therefore wait for a reviewed SDK release frommain; no local SDK path or session-only verdict fallback is used.Interfaces match the merged approved contract: Yes for this implemented slice. The merged #1888 plan includes every human-authorized amendment. The review repairs add no contract deviation. Human merge and SDK publication remain separate steps.
Review and verification
The review's blocking retry race was reproduced and fixed:
RetryFailedRunnow shares the reservation guard used by prompt entry. Focused tests prove one proceed run and no false failure event. Other repairs add a classified, content-safe failure diagnostic; make Refresh activity work for idle sessions; checkpoint the exact authorization handoff before a cursorless control; preserve stream deduplication across replay; restrict the presentation GET to same-origin browser navigation; and document SDK event fields. The activity cursor now belongs to the exact session, run, authorization, and call, so replay of an older pending event cannot clear uncertainty. DurableEvApproval.Actornow uses the accepted exact verdict caller for plan, ordinary, and scoped asks, while in-stream approvals retain the run caller and an unverified control caller remains absent. Accepted surfaced child verdicts now produce one safe approval on the parent run before its terminal result; aborted sends requeue for the terminal sweep, and the configured event sink observes the same approval-before-result order. Child arguments stay out of that record and an empty call ID prevents parent permission rule replay from a colliding child ID. The SDK high-level surface inventory includesresolvePlanAskafter #1917 merged. The relay can still wait behind another holder of the session entry lock before the old stream closes; moving that lock acquisition is deferred because it affects terminal persistence and gRPC handoff ordering.Focused server package and race tests, engine child-approval race tests, Studio mounted tests (43/43 on the combined cursor repair), presentation route tests, SDK exact-plan and high-level surface tests (11/11), SDK generated-reference checks, acceptance-plan validation,
CGO_ENABLED=0 task docs, site build, and diff checks passed during the review repairs. The local macOS default CGO linker is broken; focused Go race tests passed with the installed macOS SDK. Follow-up Domain, Test adequacy, and Security rechecks found no unresolved blocker in the reviewed slice.The earlier
b99ad336dhead passed all 33 applicable GitHub Actions checks. The next head exposed a test-only router wrapper to the pinned engine linter; it was removed and the tests now call the production resolution path. PR CI on the rebased7e7e5f7f0head passed: 34 checks successful, four optional/live checks skipped, zero failures or pending checks. This includes Analysis, Lint, root and engine race suites, Studio, SDK codegen and offline e2e, kind, performance, docs, and build.