Skip to content

fix: describe both related-doc reasons and stop sending a full conventions file twice - #123

Merged
aliasunder merged 8 commits into
mainfrom
fix/related-docs-header-wording
Sep 30, 2026
Merged

aliasunder merged 8 commits into
mainfrom
fix/related-docs-header-wording

Conversation

@aliasunder

@aliasunder aliasunder commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

The user prompt introduced every related doc with "Documentation that may describe changed code". Priority docs are included whether or not the diff touches them, so that header misdescribed them. The header now names both inclusion reasons and points at each block's reason attribute:

Documentation provided as context — flag any claims that have become stale. A block whose reason is "priority documentation" is included whether or not the diff touches it; every other block's reason names changed files it mentions:

The section stays one section. Each doc block already carries reason="priority documentation" or reason="mentions …", so the header only needed to stop claiming a single reason for both.

A second fix rides along. When the conventions section carries the whole conventions file, the orchestrator is meant to send no other full copy. The related-file scan was not told to skip it, so a JavaScript/TypeScript conventions file that imports a changed file was sent twice: in the conventions section and again as a related-file block. The scan now gets the conventions path as an exclusion in that case.

Changes

  • src/orchestrate.ts: findRelatedFiles excludes the conventions file when the conventions section already carries it in full.
  • src/__tests__/orchestrate.test.ts: two exact excludePaths expectations now include the conventions path. Two new tests cover the full-section case (the file is excluded and no related-file block carries it) and the truncated case (nothing is excluded, so a related-file block can still carry the full text).
  • src/review/prompt.ts:
    • The related-docs header wording.
    • Doc comments name the functions and modules that prompt strings must stay in step with: filterNonFindings, annotateDiff, renderExcludedFilesNote, mergePhaseFindings, and the reason strings readPriorityDocs and findRelatedDocs set. A comment on buildSystemPrompt's section array says the order matters, because sections cite each other as "above" and "below".
    • conventionsRenderInFull's doc lists every case where the conventions section defers to another copy of the file.
    • truncateConventions calls conventionsRenderInFull instead of repeating its length check.
    • renderFileBlock keeps a file's reason on diff-only blocks too. No caller sets a reason on a diff-only file today, so output doesn't change.
    • The conventions, diff, and prior-findings/prior-comments sections are built as open tag, body, and close tag, like the metadata section. The rendered text is unchanged.
  • src/review/__tests__/prompt.test.ts:
    • The header test now renders one priority doc and one mention-matched doc and asserts the header plus both blocks as one section.
    • The section-order and omission tests use the new header text.
    • The omission tests for related docs and prior bot comments gain a positive anchor, so an empty prompt can't pass them.
    • New tests cover a diff-only block that keeps its reason, the whole diff section, and conventions rendered in full at exactly the cap.
    • Prompt-section tests that checked fragments now assert the whole section: prior findings, metadata with no description, a related-file block, and the truncated conventions cases.
  • src/context/__tests__/workspace.test.ts: a new test feeds the real readPriorityDocs output into buildUserPrompt and asserts the header and the README block together, so renaming the priority-doc reason string on either side fails.

Testing

  • 816 tests pass; lint and tsc are clean.
  • Mutation checks:
    • Restoring the old header fails the section-order test and the header test.
    • Removing the conventions path from the related-file scan's exclusions fails the full-section test.
  • Live check: a temporary commit changed the max_related_docs default in src/config.ts from 10 to 12 without updating README, and a later commit reverts it. On that run README was a priority doc and no doc was mention-matched (priorityDocPaths: README.md, mentionMatchedDocsCount: 0). The review flagged src/config.ts:156 with "Reconcile the max_related_docs default with README's documented value", citing README's input table, so the model read the priority doc under the new header. That run used an earlier draft of the header. It had the same opening line and the same section and block layout, and differed only in how it described the two reasons.

🤖 Generated with Claude Code

aliasunder and others added 2 commits September 30, 2026 17:24
…header

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ore merge)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/config.ts Outdated
@umm-actually

umm-actually Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

umm-actually re-reviewed at 2ff5b6a

No new findings (3 tracked finding(s) across all runs).


umm-actually · deepseek/deepseek-v4.1-flash

aliasunder and others added 2 commits September 30, 2026 17:27
…rantee

Priority docs are read under a token budget and skipped when missing,
diff-excluded, or already sent in full by another channel, so the header
no longer claims they are sent on every review.

Ship-Check: pr-review · claude-opus-5-5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/review/prompt.ts Outdated
aliasunder and others added 3 commits September 30, 2026 17:36
Point each prompt-text contract at the code that honors it (diff headers, excluded-files trailer, non-finding filter, phase merge, doc reason strings). List every conventions full-copy case in one place, and state why the system-prompt order matters. Reuse conventionsRenderInFull in truncateConventions. Build the conventions, diff, and prior sections as tag/body/tag joins. Render the reason attribute on diff-only blocks too. The prompt output is unchanged for every input callers produce.

Ship-Check: code-quality · claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… header

Ship-Check: triage · claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… reason quote

- A diff-only file block keeps its reason attribute.
- The diff and prior-findings sections are asserted as whole sections.
- Conventions exactly at the cap render in full, matching conventionsRenderInFull.
- Truncation, metadata and related-file tests assert whole sections, not fragments.
- The related-docs header's quoted reason is checked against what readPriorityDocs sets.

Ship-Check: test-audit · claude-opus-5-5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/review/prompt.ts Outdated
The related-file scan did not receive the conventions path when the
conventions section carried the whole file, so a JS/TS conventions file
that imports a changed file was sent twice. Correct two prompt.ts
comments: readPriorityDocs skips the conventions file by exclusion
rather than never receiving it, and filterNonFindings covers most, not
all, of the quoted non-finding phrases.

Ship-Check: bug-check · claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aliasunder aliasunder changed the title fix(review): describe both doc inclusion reasons in the related-docs header fix: describe both related-doc reasons and stop sending a full conventions file twice Sep 30, 2026
@aliasunder
aliasunder merged commit b743fe0 into main Sep 30, 2026
9 checks passed
@aliasunder
aliasunder deleted the fix/related-docs-header-wording branch September 30, 2026 22:59
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.

1 participant