@safetnsr/vet 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/checks/tests.d.ts +2 -0
- package/dist/checks/tests.js +228 -0
- package/dist/checks/verify.d.ts +2 -0
- package/dist/checks/verify.js +219 -0
- package/dist/cli.js +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { walkFiles } from '../util.js';
|
|
4
|
+
const TEST_FILE_RE = /\.(test|spec)\.(ts|js|tsx|jsx)$/;
|
|
5
|
+
const TEST_DIR_RE = /(?:^|[/\\])(__tests__|tests?)[/\\]/;
|
|
6
|
+
function isTestFile(relPath) {
|
|
7
|
+
return TEST_FILE_RE.test(relPath) || TEST_DIR_RE.test(relPath);
|
|
8
|
+
}
|
|
9
|
+
// Pattern 1: Tautological assertions
|
|
10
|
+
function findTautological(lines, file) {
|
|
11
|
+
const issues = [];
|
|
12
|
+
// expect(literal).toBe(literal) or .toEqual(literal)
|
|
13
|
+
const expectLiteral = /expect\(([^)]+)\)\s*\.\s*(?:toBe|toEqual)\(\s*([^)]+)\s*\)/;
|
|
14
|
+
// assert.strictEqual(x, x)
|
|
15
|
+
const assertStrictEqual = /assert\.strictEqual\(\s*([^,]+?)\s*,\s*([^)]+?)\s*\)/;
|
|
16
|
+
for (let i = 0; i < lines.length; i++) {
|
|
17
|
+
const line = lines[i];
|
|
18
|
+
const m1 = line.match(expectLiteral);
|
|
19
|
+
if (m1) {
|
|
20
|
+
const left = m1[1].trim();
|
|
21
|
+
const right = m1[2].trim();
|
|
22
|
+
if (left === right) {
|
|
23
|
+
issues.push({
|
|
24
|
+
severity: 'error',
|
|
25
|
+
message: `tautological assertion: expect(${left}).toBe/toEqual(${right})`,
|
|
26
|
+
file, line: i + 1, fixable: false,
|
|
27
|
+
fixHint: 'assert on actual behavior, not constant values',
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const m2 = line.match(assertStrictEqual);
|
|
32
|
+
if (m2) {
|
|
33
|
+
const left = m2[1].trim();
|
|
34
|
+
const right = m2[2].trim();
|
|
35
|
+
if (left === right) {
|
|
36
|
+
issues.push({
|
|
37
|
+
severity: 'error',
|
|
38
|
+
message: `tautological assertion: assert.strictEqual(${left}, ${left})`,
|
|
39
|
+
file, line: i + 1, fixable: false,
|
|
40
|
+
fixHint: 'compare different values — input vs expected output',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return issues;
|
|
46
|
+
}
|
|
47
|
+
// Pattern 2: Empty test bodies
|
|
48
|
+
function findEmptyBodies(content, file) {
|
|
49
|
+
const issues = [];
|
|
50
|
+
// Match it/test with arrow or function, empty body
|
|
51
|
+
const re = /(?:^|\n)([ \t]*(?:it|test)\s*\([^,]+,\s*(?:(?:async\s+)?(?:\(\)\s*=>|\([^)]*\)\s*=>|function\s*\([^)]*\)))\s*\{([\s]*)\}\s*\))/g;
|
|
52
|
+
let m;
|
|
53
|
+
while ((m = re.exec(content)) !== null) {
|
|
54
|
+
const body = m[2];
|
|
55
|
+
// body should be empty or whitespace/comments only
|
|
56
|
+
const stripped = body.replace(/\/\/[^\n]*/g, '').replace(/\/\*[\s\S]*?\*\//g, '').trim();
|
|
57
|
+
if (stripped === '') {
|
|
58
|
+
const line = content.substring(0, m.index).split('\n').length;
|
|
59
|
+
issues.push({
|
|
60
|
+
severity: 'error',
|
|
61
|
+
message: 'empty test body — test does nothing',
|
|
62
|
+
file, line, fixable: false,
|
|
63
|
+
fixHint: 'add actual test logic or remove the test',
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return issues;
|
|
68
|
+
}
|
|
69
|
+
// Pattern 3: Todo / skipped tests
|
|
70
|
+
function findTodoSkipped(lines, file) {
|
|
71
|
+
const issues = [];
|
|
72
|
+
const todoRe = /(?:it|test)\.todo\s*\(/;
|
|
73
|
+
const skippedRe = /(?:^|\s)(?:xit|xtest|xdescribe)\s*\(/;
|
|
74
|
+
for (let i = 0; i < lines.length; i++) {
|
|
75
|
+
if (todoRe.test(lines[i])) {
|
|
76
|
+
issues.push({
|
|
77
|
+
severity: 'warning',
|
|
78
|
+
message: 'todo test — placeholder with no implementation',
|
|
79
|
+
file, line: i + 1, fixable: false,
|
|
80
|
+
fixHint: 'implement the test or remove the placeholder',
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (skippedRe.test(lines[i])) {
|
|
84
|
+
issues.push({
|
|
85
|
+
severity: 'warning',
|
|
86
|
+
message: 'skipped test — disabled with x prefix',
|
|
87
|
+
file, line: i + 1, fixable: false,
|
|
88
|
+
fixHint: 'fix and re-enable or remove the skipped test',
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return issues;
|
|
93
|
+
}
|
|
94
|
+
// Pattern 4: Zero-assertion tests
|
|
95
|
+
// We need to find test blocks with code but no assertions
|
|
96
|
+
function findZeroAssertionTests(content, file) {
|
|
97
|
+
const issues = [];
|
|
98
|
+
// Find it(...) or test(...) blocks - simplified regex for the opening
|
|
99
|
+
const testBlockRe = /(?:^|\n)([ \t]*)(?:it|test)\s*\(\s*(?:'[^']*'|"[^"]*"|`[^`]*`)\s*,\s*(?:async\s+)?(?:\(\)\s*=>|\([^)]*\)\s*=>|function\s*\([^)]*\))\s*\{/g;
|
|
100
|
+
let m;
|
|
101
|
+
while ((m = testBlockRe.exec(content)) !== null) {
|
|
102
|
+
const startIdx = m.index + m[0].length;
|
|
103
|
+
// Find matching closing brace
|
|
104
|
+
let depth = 1;
|
|
105
|
+
let i = startIdx;
|
|
106
|
+
while (i < content.length && depth > 0) {
|
|
107
|
+
if (content[i] === '{')
|
|
108
|
+
depth++;
|
|
109
|
+
else if (content[i] === '}')
|
|
110
|
+
depth--;
|
|
111
|
+
i++;
|
|
112
|
+
}
|
|
113
|
+
if (depth !== 0)
|
|
114
|
+
continue;
|
|
115
|
+
const body = content.substring(startIdx, i - 1);
|
|
116
|
+
const stripped = body.replace(/\/\/[^\n]*/g, '').replace(/\/\*[\s\S]*?\*\//g, '').trim();
|
|
117
|
+
if (stripped === '')
|
|
118
|
+
continue; // empty body handled elsewhere
|
|
119
|
+
// Check for assertion calls
|
|
120
|
+
const assertionRe = /(?:expect\s*\(|assert\.|\.should\.|toBe\s*\(|toEqual\s*\(|toMatch\s*\(|toThrow\s*\()/;
|
|
121
|
+
if (!assertionRe.test(body)) {
|
|
122
|
+
const line = content.substring(0, m.index).split('\n').length;
|
|
123
|
+
issues.push({
|
|
124
|
+
severity: 'warning',
|
|
125
|
+
message: 'test has code but no assertions',
|
|
126
|
+
file, line, fixable: false,
|
|
127
|
+
fixHint: 'add expect() or assert calls to verify behavior',
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return issues;
|
|
132
|
+
}
|
|
133
|
+
// Pattern 5: Mock-only tests
|
|
134
|
+
function findMockOnlyTests(content, file) {
|
|
135
|
+
const issues = [];
|
|
136
|
+
const testBlockRe = /(?:^|\n)([ \t]*)(?:it|test)\s*\(\s*(?:'[^']*'|"[^"]*"|`[^`]*`)\s*,\s*(?:async\s+)?(?:\(\)\s*=>|\([^)]*\)\s*=>|function\s*\([^)]*\))\s*\{/g;
|
|
137
|
+
let m;
|
|
138
|
+
while ((m = testBlockRe.exec(content)) !== null) {
|
|
139
|
+
const startIdx = m.index + m[0].length;
|
|
140
|
+
let depth = 1;
|
|
141
|
+
let i = startIdx;
|
|
142
|
+
while (i < content.length && depth > 0) {
|
|
143
|
+
if (content[i] === '{')
|
|
144
|
+
depth++;
|
|
145
|
+
else if (content[i] === '}')
|
|
146
|
+
depth--;
|
|
147
|
+
i++;
|
|
148
|
+
}
|
|
149
|
+
if (depth !== 0)
|
|
150
|
+
continue;
|
|
151
|
+
const body = content.substring(startIdx, i - 1);
|
|
152
|
+
// Find all expect lines
|
|
153
|
+
const expectLines = body.split('\n').filter(l => /expect\s*\(/.test(l));
|
|
154
|
+
if (expectLines.length === 0)
|
|
155
|
+
continue;
|
|
156
|
+
const mockRe = /\.mock|mockFn|jest\.fn|vi\.fn/;
|
|
157
|
+
const allMock = expectLines.every(l => mockRe.test(l));
|
|
158
|
+
if (allMock) {
|
|
159
|
+
const line = content.substring(0, m.index).split('\n').length;
|
|
160
|
+
issues.push({
|
|
161
|
+
severity: 'info',
|
|
162
|
+
message: 'test only asserts on mocks — no real behavior verified',
|
|
163
|
+
file, line, fixable: false,
|
|
164
|
+
fixHint: 'add assertions on actual return values or side effects',
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return issues;
|
|
169
|
+
}
|
|
170
|
+
// Pattern 6: Duplicate describe blocks
|
|
171
|
+
function findDuplicateDescribes(lines, file) {
|
|
172
|
+
const issues = [];
|
|
173
|
+
const describeRe = /describe\s*\(\s*(['"`])([^'"`]+)\1/;
|
|
174
|
+
const seen = new Map();
|
|
175
|
+
for (let i = 0; i < lines.length; i++) {
|
|
176
|
+
const m = lines[i].match(describeRe);
|
|
177
|
+
if (m) {
|
|
178
|
+
const name = m[2];
|
|
179
|
+
if (seen.has(name)) {
|
|
180
|
+
issues.push({
|
|
181
|
+
severity: 'info',
|
|
182
|
+
message: `duplicate describe block: "${name}"`,
|
|
183
|
+
file, line: i + 1, fixable: false,
|
|
184
|
+
fixHint: 'merge duplicate describe blocks into one',
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
seen.set(name, i + 1);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return issues;
|
|
193
|
+
}
|
|
194
|
+
export function checkTests(cwd, ignore) {
|
|
195
|
+
const allFiles = walkFiles(cwd, ignore);
|
|
196
|
+
const testFiles = allFiles.filter(f => isTestFile(f));
|
|
197
|
+
const issues = [];
|
|
198
|
+
for (const rel of testFiles) {
|
|
199
|
+
let content;
|
|
200
|
+
try {
|
|
201
|
+
content = readFileSync(join(cwd, rel), 'utf-8');
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const lines = content.split('\n');
|
|
207
|
+
issues.push(...findTautological(lines, rel));
|
|
208
|
+
issues.push(...findEmptyBodies(content, rel));
|
|
209
|
+
issues.push(...findTodoSkipped(lines, rel));
|
|
210
|
+
issues.push(...findZeroAssertionTests(content, rel));
|
|
211
|
+
issues.push(...findMockOnlyTests(content, rel));
|
|
212
|
+
issues.push(...findDuplicateDescribes(lines, rel));
|
|
213
|
+
}
|
|
214
|
+
let score = 100;
|
|
215
|
+
for (const issue of issues) {
|
|
216
|
+
if (issue.severity === 'error')
|
|
217
|
+
score -= 8;
|
|
218
|
+
else if (issue.severity === 'warning')
|
|
219
|
+
score -= 4;
|
|
220
|
+
else
|
|
221
|
+
score -= 2;
|
|
222
|
+
}
|
|
223
|
+
score = Math.max(0, score);
|
|
224
|
+
const summary = issues.length > 0
|
|
225
|
+
? `${issues.length} test anti-pattern${issues.length !== 1 ? 's' : ''} found across ${testFiles.length} test file${testFiles.length !== 1 ? 's' : ''}`
|
|
226
|
+
: 'no test anti-patterns found';
|
|
227
|
+
return { name: 'tests', score, maxScore: 100, issues, summary };
|
|
228
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { join, basename } from 'node:path';
|
|
2
|
+
import { readFileSync, existsSync, statSync } from 'node:fs';
|
|
3
|
+
import { execSync } from 'node:child_process';
|
|
4
|
+
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
5
|
+
function safeExec(cmd, cwd) {
|
|
6
|
+
try {
|
|
7
|
+
return execSync(cmd, { cwd, encoding: 'utf-8', timeout: 10_000, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return '';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function isTestFile(filePath) {
|
|
14
|
+
const base = basename(filePath);
|
|
15
|
+
if (/\.(test|spec)\.[a-z]+$/i.test(base))
|
|
16
|
+
return true;
|
|
17
|
+
const normalized = filePath.replace(/\\/g, '/');
|
|
18
|
+
// Match __tests__/ anywhere in path (including at root)
|
|
19
|
+
if (normalized.includes('__tests__/') || normalized.includes('/__tests__'))
|
|
20
|
+
return true;
|
|
21
|
+
if (normalized.includes('/test/') || normalized.startsWith('test/'))
|
|
22
|
+
return true;
|
|
23
|
+
if (normalized.includes('/tests/') || normalized.startsWith('tests/'))
|
|
24
|
+
return true;
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
function hasAssertions(content) {
|
|
28
|
+
return /\b(assert|expect\s*\(|it\s*\(|test\s*\(|describe\s*\(|should\.|toBe\(|toEqual\(|assertEqual|assertStrictEqual)\b/i.test(content);
|
|
29
|
+
}
|
|
30
|
+
function countLines(content) {
|
|
31
|
+
return content.split('\n').filter(l => l.trim().length > 0).length;
|
|
32
|
+
}
|
|
33
|
+
/** Extract file names mentioned in commit messages as claims */
|
|
34
|
+
function extractClaimsFromMessages(messages) {
|
|
35
|
+
const claims = [];
|
|
36
|
+
// All patterns require a file extension (dot in name) to avoid false positives
|
|
37
|
+
const patterns = [
|
|
38
|
+
/\b(?:creat\w*|add\w*|implement\w*|wrot\w*|built|generat\w*|scaffold\w*)\s+([\w./\\-]+\.[a-z]{1,5})/gi,
|
|
39
|
+
/\b(?:fix\w*|resolv\w*|updat\w*|modify|modified)\s+([\w./\\-]+\.[a-z]{1,5})/gi,
|
|
40
|
+
/\badd\w*\s+tests?\s+(?:for\s+)?([\w./\\-]+\.[a-z]{1,5})/gi,
|
|
41
|
+
];
|
|
42
|
+
for (const msg of messages) {
|
|
43
|
+
for (const pattern of patterns) {
|
|
44
|
+
pattern.lastIndex = 0;
|
|
45
|
+
let m;
|
|
46
|
+
while ((m = pattern.exec(msg)) !== null) {
|
|
47
|
+
const candidate = m[1].replace(/[,.:;)]+$/, '');
|
|
48
|
+
if (candidate && candidate.length > 2 && !candidate.startsWith('-')) {
|
|
49
|
+
claims.push(candidate);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return [...new Set(claims)];
|
|
55
|
+
}
|
|
56
|
+
/** Get files changed in recent agent session (git diff against since or HEAD~1) */
|
|
57
|
+
function getChangedFiles(cwd, since) {
|
|
58
|
+
let raw = '';
|
|
59
|
+
if (since) {
|
|
60
|
+
raw = safeExec(`git diff ${since} --name-only`, cwd);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
// Try HEAD~1 first
|
|
64
|
+
raw = safeExec(`git diff HEAD~1 --name-only`, cwd);
|
|
65
|
+
if (!raw.trim()) {
|
|
66
|
+
// Fall back to last commit's added/modified files
|
|
67
|
+
raw = safeExec(`git show --name-only --format="" HEAD`, cwd);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return raw
|
|
71
|
+
.split('\n')
|
|
72
|
+
.map(l => l.trim())
|
|
73
|
+
.filter(l => l.length > 0 && !l.startsWith('diff') && !l.startsWith('index'));
|
|
74
|
+
}
|
|
75
|
+
/** Get recent git log messages */
|
|
76
|
+
function getRecentMessages(cwd, since) {
|
|
77
|
+
let raw = '';
|
|
78
|
+
if (since) {
|
|
79
|
+
raw = safeExec(`git log ${since}..HEAD --oneline`, cwd);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
raw = safeExec(`git log -10 --oneline`, cwd);
|
|
83
|
+
}
|
|
84
|
+
return raw.split('\n').map(l => l.replace(/^[a-f0-9]+\s+/, '').trim()).filter(l => l.length > 0);
|
|
85
|
+
}
|
|
86
|
+
// ── Main check ───────────────────────────────────────────────────────────────
|
|
87
|
+
export function checkVerify(cwd, since) {
|
|
88
|
+
const issues = [];
|
|
89
|
+
let deductions = 0;
|
|
90
|
+
// Check if git repo
|
|
91
|
+
const isGit = safeExec('git rev-parse --is-inside-work-tree', cwd).trim();
|
|
92
|
+
if (isGit !== 'true') {
|
|
93
|
+
return {
|
|
94
|
+
name: 'verify',
|
|
95
|
+
score: 100,
|
|
96
|
+
maxScore: 100,
|
|
97
|
+
issues: [],
|
|
98
|
+
summary: 'not a git repository — skipped',
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// Check if any commits exist
|
|
102
|
+
const hasCommits = safeExec('git rev-parse HEAD', cwd).trim();
|
|
103
|
+
if (!hasCommits) {
|
|
104
|
+
return {
|
|
105
|
+
name: 'verify',
|
|
106
|
+
score: 100,
|
|
107
|
+
maxScore: 100,
|
|
108
|
+
issues: [],
|
|
109
|
+
summary: 'no commits found — skipped',
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
// Get changed files from git diff
|
|
113
|
+
const changedFiles = getChangedFiles(cwd, since);
|
|
114
|
+
// Get commit messages for claim extraction
|
|
115
|
+
const messages = getRecentMessages(cwd, since);
|
|
116
|
+
// Extract explicit claims from commit messages
|
|
117
|
+
const explicitClaims = extractClaimsFromMessages(messages);
|
|
118
|
+
// Build unified file list to verify: changed files + explicitly claimed files
|
|
119
|
+
const toVerify = new Set();
|
|
120
|
+
for (const f of changedFiles)
|
|
121
|
+
toVerify.add(f);
|
|
122
|
+
for (const f of explicitClaims)
|
|
123
|
+
toVerify.add(f);
|
|
124
|
+
if (toVerify.size === 0) {
|
|
125
|
+
return {
|
|
126
|
+
name: 'verify',
|
|
127
|
+
score: 100,
|
|
128
|
+
maxScore: 100,
|
|
129
|
+
issues: [],
|
|
130
|
+
summary: 'no agent claims found in recent git history',
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
let verified = 0;
|
|
134
|
+
let failed = 0;
|
|
135
|
+
for (const relPath of toVerify) {
|
|
136
|
+
const absPath = join(cwd, relPath);
|
|
137
|
+
// 1. File must exist
|
|
138
|
+
if (!existsSync(absPath)) {
|
|
139
|
+
// Only flag files that were explicitly in claims from messages (not just diff-referenced)
|
|
140
|
+
// Changed files that don't exist could be deletions — only flag if explicitly claimed
|
|
141
|
+
if (explicitClaims.includes(relPath)) {
|
|
142
|
+
issues.push({
|
|
143
|
+
severity: 'error',
|
|
144
|
+
message: `Claimed file missing: ${relPath}`,
|
|
145
|
+
file: relPath,
|
|
146
|
+
fixable: false,
|
|
147
|
+
fixHint: 'Agent claimed to create this file but it does not exist',
|
|
148
|
+
});
|
|
149
|
+
deductions += 15;
|
|
150
|
+
failed++;
|
|
151
|
+
}
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
let content = '';
|
|
155
|
+
try {
|
|
156
|
+
const stat = statSync(absPath);
|
|
157
|
+
if (!stat.isFile()) {
|
|
158
|
+
verified++;
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
content = readFileSync(absPath, 'utf-8');
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const lineCount = countLines(content);
|
|
167
|
+
// 2. File must have meaningful content (>10 non-empty lines)
|
|
168
|
+
if (lineCount < 10 && lineCount > 0) {
|
|
169
|
+
issues.push({
|
|
170
|
+
severity: 'warning',
|
|
171
|
+
message: `Thin file: ${relPath} (${lineCount} non-empty lines)`,
|
|
172
|
+
file: relPath,
|
|
173
|
+
fixable: false,
|
|
174
|
+
fixHint: 'Agent claimed to create/modify this file but it has minimal content',
|
|
175
|
+
});
|
|
176
|
+
deductions += 8;
|
|
177
|
+
failed++;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (lineCount === 0) {
|
|
181
|
+
issues.push({
|
|
182
|
+
severity: 'error',
|
|
183
|
+
message: `Empty file: ${relPath}`,
|
|
184
|
+
file: relPath,
|
|
185
|
+
fixable: false,
|
|
186
|
+
fixHint: 'Agent claimed to create this file but it is empty',
|
|
187
|
+
});
|
|
188
|
+
deductions += 15;
|
|
189
|
+
failed++;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
// 3. Test files must have actual assertions
|
|
193
|
+
if (isTestFile(relPath)) {
|
|
194
|
+
if (!hasAssertions(content)) {
|
|
195
|
+
issues.push({
|
|
196
|
+
severity: 'error',
|
|
197
|
+
message: `Test file has no assertions: ${relPath}`,
|
|
198
|
+
file: relPath,
|
|
199
|
+
fixable: false,
|
|
200
|
+
fixHint: 'Test file exists but contains no expect(), assert(), or test() calls',
|
|
201
|
+
});
|
|
202
|
+
deductions += 12;
|
|
203
|
+
failed++;
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
verified++;
|
|
208
|
+
}
|
|
209
|
+
const finalScore = Math.max(0, 100 - deductions);
|
|
210
|
+
return {
|
|
211
|
+
name: 'verify',
|
|
212
|
+
score: finalScore,
|
|
213
|
+
maxScore: 100,
|
|
214
|
+
issues,
|
|
215
|
+
summary: failed === 0
|
|
216
|
+
? `${verified} agent claim${verified !== 1 ? 's' : ''} verified clean`
|
|
217
|
+
: `${failed} claim${failed !== 1 ? 's' : ''} failed verification (${verified} passed)`,
|
|
218
|
+
};
|
|
219
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -15,6 +15,8 @@ import { checkDebt } from './checks/debt.js';
|
|
|
15
15
|
import { checkIntegrity } from './checks/integrity.js';
|
|
16
16
|
import { checkReceipt, runReceiptCommand } from './checks/receipt.js';
|
|
17
17
|
import { checkMemory } from './checks/memory.js';
|
|
18
|
+
import { checkVerify } from './checks/verify.js';
|
|
19
|
+
import { checkTests } from './checks/tests.js';
|
|
18
20
|
import { checkMap, renderMapReport } from './checks/map.js';
|
|
19
21
|
import { score } from './scorer.js';
|
|
20
22
|
import { reportPretty, reportJSON, reportBadge } from './reporter.js';
|
|
@@ -166,9 +168,13 @@ async function runChecks() {
|
|
|
166
168
|
const receiptResult = await checkReceipt(cwd);
|
|
167
169
|
// Memory: stale facts in agent memory files
|
|
168
170
|
const memoryResult = checkMemory(cwd);
|
|
171
|
+
// Verify: agent claim validation
|
|
172
|
+
const verifyResult = checkVerify(cwd, since);
|
|
173
|
+
// Tests: test theater detection
|
|
174
|
+
const testsResult = checkTests(cwd, ignore);
|
|
169
175
|
return score(cwd, {
|
|
170
176
|
security: [scanResult, secretsResult, configResult, modelsResult, owaspResult],
|
|
171
|
-
integrity: [diffResult, integrityResult, receiptResult, memoryResult],
|
|
177
|
+
integrity: [diffResult, integrityResult, receiptResult, memoryResult, verifyResult, testsResult],
|
|
172
178
|
debt: [readyResult, historyResult, debtResult],
|
|
173
179
|
deps: [depsResult],
|
|
174
180
|
});
|