Summary
Stats.RelationCount is computed as relTotal + PendingRelationCount, and the formatter then renders PendingRelationCount again as a child branch under that total. Pending relations are counted once in the headline number and re-listed beneath it — every consumer of MemoryStats and remindb inspect reads an inflated count.
Location
pkg/inspect/inspect.go:78 — RelationCount: relTotal + core.PendingRelationCount
pkg/inspect/format.go:79,82-84 — headline Relations: <RelationCount> followed by a pending: <PendingRelationCount> sub-branch
Category
refactor (display/aggregation bug, not a data-corruption bug — the DB stores correct values; only the reported total is wrong)
Impact
High. Anyone scripting against MemoryStats.relations or grepping inspect output for the relations count gets a wrong number. The pending: sub-line implies it's a breakdown of the total, but the total already includes it.
Rationale
// pkg/inspect/inspect.go:78
RelationCount: relTotal + core.PendingRelationCount,
// pkg/inspect/format.go:78-86
func writeRelations(b *strings.Builder, s *Stats) {
row(b, "Relations:", fmt.Sprintf("%d", s.RelationCount))
branches := mapBranches(s.RelationsByOrigin)
if s.PendingRelationCount > 0 {
branches = append(branches, branch{key: "pending:", value: fmt.Sprintf("%d", s.PendingRelationCount)})
}
writeBranches(b, branches)
}
relTotal already counts every resolved edge; PendingRelationCount counts unresolved wiki-link forwards. Summing them and then showing the pending count as a sub-row creates the inconsistency.
Suggested change direction
Make RelationCount the resolved total only:
Leave the pending: sub-branch in writeRelations as-is. The header now reads honestly ("N resolved relations") and the sub-row legitimately reports "M pending" alongside it. The MCP MemoryStats envelope keeps the same field names; only the value changes meaning.
Filed by the nightly enhancement-scanner routine at commit f11c9f1.
Summary
Stats.RelationCountis computed asrelTotal + PendingRelationCount, and the formatter then rendersPendingRelationCountagain as a child branch under that total. Pending relations are counted once in the headline number and re-listed beneath it — every consumer ofMemoryStatsandremindb inspectreads an inflated count.Location
pkg/inspect/inspect.go:78—RelationCount: relTotal + core.PendingRelationCountpkg/inspect/format.go:79,82-84— headlineRelations: <RelationCount>followed by apending: <PendingRelationCount>sub-branchCategory
refactor (display/aggregation bug, not a data-corruption bug — the DB stores correct values; only the reported total is wrong)
Impact
High. Anyone scripting against
MemoryStats.relationsor greppinginspectoutput for the relations count gets a wrong number. Thepending:sub-line implies it's a breakdown of the total, but the total already includes it.Rationale
relTotalalready counts every resolved edge;PendingRelationCountcounts unresolved wiki-link forwards. Summing them and then showing the pending count as a sub-row creates the inconsistency.Suggested change direction
Make
RelationCountthe resolved total only:Leave the
pending:sub-branch inwriteRelationsas-is. The header now reads honestly ("N resolved relations") and the sub-row legitimately reports "M pending" alongside it. The MCPMemoryStatsenvelope keeps the same field names; only the value changes meaning.Filed by the nightly enhancement-scanner routine at commit f11c9f1.