Repository navigation
docs(plan): Mecatl Studio chat acceptance plan - #1755
Conversation
5470a89 to
82dad4f
Compare
Review finding addressed: unbounded activity replayConfirmed and fixed. The first draft of this contract had The published SDK made the bound free: Contract now (this PR):
New acceptance criteria AC2.7, AC2.8, and AC2.9 name the proofs. The two settings are declared in the CLI/config row, the rationale is recorded under Human decisions, and the risks section notes that 2000 is a starting value rather than a measured one. Implementation is in the layer above (#1756), with six unit proofs: bounded replay with the truncation cursor, exact resume without duplication, the durable-gap stop, live events staying unbounded, header-versus-query precedence with Acceptance test against a real daemon is in #1767: a tiny replay bound truncates after exactly its quota and names the last cursor, resuming from it returns only events not already delivered, walking the cursors to the run's terminal result never duplicates one and never exceeds the bound in a single request, and an unusable cursor is refused. One implementation note worth flagging for review: the resume query parameter is Agreed on the SDK surface: no primary blocker there. The only risk was this contract baking in the unbounded behaviour, which it no longer does. |
82dad4f to
b1cf30c
Compare
b1cf30c to
d55d550
Compare
d55d550 to
64f8cf2
Compare
64f8cf2 to
300afe3
Compare
300afe3 to
310fc4b
Compare
Bounded plan for the first Studio feature layer: the session inventory and lifecycle routes, the run SSE union (run.started / run.event / run.error, unknown SDK kinds preserved with their raw payload), run controls addressed to the exact durable run, and the chat workspace with its ported behaviour tests as proofs. The BFF contract is taken from the design prototype with one deliberate divergence: activity replay is BOUNDED and RESUMABLE rather than an unconditional replay from the start of durable history. It carries a resume cursor (SSE `id` frames honouring `Last-Event-ID`), bounds a no-cursor replay to STUDIO_ACTIVITY_REPLAY_MAX events, reports `run.truncated` when the history exceeds that bound, and caps concurrent streams per session -- answering a blocking review finding that the unconditional replay let one authenticated browser impose unbounded historical reads on the BFF and the daemon. The bootstrap's stub stream schema is replaced, and the experimental image label is removed when this lands. Tracking: #1736 Signed-off-by: Samuele Verzi <[email protected]>
310fc4b to
62068d1
Compare
Summary
Adds
docs/acceptance/studio-chat.md(Bounded): the first feature contract — the/api/v1/sessions…session inventory and lifecycle routes, the run SSE union (run.started/run.event/run.error, unknown SDK kinds preserved with their raw payload), run controls addressed to the exact durable run, and the chat workspace with its behaviour tests as proofs.Review focus
studio.chat.*browser storage keys.Checker:
check-acceptance-plan.shpasses;task docspasses. Stacked delivery: nothing in this series merges until the whole stack is reviewed; the plan's approval-by-merge event is deferred to the end, as its Delivery line records.Amended after review
A review finding against the first draft of this contract:
GET /sessions/{id}/activityspecified an unconditional replay of a session's whole durable history, with no cursor, window, or cap. An authenticated browser could reattach to a long-lived chat repeatedly and make the backend for frontend and the daemon do unbounded historical reads and stream that history back each time. The published SDK'sAttachOptions.fromalready accepts"now","start", or a cursor, and every envelope carries an opaque string cursor, so the bound costs no capability.The contract now says:
run.eventframe carries its durable cursor in the SSEidfield; a request resumes exactly afterLast-Event-ID(or theresumeFromquery parameter, the header winning).STUDIO_ACTIVITY_REPLAY_MAXdurable replay events (default 2000) and reads no further, then ends withrun.truncated {reason: "bound", cursor}pointing the client at the authoritative transcript. Live events stay unbounded so a long turn still streams in full.run.truncated {reason: "gap"}rather than streaming across the hole; an unusable cursor is400 invalid_cursor.STUDIO_ACTIVITY_MAX_STREAMSconcurrent activity streams per replica (default 4), beyond which the route answers429 too_many_streamswithRetry-After.Three new acceptance criteria (AC2.7, AC2.8, AC2.9) name proofs for bounded replay, exact resume without duplication, the gap case, the invalid cursor, and the stream cap. The two new settings are declared in the CLI/config row. The decision and its rationale are recorded under Human decisions;
Deferred decisions and known risksrecords that the 2000 default is a starting value, not a measured one.Contract amendments
startornowcursor, or one over 1,024 characters, is refused with400 invalid_cursor. A daemonactivity_gaperror ends the stream as a gap does.run.errormessages are clamped and redacted like problem details. Base64 attachments are validated in one linear pass.boundtruncation it reattaches from the cursor (up to 50 times) instead of failing the run.run.truncatedand reads no further envelope (AC2.7). A resumed stream starts with the next durable event, with no leadingrun.started, while a later run still gets one (AC2.8). A request that saw no run closes at the live boundary unless the session is running, awaiting, or authorizing (AC2.5).413 request_too_large(AC2.11).'self'for images (AC4.3).run.startedkeeps the active message (AC4.10). The chat list and the preview keep separate widths (AC4.11).Development stage
Contract linkage
/api/v1/sessions…and the run SSE union) inside the boundary ADR 0351 fixed; no new durable architecture decisiongh stack) delivery for the whole Studio series: nothing merges until every layer is reviewed, so the plan's approval-by-merge event is deferred to the end (recorded in each plan's Delivery line), and each implementation layer records the exact plan commit it built against.docs/acceptance/studio-chat.mdInterface conformance
/api/v1/sessions…routes; therun.started/run.event/run.truncated/run.errorSSE union with unknown SDK kinds preserved;409 stale_run_controlon controls for ended runs;studio.chat.*browser storage keys. No gRPC, Go, CLI, or tool-schema change.Issue relationship
Relates to #1747 (parent #1736; stack #1766). Non-closing: the step completes when both of its layers merge.
Type of change
Test plan
Baseline checks
task lint)task test)go run ./cmd/mecademo)task docs)Plan layer: the acceptance-plan checker and
task docspass. The Studio gates (task studio:check,task ac-trace) run on the implementation layer above, since this layer adds noapps/code.User-facing change
None — a plan document and, for the bootstrap, ADR 0351.
Special notes for reviewers
Part of a fourteen-layer stack; review bottom-up. Nothing merges until the whole series is reviewed.