Skip to content

Dedupe monitor mirror by signature - #515

Merged
joelteply merged 1 commit into
canaryfrom
codex/dedupe-monitor-mirror-sigs
May 5, 2026
Merged

joelteply merged 1 commit into
canaryfrom
codex/dedupe-monitor-mirror-sigs

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

  • prevent monitor_formatter from appending/displaying the same signed envelope twice
  • load recent local messages.jsonl signatures at startup and treat sig as the envelope identity
  • skip mirror+display when a gist receive replays a signature already present locally
  • cover host self-echo and duplicate bearer reads with unit tests

Observed during the coordinated Mac reset after #514: raw messages.jsonl contained duplicate identical sig lines for mac-reset-ok and follow-up broadcasts. This patch fixes the mirror boundary instead of asking each sender path to avoid every possible echo.

Tests

  • python3 test/test_monitor_formatter.py
  • ./airc doctor --tests python_units
  • bash -n airc lib/airc_bash/cmd_connect.sh test/integration.sh
  • git diff --check

Follow-up from #511/#514 validation.

Copilot AI review requested due to automatic review settings May 5, 2026 05:45
@joelteply
joelteply merged commit c11b083 into canary May 5, 2026
8 checks passed
@joelteply
joelteply deleted the codex/dedupe-monitor-mirror-sigs branch May 5, 2026 05: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 aims to prevent monitor_formatter from mirroring/appending and displaying the same signed envelope more than once by treating sig as the envelope identity and deduping at the mirror boundary. This addresses duplicate lines observed in local messages.jsonl when a host’s own gist receive replays messages already recorded locally (and when duplicate bearer reads occur).

Changes:

  • Add an in-memory seen_sigs index in monitor_formatter.run() and preload it from recent messages.jsonl history.
  • Skip both mirroring and display when an inbound envelope’s sig is already known.
  • Add unit tests asserting that duplicate signatures don’t produce duplicate stdout output or duplicate messages.jsonl entries.

Reviewed changes

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

File Description
lib/airc_core/monitor_formatter.py Adds signature-based dedupe (seen_sigs + preload from local log) and skips mirror+display for already-seen signatures.
test/test_monitor_formatter.py Adds MirrorDedupeTests to validate stream-level dedupe and “already local at startup” dedupe behavior.

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

Comment on lines +314 to +331
seen_sigs: set[str] = set()

def _load_seen_sigs(limit: int = 5000) -> None:
try:
with open(local_log, encoding="utf-8", errors="replace") as f:
lines = f.readlines()[-limit:]
except Exception:
return
for raw in lines:
try:
obj = json.loads(raw)
except Exception:
continue
sig = obj.get("sig")
if isinstance(sig, str) and sig:
seen_sigs.add(sig)

_load_seen_sigs()
Comment on lines 504 to +508
try:
with open(local_log, "a") as f:
f.write(line + "\n")
if isinstance(sig, str) and sig:
seen_sigs.add(sig)
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