Skip to content

fix(gist): select freshest channel envelope - #460

Merged
joelteply merged 1 commit into
canaryfrom
fix/gist-content-channel-select
May 4, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/gist-content-channel-select

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

  • make gistparse gist_content --channel <name> choose the freshest envelope whose channels[] contains that channel
  • pass the requested channel when resolving a gist in cmd_connect and _mesh_age_secs
  • keep first-file fallback only for legacy/single-file gists
  • add regression coverage for multi-file gists with stale sibling files

Root Cause

#459 fixed the split-brain resolver path, but live reconnect exposed a second destructive bug: after resolving the right multi-file gist, gist_content read the first file. In the live gist, one sibling file was stale while another file in the same gist had a fresh heartbeat. Reading the stale sibling made AIRC conclude the host was stale and delete/take over the whole gist.

A takeover decision must be based on the channel-relevant freshest envelope, not an arbitrary first file.

Verification

  • bash -n airc lib/airc_bash/mesh.sh lib/airc_bash/cmd_connect.sh
  • python3 test/test_gistparse.py
  • PYTHONPATH=lib python3 test/test_channel_gist.py
  • ./test/integration.sh solo_mesh_warns
  • git diff --check

No live reconnect attempt until this lands; canary currently has #459 without this guard, so reconnecting can still make a bad takeover decision on multi-file gists.

Copilot AI review requested due to automatic review settings May 4, 2026 17:24
@joelteply
joelteply merged commit ef9b0d3 into canary May 4, 2026
8 checks passed
@joelteply
joelteply deleted the fix/gist-content-channel-select branch May 4, 2026 17:26

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 gist envelope selection for multi-file gists so that takeover/staleness decisions are based on the freshest envelope relevant to the requested channel, rather than whichever file happens to be “first” in the gist.

Changes:

  • Added gistparse gist_content --channel <name> to select the freshest envelope whose channels[] includes the requested channel (with legacy first-file fallback when no channel is provided).
  • Updated cmd_connect.sh and _mesh_age_secs to pass the requested channel into gist-content resolution (including the git-clone fallback preferring airc-room-<channel>.json).
  • Added regression tests covering multi-file gists with stale sibling files.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
test/test_gistparse.py Adds regression tests ensuring channel-aware freshest-envelope selection and preserving legacy fallback behavior.
lib/airc_core/gistparse.py Implements channel-aware gist file selection (--channel) and keeps legacy first-file fallback.
lib/airc_bash/mesh.sh Updates _mesh_age_secs to resolve gist content via gistparse gist_content, optionally channel-scoped.
lib/airc_bash/cmd_connect.sh Passes --channel "$room_name" to gist parsing and prefers channel-named file in git-clone fallback.

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

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