-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0004_add_propagation_engine.sql
More file actions
47 lines (43 loc) · 2.03 KB
/
0004_add_propagation_engine.sql
File metadata and controls
47 lines (43 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* 🎯 SEMANTIC INTENT: Layer 3 - Propagation Engine Schema
*
* PURPOSE: Add propagation prediction metadata to context_snapshots
*
* WAKE INTELLIGENCE LAYER 3 (FUTURE):
* - Predicts WHAT contexts will be needed next
* - Based on temporal patterns, causal chains, and usage frequency
* - Enables proactive pre-fetching and caching
*
* NEW COLUMNS:
* - prediction_score: 0.0-1.0 likelihood of future access (composite score)
* - last_predicted: When prediction was last calculated (ISO timestamp)
* - predicted_next_access: Estimated next access time (ISO timestamp)
* - propagation_reason: Why predicted (JSON array of reasons)
*
* MIGRATION STRATEGY:
* - Add columns with default NULL (all existing contexts unpredicted)
* - No data migration needed (predictions computed on-demand)
* - Backward compatible (can query with/without predictions)
*
* OBSERVABLE ANCHORING:
* - All predictions based on measurable access patterns
* - Deterministic scoring algorithms
* - No subjective interpretation
*/
-- Add Layer 3: Propagation Engine columns
ALTER TABLE context_snapshots ADD COLUMN prediction_score REAL DEFAULT NULL;
ALTER TABLE context_snapshots ADD COLUMN last_predicted TEXT DEFAULT NULL;
ALTER TABLE context_snapshots ADD COLUMN predicted_next_access TEXT DEFAULT NULL;
ALTER TABLE context_snapshots ADD COLUMN propagation_reason TEXT DEFAULT NULL;
-- Create index for prediction-based queries (find high-score contexts)
CREATE INDEX IF NOT EXISTS idx_context_snapshots_prediction_score
ON context_snapshots(prediction_score DESC)
WHERE prediction_score IS NOT NULL;
-- Create index for prediction staleness queries (find contexts needing re-prediction)
CREATE INDEX IF NOT EXISTS idx_context_snapshots_last_predicted
ON context_snapshots(last_predicted ASC)
WHERE last_predicted IS NOT NULL;
-- Create composite index for project + prediction score (fetch top predictions per project)
CREATE INDEX IF NOT EXISTS idx_context_snapshots_project_prediction
ON context_snapshots(project, prediction_score DESC)
WHERE prediction_score IS NOT NULL;