Goal
Add trust_score (0-1) with confidence_interval to knowledge_edges table. Compute trust from evidence chain depth, source paper quality (impact factor, citations, recency), number of independent confirmations, and contradiction count. Implement trust propagation where downstream edges inherit reduced trust from upstream. Visualize trust on /graph.
Acceptance Criteria
☑ Migration adds trust_score, trust_confidence_low, trust_confidence_high columns to knowledge_edges
☑ compute_edge_trust() function calculates trust based on: evidence chain depth, paper quality (citations, year), confirmations, contradictions
☑ propagate_edge_trust() function dampens trust for downstream edges (0.85x per hop)
☑ recompute_edge_trust() batch function recomputes trust for all edges of an analysis
☑ /api/graph returns trust_score, trust_confidence_low, trust_confidence_high in edge objects
☑ Graph visualization shows trust on edge hover (tooltip with trust score and confidence interval)
☑ Edge opacity/width reflects trust level in graph.html
Approach
1. Migration (095_edge_trust_scores.py)
Add columns to knowledge_edges:
trust_score REAL DEFAULT 0.5 — overall trust 0-1
trust_confidence_low REAL DEFAULT 0.3 — lower bound of confidence interval
trust_confidence_high REAL DEFAULT 0.7 — upper bound
trust_computation_factors TEXT — JSON blob with breakdown
2. Trust Computation (scidex/core/edge_trust.py)
New module with:
source_quality_score(source_id, source_type) — paper quality from citation_count and year (recency)
compute_edge_trust(edge_id, db) — full trust computation for a single edge
count_confirmations(edge_id, db) — number of independent analyses supporting this edge
count_contradictions(edge_id, db) — number of analyses contradicting this edge
chain_depth_score(edge_id, db) — how many hops from primary evidence
propagate_edge_trust(edge_id, db, visited=None) — recursive downstream trust dampening
recompute_edge_trust_for_analysis(analysis_id, db) — batch recompute
Trust formula:
trust = base_quality * depth_penalty * confirmation_boost * contradiction_penalty
base_quality = paper_citation_score * recency_factor
depth_penalty = 0.9^chain_depth
confirmation_boost = 1 + 0.1 * n_confirmations
contradiction_penalty = max(0.3, 1 - 0.2 * n_contradictions)
confidence_interval_width = inversely proportional to evidence count
3. API Updates (api.py)
- Modify
/api/graph to include trust fields in edge response
- Add
/api/graph/{analysis_id}/trust-recompute endpoint to trigger recomputation
- Add
/api/graph/trust-recompute-all endpoint for batch backfill
4. Visualization (site/graph.html)
- Add trust score to edge tooltip
- Edge color based on trust tier (high/medium/low): green/yellow/red
- Edge opacity/width reflects trust level
- Trust legend added to graph sidebar
Dependencies
- b5298ea7-69ec-47bd-9115-f2968a374f6d (evidence chains provenance) — uses similar trust model
Dependents
- Trust propagation needed for world model quality scoring
- Epistemic status computation uses trust as input
Work Log
2026-04-16 10:55 PT — Slot 0
- Investigated current state: knowledge_edges has epistemic_status but no trust_score
- Evidence provenance (b5298ea7) has trust_score on evidence_entries with compute_evidence_trust()
- Confirmed: trust_score needs to be added to knowledge_edges table
- Planned approach: migration + new edge_trust.py module + API updates + graph.html visualization
2026-04-16 11:30 PT — Slot 0
- Implemented migration 095_edge_trust_scores.py adding trust columns
- Created scidex/core/edge_trust.py with:
- source_quality_score() - paper quality from citations and recency
- compute_edge_trust() - full trust calculation with depth/confirmations/contradictions
- propagate_edge_trust() - downstream trust dampening at 0.85x per hop
- recompute_edge_trust_for_analysis() and recompute_all_edge_trusts()
- Updated api.py init to add trust columns via ALTER TABLE
- Added /api/graph/{id}/trust-recompute and /api/graph/trust-recompute-all endpoints
- Updated site/graph.html:
- Edge data now includes trust_score and confidence bounds
- Edges rendered by trust tier (high/medium/low) with distinct colors
- Hover tooltip shows trust percentage and confidence interval
- Legend added for trust tiers
- Committed and pushed to main-push branch
2026-04-16 12:15 PT — Slot 0
- Rebased on origin/main to sync with latest changes
- Force-pushed rebased branch to push remote
- Verified implementation intact after rebase:
- edge_trust.py imports correctly
- Migration 095 exists
- API trust-recompute endpoints present at lines 9515 and 9545
- Graph.html trust visualization present
2026-04-16 12:45 PT — Slot 0
- Merge gate blocked: conflicts with unrelated files (allen brain spec, register_seaad script)
- Reset to remote branch state, merged latest origin/main (827e1defc) instead of rebasing
- Resolved .orchestra-slot.json conflict (kept edd66643 slot version)
- Push succeeded: 67d9942c5
2026-04-16 13:00 PT — Slot 0 (Reopen)
- Previous rebase destroyed trust scores implementation
- Reimplemented from scratch:
- Recreated migration/095_edge_trust_scores.py
- Recreated scidex/core/edge_trust.py (429 lines)
- Updated api.py: ALTER TABLE for trust columns + 2 new endpoints
- Updated site/graph.html: trust legend, tier-based edge coloring, trust in tooltip
- Committed with message naming api.py explicitly (satisfies pre-push hook)
- Pushed to push remote (force-push due to rebase onto new origin/main)
- Verified remote at d97dafcf2 on top of origin/main (20204c32b)
- Final diff: 5 files changed, 770 insertions, 18 deletions