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
Let me start by understanding the repository structure and the issue at hand. The issue is about adding WebUI idempotency and accepted-message ledger to a project called "Reborn WebUI Beta". Let me explore the repository first.
Assistant
This is a Rust project. Let me explore the source code structure to understand the project and find the relevant files for WebUI mutations
Assistant
The key files seem to be in
ironclaw_product_workflow. Let me look at the relevant source files.Assistant
Let me look at the core files: webui_inbound.rs, ledger.rs, action.rs, error.rs, and the contract
Assistant
Now let me look at the ledger and workflow files
Assistant
Let me look at the files one at a time
Assistant
Now let me look at the action.rs and then the workflow.rs and error.rs.
Assistant
Let me look at the workflow
Assistant
Let me look at error.rs and the reborn_services
Assistant
Let me look at reborn_services.rs
Assistant
Now let me look at the contract test for webui_in
Assistant
Let me look at fakes.rs and the product_workflow_contract tests
Assistant
Let me look at the product workflow contract tests
Assistant
Let me see the full reborn_services.rs file
Assistant
Let me read the rest of the reborn_services file to see the submit_turn method and create_thread method.
Assistant
Let me continue reading the rest
Assistant
Let me read the rest of reborn_services.rs
Assistant
Let me look at the reborn_services_contract tests
Assistant
Let me look at the git log to understand recent changes and what's expected
Assistant
Let me look at the recent changes related to reborn ingress boundary and understand the context better.
Assistant
Let me look at the product workflow CLAUDE.md and the inbound_turn.rs
Assistant
Let me look at the inbound_turn.rs file
Assistant
Let me look at the inbound_turn_contract tests
Assistant
Let me look at the reborn_services types
Assistant
Now let me look at the reborn_services error.rs
Assistant
Let me look at the lib.rs of ironclaw_product_workflow to understand all the exports
Assistant
Let me search for create_thread related tests and code in the contract tests
Assistant
Let me read the duplicate tests in reborn_services_
Assistant
Let me first try to build and run the existing tests to understand the current state.
Assistant
Let me check the Rust toolchain setup
Assistant
Let me check what's available for Rust
Assistant
Let me set up the Rust toolchain
Assistant
Now let me try to build and run the tests for the product_workflow crate
Assistant
Let me look at the InMemorySessionThreadService to understand the concurrent duplicate handling
Assistant
Let me look at the InMemorySessionThreadService implementation
Assistant
Let me search for specific test scenarios in the repo
Assistant
Let me search for any TODO/FIXME items related to idempotency in the codebase
Assistant
Let me search for any test stubs or TODO markers related to the acceptance criteria
Assistant
Let me look at the reborn_dependency_boundaries test to understand the architecture better
Assistant
Let me look at the DB implementation of SessionThreadService to see how replay_accepted_inbound_message
Assistant
Let me find the DurableState implementation in db.rs
Assistant
Let me look at the
DurableState.replay_accepted_inbound_messageat line 634.Assistant
Let me look at the recent git changes related to webui_inbound and reborn_services
Assistant
Let me write a small script to test edge cases and see if there are issues
Assistant
Let me run the cross-thread duplicate test to understand the current behavior
Assistant
Let me look at the SessionThreadService trait definition
Assistant
Let me look at the contract.rs to see the types
Assistant
Let me re-read the duplicate submit test carefully to understand the expected
Assistant
Let me write a quick test to verify the cross-thread duplicate
Assistant
Let me check the IdempotencyKey type from ironclaw_turns
Assistant
Let me find where IdempotencyKey is defined in ironclaw_t
Assistant
Let me search for IdempotencyKey more
Assistant
Now I have a clear understanding. Let me implement the changes. Let me first open the reborn_services.rs file.
Assistant
Let me try the open command differently
Assistant
Let me view the submit_turn method starting at line 103
Assistant
Let me use scroll_down to navigate
Assistant
Let me scroll down further to see the rest of submit_turn
Assistant
Let me look at the webui_source_binding_id function
Assistant
Let me view webui_source_binding_id at line 609
Assistant
Now I have a clear plan. Let me implement the changes. First, let me add the
webui_idempotency_binding_idfunction and modifysubmit_turn.Assistant
Let me use a simpler approach with sed to make the changes
Assistant
Let me use the replace command to add the new function
Assistant
Let me use sed to make the changes directly
Assistant
Let me verify the new function was added correctly
Assistant
Now let me modify the
submit_turnmethod to use the idempotency binding and add cross-thread detectionAssistant
Let me verify the changes to the submit_turn method
Assistant
Let me verify the rest of submit_turn
Assistant
Let me try building to see if it compiles
Assistant
It compiles. Now let me run the existing tests to see if they still pass
Assistant
All tests pass. Now let me add the missing tests. Let me open the contract test file.
Assistant
Let me see the end of the test file
Assistant
Let me look at the imports and helper types in the test file
Assistant
Let me find the FakeTurnCoordinator and other test helpers
Assistant
Let me look at the FakeTurnCoordinator implementation
Assistant
Now let me add the missing tests. I'll add them right before the
facade_source_avoids_forbidden_runtime_dependenciestest at the end.Assistant
Let me create the test code and insert it before the facade_source test
Assistant
Let me build and run the new tests
Assistant
Let me check the test attribute format in the existing tests
Assistant
I need to use
#[tokio::test]instead of#[test]. Let me fix thatAssistant
Let me check if there are non-async tests that were also affected
Assistant
Let me check the facade_source test - it should not be async
Assistant
I see an issue - the sed replaced the
#[test]on thefacade_source_avoidstest too. Let me check and fix itAssistant
Let me look around line 1103
Assistant
Let me look at lines around 838-845
Assistant
Let me look at the area around the facade_source_avoids function
Assistant
The facade_source_avoids test lost its attribute. Let me fix it by adding
#[test]backAssistant
Let me try building and running again
Assistant
Let me fix the variable name inconsistency
Assistant
Let me fix the unused variable by using it in the assertions
Assistant
Let me fix the test to use the already_submitted variable in assertions
Assistant
Let me add an assertion that uses
already_submittedAssistant
Let me check the exact current state and fix it
Assistant
Let me fix the broken assertions
Assistant
Now let me try building again
Assistant
Let me check the issue area
Assistant
The earlier sed command has corrupted multiple
assert!(...blocks. Let me restore the test file from git and re-apply my changes more carefully.Assistant
Now let me add the tests properly
Assistant
Now let me build and run tests
Assistant
Let me try just checking compilation first
Assistant
Let me check if the tests compile by running cargo test with --no-run
Assistant
Let me run just the existing tests first to make sure they still pass
Assistant
Good, 22 tests total now. Let me run the cross-thread test
Assistant
Let me run all the new tests
Assistant
Let me try running just the concurrent
Assistant
Let me check the tokio features in Cargo.tom
Assistant
Let me check if there's a way to use multi-threaded runtime for tests
Assistant
Let me rewrite the concurrent tests to use
tokio::join!which works on single-threaded runtimeAssistant
Now let me also fix the cross_thread_concurrent test
Assistant
Now let me run all the new tests
Assistant
All 5 new tests pass. Let me now run ALL tests to make sure nothing is broken.
Assistant
All 54 tests pass (1+15+22+17=55 minus 1). Let me also run the inbound_turn_contract tests to make sure nothing is broken there either.
Assistant
Let me also check that I haven't broken any dependent crates by running a broader test
Assistant
Let me see the full diff of all
Assistant
Good. Let me verify the final test count and ensure everything is clean
Assistant
Let me also check for any clippy issues
Assistant
No clippy issues. Let me clean up the temporary files I created.
Assistant
All checks pass. Let me now check the final state of all changes one more time and
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.