fix(tts): reject cancel_synthesis for terminal entry statuses - #178
Merged
Conversation
cancel_entry flipped any entry to pending unconditionally, so a cancel arriving after the entry left processing (race: synthesis finished while the UI menu was open) silently regressed a ready/error entry and orphaned its audio from the state machine. Now ready/playing/error are rejected with synthesis_error before touching registries or storage. pending stays allowed: cancel is idempotent for idle entries (#129 semantics) and a just-added entry briefly sits in pending with its task already registered.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cancel_entrypreviously flipped any entry topendingunconditionally. A cancel arriving after the entry leftprocessing(the race fixed frontend-side in feat(ui): expose cancel_synthesis in the queue entry menu #174: synthesis finishes while the context menu is open) silently regressed aready/errorentry and orphaned its audio from the state machine (playback requiresready; the entry would be re-synthesized on the next trigger).ready/playing/errorare rejected withsynthesis_errorbefore touching the registries or storage — same error style asplay_entry's "entry is not ready".pendingstays allowed deliberately: cancel is idempotent for idle entries (existing feat(tts): make cancel_synthesis actually stop synthesis #129 orchestration test pins this), and a just-added entry briefly sits inpendingwith its synthesis task already registered — rejecting it would break that window.harden-cancel-entry-status-guardarchived;ipc-commandsspec updated (idle-cancel allowed, terminal-entry rejection, new scenarios).Test plan
cargo test— 974 passed (new: rejectready/errorwith registries untouched;pendingwith a registered task still aborts it)just lintgreenopenspec validate --specs --strictgreenFollow-up (not in this PR)
A µs-scale read-decide-write race remains between
require_entryandupdate_entry(guard reads a clone, synthesis can complete before the write). Closing it needs a storage-level compare-and-set, which would also hardenapply_ready_if_current/apply_error_if_current— will be filed as a separate tech-debt issue.Closes #176