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
Now let's view the duplicate tests in detail:
Assistant
Good, toolchain is set up now. Let's run the repro test.
Assistant
Now let's remove the thread segment from
webui_source_binding_id:Assistant
Now let's rerun the repro test and the existing contract tests:
Assistant
Cross-thread duplicate rejection now works. Let's run the full existing contract test suite for this crate to ensure nothing broke:
Assistant
All existing tests pass. Now let's test the concurrent duplicate scenario (same-thread and cross-thread) to validate acceptance criteria more thoroughly.
Assistant
Let me rewrite my tmp_repro.rs completely using the same pattern from the existing test file, but more simply by copying much of the fake infra.
Assistant
Now the
db.rsDurableState version:Assistant
Now let's rewrite my repro test to use the real
DefaultTurnCoordinator+InMemoryTurnStateStore, and remove the debug eprintln from reborn_services.rs.Assistant
Now let's rewrite tmp_repro.rs using the real
TurnCoordinator:Assistant
Let's run this repeatedly to check for flakiness with the real coordinator (true concurrency, multi-thread):
Assistant
40/40 runs pass consistently now with the real turn coordinator under true concurrency. Let's also run the full test suite for
ironclaw_threads(since I modifiedmark_message_submittedin both backends) and the fullironclaw_product_workflowsuite again:Assistant
Good — confirms this scenario was already tested and correctly handled at the thread-service layer when
source_binding_iddoesn't encode thread. My fix inreborn_services.rsnow correctly relies on this pre-existing capability. Let's check the db feature flag fordb_session_thread_contract.rs:Assistant
Let's run with the
libsqlfeature to exercise the DB-backedmark_message_submittedfix as well:Assistant
All pass. Now let's re-run the full ironclaw_product_workflow test suite (with tmp_repro included) plus broader workspace checks that depend on these crates:
Assistant
All green. Now let's also check
mark_message_deferred_busyfor a similar race (the DeferredBusy path). Let's examine if it needs the same idempotent-no-op treatment:Assistant
Let's also verify concurrent
create_threadduplicates behave correctly:Assistant
All good. Now let's remove the temporary repro test file and do a final full review of the diff.
Assistant
Good, tmp_repro.rs removed and not tracked. Let's view the final diff:
Assistant
Whole workspace checks cleanly (only a pre-existing unrelated dead-code warning). Let's run the broader workspace test suite for the crates most related to this change to be thorough, plus double-check
cargo fmt --checkisn't required but let's check clippy on the touched files quickly.Assistant
No clippy warnings on touched crates. Now let's run the full relevant test suites one more time to be safe, and confirm the tmp file is indeed gone.
Assistant
All green, and the temp repro file is gone (not in
tests/listing, andgit statusearlier confirmed no untracked files). Let's do a finalgit statuscheck:Assistant
Clean, minimal diff across exactly the files needed. Let me review the checklist:
Assistant
This is a clean, minimal, well-documented fix. Let's do one last full test pass across the workspace to be extra sure before submitting.
Assistant
All tests across the affected crates pass. Now the checklist review:
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.