Useful extras when relevant: security (injection, path traversal, secrets,
authz), perf (hot-path regressions, N+1, unbounded growth), concurrency.
export const meta = {
name: 'adversarial-review',
description: 'Adversarial review of the current change-set',
phases: [
{ title: 'Find', detail: 'read-only finders per dimension' },
{ title: 'Verify', detail: 'adversarial verification of each finding' },
],
}
const SCOPE = `<repo, change-set description, per-area context, READ ONLY:
do not modify files or run builds/tests. Cite file:line for every claim.>`
const FINDINGS = {
type: 'object', required: ['findings'],
properties: { findings: { type: 'array', items: {
type: 'object', required: ['title', 'file', 'severity', 'detail'],
properties: {
title: { type: 'string' },
file: { type: 'string', description: 'file:line' },
severity: { type: 'string', enum: ['critical', 'major', 'minor'] },
detail: { type: 'string', description: 'what is wrong, the concrete failure scenario, and the suggested fix' },
} } } },
}
const DIMENSIONS = [ ]
phase('Find')
const found = await pipeline(
DIMENSIONS,
(d) => agent(
`${SCOPE}\nYour dimension: ${d.prompt}\nReport at most 8 findings; only report things you are confident are real after reading the actual code (not the diff alone — open the files). No style nits.`,
{ label: `find:${d.key}`, phase: 'Find', schema: FINDINGS }),
(result, d) => parallel((result?.findings ?? []).map((f) => () =>
agent(
`${SCOPE}\nAdversarially verify this finding from a ${d.key} reviewer. Read the cited code and trace the actual behavior. Default to refuted unless the failure scenario is concretely reachable. Finding:\n${JSON.stringify(f, null, 1)}`,
{ label: `verify:${f.title.slice(0, 30)}`, phase: 'Verify', schema: {
type: 'object', required: ['real', 'reason'],
properties: { real: { type: 'boolean' }, reason: { type: 'string' }, fixHint: { type: 'string' } },
} }).then((v) => ({ ...f, dimension: d.key, verdict: v }))
))
)
const flat = found.filter(Boolean).flat().filter(Boolean)
const confirmed = flat.filter((f) => f.verdict?.real)
log(`${confirmed.length} confirmed, ${flat.length - confirmed.length} refuted`)
return {
confirmed,
refutedTitles: flat.filter((f) => f.verdict && !f.verdict.real).map((f) => f.title),
}