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.
Interface
No new interfaces are introduced.
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.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /ironclaw, current file: none) bash-$
Assistant
This is the "Inbound Facade" module. Let's inspect it.
Assistant
This is exactly the module. Now let's look for the WebUI native product workflow adapters that call into this facade.
Assistant
Found it:
webui_inbound.rsandwebui_inbound_contract.rs. Let's examine these.Assistant
Now let's build the relevant crates.
Assistant
Good, everything builds. Let's run the tests for these crates to see current state.
Assistant
Let's write a temp test to check the cross-thread duplicate behavior currently.
Assistant
Now let's implement the fix. First, add the new helper function near
webui_source_binding_id.Assistant
Now let's update
submit_turnto use the new idempotency key and add the cross-thread mismatch rejection.Assistant
The fix works. Now let's run the full existing test suite to make sure nothing broke.
Assistant
Now let's double check the full diff and re-run the complete test suite once more (without the temp test file) to confirm everything is clean.
Assistant
Good, the temp test file was removed and isn't tracked. Let's view the full diff.
Assistant
Good,
DefaultTurnCoordinator::new(Arc<InMemoryTurnStateStore>)withAllowAllTurnAdmissionPolicy. Let's write a temp concurrency test.Assistant
Builds fine. Let's also run tests for that crate and the wider workspace-relevant tests quickly.
Assistant
All good. Now let's run clippy on the modified crate to ensure no lint issues since the repo likely enforces clippy in CI.
Assistant
No clippy warnings. Now let's do a final review of the diff and clean up state.
Assistant
Let's do a final full run of the workspace tests relevant to WebUI/product-workflow to be thorough.
Assistant
Clean. No leftover temp files. Let's view the final diff once more for a sanity check.
Assistant
This looks complete and correct. Let me go through the checklist now.
Assistant
All tests pass. Let me finalize and review the checklist thoroughly.
Checklist review:
-
If an error was reported in the issue description, I have successfully reproduced it. ✅ The issue didn't include an explicit stack trace/error, but it described acceptance criteria including "cross-thread duplicate rejection" and "concurrent duplicate behavior". I investigated the
ironclaw_conversations/ironclaw_product_workflow/ironclaw_threadscrates (the Inbound Facade / WebUI idempotency implementation for M2), and via a temporary reproduction test confirmed a genuine gap: the WebUIRebornServices::submit_turncomputed its idempotency-ledger key (source_binding_id) including thethread_id, so reusing the sameclient_action_idfor a differentthread_idsilently created a second independent accepted message and a second turn instead of being rejected as a duplicate — violating the "cross-thread duplicate rejection" acceptance criterion. -
If an error was reported in the issue description, I have confirmed that my fix resolves the error. ✅ After introducing an actor-scoped (thread-independent)
webui_idempotency_binding_idused as the ledger key, plus an explicitreplay.thread_id != scope.thread_idcheck that rejects the request with aConflictbefore any duplicate work happens, my reproduction test passed (previously failed). I also re-verified same-thread duplicate-replay behavior and concurrent-duplicate behavior (via a separate temporary test using the realDefaultTurnCoordinator+InMemoryTurnStateStore) both already produce exactly one accepted message/turn, satisfying those acceptance criteria too. Both temporary test files were removed afterward per instructions not to add new tests. -
I have thought about edge cases and made sure my fix handles them as well. ✅ Considered: same-thread duplicate replay (still works, existing test passes), concurrent duplicates on the same thread (verified via temp test — the
ironclaw_threadsmutex-guarded ledger +ironclaw_turnsDefaultTurnCoordinator's own idempotency-key in-flight/settled cache jointly guarantee at most one turn), failed validation (validation happens before any thread/message mutation, so no ghost turns/messages are created on invalid input), and retry after transientThreadBusy/Unavailable(neither is cached permanently by the turn coordinator's idempotency ledger, so retries deterministically re-attempt rather than replaying a stale transient failure forever). I kept the thread-scoped binding id intact forreply_target_binding_id/SourceBindingRef/ReplyTargetBindingRefso per-thread reply routing semantics are unaffected — only the duplicate-detection key changed. -
I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. ✅ Ran full test suites for
ironclaw_product_workflow,ironclaw_threads,ironclaw_conversations,ironclaw_turns, andironclaw_reborn_composition(the downstream composition crate that wiresRebornServicesinto the runtime) — all passed. Also rancargo clippy -p ironclaw_product_workflow --all-targetswith no warnings.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →