Skip to content

feat: O(1) dashboard stats snapshot + maintained conflict-edge list - #415

Merged
nambok merged 1 commit into
mainfrom
perf/stats-snapshot-and-conflict-edges
Jul 31, 2026
Merged

feat: O(1) dashboard stats snapshot + maintained conflict-edge list#415
nambok merged 1 commit into
mainfrom
perf/stats-snapshot-and-conflict-edges

Conversation

@nambok

@nambok nambok commented Jul 31, 2026

Copy link
Copy Markdown
Owner

materialize dashboard stats snapshot and maintain a conflict-edge list

Remove the last whole-tenant scans from the dashboard read path so /stats
and /contradictions are O(1) at any scale, cold or warm.

- ScopeCounts gains growth (per-creation-month counts), maintained
  incrementally on store/forget like the other counts, so the growth
  timeline and "this month" figure are exact and O(1) with no scan.
- StatsSnapshot + refresh_stats_snapshot materialize the parts that
  genuinely need a pass (decayed-salience health histogram, avg health,
  recall-count usage sums, entity/community totals) in one walk, persisted
  per tenant and served O(1) by stats_snapshot. The host drives the refresh
  from the maintenance sweep, which already walks every node for archival,
  so no request ever pays the O(N) cost.
- The graph maintains a conflict-edge list (contradicts, supersedes) keyed
  by (source, target, type), so the conflict view enumerates the actual
  pairs in O(conflicts) instead of walking every node's out-edges (which
  rescans the delta log per node). Reground on compact/load; skipped on
  serialize since a tuple key is not a JSON map key.

Tests: scope-counts growth, stats-snapshot materialize + persist across
reopen, conflict-edge enumerate/maintain/persist/remove.
@nambok
nambok merged commit 7375e88 into main Jul 31, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant