Skip to content

feat: presence-derived parley_list_users (who's live on the bus)#6

Merged
sharpTrick merged 2 commits into
mainfrom
feat/presence-list-users
Jul 3, 2026
Merged

feat: presence-derived parley_list_users (who's live on the bus)#6
sharpTrick merged 2 commits into
mainfrom
feat/presence-list-users

Conversation

@sharpTrick

Copy link
Copy Markdown
Owner

What & why

Adds parley_list_users — an MCP tool that reports who is live on the bus, with an optional glob filter (e.g. claude-*), for picking a hand-off target.

This started as "should list users be a core seam method every backend implements?" The answer was no: the seam is six methods on purpose, several backends have no enumerable user set (Redis/NATS/Discord/Telegram), and a mandatory listUsers would mean four different things wearing one name — the failure the conformance suite exists to prevent.

The better design (Patrick's insight): make presence a message. Each bridge announces hello / heartbeat / goodbye, and liveness is derived entirely above the seam from post/fetchRecent + a TTL window.

Result

  • Works identically on every backend — no new seam method.
  • Lists an idle instance that has never posted (the case a sender-scan misses).
  • Zero changes to any backend plugin; the conformance suite is unchanged — the repo's own proof that prime directive chore: scaffold five new backend packages (postgres, zulip, discord, telegram, slack) #2 held.
  • Presence streams are isolated: derived presence topics are never subscribed and never enter catch-up/dedup, so heartbeats never surface as <channel> events or pollute durable history.
  • Reports Parley-participant liveness, not a human directory — a human in a native client appears once they send a real message.

Design decisions (locked with the user)

  • Dedicated presence stream (not heartbeats in real topics) — keeps durable history and push clean, no Message-model change.
  • Presence-only, uniform (not presence + per-backend directory) — keeps the "same behavior everywhere" property.

Changes (all in bridge-core)

  • engine/presence.tspresenceTopicFor, encode/decode, computeLive (TTL liveness)
  • transport/presence-loop.ts — best-effort hello/heartbeat/goodbye emitter
  • identity-filter.tsmatchGlob / filterHandles
  • transport/tools.tsparley_list_users tool (+ ToolDeps gains presenceTtlMs/now)
  • lifecycle wiring: stdio-bridge (attach/shutdown) + http (app scope)
  • config.tspresence block (enabled/heartbeat_ms/ttl_ms)
  • docs: DESIGN §7/§11, README; fixed the stale §4 "real account lookup for Matrix/XMPP" note (both echo the handle today)

Testing

  • 154 tests pass, typecheck clean. 25 new unit tests (presence, glob, emitter loop, 6 tool cases).
  • End-to-end on a real SQLite backend through the full bridge lifecycle — all 7 checks passed: idle agent discoverable via presence alone; filter narrows; real messages never pollute the presence stream or invent a user; clean-shutdown goodbye drops fast; a stale/crashed heartbeat is reclaimed by TTL.

Known follow-up

  • Presence streams grow append-only (heartbeat every 30s). list_users reads a bounded recent window; retention/pruning is a future optimization (the seam has no delete) — noted, not blocking.

🤖 Generated with Claude Code

sharpTrick and others added 2 commits July 3, 2026 01:34
…ive message

subscribe() started its XREAD loop at '$' and returned without awaiting the
first (blocking) read. '$' only resolves to the stream's last id when that read
registers server-side, so a post() (XADD) racing in during the startup window
got an id below the resolved '$' and was dropped forever — it never reached the
subscriber. Surfaced as an intermittent failure of the "identical backendMsgId +
cursor via live push and via catch-up" conformance test under CI load (Node 24).

Fix: capture a concrete stream tail id via XINFO STREAM, awaited before
subscribe() resolves, and read strictly after it. A concrete id has no gap, so a
message added during startup is still delivered. Falls back to '0' when the
stream doesn't exist yet (no history to skip). Verified: redis conformance 20/20.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a parley_list_users MCP tool that reports who is LIVE on the bus, with an
optional glob filter (e.g. "claude-*"). Rather than a mandatory seam method
(which several backends can't implement and which would mean different things
per backend), liveness is derived ENTIRELY ABOVE THE SEAM: each bridge posts
hello/heartbeat/goodbye to a derived, isolated presence stream, and the tool
reconstructs the roster from fetchRecent + a TTL window.

Result: works identically on every backend, lists an idle instance that hasn't
posted, and touches zero seam methods and zero backend plugins — the conformance
suite is unchanged.

- engine/presence.ts: presenceTopicFor, encode/decode, computeLive (TTL liveness)
- transport/presence-loop.ts: hello/heartbeat/goodbye emitter (best-effort)
- identity-filter.ts: matchGlob / filterHandles
- transport/tools.ts: parley_list_users tool
- lifecycle wiring in stdio-bridge (attach/shutdown) + http (app scope)
- presence config block (enabled/heartbeat_ms/ttl_ms)
- docs: DESIGN §7/§11, README; fix stale §4 "real account lookup" note
- gitignore local .project.yml tooling metadata

Verified end-to-end on a real SQLite backend: idle agent listed, presence stream
isolated from real topics, goodbye + TTL both drop participants.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sharpTrick sharpTrick merged commit 28230b1 into main Jul 3, 2026
3 checks passed
@sharpTrick sharpTrick deleted the feat/presence-list-users branch July 3, 2026 11:31
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.

1 participant