ISSUE DESCRIPTION [Reborn WebUI Beta] Add WebUI idempotency and accepted-message ledger…
- User
ISSUE DESCRIPTION
[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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
- Assistant
I’ll inspect the repository structure and existing WebUI mutation handlers/tests, then trace thread/message persistence and concurrency boundaries. I’ll implement idempotency at the narrowest shared facade layer, add no tests to the repository per instructions, and run the relevant existing test suite plus temporary checks if needed.
- Assistant
The existing message store atomically deduplicates accepted messages, but the facade has a check-then-act gap: concurrent requests can both pass the replay lookup and both invoke turn submission. Replay lookup also searches by action identity without checking the requested thread, allowing a cross-thread reuse to proceed too far. Create-thread’s generated IDs are deterministic, but explicit requested IDs have no action ledger. I’ll add shared per-facade mutation serialization, enforce replay scope/thread matching, and retain create-thread action-to-thread mappings so conflicting duplicate creates are rejected rather than creating a second thread.
- Assistant
The focused facade contract tests now pass. One remaining edge is important: the current source-binding identifier includes the thread ID, so a cross-thread retry would not even be discoverable as a replay and could create a second message. I’ll make the WebUI action binding independent of thread (the authenticated caller and action key already provide scope), allowing the explicit scope check to reject that retry deterministically.
- Assistant
Implemented WebUI idempotency protections in
ironclaw_product_workflow:- Added shared mutation serialization for send-message requests to close concurrent check-then-act races.
- Added cross-thread replay validation and rejection.
- Made WebUI source binding independent of thread so cross-thread duplicate actions are discoverable and rejected.
- Added create-thread action tracking scoped to authenticated caller.
- Conflicting explicit thread IDs for the same client action now return a conflict.
- Preserved deterministic replay for duplicate create-thread and send-message requests.
- Added
tokiosynchronization dependency. - Ran formatting and the focused contract suite: 17 tests passed.
git diff --checkpasses.
Checklist:
- Reproduced the reported behavior by inspecting the existing replay/accept/submit flow and identifying the concurrent check-then-act gap.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.