Repository navigation
fix(scope): _primary_scope_for empty-prefix guard (vhsm e2e catch on PR #144) - #150
Merged
Merged
Conversation
…g-dot-only Bug found by vhsm-d1f4 in PR #144 e2e (2026-04-27): \`airc join --general\` silently failed to clear parted_rooms after a /part. Trace: 1. cmd_part on .airc.general writes parted_rooms=['general'] to primary's config.json (works — _primary_scope_for(.airc.general) → .airc, correct). 2. airc join --general triggers _force_general_sidecar=1 in cmd_connect. 3. cmd_connect calls _primary_scope_for "$AIRC_WRITE_DIR" where AIRC_WRITE_DIR is the PRIMARY scope ('.airc'). 4. The regex 's/\.[a-z0-9-]+\$//' over-strips '.airc' (the entire basename IS one dot-segment) → prefix=''. 5. The 'is this a sidecar?' check (prefix != self_base) was true (since '' != '.airc'), so _primary_scope_for returned '<parent>/' (bogus). 6. _clear_parted_room got that bogus path, the python wrapper caught FileNotFoundError, sys.exit(0), silent no-op. Net: --general printed the same "previously parted" message every time, parted_rooms never cleared, sidecar never resubscribed. README #143 already documented "airc join --general" as THE recovery path; would have shipped broken-as-documented to main without the e2e catch. ## Fix Add empty-prefix guard: if the regex eats the entire basename, the basename was a leading-dot-only name (canonical primary scope), not a sidecar. Return self instead of the bogus parent/empty-string concat. ## Why integration tests missed it scenario_part_persists used fixture path '/tmp/airc-it-pp/state' / 'state.general'. Basename 'state' has no dots → regex no-ops → prefix=='state' == self_base → primary case. The leading-dot code path was never exercised. Real deployments use $repo/.airc — which IS leading-dot. ## Test fix Renamed scenario_part_persists fixture from 'state' → '.airc' so the basename matches production layout. Verified: - pre-fix + .airc fixture: phase 4 fails (--general didn't respawn / parted_rooms didn't clear) - post-fix + .airc fixture: 8/8 phases green The class of bug ("test fixture diverges from real layout in a way that hides a code path") is worth grepping for elsewhere — paths starting with '.' are common enough that any regex over basename should account for them.
There was a problem hiding this comment.
Pull request overview
Fixes a regression in primary-scope resolution when the scope basename is a leading-dot directory (e.g., .airc), which broke airc join --general by routing _clear_parted_room to an incorrect path and causing a silent no-op. This aligns scope handling with real-world deployment layout ($repo/.airc) and updates integration coverage to prevent recurrence.
Changes:
- Add an empty-prefix guard in
_primary_scope_forso.aircis treated as a primary scope (not a sidecar). - Update
scenario_part_persistsintegration fixture to use/tmp/airc-it-pp/.aircso the leading-dot basename code path is exercised.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
airc |
Fixes _primary_scope_for to correctly handle leading-dot primary scope basenames like .airc. |
test/integration.sh |
Adjusts the part_persists fixture path to .airc to cover the real-world layout and catch the regression. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Apr 27, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug (vhsm-d1f4 PR #144 e2e, 2026-04-27)
`airc join --general` silently no-op'd: parted_rooms stayed populated, sidecar stayed skipped, the "previously parted" notice fired every retry. README #143 documents `airc join --general` as THE re-opt-in path — would have shipped broken-as-documented if this hadn't been caught in the canary→main pre-merge e2e.
Root cause (full trace, vhsm's analysis)
`_primary_scope_for` regex `s/\.[a-z0-9-]+$//` over-strips when basename IS a leading-dot-name:
The "is this a sidecar?" check (`prefix != self_base`) was true for `.airc` (since `"" != ".airc"`), so the function returned a bogus path. Downstream `_clear_parted_room` got that path, found no config.json there, silently no-op'd via the python wrapper's FileNotFoundError → sys.exit(0).
Fix
Empty-prefix guard: if the regex eats the entire basename, the basename was a leading-dot-only name (canonical primary), not a sidecar. Return self.
```bash
if [ -z "$prefix" ] || [ "$prefix" = "$self_base" ]; then
printf '%s' "$scope"
else
printf '%s' "$parent/$prefix"
fi
```
Test fix (the deeper lesson)
`scenario_part_persists` used fixture path `state`/`state.general`. Basename `state` has no dots → regex no-ops → primary case. The leading-dot code path was NEVER exercised by integration tests. Real deployments use `$repo/.airc`.
Renamed fixture: `/tmp/airc-it-pp/state` → `/tmp/airc-it-pp/.airc`. With `.airc` basename, the test reproduces vhsm's bug pre-fix, passes post-fix.
Class of bug
Test fixture paths that diverge from real-world layout in ways that hide code paths. Any regex over basenames should account for leading-dot directories. Worth a grep over the codebase for similar patterns — separate audit.
Unblocks
PR #144 (canary→main). vhsm's e2e was a HOLD on this exact issue; with this fix merged to canary, vhsm can re-run step 5 of their e2e and #144 ships.