Skip to content

feat(buzz-waker): connection loop, real WakeEffects, daemon binary - #20

Merged
yjc801 merged 3 commits into
mainfrom
waker-daemon
Aug 11, 2026
Merged

yjc801 merged 3 commits into
mainfrom
waker-daemon

Conversation

@yjc801

@yjc801 yjc801 commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Adds the connection loop, real WakeEffects, and the daemon binary — the pieces the buzz-waker daemon needed and previously lacked. Stacks on #18 (agent-waker-backfill), since the backlog walk is the last piece of the event feed underneath this.

What's here

  • presence_feed.rs — one authenticated subscription per watched agent. Presence turned out to be simpler than expected: it's a global, non-queryable relay event (kind 20001), not something you can query after the fact, so the daemon keeps a live tap and caches the latest status. An online republish on an interval doubles as the heartbeat signal the wake attempt state machine already wants — one subscription now feeds both.
  • effects.rsRealWakeEffects, a real (non-test) implementation of the WakeEffects trait. Presence, heartbeat, and confirm-author-not-known-agent are real and working. start_managed_agent (the actual provider deploy) is the one deliberately unimplemented seam — every real wake attempt today ends in DeployFailed, logged clearly as such.
  • wake_loop.rs — the connection loop that was completely missing: reconnect/backoff, feed pumping, wake attempts spawned on their own tasks so the loop keeps answering the relay's pings during the ~100s+ a liveness proof can take.
  • main.rs — env-var config (matches every other daemon in this repo, no clap), JSON tracing, SIGTERM/ctrl_c shutdown via CancellationToken, one loop pair (mention feed + presence tap) per configured agent.

Known simplification

This daemon's "known agent" baseline is just its own configured watch list, not the app's full managed-agent roster (desktop has more visibility than this daemon does). Documented as a gap in code comments; closes once bundle ingestion exists.

Still open, deliberately scoped out

  • Bundle transport — how a signed launch bundle reaches this process.
  • Provider deploy wire protocol — currently Tauri-desktop-only code (desktop/src-tauri/src/managed_agents/backend.rs), needs reimplementing here.

Both are real architectural calls; landing a working, tested connection loop first and building deploy on top of a process that already runs.

Test plan

  • cargo test -p buzz-waker — 157/157 passing (153 lib + 4 main binary)
  • cargo clippy -p buzz-waker --all-targets — clean
  • cargo fmt -p buzz-waker --check — clean
  • just ci (full workspace) — not yet run; will report before requesting review

🤖 Generated with Claude Code

@yjc801
yjc801 deleted the branch main August 11, 2026 12:44
@yjc801 yjc801 closed this Aug 11, 2026
@yjc801 yjc801 reopened this Aug 11, 2026
@yjc801
yjc801 changed the base branch from agent-waker-backfill to main August 11, 2026 13:02
Sprite added 2 commits August 11, 2026 07:10
Adds the pieces the daemon needed and previously lacked: presence_feed.rs
(one authenticated subscription per watched agent, doubling as the
liveness heartbeat since presence is a global, non-queryable kind:20001
republished on an interval), effects.rs (RealWakeEffects — presence,
heartbeat, and confirm-author-not-known-agent are real; provider deploy
is the one deliberately unimplemented seam, every real attempt currently
ends in DeployFailed), wake_loop.rs (reconnect/backoff, feed pumping,
wake attempts spawned on their own tasks so the loop keeps answering
relay pings during a liveness proof), and main.rs (env-var config, JSON
tracing, SIGTERM/ctrl_c shutdown, one loop pair per configured agent).

Known simplification, not closed here: "known agent" is this daemon's
own configured watch list, not the full managed-agent roster the desktop
sees. Closes once bundle ingestion exists.

Still open: bundle transport and the provider deploy wire protocol
(currently Tauri-desktop-only code). Scoped out deliberately.

Signed-off-by: Sprite <noreply@sprites.dev>
…ision, local filter enforcement

Addresses three P2 findings from Alex's review of b177b42:

- presence_feed.rs: treat a relay CLOSED frame on the presence
  subscription as a reconnect/failure path instead of the ignored
  catch-all, so the tap doesn't sit permanently unsubscribed on a
  still-open socket.
- presence_feed.rs: verify locally that a delivered event is kind:20001
  and authored by the watched agent before folding it into cached
  presence — signature verification alone doesn't prove the relay
  respected this subscription's filter.
- main.rs: supervise watch tasks for early exit (corrupt cursor, panic)
  during normal operation, not just after shutdown, and fail the daemon
  rather than run silently degraded with an unwatched agent.

Pulled the presence classification logic into a pure presence_frame
function, matching relay_feed.rs's existing feed_frame pattern, and
added unit tests for it.

Signed-off-by: Sprite <noreply@sprites.dev>
Addresses Alex's round-3 P2 finding: FeedStep::ChannelLiveClosed only
logged the closure. A relay can close one per-channel live subscription
for rate limiting, eviction, or transient authorization state while the
socket and membership watch stay healthy. Left alone, nothing reopens
that channel until an unrelated reconnect or membership change, while
idle checkpoints keep advancing the coverage watermark — mentions in
that channel go silently missing with no later replay.

Retries the one subscription immediately, using the same connection's
since floor. Only falls back to the ordinary reconnect ladder if the
re-subscribe call itself fails.

Signed-off-by: Junchao Yan <yjc801@gmail.com>
@yjc801
yjc801 merged commit 6adcb14 into main Aug 11, 2026
21 of 24 checks passed
@yjc801
yjc801 deleted the waker-daemon branch August 11, 2026 14:53
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