Skip to content

fix(agents): label live peers that predate discovery publication - #2309

Merged
decode2 merged 2 commits into
mainfrom
fix/2305-bug-agents-orchestrator-list-publishes-e
Oct 16, 2026
Merged

decode2 merged 2 commits into
mainfrom
fix/2305-bug-agents-orchestrator-list-publishes-e

Conversation

@barbatdev

@barbatdev barbatdev commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2305

Problem

orchestrator_list rendered live peers as context: unknown · repository: unknown · metadata: unknown, leaving the operator with indistinguishable session IDs.

Root cause

The affected peers are long-lived sessions whose loaded code predates discovery publication (#1714/#1720, merged 2026-10-03, first released in v4.1.0). They heartbeat the legacy schema-1 presence header (with its label) but never write the discovery sidecar, so the reader correctly fails closed. Reproduced on Linux with a peer started on 2026-10-02: recent header labeled gentle-shell, no discovery sidecar.

Change

  • lib/orchestrator-presence.ts: discoveryAbsent() is true only when the sidecar does not exist (ENOENT); a present but unreadable sidecar is not absent.
  • lib/orchestrator-discovery.ts: a peer with a recent header and no sidecar gets a display-only legacyLabel; freshness stays unknown.
  • extensions/gentle-agents.ts: orchestrator_list renders such peers as <label> · context: legacy (this session predates discovery publication; restart it to publish its workspace and repository) · repository: not published · metadata: legacy.

Unchanged and still fail-closed: invalid sidecars, metadata bound to another activation, stale heartbeats. orchestrator_consult metadata stays unavailable for legacy peers.

Verification

  • New tests in tests/orchestrator-discovery.test.ts: legacy label for a live peer without a sidecar (red before the change, green after); no label for invalid or foreign sidecars.
  • New test in tests/gentle-agents.test.ts pins the full orchestrator_list row through the registered tool (red before the change, green after) and checks that orchestrator_consult stays unavailable.
  • pnpm test: all stages pass (unit-tests, provider-contract, runtime-harness) at 4c44f34a4 on base d72c28ae1.
  • pnpm typecheck: 0 diagnostics.
  • Live check against a real profile: the pre-publication peer now yields legacyLabel=gentle-shell; the other four peers are unchanged.

Out of scope

Transport arming on Windows (#2166), hidden transport errors (#2124), stale peer advertisements (#1443), the recipient picker (#1308). Presence-scan hardening (full traversal past the 128-entry page, stale duplicate headers left by resumed sessions) goes to a separate PR referencing #2305.

Summary by CodeRabbit

  • Bug Fixes
    • Active peers created before discovery information was available now display their legacy label and status instead of generic unknown context.
    • Repository publication is shown as unavailable for these peers, while existing discovery and freshness details remain unchanged for other peers.
    • Expired peers and peers with existing discovery sidecars do not receive the legacy label.

A session started before discovery publication (#1714/#1720) heartbeats the
schema-1 presence header but never writes a discovery sidecar, so
orchestrator_list rendered every field as unknown. When the header is recent
and the sidecar is absent, show the header label with an explicit legacy
marker. Invalid or foreign sidecars and stale heartbeats still fail closed.

Closes #2305
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 4c9a89d0-9e95-4eba-9548-db1a66e70f32
📥 Commits

Reviewing files that changed from the base of the PR and between d72c28a and c7bdfb9.

📒 Files selected for processing: 5
  • extensions/gentle-agents.ts
  • lib/orchestrator-discovery.ts
  • lib/orchestrator-presence.ts
  • tests/gentle-agents.test.ts
  • tests/orchestrator-discovery.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Walkthrough

Discovery now labels live peers with absent discovery sidecars as legacy peers. orchestrator_list displays their legacy label and publication details. Tests cover sidecar and heartbeat conditions, and confirm consultation remains unavailable for these peers.

Changes: Legacy peer context

Layer / File(s) Summary
Identify peers with absent discovery sidecars
lib/orchestrator-presence.ts, lib/orchestrator-discovery.ts, tests/orchestrator-discovery.test.ts
Discovery adds a legacy label when a peer has a recent presence header and no discovery sidecar. Tests cover expired heartbeats and present sidecars that are mismatched or malformed.
Display legacy peer labels
extensions/gentle-agents.ts, tests/gentle-agents.test.ts
orchestrator_list displays the legacy label, legacy context and metadata, and an unpublished repository. The regression test confirms orchestrator_consult remains unavailable and does not spawn a child or send a message.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: decode2

Merge Risk: ⚪ Minimal · up to c7bdf

Recent peers without discovery metadata are identified as legacy, while consultation remains unavailable. No actionable merge risk remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Linked Issues check Warning Issue #2305 requires live peers to expose the recorded repository root or clone hash, declared aliases, and a published metadata snapshot. The reviewed code adds legacyLabel only when the discovery … Publish or recover the required repository scope, declared aliases, and metadata snapshot for live peers without a discovery sidecar, and return that snapshot from orchestrator_consult. If legacy peers cannot provide this data, obtain an …
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: labeling live peers that predate discovery publication.
Out of Scope Changes check Passed The changes stay within the linked issue's peer-discovery behavior. discoveryAbsent, legacyLabel, the orchestrator_list rendering, and the regression tests support the legacy-peer display case. …
Docstring Coverage Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 5 files.
Full details: Linked Issues check

Explanation

Issue #2305 requires live peers to expose the recorded repository root or clone hash, declared aliases, and a published metadata snapshot. The reviewed code adds legacyLabel only when the discovery sidecar is absent. The orchestrator_list row reports the repository as not published and metadata as legacy, and orchestrator_consult remains unavailable. The added tests pin this fallback, so the PR does not implement the direct issue outcome for these live peers.

Resolution

Publish or recover the required repository scope, declared aliases, and metadata snapshot for live peers without a discovery sidecar, and return that snapshot from orchestrator_consult. If legacy peers cannot provide this data, obtain an explicit issue requirement that accepts the legacy fallback instead of claiming the issue is closed.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@barbatdev

Copy link
Copy Markdown
Contributor Author

End-to-end check in a live session (after /reload loading this branch), orchestrator_list with no arguments:

- 01a0fa19-15a5-747a-9708-7c3af8a86363 · gentle-shell · context: legacy (this session predates discovery publication; restart it to publish its workspace and repository) · repository: unknown · metadata: unknown
  recorded catalog: unknown

Before the change the same peer rendered as context: unknown · repository: unknown · metadata: unknown. A peer that publishes discovery still renders its workspace and repository unchanged, and a stale peer still renders context: unknown · metadata: stale.

…list

A peer that predates discovery publication never publishes its repository
scope, so rendering repository and metadata as unknown contradicted the
legacy marker on the same row. Render them as not published and legacy, and
pin the full row through the registered tool.
@decode2
decode2 merged commit 6747756 into main Oct 16, 2026
9 checks passed
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.

bug(agents): orchestrator_list publishes every peer as context/repository/metadata unknown on 4.2.0 although #1701 shipped

2 participants