Context Documents

Generate a legacy + Temporal tree pair for A/B comparison (internal admin tool)

Kick off both the legacy BackgroundTask path AND the Temporal workflow against the same app data, in a single call.

Admin-only — used by Hyperspell employees to validate Temporal-vs-legacy parity. Reads (and emits via the GET diff endpoint) both engines' raw metadata, including doc_manifests and source_manifest. Will be deleted once the Temporal cutover is complete; no public-API stability promise.

Wraps the dispatch logic the comparison UI was previously doing from the browser (two separate POSTs to /tree and /tree-temporal). This endpoint guarantees both rows are created with identical request inputs, in a single DB transaction, before any dispatch happens — so a script or eval framework can run the comparison without needing a browser.

The legacy side dispatches synchronously into a FastAPI BackgroundTask (fire-and-forget, can't fail at dispatch). The Temporal side dispatches via _start_tree_workflow (gRPC; can fail in three ways: known ALREADY_EXISTS, ambiguous RPCError, or anything unexpected). All three failure modes mark the temporal row FAILED via the orphan-cleanup helper and let the legacy run continue — the endpoint always returns 200 with both tree_ids so the caller's polling loop sees a terminal state on the failed side.

post/context-documents/tree/compare

Request body

sourcesstring[] nullable

Integration sources to include (e.g., ['gmail', 'slack']). Defaults to all.

user_idstring nullable

User ID for personal tier scoping. When set, personal/context.md is generated from this user's data only. Company and workstream tiers still use all data.

workstream_namestring nullable

Generate docs for this workstream only (skip auto-detection).

Response

Successful Response

Changes