Repository navigation
Dedupe monitor mirror by signature - #515
Merged
Merged
Conversation
There was a problem hiding this comment.
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_sigsindex inmonitor_formatter.run()and preload it from recentmessages.jsonlhistory. - Skip both mirroring and display when an inbound envelope’s
sigis already known. - Add unit tests asserting that duplicate signatures don’t produce duplicate stdout output or duplicate
messages.jsonlentries.
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) |
This was referenced May 5, 2026
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
messages.jsonlsignatures at startup and treatsigas the envelope identityObserved during the coordinated Mac reset after #514: raw
messages.jsonlcontained duplicate identicalsiglines formac-reset-okand follow-up broadcasts. This patch fixes the mirror boundary instead of asking each sender path to avoid every possible echo.Tests
Follow-up from #511/#514 validation.