Skip to content

feat(rooms): persist /part across reboots (closes #136) - #138

Merged
joelteply merged 1 commit into
canaryfrom
feat/persist-subscribed-rooms
Apr 27, 2026
Merged

joelteply merged 1 commit into
canaryfrom
feat/persist-subscribed-rooms

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Bug

`airc part #general` was session-only. Next `airc join` auto-respawned the sidecar — your /part was useless. The substrate replayed the same noise after every reboot or teardown, which is exactly what AI agents can't drift past on their own.

Fix

  • `cmd_part` records the parted room into the primary scope's `parted_rooms` list. Single source of truth even when /part is invoked from a sidecar scope — `_primary_scope_for` strips the trailing `.` suffix to find the parent.
  • `spawn_general_sidecar_if_wanted` reads `parted_rooms` on bootstrap. If "general" is in the list, skips spawn with a "previously parted" notice (no silent skip).
  • New `airc join --general` flag: explicit re-opt-in. Clears "general" from `parted_rooms` and forces `general_sidecar=1` (overrides `AIRC_GENERAL_SIDECAR` recursion guard / `AIRC_NO_GENERAL` env). Symmetric inverse of `--no-general`.

Override hierarchy (deliberate)

Mechanism Persisted? Effect
`/part #general` yes writes parted_rooms
`airc join --general` yes clears parted_rooms
`--no-general` flag no (session) skips spawn this run only
`AIRC_NO_GENERAL=1` env no (session) same as flag
`AIRC_GENERAL_SIDECAR=1` no (session) recursion guard inside sidecar

Why session-only opt-outs DON'T touch parted_rooms: test harnesses set `AIRC_NO_GENERAL=1` to suppress sidecar noise during runs — they shouldn't accidentally persist the choice into the user's real config.

Test (`scenario_part_persists`, 8 phases)

  • Phase 1: primary + sidecar both up, parted_rooms empty
  • Phase 2: /part writes "general" to primary's parted_rooms
  • Phase 3: re-bootstrap respects parted_rooms (sidecar does NOT respawn) + "previously parted" notice surfaces
  • Phase 4: `--general` round-trip clears parted_rooms and respawns sidecar

Adjacent: `part_keeps_sidecar` (6/6) + `general_sidecar_default` (12/12), no regressions.

Future-ready for #137

`parted_rooms` is a list, not a single bool, so per-repo / per-org sidecars (issue #137) can use the same mechanism without schema migration.

Pre-fix: airc part #general left the lobby for the session, but the
next airc join auto-respawned the sidecar — your /part was useless.
The substrate replayed the same noise after every reboot or teardown,
which is exactly the case AI agents can't drift past on their own.

Post-fix: cmd_part records the parted room into the PRIMARY scope's
parted_rooms list (single source of truth, even when /part runs from
a sidecar scope — _primary_scope_for resolves the parent). On bootstrap,
spawn_general_sidecar_if_wanted reads parted_rooms and skips spawn for
any room in it, with a "previously parted" notice so the skip isn't
silent.

New explicit re-opt-in: airc join --general clears "general" from
parted_rooms and forces sidecar=1 (overrides AIRC_GENERAL_SIDECAR /
AIRC_NO_GENERAL session env). Symmetric inverse of --no-general.

Override knobs (--no-general, AIRC_NO_GENERAL=1, AIRC_GENERAL_SIDECAR=1
recursion guard) are session-only and DO NOT touch parted_rooms — only
explicit /part persists. This preserves test-harness ergonomics
(AIRC_NO_GENERAL=1 in CI doesn't accidentally write parted state).

Future-ready for issue #137: parted_rooms is a list, not a single bool,
so per-repo / per-org sidecars can use the same mechanism without
schema migration.

Test scenario_part_persists exercises the full cycle:
  Phase 1: primary + sidecar both up, parted_rooms empty
  Phase 2: /part writes "general" to primary parted_rooms
  Phase 3: bootstrap honors parted_rooms (sidecar does NOT respawn)
  Phase 4: --general clears parted_rooms (round-trip works)

Adjacent: part_keeps_sidecar (6/6) + general_sidecar_default (12/12)
no regressions.
Copilot AI review requested due to automatic review settings April 27, 2026 15:16
@joelteply
joelteply merged commit 750c3da into canary Apr 27, 2026
1 check passed
@joelteply
joelteply deleted the feat/persist-subscribed-rooms branch April 27, 2026 15:16

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

Adds persistence for /part #general so that leaving the lobby remains effective across reboots/teardowns, and provides an explicit --general re-opt-in path.

Changes:

  • Persist sidecar /part state in the primary scope config via a parted_rooms list.
  • Skip auto-spawning the #general sidecar when general is listed in parted_rooms, with a user-visible notice.
  • Add an integration test scenario validating persistence + --general round-trip behavior.

Reviewed changes

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

File Description
airc Adds parted_rooms read/write helpers, persists /part into primary config, honors it during #general sidecar bootstrap, and adds --general re-opt-in behavior.
test/integration.sh Adds scenario_part_persists and wires it into the test runner to validate the new persistence and re-opt-in semantics.

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

Comment thread airc
Comment on lines +1785 to +1791
# scope and force the sidecar back on. Done after arg parsing so we
# know AIRC_WRITE_DIR (set by ensure_init below) is meaningful — but
# we have to wait for ensure_init to run, since --general can be
# called before any prior init. The cleanup happens via a deferred
# check in spawn_general_sidecar_if_wanted: since _clear_parted_room
# is idempotent, we can call it eagerly here when config exists, and
# also force general_sidecar=1 to override any session env opt-out.

Copilot AI Apr 27, 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 for the --general re-opt-in path references waiting for ensure_init to run / AIRC_WRITE_DIR being set by ensure_init, but AIRC_WRITE_DIR is set at script startup and cmd_connect doesn’t call ensure_init in this area. Updating the comment to match the actual control flow would avoid confusion for future maintenance.

Suggested change
# scope and force the sidecar back on. Done after arg parsing so we
# know AIRC_WRITE_DIR (set by ensure_init below) is meaningful — but
# we have to wait for ensure_init to run, since --general can be
# called before any prior init. The cleanup happens via a deferred
# check in spawn_general_sidecar_if_wanted: since _clear_parted_room
# is idempotent, we can call it eagerly here when config exists, and
# also force general_sidecar=1 to override any session env opt-out.
# scope and force the sidecar back on. Done after arg parsing so all
# flags are settled before we override any session opt-out. AIRC_WRITE_DIR
# is already available here; if config exists, clear the primary scope's
# parted state for #general immediately. Since _clear_parted_room is
# idempotent, this eager cleanup is safe, and forcing general_sidecar=1
# ensures the later sidecar logic resubscribes even after a prior /part.

Copilot uses AI. Check for mistakes.
Comment thread airc
Comment on lines +948 to +952
parent=$(dirname "$scope")
self_base=$(basename "$scope")
prefix=$(printf '%s' "$self_base" | sed -E 's/\.[a-z0-9-]+$//')
if [ "$prefix" = "$self_base" ]; then
# Already primary — no trailing .<word> suffix to strip.

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

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

_primary_scope_for strips any trailing "." from the scope basename. If someone sets AIRC_HOME to a primary scope whose basename itself contains a dot (e.g. /tmp/airc.dev), this will incorrectly treat it as a sidecar and compute the wrong “primary” path, causing parted_rooms writes/clears to hit the wrong config.json. Consider only stripping known sidecar suffixes (currently ".general"), or verify the stripped directory is actually the primary (e.g. has config.json) before rewriting the path.

Copilot uses AI. Check for mistakes.
Comment thread test/integration.sh
Comment on lines +2489 to +2493
# Wait a couple seconds for any stray sidecar spawn before asserting.
sleep 2
[ ! -f "${home1}.general/airc.pid" ] \
&& pass "phase 3: sidecar does NOT auto-respawn (parted_rooms honored)" \
|| fail "phase 3: sidecar respawned despite /part persistence"

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

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

In phase 3 the test only sleeps 2s before asserting the sidecar pidfile does not exist. Phase 1 waits up to 8s for the sidecar pidfile to appear, so a slow sidecar start could slip past this check (false pass) or make the test flaky. Prefer waiting the same max window and failing immediately if ${home1}.general/airc.pid appears during it, then assert it’s still absent at the end.

Suggested change
# Wait a couple seconds for any stray sidecar spawn before asserting.
sleep 2
[ ! -f "${home1}.general/airc.pid" ] \
&& pass "phase 3: sidecar does NOT auto-respawn (parted_rooms honored)" \
|| fail "phase 3: sidecar respawned despite /part persistence"
# Watch the same max startup window used elsewhere and fail immediately
# if the sidecar pidfile appears at any point.
local sidecar_respawned=0
for i in 1 2 3 4 5 6 7 8; do
sleep 1
if [ -f "${home1}.general/airc.pid" ]; then
sidecar_respawned=1
fail "phase 3: sidecar respawned despite /part persistence"
break
fi
done
if [ "$sidecar_respawned" -eq 0 ]; then
[ ! -f "${home1}.general/airc.pid" ] \
&& pass "phase 3: sidecar does NOT auto-respawn (parted_rooms honored)" \
|| fail "phase 3: sidecar respawned despite /part persistence"
fi

Copilot uses AI. Check for mistakes.
joelteply added a commit that referenced this pull request Apr 27, 2026
…143)

chore(readme,skills): bring docs to spec for canary→main

README updates:
- Integration suite count: 88 assertions / 11 scenarios → ~245 / 32
- Core Commands: add `airc msg --room <name>` (sibling-room send) and
  `airc away` / `airc back` (IRC /away alias)
- Default Rooms: document /part stickiness (parted_rooms persists in
  primary scope's config) and `airc join --general` re-opt-in flag
- Skills table: add /whois, /away, /kick rows so the table covers
  every IRC verb in the IRC↔airc table (no more "documented in table,
  missing from skills")

New skills (install.sh auto-symlinks; no installer changes):
- skills/away/SKILL.md — IRC /away alias for status set/clear
- skills/whois/SKILL.md — identity lookup + cross-scope walk note
- skills/kick/SKILL.md — host-only peer eviction with SSH key drop

Why now: vhsm and continuum drove the IRC-table audit through QA.
README and skills were the last surfaces still claiming the
pre-#122/#138/#139 shape. Closing the gap before promoting canary
to main so the merged tree presents a coherent story.
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