Repository navigation
refactor: lifecycle transition test seam (#47 CAND-5) - #53
Merged
Merged
Conversation
…module Concentrate the recording pipeline's deterministic decisions into a new src-tauri/src/lifecycle.rs so they can be characterized without an AppHandle, following #51's settings-module convention. - toggle_action(): pure Idle/Recording/busy -> Start/Stop/Ignore decision, used by the command, tray, and single-instance adapters via toggle(). - session_is_current(): single predicate replacing the three duplicated stale-session checks in is_session_current/set_state_for_session/ finish_session, gating every pipeline checkpoint. - failure_outcome()/no_speech_outcome()/delivery_outcome(): terminal projections for recorder/transcription failure, empty transcript, and post-delivery cleanup/paste/history results (supersedes the old final_delivery_status()). recorder/STT/cleanup/delivery/history stay effect implementations in engine.rs; incremental scheduling and visible Stage values are untouched. Adds characterization tests for duplicate start/toggle, stop before init finishes, cancellation at every pipeline checkpoint, stale completion after cancel/new session, cleanup failure with raw delivery, and history failure. Ref #47 (CAND-5).
7 tasks
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.
Implements CAND-5 of #47: a characterization-first lifecycle test seam ahead of CAND-1's incremental-orchestration move.
Scope
src-tauri/src/lifecycle.rs(new),src-tauri/src/engine.rs,src-tauri/src/lib.rs(module registration).run_incremental_worker/choose_segment_end/etc.), does not change theStageset or its emission order.paste.rsor CLI binaries (parallel lane's scope).What changed
Session state was distributed across
recording/active_session/state/level/chord/file-job fields, with the pipeline's cancellation and partial-failure invariants buried inside effectful code that needs anAppHandleto exercise. This extracts exactly the deterministic parts intolifecycle.rs, following #51's settings-module convention (pure decision functions, no Tauri):toggle_action(stage)— Idle/Recording/busy → Start/Stop/Ignore. All three entry adapters (command, tray, single-instance--toggle) already route throughEngine::toggle, so this is the one place duplicate-start protection lives.session_is_current(active, session_id, token_cancelled)— replaces three duplicated inline stale-session checks (is_session_current,set_state_for_session,finish_session) with one predicate. Every pipeline checkpoint (after recorder stop, after transcript resolution, after cleanup, after delivery, at terminal projection) now shares this single decision.failure_outcome/no_speech_outcome/delivery_outcome— terminal error/message/history-entry projection for recorder/transcription failure, empty transcript, and post-delivery cleanup+paste+history combinations (supersedes the oldfinal_delivery_status).engine.rsstill performs every effect (recorder, incremental/STT, cleanup, paste, history, Tauri emit) and still owns the pipeline's control flow; it just calls into these pure functions instead of duplicating the decisions inline.Tests added (
lifecycle.rs)toggle_actionstarts only from Idle, stops only from Recording, ignores while busy.session_is_current(None, ...)is always false.session_is_currentcharacterized for cancelled session record, cancelled stage token, and an explicit per-checkpoint test.delivery_outcomereports no error, an advisory message.delivery_outcomeclearslast_entrywithout affectingerror/message.Validation
cargo test(lib) — 67 passedcargo test -p pickscribe-app --locked --lib— 29 passed (18 new inlifecycle::tests)cargo test --workspace --locked --all-targets— all greenbun run build— succeedsRef #47 (CAND-5).