Phase 1: broker ask/reply messaging - #168
Draft
sdougbrown wants to merge 2 commits into
Draft
Conversation
Phase 1 of inter-agent ask/reply plumbing: - Enrich AgentMessage with ID, ReplyTo, ExpectsReply, ToRunID, Attachments, Supersedes fields (backward-compatible, omitempty) - Add AskEdge, AskReply, SessionInfo types - Add global ask-edge registry (namespaced by sender run ID) with per-RunState fallback for mutual-ask guard - /send: handle expects_reply (register ask edge), reply_to (route to waiting sender), and plain fire-and-forget - /wait_reply: long-poll with auth (sender-only), timeout (504), and cancel signals; preserves edge on client disconnect - /cancel_message: ownership-checked cancellation with signal - /sessions: list registered runs with metadata - Background goroutine prunes expired ask edges and delivers timeout signals to waiting channels - Mutual-ask deadlock guard (TOCTOU-safe under global lock) - Add closeCh for clean goroutine shutdown in Stop() - 12 integration tests covering all ask/reply flows (happy path, mutual guard, cancel, timeout, pruning, auth) - All existing tests pass; 38/38 Go packages green Fix review findings: namespaced keys prevent cross-run message ID collisions; ownership checks on wait_reply and reply paths prevent spoofing; prune loop shutdown via closeCh; rollback cleans global registry on SendTo failure; WriteTimeout kept at 30s with handler- level long-poll for re-poll safety.
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
Enriches avenor's in-process HTTP broker with structured ask/reply coordination between agent runs. Agents can now send blocking questions (expects_reply), receive correlated replies, cancel pending asks, and discover peers — all through the existing broker transport.
Key changes
Message model (internal/runtime/broker/message.go)
Broker endpoints (internal/runtime/broker/broker.go)
Security
Tests (12 new)
Ask/reply happy path, fire-and-forget backward compat, mutual-ask guard, cancel (success/nonexistent/wrong-owner), expired-edge fallback, sessions listing, session info updates, pruning signal delivery, wait timeout via prune, auth enforcement. All 38 Go packages green.
Next phases