Summary
POST /api/comms/task calls state.kernel.memory_substrate().task_post(...) directly, bypassing the Kernel::task_post wrapper that publishes the SystemEvent::TaskPosted event. As a result, tasks created via HTTP never hit the event bus, and triggers with pattern: "TaskPosted" never fire for UI-posted tasks.
Repro
- Register a trigger:
POST /api/triggers with {"pattern": "TaskPosted", ...}
- Post a task:
POST /api/comms/task with {"title": "t", "description": "d"}
GET /api/triggers — fire_count stays at 0.
Posting the same task via an agent's task_post tool (which goes through KernelHandle::task_post → Kernel::task_post) fires the trigger as expected.
Location
- HTTP handler:
crates/librefang-api/src/routes/network.rs:1460-1488 (comms_task)
- Kernel wrapper (correct path):
crates/librefang-kernel/src/kernel/mod.rs:12048-12076
- Same issue likely applies wherever
memory_substrate().task_complete(...) is called directly from the API layer.
Suggested fix
Route comms_task through the kernel wrapper instead of the memory substrate. Audit the API layer for other direct memory_substrate().task_* callers.
Secondary
filter_to_comms_event in network.rs:1103-1160 only matches Message and Lifecycle payloads, so even once the event is published, GET /api/comms/events won't surface TaskPosted/TaskClaimed/TaskCompleted. Worth extending to match EventPayload::System(SystemEvent::Task*) so the comms feed is complete.
Summary
POST /api/comms/taskcallsstate.kernel.memory_substrate().task_post(...)directly, bypassing theKernel::task_postwrapper that publishes theSystemEvent::TaskPostedevent. As a result, tasks created via HTTP never hit the event bus, and triggers withpattern: "TaskPosted"never fire for UI-posted tasks.Repro
POST /api/triggerswith{"pattern": "TaskPosted", ...}POST /api/comms/taskwith{"title": "t", "description": "d"}GET /api/triggers—fire_countstays at 0.Posting the same task via an agent's
task_posttool (which goes throughKernelHandle::task_post→Kernel::task_post) fires the trigger as expected.Location
crates/librefang-api/src/routes/network.rs:1460-1488(comms_task)crates/librefang-kernel/src/kernel/mod.rs:12048-12076memory_substrate().task_complete(...)is called directly from the API layer.Suggested fix
Route
comms_taskthrough the kernel wrapper instead of the memory substrate. Audit the API layer for other directmemory_substrate().task_*callers.Secondary
filter_to_comms_eventinnetwork.rs:1103-1160only matchesMessageandLifecyclepayloads, so even once the event is published,GET /api/comms/eventswon't surfaceTaskPosted/TaskClaimed/TaskCompleted. Worth extending to matchEventPayload::System(SystemEvent::Task*)so the comms feed is complete.