Repository navigation
fix(mesh): elect takeover winner by channel - #462
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens AIRC’s mesh “takeover” and gist-envelope selection logic to be channel-scoped, preventing unrelated gists (e.g., live test rooms) from being elected as the canonical winner during host publish races and avoiding stale/incorrect envelope reads in multi-file gists.
Changes:
- Update
_mesh_take_overto elect the canonical gist via the channel-aware_mesh_find <channel>resolver rather than description-based gist listing. - Extend
airc_core.gistparse gist_contentwith--channelto select the freshest matching envelope, and wire that into connect and mesh age checks. - Add regression tests for channel-aware gist envelope selection and preserve legacy first-file fallback behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
test/test_gistparse.py |
Adds unit coverage for channel-aware envelope selection and legacy fallback behavior. |
lib/airc_core/gistparse.py |
Implements gist_content --channel to choose the freshest envelope matching the requested channel. |
lib/airc_bash/mesh.sh |
Uses channel-aware gist content selection for heartbeat age and channel-scoped winner election for takeovers. |
lib/airc_bash/cmd_connect.sh |
Resolves gist content using gist_content --channel and improves the git-clone fallback to try the channel envelope first. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+271
to
+274
| matches.append((str(env.get("last_heartbeat", "")), name == exact_name, content)) | ||
| if matches: | ||
| matches.sort(key=lambda item: (item[0], item[1]), reverse=True) | ||
| print(matches[0][2]) |
Comment on lines
+260
to
+268
| exact_name = f"airc-room-{channel}.json" | ||
| matches = [] | ||
| for name, entry in files.items(): | ||
| if not isinstance(entry, dict): | ||
| continue | ||
| content = entry.get("content", "") | ||
| if not content: | ||
| continue | ||
| env = _read_json_text(content) |
Comment on lines
+743
to
+749
| # Prefer the requested channel's envelope; fall back to the | ||
| # first non-dotfile for legacy single-file invite gists. | ||
| local _gist_file | ||
| _gist_file=$(find "$_gist_tmp" -maxdepth 1 -type f ! -name '.git*' 2>/dev/null | head -1 || true) | ||
| _gist_file="$_gist_tmp/airc-room-${room_name}.json" | ||
| if [ ! -f "$_gist_file" ]; then | ||
| _gist_file=$(find "$_gist_tmp" -maxdepth 1 -type f ! -name '.git*' 2>/dev/null | head -1 || true) | ||
| fi |
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.
Summary
_mesh_take_overelect the winner through_mesh_find <channel>instead of exact-descriptionairc meshlistingRoot Cause
After #460, reconnect no longer deleted a gist because of a stale sibling file. But live testing exposed another independent split-brain path: post-publish race-loser detection still listed every exact-description
airc meshgist and picked the oldest, regardless of channel. It yielded a#cambriantechhost attempt to a leaked live testairc meshgist whose host wastdd-cr-*and whose envelope was only#general.Winner election must be channel-scoped. Otherwise unrelated live test/project gists can steal production discovery.
Verification
bash -n airc lib/airc_bash/mesh.sh lib/airc_bash/cmd_connect.shpython3 test/test_gistparse.pyPYTHONPATH=lib python3 test/test_channel_gist.py./test/integration.sh solo_mesh_warnsgit diff --checkNo live reconnect until this lands; canary with #459/#460 still has the channel-blind takeover election.