{"record":{"id":"0fbf0b311ee15ff5","repo":"astrid-runtime/astrid","slug":"own-agent-v1-event-delivered-subtree-match","errorCode":null,"errorMessage":"own agent.v1.* event delivered (subtree match)","messagePattern":"own agent\\.v1\\.\\* event delivered \\(subtree match\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-gateway/src/routes/stream.rs","lineNumber":365,"sourceCode":"        let me = \"alice\";\n        let mut feed_rx = bus.subscribe_topic_routed_scoped(\n            Uuid::new_v4(),\n            TOPIC_AGENT_EVENTS,\n            \"gateway\",\n            \"gateway::agent_stream\",\n            Some(Some(me.to_string())),\n        );\n\n        bus.publish(ipc_event(\n            \"agent.v1.stream.delta\",\n            me,\n            serde_json::json!({ \"text\": \"chunk\" }),\n        ));\n\n        let event = feed_rx\n            .recv(Some(Duration::from_secs(2)))\n            .await\n            .expect(\"own agent.v1.* event delivered (subtree match)\");\n        let AstridEvent::Ipc { message, .. } = &*event else {\n            panic!(\"expected IPC\");\n        };\n        assert_eq!(message.topic, \"agent.v1.stream.delta\");\n        assert_eq!(message.principal.as_deref(), Some(me));\n    }\n}\n","sourceCodeStart":347,"sourceCodeEnd":373,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-gateway/src/routes/stream.rs#L347-L373","documentation":"This is a test assertion panic in the gateway stream feed test: the test subscribes a feed and waits up to 2 seconds for an event on the `agent.v1.*` topic subtree, but none was delivered. The `expect` message fires when `feed_rx.recv` returns `None` (channel closed) or times out before a matching event arrives. It guards the invariant that the feed delivers the process's own agent events via subtree topic matching.","triggerScenarios":"Calling `feed_rx.recv(Some(Duration::from_secs(2)))` in `scoped_feed_delivers_own_agent_events` when no `AstridEvent::Ipc` message with topic `agent.v1.stream.delta` was published to the feed within the 2s timeout, or the feed channel closed without delivering.","commonSituations":"A regression in the feed's topic-subtree subscription filter (e.g. exact-match instead of `agent.v1.*` prefix match), the delta event published under a different topic, the publishing side never emitting the chunk, or an overloaded/slow CI machine exceeding the 2s timeout.","solutions":["Check that the feed subscription uses subtree/prefix matching for `agent.v1.*`, not exact topic equality.","Verify the test actually publishes a delta with topic `agent.v1.stream.delta` before calling recv.","Confirm the event carries the expected principal (`Some(me)`); a principal-scoped feed filter may drop it.","Increase the recv timeout if failures only occur on slow CI runners."],"exampleFix":"// before\nlet event = feed_rx.recv(Some(Duration::from_secs(2))).await.expect(\"own agent.v1.* event delivered (subtree match)\");\n// after\nlet event = feed_rx\n    .recv(Some(Duration::from_secs(5)))\n    .await\n    .unwrap_or_else(|| panic!(\"no agent.v1.* event within timeout; topic sent: {sent_topic:?}\"));","handlingStrategy":"validation","validationCode":"// Rust (test): verify the subscription filter covers the topic before waiting\nassert!(subtree_matches(\"agent.v1.*\", \"agent.v1.stream.delta\"), \"topic must be within agent.v1 subtree\");","typeGuard":"fn as_ipc(event: &AstridEvent) -> Option<&IpcMessage> {\n    if let AstridEvent::Ipc { message, .. } = event { Some(message) } else { None }\n}","tryCatchPattern":null,"preventionTips":["Always use generous timeouts in feed tests; prefer polling with assertion diagnostics over bare expect.","Test subtree matching separately from payload assertions.","Log the published topic when a recv times out to localize filter regressions."],"tags":["rust","test-assertion","event-feed","timeout"],"backgroundTag":"empty-result-set","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}