feat(channel): gate sensor startup on end-to-end channel handshake#3
Merged
feat(channel): gate sensor startup on end-to-end channel handshake#3
Conversation
Boot now sends a single channel notification 5s post-init asking Claude to call the new confirm_channel_received tool. The ack proves that notifications/claude/channel is being delivered before any sensor starts polling, so dedup state in ~/.world2agent/state.json only accumulates when the client is actively consuming signals — every channel-enabled session starts clean from a known-good baseline. - 30s deadline for the ack; absent that, sensors stay offline for the session - After applyConfig succeeds, a "ready" channel notification announces the active sensor list so users get a single-sentence confirmation - start_sensors / reload_sensors await channelReady and return a clear help message when the channel is offline, so /world2agent:sensor-add can't half-write state in a non-channel session - Persistent boot/lifecycle log at ~/.world2agent/channel.log for debug inspection without re-instrumenting the bundle Bumps plugin manifest to 0.1.0-alpha.2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
confirm_channel_receivedtool. The ack is the proof thatnotifications/claude/channelis being delivered, so sensor polling (and the dedup state in~/.world2agent/state.json) only starts on a known-good channel — every channel-enabled session opens with a clean baseline and no signals get silently swallowed by staleseen_idsfrom a previous non-channel launch.applyConfigsucceeds with the running sensor list, so users see one short Claude-authored confirmation that World2Agent is up and which sources it's watching.start_sensors/reload_sensorsawait the same gate and return a clear help message if the channel never acked, so/world2agent:sensor-addcan't half-write state in a non-channel session.~/.world2agent/channel.logfor inspecting the handshake trace without re-instrumenting the bundle.0.1.0-alpha.2.Why the 5s delay
Empirically, channel notifications fired in the first ~1ms after
oninitializedgo missing from the session transcript — Claude Code finishes wiring up its channel listener slightly after the MCP init handshake completes. Notifications fired ≥100ms post-init are reliably consumed; 5s gives the listener plenty of headroom, and theconfirm_channel_receivedack typically arrives ~9s later.Test plan
claude --dangerously-load-development-channels plugin:world2agent@world2agent-plugins, no sensor config changes — verifychannel.logshows handshake fire → ack → sensor started, and Claude posts a one-sentence "World2Agent is ready" message.claude(no flag) — verify the plugin sits idle, sensor does not start,state.jsonis not written.claudesession, run/world2agent:sensor-add— verify the slash command's finalreload_sensorscall returns the channel-disabled help text and Claude tells the user to relaunch with the flag.~/.world2agent/channel.logand confirm the boot trace lines describe the lifecycle in order (Connecting → Connected → handshake fire → ack → Starting sensor(s) → Started → Sending ready notification).ps | grep world2agent).🤖 Generated with Claude Code