Three connected changes that turn "Start research" from a status flip into a real pipeline that produces a reviewable artifact: - Migration 0036: adds research_topics.topology_kind (default 'hub_spoke') and a new research_outcomes table (id, topic_id, version DESC, body_md, produced_by_run_id, created_at) so each run's final synthesis is versioned and persistent. - Wizard now has a topology picker in the Outcome step — hub_spoke / pipeline / hierarchical / star_moe — with copy that steers users to the right shape (Pipeline for research → distill → analyze → implement rosters, hub_spoke for the coordinator- and-specialists default). - start_topic reads the chosen topology_kind, parses it into a cm_topology::TopologyKind, and dispatches a per-shape coordinator prompt via build_coordinator_task. Pipeline explicitly tells stage 1 not to write the final artifact and propagates a "final stage MUST emit a complete markdown document with measurable acceptance criteria" instruction downstream. The graph builder is called with the topology the user actually picked instead of hard-coded HubSpoke. - topology_worker::freeze_research_outcome fires after every successful complete(). It looks up research_topic_id on the run; if set and final_output is non-empty, it inserts a new research_outcomes row (version auto-derived server-side via coalesce(max(version), 0) + 1). Best-effort — a DB hiccup logs but doesn't fail the run. - TopicDetail now includes topology_kind and latest_outcome. ResearchCanvas swaps in the outcome's body_md (rendered as pre-wrap markdown, versioned header, produced-at timestamp) whenever an outcome exists; the original prompt collapses into an "Original prompt" <details> below so it's still one click away. Pre-run topics still show the description as before. Follow-ups still open: reject-with-revision loop feeding the coordinator, publishing → published transition + real artifact export (md / pdf), and an approvals inbox surface for reviewers.
30 lines
1.4 KiB
SQL
30 lines
1.4 KiB
SQL
-- 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);
|