Repository navigation
Description
Summary
Add a temporal flow view to the graph explorer that visualizes how knowledge about a subject evolves over time. Facts are arranged chronologically on a timeline axis with edges showing how topics connect across days — answering "How did my understanding of X develop from January to February?"
Parent epic: #204
Background
This is the feature that no code graph tool can do — code relationships are structural (static), but knowledge relationships are temporal (they evolve). Cortex already stores created_at timestamps on every fact. This feature surfaces that temporal dimension visually.
Use cases:
- "Show me how my trading strategy evolved over the last month"
- "When did I first learn about Public.com? What decisions followed?"
- "What's the trajectory of the Eyes Web project?"
- "Timeline of all decisions about agent architecture"
Implementation Plan
1. Timeline API endpoint
GET /api/timeline?subject=trading&from=2026-01-01&to=2026-02-28&bucket=day
Parameters:
| Param | Type | Default | Description |
|---|---|---|---|
subject |
string | required | Subject to trace through time |
from |
ISO date | 30 days ago | Start date |
to |
ISO date | today | End date |
bucket |
day|week|month |
day |
Time granularity |
min_confidence |
float | 0.3 | Minimum confidence |
related |
bool | true | Include related subjects (1-hop connections) |
Response:
{
"subject": "trading",
"range": {"from": "2026-01-01", "to": "2026-02-28"},
"bucket": "day",
"buckets": [
{
"date": "2026-01-15",
"facts": [
{
"id": 800,
"subject": "trading",
"predicate": "uses strategy",
"object": "EMA 7/28 crossover",
"confidence": 0.45,
"source": "memory/2026-01-15.md"
}
],
"related_subjects": ["ema", "alpaca"],
"fact_count": 3,
"avg_confidence": 0.72
},
{
"date": "2026-02-09",
"facts": [
{
"id": 1234,
"subject": "trading",
"predicate": "uses strategy",
"object": "ORB (Opening Range Breakout)",
"confidence": 0.95,
"source": "memory/2026-02-09.md"
}
],
"related_subjects": ["orb", "options", "alpaca"],
"fact_count": 8,
"avg_confidence": 0.88
}
],
"transitions": [
{
"from_date": "2026-01-15",
"to_date": "2026-02-09",
"type": "superseded",
"from_fact": 800,
"to_fact": 1234,
"description": "EMA strategy replaced by ORB strategy"
}
],
"subject_first_seen": "2025-12-20",
"subject_last_updated": "2026-02-24",
"total_facts_over_time": 47,
"confidence_trend": [
{"date": "2026-01-01", "avg": 0.65},
{"date": "2026-01-15", "avg": 0.72},
{"date": "2026-02-01", "avg": 0.81},
{"date": "2026-02-15", "avg": 0.88}
]
}2. Transition detection (internal/graph/temporal.go)
Detect when knowledge changes over time:
type TransitionType string
const (
TransitionSuperseded TransitionType = "superseded" // Old fact replaced by new
TransitionRefined TransitionType = "refined" // Confidence increased
TransitionDecayed TransitionType = "decayed" // Confidence dropped
TransitionExpanded TransitionType = "expanded" // New related facts added
TransitionContradicted TransitionType = "contradicted" // Conflicting facts appeared
)Detection rules:
- Superseded: Two facts with same subject + similar predicate but different objects, where newer has higher confidence
- Refined: Same fact's confidence increased between reinforcements
- Decayed: Confidence dropped below threshold since last check
- Expanded: New subjects appeared in the 1-hop neighborhood over time
- Contradicted: Two active facts with opposing predicates/objects (reuse existing
cortex conflictslogic)
3. Graph UI — Timeline View
Layout: Horizontal timeline (left = past, right = present)
┌─────────────────────────────────────────────────────────┐
│ Jan 15 Jan 28 Feb 9 Feb 24 │
│ │ │ │ │ │
│ ●──────────────●──────→→→→───●───────────────● │
│ EMA Volume ORB Options │
│ strategy filter strategy live on │
│ (0.45) removed locked Public │
│ (0.72) (0.95) (0.91) │
│ │
│ ─ ─ superseded ─ ─ ─ ─ ─ ─ ─ ┘ │
└─────────────────────────────────────────────────────────┘
UI components:
-
Timeline axis — horizontal, zoomable/pannable
- Tick marks at bucket intervals (day/week/month)
- Date labels below axis
-
Fact nodes on timeline — positioned at their
created_atdate- Size = fact count in that bucket
- Color = confidence (green → yellow → red gradient)
- Hover = full fact text + metadata tooltip
- Click = select + show in detail panel
-
Transition edges — curved arrows between nodes
- Dashed red for "superseded"
- Solid green for "refined"
- Dotted gray for "decayed"
- Blue for "expanded"
-
Confidence trend line — optional overlay showing avg confidence over time
- Thin line chart superimposed on timeline
- Shows whether knowledge about this subject is getting more or less certain
-
Related subjects swim lanes — optional
- Parallel timelines for related subjects below the main one
- Shows how connected topics co-evolve
Controls:
- Subject search (same as main search)
- Date range picker (from/to)
- Bucket size selector (day/week/month)
- Toggle: show/hide transitions
- Toggle: show/hide confidence trend
- Toggle: show/hide related subjects
4. Rendering approach
Use D3.js (already in the visualizer) with a custom timeline layout:
- X-axis = time (d3.scaleTime)
- Y-axis = swim lanes (main subject + related subjects)
- Nodes = circles on the timeline
- Edges = d3.linkHorizontal() curves between time points
- Confidence trend = d3.line() with d3.curveMonotoneX
This is a separate view mode from the force-directed graph — switch via a tab/toggle at the top of the canvas area.
5. Server handler
mux.HandleFunc("/api/timeline", func(w http.ResponseWriter, r *http.Request) {
handleTimelineAPI(w, r, cfg.Store)
})Query strategy:
- Select all facts where subject matches (case-insensitive) within date range
- Group by
bucket(day/week/month) using SQLitestrftime() - If
related=true, also query 1-hop connected subjects and include their facts - Run transition detection on chronologically sorted facts
- Compute confidence trend by averaging per-bucket
Testing
| Test | Description |
|---|---|
TestTimelineBasicSubject |
Returns bucketed facts for a known subject |
TestTimelineDateRange |
From/to filters work correctly |
TestTimelineBucketDay |
Daily bucketing groups facts correctly |
TestTimelineBucketWeek |
Weekly bucketing aggregates across days |
TestTimelineTransitionSuperseded |
Detects when a fact is replaced |
TestTimelineTransitionRefined |
Detects confidence increase |
TestTimelineConfidenceTrend |
Trend line has correct averages |
TestTimelineRelatedSubjects |
Related subjects included when flag is true |
TestTimelineEmptyRange |
No facts in range returns empty buckets |
TestTimelineUnknownSubject |
Returns 404 for nonexistent subject |
Acceptance Criteria
-
GET /api/timeline?subject=tradingreturns bucketed temporal data - Transition detection identifies superseded/refined/decayed facts
- Graph UI has "Timeline" view mode (tab/toggle)
- Timeline renders with D3.js horizontal layout
- Confidence trend line overlays on timeline
- Related subjects show as parallel swim lanes
- Transitions rendered as colored curved edges
- Date range and bucket size controls functional
- 10+ new tests passing
- Existing graph views unaffected
Files to Create/Modify
| File | Change |
|---|---|
internal/graph/temporal.go |
New — timeline query, bucketing, transition detection |
internal/graph/temporal_test.go |
New — tests |
internal/graph/server.go |
Register /api/timeline handler |
internal/graph/visualizer.html |
Timeline view mode, D3 timeline layout, confidence trend, swim lanes |
Estimated Effort
Large — new endpoint with non-trivial transition detection logic + entirely new UI visualization mode. The D3 timeline layout is the most complex piece (custom, not a standard D3 example).
Design Notes
- Why horizontal timeline, not vertical? Horizontal maps naturally to "left = past, right = present" which is the standard mental model. Vertical timelines work for chat/feed UIs but not for graph exploration.
- Why not reuse force-directed layout with time as X-axis? Force-directed fights against fixed positions. A dedicated timeline layout is cleaner and more readable.
- Swim lanes are optional — start with single-subject timeline, add swim lanes as a follow-up if the basic version works well.
Activity
feat(graph): temporal flow timeline view (#209)