Skip to content

Claude session owns bridge lifetime; Monitor is a replaceable reader - #1950

Merged
trissim merged 4 commits into
mainfrom
fix/claude-session-bridge
Oct 20, 2026
Merged

trissim merged 4 commits into
mainfrom
fix/claude-session-bridge

Conversation

@trissim

@trissim trissim commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

P233 — session-owned Claude bridge

Review head: 2dd8bac.

The Claude process owns the bridge and its registered endpoint. Monitor processes are replaceable readers. Killing a reader during /compact no longer retires the bridge. Presence remains Connected; this does not add a separate compaction backend, status or UI.

Ownership and reconciliation

  • MonitorService owns the session socket and request lifetime through asyncio streams. NoReader, UnreadyReader and AttachedReader own detached, unproven and proven delivery behavior; MonitorAttachment exists only after attachment.
  • A replacement must supply its fresh transcript probe before an unattempted message is recorded or emitted. Emitted/UNKNOWN attempts remain in the existing delivery journal without replay.
  • The Claude process incarnation is verified against the hook's session and actual OS ancestry. SessionEnd from a stale incarnation is refused. Process-exit observation releases the endpoint even after SIGKILL.
  • Rebased onto d27ff3859, preserving main's Operation.execute, declaration-driven FieldCodec arguments, TimestampedWire validation, P277 PeerSync hook, P285 directive entry and ClaudeHook warnings. Serve.transcript uses the existing PathText codec.
  • Saved watch commands are decoded into tuples before constructing the frozen WatchRecord; no post-construction frozen-field mutation remains. Startup calls the existing ParentedProcess.alive() method rather than testing its bound method as a boolean.
  • Existing Claude/manual compaction owners remain unchanged. Represent Claude compaction as connected bridge presence #1921 was closed without merging; its separate compaction UI/status/hooks are not included here. No product probe script or tools change is included.

Verification on this exact head

26 passed, 0 failed, one existing pytest configuration warning. Run in the background under timeout 300:

tests/test_session_bridge.py
tests/test_watch_guard.py
tests/test_monitor_delivery.py
tests/test_registration_process_identity.py

The source-first census used the existing NRA ModuleSyntaxIndex over 12 related files for the published implementation and current-main reconciliation, with zero parse omissions. It covers the operation, transport, process, hook and reader owners and their consumers. Async callbacks, Pydantic union construction and external hook invocation remain dynamic-resolution limits; the actual application proof below exercises them.

Separate full source/tools ratchets, pinned to comparison main 15ba6ed and this exact head:

--root src:   rc=1; introduced={}; sole positive delta: SourceLines +562
--root tools: rc=0; introduced={}; no positive deltas

Line growth is disclosed, not treated as a defect or hidden with a budget trailer. These are not checks against the subsequently advanced main.

Actual configured Claude proof

Fresh private bus/session, real Claude provider and Monitor tool, real startup/PreCompact/compact/SessionEnd hooks, and actual transcript. Final proof exited 0:

session bridge PID                           686058
Monitor killed during /compact               687218
bridge stayed Connected, same PID            686058
message retained without an attempt           08f14cc01c57, 17 seconds detached
replacement fresh probe                      observed
actual delivery confirmation record          4cf4ee94-c8bc-4d9f-a330-a751fcfa0ddc
matching delivery in actual transcript        exactly 1
SessionEnd                                   retired original bridge
resumed session                              literal RESUMED answer
stale-incarnation SessionEnd                  refused
resumed Claude SIGKILL                        released bridge registration

Original sessions and uncertain inputs were not replayed. The proof used a new isolated session and did not modify live installation or global hook settings. All owned proof processes exited.

Receipts under /home/ts/.cache/agent-scratch/pi-bridge-compact/P233/: final-tests.log, final-ratchet-{src,tools}.log, current-live-02.log, current-live-02/events.jsonl, and current-rebase-{published,current-main}-source.json.

Remaining limits and handoff

  • The historical ordered grep still matches main's unchanged registration.py use of entry_if_present; its expected-zero result is not claimed. The newer commander instruction (5167) requests marking this PR ready.
  • GitHub reports MERGEABLE / BEHIND. Newer-main integration and fresh-environment practice installation remain merger work; these checks do not establish installed acceptance.
  • P205's separate managed-input integration must await transport writes and retain uncertain attempts; it is not delivered by this PR.

Assumed:

  • The merger owns current-main integration, practice installation, paired-runtime publication and installed acceptance.
  • Existing session identity, process incarnation, registered endpoint and transcript remain authoritative; Monitor termination only replaces the reader.
  • Ready means ready for review, not merged, installed or accepted in production.

Agent-Comms-Order: 4da91cc38c5d

@trissim
trissim force-pushed the fix/claude-session-bridge branch from 3a4b556 to d6e7cd6 Compare October 20, 2026 01:50
@trissim
trissim force-pushed the fix/claude-session-bridge branch from c3afa79 to 16a6d2a Compare October 20, 2026 01:55
@trissim
trissim marked this pull request as ready for review October 20, 2026 03:08
Copilot AI balanced review requested due to automatic review settings October 20, 2026 03:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@trissim
trissim merged commit 076adf0 into main Oct 20, 2026
0 of 4 checks passed
trissim added a commit that referenced this pull request Oct 20, 2026
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