Skip to content

fix(airc): rename propagates to sibling scopes; cmd_send --internal flag (#179) - #183

Merged
joelteply merged 1 commit into
canaryfrom
fix/airc-rename-propagate-to-sidecars
Apr 28, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/airc-rename-propagate-to-sidecars

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Fixes #179 — vhsm-d1f4 + ideem-local-4bef caught 2026-04-28 that nick rename only updated the current scope's config, leaving sidecars to broadcast under the OLD name. Skill section 0 promises "the visible nick is shared across both rooms"; this enforces that.

Three entangled fixes:

  • cmd_rename writes the new name to ALL scopes' config.json (primary + sidecars). Reorder so config writes happen BEFORE the broadcast — cmd_send may die() (exit 1) when the scope's monitor is down, so a broadcast failure can't prevent propagation if propagation runs first.
  • cmd_send takes a new --internal flag for informational broadcasts ([rename], etc). When the monitor is down, --internal callers append to the local log and return 0 instead of die()ing. The monitor-down die is appropriate UX for explicit airc send (surfaces "you're broadcasting to nobody"), but wrong for [rename] — receivers heal via monitor_formatter's host-fallback on next traffic regardless.
  • Recursion guard moves to a --no-propagate flag (was AIRC_RENAME_NO_PROPAGATE env var). Plus new airc_core.config set_name replaces the inline-Python heredoc that was quoting-fragile. All params are now --flag form, consistent with the rest of the airc CLI surface (README convention).

Test plan

  • Local fixture: primary → 2 sidecars propagation
  • Local fixture: sidecar → primary + sibling sidecar propagation
  • Local fixture: --no-propagate guard prevents recursion
  • Local fixture: --help, missing name, unknown flag UX
  • Local fixture: best-effort log appended in all scopes when monitors down
  • Integration suite: same 3 pre-existing flakes as canary, no regressions (180 → 181 passing on my branch)

🤖 Generated with Claude Code

…lag (#179)

Three entangled fixes for the multi-scope rename bug filed by vhsm-d1f4
+ ideem-local-4bef on 2026-04-28:

1. cmd_rename now writes the new name to ALL scopes' config.json
   (primary + sidecars), not just the current scope. Reorder so config
   writes happen BEFORE the broadcast: cmd_send may die() (exit 1) when
   the scope's monitor is down, so a broadcast failure can't prevent
   propagation if propagation runs first.

2. cmd_send takes a new --internal flag for informational broadcasts
   ([rename], etc). When the monitor is down, --internal callers append
   to the local log and return 0 instead of die()ing. The monitor-down
   die is appropriate UX for explicit `airc send` (surfaces "you're
   broadcasting to nobody"), but wrong for [rename] — receivers heal
   via monitor_formatter's host-fallback on next traffic regardless.

3. cmd_rename's recursion guard moves from AIRC_RENAME_NO_PROPAGATE env
   var to a --no-propagate flag. Plus a new airc_core.config set_name
   subcommand replaces the inline-Python heredoc that was quoting-
   fragile. All params are now --flag form, consistent with the rest
   of the airc CLI surface (per README convention).

Test fixture verifies: primary→sidecars, sidecar→primary, three-scope
fan-out, --no-propagate guard, --help/missing-name UX. Integration
suite passes — same 3 pre-existing flakes as canary, no regressions
(180→181 passing).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings April 28, 2026 00:45
@joelteply
joelteply merged commit 9c08ce4 into canary Apr 28, 2026
3 checks passed
@joelteply
joelteply deleted the fix/airc-rename-propagate-to-sidecars branch April 28, 2026 00:46

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 #179 by ensuring airc rename updates the identity name across the primary scope and all sibling sidecar scopes, and introduces a best-effort internal-send mode so informational broadcasts (like [rename]) don’t hard-fail when a scope monitor is down.

Changes:

  • Add airc_core.config set_name to update config.json name via a quoting-safe Python CLI.
  • Update cmd_rename to support a --no-propagate recursion guard and propagate renames to sibling scopes before broadcasting.
  • Add cmd_send --internal so monitor-down cases append locally and return success for internal informational broadcasts.

Reviewed changes

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

File Description
lib/airc_core/config.py Adds set_name subcommand used by rename propagation to update config.json name without fragile inline-Python heredocs.
airc Implements rename propagation across sibling scopes, reorders rename phases (write → propagate → broadcast), and adds cmd_send --internal behavior for monitor-down cases.

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

Comment thread lib/airc_core/config.py
Comment on lines +48 to +67
"""Atomically write the identity name into config.json.

Replaces the inline-Python heredoc that lived in cmd_rename. With
multi-scope rename propagation (#179), cmd_rename writes the name
into the primary scope AND every sidecar scope's config; doing it
via a single CLI call per scope keeps the write quoting-safe (the
heredoc inlined `$new_name` into a python string literal which
would have broken on names containing single quotes — fortunately
the rename sanitizer only allows [a-z0-9-] today, but the heredoc
pattern was a sharp edge).
"""
try:
c = json.load(open(args.config))
except (OSError, ValueError) as e:
print(f"airc-config-set-error: cannot read {args.config}: {e}", file=sys.stderr)
return 1
c["name"] = args.name
try:
json.dump(c, open(args.config, "w"), indent=2)
return 0

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

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

cmd_set_name claims to write the config "atomically", but the implementation truncates and rewrites args.config in place (open(..., "w")). If the process is interrupted mid-write, config.json can be left partially written/corrupt. Consider writing to a temp file in the same directory and os.replace() it into place (and use with open(...) for both read/write) so the update is truly atomic on POSIX/Windows.

Copilot uses AI. Check for mistakes.
Comment thread airc
Comment on lines 3444 to +3448
[ -z "$target_room" ] && die "Usage: airc send --room <name> <message>"
shift 2 ;;
--internal)
internal=1
shift ;;

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

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

--internal is parsed and stored in a local variable, but if --room triggers the re-exec path, the exec only forwards positional args ("$@") and drops --internal. That means airc send --room X --internal ... (or any internal caller using --room) will lose the best-effort semantics in the target scope and can still die on monitor-down. Consider preserving --internal across the re-exec (e.g., include it in the exec argv when internal=1, or propagate via an env var).

Copilot uses AI. Check for mistakes.
Comment thread airc
Comment on lines +2897 to +2916
if [ "$no_propagate" != "1" ]; then
local _primary _parent _primary_base _sibling
_primary=$(_primary_scope_for "$AIRC_WRITE_DIR")
_parent=$(dirname "$_primary")
_primary_base=$(basename "$_primary")
# Glob all sibling sidecars (named <primary>.<room>) — does NOT
# match the primary itself (which has no trailing `.<room>`).
for _sibling in "$_parent/$_primary_base".*; do
[ -d "$_sibling" ] || continue
[ -f "$_sibling/config.json" ] || continue
[ "$_sibling" = "$AIRC_WRITE_DIR" ] && continue
AIRC_HOME="$_sibling" "$0" rename --no-propagate "$new_name" \
|| echo " warn: rename propagation to $_sibling failed (exit $?)" >&2
done
# If WE are a sidecar (current scope != primary), also rename the
# primary scope.
if [ "$AIRC_WRITE_DIR" != "$_primary" ] && [ -f "$_primary/config.json" ]; then
AIRC_HOME="$_primary" "$0" rename --no-propagate "$new_name" \
|| echo " warn: rename propagation to primary $_primary failed (exit $?)" >&2
fi

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

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

The new sibling-scope propagation logic in cmd_rename (updating all .airc.<room> configs + the primary) is a key behavior change for #179, but the repo’s existing integration tests only exercise single-scope rename. Adding an integration scenario that creates a primary + at least one sidecar and asserts that a rename in either scope updates all sibling config.json files (and does not recurse infinitely) would prevent regressions.

Copilot uses AI. Check for mistakes.
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