feat(desktop): add bounded Context Graph entity accounting - #13
Merged
branarakic-agent merged 2 commits intoAug 14, 2026
Merged
Conversation
…otals
Every chip in the memory panel is conceptually a SUB-GRAPH of the
channel's Context Graph — a kind of entity, one participant's
contributions, code. This makes the numbers those chips carry mean
exactly that, and makes the sums check out (buzz-dkg-beta#13):
- subgraphCounts.ts: a battery of budget-safe semantic aggregates (exact
type/predicate IRIs, one aggregate per query, LIMIT everywhere — the
relay's query gate rejects GROUP BY, GRAPH clauses, and unbound
patterns) counting each kind sub-graph (decisions, evidence events,
people & agents, capture runs, claims, code), each contributor's
sub-graph via prov:wasAttributedTo, and the layer's typed-entity
total. "Entity" follows the DKG node UI's own semantics
(packages/node-ui buildEntities): entities of every kind, not
decisions.
- The dashboard gains a reconciliation line — e.g. "312 entities = 30
decisions · 240 evidence · 11 people & agents · 30 capture runs" —
and any mismatch is SHOWN ("n other" for unclassified subjects,
"n cross-typed" for double-counted ones), never hidden. The
invariant is verified in the UI, not assumed.
- Layer cards never present a display-bounded list length as a total
again: an uncapped *Count from the gateway wins, a measured entity
total is next, and a bare list renders only as a lower bound (≥n).
- The All-decisions chip carries the true decision count; each
People & agents chip carries that agent's sub-graph entity count
(falling back to raw event count until measured, with the unit named
in the tooltip).
- Lens overlay legends now say "in this view" — a per-lens node tally
can no longer impersonate a channel-wide layer total.
Counting never gates the panel: every query failure degrades to null
and the previous behavior. Covered by unit tests for the query builder,
binding parser, and reconciliation math, plus an e2e that stubs the
gateway aggregates and asserts the reconciliation line, the honest
layer card, and the per-agent chip end to end.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Ziga Drev <zigadrev@MacBook-Pro-8.local>
Signed-off-by: branarakic <branimir.rakic@origin-trail.com>
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.
Summary
Adds entity accounting to the DKG memory panel while keeping reads bounded and the displayed units honest.
*Countand bounded-list fallbacks remain explicitly graph counts.Counting remains optional: any failed aggregate degrades to the prior display behavior and never gates the memory panel.
Load bound
A refresh issues seven fixed aggregate requests plus at most 16 contributor requests. The client permits four in flight at once. Fixed type requests read SWM and VM; participant requests read shared memory only. The two-minute refresh aligns with the gateway cache window.
Validation
Follow-up
For larger communities, the provider should eventually expose typed entity counters directly from
channel_memory, replacing the bounded client-side aggregate battery.