fix(session): fail-fast (or warn loudly) when launcher dropped session key (#284.4)#302
Merged
Merged
Conversation
3e46978 to
f2a11ff
Compare
Deploying wireup-landing with
|
| Latest commit: |
48da312
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8b8a03f3.wireup-landing.pages.dev |
| Branch Preview URL: | https://fix-284-4-cli-wire-home-fail.wireup-landing.pages.dev |
b753b50 to
24bd219
Compare
…n key (#284.4) Issue #284 part 4 (from Willard's Windows report). When the launcher spawns wire without `WIRE_HOME` or `WIRE_SESSION_ID` (and no host-adapter env like `CLAUDE_CODE_SESSION_ID` either), the session adapter falls through to one of two silent-failure modes: - `wire mcp` mints a fresh per-process key (`SESSION_SOURCE = "minted"`) so the new server gets its own identity rather than colliding on the cwd-default. - `wire daemon` / `wire monitor` / `wire notify` run against the machine-default identity (`SESSION_SOURCE = "machine-default"`). Both fallbacks are usually NOT what the launcher meant. The operator only finds out minutes later, when they notice a sibling daemon serving the real session-key home racing the inbox cursor with this process's freshly-minted-or-default one. New helper `crate::session::warn_if_unexpected_session_source(role)`: - Default: forces a clear stderr line naming the resolved source (`machine-default` / `minted`) and the operator-facing remediation ("pass an explicit `WIRE_SESSION_ID=<key>` or `WIRE_HOME=<path>`"). Force-rendered, NOT gated on TTY — these are spawn paths under Claude Code / scripts where stderr may not look like a terminal. - `WIRE_STRICT_SESSION=1`: upgrades the warning to a hard exit (code 2) at startup, so the launcher fails-fast instead of letting downstream `init` / `bind` / `daemon` calls block on a shared relay-state lock or quietly write to the wrong home. Each of the four inbox-owning entry points now calls warn_if_unexpected_session_source BEFORE warn_on_identity_collision: - mcp.rs (`wire mcp`) - cli/relay.rs (`wire daemon`) - cli/comms.rs (`wire monitor`, `wire notify --once`-excluded) The collision check itself stays in place; the session-source check is the earlier signal that catches the "launcher dropped the key" cases the collision check needs another sibling process to actually fire. Pure-logic `is_unexpected_session_source(&str) -> bool` predicate is extracted + unit-tested across every adapter label. Tests: 3 new in session::tests, all green on `x86_64-pc-windows-msvc` (rustc 1.96.0): - is_unexpected_session_source_flags_machine_default_and_minted - is_unexpected_session_source_passes_explicit_sources - is_unexpected_session_source_handles_unknown_conservatively Full lib suite: 489 passed; 0 failed; 7 ignored. Stacks on top of #294 (Windows test/clippy hygiene); rebase onto main once #294 lands. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: laul.pogan <paul@zaibatsuheavy.industries>
24bd219 to
48da312
Compare
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.
Part 4 of #284 (Willard's Windows report).
Summary
When the launcher spawns wire without inheriting `WIRE_HOME` or `WIRE_SESSION_ID` (and no host-adapter env like `CLAUDE_CODE_SESSION_ID` either), the session adapter silently falls through to:
Both fallbacks are usually not what the launcher meant. The operator only finds out minutes later when they notice a sibling process serving the real session-key home racing the inbox cursor with this one's machine-default-or-minted one. Willard's repro: the spawned shell dropped `WIRE_HOME` on the floor, the child wrote to the cwd-default home, and the resulting cross-home contention contributed to the `relay.lock` pileup behind #284.5.
Fix
A new helper `crate::session::warn_if_unexpected_session_source(role)`:
Default: forces a clear stderr line naming the resolved source (`machine-default` / `minted`) and the operator-facing remediation ("pass an explicit `WIRE_SESSION_ID=` or `WIRE_HOME=`"). Force-rendered, not gated on TTY — these are spawn paths under Claude Code or scripts where stderr usually isn't a terminal.
`WIRE_STRICT_SESSION=1`: upgrades the warning to a hard exit (code 2) at startup so the launcher fails-fast instead of letting downstream `init` / `bind` / `daemon` calls block on a shared relay-state lock or quietly write to the wrong home.
Each of the four inbox-owning entry points now calls `warn_if_unexpected_session_source` BEFORE `warn_on_identity_collision`:
The existing collision check stays in place; the session-source check is the earlier signal that catches the "launcher dropped the key" cases the collision check only fires for once a sibling process is also already running.
Pure-logic
`is_unexpected_session_source(&str) -> bool` is split out so the policy is exhaustively unit-testable across every adapter label.
Tests
3 new in `session::tests`, all green on `x86_64-pc-windows-msvc` (rustc 1.96.0):
Full lib suite: 489 passed; 0 failed; 7 ignored.
Stack
Stacks on top of #294 (Windows test/clippy hygiene). Sibling Windows-cluster PRs already open: #296 (#284.5), #297 (#247.4), #298 (#284.1), #300 (#284.2), #301 (#284.3). This rounds out the Willard #284 cluster + #247.4 from saffron's hand-off.
Test plan
🤖 Generated with Claude Code