# R2b-refusal — immediate refusals, separate resync Focused correction on the retained `faa5866` cancellation candidate. The action source is now shared by both deliberate run actions (cancel and human decision); no wiring, screen, controller, repository, socket, pubspec, web, server or device file was touched. ## What changed | File | Lines | Responsibility | | --- | --- | --- | | `lib/features/runs/actions/action_refusal.dart` | 18 | Refusal message plus optional bounded re-read outcome; local guard words | | `lib/features/runs/actions/cancel_run_action.dart` | 119 | Immediate refusal return, single-flight resync, ownership checks | | `lib/features/runs/actions/cancel_dialog.dart` | 165 | Shows the refusal and re-enables Keep before the resync settles | | `lib/features/runs/actions/decision_action.dart` | 176 | Same async flow for `decide_run`, draft preserved | | `lib/features/runs/actions/decision_dialog.dart` | 268 | Shows refusal, keeps draft, disables retry only on server truth | | `test/features/runs/actions/cancel_resilience_test.dart` | 271 | Three new fake-gateway regressions | | `test/features/runs/actions/decision_resilience_test.dart` | 351 | Three new fake-gateway regressions | | `test/features/runs/actions/decision_action_test.dart` | 265 | Cancel/no-request coverage | ## Async flow A refused mutation no longer awaits `get_run` before returning: 1. `_submit` catches the mutation error and computes the refusal text. 2. It returns `ActionRefusal(message, stillPossible: _resyncRun(id))` at once. `_resyncRun` starts one `get_run` for that refusal; a concurrent refusal observes the same future instead of issuing another request. 3. The prompt clears its sending state, shows the server's words and makes Keep/Cancel available in the same frame. Back is enabled too (`PopScope` only gates the in-flight mutation). Confirm stays disabled while the check is pending and after it proves the action impossible, so a doomed mutation cannot be resubmitted from the open prompt. 4. The resync runs detached but bounded: exactly one `get_run`, no retries or polling. Every exception becomes `null` (unknown truth), which leaves the refusal visible and a deliberate retry available. 5. Before delivering a refreshed run, the action checks `mounted` and that the run id it owns is still the request's id. A late read after disposal or navigation touches nothing and raises nothing. On success the mutation reply is still used directly, the prompt closes, and no duplicate `get_run` is issued. The dialog and action keep the existing in-flight double-submit guard. The human-decision prompt keeps the selected option and feedback controller untouched while a refusal or resync is pending; its retry is disabled only when the refreshed run no longer offers the same decision (same stage and option keys). No repository, protocol or socket code changed. The web's `cancel_run` plus silent refresh remains the reference; this version keeps the diagnostic in the open prompt rather than moving it to the web's separate Action-failed dialog. ## Regression coverage added Fake gateway, no socket or real server: - immediate `cancel_run` refusal plus a deliberately unresolved `get_run`: the exact message is visible, Keep is enabled, confirm is disabled and no run callback has fired **before** the resync completes; Keep closes the prompt; a late resync still delivers server truth safely; - late cancel resync after the whole action is disposed: no exception, no callback; - resync proving the run is no longer cancellable: refusal stays visible, confirm cannot submit again (an attempted tap adds no request), Keep dismisses and the ineligible run is delivered; - immediate `decide_run` refusal plus an unresolved `get_run`: exact message, selection and feedback retained, Cancel enabled, no callback yet; after the resync proves the decision gone, the message remains and confirm is disabled; - decision resync that fails: message and draft remain, Confirm is re-enabled because server truth is unknown; - late decision resync after disposal: no exception, no callback; - Cancel on an untouched decision draft sends nothing and keeps the action available. ## Checks actually run ``` dart format lib/features/runs/actions test/features/runs/actions # clean flutter analyze # No issues found! flutter test test/features/runs/actions # 23 passed flutter test # 52 passed flutter build web # Built build/web ``` ## Honest limits - Still **not wired into a run-detail screen** on this branch; there is no browser interaction or rendered capture for this widget. `flutter build web` proves compilation only. - Mobile remains unverified: no Android/iOS build, emulator, ADB or device. - No real server or run was mutated; all evidence uses local fakes. - No commit, push, deployment or canonical-URL change is claimed here beyond the candidate commit checked by the manager.