Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions packages/cli/src/commands/review/lib/certification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,33 @@ export function declaresOwnUncoverable(
return m !== null && Number(m[1]) === chunk;
}

/**
* Does any of these serialized tool-call args name the EXACT `path`? The
* comparison is against the whole JSON string value (`JSON.stringify(path)`
* carries the closing quote), so a `${path}.bak` — or any longer path that
* merely contains this one as a prefix — is NOT credited: the same trap
* `parseTranscript` avoids for the diff path. This one needle is what the
* bar's "exact path, not a look-alike" guarantee rests on; every path atom
* below routes through it, so a fix to the match reaches all of them at once
* (the drift this module exists to eliminate, applied to its own internals).
*/
function namesPath(args: readonly string[], path: string): boolean {
Comment thread
wenshao marked this conversation as resolved.
Resolved
const needle = JSON.stringify(path);
return args.some((a) => a.includes(needle));
}
Comment thread
wenshao marked this conversation as resolved.
Resolved

/**
* Did this record's agent open the brief recorded under `key`? Compared as a
* whole JSON string value (`successfulCallArgs` are serialized args), so a
* `${brief}.bak` cannot be credited for the brief — the same trap
* `parseTranscript` avoids for the diff path. "Open" is mention-level: any
* successful tool whose args name the exact path.
* `${brief}.bak` cannot be credited for the brief. "Open" is mention-level:
* any successful tool whose args name the exact path.
*/
export function openedBrief(
rec: AgentRecord,
planPath: string,
key: string,
): boolean {
const needle = JSON.stringify(briefPath(planPath, key));
return rec.successfulCallArgs.some((a) => a.includes(needle));
return namesPath(rec.successfulCallArgs, briefPath(planPath, key));
}

/**
Expand All @@ -87,8 +100,7 @@ export function readBrief(
planPath: string,
key: string,
): boolean {
const needle = JSON.stringify(briefPath(planPath, key));
return rec.successfulReadFileArgs.some((a) => a.includes(needle));
return namesPath(rec.successfulReadFileArgs, briefPath(planPath, key));
}

/**
Expand All @@ -104,6 +116,5 @@ export function readFindingsPointer(
pointer: string | null,
): boolean {
if (pointer === null) return true;
const needle = JSON.stringify(pointer);
return rec.successfulReadFileArgs.some((a) => a.includes(needle));
return namesPath(rec.successfulReadFileArgs, pointer);
}
Loading