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
2 changes: 1 addition & 1 deletion packages/gittensory-mcp/lib/local-branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ export function isTestFile(file) {
}

export function isCodeFile(file) {
return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|c|h|m|vue|svelte|astro)$/i.test(file) && !isTestFile(file);
return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|cc|c|h|hpp|m|vue|svelte|astro)$/i.test(file) && !isTestFile(file);
}

function numberValue(value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function isTestFile(file) {
}

function isCodeFile(file) {
return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|c|h|m|vue|svelte|astro)$/i.test(file) && !isTestFile(file);
return /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|cc|c|h|hpp|m|vue|svelte|astro)$/i.test(file) && !isTestFile(file);
}

function lineCount(file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def metadata_fallback(metadata: dict) -> dict:
lines = max(int(entry.get("additions") or 0) + int(entry.get("deletions") or 0), 0)
if is_test_file(path):
tests += lines
elif lower_path.endswith((".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs", ".py", ".rb", ".rs", ".go", ".java", ".kt", ".scala", ".sql", ".cs", ".swift", ".groovy", ".php", ".cpp", ".c", ".h", ".m", ".vue", ".svelte", ".astro")):
elif lower_path.endswith((".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs", ".py", ".rb", ".rs", ".go", ".java", ".kt", ".scala", ".sql", ".cs", ".swift", ".groovy", ".php", ".cpp", ".cc", ".c", ".h", ".hpp", ".m", ".vue", ".svelte", ".astro")):
source += lines
else:
non_code += lines
Expand Down
2 changes: 1 addition & 1 deletion src/rules/advisory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ function severityToAnnotationLevel(severity: AdvisorySeverity): CheckRunAnnotati
}

function isCodePath(path: string): boolean {
return /\.(ts|tsx|js|jsx|py|go|rs|java|rb|php|cs|cpp|c|h|swift|kt|m|sql|yaml|yml|json|toml|md|vue|svelte|astro)$/i.test(path);
return /\.(ts|tsx|js|jsx|py|go|rs|java|rb|php|cs|cpp|cc|c|h|hpp|swift|kt|m|sql|yaml|yml|json|toml|md|vue|svelte|astro)$/i.test(path);
}

function collisionClustersForPull(collisions: CollisionReport, pullNumber: number): CollisionCluster[] {
Expand Down
5 changes: 3 additions & 2 deletions src/signals/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5538,9 +5538,10 @@ function sanitizeOutcomeDimensionKey(key: string): string {
function isCodeFile(file: string): boolean {
// Mirrors isCodeFile in local-branch.ts — kept in sync (cs/swift/groovy/php and C/C++/Objective-C added
// so native/C#/Swift/Groovy/PHP source counts as code, matching the test conventions
// isTestPath already recognizes; vue/svelte/astro match rag.ts, visual paths, and isCodePath).
// isTestPath already recognizes; vue/svelte/astro match rag.ts, visual paths, and isCodePath;
// cc/hpp complete the C++ extension set alongside cpp/c/h).
return (
/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|c|h|m|vue|svelte|astro)$/i.test(
/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|cc|c|h|hpp|m|vue|svelte|astro)$/i.test(
file,
) && !isTestFile(file)
);
Expand Down
3 changes: 2 additions & 1 deletion src/signals/local-branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1272,8 +1272,9 @@ export function isCodeFile(file: string): boolean {
// count as code too — otherwise a C#/Swift/Groovy/PHP/native source file is neither test
// nor code in the local scorer. vue/svelte/astro align with review/rag.ts CODE_EXT_RE,
// review/visual/paths.ts, and rules/advisory.ts isCodePath so every classifier agrees.
// cc/hpp round out the C++ set alongside cpp/c/h (rag.ts already indexes all four).
return (
/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|c|h|m|vue|svelte|astro)$/i.test(
/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|py|rb|rs|kt|scala|java|go|sql|cs|swift|groovy|php|cpp|cc|c|h|hpp|m|vue|svelte|astro)$/i.test(
file,
) && !isTestFile(file)
);
Expand Down
3 changes: 3 additions & 0 deletions test/unit/local-branch-file-classifiers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ describe("isCodeFile", () => {
"src/native/add.cpp",
"include/native/add.h",
"src/objc/View.m",
// Alternate C++ spellings indexed by rag.ts but previously missing here.
"native/src/parser.cc",
"libs/core/types.hpp",
// Front-end framework source — already indexed as code by rag.ts and flagged
// as visual paths, but must count as code for slop/missing-tests signals.
"src/App.vue",
Expand Down
5 changes: 5 additions & 0 deletions test/unit/local-branch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1779,6 +1779,11 @@ describe("local MCP git metadata collection", () => {
expect(isTestFile(file)).toBe(false);
expect(isCodeFile(file)).toBe(true);
}
// Alternate C++ spellings (.cc/.hpp) must mirror server isCodeFile too.
for (const file of ["native/src/parser.cc", "libs/core/types.hpp"]) {
expect(isTestFile(file)).toBe(false);
expect(isCodeFile(file)).toBe(true);
}
});

it("extracts linked issues only from standalone closing keywords, not keyword substrings", async () => {
Expand Down
21 changes: 21 additions & 0 deletions test/unit/rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,27 @@ describe("advisory rules", () => {
}
});

it("flags Missing test evidence for .cc/.hpp C++ source via isCodePath + isCodeFile parity", () => {
const advisory = buildPullRequestAdvisory(repo, {
repoFullName: repo.fullName, number: 24, title: "Add C++ modules without tests", state: "open",
authorLogin: "contributor", authorAssociation: "NONE", labels: [], linkedIssues: [],
});
const sourcePaths = ["native/src/parser.cc", "libs/core/types.hpp"];
const files: PullRequestFileRecord[] = sourcePaths.map((path) => ({
repoFullName: repo.fullName, pullNumber: 24, path, additions: 10, deletions: 0, changes: 10, payload: {},
}));
const collisions: CollisionReport = {
repoFullName: repo.fullName, generatedAt: "2026-06-10T00:00:00.000Z",
summary: { clusterCount: 0, highRiskCount: 0, itemsReviewed: 0 }, clusters: [],
};

const { annotations } = buildCheckRunAnnotations(advisory, { files, collisions, pullNumber: 24 }, "standard");

for (const path of sourcePaths) {
expect(annotations.some((entry) => entry.title === "Missing test evidence" && entry.path === path)).toBe(true);
}
});

it("buildCheckRunAnnotations uses notice level for medium-risk collisions and critical public finding text", () => {
const advisory = {
...buildPullRequestAdvisory(repo, null),
Expand Down
14 changes: 10 additions & 4 deletions test/unit/score-preview-script.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ describe("gittensor-score-preview.mjs classifier parity with the server", () =>
{ path: "src/native/add.c", additions: 2, deletions: 0 },
{ path: "src/native/add.cpp", additions: 3, deletions: 0 },
{ path: "include/native/add.h", additions: 4, deletions: 0 },
{ path: "native/src/parser.cc", additions: 5, deletions: 0 },
{ path: "libs/core/types.hpp", additions: 7, deletions: 0 },
{ path: "src/objc/View.m", additions: 6, deletions: 0 },
]);
expect(out.sourceTokenScore).toBe(25); // src/loader.mts + native source extensions
expect(out.sourceTokenScore).toBe(37); // src/loader.mts + native source extensions
expect(out.testTokenScore).toBe(SAMPLE_TEST_LINES + 7); // cy + pytest + root snapshot + JVM tests
expect(out.nonCodeTokenScore).toBe(0); // the .mts is no longer misfiled as non-code
});
Expand Down Expand Up @@ -73,14 +75,16 @@ describe("gittensor-score-preview.mjs classifier parity with the server", () =>
{ path: "src/native/add.c", additions: 2, deletions: 0 },
{ path: "src/native/add.cpp", additions: 3, deletions: 0 },
{ path: "include/native/add.h", additions: 4, deletions: 0 },
{ path: "native/src/parser.cc", additions: 5, deletions: 0 },
{ path: "libs/core/types.hpp", additions: 7, deletions: 0 },
{ path: "src/objc/View.m", additions: 6, deletions: 0 },
];
const env = { ...process.env };
delete env.GITTENSOR_ROOT;
const res = spawnSync(python, [scriptPy], { input: JSON.stringify({ changedFiles: nativeFiles }), encoding: "utf8", env });
expect(res.status, res.stderr).toBe(0);
const out = JSON.parse(res.stdout);
expect(out.sourceTokenScore).toBe(15); // 2 + 3 + 4 + 6
expect(out.sourceTokenScore).toBe(27); // 2 + 3 + 4 + 5 + 7 + 6
expect(out.testTokenScore).toBe(0);
expect(out.nonCodeTokenScore).toBe(0);
});
Expand All @@ -92,9 +96,11 @@ describe("gittensor-score-preview.mjs classifier parity with the server", () =>
const upperCaseFiles = [
{ path: "src/native/Foo.C", additions: 2, deletions: 0 },
{ path: "include/native/Foo.H", additions: 4, deletions: 0 },
{ path: "native/src/Parser.CC", additions: 5, deletions: 0 },
{ path: "libs/core/Types.HPP", additions: 3, deletions: 0 },
];
const mjs = runPreview(upperCaseFiles);
expect(mjs.sourceTokenScore).toBe(6);
expect(mjs.sourceTokenScore).toBe(14);
expect(mjs.nonCodeTokenScore).toBe(0);

const python = findPython();
Expand All @@ -104,7 +110,7 @@ describe("gittensor-score-preview.mjs classifier parity with the server", () =>
const res = spawnSync(python, [scriptPy], { input: JSON.stringify({ changedFiles: upperCaseFiles }), encoding: "utf8", env });
expect(res.status, res.stderr).toBe(0);
const py = JSON.parse(res.stdout);
expect(py.sourceTokenScore).toBe(6);
expect(py.sourceTokenScore).toBe(14);
expect(py.nonCodeTokenScore).toBe(0);
});

Expand Down
Loading