Skip to content

Context: aggregate sharded sources by kind so they surface to the agent (0.5.5)#51

Merged
dilawarabbas1 merged 2 commits into
mainfrom
claude/context-aggregate-sharded-sources
May 29, 2026
Merged

Context: aggregate sharded sources by kind so they surface to the agent (0.5.5)#51
dilawarabbas1 merged 2 commits into
mainfrom
claude/context-aggregate-sharded-sources

Conversation

@dilawarabbas1

Copy link
Copy Markdown
Owner

Summary

Real bug fix surfaced from a sharded-docs project: the Context's accessors (top_bugs, top_anti_patterns, etc.) only read the single canonically-named source. Projects that follow the hand-maintained docs convention with sharded files (bug-registry-{infra,agents,orchestrator}.md, db-impact-map-{master,tenant,vector}.md, etc.) had their content invisible to the agent — the canonical-named entry parsed to a thin stub, while the shards sat in the cache but were never aggregated into Context.

Measured impact (real project)

Accessor Before After
top_bugs 2 533
top_anti_patterns 0 242

Agent reads went from "this project has 2 known bugs" to "this project has 533 known bugs across 3 shards."

Fix

context.py gains _iter_kind() / _entries_for_kind() helpers that walk every source whose .kind matches (canonical + same-kind extras), deduped by (id, title). Eight accessors switch to the kind-aggregator:

  • top_bugs
  • top_anti_patterns
  • redis_keys
  • db_impact
  • dependency_map
  • architecture_sections
  • hotspots_for_files
  • detect_conflicts

No config change required for projects that already register shards under sources.extra with the right kind. Single-canonical-source projects are unchanged — the helper falls through when no extras share the kind.

Test plan

  • New test_kind_aggregates_across_extra_shards pins the behaviour
  • Full suite: 834 passed, 2 skipped
  • No breaking changes; no schema changes; no config changes

Version

0.5.4 → 0.5.5

(Bug-fix release. The fix is the work of 26d1bf9; this PR also bumps version + adds CHANGELOG entry in a separate commit so the release-note artefact is on main.)


Generated by Claude Code

dilawarabbas1 and others added 2 commits May 29, 2026 11:55
A "kind" (bug_registry, anti_patterns, db_impact_map, …) can be backed
by more than one doc. Large projects keep the canonical entry as a thin
index stub and put the real content in per-domain shards registered
under sources.extra with the same kind (bug-registry-{agents,infra,
orchestrator}.md, db-impact-map-{master,tenant,vector}.md, etc.).

The Context accessors read only the single canonically-named source
(self.sources.get("bug_registry")), so every shard's parsed content sat
in the cache + pointer cards but never reached the context the agent
reads. Measured on a real sharded project: top_anti_patterns surfaced
0 (the stub parsed to "no entries"), top_bugs surfaced 2 — while the
backend shards held 242 anti-patterns and 534 bugs that were completely
invisible to the agent.

Fix: add _iter_kind()/_entries_for_kind() that aggregate across every
source whose .kind matches (canonical + same-kind extras), deduped by
(id, title). top_bugs / top_anti_patterns / redis_keys / db_impact /
dependency_map / architecture_sections / hotspots_for_files /
detect_conflicts all switch to it. No config change needed for projects
that already register shards under sources.extra; on the real project
this turned top_bugs 2->533 and top_anti_patterns 0->242.

New test_kind_aggregates_across_extra_shards pins the behavior. All
context/sources/conflicts/adapters/layered suites green (55 tests).
@dilawarabbas1 dilawarabbas1 merged commit 7c5ff26 into main May 29, 2026
0 of 3 checks passed
@dilawarabbas1 dilawarabbas1 deleted the claude/context-aggregate-sharded-sources branch May 29, 2026 08:06
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.

2 participants