@bugb-technologies/bravos 1.3.0 → 1.4.1

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.
Files changed (42) hide show
  1. package/README.md +17 -10
  2. package/dist/ci.js +11 -3
  3. package/dist/cli.js +16 -6
  4. package/dist/doctor.js +2 -2
  5. package/dist/guide.js +2 -2
  6. package/dist/help.js +10 -14
  7. package/dist/install-proof-tool.js +117 -0
  8. package/dist/proof-tools.js +29 -0
  9. package/dist/report/check.js +4 -1
  10. package/dist/report/data.js +81 -149
  11. package/dist/report/markdown.js +1 -1
  12. package/dist/report/redact.js +16 -0
  13. package/dist/report/runs.js +169 -0
  14. package/dist/setup.js +43 -19
  15. package/dist/start/answers.js +5 -3
  16. package/dist/start/index.js +28 -14
  17. package/dist/versions.js +5 -4
  18. package/docs/GUIDE.md +2 -2
  19. package/hooks/lib/autopilot.mjs +155 -37
  20. package/hooks/lib/briefing.mjs +9 -3
  21. package/hooks/lib/nightly-stage.mjs +66 -0
  22. package/hooks/lib/nightly-tools.sh +45 -0
  23. package/hooks/lib/pre-pr.mjs +88 -17
  24. package/hooks/lib/proof-tool-pins.json +12 -0
  25. package/hooks/lib/replay.mjs +579 -0
  26. package/hooks/lib/setup.mjs +15 -6
  27. package/hooks/lib/snapshot.mjs +75 -9
  28. package/package.json +1 -1
  29. package/skills/bravos/SKILL.md +1 -1
  30. package/skills/bravos-annotate/SKILL.md +6 -5
  31. package/skills/bravos-annotate/scripts/slice.mjs +15 -8
  32. package/skills/bravos-cicd/SKILL.md +1 -1
  33. package/skills/bravos-env/SKILL.md +3 -3
  34. package/skills/bravos-prove/SKILL.md +11 -15
  35. package/skills/bravos-recheck/SKILL.md +3 -3
  36. package/skills/bravos-report/SKILL.md +1 -1
  37. package/skills/bravos-schedule/SKILL.md +1 -1
  38. package/skills/bravos-ship/SKILL.md +1 -1
  39. package/skills/bravos-templatize/SKILL.md +3 -3
  40. package/templates/workflows/bravos-nightly-claude.yml +131 -74
  41. package/templates/workflows/bravos-nightly-codex.yml +130 -73
  42. package/templates/workflows/bravos-pr-gate.yml +88 -14
package/dist/setup.js CHANGED
@@ -1,14 +1,16 @@
1
1
  // @comment -- "bravos setup: puts the binaries bravos drives onto this machine. The analyzer and the code graph are licensed bundles fetched through the account portal (artifacts.ts); guardlink and cxg are free CLIs installed with their own package managers. --check reports without changing anything, --dry-run says what would run, and nothing is fetched or installed without a licence for it. Also the SAST runner: `bravos sast run` invokes the staged analyzer with the argv the Python CLI used and writes the run folder the briefing and `bravos sast` read."
2
+ import { checkProofTool, formatProofTool } from './proof-tools.js';
2
3
  import { spawnSync } from 'node:child_process';
3
4
  import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
4
- import { join } from 'node:path';
5
+ import { isAbsolute, join } from 'node:path';
5
6
  import { bundleEnvironment, hostTarget, install, missingPaths, staged, VERSIONS } from './artifacts.js';
6
7
  import { graphBin, graphEnv } from './codegraph.js';
7
8
  import { whichBin } from './guardlink.js';
8
9
  import { findAnalyzer } from './graphbin.js';
9
10
  import { licenceLib, requireFeature } from './licence.js';
10
11
  import { BravosError } from './types.js';
11
- import { CXG_VERSION, GUARDLINK_VERSION } from './versions.js';
12
+ import { PROOF_TOOL_PINS } from './versions.js';
13
+ import { installProofTool, proofToolAction } from './install-proof-tool.js';
12
14
  // @comment -- "What is here and what setup would do, read-only: for each piece its path when present, the pinned version, whether the licence covers it, and the one action."
13
15
  export async function plan(env) {
14
16
  const L = await licenceLib();
@@ -19,18 +21,29 @@ export async function plan(env) {
19
21
  const items = [
20
22
  { id: 'analyzer', present: staged(env, 'analyzer') ?? findAnalyzer(env), wanted: VERSIONS.analyzer, licensed: sast, action: !t ? 'no build for this platform' : sast ? 'fetch, verify and stage the analyzer bundle' : 'on the Team plan: bravos account activate' },
21
23
  { id: 'codegraph', present: staged(env, 'codegraph') ?? graphBin('codegraph-build', env), wanted: VERSIONS.codegraph, licensed: graph, action: !t ? 'no build for this platform' : graph ? 'fetch, verify and stage codegraph-build and codegraph-mcp' : 'on the Team plan: bravos account activate' },
22
- { id: 'guardlink', present: whichBin('guardlink', env), wanted: GUARDLINK_VERSION, licensed: null, action: `npm install -g guardlink@${GUARDLINK_VERSION}` },
23
- { id: 'cxg', present: whichBin('cxg', env), wanted: CXG_VERSION, licensed: null, action: `cargo install cert-x-gen@${CXG_VERSION} --force && cxg pentest update` },
24
+ ...['guardlink', 'cxg'].map(id => ({
25
+ id, present: whichBin(id, env), wanted: PROOF_TOOL_PINS[id].revision ?? PROOF_TOOL_PINS[id].version,
26
+ licensed: null, action: proofToolAction(id), proofTool: checkProofTool(id, env),
27
+ })),
24
28
  ];
25
29
  return { items, licence: v };
26
30
  }
27
- export const formatPlan = (items) => items.map((i) => `${i.present ? '✔' : '✘'} ${i.id.padEnd(10)} ${i.present ? i.present : `absent — ${i.action}`}${i.present && i.licensed === false ? ' (licence does not cover it now)' : ''}`);
31
+ export const formatPlan = (items) => items.map(i => {
32
+ if (i.present && i.proofTool && i.proofTool.status !== 'ready') {
33
+ return '✘ ' + i.id.padEnd(10) + ' ' + i.present + ' (' + i.proofTool.status + ') — ' + i.action;
34
+ }
35
+ const status = i.present ? i.present : 'absent — ' + i.action;
36
+ return (i.present ? '✔ ' : '✘ ') + i.id.padEnd(10) + ' ' + status + (i.present && i.licensed === false ? ' (licence does not cover it now)' : '');
37
+ });
28
38
  // @comment -- "The setup itself. Default: the two licensed bundles for a licensed machine; --tools adds guardlink and cxg; --analyzer/--codegraph narrow it. Each licensed piece passes the gate before the first request. --dry-run prints the actions; -y is required for the package-manager installs because they run other people's installers."
29
39
  export async function runSetup(env, opts, io) {
30
40
  const lines = [];
31
41
  const { items } = await plan(env);
32
42
  if (opts.check) {
33
43
  lines.push(...formatPlan(items));
44
+ for (const item of items)
45
+ if (item.proofTool)
46
+ lines.push(formatProofTool(item.proofTool));
34
47
  return lines;
35
48
  }
36
49
  const pick = opts.analyzer || opts.codegraph || opts.tools ? { analyzer: !!opts.analyzer, codegraph: !!opts.codegraph, tools: !!opts.tools } : { analyzer: true, codegraph: true, tools: false };
@@ -53,23 +66,25 @@ export async function runSetup(env, opts, io) {
53
66
  lines.push(...selfTest(kind, r.dir, env));
54
67
  }
55
68
  if (pick.tools) {
56
- for (const i of items.filter((x) => x.id === 'guardlink' || x.id === 'cxg')) {
57
- if (i.present) {
58
- lines.push(`${i.id}: present at ${i.present}`);
69
+ for (const i of items) {
70
+ if (i.id !== 'guardlink' && i.id !== 'cxg')
71
+ continue;
72
+ const check = i.proofTool;
73
+ if (!check)
74
+ throw new BravosError(i.id + ': capability check is unavailable');
75
+ if (i.present && check.status === 'ready') {
76
+ lines.push(formatProofTool(check), i.id + ': already compatible at ' + i.present);
59
77
  continue;
60
78
  }
61
79
  if (opts.dryRun || !opts.yes) {
62
- lines.push(`${i.id}: absent — ${opts.dryRun ? 'would run' : 'run'} ${i.action}${opts.yes ? '' : ' (add -y to run it here)'}`);
80
+ const state = i.present ? check.status + ' at ' + i.present : 'absent';
81
+ lines.push(i.id + ': ' + state + ' — ' + i.action + (opts.yes ? '' : ' (add -y to run it here)'));
63
82
  continue;
64
83
  }
65
- lines.push(`${i.id}: running ${i.action}`);
66
- for (const cmd of i.action.split(' && ')) {
67
- const [bin, ...args] = cmd.split(' ');
68
- const r = spawnSync(bin, args, { env, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], timeout: 20 * 60 * 1000 });
69
- if (r.status !== 0)
70
- throw new BravosError(`${cmd} failed (exit ${r.status}): ${(r.stderr || r.stdout || '').trim().split('\n').slice(-3).join(' ')}`);
71
- }
72
- lines.push(`${i.id}: installed`);
84
+ const path = installProofTool(i.id, env, io.echo);
85
+ lines.push(i.id + ': installed and verified on PATH at ' + path);
86
+ if (i.id === 'cxg')
87
+ lines.push('Browser replay also needs the CXG Python requirements and Playwright Chromium for the selected Python environment.');
73
88
  }
74
89
  }
75
90
  return lines;
@@ -89,11 +104,16 @@ export function selfTest(kind, dir, env) {
89
104
  }
90
105
  // @comment -- "Runs the analyzer the way the Python adapter did: bravos-cli analyze ROOT --ci --fail-on never --allow-incomplete-analysis --codegraph <reuse when a graph store exists> --scip off -f json,sarif -o .bravos/sast/<run>/report, under the bundle's environment, then writes meta.json (sha, exit, at) so the briefing's SAST line and bravos sast candidates read it. The exit code is a health signal; findings are read from the report."
91
106
  export async function runSast(root, env, opts = {}) {
92
- await requireFeature(env, 'sast', 'bravos sast run');
107
+ const licence = await requireFeature(env, 'sast', 'bravos sast run');
93
108
  const dir = staged(env, 'analyzer');
94
109
  const bin = dir ? join(dir, 'bravos-cli') : findAnalyzer(env);
95
110
  if (!bin)
96
111
  throw new BravosError('bravos-cli is not installed: bravos setup --analyzer fetches it');
112
+ // @comment -- "The analyzer reads the threat model through whatever guardlink is on PATH, and installs its own pinned copy when there is none. Run it only with the GuardLink this bravos pins, so SAST and the rest of bravos read the model with one parser."
113
+ const gl = checkProofTool('guardlink', env);
114
+ if (gl.status !== 'ready') {
115
+ throw new BravosError(`bravos sast run needs the GuardLink this bravos pins (guardlink@${PROOF_TOOL_PINS.guardlink.version}) on PATH, and it is ${gl.status}. Run bravos setup --tools -y first; otherwise the analyzer would read the threat model with a different GuardLink.`);
116
+ }
97
117
  const base = join(root, '.bravos', 'sast');
98
118
  mkdirSync(base, { recursive: true });
99
119
  if (!existsSync(join(base, '.gitignore')))
@@ -116,7 +136,11 @@ export async function runSast(root, env, opts = {}) {
116
136
  return a;
117
137
  };
118
138
  // @comment -- "The analyzer reads the code graph from the same store bravos graph build writes to, so it runs with BRAVOS_CODEGRAPH_DIR set (graphEnv): without it, --codegraph reuse looks in the analyzer's own default store and finds no graph even when one was just built."
119
- const runEnv = dir ? bundleEnvironment(dir, graphEnv(env)) : graphEnv(env);
139
+ const baseEnv = graphEnv(env);
140
+ // @comment -- "The analyzer looks for its licence only in $BRAVOS_HOME or $BRAVOS_LICENCE, while bravos also falls back to ~/.bravos and ~/.bugb. Hand it the licence file bravos found (the path, never the token), so a SAST run never refuses a licence bravos accepted."
141
+ if (!env.BRAVOS_LICENCE && !env.BRAVOS_LICENSE && isAbsolute(licence.source) && existsSync(licence.source))
142
+ baseEnv.BRAVOS_LICENCE = licence.source;
143
+ const runEnv = dir ? bundleEnvironment(dir, baseEnv) : baseEnv;
120
144
  const spawn = (graph) => spawnSync(bin, argvFor(graph), { cwd: root, env: runEnv, encoding: 'utf8', timeout: (opts.timeoutS ?? 1800) * 1000, maxBuffer: 64 * 1024 * 1024, stdio: ['ignore', 'pipe', 'pipe'] });
121
145
  let r = spawn(codegraph);
122
146
  const notes = [];
@@ -6,7 +6,7 @@ export const PRESETS = {
6
6
  pr: { label: 'Map threats and check every pull request', hint: 'no AI key needed', pr: 'hook+github', autopilot: false, schedule: 'none', proving: 'ask' },
7
7
  everything: { label: 'Everything: annotations, PR checks and scheduled testing', hint: 'weekly nightly run, autopilot on', pr: 'hook+github', autopilot: true, schedule: 'weekly', proving: 'ask' },
8
8
  };
9
- /** Where the cost of one pentest is published; the continuous-pentest question links to it. */
9
+ /** Pricing for optional CXG model generation. */
10
10
  export const PENTEST_COST_URL = 'https://bugb.io/pricing#pentest-cost';
11
11
  /** The bravos init arguments these answers amount to (the review step prints them). */
12
12
  // @comment -- "The init flags for the chosen answers: agents, the pre-PR hook, autopilot, which workflows and the nightly cadence, and the loopback scope starter when testing is on"
@@ -36,16 +36,18 @@ export function nightlySecrets(a) {
36
36
  }
37
37
  // @comment -- "proving.md in the exact form the prove skill and the briefing read: choice, generation, the person's own words quoted, and confirmed by their name and the date. Setup records no target or start command: the agent finds how the app starts and where it listens (loopback only) when it tests, and writes them then."
38
38
  export function provingText(a, date) {
39
- const quoted = a.words.trim().replace(/\s+/g, ' ').replace(/"/g, "'");
40
39
  return [
41
40
  '# How findings are proven',
42
41
  '',
43
42
  'Recorded by `bravos start` from the answers below. Edit it, or run `bravos start --again`, to change it.',
44
43
  '',
45
44
  `choice: ${a.proving}`,
45
+ ...(a.proving === 'auto' ? [`kits: ${a.kitPolicy ?? 'reviewed'}`] : []),
46
46
  `generation: ${a.generation ? 'yes' : 'no'}`,
47
47
  '',
48
- `"${quoted}"`,
48
+ // Automatic tests need the one local app they may contact; the agent finds it (bravos-env) and a person merges it.
49
+ ...(a.proving === 'auto' ? ['Automatic tests start once a `target: http://localhost:<port>/` line naming your local app is added here and merged to the default branch (bravos-env does this with you).', ''] : []),
50
+ JSON.stringify(a.words.trim()),
49
51
  '',
50
52
  `— confirmed by ${a.name.trim()}, ${date}`,
51
53
  '',
@@ -70,7 +70,7 @@ async function flow(opts, d) {
70
70
  p.warn(`The old Python bravos at ${shadow} may run instead of this one. Rename it: mv ${shadow} ${shadow}-py`);
71
71
  }
72
72
  const has = (s, f) => !!s.lic?.unlocked.includes(f);
73
- const missingTools = (s) => (s.items ?? []).filter((i) => (i.id === 'guardlink' || i.id === 'cxg') && !i.present);
73
+ const missingTools = (s) => (s.items ?? []).filter((i) => (i.id === 'guardlink' || i.id === 'cxg') && (!i.present || (i.proofTool && i.proofTool.status !== 'ready')));
74
74
  const missingBundles = (s) => (s.items ?? []).filter((i) => (i.id === 'analyzer' || i.id === 'codegraph') && !i.present && i.licensed);
75
75
  const steps = [
76
76
  // theme
@@ -110,7 +110,11 @@ async function flow(opts, d) {
110
110
  // tools
111
111
  async (s) => {
112
112
  s.items = (await d.setupPlan()).items;
113
- p.note(s.items.map((i) => `${i.present ? '✔' : '✗'} ${i.id.padEnd(10)} ${i.present ? 'installed' : i.licensed === false ? 'Team plan' : `missing — ${i.action}`}`).join('\n'), 'Tools');
113
+ p.note(s.items.map((i) => {
114
+ if (i.present && i.proofTool && i.proofTool.status !== 'ready')
115
+ return `✗ ${i.id.padEnd(10)} ${i.present} needs a compatible build for ${i.proofTool.capability}`;
116
+ return `${i.present ? '✔' : '✗'} ${i.id.padEnd(10)} ${i.present ? 'installed' : i.licensed === false ? 'Team plan' : `missing — ${i.action}`}`;
117
+ }).join('\n'), 'Tools');
114
118
  const missing = [...missingTools(s), ...missingBundles(s)];
115
119
  s.installTools = false;
116
120
  if (!missing.length)
@@ -192,7 +196,7 @@ async function flow(opts, d) {
192
196
  s.autopilot = false;
193
197
  return;
194
198
  }
195
- s.autopilot = await p.confirm('autopilot', 'Turn on autopilot? At the end of each agent turn it sends the agent back once if changed code lacks annotations.', s.autopilot ?? saved?.autopilot ?? PRESETS[s.preset].autopilot);
199
+ s.autopilot = await p.confirm('autopilot', 'Review changed code at the end of each agent turn? Autopilot asks the agent to update relevant claims and follows your testing preference.', s.autopilot ?? saved?.autopilot ?? (s.preset === 'pr' && !opts.yes ? true : PRESETS[s.preset].autopilot));
196
200
  },
197
201
  // scheduled run (GitHub Actions)
198
202
  async (s) => {
@@ -202,7 +206,7 @@ async function flow(opts, d) {
202
206
  s.schedule = 'none';
203
207
  return;
204
208
  }
205
- p.info('A scheduled run has an agent annotate what changed, on GitHub. Claude Code signs in there with your Claude plan and GitHub Copilot uses your Copilot plan, like a session would; Codex needs an OpenAI API key. The PR check uses no AI.');
209
+ p.info('A scheduled run has an agent annotate the next slice on GitHub. The Claude Code and Codex workflows also support authorized probe replay. Claude Code signs in there with your Claude plan and GitHub Copilot uses your Copilot plan, like a session would; Codex needs an OpenAI API key. The PR check uses no AI.');
206
210
  s.schedule = await p.select('schedule', 'Run Bravos on a schedule in GitHub Actions?', [
207
211
  { value: 'none', label: 'No schedule', hint: 'no sign-in needed' },
208
212
  { value: 'weekly', label: 'Once a week', hint: 'Sunday night; the cheapest', recommended: true },
@@ -229,22 +233,27 @@ async function flow(opts, d) {
229
233
  }
230
234
  const choices = [
231
235
  { value: 'ask', label: 'Ask me every time before testing', recommended: true },
232
- { value: 'auto', label: 'Test my local app automatically', hint: 'localhost only' },
233
- ...(s.schedule !== 'none' ? [{ value: 'schedule', label: 'Only in the scheduled run' }] : []),
236
+ { value: 'auto', label: 'Test my local app as I build', hint: 'includes scoped tests written by this agent' },
237
+ { value: 'auto-reviewed', label: 'Automatically replay reviewed kits only', hint: 'uses the tested kit version on the default branch' },
238
+ ...(s.schedule !== 'none' && s.nightlyAgent !== 'copilot' ? [{ value: 'schedule', label: 'Only in the scheduled run' }] : []),
234
239
  { value: 'none', label: 'Never test, just annotate' },
235
240
  ];
236
241
  p.info('Bravos only tests apps you own, on localhost; your agent finds how to start the app when it tests. Anything else needs a reviewed scope file and your own typed authorization at that time; setup never fills that in.');
237
- const want = s.proving ?? saved?.proving ?? PRESETS[s.preset].proving;
238
- s.proving = await p.select('proving', 'How should Bravos handle testing?', choices, choices.some((c) => c.value === want) ? want : 'ask');
242
+ const previous = s.proving ?? saved?.proving ?? PRESETS[s.preset].proving;
243
+ const previousKits = s.kitPolicy ?? saved?.kitPolicy ?? (saved?.generation === false ? 'reviewed' : 'session');
244
+ const want = previous === 'auto' && previousKits === 'reviewed' ? 'auto-reviewed' : previous;
245
+ const choice = await p.select('proving', 'How should Bravos handle testing?', choices, choices.some((c) => c.value === want) ? want : 'ask');
246
+ s.proving = choice === 'auto-reviewed' ? 'auto' : choice;
247
+ s.kitPolicy = choice === 'auto-reviewed' ? 'reviewed' : 'session';
239
248
  },
240
- // continuous pentest (model-written tests; spends credits)
249
+ // Optional external generation is separate from replaying harness-authored tests.
241
250
  async (s) => {
242
251
  if (s.proving === 'none') {
243
252
  s.generation = false;
244
253
  return;
245
254
  }
246
- p.info(`This will cost additional credits: an AI model writes new tests for new code as you build. What one pentest costs: ${PENTEST_COST_URL}`);
247
- s.generation = await p.confirm('generation', 'May Bravos continuously pentest your application as you build it?', s.generation ?? saved?.generation ?? false, { yes: 'Yes, keep testing as I build', no: 'No, only replay tests I approved', recommend: false });
255
+ p.info(`Your coding agent can write tests in this session. Optional CXG model generation spends additional credits. See ${PENTEST_COST_URL}`);
256
+ s.generation = await p.confirm('generation', 'Allow CXG to generate additional probes through a paid model API?', s.generation ?? saved?.generation ?? false, { yes: 'Allow model API spend', no: 'Use the current agent and supplied tests', recommend: false });
248
257
  },
249
258
  // the person's own words
250
259
  async (s) => {
@@ -333,7 +342,7 @@ async function flow(opts, d) {
333
342
  ...(answers.schedule !== 'none' ? [` + .github/workflows/bravos-nightly-${answers.nightlyAgent}.yml (${answers.schedule}, cron ${CRON[answers.schedule]} UTC)`] : []),
334
343
  ...(answers.schedule !== 'none' && answers.nightlyAgent === 'copilot' ? [' + .github/workflows/copilot-setup-steps.yml (prepares Copilot\'s session: Node and guardlink)'] : []),
335
344
  ...(answers.proving !== 'none' ? [' + .guardlink/scope.yaml (localhost only; authorization left for you)'] : []),
336
- ...(answers.name ? [` + .guardlink/proving.md (${answers.proving}${answers.generation ? ', continuous pentest' : ''}, confirmed by ${answers.name})`] : []),
345
+ ...(answers.name ? [` + .guardlink/proving.md (${answers.proving}${answers.generation ? ', model API generation allowed' : ''}, confirmed by ${answers.name})`] : []),
337
346
  ...(Object.keys(s.secrets).length ? [` + GitHub secrets: ${Object.keys(s.secrets).join(', ')}`] : []),
338
347
  ' + .bravos/setup.json (your answers, for bravos start --again)',
339
348
  ...(has(s, 'codegraph') ? ['Then: build the code graph for this repository'] : []),
@@ -382,6 +391,7 @@ function toAnswers(s) {
382
391
  schedule: s.schedule ?? 'none',
383
392
  nightlyAgent: s.nightlyAgent ?? 'claude',
384
393
  proving: s.proving ?? 'none',
394
+ ...(s.proving === 'auto' ? { kitPolicy: s.kitPolicy } : {}),
385
395
  generation: !!s.generation,
386
396
  words: s.proving === 'auto' || s.proving === 'schedule' ? (s.words ?? '') : '',
387
397
  name: s.name ?? '',
@@ -395,6 +405,10 @@ async function apply(answers, s, d, opts, has) {
395
405
  const r = await p.spin('Installing guardlink and cxg', () => d.bravos(['setup', '--tools', '-y']), (r) => (r.code ? { fail: 'Installing guardlink and cxg — failed' } : 'Installed guardlink and cxg'));
396
406
  for (const l of [...r.out, ...r.err])
397
407
  (r.code ? p.warn : p.info)(l);
408
+ // A tool that would not install (no cargo, offline, an incompatible build) limits proving, not the
409
+ // rest of setup: carry on, and say what still needs doing instead of leaving the repo unset.
410
+ if (r.code)
411
+ p.warn('Carrying on without them: annotation and the briefing work now; proving needs guardlink and cxg. Fix the line above, then run bravos setup --tools.');
398
412
  }
399
413
  if (answers.installTools && has.missingBundles) {
400
414
  const r = await p.spin('Fetching the Bravos analyzer and code graph', () => d.bravos(['setup']), (r) => (r.code ? { fail: 'Fetching the analyzer and code graph — failed' } : 'Fetched the analyzer and code graph'));
@@ -438,9 +452,9 @@ async function apply(answers, s, d, opts, has) {
438
452
  `Open ${tool} in ${tildify(repo, d.env.HOME)} and type:`,
439
453
  '',
440
454
  ` ${handoff} learns what the app is for (asks you a few questions)`,
441
- ` ${sigil(lead)}bravos-annotate maps the threats in your code, then runs the first SAST scan over them`,
455
+ ` ${sigil(lead)}bravos-annotate maps the threats in your code`,
442
456
  '',
443
- 'SAST waits for that first annotation on purpose: it reads the threat model to know what matters.',
457
+ 'Autopilot can review later changes in your agent. Live testing follows the preference and target you authorized.',
444
458
  copied ? `(${handoff} is on your clipboard.) The Bravos banner shows the next step each time you open a session.` : 'The Bravos banner shows the next step each time you open a session.',
445
459
  'Follow along in a second terminal: bravos watch',
446
460
  ].join('\n'), 'One step left, in your agent');
package/dist/versions.js CHANGED
@@ -1,8 +1,9 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { hooksDir } from './paths.js';
1
4
  // @comment -- "The versions of the two binary bundles this CLI installs. Pinned here, not read from the network: a bravos release names the analyzer and code-graph builds it was tested with, and bravos setup fetches exactly those."
2
5
  /** The licensed analyzer bundle (bravos-cli plus gitleaks, osv-scanner, kics, zizmor and the rules), published by specter-v1's analyzer-release workflow. */
3
- export const ANALYZER_VERSION = '0.6.1';
6
+ export const ANALYZER_VERSION = '0.6.2';
4
7
  /** The code graph binaries (codegraph-build, codegraph-mcp), published by specter-v1's codegraph-release workflow. */
5
8
  export const CODEGRAPH_VERSION = '0.1.0';
6
- /** Pins for the two free CLIs bravos setup --tools installs. */
7
- export const GUARDLINK_VERSION = '2.5.0';
8
- export const CXG_VERSION = '1.7.0';
9
+ export const PROOF_TOOL_PINS = JSON.parse(readFileSync(join(hooksDir(), 'lib', 'proof-tool-pins.json'), 'utf8'));
package/docs/GUIDE.md CHANGED
@@ -44,7 +44,7 @@ Keep bravos watch running in a second terminal pane beside your agent (free, rea
44
44
 
45
45
  ### Hands-off: autopilot
46
46
 
47
- bravos init --autopilot (or sync --autopilot) makes upkeep happen without anyone asking. At the end of each turn a check sends the agent back once if the changes left code with no annotation, touched code under a confirmed or stale claim, or put open exposures on changed files. The pre-PR gate runs on every gh pr create.
47
+ bravos init --autopilot (or sync --autopilot) makes upkeep happen without anyone asking. At turn end the agent reviews changed code, including edits inside annotated files. It follows the recorded proving preference for affected claims. The pre-PR gate runs on every gh pr create.
48
48
 
49
49
  Proving follows your choice, not a fixed rule: the first time it comes up the agent asks you once — prove automatically on your loopback target, ask each time, on a schedule, or not now — and records your words in .guardlink/proving.md. Say "ask me first" or "stop auto-proving" at any time to change it. Non-loopback targets still need a reviewed scope and your typed authorization every time.
50
50
 
@@ -84,7 +84,7 @@ Run bravos first: it reads the briefing, explains the loop in five lines and rou
84
84
 
85
85
  Skills: `/bravos-cicd` · `/bravos-schedule`
86
86
 
87
- bravos init --ci writes the PR gate and nightly workflows. bravos-cicd audits existing workflows: broken guardlink calls, script injection from pull-request text, missing SARIF upload. The nightly can replay retest kits only against a target the committed, reviewed scope authorizes.
87
+ bravos init --ci writes the PR gate and nightly workflows. bravos-cicd audits existing workflows: broken guardlink calls, script injection from pull-request text, missing SARIF upload. The Claude and Codex nightlies can replay committed, bound kits when scheduled testing is authorized. The Copilot job assigns an annotation task.
88
88
 
89
89
  ## What to do, by task
90
90
 
@@ -1,13 +1,14 @@
1
- // @comment -- "bravos autopilot's end-of-turn check (Claude Code and Codex Stop hooks): from the working-tree changes since HEAD it finds changed files with no GuardLink annotation, confirmed or stale claims on changed files, and open exposures on changed files, using only the two fast guardlink calls (unannotated and ci, run concurrently; lint and diff are left to the pre-PR gate because they take a minute on a large repo), and returns block with a short reason naming the skill to run, or allow. A nudge, not a gate: a missing tool, a timeout or bad input allows. Each finding is raised once per session (its key is looked up in the harness's transcript, which bravos only reads). Read-only: argv spawns, no shell."
1
+ // @comment -- "bravos autopilot's end-of-turn check (Claude Code and Codex Stop hooks): reads session changes, the annotation worklist, current model and tested states; reports changes to review and affected claim keys, scoped to code and sidecar locations, and returns block with a short reason naming the skill to run, or allow. A nudge, not a gate: a missing tool, a timeout or bad input allows. Each finding is raised once per session, per file or claim rather than per edit (its key is looked up in the harness's transcript, which bravos only reads), and the guardlink calls share one time budget under the hook's 30 s limit. Read-only: argv spawns, no shell."
2
2
  import { createHash } from 'node:crypto';
3
3
  import { appendFileSync, existsSync, mkdirSync, openSync, readFileSync, readSync, closeSync, fstatSync, writeFileSync } from 'node:fs';
4
4
  import { join } from 'node:path';
5
5
  import { gitStaleness, staleness } from './resync.mjs';
6
- import { asyncRunner, fingerprint, readSnapshot, workingChanges } from './snapshot.mjs';
6
+ import { asyncRunner, changedHunks, fingerprint, readSnapshot, workingChanges } from './snapshot.mjs';
7
7
 
8
8
  export { asyncRunner, readSnapshot, safeSessionId, takeSnapshot } from './snapshot.mjs';
9
9
 
10
- export const AUTOPILOT_DEADLINE_MS = 20000;
10
+ // One budget for the whole check, under the harness's 30 s hook limit.
11
+ export const AUTOPILOT_DEADLINE_MS = 24000;
11
12
  const TRANSCRIPT_TAIL = 4 * 1024 * 1024;
12
13
  const MAX_LIST = 5;
13
14
 
@@ -58,14 +59,18 @@ export async function changedFiles(root, env, run, snapshot = null) {
58
59
  const now = await workingChanges(root, env, run);
59
60
  const out = new Set();
60
61
  if (snapshot) {
61
- for (const rel of now) if (snapshot.files[rel] === undefined || snapshot.files[rel] !== fingerprint(root, rel)) out.add(rel);
62
- const committed = await run('git', ['diff', '--name-only', `${snapshot.head}..HEAD`], { cwd: root, env });
63
- if (committed.status === 0) for (const l of committed.stdout.split('\n')) if (l.trim()) out.add(l.trim());
62
+ for (const rel of now) if (!Object.hasOwn(snapshot.files, rel) || snapshot.files[rel] !== fingerprint(root, rel)) out.add(rel);
63
+ // Also catch a previously dirty file restored to HEAD during the session.
64
+ for (const path of Object.keys(snapshot.files)) if (!now.has(path) && snapshot.files[path] !== fingerprint(root, path)) out.add(path);
65
+ const committed = await run('git', ['diff', '--name-only', `${snapshot.head}..HEAD`, '-z', '--no-renames', '--'], { cwd: root, env });
66
+ if (committed.status === 0) for (const path of committed.stdout.split('\0')) if (path) out.add(path);
64
67
  } else {
65
68
  for (const rel of now) out.add(rel);
66
69
  }
67
70
  const locked = lockedFiles(root);
68
- for (const rel of [...out]) if (isGenerated(rel, locked)) out.delete(rel);
71
+ // Shared agent settings also carry operator-authored permissions and hooks; review
72
+ // those through GuardLink's config model instead of treating them as source.
73
+ for (const rel of [...out]) if (rel.startsWith('.bravos/') || locked.has(rel)) out.delete(rel);
69
74
  return out;
70
75
  }
71
76
 
@@ -88,15 +93,43 @@ function transcriptTail(path) {
88
93
  }
89
94
  }
90
95
 
91
- const listOf = (all) => { const xs = [...new Set(all)]; return xs.slice(0, MAX_LIST).join(', ') + (xs.length > MAX_LIST ? ` and ${xs.length - MAX_LIST} more` : ''); };
92
96
  const fileOf = (c) => c?.location?.file ?? c?.file;
93
97
 
98
+ function proofInstruction(pref, retest) {
99
+ const skill = retest ? 'bravos-recheck' : 'bravos-prove';
100
+ if (pref.status !== 'set') return 'ask the person once how they want findings proven (bravos-prove); retain these claim keys for that decision';
101
+ if (pref.choice === 'ask') return `ask the person before testing with ${skill}`;
102
+ if (pref.choice === 'schedule') return 'leave the keys for the authorized scheduled run and report that they await testing';
103
+ if (pref.choice === 'none') return 'report the outstanding claims; the person chose not to run tests';
104
+ return `use bravos-templatize for missing kits and ${skill} on ${pref.target ?? 'the recorded loopback target'} under the recorded scope and generation choice`;
105
+ }
106
+
107
+ // @comment -- "GuardLink hypothesis list names the authored row (a .gal line in external mode). Join the exact authored line, asset and threat to parse's current exposure or confirmation to get its logical source span. Never identify an individual claim by threat and file alone."
108
+ function authoredKey(file, line, asset, threat) {
109
+ return JSON.stringify([file, line, asset, threat]);
110
+ }
111
+
112
+ function overlaps(hunks, file, start, end = start) {
113
+ if (!hunks.has(file)) return true; // Untracked file, binary, or no patch available: review the file.
114
+ if (!Number.isInteger(start) || !Number.isInteger(end)) return hunks.get(file).length > 0;
115
+ return hunks.get(file).some(h => h.start <= end && start <= h.end);
116
+ }
117
+
118
+ function touches(location, changed, hunks) {
119
+ if (!location) return false;
120
+ if (changed.has(location.origin_file) && overlaps(hunks, location.origin_file, location.origin_line)) return true;
121
+ if (!changed.has(location.file)) return false;
122
+ const anchor = location.anchor;
123
+ return overlaps(hunks, location.file, anchor?.start_line ?? location.line, anchor?.end_line ?? location.line);
124
+ }
125
+
94
126
  /**
95
127
  * Runs the end-of-turn check. `payload` is the Stop hook's stdin (stop_hook_active, transcript_path).
96
128
  * Returns { decision: 'allow' } or { decision: 'block', reason }.
97
129
  */
98
130
  // @comment -- "Decides the Stop hook's answer: allow when autopilot is off, the turn was already continued by a Stop hook, guardlink is absent, nothing changed or nothing new is found; otherwise block once with one line per finding and the skill that handles it, and for new exposures the next step the recorded proving preference implies."
99
131
  export async function runAutopilot({ root, env = process.env, payload = {}, run = asyncRunner, deadlineMs = AUTOPILOT_DEADLINE_MS }) {
132
+ const started = Date.now();
100
133
  if (env.BRAVOS_AUTOPILOT === 'off') return { decision: 'allow' };
101
134
  if (payload?.stop_hook_active === true) return { decision: 'allow' };
102
135
  if (!existsSync(join(root, '.guardlink'))) return { decision: 'allow' };
@@ -113,12 +146,25 @@ export async function runAutopilot({ root, env = process.env, payload = {}, run
113
146
  const branch = branchRef && branchRef !== 'HEAD' ? branchRef : null;
114
147
  const behind = staleness({ ...(await gitStaleness(git, base)), branch, base });
115
148
 
116
- // The two fast guardlink calls, side by side; a missing guardlink or a timeout reads as nothing found.
117
- const [wl, ci] = await Promise.all([json(run, ['unannotated', '--json'], o), json(run, ['ci', '-f', 'json'], o)]);
149
+ // The hook runs under a 30 s harness limit: the guardlink calls share what is left of one budget, not 20 s each.
150
+ const left = Math.max(2000, deadlineMs - (Date.now() - started));
151
+ const og = { ...o, timeoutMs: left };
152
+ const [wl, ci, ledger, model, patch] = await Promise.all([
153
+ json(run, ['unannotated', '--json'], og), json(run, ['ci', '-f', 'json'], og),
154
+ json(run, ['hypothesis', 'list', '--json'], og), json(run, ['parse', '.', '--no-pretty'], og),
155
+ changedHunks(root, env, run, snapshot?.head ?? 'HEAD', left),
156
+ ]);
157
+ const hunks = new Map();
158
+ for (const path of changed) {
159
+ if (!patch.has(path)) continue;
160
+ const baseline = snapshot?.hunks?.[path];
161
+ const prior = new Set(Array.isArray(baseline) ? baseline : []);
162
+ hunks.set(path, patch.get(path).filter(h => !prior.has(h.hash)));
163
+ }
118
164
 
119
165
  const findings = [];
120
- // A short, stable key per finding: the same finding is raised once per session, a changed one again.
121
- const add = (key, line) => findings.push({ key: `[bravos-autopilot:${key.split(':')[0]}:${createHash('sha256').update(key).digest('hex').slice(0, 10)}]`, line });
166
+ const add = (key, line) => findings.push({ key: `[bravos-autopilot:${key.split(':')[0]}:${createHash('sha256').update(key).digest('hex').slice(0, 12)}]`, line });
167
+ const changedSource = path => changed.has(path) && (!hunks.has(path) || hunks.get(path).length > 0);
122
168
 
123
169
  if (behind) {
124
170
  add(`behind:${base}:${behind.behind}`, `this checkout is ${behind.behind} commits behind ${base}${behind.baseDate ? ` (shared base ${behind.baseDate})` : ''}, so its threat model describes older code${snapshot ? '' : ' and the changes here may predate this session'}: update the branch, or carry its annotation work to ${base} with bravos-resync, before annotating or proving here.`);
@@ -126,33 +172,93 @@ export async function runAutopilot({ root, env = process.env, payload = {}, run
126
172
  if (!snapshot) return finish(findings, payload);
127
173
  }
128
174
 
129
- const worklist = arr(wl?.worklist).map((w) => (typeof w === 'string' ? w : w?.file ?? w?.path)).filter((f) => changed.has(f));
130
- if (worklist.length) add(`unannotated:${worklist.sort().join(',')}`, `${worklist.length} changed file(s) have no GuardLink annotation (${listOf(worklist)}): annotate the security-relevant code in them with bravos-annotate, or say why none is needed.`);
175
+ const configFiles = new Set(arr(model?.agent_config?.files).map(f => f.path));
176
+ for (const path of changed) {
177
+ if (changedSource(path) && (configFiles.has(path) || (GENERATED_FILES.has(path) && hunks.has(path)))) {
178
+ add('config:' + path, 'Review changed coding-agent capabilities in ' + path + ' with bravos-annotate and GuardLink’s unentitled coding-agent reach lookup. Check the capability, affected asset and approval before proposing an entitlement.');
179
+ }
180
+ }
181
+ const paths = rows => arr(rows).map(w => typeof w === 'string' ? w : w?.file ?? w?.path)
182
+ .filter(path => changedSource(path) && !isGenerated(path) && !configFiles.has(path));
183
+ for (const path of paths(wl?.worklist)) {
184
+ add(`unannotated:${path}`, `${path} has no GuardLink annotation: review the change with bravos-annotate; record any security-relevant behavior.`);
185
+ }
186
+ for (const path of paths(wl?.annotated)) {
187
+ const ranges = hunks.get(path)?.map(h => h.start === h.end ? h.start : `${h.start}-${h.end}`).join(', ');
188
+ add(`review:${path}`, `review changed code in ${path}${ranges ? ` (lines ${ranges})` : ''} with bravos-annotate. Check new behavior and guards even when another symbol in this file already has an annotation.`);
189
+ }
190
+
191
+ const excluded = new Set(arr(wl?.excluded).map(e => e?.path ?? e?.file));
192
+ for (const path of changed) {
193
+ if (path.endsWith('.gal') && changedSource(path)) {
194
+ add('sidecar:' + path, 'Review changed claims in ' + path + ' with bravos-annotate. Read the logical source named by each affected block; reconcile retired claims and their replay kits.');
195
+ } else if (hunks.get(path)?.some(h => h.deleted) && !excluded.has(path) && !/\.(?:md|txt|rst)$/i.test(path)) {
196
+ add('removed:' + path, 'Review the deletion or move of ' + path + ' with bravos-annotate. Check its previous guards, current callers and any sidecars that still describe it.');
197
+ }
198
+ }
131
199
 
132
- const confirmed = arr(ci?.confirmed).filter((c) => changed.has(fileOf(c)));
133
- if (confirmed.length) {
134
- const ids = confirmed.map((c) => `${c.threat ?? '?'} at ${fileOf(c)}:${c?.location?.line ?? c?.line ?? '?'}`);
135
- add(`recheck:${ids.sort().join(',')}`, `you changed code under a confirmed exploit (${listOf(ids)}): run bravos-recheck to see whether the change fixed it, before finishing.`);
200
+ // ci.stale gives logical file/line, but not the whole source span. Use the
201
+ // parse location so a stale claim in an untouched sibling is not requeued.
202
+ const staleLocations = new Map();
203
+ for (const [verb, rows] of Object.entries({ exposes: model?.exposures, mitigates: model?.mitigations, boundary: model?.boundaries, flows: model?.flows, confirmed: model?.confirmed })) {
204
+ for (const { location } of arr(rows)) {
205
+ if (!location) continue;
206
+ const key = JSON.stringify([verb, location.file, location.line]);
207
+ if (!staleLocations.has(key)) staleLocations.set(key, []);
208
+ staleLocations.get(key).push(location);
209
+ }
136
210
  }
137
- const stale = arr(ci?.stale).filter((c) => changed.has(fileOf(c)));
138
- if (stale.length) {
139
- const ids = stale.map((c) => `${fileOf(c)}:${c?.line ?? c?.location?.line ?? '?'}`);
140
- add(`stale:${ids.sort().join(',')}`, `${stale.length} claim(s) went stale in files you changed (${listOf(ids)}): re-read and re-verify them with bravos-recheck.`);
211
+ for (const c of arr(ci?.stale)) {
212
+ const file = fileOf(c);
213
+ const locations = staleLocations.get(JSON.stringify([c.verb, file, c.line]));
214
+ if (locations ? !locations.some(l => touches(l, changed, hunks)) : !changedSource(file)) continue;
215
+ add('stale:' + (c.key ?? authoredKey(file, c.line)), (c.verb ?? 'guard') + ' claim at ' + file + ':' + (c.line ?? c.location?.line ?? '?') + ' went stale: re-read and re-verify it with bravos-recheck.');
141
216
  }
142
217
 
143
- // Open exposures on the files this turn changed: what a proving decision is about.
144
- const confirmedKeys = new Set(confirmed.map((c) => `${c.threat}|${fileOf(c)}`));
145
- const open = arr(ci?.exposures).filter((e) => changed.has(fileOf(e)) && !confirmedKeys.has(`${e.threat}|${fileOf(e)}`));
146
- if (open.length) {
147
- const ids = open.map((e) => `${e?.threat ?? '?'} on ${e?.asset ?? '?'}`);
148
- const p = readProving(root);
149
- let next;
150
- if (p.status !== 'set') next = 'ask the person once how they want findings proven (automatically on their loopback target, each time you ask, on a schedule, or not now), and record their answer with bravos-prove';
151
- else if (p.choice === 'auto') next = `prove the untested ones with bravos-prove on ${p.target ?? 'the recorded loopback target'}, as .guardlink/proving.md records (${p.by}, ${p.date})`;
152
- else if (p.choice === 'ask') next = 'ask the person whether to prove them now (bravos-prove), as .guardlink/proving.md asks';
153
- else if (p.choice === 'schedule') next = 'leave them for the scheduled run .guardlink/proving.md names, and say so';
154
- else next = 'note them for the person; .guardlink/proving.md says not to prove for now';
155
- add(`prove:${ids.sort().join(',')}`, `${open.length} open exposure(s) sit on files this turn changed (${listOf(ids)}): ${next}.`);
218
+ const byAuthored = new Map();
219
+ for (const entry of [...arr(model?.exposures), ...arr(model?.confirmed)]) {
220
+ const loc = entry.location;
221
+ if (!loc) continue;
222
+ byAuthored.set(authoredKey(loc.origin_file ?? loc.file, loc.origin_line ?? loc.line, entry.asset, entry.threat), loc);
223
+ }
224
+ const controls = new Map();
225
+ for (const m of arr(model?.mitigations)) {
226
+ if (!touches(m.location, changed, hunks)) continue;
227
+ const pair = JSON.stringify([m.asset, m.threat]);
228
+ if (!controls.has(pair)) controls.set(pair, []);
229
+ controls.get(pair).push(m.location);
230
+ }
231
+ const pref = readProving(root);
232
+ if (ledger?.ledger === 'corrupt') {
233
+ add('ledger:corrupt', 'GuardLink could not read the hypothesis ledger. Restore its evidence before treating any claim as untested or running a retest.');
234
+ } else if (Array.isArray(ledger?.records)) {
235
+ if (!Array.isArray(model?.exposures) && ledger.records.some(r => !r.location && r.file?.endsWith('.gal'))) {
236
+ add('ledger:locations', 'GuardLink source locations are unavailable for sidecar claims. Read their source blocks before selecting tests; the set of affected claims is unknown.');
237
+ }
238
+ for (const record of ledger.records) {
239
+ if (!record?.key) continue;
240
+ const loc = record.location ?? byAuthored.get(authoredKey(record.file, record.line, record.asset, record.threat));
241
+ if (!loc) {
242
+ if (changed.has(record.file)) add('unresolved:' + record.key, 'Resolve the logical source location for claim ' + record.key + ' in ' + record.file + ' before choosing a kit.');
243
+ continue;
244
+ }
245
+ const affectedControls = controls.get(JSON.stringify([record.asset, record.threat])) ?? [];
246
+ if (!touches(loc, changed, hunks) && !affectedControls.length) continue;
247
+ // A current refutation holds until its anchor or a separate control changes.
248
+ if (record.state === 'refuted' && !affectedControls.length) continue;
249
+ const retest = record.state === 'retest' || record.state === 'confirmed' || record.expired || record.state === 'refuted';
250
+ add(`proof:${record.key}:${record.state}`, `${retest ? 'Retest' : 'Untested'} ${record.threat} on ${record.asset} at ${loc.file}:${loc.line} (claim ${record.key}): ${proofInstruction(pref, retest)}.`);
251
+ }
252
+ } else {
253
+ // A legacy/unavailable ledger cannot report coverage of mitigated claims.
254
+ for (const c of arr(ci?.confirmed).filter(c => changedSource(fileOf(c)))) {
255
+ const file = fileOf(c);
256
+ add(`recheck:${authoredKey(file, c.location?.line, c.asset, c.threat)}`, `confirmed ${c.threat} at ${file}:${c.location?.line ?? '?'}: review with bravos-recheck; ${proofInstruction(pref, true)}.`);
257
+ }
258
+ for (const e of arr(ci?.exposures).filter(c => changedSource(fileOf(c)))) {
259
+ const file = fileOf(e);
260
+ add(`prove:${authoredKey(file, e.location?.line, e.asset, e.threat)}`, `open exposure ${e.threat} on ${e.asset} in ${file}: ${proofInstruction(pref, false)}. The hypothesis ledger was unavailable; tested state is unknown.`);
261
+ }
156
262
  }
157
263
 
158
264
  return finish(findings, payload);
@@ -164,10 +270,22 @@ function finish(findings, payload) {
164
270
  const seen = transcriptTail(payload?.transcript_path);
165
271
  const fresh2 = findings.filter((f) => !seen.includes(f.key));
166
272
  if (fresh2.length === 0) return { decision: 'allow' };
273
+ // Keep large changes readable while preserving one deduplication key per distinct finding.
274
+ const groups = new Map();
275
+ for (const f of fresh2) {
276
+ const kind = f.key.split(':')[1];
277
+ if (!groups.has(kind)) groups.set(kind, []);
278
+ groups.get(kind).push(f);
279
+ }
280
+ const lines = [];
281
+ for (const [kind, group] of groups) {
282
+ for (const item of group.slice(0, MAX_LIST)) lines.push('- ' + item.line);
283
+ if (group.length > MAX_LIST) lines.push('- ' + (group.length - MAX_LIST) + ' more ' + kind + ' items: inspect the rest with the changed-file diff and guardlink hypothesis list --json.');
284
+ }
167
285
  const reason = [
168
286
  'bravos autopilot, before you finish:',
169
- ...fresh2.map((f) => `- ${f.line}`),
170
- 'If something here does not apply, say why in one line and finish.',
287
+ ...lines,
288
+ 'Finish quietly when the review finds no security change. Surface a finding, an untested claim that needs attention, or a decision the person must make.',
171
289
  fresh2.map((f) => f.key).join(' '),
172
290
  ].join('\n');
173
291
  const summary = `sent the agent back once: ${fresh2[0].line}${fresh2.length > 1 ? ` (+${fresh2.length - 1} more)` : ''}`;