-- Research pipeline v2: topology_kind on the topic + a persisted outcome per -- run so `reviewing`/`publishing`/`published` states have an artifact to -- point at instead of the original prompt. -- -- topology_kind — the graph shape start_topic builds when firing this -- topic. Default 'hub_spoke' matches the prior implicit behavior. -- Wizard exposes: hub_spoke, pipeline, hierarchical, star_moe. The -- coordinator prompt in start_topic branches on this string. -- -- research_outcomes — one row per run's final synthesis. Versioned per -- topic (1, 2, …) so reject-with-revision loops keep history. body_md -- is the coordinator's final_output verbatim; produced_by_run_id -- back-links to the topology_runs row that made it (nullable + SET -- NULL cascade so an old run being pruned doesn't drop the artifact). ALTER TABLE research_topics ADD COLUMN topology_kind TEXT NOT NULL DEFAULT 'hub_spoke'; CREATE TABLE research_outcomes ( id UUID PRIMARY KEY, topic_id UUID NOT NULL REFERENCES research_topics (id) ON DELETE CASCADE, version INTEGER NOT NULL, body_md TEXT NOT NULL, produced_by_run_id UUID REFERENCES topology_runs (id) ON DELETE SET NULL, created_at TIMESTAMPTZ NOT NULL DEFAULT now(), UNIQUE (topic_id, version) ); CREATE INDEX research_outcomes_topic_idx ON research_outcomes (topic_id, version DESC);