56a5d29598
* add one-time diff coverage preflight for PR reviews track diff read coverage from agent tool-use events and run a one-time pre-flight before review submission, with explicit coverage skip reasons for low-value files like lockfiles. Made-with: Cursor * add manual dispatch fallback for preview deploy workflow allow preview repo and preview sync jobs to be run via workflow_dispatch with explicit PR number and branch inputs, so preview provisioning can be retriggered when pull_request events fail to fire. Made-with: Cursor * fix manual preview dispatch PR input wiring use normalized PR number and branch env values for comment creation and script env wiring so workflow_dispatch preview runs can create and update PR-specific preview resources. Made-with: Cursor * remove obsolete snapshots invalidated by checkout instructions change * fix diff coverage read offset handling and add local sanity-check guidance normalize read offset semantics for diff coverage tracking, reuse shared range counting in review preflight, add focused diff coverage unit tests, and document the local play.ts testing workflow in AGENTS.md. Made-with: Cursor * add regenerated mcp test snapshots capture snapshot files generated by the review comment and checkout formatting tests during pre-push validation so the branch remains clean and reproducible. Made-with: Cursor * add diff coverage preflight instrumentation logs log diff coverage initialization in checkout_pr and emit preflight state/breakdown diagnostics in create_pull_request_review to debug missing coverage enforcement in preview e2e runs. Made-with: Cursor * add env override to force local cli execution in action runtime support explicit local-cli execution via PULLFROG_FORCE_LOCAL_CLI so preview workflows can run branch action code instead of the npm fallback package during e2e debugging. Made-with: Cursor * add preview e2e debugging learnings for action runtime validation capture the preview execution-path gotchas and one-time preflight verification pattern in AGENTS.md so future investigations validate the real runtime and avoid npm fallback confusion. Made-with: Cursor * reduce diff coverage log noise while preserving failure visibility downgrade verbose diff coverage lifecycle diagnostics to debug, keep a concise info-level pre-flight failure signal, and document preview runtime debugging learnings in AGENTS.md. Made-with: Cursor * WIP * tune sync.md: ff override + softer overlap verification Made-with: Cursor * chore: bump models snapshot for claude-opus-4-7 Made-with: Cursor * rip out coverage_skips waiver from diff coverage pre-flight Made-with: Cursor --------- Co-authored-by: pullfrog[bot] <226033991+pullfrog[bot]@users.noreply.github.com>
128 lines
3.0 KiB
TypeScript
128 lines
3.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
createDiffCoverageState,
|
|
getDiffCoverageBreakdown,
|
|
recordDiffReadFromToolUse,
|
|
} from "./diffCoverage.ts";
|
|
|
|
const diffPath = "/tmp/pr-1.diff";
|
|
const toc = `## Files (2)
|
|
- src/a.ts → lines 5-10
|
|
- yarn.lock → lines 12-20
|
|
|
|
---
|
|
`;
|
|
|
|
describe("diff coverage line checker", () => {
|
|
it("treats Read offsets as zero based", () => {
|
|
const state = createDiffCoverageState({
|
|
diffPath,
|
|
totalLines: 30,
|
|
toc,
|
|
});
|
|
|
|
const tracked = recordDiffReadFromToolUse({
|
|
state,
|
|
toolName: "Read",
|
|
input: {
|
|
filePath: diffPath,
|
|
offset: 0,
|
|
limit: 3,
|
|
},
|
|
cwd: "/",
|
|
});
|
|
|
|
expect(tracked).toBe(true);
|
|
const breakdown = getDiffCoverageBreakdown({ state });
|
|
expect(breakdown.coveredRanges).toEqual([{ startLine: 1, endLine: 3 }]);
|
|
});
|
|
|
|
it("treats ReadFile offsets as one based", () => {
|
|
const state = createDiffCoverageState({
|
|
diffPath,
|
|
totalLines: 30,
|
|
toc,
|
|
});
|
|
|
|
const tracked = recordDiffReadFromToolUse({
|
|
state,
|
|
toolName: "ReadFile",
|
|
input: {
|
|
path: diffPath,
|
|
offset: 1,
|
|
limit: 2,
|
|
},
|
|
cwd: "/",
|
|
});
|
|
|
|
expect(tracked).toBe(true);
|
|
const breakdown = getDiffCoverageBreakdown({ state });
|
|
expect(breakdown.coveredRanges).toEqual([{ startLine: 1, endLine: 2 }]);
|
|
});
|
|
|
|
it("supports negative offsets from file end", () => {
|
|
const state = createDiffCoverageState({
|
|
diffPath,
|
|
totalLines: 30,
|
|
toc,
|
|
});
|
|
|
|
const tracked = recordDiffReadFromToolUse({
|
|
state,
|
|
toolName: "Read",
|
|
input: {
|
|
path: diffPath,
|
|
offset: -2,
|
|
limit: 2,
|
|
},
|
|
cwd: "/",
|
|
});
|
|
|
|
expect(tracked).toBe(true);
|
|
const breakdown = getDiffCoverageBreakdown({ state });
|
|
expect(breakdown.coveredRanges).toEqual([{ startLine: 29, endLine: 30 }]);
|
|
});
|
|
|
|
it("computes per-file unread ranges from tracked reads", () => {
|
|
const state = createDiffCoverageState({
|
|
diffPath,
|
|
totalLines: 30,
|
|
toc,
|
|
});
|
|
|
|
recordDiffReadFromToolUse({
|
|
state,
|
|
toolName: "Read",
|
|
input: {
|
|
path: diffPath,
|
|
start_line: 5,
|
|
end_line: 6,
|
|
},
|
|
cwd: "/",
|
|
});
|
|
|
|
recordDiffReadFromToolUse({
|
|
state,
|
|
toolName: "Read",
|
|
input: {
|
|
path: diffPath,
|
|
start_line: 12,
|
|
end_line: 14,
|
|
},
|
|
cwd: "/",
|
|
});
|
|
|
|
const breakdown = getDiffCoverageBreakdown({ state });
|
|
const firstFile = breakdown.files[0];
|
|
const secondFile = breakdown.files[1];
|
|
|
|
expect(firstFile.filename).toBe("src/a.ts");
|
|
expect(firstFile.coveredRanges).toEqual([{ startLine: 5, endLine: 6 }]);
|
|
expect(firstFile.unreadRanges).toEqual([{ startLine: 7, endLine: 10 }]);
|
|
|
|
expect(secondFile.filename).toBe("yarn.lock");
|
|
expect(secondFile.coveredRanges).toEqual([{ startLine: 12, endLine: 14 }]);
|
|
expect(secondFile.unreadRanges).toEqual([{ startLine: 15, endLine: 20 }]);
|
|
});
|
|
});
|