Repository navigation
AIRC: session-scoped identity, port override, rename, doctor, teardown, tests - #2
Merged
Merged
Conversation
Adds per-instance scope so multiple Claude tabs on one machine can peer without identity collision. Skills default AGENT_RELAY_HOME=$PWD/.agent-relay so state lives with the project and resumes on re-invoke. Core changes to relay binary: - resolve_name() helper: AGENT_RELAY_NAME env > config.json name > cwd basename > hostname - remote_home() helper: reads host_relay_home from config (fallback ~/.agent-relay) - cmd_rename: updates config.json, broadcasts [rename] marker to paired peers - monitor loop: handles inbound [rename] markers, renames local peer files - Pairing exchange now includes relay_home on both sides, stored in peer records - All hardcoded ~/.agent-relay/messages.jsonl (5 sites) -> $rhome/messages.jsonl - Joiner now saves host as a peer (gap in v1; send to host-name now works) Skill changes: - relay:connect defaults AGENT_RELAY_HOME=$PWD/.agent-relay, auto-gitignores it - relay:send uses same project-scoped prefix - Both skills document rename + identity resolution order Backwards compatible: peers without relay_home fall back to ~/.agent-relay, so rolling upgrade across a mesh works one peer at a time. test-two-instance.sh: tmux-runnable round-trip validator (host/join/verify modes).
Port override:
- AGENT_RELAY_PORT env var selects listen port (default 7547)
- Join string format: name@user@host[:port]#pubkey, :port only when non-default
- Lets two hosts coexist on one machine
Two-tier file resolver:
- HOME_TIER: $HOME/.agent-relay (machine default, vanilla)
- LOCAL_TIER: $PWD/.agent-relay (opt-in by creating the directory)
- AGENT_RELAY_HOME collapses both to one explicit path
- relay_path <sub>: returns effective file path (local wins where exists,
home fills in, new writes land local if opted in)
- relay_list <subdir>: union listing deduped by name, local first
- All consumers of CONFIG/PEERS_DIR/MESSAGES/IDENTITY_DIR updated
Backwards compatible by construction: no $PWD/.agent-relay/ means
LOCAL_TIER="", every resolver falls through to home. Identical to vanilla.
Skills now parse flags so callers don't hand-wire env prefixes every time: /relay:connect [join] [--name=X] [--home=PATH] [--port=N] [--scope=home|local] /relay:send [peer] <msg> [--home=PATH] /relay:rename <new-name> [--home=PATH] Each flag maps to the env var it fronts. Unset flags = vanilla defaults. --scope=local is a shorthand for --home=$PWD/.agent-relay (per-project identity). rename is a new skill — wraps the relay binary's cmd_rename (added in the session-scope commit) so peer-name collisions are fixable post-hoc.
Binary, skills, state, env vars, URLs all rebranded. relay → airc AGENT_RELAY_HOME → AIRC_HOME AGENT_RELAY_NAME → AIRC_NAME AGENT_RELAY_PORT → AIRC_PORT ~/.agent-relay/ → ~/.airc/ ~/.agent-relay-src/ → ~/.airc-src/ skill name: relay:* → skill name: airc:* slash command /relay:* → /airc:* github.com/.../agent-relay → github.com/.../airc README rewritten with the IRC analogy, "remote desktop for Claude" framing, Toby-style onboarding story, and a roadmap (short join codes, URL scheme, channels, mDNS discovery, QR pairing). No backwards-compat shim — fresh install, fresh pair. The old agent-relay repo remains for anyone still on the previous install.
…N name field Rename residue: RELAY_HOME (bash var) → AIRC_WRITE_DIR relay_home (JSON field in peer records + config) → airc_home host_relay_home → host_airc_home Bug fix: [rename] monitor handler now updates the 'name' field inside the renamed peer JSON, not just the filename. Without this, `airc peers` kept showing the old name even after the file was moved. Integration test (from test-two-instance.sh run 6/6 pass criteria): ✓ host on non-default port (AIRC_PORT=7548) ✓ :port round-trips in join string ✓ pair establishes, peer records written with airc_home populated ✓ send (joiner → host) delivers through monitor ✓ send (host → joiner) delivers through monitor ✓ rename on host propagates: [rename] marker → peer file renamed → airc peers shows new name
Two new first-class commands:
airc doctor [tabs|scope|all] — self-test: runs test/integration.sh.
Validates pairing, send both directions,
monitor correctness, rename propagation,
and the two-tier .airc/ scope resolver.
airc teardown [--flush] — kill all local airc processes (airc connect,
airc monitor, their Python listener children),
free port 7547/7548. --flush also wipes
state. Aliases: `airc stop`, `airc flush`.
Integration test (test/integration.sh):
- tabs host/join/send bidirectionally/rename on one machine, different ports
- scope home-tier default, $PWD/.airc opt-in, local shadows home on collision
- teardown teardown kills host + frees port, preserves state without --flush
Test cleanup now uses `airc teardown` itself (dogfood — if teardown breaks,
the test notices in its own cleanup path).
Skills added:
/airc:doctor wraps `airc doctor`
/airc:teardown wraps `airc teardown` (also /airc:stop, /airc:flush when added)
Bug fix in rename handler: when [rename] marker arrives, also update the
'name' field inside the renamed peer JSON. Before this, `airc peers` kept
showing the old name even after the peer file was moved.
Migration:
On first invocation, if AIRC_HOME is not set AND $HOME/.airc doesn't exist
AND $HOME/.agent-relay does, we mv the old dir into place. One-time, silent
when not applicable. Preserves identity, peers, messages, reminder state —
no re-pair needed for anyone on the pre-rename setup.
Test harness:
- Removed the race-prone immediate peer-file check (fs writes trailed the
"Connected to" log line; the later send + rename assertions already prove
peer-record correctness transitively).
- Added two end-of-scenario invariants that close the coverage gap:
* "peer record for renamed peer is on disk" (survives rename + fs sync)
* "peer record has non-empty airc_home" (proves the handshake's
host_airc_home round-trip populated the joiner's peer record,
which is what remote_home() depends on for correct send routing)
- Test cleanup now uses `airc teardown` itself (dogfood).
Before/after: 11/13 → 21/21.
Running monitors / `tail -F` / scripts still pointing at the old path keep working after the mv, because we leave `~/.agent-relay → ~/.airc` behind. Surfaced by M5-Claude's session: their background Monitor tool was tailing ~/.agent-relay/messages.jsonl; my previous migration broke that silently. Symlink preserves the contract. Tests: 21/21 pass (full suite: tabs 12, scope 3, teardown 5, with the added end-of-tabs peer-record + airc_home invariants).
AIRC_REMINDER=<seconds> overrides the default 300s heartbeat interval at
host start. Useful for testing (short cadence) or custom engagement cycles.
Env beats positional beats default, matching AIRC_NAME/AIRC_HOME/AIRC_PORT.
Test suite +6 assertions (all pass):
✓ AIRC_REMINDER=2 applied at host start
✓ interval persisted to state/reminder
✓ heartbeat fires within 12s of silence (tests the monitor loop's
reminder emit + the last_sent guard)
✓ reminded marker is set after firing (prevents spam)
✓ `airc reminder off` removes the reminder file
✓ `airc reminder 42` writes new interval
Full suite: 27/27 pass.
…file
Bugs surfaced during m5-claude's dogfood of the airc branch:
1) airc send returned exit 1 on benign SSH stderr warnings ("Permanently
added...") even though the remote append SUCCEEDED. Caller sees failure,
message still delivers. False-positive error.
Fix: remote side echoes __APPENDED__ on success; send checks for that
marker on stdout, not the ssh exit code.
2) airc teardown (run by airc doctor) used global pgrep patterns, killing
live peer connections in OTHER Claude tabs on the same machine. Took out
the in-progress demo with m5-claude.
Fix: cmd_connect writes its PID(s) to $AIRC_WRITE_DIR/airc.pid; teardown
reads that file and kills ONLY those PIDs + direct descendants (python
listener children). Other scopes on same machine untouched. After killing,
briefly sleep and reap any python listener orphaned to init as a safety net.
Test suite (28/28 pass):
+ new assertion: teardown in a different scope must NOT kill an unrelated host
+ cleanup_procs between scenarios uses airc.pid files (canonical scope markers)
instead of argv regex which misses backgrounded subshells that inherit parent argv
How m5-claude would have caught this earlier if we'd dogfooded:
send failure was a false positive — message landed, exit code lied
teardown-nukes-everything surfaced when doctor cleanup killed the demo host
Problem m5-claude-code surfaced during dogfood: a joiner's `airc send` delivers over SSH to the host's messages.jsonl, but the joiner's OWN local log stays empty. Running `airc logs` (which tails the remote via SSH and filters from=me out) shows nothing the joiner sent. Reads as "silent fail" from the user's POV, even though the message landed with a valid sig. Fix: after a successful remote append, also append the same JSON line to the joiner's local $MESSAGES. Monitor's existing self-echo filter (skips from=me) prevents double-surfacing. Now `airc logs` works as an audit trail and `tail -F ~/.airc/messages.jsonl` shows the user their own sends. Test: +1 assertion — after beta → alpha send, beta's local messages.jsonl must contain the outbound. Full suite now 29/29 pass. Surfaced by: m5-claude-code in real-time dogfood of the branch. The bug wouldn't have appeared in my solo tests because I was always checking the RECEIVER's log, never the SENDER's — the classic failure mode of "tests assert what I thought to check, not what users actually do."
…move port-kill fallback
Two real-world UX bugs in ONE root cause: the test suite was using port 7548
AND had a cleanup_procs safety-net that killed anything on 7548 running a
python socket listener. Every `airc doctor` / full-suite run silently killed
the live demo host (which was also on 7548), breaking m5-claude-code's monitor
and taking down the 3-way demo twice.
Fixes:
- Test uses port 7549 (test-reserved). Tests never touch 7547 (default) or
7548 (common second-port).
- cleanup_procs now ONLY kills by airc.pid files. No broad lsof/pkill
fallback. If a test leaks a process, that's a test bug; fix via pidfile,
never with a wider hammer.
Verified: full suite runs (29/29 pass on port 7549) with a live demo host on
7548 sitting completely untouched through the run. Host before: pid 48212.
Host after: pid 48212, same pid, same port.
Lesson: broad safety nets in test cleanup LOOK helpful but destroy live
state you didn't know about. Scope tightly, fail visibly.
…or text Bug surfaced by m5-test's real-world test: airc send-file returned "ERROR: Failed to transfer <filename>" with no detail. Root cause: scp wasn't getting the -i flag that relay_ssh passes, so it fell back to system ssh_config (~/.ssh/id_*) which doesn't exist in isolated AIRC_HOME tiers. scp auth silently failed. Fix: cmd_send_file now passes -i "$IDENTITY_DIR/ssh_key" (same key relay_ssh uses). Also captures scp stderr and includes it in the die message — "Failed to transfer X: <real scp error>" instead of silent "2>/dev/null" suppression. Test: +2 assertions in scenario_tabs (31/31 pass): - beta send-file to alpha returns OK - payload lands on host at files/<sender>/<filename>
Review pass before merge. Found and fixed:
- connect + send docs claimed send auto-picks the lone peer. That was
tried and reverted; binary now requires explicit peer. Send docs now
say "peer required", connect's "after connecting" section updated.
- doctor docs listed only tabs|scope as scenarios. Binary now has 4
(tabs/scope/reminder/teardown = 31 assertions). Also updated port ref
from 7548 to 7549 (test-reserved) and added scope-isolation failure note.
- teardown docs claimed it kills "every airc connect / airc monitor
process owned by this user" — wildly inaccurate after the scope-aware
fix. Now correctly describes PID-file-based, scope-only behavior with
the guarantee that other tabs' sessions are untouched.
- send-file docs were bare. Expanded with: --home flag, identity-key
auth (fix we landed), failure modes showing scp stderr, integrity
verification suggestion.
No binary changes. Docs align with shipped behavior as of commit e65f0aa.
Zero-silent-loss guarantee. Before this commit, if the SSH wire failed
(unreachable host, auth race, any transient), airc send exited 1 and the
outbound vanished from both sides. User had no audit trail of what they
tried to send. Surfaced during m5-test's dogfood: a design-response reply
was composed, sent via airc, and neither tab had any record afterward.
Changes:
cmd_send now writes the outbound to the local messages.jsonl FIRST,
then attempts the wire. On wire failure (SSH exit non-zero OR missing
__APPENDED__ marker on stdout), we append a {"from":"airc","msg":"[SEND
FAILED to <peer>] <scp stderr>"} line next to the mirrored outbound.
User's airc logs now always shows what they tried to send + why it
failed, and the peer name is right there for retry.
`|| true` guard on the ssh call so `set -e` doesn't abort before we
reach the failure-marker branch.
relay_ssh now sets ConnectTimeout=10 (avoids 60s hang on unreachable)
and ServerAliveInterval=30 (keeps monitor tails healthy).
Test: 2 new assertions in scenario_tabs using an unreachable 127.0.0.99
host. 33/33 pass.
Demo host on 7548 was kept alive through the test run (verified via
lsof pre + post): the scope-isolation fixes hold.
…d-rename # Conflicts: # README.md # relay
Ported from main's relay binary (commits d46df5d, 0495709): - cmd_send: pipe payload via stdin to remote cat, so apostrophes in user messages can no longer break the single-quoted echo on the wire. - cmd_peers: replace `&& echo` with `if` so the command exits 0 under set -e when peers exist. - monitor: persist last-seen line offset to monitor_offset so restarts don't replay history. On first run, skip to EOF (history is in `airc logs`). README: rewritten to describe the shipped post-rename surface — airc instead of relay, doctor/teardown commands, scope isolation guarantee, zero-silent-loss send semantics, two-tier identity, migration note.
- README: spell out "Agentic Internet Relay Chat" as the title
- integrations/{claude-code,cursor,windsurf,openai-codex,generic}:
swap relay/agent-relay references for airc, update CLI surface
(connect/send/logs/peers/monitor), mention mirror-first +
[SEND FAILED] marker semantics, point claude-code at the shipped
/airc:* skills instead of stale hook config
…s-is - New integrations/opencode/README.md mirroring the cursor/codex pattern, pointing at AGENTS.md and the bash tool. - README integrations table: add opencode row and a note that Claude Code forks (openclaw, etc) consume the existing Claude Code skills directly.
22 of 32 tasks
joelteply
added a commit
that referenced
this pull request
Apr 15, 2026
vhsm-claude's three #12 followups, in one commit: 1. **Exponential backoff on drain loop** (vhsm #1). Pre-this-commit: flush_pending_loop polled every 5s forever. A week-long outage = ~121k SSH attempts, unnecessary load on both sides and the Mac's sleep/wake cycle. Now: 5 → 10 → 30 → 60 → 120 → 300s cap, doubling per consecutive all-fail cycle. Any delivery resets to 5s (host is healthy, drain fast so new queued sends go through quickly). 2. **Pending size cap** (vhsm #2). Pre-this-commit: pending.jsonl was unbounded. Long outage + chatty user = disk-filling file of messages that may never drain. Now: default AIRC_PENDING_MAX=10000 hard cap; beyond it, cmd_send dies with "queue at cap" instead of silently appending. Warn-once at 1000 via marker file (cleared on successful drain, so re-warns if queue re-grows). 3. **Partial-drain ordering test** (vhsm #3). scenario_queue_limits seeds a known 3-message pending.jsonl and asserts the host receives them in order. Catches regressions in the cat-unsent-pending logic that preserves ordering across retries. Test infrastructure: - scenario_queue_limits: kills the joiner's monitor before mutating pending (flush loop + test races → nondeterministic counts); for ordering test, restarts the joiner's monitor with fresh backoff so drain happens within a reasonable test timeout. - Backoff timing isn't directly testable in short integration runs (would need minutes to see doublings); added source-level grep assertions so a future refactor can't silently remove the backoff mechanism. Full suite: 78/78. Refs #12 review, #7.
joelteply
added a commit
that referenced
this pull request
Apr 24, 2026
…-tests cmd_doctor was a thin exec wrapper around test/integration.sh, but /doctor SKILL.md promised "checks environment health, proactively fixes recoverable issues (install gh, etc.)." Audit fix #2 from PR #63 follow-up -- bring command up to spec. cmd_doctor (default mode) now: - Detects platform pkgmgr (brew/apt/dnf/pacman/apk). - Probes git, gh, openssl, ssh, ssh-keygen, python3 + emits exact install command for the detected pkgmgr on each [MISSING] line. - Probes gh auth status (gist scope) -- the #1 cause of "airc feels broken" silently. - Probes tailscale separately as [info] (optional, never blocks). - Reports scope + identity state. - Tail line tells the user re-running install.sh is the fastest path if multiple things are missing. Same shape as the install.ps1 winget probe pattern (Windows side already uses this for parity with the bash 'curl|sh') -- now bash behaves the same. `airc doctor --tests` (or `airc tests` / `airc test`) routes to _doctor_run_tests, which is the prior cmd_doctor body verbatim, so existing CI / muscle-memory keeps working. Dispatch updated: `doctor` -> cmd_doctor; `tests|test` -> _doctor_run_tests. SKILL.md rewritten to: (Step 1) just run `airc doctor`, act on [MISSING] lines; (Step 2) `airc doctor --tests $ARGUMENTS` for behavioral suite. The prior 30-line inline shell probes in Step 1 are gone -- they're now built into the binary. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2 of 3 tasks
joelteply
added a commit
that referenced
this pull request
Apr 25, 2026
Round 2 of Copilot review on the stale-pairing safety + winget messaging: 1. install.sh: "Installing missing prereqs via winget: <list>" was being printed even when the list contained only unmappable items (winget has no auto-install for ssh-keygen/openssl). Pre-fix, the message claimed action that didn't happen. Now: only print "Installing..." when there's an actual pkg to install; print "Missing prereqs not auto-installable" otherwise. 2. bash + ps1 stale-pairing detect: was gating only on `gh auth status` succeeding, but elsewhere in the codebase (and doctor --connect specifically) we treat "authed but no gist scope" as distinct because gh's API can return 401/403/404 inconsistently when scope is missing. Now: gate on auth-status AND gist-scope present (matching doctor --connect chain) before running the gist freshness probe. 3. bash: comment claimed "Probe with --silent" but the flag wasn't passed; the redirection was actually doing the work. Updated comment to match the actual mechanism. 4. ps1: same as #2 - mirror the gist-scope check for parity. 133/133 integration tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Apr 28, 2026
joelteply
added a commit
that referenced
this pull request
Jun 10, 2026
… (card 0fa8dc5b) 1. Rung 3: name-only TOFU forbidden — both-screen SAS (emoji/word pair) verifies key material, not an attacker-chosen mDNS name; skipped SAS = Untrusted tier with explicit promotion. 2+4. Cite e3ebce7a instead of minting a duplicate card; record the reviewer's discovery that AccountRegistryDocument.peers ALREADY carries peer_spec+endpoints (wiring, not construction); adopt the codebase's own per-writer-artifacts + reader-merge pattern instead of create-if-absent (no creation race, no clock arbitration). 3. Relay provisioning named in the unlock order: any reachable grid node qualifies (relay-by-default), tailnet interim, federated self-hostable relay ships with the rendezvous service (one deployable, two roles). Outbound-only guarantee no longer assumes infrastructure nobody owns. 5. WHICH credential defined honestly: continuum account for cross-platform households (a stated journey step), gh for dev, platform accounts only when genuinely shared; never guessed. Also fixes the sequencing inversion: e3ebce7a carriage moves into unlock #2 as the routes resolver's input feed. Co-Authored-By: Claude Fable 5 <[email protected]>
joelteply
added a commit
that referenced
this pull request
Jun 11, 2026
…#1117) * docs: ZERO-FRICTION-PATH.md — the full automation map (card 0fa8dc5b) Joel: 'we can automate everything, we have Rust at all layers.' Proof by construction: the target user journey (one command → binary → identity → pairing phrase → the grid appears), then every friction point from the 2026-06-10 5090 bring-up mapped to the Rust mechanism that deletes it, what already exists, and which card owns it. Ordered unlock sequence: release pipeline → routes (625abe6d) → self-update + continuous doctor → mDNS + same-account auto-enrol → federated user rendezvous. Automation removes ceremony, never consent or verifiability. Co-Authored-By: Claude Fable 5 <[email protected]> * docs(zero-friction): Joel correction — accounts are for SHARING only, never required for your own grid (card 0fa8dc5b) Own-grid formation is fully local: pairing phrase admits a machine, peer records gossip inside the grid, LAN discovery does the rest — zero accounts, zero cloud, works offline. gh/rendezvous enter only when crossing grids (sharing, publishing, public invites). Co-Authored-By: Claude Fable 5 <[email protected]> * docs(zero-friction): the pairing waterfall — machines pair themselves, codes are the bottom rung (card 0fa8dc5b) Joel: 'think of all the communication points and what needs to be exchanged, then make it automatic — only code passed when absolutely necessary; we were using gists for this.' The payload is a ~200-byte signed peer record; ANY already-held authenticated channel carries it. Waterfall: (1) shared authenticated store — auto, what the gists were for, airc does natively what agents did by hand tonight; (2) LAN + cached anchor — auto, offline-capable; (3) LAN, no anchor — one tap on an existing machine, nothing typed; (4) remote + nothing shared — only here does the mnemonic/QR exist. Same inventory rule extended to endpoints, rooms, presence: name the payload, ride the best existing channel, never mint credentials, never show humans tokens. Co-Authored-By: Claude Fable 5 <[email protected]> * docs(zero-friction): the anti-cheat rule — rendezvous derived from credential alone, no a-priori knowledge (card 0fa8dc5b) Joel caught the architecture cheating: tonight's bootstrap gist was manually created and its URL hand-carried — a-priori knowledge that a new repo user cannot have. Rule now normative: store location is DERIVED by convention from the credential, created-if-absent, nothing out-of-band ever. Same account = same grid automatically; tailnet only off-LAN. Uncheatable acceptance test pinned: two fresh machines, same credential, zero shared bytes, install + join → routed + delivered. Co-Authored-By: Claude Fable 5 <[email protected]> * docs(zero-friction): close the five design holes from sentinel review (card 0fa8dc5b) 1. Rung 3: name-only TOFU forbidden — both-screen SAS (emoji/word pair) verifies key material, not an attacker-chosen mDNS name; skipped SAS = Untrusted tier with explicit promotion. 2+4. Cite e3ebce7a instead of minting a duplicate card; record the reviewer's discovery that AccountRegistryDocument.peers ALREADY carries peer_spec+endpoints (wiring, not construction); adopt the codebase's own per-writer-artifacts + reader-merge pattern instead of create-if-absent (no creation race, no clock arbitration). 3. Relay provisioning named in the unlock order: any reachable grid node qualifies (relay-by-default), tailnet interim, federated self-hostable relay ships with the rendezvous service (one deployable, two roles). Outbound-only guarantee no longer assumes infrastructure nobody owns. 5. WHICH credential defined honestly: continuum account for cross-platform households (a stated journey step), gh for dev, platform accounts only when genuinely shared; never guessed. Also fixes the sequencing inversion: e3ebce7a carriage moves into unlock #2 as the routes resolver's input feed. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]>
This was referenced Jun 11, 2026
Closed
Summary
~/.airc/home + opt-in$PWD/.airc/per-project) viarelay_path/relay_listprimitivesAIRC_NAMEenv var,config.jsonoverride, cwd basename, hostname fallbackairc rename <new>with[rename]protocol marker that propagates to paired peers (auto-renames their peer record + JSONnamefield)AIRC_PORToverride +:portcarried in join string for same-machine multi-hostairc doctor [tabs|scope|reminder|teardown|all]runs the bundled integration suite (27 tests, 4 scenarios)airc teardown [--flush]kills processes, frees ports, preserves state unless--flush; aliasesstop,flushAIRC_REMINDERenv var for heartbeat cadence (default 300s)~/.agent-relay→~/.aircwith back-compat symlink (so running monitors don't break)/airc:connect,/airc:send, new/airc:rename,/airc:doctor,/airc:teardownBackwards compatible by construction: no
$PWD/.airc/⇒ vanilla single-tier behavior; no custom env vars ⇒ vanilla defaults.Test plan
airc doctor all— 27/27 pass on macOS 14 / zshairc reminder offdisables,airc reminder <n>sets new interval--flush)🤖 Generated with Claude Code