Skip to content

fix: perch scan --since read unchanged methods in changed files - #439

Merged
jbrown9513 merged 11 commits into
mainfrom
claude/issue-438-investigation-3db22b
Oct 29, 2026
Merged

jbrown9513 merged 11 commits into
mainfrom
claude/issue-438-investigation-3db22b

Conversation

@jbrown9513

Copy link
Copy Markdown
Contributor

perch scan --since limited only the defect questions to methods a hunk touched. Security, lint and custom rules were asked of every method in a changed file, so a one-line change in a large file paid for a reading of every method in it.

--since now reads only the methods a hunk touched, for every question and for method rules shown a document. Unchanged methods are still sent as callers and callees, and findings an earlier scan made on them are still reported.

Closes #438

Only defect questions were limited to methods a hunk touched. Security,
lint and custom rules, including rules shown a document, were still asked
of every method in a changed file. --since now reads only the methods a
hunk touched; the rest of the file stays in view as callers and callees.

@perchcode-bot perchcode-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perch found 7 issues in code this pull request changed. See the scan

Comment thread src/units.js
* a free one, which beats a request spent on ranking. One search need not wait on another.
*/
export async function searchUnits({ rules, scan, graph, files, tree, eligible, revision, systemOne, inScope, ignores, min = BELIEVED,
export async function searchUnits({ rules, scan, graph, files, tree, eligible, revision, systemOne, inScope, changed, ignores, min = BELIEVED,

@perchcode-bot perchcode-bot Bot Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the scan of f777179 no longer reports this.

P1 Defect: wrong lookup (93%)

Perch believes searchUnits has this problem. It is a probability, not a located defect: the cause may sit a few lines away.

Check a fix with perch check src/units.js::searchUnits. See the scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan of f777179 no longer reports this, so Perch marked it fixed. Resolve this thread when you are done with it. See the scan

Comment thread src/scan.js
@@ -112,7 +112,7 @@ const createWalk = (graph, candidates, inScope = () => true) => {
const visited = new Set(), stack = [], ranked = candidates.map(candidate => candidate.id);
const enqueue = ids => {

@perchcode-bot perchcode-bot Bot Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the scan of 21a76bc no longer reports this.

P2 Defect: wrong lookup (91%)

Perch believes createWalk.enqueue has this problem. It is a probability, not a located defect: the cause may sit a few lines away.

Check a fix with perch check src/scan.js::createWalk.enqueue. See the scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan of 21a76bc no longer reports this, so Perch marked it fixed. Resolve this thread when you are done with it. See the scan

Comment thread src/scan.js
&& !graph.nodes.get(id).test && inScope(id));
stack.push(...valid.sort((a, b) => score(a) - score(b)));
};
const next = () => {

@perchcode-bot perchcode-bot Bot Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the scan of 21a76bc no longer reports this.

P2 Defect: wrong lookup (78%)

Perch believes createWalk.next has this problem. It is a probability, not a located defect: the cause may sit a few lines away.

Check a fix with perch check src/scan.js::createWalk.next. See the scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan of 21a76bc no longer reports this, so Perch marked it fixed. Resolve this thread when you are done with it. See the scan

Comment thread src/scan.js
const linesOf = createLineReader(root, graph), walk = createWalk(graph, candidates, inScope);
const linesOf = createLineReader(root, graph), walk = createWalk(graph, candidates, id => inScope(graph.nodes.get(id).path) && changed(id));
const askedByMethod = new Map();
const stepFor = async nodeId => {

@perchcode-bot perchcode-bot Bot Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the scan of 21a76bc no longer reports this.

P2 Defect: inverted condition (66%)

Perch believes scanRepository.stepFor has this problem. It is a probability, not a located defect: the cause may sit a few lines away.

Check a fix with perch check src/scan.js::scanRepository.stepFor. See the scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan of 21a76bc no longer reports this, so Perch marked it fixed. Resolve this thread when you are done with it. See the scan

Comment thread src/units.js
* `mentions <text>`, which is a text match and finds the methods worth asking rather than the methods that are guilty.
*/
export function selectUnits(rule, { scan, graph, files, tree, eligible = null, inScope = () => true, ignores = () => false }) {
export function selectUnits(rule, { scan, graph, files, tree, eligible = null, inScope = () => true, changed = () => true, ignores = () => false }) {

@perchcode-bot perchcode-bot Bot Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the scan of f777179 no longer reports this.

Lint: no-silent-failure (100%)

Perch believes selectUnits has this problem. It is a probability, not a located defect: the cause may sit a few lines away.

Check a fix with perch check src/units.js::selectUnits. See the scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan of f777179 no longer reports this, so Perch marked it fixed. Resolve this thread when you are done with it. See the scan

Comment thread src/units.js
// `changed` narrows a method or test in them to one a hunk touched. A unit whose document the branch changed is in it too: the
// code judged by a vocabulary has to be asked again when the vocabulary moves.
// What perch.yaml ignores stays out either way, since a document being in scope says nothing about the unit's own path.
const spared = unit => !ignores(unit.path) && !ours(unit.path)

@perchcode-bot perchcode-bot Bot Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the scan of f777179 no longer reports this.

Lint: no-silent-failure (100%)

Perch believes selectUnits.spared has this problem. It is a probability, not a located defect: the cause may sit a few lines away.

Check a fix with perch check src/units.js::selectUnits.spared. See the scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan of f777179 no longer reports this, so Perch marked it fixed. Resolve this thread when you are done with it. See the scan

Comment thread src/units.js
&& (inScope(unit.path) && (!unit.part || changed(unit)) || Boolean(unit.context) && inScope(unit.context.path))
&& appliesToLanguage(rule, languageOf(unit.path))
&& (!rule.except || ![rule.except].flat().some(glob => matches(glob, unit.path)));
const keep = units => units.map(shown).filter(unit => unit && spared(unit));

@perchcode-bot perchcode-bot Bot Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the scan of f777179 no longer reports this.

Lint: no-silent-failure (100%)

Perch believes selectUnits.keep has this problem. It is a probability, not a located defect: the cause may sit a few lines away.

Check a fix with perch check src/units.js::selectUnits.keep. See the scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan of f777179 no longer reports this, so Perch marked it fixed. Resolve this thread when you are done with it. See the scan

@perchcode-bot

perchcode-bot Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Perch Scan: no issues in 92 methods at b1fd574.

2 issues fixed since the last push.

See the scan

@perchcode-bot perchcode-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perch found 2 issues in code this pull request changed. See the scan

Comment thread src/change-context.js
}
// A method is changed when a line the branch added or deleted is one of its own. A hunk's context lines are not, and neither
// are the methods inside a top-level unit's span: its `lines` are what it covers.
const owns = node => node.lines ? (own => at => own.has(at))(new Set(node.lines)) : at => at >= node.line && at <= node.end_line;

@perchcode-bot perchcode-bot Bot Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the scan of f777179 no longer reports this.

P1 Defect: off by one (82%)

Perch believes createChangeReader.owns has this problem. It is a probability, not a located defect: the cause may sit a few lines away.

Check a fix with perch check src/change-context.js::createChangeReader.owns. See the scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan of f777179 no longer reports this, so Perch marked it fixed. Resolve this thread when you are done with it. See the scan

Comment thread src/scan.js
* what it covers.
*/
const createWalk = (graph, candidates, inScope = () => true) => {
const createWalk = (graph, candidates, reads = () => true) => {

@perchcode-bot perchcode-bot Bot Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the scan of f777179 no longer reports this.

P1 Defect: wrong lookup (63%)

Perch believes createWalk has this problem. It is a probability, not a located defect: the cause may sit a few lines away.

Check a fix with perch check src/scan.js::createWalk. See the scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan of f777179 no longer reports this, so Perch marked it fixed. Resolve this thread when you are done with it. See the scan

@perchcode-bot perchcode-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perch found an issue in code this pull request changed and is still reading. See the scan

Comment thread src/scan.js
* with callers and callees. The two ask nothing in common. A method no hunk touched is not read at all, and without a change
* there is no diff to ask the bug questions over.
*/
export function sinceQuestions(asked, changed) {

@perchcode-bot perchcode-bot Bot Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the scan of cd6d817 no longer reports this.

P2 Defect: off by one (76%)

Perch believes sinceQuestions has this problem. It is a probability, not a located defect: the cause may sit a few lines away.

Check a fix with perch check src/scan.js::sinceQuestions. See the scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan of cd6d817 no longer reports this, so Perch marked it fixed. Resolve this thread when you are done with it. See the scan

@perchcode-bot perchcode-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perch found an issue in code this pull request changed. See the scan

Comment thread src/units.js
* a free one, which beats a request spent on ranking. One search need not wait on another.
*/
export async function searchUnits({ rules, scan, graph, files, tree, eligible, revision, systemOne, inScope, ignores, min = BELIEVED,
export async function searchUnits({ rules, scan, graph, files, tree, eligible, revision, systemOne, inScope, changed, ignores, min = BELIEVED,

@perchcode-bot perchcode-bot Bot Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the scan of cd6d817 no longer reports this.

P1 Defect: off by one (99%)

Perch believes searchUnits has this problem. It is a probability, not a located defect: the cause may sit a few lines away.

Check a fix with perch check src/units.js::searchUnits. See the scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan of cd6d817 no longer reports this, so Perch marked it fixed. Resolve this thread when you are done with it. See the scan

@perchcode-bot perchcode-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perch found 3 issues in code this pull request changed and is still reading. See the scan

Comment thread src/scan.js
* with callers and callees. The two ask nothing in common. A method no hunk touched is not read at all, and without a change
* there is no diff to ask the bug questions over.
*/
export function sinceQuestions(asked, changed) {

@perchcode-bot perchcode-bot Bot Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the scan of cd6d817 no longer reports this.

P2 Defect: other defect (76%)

Perch believes sinceQuestions has this problem. It is a probability, not a located defect: the cause may sit a few lines away.

Check a fix with perch check src/scan.js::sinceQuestions. See the scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan of cd6d817 no longer reports this, so Perch marked it fixed. Resolve this thread when you are done with it. See the scan

Comment thread src/units.js
@@ -305,7 +305,7 @@ export function neighbourhood(sees, unit, { graph, files, max = MAX_SEEN }) {
const text = files.get(unit.path) ?? '';
if (sees === 'file') return { file_source: text };
const show = ids => ids.slice(0, max).map(id => graph.nodes.get(id)).filter(Boolean)

@perchcode-bot perchcode-bot Bot Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the scan of cd6d817 no longer reports this.

P2 Defect: other defect (67%)

Perch believes neighbourhood.show has this problem. It is a probability, not a located defect: the cause may sit a few lines away.

Check a fix with perch check src/units.js::neighbourhood.show. See the scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan of cd6d817 no longer reports this, so Perch marked it fixed. Resolve this thread when you are done with it. See the scan

Comment thread src/units.js
* `mentions <text>`, which is a text match and finds the methods worth asking rather than the methods that are guilty.
*/
export function selectUnits(rule, { scan, graph, files, tree, eligible = null, inScope = () => true, ignores = () => false }) {
export function selectUnits(rule, { scan, graph, files, tree, eligible = null, inScope = () => true, changed = () => true, ignores = () => false }) {

@perchcode-bot perchcode-bot Bot Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the scan of cd6d817 no longer reports this.

P2 Defect: other defect (62%)

Perch believes selectUnits has this problem. It is a probability, not a located defect: the cause may sit a few lines away.

Check a fix with perch check src/units.js::selectUnits. See the scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan of cd6d817 no longer reports this, so Perch marked it fixed. Resolve this thread when you are done with it. See the scan

@perchcode-bot perchcode-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perch found 2 issues in code this pull request changed and is still reading. See the scan

Comment thread src/scan.js
const linesOf = createLineReader(root, graph), walk = createWalk(graph, candidates, inScope);
const linesOf = createLineReader(root, graph), walk = createWalk(graph, candidates, id => inScope(graph.nodes.get(id).path) && changed(id));
const askedByMethod = new Map();
const stepFor = async nodeId => {

@perchcode-bot perchcode-bot Bot Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the scan of b1fd574 no longer reports this.

P2 Defect: other defect (70%)

Perch believes scanRepository.stepFor has this problem. It is a probability, not a located defect: the cause may sit a few lines away.

Check a fix with perch check src/scan.js::scanRepository.stepFor. See the scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan of b1fd574 no longer reports this, so Perch marked it fixed. Resolve this thread when you are done with it. See the scan

Comment thread src/units.js
* that failed about which line failed on it. `documents` holds the text of every document a rule can be shown.
*/
export async function askUnits({ rules, scan, graph, files, tree, eligible, revision, systemOne, inScope, ignores, min = BELIEVED,
export async function askUnits({ rules, scan, graph, files, tree, eligible, revision, systemOne, inScope, changed, ignores, min = BELIEVED,

@perchcode-bot perchcode-bot Bot Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the scan of b1fd574 no longer reports this.

P2 Defect: bad state change (66%)

Perch believes askUnits has this problem. It is a probability, not a located defect: the cause may sit a few lines away.

Check a fix with perch check src/units.js::askUnits. See the scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan of b1fd574 no longer reports this, so Perch marked it fixed. Resolve this thread when you are done with it. See the scan

@jbrown9513
jbrown9513 merged commit 97710f2 into main Oct 29, 2026
8 checks passed
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.

perch scan --since runs security checks on unchanged methods

1 participant