crossexamdev 0.2.0 → 0.4.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/README.md +7 -2
- package/bin/crossexam.js +253 -5
- package/package.json +1 -1
- package/src/claims.js +138 -120
- package/src/evidence.js +3 -1
- package/src/findings.js +194 -0
- package/src/github.js +93 -69
- package/src/mcp.js +155 -5
- package/src/mutate.js +582 -0
- package/src/redact.js +59 -0
- package/src/reliability.js +154 -0
- package/src/report.js +195 -99
- package/src/sandbox.js +627 -0
- package/src/strength.js +637 -0
- package/src/upload.js +212 -0
package/README.md
CHANGED
|
@@ -8,11 +8,16 @@ crossexam cross-examines what coding agents claim ("all tests pass", "every call
|
|
|
8
8
|
npx crossexamdev scan # how often have your agents been wrong?
|
|
9
9
|
npx crossexamdev verify "All tests pass." # re-check any agent's summary right now
|
|
10
10
|
npx crossexamdev init --mcp # make every agent in this repo check itself
|
|
11
|
-
npx crossexamdev mcp # MCP server with
|
|
11
|
+
npx crossexamdev mcp # MCP server with verify_claims and assess_test_strength
|
|
12
|
+
npx crossexamdev mutate # would the tests notice a bug in what the agent changed?
|
|
12
13
|
```
|
|
13
14
|
|
|
14
15
|
Node 18.17+, zero dependencies, runs entirely on your machine. Once installed, the command is also available as `crossexam`.
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
`mutate` plants small defects in the changed lines and runs your tests against each one, in a disposable copy of the repo. Tests run inside a sandbox (bubblewrap on Linux, `sandbox-exec` on macOS, or Docker). Where none is available, crossexam refuses unless you pass `--unsandboxed`. Details and the threat model: https://github.com/zackt223/crossexam/blob/master/docs/mutation-security.md
|
|
18
|
+
|
|
19
|
+
Site: https://zackt223.github.io/crossexam/
|
|
20
|
+
|
|
21
|
+
Full docs and the GitHub Action: https://github.com/zackt223/crossexam
|
|
17
22
|
|
|
18
23
|
Free and open source under the MIT license. Built by [Zack Telsem](https://zacktelsem.com).
|
package/bin/crossexam.js
CHANGED
|
@@ -4,15 +4,20 @@ import os from 'node:os';
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { analyzeSession } from '../src/analyze.js';
|
|
7
|
+
import { detectWorkClaims } from '../src/claims.js';
|
|
7
8
|
import { emitActions, readPullRequest } from '../src/github.js';
|
|
8
9
|
import { globalSnippets, runInit } from '../src/init.js';
|
|
9
10
|
import { detectCommands, verifyText } from '../src/live.js';
|
|
10
11
|
import { formatForAgent, startMcpServer } from '../src/mcp.js';
|
|
11
12
|
import { discoverAider, discoverMore } from '../src/readers.js';
|
|
12
|
-
import { buildReport, c, printReport } from '../src/report.js';
|
|
13
|
+
import { buildReport, c, printReport, printStrength } from '../src/report.js';
|
|
14
|
+
import { assessStrength, ledgerRecord, qualityOf, strengthHistory, toCsv, withoutSource } from '../src/strength.js';
|
|
13
15
|
import { AGENTS, defaultSources, findTranscripts, readSession } from '../src/transcripts.js';
|
|
16
|
+
import { SOURCE_POLICIES, buildPayload, classifyReport, githubContext, validatePayload } from '../src/upload.js';
|
|
17
|
+
import { findingsFrom, formatFindingsForAgent, listSessions, loadSession, openSession, reverify as reverifySession, reverifyRecord } from '../src/findings.js';
|
|
18
|
+
import { describeAgent, reliability as reliabilityOf } from '../src/reliability.js';
|
|
14
19
|
|
|
15
|
-
const VERSION = '0.
|
|
20
|
+
const VERSION = '0.4.0';
|
|
16
21
|
const HELP = `
|
|
17
22
|
${c.bold('crossexam')} — cross-examine what your coding agents claim
|
|
18
23
|
|
|
@@ -22,6 +27,21 @@ const HELP = `
|
|
|
22
27
|
crossexam init [--mcp] add the rule to AGENTS.md (and MCP configs) so agents check themselves
|
|
23
28
|
crossexam verify --github in CI: check the claims in an agent's pull request description
|
|
24
29
|
|
|
30
|
+
${c.bold('Test strength')}
|
|
31
|
+
crossexam mutate plant small defects in the changed code and see if the tests notice
|
|
32
|
+
crossexam verify --mutate verify claims, then grade how strong the tests behind them are
|
|
33
|
+
|
|
34
|
+
${c.bold('Findings and re-verification')}
|
|
35
|
+
crossexam findings [id] the open findings of a session, structured for an agent (--json)
|
|
36
|
+
crossexam reverify <id> re-check a session independently; only this closes a finding
|
|
37
|
+
crossexam reliability how reliably each agent produces working software, from your own
|
|
38
|
+
verify / mutate / reverify evidence (--since 90d, --agent, --json)
|
|
39
|
+
|
|
40
|
+
${c.bold('Cloud')} (not open yet: nothing is ever sent today)
|
|
41
|
+
crossexam upload --dry-run --report <file>
|
|
42
|
+
show exactly what a run would send to crossexam cloud: paths made
|
|
43
|
+
relative, secrets redacted. --source none leaves code lines out
|
|
44
|
+
|
|
25
45
|
${c.bold('History')}
|
|
26
46
|
crossexam scan check local transcripts: Claude Code, Codex, Gemini CLI, Cline,
|
|
27
47
|
Roo Code, Kilo Code, Aider and the open format
|
|
@@ -35,6 +55,30 @@ const HELP = `
|
|
|
35
55
|
--json machine-readable result
|
|
36
56
|
--fail-on <contradicted|none> exit 1 when a claim is contradicted (default: contradicted)
|
|
37
57
|
--timeout <seconds> per command (default 300)
|
|
58
|
+
--mutate also assess test strength when tests or finished work are claimed
|
|
59
|
+
|
|
60
|
+
${c.bold('mutate')}
|
|
61
|
+
--base <ref> compare against this ref (default: uncommitted changes, else HEAD~1)
|
|
62
|
+
--files <a.ts,b.js> mutate these files, every line, instead of the diff
|
|
63
|
+
--max <n> mutants to run this time (default 25; finished ones are cached)
|
|
64
|
+
--budget <seconds> stop starting new mutants after this long (default 300)
|
|
65
|
+
--isolation <auto|bwrap|sandbox-exec|docker>
|
|
66
|
+
sandbox for the test runs (default auto: the first one that works here;
|
|
67
|
+
refuses to run if none does)
|
|
68
|
+
--unsandboxed run without a sandbox, with your own permissions (code you trust only)
|
|
69
|
+
--test-command <cmd> the oracle (default: the repo's test command)
|
|
70
|
+
--no-cache ignore cached results
|
|
71
|
+
--json [out.json] / --csv <f> write the full report (secret-looking values are redacted)
|
|
72
|
+
--no-source leave code lines out of the report
|
|
73
|
+
--agent <name> record which agent made the change, for history
|
|
74
|
+
--fail-under <0-1> exit 1 when the mutation score is below this
|
|
75
|
+
|
|
76
|
+
${c.bold('upload')}
|
|
77
|
+
--dry-run build and check the payload, print it, send nothing
|
|
78
|
+
--report <file> a report saved with verify --json or mutate --json (repeatable)
|
|
79
|
+
--source <changed-lines|none> include the changed code lines, or none of them (default changed-lines)
|
|
80
|
+
--agent <name> which agent made the change (otherwise taken from the pr)
|
|
81
|
+
--out <file> write the payload to a file instead of stdout
|
|
38
82
|
|
|
39
83
|
${c.bold('scan')}
|
|
40
84
|
--since <30d|12h|all> how far back to look (default 30d)
|
|
@@ -52,7 +96,7 @@ const HELP = `
|
|
|
52
96
|
--dry-run print the change, write nothing
|
|
53
97
|
`;
|
|
54
98
|
|
|
55
|
-
const VALUED = new Set(['since', 'agent', 'repo', 'file', 'json', 'limit', 'path', 'cwd', 'fail-on', 'timeout']);
|
|
99
|
+
const VALUED = new Set(['report', 'source', 'out', 'since', 'agent', 'repo', 'file', 'json', 'limit', 'path', 'cwd', 'fail-on', 'timeout', 'base', 'files', 'max', 'budget', 'isolation', 'test-command', 'csv', 'fail-under']);
|
|
56
100
|
const args = process.argv.slice(2);
|
|
57
101
|
const cmd = args[0] && !args[0].startsWith('-') ? args.shift() : 'scan';
|
|
58
102
|
const flag = (name) => args.includes(`--${name}`);
|
|
@@ -70,6 +114,11 @@ try {
|
|
|
70
114
|
else if (flag('version') || cmd === 'version') console.log(VERSION);
|
|
71
115
|
else if (cmd === 'scan') await scan();
|
|
72
116
|
else if (cmd === 'verify') await verify();
|
|
117
|
+
else if (cmd === 'mutate') await mutate();
|
|
118
|
+
else if (cmd === 'upload') upload();
|
|
119
|
+
else if (cmd === 'reverify') await reverify();
|
|
120
|
+
else if (cmd === 'findings') findings();
|
|
121
|
+
else if (cmd === 'reliability') reliabilityCmd();
|
|
73
122
|
else if (cmd === 'mcp') startMcpServer({ version: VERSION, defaultCwd: path.resolve(String(opt('cwd', process.cwd()))) });
|
|
74
123
|
else if (cmd === 'init') init();
|
|
75
124
|
else if (cmd === 'hook') await hook();
|
|
@@ -125,6 +174,9 @@ async function scan() {
|
|
|
125
174
|
}
|
|
126
175
|
|
|
127
176
|
const report = buildReport(claims, { sessions, turns, ranCheckTurns, contradictedTurns, agents: [...agents], since: since ? new Date(since).toISOString() : null });
|
|
177
|
+
// Test strength from earlier `mutate` / `verify --mutate` / MCP runs: a separate dimension.
|
|
178
|
+
const mutation = strengthHistory({ since, agent: typeof onlyAgent === 'string' ? onlyAgent : undefined, repo: typeof onlyRepo === 'string' ? onlyRepo : undefined });
|
|
179
|
+
if (mutation) report.mutation = mutation;
|
|
128
180
|
const json = opt('json');
|
|
129
181
|
if (json) {
|
|
130
182
|
const out = typeof json === 'string' ? json : 'crossexam-report.json';
|
|
@@ -158,17 +210,213 @@ async function verify() {
|
|
|
158
210
|
onRun: (command) => !json && process.stderr.write(c.dim(` running ${command}…\n`)),
|
|
159
211
|
});
|
|
160
212
|
|
|
161
|
-
if (
|
|
213
|
+
if (flag('mutate') && wantsStrength(text, r)) {
|
|
214
|
+
if (!json) process.stderr.write(c.dim(' assessing test strength (planting defects in an isolated copy)…\n'));
|
|
215
|
+
const strength = await assessStrength({ cwd, ...mutateOpts(), onProgress: json ? undefined : progress });
|
|
216
|
+
attachStrength(r, strength);
|
|
217
|
+
ledger([ledgerRecord(strength, { agent: pr?.agent || String(opt('agent', 'unknown')), claim: r.results.find((x) => x.kind === 'tests')?.claim ?? null, source: github ? 'github' : 'verify' })]);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// evidence for reliability history, and a findings session the agent can close
|
|
221
|
+
const who = pr?.agent || String(opt('agent', 'unknown'));
|
|
222
|
+
ledger(claimRecords(r, who, github ? 'github' : 'verify', cwd));
|
|
223
|
+
const findings = findingsFrom({ verify: r, strength: r.strength });
|
|
224
|
+
const session = findings.length && !github && !flag('dry-run') ? openSession({ findings, cwd, repo: r.strength?.repo, agent: who, source: 'verify', testCommand: r.strength?.testCommand }) : null;
|
|
225
|
+
|
|
226
|
+
if (json) process.stdout.write(JSON.stringify({ ...r, pr, findings, session: session?.id ?? null }, null, 2) + '\n');
|
|
162
227
|
else if (github) emitActions(pr, r);
|
|
163
228
|
else {
|
|
164
229
|
console.log();
|
|
165
230
|
console.log(formatForAgent(r).replace(/^/gm, ' '));
|
|
231
|
+
if (r.strength) printStrength(r.strength, { limit: 4 });
|
|
166
232
|
if (!r.results.length && Object.keys(r.commands).length) console.log(c.dim(`\n Checks available here: ${Object.entries(r.commands).map(([k, v]) => `${k} (${v.command})`).join(', ')}`));
|
|
233
|
+
if (session) console.log(`\n ${c.bold(`${findings.length} finding${findings.length === 1 ? '' : 's'}`)} ${c.dim(`· session ${session.id} · after fixing, re-check with`)} crossexam reverify ${session.id}`);
|
|
167
234
|
console.log();
|
|
168
235
|
}
|
|
169
236
|
if (opt('fail-on', 'contradicted') !== 'none' && !r.ok) process.exitCode = 1;
|
|
170
237
|
}
|
|
171
238
|
|
|
239
|
+
/**
|
|
240
|
+
* What a run would send to crossexam cloud. Cloud isn't open yet, so this only
|
|
241
|
+
* ever builds, checks and prints the payload; it has no way to send it.
|
|
242
|
+
*/
|
|
243
|
+
function upload() {
|
|
244
|
+
if (!flag('dry-run')) {
|
|
245
|
+
process.stderr.write("crossexam cloud isn't open yet, so there is nowhere to send this and nothing was sent.\nRun with --dry-run to see exactly what a run would send.\n");
|
|
246
|
+
process.exitCode = 2;
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const files = opts('report');
|
|
250
|
+
if (!files.length) throw new Error('upload --dry-run needs --report <file>: save one with `crossexam verify "…" --json > verify.json` or `crossexam mutate --json mutate.json`.');
|
|
251
|
+
let verify = null;
|
|
252
|
+
let mutation = null;
|
|
253
|
+
for (const f of files) {
|
|
254
|
+
const got = classifyReport(JSON.parse(fs.readFileSync(path.resolve(f), 'utf8')));
|
|
255
|
+
verify = got.verify ?? verify;
|
|
256
|
+
mutation = got.mutation ?? mutation;
|
|
257
|
+
}
|
|
258
|
+
const source = String(opt('source', 'changed-lines'));
|
|
259
|
+
if (!SOURCE_POLICIES.includes(source)) throw new Error(`--source must be one of ${SOURCE_POLICIES.join(', ')}`);
|
|
260
|
+
const agent = opt('agent');
|
|
261
|
+
const payload = buildPayload({
|
|
262
|
+
verify,
|
|
263
|
+
mutation,
|
|
264
|
+
github: githubContext(),
|
|
265
|
+
agent: typeof agent === 'string' ? agent : undefined,
|
|
266
|
+
cliVersion: VERSION,
|
|
267
|
+
root: path.resolve(String(opt('cwd', verify?.cwd || process.cwd()))),
|
|
268
|
+
sourcePolicy: source,
|
|
269
|
+
});
|
|
270
|
+
const errors = validatePayload(payload);
|
|
271
|
+
if (errors.length) throw new Error(`the payload failed its own checks:\n ${errors.join('\n ')}`);
|
|
272
|
+
const text = JSON.stringify(payload, null, 2);
|
|
273
|
+
const out = opt('out');
|
|
274
|
+
if (typeof out === 'string') {
|
|
275
|
+
fs.writeFileSync(out, text + '\n');
|
|
276
|
+
process.stderr.write(`dry run: ${Buffer.byteLength(text)} bytes written to ${out}. nothing was sent.\n`);
|
|
277
|
+
} else {
|
|
278
|
+
process.stdout.write(text + '\n');
|
|
279
|
+
process.stderr.write(`dry run: ${Buffer.byteLength(text)} bytes. nothing was sent.\n`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
async function mutate() {
|
|
284
|
+
const cwd = path.resolve(String(opt('cwd', process.cwd())));
|
|
285
|
+
const json = opt('json');
|
|
286
|
+
const toStdout = json === true;
|
|
287
|
+
const full = await assessStrength({ cwd, ...mutateOpts(), onProgress: toStdout ? undefined : progress });
|
|
288
|
+
const r = flag('no-source') ? withoutSource(full) : full;
|
|
289
|
+
const who = String(opt('agent', 'unknown'));
|
|
290
|
+
ledger([ledgerRecord(r, { agent: who, source: 'mutate' })]);
|
|
291
|
+
const findings = findingsFrom({ strength: full });
|
|
292
|
+
const session = findings.length ? openSession({ findings, cwd, repo: full.repo, agent: who, source: 'mutate', testCommand: full.testCommand }) : null;
|
|
293
|
+
r.findings = flag('no-source') ? findings.map(({ before, after, ...f }) => f) : findings;
|
|
294
|
+
r.session = session?.id ?? null;
|
|
295
|
+
const csv = opt('csv');
|
|
296
|
+
if (typeof csv === 'string') fs.writeFileSync(csv, toCsv(r));
|
|
297
|
+
if (toStdout) process.stdout.write(JSON.stringify(r, null, 2) + '\n');
|
|
298
|
+
else {
|
|
299
|
+
if (typeof json === 'string') fs.writeFileSync(json, JSON.stringify(r, null, 2));
|
|
300
|
+
printStrength(r, { limit: Number(opt('limit', 8)) });
|
|
301
|
+
if (session) console.log(` ${c.bold(`${findings.length} finding${findings.length === 1 ? '' : 's'}`)} ${c.dim(`· session ${session.id} · after adding tests, re-check with`)} crossexam reverify ${session.id}\n`);
|
|
302
|
+
if (typeof json === 'string') console.log(` ${c.dim('Report written to')} ${path.resolve(json)}\n`);
|
|
303
|
+
}
|
|
304
|
+
const under = opt('fail-under');
|
|
305
|
+
if (under !== undefined && r.summary.score != null && r.summary.score < Number(under)) process.exitCode = 1;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** One ledger record per checked claim: the evidence reliability history is built from. */
|
|
309
|
+
function claimRecords(r, agent, source, cwd) {
|
|
310
|
+
const at = new Date().toISOString();
|
|
311
|
+
const repo = path.basename(cwd);
|
|
312
|
+
return r.results.map((x) => ({ type: 'verify', at, agent, repo, source, kind: x.kind, verdict: x.verdict }));
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** Re-check a findings session independently: only this can close a finding. */
|
|
316
|
+
async function reverify() {
|
|
317
|
+
const id = positional()[0];
|
|
318
|
+
if (!id) {
|
|
319
|
+
const recent = listSessions(8);
|
|
320
|
+
if (!recent.length) throw new Error('reverify needs a session id. Sessions are opened when verify or mutate finds something.');
|
|
321
|
+
console.log(`\n ${c.bold('Recent sessions')}`);
|
|
322
|
+
for (const s of recent) {
|
|
323
|
+
const open = s.findings.filter((f) => f.status === 'open' || f.status === 'still-open').length;
|
|
324
|
+
console.log(` ${s.id} ${c.dim(s.createdAt.slice(0, 16).replace('T', ' '))} ${s.repo} ${open ? c.red(`${open} open`) : c.green('all closed')} ${c.dim(`${s.rounds.length} re-check${s.rounds.length === 1 ? '' : 's'}`)}`);
|
|
325
|
+
}
|
|
326
|
+
console.log(c.dim('\n crossexam reverify <id>\n'));
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
const json = flag('json');
|
|
330
|
+
const unsandboxed = flag('unsandboxed');
|
|
331
|
+
const { session, summary, changes } = await reverifySession(id, { cwd: typeof opt('cwd') === 'string' ? String(opt('cwd')) : undefined, isolation: typeof opt('isolation') === 'string' ? String(opt('isolation')) : unsandboxed ? 'none' : undefined, allowUnsandboxed: unsandboxed });
|
|
332
|
+
ledger([reverifyRecord(session, summary)]);
|
|
333
|
+
if (json) {
|
|
334
|
+
process.stdout.write(JSON.stringify({ session: session.id, ...summary, changes, findings: session.findings }, null, 2) + '\n');
|
|
335
|
+
} else {
|
|
336
|
+
const mark = { resolved: c.green('✓ resolved '), 'still-open': c.red('✗ still open'), superseded: c.gray('○ superseded') };
|
|
337
|
+
console.log(`\n ${c.bold(`Re-check ${summary.round}`)} ${c.dim(`· session ${session.id} · ${session.repo}`)}`);
|
|
338
|
+
if (summary.blocker) console.log(` ${c.yellow(summary.blocker)}`);
|
|
339
|
+
for (const ch of changes) {
|
|
340
|
+
const f = session.findings.find((x) => x.id === ch.id);
|
|
341
|
+
const what = f.type === 'claim' ? `"${f.claim}"` : `${f.file}:${f.line} ${c.dim(`${f.category} · ${f.operator}`)}`;
|
|
342
|
+
console.log(` ${mark[ch.status]} ${what}\n ${c.dim(ch.evidence)}`);
|
|
343
|
+
}
|
|
344
|
+
const open = session.findings.filter((f) => f.status === 'still-open' || f.status === 'open').length;
|
|
345
|
+
console.log(open ? `\n ${c.red(`${open} still open.`)} ${c.dim('Fix them and run this again.')}\n` : `\n ${c.green('Every finding is closed.')}\n`);
|
|
346
|
+
}
|
|
347
|
+
if (session.findings.some((f) => f.status === 'still-open' || f.status === 'open')) process.exitCode = 1;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/** The open findings of a session, structured for an agent. */
|
|
351
|
+
function findings() {
|
|
352
|
+
const id = positional()[0];
|
|
353
|
+
const session = id ? loadSession(id) : listSessions(1)[0];
|
|
354
|
+
if (!session) throw new Error('No findings sessions yet. They are opened when verify or mutate finds something.');
|
|
355
|
+
if (flag('json')) process.stdout.write(JSON.stringify(session, null, 2) + '\n');
|
|
356
|
+
else console.log('\n' + formatFindingsForAgent(session).replace(/^/gm, ' ') + '\n');
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** How reliably each agent produces working software, from recorded evidence. */
|
|
360
|
+
function reliabilityCmd() {
|
|
361
|
+
const since = parseSince(opt('since', '90d'));
|
|
362
|
+
const agent = typeof opt('agent') === 'string' ? String(opt('agent')) : undefined;
|
|
363
|
+
const repo = typeof opt('repo') === 'string' ? String(opt('repo')) : undefined;
|
|
364
|
+
const r = reliabilityOf({ since, agent, repo });
|
|
365
|
+
if (flag('json')) {
|
|
366
|
+
process.stdout.write(JSON.stringify(r, null, 2) + '\n');
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (!r.agents.length) {
|
|
370
|
+
console.log(`\n ${c.dim('No verification evidence yet. It builds up as you run verify, mutate and reverify (or the MCP tools and the hook).')}\n`);
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const p = (v) => (v == null ? c.dim(' — ') : `${String(Math.round(v * 100)).padStart(3)}%`);
|
|
374
|
+
console.log(`\n ${c.bold('Reliability by agent')} ${c.dim(`· ${r.records} records from your own runs`)}\n`);
|
|
375
|
+
console.log(c.dim(' agent claims held tests caught fixed on 1st re-check evidence'));
|
|
376
|
+
for (const a of r.agents) {
|
|
377
|
+
const held = a.claims.falseDoneRate == null ? null : 1 - a.claims.falseDoneRate;
|
|
378
|
+
console.log(` ${a.agent.padEnd(16)} ${p(held)} ${p(a.strength.score)} ${p(a.fixes.firstRecheckRate)} ${String(a.evidence).padStart(4)}`);
|
|
379
|
+
}
|
|
380
|
+
console.log();
|
|
381
|
+
for (const a of r.agents) {
|
|
382
|
+
console.log(` ${c.bold(a.agent)}: ${describeAgent(a)}.`);
|
|
383
|
+
if (a.strength.behaviouralSurvivors) console.log(c.dim(` ${a.strength.behaviouralSurvivors} behavioural gap${a.strength.behaviouralSurvivors === 1 ? '' : 's'} (access checks, transactions, retries, concurrency) went untested.`));
|
|
384
|
+
const recent = a.weeks.slice(-6).filter((w) => w.falseDoneRate != null || w.score != null);
|
|
385
|
+
if (recent.length > 1) console.log(c.dim(` weekly: ${recent.map((w) => `${w.week.slice(5)} ${w.score != null ? Math.round(w.score * 100) + '%' : '—'}`).join(' ')}`));
|
|
386
|
+
}
|
|
387
|
+
console.log(c.dim('\n Three separate measures, never blended: an agent can be honest about its claims and still ship weak tests.\n'));
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function mutateOpts() {
|
|
391
|
+
const files = opts('files').flatMap((f) => f.split(',')).filter(Boolean);
|
|
392
|
+
const str = (k) => (typeof opt(k) === 'string' ? String(opt(k)) : undefined);
|
|
393
|
+
const num = (k) => (typeof opt(k) === 'string' ? Number(opt(k)) : undefined);
|
|
394
|
+
const unsandboxed = flag('unsandboxed');
|
|
395
|
+
return { base: str('base'), files: files.length ? files : undefined, max: num('max'), budgetSeconds: num('budget'), isolation: str('isolation') || (unsandboxed ? 'none' : undefined), allowUnsandboxed: unsandboxed, testCommand: str('test-command'), cache: !flag('no-cache') };
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function progress(e) {
|
|
399
|
+
if (!process.stderr.isTTY) return;
|
|
400
|
+
if (e.phase === 'copy') process.stderr.write(c.dim(` copying the repo to a temporary folder; tests will run ${e.isolation?.sandboxed ? 'sandboxed (' + e.isolation.method + ')' : 'NOT SANDBOXED'}…\n`));
|
|
401
|
+
else if (e.phase === 'baseline') process.stderr.write(c.dim(' running the unmutated test suite (baseline)…\n'));
|
|
402
|
+
else if (e.phase === 'mutant') {
|
|
403
|
+
const st = { MUTATION_KILLED: c.green('killed '), MUTATION_SURVIVED: c.red('survived '), MUTATION_INVALID: c.gray('invalid '), MUTATION_UNRESOLVED: c.yellow('unresolved') }[e.status];
|
|
404
|
+
process.stderr.write(c.dim(` [${String(e.i).padStart(2)}/${e.total}] `) + st + c.dim(` ${e.mutant.file}:${e.mutant.line} ${e.mutant.operator}${e.cached ? ' (cached)' : ''}\n`));
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/** Only grade test strength when someone claimed tests pass or that work was done. */
|
|
409
|
+
function wantsStrength(text, r) {
|
|
410
|
+
return r.results.some((x) => x.kind === 'tests') || detectWorkClaims(text).length > 0;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/** Quality rides alongside the verdict; it never changes it. */
|
|
414
|
+
function attachStrength(r, strength) {
|
|
415
|
+
r.strength = strength;
|
|
416
|
+
const q = qualityOf(strength);
|
|
417
|
+
for (const x of r.results) if (x.kind === 'tests') x.quality = q;
|
|
418
|
+
}
|
|
419
|
+
|
|
172
420
|
function init() {
|
|
173
421
|
const cwd = path.resolve(String(opt('cwd', process.cwd())));
|
|
174
422
|
const { cli, server } = selfCommands();
|
|
@@ -266,7 +514,7 @@ function parseSince(v) {
|
|
|
266
514
|
|
|
267
515
|
function ledger(claims) {
|
|
268
516
|
try {
|
|
269
|
-
const dir = path.join(os.homedir(), '.crossexam');
|
|
517
|
+
const dir = (process.env.CROSSEXAM_HOME || path.join(os.homedir(), '.crossexam'));
|
|
270
518
|
fs.mkdirSync(dir, { recursive: true });
|
|
271
519
|
fs.appendFileSync(path.join(dir, 'ledger.jsonl'), claims.map((x) => JSON.stringify(x)).join('\n') + '\n');
|
|
272
520
|
} catch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crossexamdev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Cross-examine what any coding agent claims: verify CLI, MCP server, GitHub Action and transcript history for Claude Code, Codex, Gemini CLI, Cline, Aider and more.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/claims.js
CHANGED
|
@@ -1,120 +1,138 @@
|
|
|
1
|
-
// Claim detection: find sentences where an agent asserts something is done
|
|
2
|
-
// and classify what kind of claim it is.
|
|
3
|
-
|
|
4
|
-
/** @typedef {'tests'|'build'|'types'|'lint'|'refactor'|'migration'|'deps'|'security'} ClaimKind */
|
|
5
|
-
|
|
6
|
-
const KINDS = /** @type {const} */ ({
|
|
7
|
-
tests: [
|
|
8
|
-
/\b(?:all\s+)?(?:the\s+)?(?:\d+\s+)?(?:unit\s+|e2e\s+|integration\s+|existing\s+|new\s+)?tests?\s+(?:now\s+|still\s+|all\s+|are\s+all\s+)?(?:pass(?:es|ed|ing)?|are\s+(?:passing|green)|(?:is|are)\s+green|succeed(?:s|ed)?)\b/i,
|
|
9
|
-
/\btest\s+suite\s+(?:now\s+)?(?:passes|passed|is\s+green|is\s+passing)\b/i,
|
|
10
|
-
/\b\d+\s*(?:\/\s*\d+\s*)?(?:tests?\s+)?passing\b/i,
|
|
11
|
-
/\b(?:all|every)\s+(?:\d+\s+)?(?:specs?|test\s+cases?)\s+pass/i,
|
|
12
|
-
],
|
|
13
|
-
build: [
|
|
14
|
-
/\b(?:the\s+)?build\s+(?:now\s+)?(?:succeeds|succeeded|passes|passed|is\s+green|is\s+clean|works)\b/i,
|
|
15
|
-
/\bbuilds?\s+(?:cleanly|successfully|without\s+errors)\b/i,
|
|
16
|
-
/\bcompiles\s+(?:cleanly|successfully|without\s+(?:any\s+)?errors|fine)\b/i,
|
|
17
|
-
],
|
|
18
|
-
types: [
|
|
19
|
-
/\b(?:typecheck(?:ing)?|type[- ]check(?:ing)?|tsc)\s+(?:now\s+)?(?:passes|passed|is\s+clean|comes\s+back\s+clean|clean)\b/i,
|
|
20
|
-
/\bno\s+(?:remaining\s+)?(?:type|typescript|ts)\s+errors\b/i,
|
|
21
|
-
],
|
|
22
|
-
lint: [
|
|
23
|
-
/\blint(?:er|ing)?\s+(?:now\s+)?(?:passes|passed|is\s+clean|comes\s+back\s+clean|clean)\b/i,
|
|
24
|
-
/\bno\s+(?:remaining\s+)?lint(?:ing)?\s+(?:errors|warnings|issues)\b/i,
|
|
25
|
-
],
|
|
26
|
-
refactor: [
|
|
27
|
-
/\b(?:all|every)\s+(?:the\s+)?(?:remaining\s+)?(?:callers?|call\s*sites?|usages?|references?|imports?|occurrences?|consumers?|uses)\s+(?:\S+\s+){0,4}?(?:have\s+been\s+|has\s+been\s+|were\s+|are\s+(?:now\s+)?)?(?:updated|migrated|renamed|changed|replaced|switched|moved|fixed)\b/i,
|
|
28
|
-
/\brenamed\s+`?[\w.$]+`?\s+(?:to|→|->)\s+`?[\w.$]+`?\s+(?:everywhere|across|throughout)/i,
|
|
29
|
-
],
|
|
30
|
-
migration: [
|
|
31
|
-
/\bmigrations?\s+(?:\S+\s+){0,3}?(?:ran|applied|succeeded|completed|went\s+through|(?:has|have)\s+been\s+(?:applied|run))\b/i,
|
|
32
|
-
/\b(?:applied|ran)\s+(?:the\s+)?(?:\S+\s+)?migrations?\s+(?:successfully|cleanly)\b/i,
|
|
33
|
-
],
|
|
34
|
-
deps: [
|
|
35
|
-
/\b(?:upgraded|bumped|updated|pinned)\s+`?(@?[\w./-]+)`?\s+(?:from\s+`?v?[\w.^~-]+`?\s+)?to\s+`?v?\d[\w.-]*`?/i,
|
|
36
|
-
],
|
|
37
|
-
security: [
|
|
38
|
-
/\b(?:fixed|patched|closed|resolved|mitigated|plugged)\s+(?:the\s+)?(?:\S+\s+){0,3}?(?:vulnerability|vuln|xss|injection|cve-\d{4}-\d+|ssrf|csrf|rce|security\s+(?:issue|bug|hole|flaw))/i,
|
|
39
|
-
],
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// A sentence that talks about a check rather than asserting its result.
|
|
43
|
-
const HEDGE =
|
|
44
|
-
/\b(?:make\s+sure|ensure|should|to\s+verify|to\s+confirm|check\s+(?:that|whether|if)|until|once|if|unless|whether|will|would|could|might|need(?:s)?\s+to|let'?s|let\s+me|i'?ll|want\s+to|try\s+to|expect(?:ed)?|hopefully|before)\b/i;
|
|
45
|
-
const NEGATION =
|
|
46
|
-
/\b(?:not|n't|never|no\s+longer|fail(?:s|ed|ing)?|broken|still\s+(?:fail|broken|red)|couldn'?t|unable|can'?t|without\s+running|didn'?t\s+run|haven'?t\s+run)\b/i;
|
|
47
|
-
|
|
48
|
-
/** Split assistant prose into sentence-ish units without breaking `code`. */
|
|
49
|
-
export function sentences(text) {
|
|
50
|
-
const clean = text
|
|
51
|
-
.replace(/```[\s\S]*?```/g, ' ')
|
|
52
|
-
.replace(/\r/g, '');
|
|
53
|
-
const out = [];
|
|
54
|
-
for (const line of clean.split(/\n+/)) {
|
|
55
|
-
const parts = line.split(/(?<=[.!?])\s+(?=[A-Z`*✅✓])/);
|
|
56
|
-
for (const p of parts) {
|
|
57
|
-
const s = p.replace(/^[\s>*\-•#|]+/, '').replace(/\*\*/g, '').trim();
|
|
58
|
-
if (s.length >= 8) out.push(s);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return out;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Find claims in a piece of assistant text.
|
|
66
|
-
* @returns {{kind: ClaimKind, sentence: string, subject?: {from?: string, to?: string, pkg?: string, version?: string}}[]}
|
|
67
|
-
*/
|
|
68
|
-
export function detectClaims(text) {
|
|
69
|
-
const found = [];
|
|
70
|
-
for (const s of sentences(text)) {
|
|
71
|
-
for (const [kind, patterns] of Object.entries(KINDS)) {
|
|
72
|
-
const hit = patterns.map((re) => s.match(re)).find(Boolean);
|
|
73
|
-
if (!hit) continue;
|
|
74
|
-
// Look only at the words leading into the claim for hedges and negations,
|
|
75
|
-
// so "I fixed X, and all tests pass" counts but "make sure tests pass" doesn't.
|
|
76
|
-
const lead = s.slice(Math.max(0, hit.index - 60), hit.index);
|
|
77
|
-
const own = hit[0];
|
|
78
|
-
if (HEDGE.test(lead) || HEDGE.test(own)) continue;
|
|
79
|
-
if (NEGATION.test(lead.slice(-30)) || NEGATION.test(own)) continue;
|
|
80
|
-
if (/\?\s*$/.test(s)) continue;
|
|
81
|
-
// Quoting a claim ("the agent said “all tests pass”") isn't making one.
|
|
82
|
-
if (insideQuotes(s, hit.index)) continue;
|
|
83
|
-
found.push({ kind: /** @type {ClaimKind} */ (kind), sentence: s.slice(0, 280), subject: subjectOf(kind, s) });
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return found;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function insideQuotes(s, at) {
|
|
90
|
-
const before = s.slice(0, at);
|
|
91
|
-
const straight = (before.match(/"/g) || []).length % 2 === 1;
|
|
92
|
-
const curly = before.lastIndexOf('“') > before.lastIndexOf('”');
|
|
93
|
-
return straight || curly;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function subjectOf(kind, s) {
|
|
97
|
-
if (kind === 'refactor') {
|
|
98
|
-
const r = s.match(/\brenamed\s+`([\w.$]+)`\s+(?:to|→|->)\s+`([\w.$]+)`/i) || s.match(/`([\w.$]+)`\s*(?:→|->)\s*`([\w.$]+)`/);
|
|
99
|
-
if (r) return { from: r[1].split('.').pop(), to: r[2].split('.').pop() };
|
|
100
|
-
const tick = s.match(/`([A-Za-z_$][\w$]{2,})`/);
|
|
101
|
-
return tick ? { from: tick[1] } : undefined;
|
|
102
|
-
}
|
|
103
|
-
if (kind === 'deps') {
|
|
104
|
-
const d = s.match(/\b(?:upgraded|bumped|updated|pinned)\s+`?(@?[\w./-]+)`?\s+(?:from\s+`?v?[\w.^~-]+`?\s+)?to\s+`?v?(\d+(?:\.\d+)*(?:-[\w.]+)?)`?/i);
|
|
105
|
-
return d ? { pkg: d[1], version: d[2] } : undefined;
|
|
106
|
-
}
|
|
107
|
-
return undefined;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
1
|
+
// Claim detection: find sentences where an agent asserts something is done
|
|
2
|
+
// and classify what kind of claim it is.
|
|
3
|
+
|
|
4
|
+
/** @typedef {'tests'|'build'|'types'|'lint'|'refactor'|'migration'|'deps'|'security'} ClaimKind */
|
|
5
|
+
|
|
6
|
+
const KINDS = /** @type {const} */ ({
|
|
7
|
+
tests: [
|
|
8
|
+
/\b(?:all\s+)?(?:the\s+)?(?:\d+\s+)?(?:unit\s+|e2e\s+|integration\s+|existing\s+|new\s+)?tests?\s+(?:now\s+|still\s+|all\s+|are\s+all\s+)?(?:pass(?:es|ed|ing)?|are\s+(?:passing|green)|(?:is|are)\s+green|succeed(?:s|ed)?)\b/i,
|
|
9
|
+
/\btest\s+suite\s+(?:now\s+)?(?:passes|passed|is\s+green|is\s+passing)\b/i,
|
|
10
|
+
/\b\d+\s*(?:\/\s*\d+\s*)?(?:tests?\s+)?passing\b/i,
|
|
11
|
+
/\b(?:all|every)\s+(?:\d+\s+)?(?:specs?|test\s+cases?)\s+pass/i,
|
|
12
|
+
],
|
|
13
|
+
build: [
|
|
14
|
+
/\b(?:the\s+)?build\s+(?:now\s+)?(?:succeeds|succeeded|passes|passed|is\s+green|is\s+clean|works)\b/i,
|
|
15
|
+
/\bbuilds?\s+(?:cleanly|successfully|without\s+errors)\b/i,
|
|
16
|
+
/\bcompiles\s+(?:cleanly|successfully|without\s+(?:any\s+)?errors|fine)\b/i,
|
|
17
|
+
],
|
|
18
|
+
types: [
|
|
19
|
+
/\b(?:typecheck(?:ing)?|type[- ]check(?:ing)?|tsc)\s+(?:now\s+)?(?:passes|passed|is\s+clean|comes\s+back\s+clean|clean)\b/i,
|
|
20
|
+
/\bno\s+(?:remaining\s+)?(?:type|typescript|ts)\s+errors\b/i,
|
|
21
|
+
],
|
|
22
|
+
lint: [
|
|
23
|
+
/\blint(?:er|ing)?\s+(?:now\s+)?(?:passes|passed|is\s+clean|comes\s+back\s+clean|clean)\b/i,
|
|
24
|
+
/\bno\s+(?:remaining\s+)?lint(?:ing)?\s+(?:errors|warnings|issues)\b/i,
|
|
25
|
+
],
|
|
26
|
+
refactor: [
|
|
27
|
+
/\b(?:all|every)\s+(?:the\s+)?(?:remaining\s+)?(?:callers?|call\s*sites?|usages?|references?|imports?|occurrences?|consumers?|uses)\s+(?:\S+\s+){0,4}?(?:have\s+been\s+|has\s+been\s+|were\s+|are\s+(?:now\s+)?)?(?:updated|migrated|renamed|changed|replaced|switched|moved|fixed)\b/i,
|
|
28
|
+
/\brenamed\s+`?[\w.$]+`?\s+(?:to|→|->)\s+`?[\w.$]+`?\s+(?:everywhere|across|throughout)/i,
|
|
29
|
+
],
|
|
30
|
+
migration: [
|
|
31
|
+
/\bmigrations?\s+(?:\S+\s+){0,3}?(?:ran|applied|succeeded|completed|went\s+through|(?:has|have)\s+been\s+(?:applied|run))\b/i,
|
|
32
|
+
/\b(?:applied|ran)\s+(?:the\s+)?(?:\S+\s+)?migrations?\s+(?:successfully|cleanly)\b/i,
|
|
33
|
+
],
|
|
34
|
+
deps: [
|
|
35
|
+
/\b(?:upgraded|bumped|updated|pinned)\s+`?(@?[\w./-]+)`?\s+(?:from\s+`?v?[\w.^~-]+`?\s+)?to\s+`?v?\d[\w.-]*`?/i,
|
|
36
|
+
],
|
|
37
|
+
security: [
|
|
38
|
+
/\b(?:fixed|patched|closed|resolved|mitigated|plugged)\s+(?:the\s+)?(?:\S+\s+){0,3}?(?:vulnerability|vuln|xss|injection|cve-\d{4}-\d+|ssrf|csrf|rce|security\s+(?:issue|bug|hole|flaw))/i,
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// A sentence that talks about a check rather than asserting its result.
|
|
43
|
+
const HEDGE =
|
|
44
|
+
/\b(?:make\s+sure|ensure|should|to\s+verify|to\s+confirm|check\s+(?:that|whether|if)|until|once|if|unless|whether|will|would|could|might|need(?:s)?\s+to|let'?s|let\s+me|i'?ll|want\s+to|try\s+to|expect(?:ed)?|hopefully|before)\b/i;
|
|
45
|
+
const NEGATION =
|
|
46
|
+
/\b(?:not|n't|never|no\s+longer|fail(?:s|ed|ing)?|broken|still\s+(?:fail|broken|red)|couldn'?t|unable|can'?t|without\s+running|didn'?t\s+run|haven'?t\s+run)\b/i;
|
|
47
|
+
|
|
48
|
+
/** Split assistant prose into sentence-ish units without breaking `code`. */
|
|
49
|
+
export function sentences(text) {
|
|
50
|
+
const clean = text
|
|
51
|
+
.replace(/```[\s\S]*?```/g, ' ')
|
|
52
|
+
.replace(/\r/g, '');
|
|
53
|
+
const out = [];
|
|
54
|
+
for (const line of clean.split(/\n+/)) {
|
|
55
|
+
const parts = line.split(/(?<=[.!?])\s+(?=[A-Z`*✅✓])/);
|
|
56
|
+
for (const p of parts) {
|
|
57
|
+
const s = p.replace(/^[\s>*\-•#|]+/, '').replace(/\*\*/g, '').trim();
|
|
58
|
+
if (s.length >= 8) out.push(s);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Find claims in a piece of assistant text.
|
|
66
|
+
* @returns {{kind: ClaimKind, sentence: string, subject?: {from?: string, to?: string, pkg?: string, version?: string}}[]}
|
|
67
|
+
*/
|
|
68
|
+
export function detectClaims(text) {
|
|
69
|
+
const found = [];
|
|
70
|
+
for (const s of sentences(text)) {
|
|
71
|
+
for (const [kind, patterns] of Object.entries(KINDS)) {
|
|
72
|
+
const hit = patterns.map((re) => s.match(re)).find(Boolean);
|
|
73
|
+
if (!hit) continue;
|
|
74
|
+
// Look only at the words leading into the claim for hedges and negations,
|
|
75
|
+
// so "I fixed X, and all tests pass" counts but "make sure tests pass" doesn't.
|
|
76
|
+
const lead = s.slice(Math.max(0, hit.index - 60), hit.index);
|
|
77
|
+
const own = hit[0];
|
|
78
|
+
if (HEDGE.test(lead) || HEDGE.test(own)) continue;
|
|
79
|
+
if (NEGATION.test(lead.slice(-30)) || NEGATION.test(own)) continue;
|
|
80
|
+
if (/\?\s*$/.test(s)) continue;
|
|
81
|
+
// Quoting a claim ("the agent said “all tests pass”") isn't making one.
|
|
82
|
+
if (insideQuotes(s, hit.index)) continue;
|
|
83
|
+
found.push({ kind: /** @type {ClaimKind} */ (kind), sentence: s.slice(0, 280), subject: subjectOf(kind, s) });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return found;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function insideQuotes(s, at) {
|
|
90
|
+
const before = s.slice(0, at);
|
|
91
|
+
const straight = (before.match(/"/g) || []).length % 2 === 1;
|
|
92
|
+
const curly = before.lastIndexOf('“') > before.lastIndexOf('”');
|
|
93
|
+
return straight || curly;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function subjectOf(kind, s) {
|
|
97
|
+
if (kind === 'refactor') {
|
|
98
|
+
const r = s.match(/\brenamed\s+`([\w.$]+)`\s+(?:to|→|->)\s+`([\w.$]+)`/i) || s.match(/`([\w.$]+)`\s*(?:→|->)\s*`([\w.$]+)`/);
|
|
99
|
+
if (r) return { from: r[1].split('.').pop(), to: r[2].split('.').pop() };
|
|
100
|
+
const tick = s.match(/`([A-Za-z_$][\w$]{2,})`/);
|
|
101
|
+
return tick ? { from: tick[1] } : undefined;
|
|
102
|
+
}
|
|
103
|
+
if (kind === 'deps') {
|
|
104
|
+
const d = s.match(/\b(?:upgraded|bumped|updated|pinned)\s+`?(@?[\w./-]+)`?\s+(?:from\s+`?v?[\w.^~-]+`?\s+)?to\s+`?v?(\d+(?:\.\d+)*(?:-[\w.]+)?)`?/i);
|
|
105
|
+
return d ? { pkg: d[1], version: d[2] } : undefined;
|
|
106
|
+
}
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// "I implemented X", "fixed the bug in Y", "added support for Z". These aren't
|
|
111
|
+
// factual claims crossexam can verify, so they never get a verdict and never
|
|
112
|
+
// count in reliability stats. They only trigger a test-strength assessment.
|
|
113
|
+
const WORK = /\b(?:implemented|fixed|added|built|wrote|rewrote|refactored|resolved|handled|patched|corrected|introduced|completed)\b/i;
|
|
114
|
+
|
|
115
|
+
/** Sentences asserting that work was done (implemented / fixed / added). */
|
|
116
|
+
export function detectWorkClaims(text) {
|
|
117
|
+
const found = [];
|
|
118
|
+
for (const s of sentences(text)) {
|
|
119
|
+
const hit = s.match(WORK);
|
|
120
|
+
if (!hit) continue;
|
|
121
|
+
const lead = s.slice(Math.max(0, hit.index - 60), hit.index);
|
|
122
|
+
if (HEDGE.test(lead) || NEGATION.test(lead.slice(-30)) || /\?\s*$/.test(s) || insideQuotes(s, hit.index)) continue;
|
|
123
|
+
found.push({ sentence: s.slice(0, 280), verb: hit[0].toLowerCase() });
|
|
124
|
+
}
|
|
125
|
+
return found;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Rough task type from the user's prompt, used to bucket reliability history. */
|
|
129
|
+
export function taskTypeOf(prompt = '') {
|
|
130
|
+
const p = prompt.toLowerCase();
|
|
131
|
+
if (/\bmigrat/.test(p)) return 'migration';
|
|
132
|
+
if (/\b(refactor|rename|extract|clean ?up|restructure|move\s+\w+\s+to)\b/.test(p)) return 'refactor';
|
|
133
|
+
if (/\b(upgrade|bump|dependenc|update\s+\w+\s+to\s+v?\d)/.test(p)) return 'dependency';
|
|
134
|
+
if (/\b(cve|vulnerab|xss|injection|security|auth bypass)/.test(p)) return 'security';
|
|
135
|
+
if (/\b(test|spec|coverage)\b/.test(p)) return 'tests';
|
|
136
|
+
if (/\b(fix|bug|broken|error|crash|fails?|issue)\b/.test(p)) return 'bugfix';
|
|
137
|
+
return 'feature';
|
|
138
|
+
}
|
package/src/evidence.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { redact } from './redact.js';
|
|
1
2
|
// Evidence: which commands count as a check for which claim, and whether
|
|
2
3
|
// a given run passed, failed, or hid its own exit status.
|
|
3
4
|
|
|
@@ -121,7 +122,8 @@ export function excerpt(out = '', max = 420) {
|
|
|
121
122
|
const idx = lines.findIndex((l) => FAIL_SIGNALS.some((re) => re.test(l)));
|
|
122
123
|
const from = idx > 2 ? idx - 2 : 0;
|
|
123
124
|
const s = lines.slice(from, from + 10).join('\n');
|
|
124
|
-
|
|
125
|
+
// excerpts end up in reports, pr summaries and uploads: no secrets in them
|
|
126
|
+
return redact(s.length > max ? s.slice(0, max) + '…' : s);
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
function clip(s) {
|