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.
- Assistant
Let me start by exploring the repository structure to understand the codebase and find relevant files for this issue about WebUI idempotency and accepted-message ledger.
- Assistant
Let me explore the directory structure more broadly to understand the project structure.
- Assistant
This appears to be a Rust project (Cargo.toml, Cargo.lock). Let me explore the crates directory and look for WebUI-related code.
- Assistant
Let me explore the key crates related to this issue - threads, turns, conversations, gateway, and the reborn-related crates.
- Assistant
Let me make one call at a time.
- Assistant
Let me search for action_id and webui related terms.
- Assistant
Let me look at the key files more closely.
- Assistant
Let me open the key files to understand the current implementation:
webui_inbound.rs,reborn_services.rs, andledger.rs. - Assistant
Let me continue reading the file to understand the full structure.
- Assistant
Let me continue reading the rest of webui_inbound.rs, then look at reborn_services.rs and ledger.rs.
- Assistant
Let me continue reading.
- Assistant
Let me continue reading the rest of webui_inbound.rs and then look at the reborn_services.rs file.
- Assistant
Now let me look at reborn_services.rs which contains the actual service logic for handling WebUI commands.
- Assistant
Let me continue reading the reborn_services.rs file to see the full implementation.
- Assistant
Let me continue reading to understand the full flow.
- Assistant
Let me continue reading.
- Assistant
Let me continue reading the file to understand the full implementation.
- Assistant
Let me continue reading the rest of the file.
- Assistant
Let me continue reading the rest of the file.
- Assistant
Let me continue reading.
- Assistant
Let me look at the ledger.rs file next, as it seems relevant to the "accepted-message ledger" part of the issue.
- Assistant
Now let me look at the tests and understand the current state of idempotency handling. Let me examine the test files.
- Assistant
Let me look at the test files to understand what's already tested and what might be needed.
- Assistant
Let me continue reading the test file to understand the existing tests and what they're testing.
- Assistant
Let me continue reading to see the existing tests.
- Assistant
Let me continue reading the tests to understand what's already covered and what's missing.
- Assistant
Let me continue reading to understand the full test file and identify what tests exist and what might be missing.
- Assistant
Let me continue reading the rest of the test file.
- Assistant
Let me continue reading the test file to understand all the existing tests.
- Assistant
Let me read the rest of the test file to see what tests exist.
- Assistant
Let me read the rest of the tests.
- Assistant
Let me now look at the threads crate to understand the
replay_accepted_inbound_messageandaccept_inbound_messagemethods. - Assistant
Let me look at the contract module to understand the data types and the service interface.
- Assistant
Let me continue reading the contract.rs file to see the AcceptInboundMessageRequest and related types.
- Assistant
Let me continue reading to see the rest of the contract.rs file.
- Assistant
Let me now look at the SessionThreadService trait to understand what methods are available for thread operations.
- Assistant
Let me look at the in-memory implementation to understand how idempotency is handled.
- Assistant
Let me continue reading the in-memory implementation.
- Assistant
Let me run the existing tests to see the current state.
- Assistant
Let me set up the Rust toolchain first.
- Assistant
Now let me run the existing tests to see the baseline.
- Assistant
Let me look at the
RebornSubmitTurnResponsetypes and understand the response structure better. - Assistant
Let me look at the types.rs file to understand the response types.
- Assistant
Let me continue scrolling.
- Assistant
Now I have a good understanding of the codebase. Let me look at the error module as well.
- Assistant
Let me look at the lib.rs to understand the module exports.
- Assistant
Let me look at the
inbound_turn.rsto understand how the product workflow uses the ledger: - Assistant
Let me now look at the workflow.rs to understand the ledger integration:
- Assistant
Let me now look at the action.rs to understand the
ActionFingerprintKeyandProductInboundAction: - Assistant
Let me look at the TurnCoordinator trait to understand how submit_turn handles idempotency:
- Assistant
Let me look at the TurnCoordinator trait to understand the submit_turn signature.
- Assistant
Let me now look at the fakes (test support) in the product workflow:
- Assistant
Now let me look at the AGENTS.md file to understand the project conventions:
- Assistant
Let me now understand the full picture. Let me look at the existing test expectations and the InboundIdempotencyKey behavior:
- Assistant
Let me check the SessionThreadError enum:
- Assistant
Let me look at the Cargo.toml for
ironclaw_product_workflow: - Assistant
Now I have a thorough understanding of the codebase. Let me analyze what needs to be implemented:
Current state:
submit_turnalready handles per-thread duplicates viareplay_accepted_inbound_messagecreate_threadhandles duplicates via deterministic thread IDs- The thread service has per-source_binding_id idempotency
What's missing (based on acceptance criteria):
- Cross-thread duplicate rejection: same
client_action_idacross different threads should be rejected - An accepted-message ledger at the WebUI facade level tracking
client_action_id → thread_id - Tests for concurrent duplicates, cross-thread rejection, validation ghosts, retry after transient errors
Let me implement the changes:
- Assistant
Now I understand the full picture. Let me implement the changes. First, let me add the accepted-message ledger to
RebornServices: - Assistant
Now let me update the
submit_turnmethod to add the ledger check. Let me first look at the current submit_turn more carefully: - Assistant
Let me see the full submit_turn method:
- Assistant
Now I need to modify the
submit_turnmethod. The key insight is that I need to check the ledger for cross-thread rejection, but still let the thread service handle same-thread replay. Let me implement the changes: - Assistant
Now I need to add the ledger update after the handoff is determined. Let me also add the
scoped_key_from_partsmethod. Let me first add the method: - Assistant
Now I need to add the ledger update after the handoff block in
submit_turn. Let me find the right spot: - Assistant
Let me see the context around line 283:
- Assistant
Now let me add the ledger update after the handoff block:
- Assistant
Now let me update the
create_threadmethod to also check and update the ledger. Let me find it: - Assistant
Let me see the create_thread method:
- Assistant
Now let me modify the
create_threadmethod to add ledger checks: - Assistant
Now I need to add the
accepted_message_ref_placeholderhelper function. Let me find where the other helper functions are: - Assistant
Let me add the
accepted_message_ref_placeholderfunction near the existingaccepted_message_ref: - Assistant
Let me try to compile to see if the changes compile correctly:
- Assistant
The tokio crate is only in dev-dependencies. Let me use
std::sync::Mutexinstead since we don't hold the lock across await points: - Assistant
Now I need to change
TokioMutextoMutexin the struct and everywhere it's used. Let me also check if we need a different import. - Assistant
Now I need to update the lock calls from
.lock().awaitto.lock().expect("lock")for the std Mutex: - Assistant
I need to change all
.lock().awaitto.lock().expect("accepted-message ledger lock")for the std Mutex. - Assistant
Now I need to make sure
Mutexis imported fromstd::sync. Let me check the current imports: - Assistant
I need to add
Mutexto the imports: - Assistant
Let me check if
AcceptedMessageRefis properly imported. Let me verify the current imports: - Assistant
Let me try to compile again:
- Assistant
I need to fix the remaining TokioMutex reference.
- Assistant
Let me try to compile again:
- Assistant
It compiles with just a warning about the unused
accepted_message_reffield. Let me suppress that warning and run the existing tests: - Assistant
Let me now run the existing tests:
- Assistant
All existing tests pass. Now let me add the new tests. Let me open the test file:
- Assistant
Now let me add the new tests. I'll add them before the
facade_source_avoids_forbidden_runtime_dependenciestest at the end: - Assistant
Now let me add the new tests. I'll insert them before the
facade_source_avoids_forbidden_runtime_dependenciestest: - Assistant
Now let me compile and run the tests to see if they pass:
- Assistant
All 23 tests pass (17 original + 6 new). Let me now verify the full test suite and run any broader tests that might be affected:
- Assistant
Let me just verify the crate tests pass cleanly:
- Assistant
All tests pass. Let me also check the related crate tests to make sure nothing is broken:
- Assistant
Let me also check if there are other tests in the crate that might be affected:
- Assistant
All tests pass. Let me now review the final state of the code I changed. Let me check the complete
reborn_services.rsfile: - Assistant
Let me also check the submit_turn and create_thread methods:
- Assistant
Let me also check the create_thread method:
- Assistant
Let me verify the source code check test still passes by checking if any forbidden patterns were introduced:
- Assistant
No forbidden patterns. Let me do a final comprehensive check:
- Assistant
Let me look at the full diff to review all changes:
- Assistant
Let me look at the full diff:
- Assistant
Let me do one final comprehensive check to make sure everything is clean:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.