Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
44 changes: 44 additions & 0 deletions src/gate/test-presence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,33 @@ describe("classifyChangedFiles", () => {
]);
expect(surface.dataAccessChanged).toEqual(["apps/api/src/schema.ts"]);
});

test("does not read a `select-plan` route path as a SELECT ... FROM query", () => {
// Site#3615 root cause: `\bselect\b` matched the hyphenated route segment,
// and an import `from` on the next line completed the `SELECT ... FROM`
// shape. Requiring whitespace after `select`, as real SQL has, fixes it.
const surface = classifyChangedFiles([
{
path: "apps/app/src/routeTree.gen.ts",
status: "modified",
patch:
"@@ -18,2 +18,2 @@\n" +
"+} from './routes/membership/select-plan'\n" +
"+import { Route as MembershipRegisterRouteImport } from './routes/membership/register'",
},
]);
expect(surface.dataAccessChanged).toEqual([]);
});

test("still flags a raw SELECT ... FROM query in application code", () => {
// The tightened `select`-shape must keep its recall: real SQL has whitespace
// after the keyword. This trips only the raw select shape (no `db.`, no
// `.query(`), so it locks that pattern in.
const surface = classifyChangedFiles([
changed("apps/api/src/reports.ts", "const sql = `SELECT id, name FROM users`;"),
]);
expect(surface.dataAccessChanged).toEqual(["apps/api/src/reports.ts"]);
});
});

describe("evaluateTestPresence", () => {
Expand Down Expand Up @@ -256,6 +283,23 @@ describe("evaluateTestPresence", () => {
expect(verdict).toBeNull();
});

test("does not fire on the route-tree regeneration from Site#3614", () => {
// The reported false positive: a routeTree.gen.ts regeneration (import
// re-ordering) whose `select-plan` route path read as `SELECT ... FROM`.
// No data access, nothing to flag.
const verdict = evaluateTestPresence([
{
path: "apps/app/src/routeTree.gen.ts",
status: "modified",
patch:
"@@ -18,2 +18,2 @@\n" +
"+} from './routes/membership/select-plan'\n" +
"+import { Route as MembershipRegisterRouteImport } from './routes/membership/register'",
},
]);
expect(verdict).toBeNull();
});

test("does not fire on a migration alone, even with no test", () => {
// A migration's coverage can't be linked by the diff heuristic, so it is
// never flagged — under-firing is the safe side for a warn-only gate.
Expand Down
6 changes: 5 additions & 1 deletion src/gate/test-presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ export const DEFAULT_TEST_PRESENCE_CONFIG: TestPresenceConfig = {
/\binsert\s+into\b/i,
/\bdelete\s+from\b/i,
/\bupdate\b[^\n]{0,80}\bset\b/i,
/\bselect\b[\s\S]{0,300}?\bfrom\b/i,
// `select` must be followed by whitespace, as real `SELECT … FROM` is — so a
// hyphenated route segment like `select-plan` (whose `\bselect\b` boundary is
// the hyphen) doesn't read as a query when an import `from` follows it
// (Site#3615).
/\bselect\s[\s\S]{0,300}?\bfrom\b/i,
// DDL is matched by statement shape (ON clause, column list, target
// identifier), not bare keyword adjacency: prose in a string literal —
// "its suggested CREATE INDEX fix" in an MCP tool description (Site#3539)
Expand Down
Loading