Repository navigation
fix(airc): rename propagates to sibling scopes; cmd_send --internal flag (#179) - #183
Conversation
…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]>
There was a problem hiding this comment.
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_nameto updateconfig.jsonname via a quoting-safe Python CLI. - Update
cmd_renameto support a--no-propagaterecursion guard and propagate renames to sibling scopes before broadcasting. - Add
cmd_send --internalso 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.
| """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 |
There was a problem hiding this comment.
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.
| [ -z "$target_room" ] && die "Usage: airc send --room <name> <message>" | ||
| shift 2 ;; | ||
| --internal) | ||
| internal=1 | ||
| shift ;; |
There was a problem hiding this comment.
--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).
| 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 |
There was a problem hiding this comment.
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.
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_sendmay die() (exit 1) when the scope's monitor is down, so a broadcast failure can't prevent propagation if propagation runs first.--internalflag for informational broadcasts ([rename], etc). When the monitor is down,--internalcallers append to the local log and return 0 instead of die()ing. The monitor-down die is appropriate UX for explicitairc send(surfaces "you're broadcasting to nobody"), but wrong for[rename]— receivers heal viamonitor_formatter's host-fallback on next traffic regardless.--no-propagateflag (wasAIRC_RENAME_NO_PROPAGATEenv var). Plus newairc_core.config set_namereplaces the inline-Python heredoc that was quoting-fragile. All params are now--flagform, consistent with the rest of the airc CLI surface (README convention).Test plan
--no-propagateguard prevents recursion--help, missing name, unknown flag UX🤖 Generated with Claude Code