Skip to content

POST /api/comms/task bypasses kernel wrapper, skips TaskPosted event publish #2788

Description

@neo-wanderer

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

  1. Register a trigger: POST /api/triggers with {"pattern": "TaskPosted", ...}
  2. Post a task: POST /api/comms/task with {"title": "t", "description": "d"}
  3. GET /api/triggersfire_count stays at 0.

Posting the same task via an agent's task_post tool (which goes through KernelHandle::task_postKernel::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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/apiREST/WS endpoints and dashboardarea/kernelCore kernel (scheduling, RBAC, workflows)has-prA pull request has been linked to this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions