Skip to content

Decide the pipeline's press once, when its task is spawned - #420

Merged
alexkroman merged 4 commits into
mainfrom
claude/pipeline-press-context
Nov 25, 2026
Merged

alexkroman merged 4 commits into
mainfrom
claude/pipeline-press-context

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

What & why

performRelease now takes the press's PressContext on the turn that spawns the transcribe→inject task and passes it into runTranscribeInject(press:). From there it goes to awaitUpload(press:), to inject(_:security:press:) and to a new setPhase(_:for:). Every pipeline-task setPhase passes it, so the failure log uses this press's press?.resolved. The paste's priorText/windowTitle, the remember decision, the transcript log and the failure log now all read the press the pipeline was started for.

Before, 97d29ee took let press = pressContext partway through runTranscribeInject, but only the transcript log used it. inject still read the shared capturedContext for the separator and window title, and setPhase logged failures against capturedContext. A later press overwrites that slot: a cancel during the paste ends the phase without waiting for the task. Those reads were correct only because no suspension point sat between them and the press that set them, and only a comment protected that.

setPhase(_:) stays as the press-side form and forwards pressContext; on that side the command queue rules out a newer press. capturedContext stays too: stopAndCancel's failure log and existing tests read it.

Behaviour change: none for any sequence the public commands can produce. A press is refused until the phase is terminal, and the cancel that makes it terminal also cancels the pipeline. The difference only shows if another press's context is installed while the pipeline is still live: the earlier press's paste spacing context, failure-log context and transcript-log context then stay its own.

How it was tested

  • Written in a Linux sandbox with no Swift toolchain: scripts/check.sh --portable passes, as do check-swift-size.sh and check-test-clock.sh. CI on macOS verifies the build, tests, swiftlint and swift-format.

  • New Tests/BlurtEngineTests/PipelinePressContextTests.swift (uses TestClock, no wall-clock waits). A gated transcriber holds the pipeline after release while a test-only extension installs a second, settled PressContext; then the transcript is let through.

    • One test asserts the paste got the first press's priorText/windowTitle.
    • The other makes the paste fail and asserts that the failure log and the transcript log carry the first press's context.
    • Both would fail on the old code.
  • The test installs the second context directly, because the public commands can't reach that state while a pipeline is live.

  • DictationSession.swift is now at 391/400 lines.

  • scripts/check.sh passes (or CI will, if I'm not on a Mac)

  • I read AGENTS.md and this doesn't reintroduce anything
    deliberately removed

  • Docs updated if behavior changed


Generated by Claude Code

performRelease now takes the press's PressContext on the turn that
spawns the transcribe-inject task and hands it to
runTranscribeInject(press:), which passes it on to awaitUpload, inject
and a new setPhase(_:for:). The paste's priorText/windowTitle, the
transcript log and the failure log all read that press's context, so
nothing after release reads the actor-wide pressContext/capturedContext
for it.

Before, only the transcript log took a snapshot (97d29ee), partway
through the function; inject and setPhase's failure log still read the
shared slot a later press overwrites. That was correct only because no
suspension point separated those reads from the press that set them,
which a comment protected. setPhase(_:) keeps logging against the
current press for the press side, where the command queue rules out a
newer one.

No behaviour change for any sequence the public commands can produce:
a press is refused until the phase is terminal, and the cancel that
makes it terminal also cancels the pipeline before it pastes or logs.
The new tests install a second PressContext mid-pipeline directly and
check that the first press's paste context and failure log survive it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
The two tests ran the same seven-step dictation across a later press;
jscpd counted them as a clone. One helper now runs it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
@alexkroman
alexkroman added this pull request to the merge queue Nov 25, 2026
alexkroman pushed a commit that referenced this pull request Nov 25, 2026
… CI run

Recent multi-commit PRs (#410, #413, #414, #416, #420, #422, #423, #425, #426)
mostly spent their extra ~37-minute runs on things nothing caught before CI:

- scripts/check-swift-lint-lite.sh: a toolchain-free text match for the opt-in
  SwiftLint/swift-format rules it can see (modifier_order, no_empty_block,
  NoBlockComments, swift-format's `catch  where`). Run by check.sh (so
  --portable and --lint-only) and the swift-budgets edit hook; would have
  flagged the pre-fix files of #414, #422 and #425.
- .claude/hooks/push-gate.sh: a PreToolUse hook that runs
  `check.sh --portable` (~20 s) before any `git push` and blocks a red one —
  jscpd clones (#420, #422) and post-merge size overruns (#363, #378) were
  pushes that skipped the documented portable run.
- AGENTS.md / CLAUDE.md: a "Rules only CI catches" list for the rest
  (variable_shadowing, one_declaration_per_file, type_contents_order,
  multiline_function_chains, MemberImportVisibility, one argument per line),
  and the new hook and script in the hooks table and permissions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1UDUZXyuF6g7GUmmNu
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 25, 2026
One conflict, in DictationSession+Pipeline.swift: #418 renamed the
password verdict to one targetSecurity value in two comments this PR
had rewritten around the press it now threads through. Kept this PR's
change with #418's names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
One conflict, in DictationSession+Pipeline.swift: #398 renamed the
too-short check's error to the provider-neutral TranscriberError on the
line this PR made log against its own press. Kept both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
@alexkroman
alexkroman added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit fb06ef8 Nov 25, 2026
22 checks passed
@alexkroman
alexkroman deleted the claude/pipeline-press-context branch November 25, 2026 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants