feat: agentic related-code reading (point 1 — biggest quality lever)#10
Merged
Conversation
…depends on (point 1) The #1 quality lever in DESIGN.md §六: reviewing only the diff + changed files misses the untouched code a change depends on (struct defs elsewhere, callers holding a lock). Add one model-directed planning round (src/core/related.ts): the model names the untouched files it needs from the imports/identifiers already visible in the changed code, the core fetches them via readFile (bounded by count + char budget; a miss is cheap), and they feed into the review as extra context. Deliberately minimal v1: one round, reusing the single-shot generateStructured port (no multi-turn tool-use redesign), related files go in the user-message tail so the cached system prompt is unaffected. Observable: ReviewOutcome.relatedFiles surfaces which files were pulled (comment footer + Action log + smoke output). Planning failure is never fatal (returns []). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
What
Implements the #1 quality lever from
DESIGN.md §六: agentic related-code reading.Until now BanGD reviewed only the diff plus the full contents of the changed files. It never saw the untouched code a change depends on — the struct/interface defined in another file, the caller that already holds a lock, the package's other methods sharing an invariant. That's exactly the context architecture-level reasoning needs.
How
A new core module
src/core/related.tsadds one model-directed planning round before the review:readFile, bounded by count (MAX_RELATED_FILES) and char budget (RELATED_CHAR_BUDGET). A miss returnsnulland is dropped — cheap.Deliberate scope (v1)
generateStructuredport — no multi-turn tool-use redesign. Earns its keep first; multi-round / interleaved tool-use is a documented later refinement.ReviewOutcome.relatedFilessurfaces which files were pulled — shown in the PR comment footer, the Action log, and the smoke output. This is the concrete demonstration of the lever working for a judged deliverable.[]; the review proceeds).Tests
src/core/related.test.ts(9 cases): trim/dedupe, exclude changed files, drop non-strings, cap, no-paths/throw→[], schema identity, fetch-and-drop-misses.review.test.tsupdated to be schema-aware + a new case asserting planner-named files are fetched and injected.dist/bundle rebuilt and committed.🤖 Generated with Claude Code