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.
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
Let me start by understanding the repository structure and the issue at hand.
The issue is about WebUI idempotency - making sure that duplicate browser submits do not create duplicate turns/messages. This involves:
- Using client action id / idempotency key for create-thread and send-message
- Preserving accepted-message ref/outcome for duplicate requests
- Handling concurrent duplicate submissions safely
Let me first explore the repository structure to understand what we're dealing with.
Assistant
This is a Rust project. Let me explore the structure to understand the codebase, particularly around WebUI, threads, and messages.
Assistant
Let me run the commands one at a time.
Assistant
Found relevant files. Let me explore the WebUI inbound files and search for existing idempotency patterns
Assistant
Now let me explore the test file and the
IdempotencyKeytype from `ironclaw_turnsAssistant
Let me investigate the
IdempotencyKeytype and the turns framework more deeplyAssistant
Let me look at the key files in the turns crate to understand the IdempotencyKey type and how it works.
Assistant
Let's look at the ids.rs file for the IdempotencyKey definition.
Assistant
Now let me look at the store and coordinator to understand how idempotency is handled.
Assistant
Let me look at the coordinator and admission module.
Assistant
Let me look at the admission module, request/response types, and the lib.rs.
Assistant
Let me run one at a time.
Assistant
Now let me look at the request and response files.
Assistant
Now let me look at the response types and the lib.rs to understand the exports.
Assistant
Now let me look at the lib.rs to understand the module structure and exports
Assistant
Let me look at the product workflow crate structure to understand the WebUI inbound facade.
Assistant
Let me look at these key files to understand the full picture
Assistant
Let me look at the core files for understanding the idempotency flow.
Assistant
Now let me look at the action.rs and inbound_turn.rs files
Assistant
Now let me look at the inbound turn service and workflow.
Assistant
Now let me look at the workflow.rs to understand how create_thread and send_message are handled
Assistant
Let me search for where WebUiInboundCommand is used and find the WebUI route
Assistant
Let me look at reborn_services.rs to see how WebUI commands are processed
Assistant
Let me see the full reborn_services.rs (it was truncated). Let me get the complete file
Assistant
Let me see the full file in sections
Assistant
Let me continue looking at the rest of the file and the types module
Assistant
Now let me look at the types module
Assistant
Let me look at how
replay_accepted_inbound_messageworks in the thread serviceAssistant
Let me look at the conversation service's inbound.rs and the reborn_services_
Assistant
Let me look at the contract tests for reborn_services:
Assistant
Let me search for existing tests related to idempotency and con
Assistant
Let me look at the existing product_workflow_contract and inbound_turn_contract
Assistant
Let me look at the inbound_turn_contract tests
Assistant
Let me look at the thread service implementation for accept and
Assistant
Let me check how the DB implementations handle accept_inbound_message idempot
Assistant
Let me check the DB implementation of accept_inbound_message.
Assistant
Let me see the full reborn_services_contract test file to understand what tests exist.
Assistant
Now let me look at the rest of the test file to see all the tests.
Assistant
Let me see the beginning section of the test file
Assistant
Let me look at the TurnStateStore DB implementation for submit_turn idempotency
Assistant
Let me look at the in-memory store implementation for submit_turn and
Assistant
Let me look at the submit_turn implementation in memory.rs
Assistant
Let me search for TODO/FIXME comments related to idempotency
Assistant
Let me look at the fakes and error files
Assistant
Let me look at the SessionThreadService trait interface
Assistant
Let me look at the thread model/types
Assistant
Let me look at the contract.rs to understand the types
Assistant
Let me first try to build the project and run the relevant tests to understand the current
Assistant
Let me check the Rust toolchain situation
Assistant
Let me check for toolchain configuration
Assistant
No Rust toolchain is installed. Let me try installing one.
Assistant
Good, Rust is installed. Now let me try to build and run existing tests.
Assistant
All existing tests pass. Now let me also run the webui_inbound_contract tests and other relevant tests.
Assistant
All tests pass. Now let me run the other relevant tests.
Assistant
Now I have a thorough understanding. Let me implement the changes step by step.
First, let me look at the full
reborn_services.rsto understand the complete submit_turn flow and identify exactly where changesAssistant
Now I have a clear plan. Let me implement the changes step by step.
Step 1: Modify
webui_source_binding_idto be thread-agnAssistant
Let me use the open command properly.
Assistant
Let me find the
webui_source_binding_idfunction.Assistant
Let me look at the function definition around line 609.
Assistant
Let me use the goto command properly.
Assistant
Now let me implement the changes. First, let me modify
webui_source_binding_idto be thread-agnostic and modify the submit_turn flow to detect cross-thread duplicatesAssistant
Now let me modify the submit_turn method to handle cross-thread duplicates from replays. Let me look at the replay handling section:
Assistant
Now let me modify the replay handling to add cross-thread duplicate detection:
Assistant
Now let me make
mark_message_submittedidempotent in the in-memory thread service.Assistant
Let me find the
mark_message_submittedfunctionAssistant
Let me look at the current
mark_message_submittedfunctionAssistant
Let me make
mark_message_submittedidempotent:Assistant
Now let me do the same for the DB implementation. Let me find the
mark_message_submittedfunction in db.rs:Assistant
Let me look at the DB's
mark_message_submittedfunction:Assistant
Let me goto line 665 in the db.rs to find the mark_message_submitted implementation
Assistant
Let me make
mark_message_submittedidempotent in the DB versionAssistant
Let me also make
mark_message_deferred_busyidempotent for the same concurrent safety reasons. Let me update the in-mAssistant
I made a mistake - I edited db.rs instead of in_memory.rs. Let me fix this. Let me first check the state:
Assistant
Let me fix the broken
mark_message_submittedin db.rsAssistant
Now let me also make the DB inner state's
mark_message_deferred_busyidempotent:Assistant
Let me make both DB
mark_message_deferred_busyandin_memory.rs's idempotent. First the DB:Assistant
Now let me update the in_memory.rs's
mark_message_deferred_busyto be idempotentAssistant
Let me find the mark_message_deferred_busy function in in_memory.rs.
Assistant
Now let me make the in_memory.rs's
mark_message_deferred_busyidempotent:Assistant
Now let me build and run the tests to verify everything compiles and existing tests still pass.
Assistant
All tests pass. Let me also run the inbound_turn_contract and thread tests.
Assistant
All existing tests pass. Now let me add the new tests. Let me first open the test file to see where to add tests:
Assistant
Let me find where to add new tests - let me go to the end of the test file:
Assistant
Now let me add the new tests. I'll add them before the
facade_source_avoids_forbidden_runtime_dependenciestest:Assistant
I need to add the
Barrierimport. Let me update the imports:Assistant
Let me look at the retry test more carefully - there's a variable usage issue. Let me fix it:
Assistant
I see issues with the retry test. Let me fix it properly
Assistant
Let me fix the duplicate function signature
Assistant
Let me fix the duplicate attribute properly
Assistant
Now let me build and run the new tests:
Assistant
The compile is taking long. Let me try just a compilation check first.
Assistant
Compilation succeeded. Let me run the tests now.
Assistant
Let me try running just the test binary directly since compilation already passed:
Assistant
Let me try
cargo test --no-runfirst to compile just the tests, then run themAssistant
Now let me run the test binary:
Assistant
The concurrent test is hanging due to
std::sync::Barrierblocking the tokio runtime thread. Let me fix the concurrent test and the facade test:Assistant
The
facade_source_avoids_forbidden_runtime_dependenciestest failure is a pre-existing issue with test binary execution path. Let me now fix the concurrent test that's hanging:Assistant
Let me fix the concurrent test to use a multi-threaded runtime:
Assistant
Now let me compile and run just the concurrent test:
Assistant
Now let me run the concurrent test specifically:
Assistant
The fake coordinator doesn't implement idempotency, which is why both submissions are counted. Let me fix the test to properly check for at most one message in the thread service:
Assistant
Let me simplify the concurrent test. I'm overcomplicating it. Let me use the existing helper functions and clean up the test:
Assistant
Let me compile and run the tests:
Assistant
Let me fix the unused variable warning by removing the
turn_scopeline:Assistant
I see there's a duplicate. Let me fix this:
Assistant
Let me compile and run the tests:
Assistant
Now let me run the concurrent test:
Assistant
All three new tests pass. Let me run all the tests (excluding the facade one which fails due to path issues):
Assistant
All tests pass. Let me now run the full test suite for the product_workflow crate:
Assistant
Let me run all the product_workflow tests:
Assistant
All product_workflow tests pass. Let me also verify the thread crate tests still pass:
Assistant
Let me run the session thread tests:
Assistant
All tests pass. Let me also run the turns crate tests to make sure the idempotency changes in the store don't break anything:
Assistant
Let me run the key turn tests:
Assistant
All tests pass. Let me do a final review of all changes:
Assistant
Let me see the detailed diff:
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
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-lunaCompare side by side →
- gpt-5.6-lunaCompare side by side →
- gpt-5.6-lunaCompare side by side →