Repository navigation
Conversation
…otals (trailhq#433) A workspace build federates every child but left the parent's stats.json at all zeros (written by the sync child, which had no counts to fill in — a workspace parent has no wiring.json of its own), so the statusline and anything else reading the root stats saw 'not built' while every query worked. - workspaceStats (claude/stats.ts) sums the children's graphs — the same totals the federated queries serve: node/edge/total/ready counts summed, languages unioned, sorted. Null when no child has a graph, so zeros stay honest instead of invented. - The workspace build writes it after federation; the sync child's workspace branch merges it too, so a later sync never overwrites the aggregate back to zeros. Single-repo stats untouched.
🌱 graft blast radiusNothing outside this diff depends on it. 2 areas changed; no indexed dependents at depth 2. Who knows this code — 2 people across 2 areas
Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no Test signal per changed area — 1 ✓ · 1 –Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.
1 test suite also references this code1 symbol, kept out of the diagram and the table so they cannot crowd out the areas a reviewer has to look at.
Open the interactive graph → — click an area to see its dependent symbols at file:line. |
Three rounds of hardening after the first version turned out to restate the implementation's own arithmetic: - the sync child MERGES totals around a real rebuild (runSync's build is injected: its default spawns the installed CLI, which does not exist in a source checkout, so the un-injected call silently no-ops its rebuild and lies about what was tested); - a corrupt child wiring graph degrades the aggregate to the surviving children — no NaN — and the next rebuild repairs it back in; - real drift (a child grows a function) moves the totals by its true delta; inflated stale numbers do not survive a sync; a deleted child takes its counts out (discovery re-derives membership, so a workspace.json-only removal is correctly undone by the rebuild); and workspaceStats answers null or finite on a nonexistent child, a non-graph JSON shape, and an empty workspace — never invented numbers. Also found while probing: runSync's default build silently no-ops in source checkouts (graftCliPath resolves src/cli.js under tsx). Test seam problem only — real installs point at dist — noted here because any future test that calls runSync un-injected will hit the same silent no-op.
Fixes #433.
Root cause
A workspace parent has no
wiring.jsonof its own, so the sync child's stats patch (which mergescomputeStats(wiring)for single repos) had nothing to compute — the rootstats.jsonstayed atemptyStats()zeros while the children held the real graphs. The statusline reads the root stats → "not built" despite every query working.Fix
workspaceStats(repoDir, override)(claude/stats.ts): reads each child's wiring graph and sums whatcomputeStatsalready computes per repo — node/edge/total/ready summed, languages unioned and sorted. Returns null when no child has a graph, so zeros stay honest instead of invented.graph/never importsclaude/— the helper lives in the claude layer, which already imports graph types.Tests (adversarial)
The first version of the test restated the implementation's arithmetic; the committed set attacks the design instead:
workspaceStatsanswers null or finite on a nonexistent child, a non-graph JSON shape, and an empty workspace — never invented numbers.Test-seam finding, noted not fixed
runSync's default build silently no-ops in source checkouts (graftCliPathresolvessrc/cli.js, a build artifact) — any future test calling it un-injected hits the same silent no-op. Real installs point at dist; behavior there is unaffected.