Skip to content

fix(bearer): pull LocalBearer from resolver — silent-loss class fix - #296

Merged
joelteply merged 1 commit into
canaryfrom
fix-localbearer-silent-loss
Apr 29, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix-localbearer-silent-loss

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Caught in production on canary 2026-04-29: every joiner-side broadcast was vanishing. `airc msg --room general` from a joiner returned success banner, landed in local audit log, but the room gist was never updated — peers polling the gist saw nothing for hours.

Root cause: `bearer_resolver.resolve()` picked LocalBearer for any peer whose `remote_home` was a writable local directory. LocalBearer's send appended directly to `/messages.jsonl` and returned `{"kind":"delivered"}` — correct in the SSH-tail era when joiners tailed the host's file, wrong post-3c when the gist is the substrate.

Fix: remove LocalBearer from `_REGISTRY`. Everyone (including same-machine peers) routes through GhBearer. Latency goes from ~10ms to ~1-2s for same-machine peers — imperceptible at chat pace, vastly better than silent loss. LocalBearer the class stays on disk for possible revival as a gh-aware variant.

Coverage

  • `test_bearer.py`: `ResolverOrderTests` now asserts loopback peers without `room_gist_id` raise `PeerUnreachable` (regression guard); `available_kinds()` is `['gh']` only.
  • `integration.sh` `scenario_bearer_local`: asserts resolver registry no longer contains LocalBearer + resolver does NOT route loopback peers to it. Bearer-class tests now use direct construction.
  • 62/62 `test_bearer.py` unit tests pass.

Test plan

  • Joiner runs `airc msg --room general "ping"` — message appears in the gist (verifiable via `gh api gists/`)
  • Same-machine peer with no `room_gist_id` in their config gets a clear `PeerUnreachable` rather than silent success
  • Existing `scenario_bearer_gh` still passes (GhBearer round-trip unaffected)

Caught in production on canary 2026-04-29: AI peers reported "all
broadcasts succeeded but nobody saw anything." Investigation showed
that `airc msg --room general` from a joiner returned exit 0 + the
"→ #general (broadcast)" success banner, the message landed in the
sender's local messages.jsonl mirror, but the gist (which every other
peer polls) was never updated. Several rounds of broadcasts to
#general from authenticator-448f and continuum-b741 vanished into a
black hole.

Root cause: bearer_resolver picked LocalBearer for any peer whose
remote_home was a writable directory on this filesystem. LocalBearer's
send appended the wire envelope to `<host>/messages.jsonl` directly
and returned `{"kind":"delivered"}` because the file write succeeded.
That premise was correct in the SSH-tail era (joiners tailed the
host's local file, so writing there reached them). Post-3c the
substrate is the room gist; nobody reads the host's local file
anymore. The bearer was reporting delivered against the wrong
destination.

Fix: remove LocalBearer from _REGISTRY. The gist becomes the single
source of truth for sends, regardless of locality. Latency cost for
same-machine peers goes from ~10ms to ~1-2s (gh polling cadence) —
imperceptible at chat pace, vastly better than silent loss. The
LocalBearer class stays on disk in case we revive a gh-aware variant
that ALSO writes to the gist.

Coverage:
- Updated test_bearer.py: ResolverOrderTests now asserts loopback peers
  WITHOUT a room_gist_id raise PeerUnreachable (regression guard
  against re-introducing the silent-loss path), and a loopback peer
  WITH room_gist_id resolves to GhBearer.
- ResolverPostPhase3cPlusTests asserts available_kinds() == ['gh'].
- scenario_bearer_local in integration.sh now asserts the resolver
  registry no longer contains LocalBearer + the resolver does NOT
  route loopback peers to it; bearer-class tests use direct
  construction.

This fixes the "I don't see them responding, uh oh" observation Joel
reported 2026-04-29: peers weren't frozen, my broadcasts simply
weren't reaching them.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings April 29, 2026 07:10
@joelteply
joelteply merged commit 8f20e1c into canary Apr 29, 2026
6 checks passed
@joelteply
joelteply deleted the fix-localbearer-silent-loss branch April 29, 2026 07:10

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.

Pull request overview

This PR fixes a production silent-message-loss issue by preventing bearer_resolver.resolve() from selecting LocalBearer for loopback/same-machine peers, ensuring messages are routed via gist-backed GhBearer (the post-3c substrate).

Changes:

  • Remove LocalBearer from bearer_resolver’s registered transports, leaving GhBearer as the sole resolver candidate.
  • Update unit tests to assert only gh is available and loopback peers without room_gist_id raise PeerUnreachable.
  • Update integration coverage to ensure the resolver registry no longer contains local while still smoke-testing LocalBearer via direct construction.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
lib/airc_core/bearer_resolver.py Drops LocalBearer import/registry entry; documents the silent-loss rationale.
test/test_bearer.py Updates resolver/registry expectations and adds regression guards for loopback-without-gist.
test/integration.sh Adjusts scenario_bearer_local to assert resolver opt-out + keeps direct LocalBearer smoke tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/integration.sh

local _lib_dir; _lib_dir="$(cd "$(dirname "$AIRC")/lib" && pwd)"
local fake_home; fake_home=$(mktemp -d -t airc-it-bl-home.XXXXXX)
local off_file; off_file="$fake_home/monitor_offset"

Copilot AI Apr 29, 2026

Copy link

Choose a reason for hiding this comment

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

off_file is defined but never used in this scenario. Consider removing it to keep the scenario focused (or wire it into the LocalBearer recv test if it’s meant to exercise offset tracking).

Suggested change
local off_file; off_file="$fake_home/monitor_offset"

Copilot uses AI. Check for mistakes.
Comment on lines 46 to 47
# Preference order. Earlier = preferred. The resolver tries each in turn
# via can_serve() and falls through on PeerUnreachable from open().

Copilot AI Apr 29, 2026

Copy link

Choose a reason for hiding this comment

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

The comment says the resolver "falls through on PeerUnreachable from open()", but resolve() never calls open() (it returns an unopened bearer) and it also doesn’t attempt sequential open() fallthrough. Please update this comment to reflect the current behavior (or explicitly note that open()-fallthrough is a future enhancement).

Suggested change
# Preference order. Earlier = preferred. The resolver tries each in turn
# via can_serve() and falls through on PeerUnreachable from open().
# Preference order. Earlier = preferred. The resolver checks each bearer
# via can_serve() in order and returns the first matching bearer
# unopened. It does not currently attempt open() here or fall through on
# PeerUnreachable from open(); that remains a future enhancement.

Copilot uses AI. Check for mistakes.
joelteply added a commit that referenced this pull request Apr 29, 2026
- bearer_gh.send docstring updated to match verify-after-write +
  409-retry implementation (prior text described removed ETag/If-Match path)
- monitor_formatter: 'AEAD auth failed' → 'unwrap failed (key mismatch,
  tampered, or malformed envelope)' since unwrap_envelope returns None
  for any failure mode, not just AEAD auth
- cmd_send.sh: stop swallowing bearer_cli send stderr (CLAUDE.md
  'never swallow' — was 2>/dev/null on the joiner outcome capture)
- README + SKILL.md: correct overstated 'end-to-end encrypted' framing
  (DMs are; broadcasts go plaintext on the gist) and remove stale
  same-machine LocalBearer claims (pulled #296)

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request Apr 29, 2026