Untitled conversation
- User
[Reborn WebUI Beta] Add WebUI idempotency and accepted-message ledger Parent tracker: #3607 Module: M2 — Native Product Workflow / Inbound Facade Priority: P0
Goal
Make WebUI mutations idempotent so duplicate browser submits do not create duplicate turns/messages.
Scope
- Use client action id / idempotency key for create-thread and send-message.
- Preserve accepted-message ref/outcome for duplicate requests.
- Handle concurrent duplicate submissions safely.
Acceptance criteria
- Duplicate send returns the same accepted ref/outcome.
- Concurrent duplicate send creates at most one accepted message/turn.
- Failed validation does not create a ghost turn/message.
- Retry after transient unavailable state has deterministic behavior.
- Tests cover same-thread duplicate, cross-thread duplicate rejection, and concurrent duplicate behavior.
Interface
No new interfaces are introduced.
- Assistant
I’ll trace the WebUI mutation handlers and persistence contracts first, then implement the ledger at the narrowest correct layer and test through the actual callers.
- Assistant
rgisn’t installed in this checkout, so I’m switching to targetedfind/grepinspection. I’m focusing on the web subsystem spec plus its mutation routes and DB boundary. - Assistant
The relevant implementation is the Reborn product-workflow facade, not the legacy Axum chat route. It already has canonical client-action DTOs and a create-thread replay path; I’m now reviewing that subsystem’s contracts so the send ledger composes with the existing accepted-message store instead of duplicating it in gateway state.
- Assistant
I found the concrete race: replay lookup and acceptance are individually durable, but the facade can run two “not found → accept → submit” paths concurrently. The idempotency scope also included
thread_id, which allowed the same browser action to be accepted in two threads. I’m fixing both: a stable caller/action scope, atomic cross-thread collision detection in the thread ledger, and per-action in-flight serialization at the facade. - Assistant
The core patch is in place. Validation now happens before any ledger/thread mutation; duplicate requests are serialized only against the same caller/action, and replayed submitted requests reconstruct the original
submittedresponse rather than changing it toalready_submitted. The focused crate tests are compiling now. - Assistant
The first test run exposed a test-double detail: its
get_run_statefabricates a fresh turn ID/cursor on every read, so byte-for-byte response equality is not a valid replay assertion there. The production contract we need is stable outcome kind, accepted-message ref, and run identity. I’m tightening the tests to those guarantees and adding the transient-unavailable retry/ghost-message case explicitly. - Assistant
The thread-service suite confirms its generic contract intentionally scopes identical external-event IDs by full thread scope (needed by non-WebUI adapters). I’m preserving that invariant and keeping the stricter cross-thread action rule inside the WebUI facade, where it belongs. Same-thread concurrent dedupe remains atomic through the ledger plus facade lock.
- Assistant
All targeted tests and lint checks are green, including the generic thread-service contract and Reborn architecture boundary test. I’m doing the final diff audit now for scope, docs/parity impact, and accidental churn.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.