Engineering/AI documentation
Context DAG
The Context DAG tab visualizes or inspects relationships across project context nodes.
Concepts: rag
Implementation Summary
The Context DAG tab visualizes or inspects relationships across project context nodes. Its chat-session picker only renders sessions from the active project, and every Context DAG API call carries the active project id so stale session ids cannot read a previous project's graph.
Frontend Surface
frontend/src/components/memory/MemoryView.tsxfrontend/src/components/memory/ContextDAGView.tsxfrontend/src/stores/sessionStore.tsfrontend/src/lib/contextDagApi.tsbackend/app/api/routes/context_dag.pybackend/app/core/context_dag.py
State, API, And Backend Contracts
Stores
frontend/src/stores/sessionStore.ts
API And Backend
backend/app/api/routes/context_dag.py
Architecture Notes
- Summaries survive reasoning models (2026-09-26, G2): a summary call runs with thinking off; if it
stops at the dag_summary_max_tokens cap with no text it is retried once with 8,192 tokens, and
an empty result is logged with its stop reason before the mechanical fallback. dag_summary_endpoint_id
routes summaries to a chosen Pi endpoint. Measured on 300-message conversations: fallbacks 50/50
-> 0/50, planted facts recalled from summaries 0% -> 48%; grep_history recall finds 100%.
Harness: python -m app.evals.dag_eval.
- The feature is mounted through
frontend/src/components/memory/MemoryView.tsxand the UI navigation path recorded in the inventory. ContextDAGViewderivesscopedSessionsfrom the active project before rendering the session selector and derivesscopedActiveSessionIdbefore calling context DAG structure, health, expand, grep, or compact APIs.backend/app/api/routes/context_dag.pyrequiresproject_idon session-by-id routes and loads the session by bothsession_idandproject_idbefore returning structure, health, expansion, search, node metadata, or compaction output.- Chat-triggered compaction is owned by a per-session task registry. Duplicate schedules reuse the active task, unexpected failures are logged, and application shutdown drains current-loop work while cancelling stale cross-loop tasks before the database engine closes.
- When no active project session is selected, the DAG stays in the empty selection state instead of rendering or querying a session from another project.
- History Search renders its result count with an explicit separator before the query label, including the zero-result state.
- The frontmatter and manifest entries are the durable contract for agents updating this page after code changes.
- When the referenced component, store, route, agent, skill, or test behavior changes, regenerate and validate the feature documentation.
Agents, Skills, LLM, MCP, And Permissions
- RAG-related behavior depends on project context, documents, memory, or retrieval material referenced by the cited stores and routes.
Tests And Verification
tests/test_context_dag.pytests/test_context_dag_ui_contracts.pytests/test_project_scope_contracts.py
Related Features
Related Concepts
Compass Evidence
- Spec/task: CF-SPEC-60 / CF-761
- Inventory source:
docs/features/inventory.json
When To Update
- Update this page whenever the listed UI components, stores, routes, model behavior, permissions, or tests change.
- Regenerate the site and machine manifests with
python scripts/feature_docs.py --seed-missing --generate-site --check.