Skip to content

graph build crashes on its first statement: the module forwarders were deleted instead of fixed #134

Description

@cdeust

Symptom

On 3.1.0 the graph never builds. /api/graph/progress reports
phase: "starting", pct: 0.0 and never advances; Graph, Brain, Knowledge, Board and Wiki stay
empty. Trace is unaffected — it does not go through this builder. Nothing is lost or corrupted:
the build dies before reading anything.

[cortex] background build error: module 'cortex_viz.server.graph_event_stream' has no attribute 'reset'
  File "cortex_viz/server/graph_build_run.py", line 155, in run_build
    _events.reset()
AttributeError

Root cause — and what it is not

45d4a80 deleted the module-level emit/close/reset forwarders from graph_event_stream,
justified in the code as: they "had never had a caller in this repository's history".

That premise is false. They had four:

caller call
graph_build_run.py:155 _events.reset()
graph_build_run.py:234 _events.emit(...)
graph_build_run.py finally _ev.close()
graph_build_merge.py:136 events.emit(...) — handed the module, per its own docstring

The commit's other stated reason is the real defect: emit grew an event_meta parameter and the
forwarder silently dropped it. That is a bug in the forwarder, and the reason to fix it. It was
used instead as the reason to delete it — so the root cause (a forwarder that had drifted out of
sync with the method it forwards to) was never addressed, and the deletion took four working
callers down with it.

The module is also published API: dropping three public functions in a patch-level move breaks any
consumer outside this repository, not just these callers.

What the fix must do

Restore the three forwarders plugged and functional — not route the callers around them:

  • emit(label, nodes, edges, *, chunk=1000, event_meta=None) — forwards every parameter,
    event_meta included. The drift that motivated the deletion is what gets fixed here.
  • close() and reset() restored, delegating to the singleton.
  • graph_build_run.py and graph_build_merge.py keep calling the module — unchanged.
  • Remove the "there are deliberately no module-level forwarders" comment; it now documents a
    decision that was withdrawn.

Acceptance criteria

  • A test asserts each forwarder delegates to the process singleton returned by get_stream().
  • A test asserts emit's forwarder carries event_meta through to what a subscriber receives —
    the exact drift that started this. It must fail against the pre-45d4a80 forwarder.
  • A test exercises the binding the production build actually uses, so a call site and the module
    cannot drift apart again. Every existing merge test injects a fake stream, which is why none of
    them caught this: the defect was in how the caller obtains the stream, not in what it does
    with it.
  • End-to-end: the standalone server advances past starting and reaches layout bake, with zero
    background build error in the log.

Notes

Verified locally that restoring the call path makes the build run to completion (baseline_ready,
85 hooks, 49 discussion_agents, 36752 memories, then layout bake (DrL)). PR #133 took the wrong
route — it adapted the callers to the deletion, which dresses a removal up as a solution — and is
closed in favour of this issue. Its analysis of the failure is still accurate and reusable.

See also the silent-close() defect, filed separately: it survives this fix independently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions