Skip to content

fix(conn-server): Pass 4 approval, async answers, failure wakes and Claude app notes, as T3 - #276

Merged
nckrtl merged 12 commits into
mainfrom
fix/conn-server-audit-pass4
Nov 24, 2026
Merged

nckrtl merged 12 commits into
mainfrom
fix/conn-server-audit-pass4

Conversation

@nckrtl

@nckrtl nckrtl commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Fixes four Pass 4 findings of the Conn Server port audit (guide "Approval, queues, PR watches and provider input"). One commit per finding. Each acceptance test was run failing on a9b09d8af3 and passing after its fix.

Guide Commit Crate Change Acceptance test
4.1 73bde24719 conn-engine A run's end cancels only the requests whose node belongs to that run. Before, removing queued run B cancelled the approval that active run A waited on. engine_tests::removing_a_queued_run_keeps_the_active_runs_approval: B cancelled, A's card stays pending in the shell, answering it completes A once
4.2 6dc84ec7dd conn-engine runtime-request.respond matches responseCapability. For message it validates answers as T3 does, resolves the card, and dispatches one user message async-answer:<requestId> in the same transaction. The provider-enabled guard covers it. Live answers keep adapter delivery. engine_tests::an_async_question_is_answered_with_one_message_and_one_run: T3's four invalid answers refused with no change, retry by command id returns the first outcome, a new id is refused, and after reopening there is one resolved card, one message Which color?\nBlue\n\nWhich sizes?\nSmall, Large and one run
4.4 0402dce7f9 conn-engine The provider-failure hold leaves buffered provider notifications free (T3's isBufferedProviderNotification), so the normal queue starts them. Stop and other holds are unchanged. engine_tests::a_provider_failure_holds_messages_and_starts_a_buffered_wake: the user message and a server-sourced wake stay held, and the provider wake completes once
4.5 91e6ba0bed conn-provider-claude Turns put unseen MCP app notes before the prompt as <external_KEY>text</external_KEY> blocks (T3's withClaudeAppContext). Slash commands get none. Notes count as delivered on turn completion and are cleared by compaction, conversation reset and rollback. interrupt_tests::mcp_app_notes_reach_the_claude_prompt_until_a_turn_takes_them_in, against the fake SDK host's recorded input frames: note sent, resent after an interrupt, skipped after a completed turn, resent after compaction

Extra evidence for 4.2: the real T3 pre-answer database (written by T3's own async-question test via VACUUM INTO) was imported. Answering it twice and reopening gave one resolved card, the T3 message text and one run. On main it gave none. That probe is not committed because it needs the T3-generated fixture.

Checks run on macOS, sealed (sealedCargoEnv):

  • cargo fmt
  • cargo clippy -D warnings --all-targets, per crate: conn-engine after 4.1, 4.2 and 4.4; conn-provider-claude after 4.5. The whole workspace was also clean on the tree that holds 4.5 plus the next change.
  • cargo test: conn-engine 210, 211 and 212 passed after 4.1, 4.2 and 4.4; conn-provider-claude 83 passed, 11 ignored, after 4.5.
  • The T3 reference test for 4.2 ran green.

Not run: tools/check.sh, held back because of low disk on the build host. CI covers the Linux run.

Gate fixes

  • ef94b00f9d (round 1):

    • A held queue is released only by a user's web or mobile send.
    • The async answer steers only into a running provider turn.
    • A provider result skips the hold unless Stop reached the active run.
    • A usage limit is not treated as a provider failure that lets a wake start.
  • 5ad020e1cb (round 2):

    • T3's workspacePreparation (copied by the importer) holds work after a failed worktree setup.
    • The answer checks the session's supportsActiveSteering.
    • A completed run releases unattended held work (agent, server, scheduled) before the next start, also after checkpoint capture.
    • A usage limit blocks only its own provider at automatic start and queue.resume, in queue order.
    • Each change has a test that failed on the previous head.
  • 0a03a133b8 (round 3), each with a test that failed on 5ad020e1cb:

    • Send now runs queue.resume's checks on the selected run before clearing any hold.
    • An answer that would steer a stopped run is refused and stays pending.
    • Send now and resume start as the user (port of T3's "holds a limited provider's queue … until the user resumes").
    • Monitor wakes and other follow-the-conversation runs use the thread's current selection; buffered results keep their recorded provider.
    • A provider failure holds only when the next run is on the failed provider.
  • df9d168676 (round 4), each with a test that failed on 0a03a133b8:

    • A queued run always takes the full effective selection and its instance id, so a monitor wake queued on model A starts on model B after the user picks B on the same instance (T3 startNextQueuedRun). Test: a_monitor_wake_takes_a_new_model_on_the_same_instance (failed: ran on model-a).
    • A stale pull request wake at the head of the queue is cancelled before a provider failure decides what to hold, so a runnable Codex message behind it starts. Test: a_stale_wake_does_not_hold_other_provider_work_after_a_failure (failed: wake and Codex run both held).
    • usageLimitHoldsQueue reads the latest session's lastError first; a different error lifts the old usage_limit item (threadErrorSummary). Test: a_newer_session_error_lifts_an_old_usage_limit (failed: queue.resume refused).
    • No change for scheduled dispatches: this PR only reads followsThreadSelection; fix(conn-server): an undone settle keeps the thread's place in Active #260 writes it.
  • f54a467b69 (round 5): the failure check loads thread history only when the queued message carries a pull request watch stamp, so an ordinary queued user message never scans every message under the store lock. Existing tests cover the behaviour; no new test.

Merge with #256: combine the RunEnd and Held imports in runner.rs. #256's RunEnd handling and this PR's request-owner filter and queue rules both stay.

Coordination: #256 changes the end_run signature next to the 4.4 hold and adds a RunEnd argument to finish_run_as, which 4.1 also edits. Expect textual conflicts, not semantic ones. Neither PR changes the other's rule. The outbox stack (#261/#268/#269) does not touch queued-run cancel or request cleanup.

Not in this PR: 4.6 (Codex/Claude steer notes, which needs a build) and 4.3 (external merge wake with T3's own-merge detection) follow in separate PRs.

Model: Claude Opus 5.5, Claude Code.

🤖 Generated with Claude Code

nckrtl and others added 4 commits November 23, 2026 17:38
…al, as T3

Ending any run cancelled every pending runtime request on the thread. So
removing queued run B while run A waited on an approval cancelled A's card,
and the server refused the answer while the provider still waited.

A run's end now cancels only the requests whose node belongs to that run.
T3's queued-run cancel writes only the run, its attempt and its root node.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…starts one run, as T3

A question whose provider can no longer take it live (responseCapability
`message`, as one imported from T3 after its provider exited) was answered
like a live approval. With no live session the delivery failed, the card
expired and the answer was lost: no message and no run.

The respond command now matches the capability. For `message` it checks
the answers against the question as T3 does, resolves the card and its
item, and dispatches one user message `async-answer:<requestId>` in the
same transaction: a steer of the active run, or a queued or started turn.
Like T3, it refuses the answer when the thread's provider is disabled for
its project. Live requests keep their adapter delivery.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… wake, as T3

A failed turn held every queued run. A buffered provider notification
replays output the CLI already produced, so T3 starts it while it holds
the user's messages. Here it stayed held with them.

The failure hold now leaves a queued run free when its message is a
buffered provider notification (agent, provider source, a notification,
no delegated completion), and the normal queue starts it. Stop and other
holds are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s T3

The engine passed MCP app notes in the turn input, but the Claude session
never used them, so the model never saw what an app reported.

As T3's withClaudeAppContext, a turn now puts each note the native thread
has not seen with its current text before the prompt, as quoted app data
(`<external_KEY>text</external_KEY>`). A slash command gets none. What a
turn offers enters the history only when the turn completes, so an
interrupted turn's notes go again. Compaction, a conversation reset and a
rollback clear what the history holds. Steers follow with SteerInput.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XL labels Nov 23, 2026
nckrtl and others added 3 commits November 23, 2026 19:18
…rules

Gate findings on 4.2 and 4.4:
- A held queue is released only by a client send (`sentByUserFromClient`:
  a user's web or mobile message, not a steer follow-up or scheduled task).
  The async answer, created by the server, no longer resumes work the user
  stopped.
- The async answer steers only into a provider turn that runs. A run still
  starting gets the answer as its own later run, instead of the deferred
  steer that delivered it into the start.
- A provider result queued while a held queue waits does not take the
  hold unless Stop reached the active run (`wakeSkipsHold`), so a second
  buffered result drains while the user's message stays held.
- A usage-limit failure holds everything queued, provider wakes too, as
  T3 checks `usageLimitHoldsQueue` before a failure starts a wake.

T3's worktree-setup condition has no counterpart: this engine records no
workspace preparation on runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nded and usage-limit rules

Round-2 gate findings on #276:
- Runs imported from T3 carry workspacePreparation. After a failed or
  stopped worktree setup on a thread with no checkout, a new message waits
  held instead of starting in the project root (worktreeMissingRun), and
  neither a client send nor a provider result passes the hold while setup
  is pending (worktreeSetupPending).
- An async answer steers only when the active run's session advertises
  supportsActiveSteering; otherwise it queues behind waiting work instead of
  a declined steer putting it first.
- A run that completes as the thread's newest without a Stop releases held
  work nobody reviews: agent, server and scheduled messages
  (releaseUnattendedHolds), before the next run is picked, also after a
  checkpoint capture. The user's held messages stay held.
- A usage limit writes no hold. Automatic starts and queue.resume check the
  next run's own provider (usageLimitHoldsQueue), so a limited provider
  waits in queue order while another provider's work can start.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…llow T3's queue checks

Round-3 gate findings on #276:
- queued-run.start (Send now) runs queue.resume's checks on the selected
  run before clearing any hold: a pending worktree setup or a limited
  provider refuses it and leaves the queue as it was.
- An async answer that would steer a run Stop already reached is refused,
  so the answer stays pending and can be sent again (stopReachedRun).
- Send now and queue.resume start as the user (no reset-time wait), apart
  from whether a run was selected. Ports T3's "holds a limited provider's
  queue through another provider's turn until the user resumes".
- A queued run whose message follows the thread's conversation (monitor
  wakes, delegated results, followsThreadSelection) is checked and started
  on the thread's current selection (queuedRunModelSelection); buffered
  provider results keep their recorded provider.
- A provider failure holds the queue only when the next run would start on
  the failed provider.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
nckrtl and others added 5 commits November 24, 2026 01:28
… wakes drop before a failure holds, a newer session error lifts a usage limit, as T3

- A monitor wake queued on model A starts on model B after the user picks B on the
  same instance (startNextQueuedRun copies the full selection).
- A stale pull request wake at the head of the queue is cancelled before a provider
  failure decides what to hold, so runnable work on another provider still starts.
- usageLimitHoldsQueue reads the latest session's lastError first; a different error
  means the old usage_limit item no longer holds the queue.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ll request wake

The stale-wake check at run end loaded every message of the thread for any queued
message. It now checks the queued message for a pull request watch stamp first, so an
ordinary user message never scans history under the store lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	apps/conn-server/crates/conn-provider-claude/src/interrupt_tests.rs
# Conflicts:
#	apps/conn-server/crates/conn-engine/src/commands.rs
# Conflicts:
#	apps/conn-server/crates/conn-engine/src/commands.rs
@nckrtl
nckrtl merged commit ccd733e into main Nov 24, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant