Fix delayed hcom message delivery#65
Merged
Merged
Conversation
Subscription hits create [hcom-events] system messages through send_system_message, which logs the message but does not ping notify endpoints like hcom send does. That left subscription notifications unread until an unrelated wake reached the subscriber. Wake the matching caller's notify endpoints after the system message is logged, guarded by delivered_to so typos or mismatches do not fan out. Add a TCP probe test proving only the subscribed target is woken.
OpenCode delivery ignored wake attempts while a delivery read was in flight or while an injected prompt was waiting for the transform ack. A message created during that window could remain unread until a later unrelated wake. Track a queued delivery wake and replay it after the current read finishes, after deferred ack, or after promptAsync rejects so the wake is not stranded. Keep the existing single-delivery guard and reset the new queue state on session deletion.
Owner
|
thanks |
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.
Subscription notifications could be logged as
[hcom-events]messages without waking the subscribed agent. That left agents waiting until some unrelated status change or message wake made them read the queued notification. OpenCode had a second race where a wake that arrived during an active delivery read or while a prompt injection was waiting for transform ack was ignored.This fixes both paths. Subscription notifications now wake only the matched subscriber after the message is logged, and OpenCode queues one pending delivery wake and drains it after the current read, after deferred ack, or after
promptAsyncrejects.The Rust path adds a TCP-probe test proving only the subscribed target is woken; the OpenCode replay path has no unit test because it depends on plugin runtime sequencing and was validated against a state-machine repro of the in-flight, pending-ack, and rejection sequence. Checked with
cargo fmt --check,cargo test db::subscriptions::tests::test_send_sub_notification_wakes_target_instance, andbun build src/opencode_plugin/hcom.ts --external @opencode-ai/plugin --external @opencode-ai/sdk --outfile /tmp/opencode/hcom-plugin.js.