feat: O(1) dashboard stats snapshot + maintained conflict-edge list - #415
Merged
Conversation
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.
This was referenced Jul 30, 2026
Merged
Merged
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
materialize dashboard stats snapshot and maintain a conflict-edge list