Skip to content

fix(core): actually re-advertise on discovery visibility resume - #143

Merged
Mearman merged 1 commit into
mainfrom
design/agent-lifecycle-gossip-retirement
Sep 16, 2026
Merged

Mearman merged 1 commit into
mainfrom
design/agent-lifecycle-gossip-retirement

Conversation

@Mearman

@Mearman Mearman commented Sep 16, 2026

Copy link
Copy Markdown
Member

Part of #51's own named bug ("fix the live pauseAllAdvertisements/resumeAllAdvertisements bug found in passing").

DiscoveryManager.pauseAllAdvertisements/pauseAdvertisementsForBackend discarded the real AdvertiseOptions a caller passed to advertise(), replacing them with an inert {name: "resumed", port: 0} placeholder. resumeAllAdvertisements/resumeAdvertisementsForBackend then only deleted the paused bookkeeping entry and never called backend.startAdvertising again -- so toggling mesh visibility from quiet/dark back to discoverable silently left the mesh unadvertised on every backend, while getVisibility() kept reporting "discoverable" the whole time. No test exercised this path at all before this PR (visibility.integration.test.ts only ever checked getVisibility()'s own state transitions, never that pausing/resuming actually drove a backend).

DiscoveryManager now keeps the real opts alongside each active and paused advertisement, and resume genuinely calls backend.startAdvertising(opts) again. Along the way, fixed a second, related gap the naive fix would have introduced: the caller-visible advertisement id is now minted by DiscoveryManager itself (via nanoid, distinct from whatever id a backend returns internally) and kept stable across a pause/resume cycle -- a caller holding an id from before a visibility change (e.g. to later call mesh_unadvertise) can still address the same logical advertisement afterwards, rather than the id silently changing underneath it. DiscoveryManager no longer relies on a backend's own id-generation being deterministic (the real mdns/tailscale backends happen to be, but nothing enforced that as a contract).

Test plan

  • New RED tests confirmed failing for the right reason before implementation
  • pnpm typecheck
  • pnpm lint
  • pnpm test (798/798)
  • pnpm build

pauseAllAdvertisements/pauseAdvertisementsForBackend discarded the real
AdvertiseOptions a caller passed to advertise(), replacing them with an
inert placeholder. resumeAllAdvertisements/resumeAdvertisementsForBackend
then only deleted the paused bookkeeping entry and never called
backend.startAdvertising again, so toggling mesh visibility from
quiet/dark back to discoverable silently left the mesh unadvertised on
every backend, with getVisibility() reporting "discoverable" the whole
time.

DiscoveryManager now keeps the real opts alongside each active and paused
advertisement, and resume genuinely calls backend.startAdvertising(opts)
again. The caller-visible advertisement id is now minted by
DiscoveryManager itself (via nanoid, distinct from whatever id a backend
returns internally) and kept stable across a pause/resume cycle, so a
caller holding an id from before a visibility change can still address
the same logical advertisement afterwards -- a backend is free to return
a different internal id on every startAdvertising call, and DiscoveryManager
no longer depends on backend id determinism to keep working correctly.
@Mearman
Mearman marked this pull request as ready for review September 16, 2026 05:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-16T05:11:33.229741Z 5aff3bd Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Mearman
Mearman merged commit 76c00ac into main Sep 16, 2026
6 checks passed
@Mearman
Mearman deleted the design/agent-lifecycle-gossip-retirement branch September 16, 2026 05:12
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.31.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant