Sprint Brief: Knowledge Architecture KA-5
Continuity Integration + Dashboard Visualization
What You’re Building
KA-1 through KA-4 built the knowledge graph, populated it via structural assignment, wired traversal retrieval into session-start and recall, and prepared structural features for the predictive scorer. But two things are missing:
-
Checkpoint structural snapshots — session checkpoints don’t capture which entities, aspects, and constraints were in scope. Recovery injection can’t prioritize structural context because it doesn’t know what was structurally relevant in the prior session.
-
Dashboard visibility — the knowledge graph is invisible to users. There’s no way to browse entities, see aspect/attribute structure, inspect traversal behavior, or view predictor comparison slices. The dashboard has Memory, Embeddings, Pipeline, and Engine tabs but nothing for the structural layer.
This sprint adds structural snapshots to the checkpoint system and builds a “Knowledge” dashboard tab that surfaces entity browsing, traversal telemetry, and predictor comparison slices.
Think of it as: KA-1-4 built the engine, KA-5 adds the instrument panel and the flight recorder.
Required Reading
docs/specs/INDEX.md— Integration Contracts, especially “Knowledge Architecture <-> Session Continuity”docs/specs/complete/knowledge-architecture-schema.md— sections 10 (continuity integration), 11 (phase plan, KA-5)docs/specs/approved/predictive-memory-scorer.md— section 4.6 (dashboard predictor tab) for design patternsdocs/specs/SPRINT-BRIEF-KA4.md— predictor comparisons (what this visualizes)
Prerequisites
KA-1 through KA-4 must be complete:
- KA tables populated by structural assignment pipeline
- Traversal retrieval wired into session-start and recall
- Structural features assembled for predictor candidates
predictor_comparisonsandpredictor_training_logtables exist- Comparison recording helpers and API endpoints exist
The dashboard (packages/cli/dashboard/) must build and serve. The
existing tab/navigation system must be understood — this sprint adds
a new tab to it.
Deliverables
1. Structural snapshot in checkpoints
Where: packages/daemon/src/session-checkpoints.ts
Extend WriteCheckpointParams and CheckpointRow with optional
structural snapshot fields:
// Add to WriteCheckpointParams:
readonly focalEntityIds?: ReadonlyArray<string>;
readonly focalEntityNames?: ReadonlyArray<string>;
readonly activeAspectIds?: ReadonlyArray<string>;
readonly surfacedConstraintCount?: number;
readonly traversalMemoryCount?: number;
These are stored as JSON arrays in new nullable TEXT columns on the
session_checkpoints table (via migration).
Migration: New migration 021-checkpoint-structural.ts:
-- Idempotent column additions using PRAGMA table_info pattern
ALTER TABLE session_checkpoints ADD COLUMN focal_entity_ids TEXT;
ALTER TABLE session_checkpoints ADD COLUMN focal_entity_names TEXT;
ALTER TABLE session_checkpoints ADD COLUMN active_aspect_ids TEXT;
ALTER TABLE session_checkpoints ADD COLUMN surfaced_constraint_count INTEGER;
ALTER TABLE session_checkpoints ADD COLUMN traversal_memory_count INTEGER;
Register as version 21 in packages/core/src/migrations/index.ts.
Wiring: In packages/daemon/src/hooks.ts, inside
handleSessionStart after traversal completes, capture the structural
snapshot data. Pass it through to checkpoint writes (periodic,
pre-compaction, and session-end digests).
The focal entity IDs and names come from resolveFocalEntities().
Active aspect IDs come from the traversal result (the aspects that
were walked). Constraint count and traversal memory count are already
tracked as telemetry variables — just forward them.
2. Recovery injection with structural priority
Where: packages/daemon/src/hooks.ts, recovery injection block
(around line 1135)
When a checkpoint has structural snapshot fields, the recovery section should include them as structured context:
## Session Recovery Context
## Session Checkpoint
Project: /home/nicholai/signet/signetai
Prompts: 12 | Duration: 45m
### Structural Context
Focal entities: signetai, signet-core
Active constraints: 3
Traversal memories: 24
### Recent Prompts
- fix the build error in daemon
- add the new migration
The structural context section is injected BEFORE the recent prompts section when available. When checkpoint budget is tight, structural context takes priority over prompt snippets (truncate snippets first, keep structural context).
Implementation: Update formatPeriodicDigest,
formatPreCompactionDigest, and formatSessionEndDigest to accept
optional structural snapshot data and include the structural context
section.
3. Knowledge Graph API endpoints
Where: packages/daemon/src/daemon.ts
Add read-only API endpoints for browsing the knowledge graph:
GET /api/knowledge/entities
?agent_id=default
?type=project|person|system|tool|concept|skill|task
?q=signet (search canonical_name)
?limit=50&offset=0
GET /api/knowledge/entities/:id
?agent_id=default
Returns: entity + aspects + attribute counts + dependency counts
+ structural density
GET /api/knowledge/entities/:id/aspects
?agent_id=default
Returns: aspects with attribute counts per aspect
GET /api/knowledge/entities/:id/aspects/:aspectId/attributes
?agent_id=default
?kind=attribute|constraint
?status=active|superseded
Returns: paginated attributes
GET /api/knowledge/entities/:id/dependencies
?agent_id=default
?direction=outgoing|incoming|both (default: both)
Returns: dependency edges with target entity names
GET /api/knowledge/stats
?agent_id=default
Returns: {
entityCount, aspectCount, attributeCount,
constraintCount, dependencyCount,
unassignedMemoryCount,
coveragePercent // assigned / total active memories
}
GET /api/knowledge/traversal/status
Returns: latest TraversalStatusSnapshot (already exists via
getTraversalStatus(), just expose it)
Implementation notes:
- Use
DbAccessorpattern consistent with existing endpoints - All queries include
agent_idscoping - Entity search uses
canonical_name LIKE ?with%wrapping - Attribute queries support
kindandstatusfilters - Stats endpoint computes coverage: count memories with at least one
entity_attributesrow vs total active memories - Traversal status is already tracked in-memory by
graph-traversal.ts— just expose the getter
4. Dashboard “Knowledge” tab
Where: packages/cli/dashboard/src/
Add a new “Knowledge” tab to the dashboard. This requires changes to:
-
Navigation: Add
"knowledge"toTabIdunion andVALID_TABSinnavigation.svelte.ts. Add to theMEMORY_TABSgroup (it’s a memory-adjacent view). Add page header inpage-headers.ts. -
Sidebar: Add nav item in
app-sidebar.svelte(use a graph or network icon from lucide). -
Tab component: New file
packages/cli/dashboard/src/lib/components/tabs/KnowledgeTab.svelte -
Route wiring: Add the tab to the conditional rendering in
+page.svelte
Tab layout — three sections:
4a. Entity Browser
Top section. A searchable list of entities with type filtering.
- Search input + entity type dropdown filter
- Entity cards showing: name, type badge, aspect count, attribute count, constraint count, dependency count
- Click an entity to expand an inline detail panel showing:
- Aspects list (sorted by weight DESC) with attribute counts
- Click an aspect to see its attributes/constraints
- Dependency edges (both directions) with target entity names
- Structural density metrics
Data source: GET /api/knowledge/entities, then
GET /api/knowledge/entities/:id for detail.
4b. Traversal Status
Middle section. Shows the latest traversal snapshot from session-start.
- Focal entity names and source (project/query/checkpoint)
- Entities traversed count
- Memory IDs collected
- Constraints surfaced
- Timeout indicator (yellow badge if timed out)
- Auto-refreshes on tab focus
Data source: GET /api/knowledge/traversal/status
4c. Knowledge Stats
Bottom section. Overview metrics card.
- Total entities / aspects / attributes / constraints / dependencies
- Structural coverage bar (% of memories with structural assignment)
- Unassigned memory count
Data source: GET /api/knowledge/stats
Design guidelines:
- Use shadcn-svelte components (Card, Badge, Input, Select, Skeleton)
- Follow existing tab patterns (see
PipelineTab.sveltefor layout reference,MemoryTab.sveltefor search patterns) - Use the same CSS variable system (
--sig-*) as existing tabs - Loading states use Skeleton components
- Error states show inline error messages, don’t crash the tab
5. Predictor comparison visualization
Where: packages/cli/dashboard/src/lib/components/tabs/KnowledgeTab.svelte
(or a sub-component)
Add a “Predictor Slices” section to the Knowledge tab that visualizes the comparison data from KA-4’s API endpoints.
5a. By-Project Slice
Table showing per-project predictor performance:
| Project | Wins | Losses | Win Rate | Avg Margin |
|---|
With a bar chart or inline sparkline for win rate per project.
Data source: GET /api/predictor/comparisons/by-project
5b. By-Entity Slice
Same table format but sliced by focal entity:
| Entity | Wins | Losses | Win Rate | Avg Margin |
|---|
Data source: GET /api/predictor/comparisons/by-entity
5c. Date range filter
Both slice views share a “since” date picker. Default to last 7 days. Use the existing shadcn-svelte Calendar component.
Guard: If no comparisons exist yet (predictor hasn’t run), show an informational message: “No predictor comparisons yet. Comparisons appear after the predictive scorer completes its first session.”
6. Training log visualization
Where: Same Knowledge tab, under predictor slices.
A simple table of recent training runs from
GET /api/predictor/training:
| Version | Loss | Samples | Duration | Canary NDCG | Date |
|---|
Sorted by created_at DESC, limited to 20 rows.
If canary metrics are available (canary_ndcg not null), show them.
If not, show ”—” placeholders.
Guard: Same empty-state message as comparisons if no training runs exist.
7. Continuity state structural extension
Where: packages/daemon/src/continuity-state.ts
Extend ContinuityState to accumulate structural snapshot data
during the session:
// Add to ContinuityState:
focalEntityIds: string[];
focalEntityNames: string[];
activeAspectIds: string[];
surfacedConstraintCount: number;
traversalMemoryCount: number;
Add a helper to record structural context from session-start:
export function recordStructuralContext(
sessionKey: string | undefined,
ctx: {
readonly focalEntityIds: string[];
readonly focalEntityNames: string[];
readonly activeAspectIds: string[];
readonly surfacedConstraintCount: number;
readonly traversalMemoryCount: number;
},
): void;
Wire this in hooks.ts after traversal completes, so the data flows
through to checkpoint writes.
Key Files
packages/daemon/src/session-checkpoints.ts— structural snapshot fields on checkpointspackages/daemon/src/continuity-state.ts— structural context accumulationpackages/daemon/src/hooks.ts— wire structural snapshot into checkpoints and recovery injectionpackages/daemon/src/daemon.ts— knowledge graph API endpointspackages/core/src/migrations/021-checkpoint-structural.ts— new migration for checkpoint columnspackages/core/src/migrations/index.ts— register migration 021packages/cli/dashboard/src/lib/stores/navigation.svelte.ts— add Knowledge tabpackages/cli/dashboard/src/lib/components/layout/page-headers.ts— Knowledge headerpackages/cli/dashboard/src/lib/components/app-sidebar.svelte— sidebar nav itempackages/cli/dashboard/src/lib/components/tabs/KnowledgeTab.svelte— new tab componentpackages/cli/dashboard/src/routes/+page.svelte— tab renderingpackages/daemon/src/pipeline/graph-traversal.ts— read (getTraversalStatus, not modified)packages/daemon/src/knowledge-graph.ts— read helpers (not modified)packages/daemon/src/predictor-comparisons.ts— read helpers (not modified)
What NOT to Build
- Predictor client or sidecar lifecycle (scorer phase 3)
- RRF fusion in session-start (scorer phase 3)
- Success rate EMA tracking (scorer phase 3)
- Training trigger from session-end (scorer phase 3)
- Full predictor dashboard tab (scorer phase 4) — KA-5 surfaces comparison slices within the Knowledge tab, not the full predictor observability suite
- Entity/aspect editing UI (future — read-only browsing only)
- Graph visualization with force-directed layout (future — text-based browsing for now)
- Multi-hop traversal configuration UI (future)
Verification
bun run build— no type errorsbun test— existing tests passbun run typecheck— clean- Migration 021 adds checkpoint columns idempotently
- Checkpoint writes include structural snapshot when traversal data is available
- Checkpoint writes work correctly when no traversal data exists (null columns, backwards compatible)
- Recovery injection includes structural context section when checkpoint has snapshot data
- Recovery injection works normally when checkpoint has no snapshot (backwards compatible)
GET /api/knowledge/entitiesreturns paginated entity list with type filteringGET /api/knowledge/entities/:idreturns entity detail with aspects, densityGET /api/knowledge/statsreturns correct coverage percentageGET /api/knowledge/traversal/statusreturns latest snapshot- Knowledge tab renders in dashboard with entity browser
- Knowledge tab shows traversal status section
- Knowledge tab shows stats overview
- Predictor slice tables render with comparison data
- Predictor slice tables show empty state when no data exists
- Training log table renders with training history
- Tab navigation works (hash routing, sidebar active state)
- All API endpoints include agent_id scoping