stream.analysis¶
stream.analysis ¶
Project-scoped analysis over grounded notes.
Two capabilities, both reusing the zettelkasten matrix engine (tables.py) as
the read-time projection of a project's notes:
- :func:
build_matrix/ :func:matrix_to_csv/ :func:export_csv-- assemble a comparison grid for a(project, schema)and emit it as CSV. Deterministic by default (no LLM): cells fill from the dimension-tagged notes the extraction pipeline wrote. - :func:
synthesize_narrative-- hand the grounded matrix (values + verbatim evidence quotes) to a :class:~stream.protocols.Driverand ask for a narrative synthesis, optionally written back as an agent-authored_crosssynthesis note (taggedorigin:agentfor governance).
The matrix is the same one the dashboard renders, so CSV/synthesis stay
consistent with the UI. tables.py and the store are imported lazily.
build_matrix ¶
build_matrix(project: str, *, schema: str = '', columns: list[dict[str, Any]] | None = None, row_axis: dict[str, Any] | None = None, ai: bool = False, driver: Driver | None = None, model: str = '', table_id: str = 'stream-matrix', title: str = '') -> dict[str, Any]
Build the synthesis matrix for a project.
By default (ai=False) this is a cost-free deterministic projection:
dimension-tagged notes route into schema_tag columns, one row per source.
Pass ai=True with a driver to also fill free-text prompt columns
and per-cell summaries via the agent (this persists the grid).
Source code in stream/analysis.py
matrix_to_csv ¶
Render a built matrix as CSV text (one row per source, columns as headers).
Source code in stream/analysis.py
export_csv ¶
export_csv(project: str, path: str, *, schema: str = '', columns: list[dict[str, Any]] | None = None, **kwargs: Any) -> str
Build the matrix and write it to path as CSV. Returns the path.
Source code in stream/analysis.py
render_grounded_matrix ¶
Render the matrix as grounded text: values plus verbatim evidence quotes.
Source code in stream/analysis.py
synthesize_narrative ¶
synthesize_narrative(project: str, *, driver: Driver, schema: str = '', columns: list[dict[str, Any]] | None = None, question: str = '', model: str = '', write_back: bool = False, cross_graph: str = _CROSS_GRAPH, title: str = '') -> dict[str, Any]
Build the grounded matrix and ask a Driver to synthesize a narrative.
Returns {narrative, matrix, note_id}. When write_back is set the
narrative is committed as a synthesis note in cross_graph, claimed by
project and tagged origin:agent so agent-authored writeback is
distinguishable from human notes (governance).