@bugb-technologies/bravos 1.12.0 → 1.12.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.
package/dist/doctor.js CHANGED
@@ -9,6 +9,7 @@ import { skillsRoot } from './skills.js';
9
9
  import { resolveTheme } from './palette.js';
10
10
  import { pathToFileURL } from 'node:url';
11
11
  import { hooksDir, version as packageVersion } from './paths.js';
12
+ import { cargoPathFix, findTool } from './tool-path.js';
12
13
  const TOOLS = [
13
14
  { name: 'guardlink', hint: 'bravos setup --tools -y installs a compatible GuardLink' },
14
15
  { name: 'cxg', hint: 'bravos setup --tools -y installs a compatible CXG' },
@@ -44,6 +45,13 @@ function guardlinkSkills(root, harness) {
44
45
  export function runDoctor(root, env = process.env) {
45
46
  const tools = TOOLS.map(({ name, hint }) => {
46
47
  // codegraph-mcp and bravos-cli also count when they sit inside the bravos install (bravos uses them from there).
48
+ // guardlink and cxg also count when they sit outside PATH (cxg in cargo's folder): Bravos runs them by full path and says how to fix PATH.
49
+ if (name === 'guardlink' || name === 'cxg') {
50
+ const t = findTool(name, env);
51
+ if (!t)
52
+ return { name, found: false, hint };
53
+ return t.onPath ? { name, found: true, path: t.path, hint, onPath: true } : { name, found: true, path: t.path, hint, onPath: false, fix: cargoPathFix(env) };
54
+ }
47
55
  const path = name === 'codegraph-mcp' ? graphBin('codegraph-mcp', env) : name === 'bravos-cli' ? findAnalyzer(env) : whichBin(name, env);
48
56
  return path ? { name, found: true, path, hint } : { name, found: false, hint };
49
57
  });
@@ -126,7 +134,7 @@ export function formatDoctor(r) {
126
134
  const yn = (b) => (b ? 'yes' : 'no');
127
135
  const names = (l) => (l.length ? l.join(', ') : 'none');
128
136
  return [
129
- ...r.tools.map((t) => (t.found ? `✔ ${t.name} ${t.path}` : `✘ ${t.name} ${t.hint}`)),
137
+ ...r.tools.map((t) => (t.found ? `✔ ${t.name} ${t.path}${t.onPath === false ? ` (installed, but its folder is not on PATH here; Bravos runs it by this path. To fix PATH: ${t.fix})` : ''}` : `✘ ${t.name} ${t.hint}`)),
130
138
  r.licence.plan ? `${r.licence.licensed ? '✔' : '✘'} licence ${r.licence.plan}` : r.licence.present ? `✔ licence ${r.licence.source}` : '✘ licence not found — Free (researcher) plan; bravos account activate starts a 30-day Team trial',
131
139
  r.guardlink_initialised ? '✔ guardlink initialised (.guardlink/)' : '✘ guardlink not initialised — run bravos setup',
132
140
  `skills claude: ${r.skills.claude.length} agents: ${r.skills.agents.length}`,
@@ -23,27 +23,9 @@ const prerequisites = {
23
23
  tar: 'install tar for the pinned GuardLink grammar build',
24
24
  cargo: 'install the Rust toolchain (cargo and rustc) and a native linker',
25
25
  };
26
- // @comment -- "Where cargo puts what it installs (CARGO_INSTALL_ROOT, else CARGO_HOME, else ~/.cargo, then /bin), and whether that folder is on PATH. A cargo from Homebrew or a package manager runs fine while that folder is missing from PATH, so cxg builds for minutes and then nothing can find it; setup checks first and says the one line to add."
27
- export function cargoBinDir(env) {
28
- const root = env.CARGO_INSTALL_ROOT || env.CARGO_HOME || (env.HOME ? join(env.HOME, '.cargo') : null);
29
- return root ? join(isAbsolute(root) ? root : resolve(root), 'bin') : null;
30
- }
31
- export function cargoBinOnPath(env) {
32
- const dir = cargoBinDir(env);
33
- if (!dir)
34
- return true;
35
- return (env.PATH ?? '').split(delimiter).some((p) => p && resolve(p) === dir);
36
- }
37
- /** The line that puts cargo's folder on PATH, for the person's own shell profile. */
38
- export function cargoPathFix(env) {
39
- const dir = cargoBinDir(env) ?? '~/.cargo/bin';
40
- const shown = env.HOME && dir.startsWith(env.HOME + '/') ? `$HOME${dir.slice(env.HOME.length)}` : dir;
41
- const shell = (env.SHELL ?? '').split('/').pop();
42
- const profile = shell === 'zsh' ? '~/.zshrc' : shell === 'bash' ? '~/.bash_profile' : shell === 'fish' ? null : '~/.profile';
43
- return profile
44
- ? `echo 'export PATH="${shown}:$PATH"' >> ${profile}, then open a new terminal`
45
- : `fish_add_path ${shown}, then open a new terminal`;
46
- }
26
+ // The cargo folder helpers live in tool-path.ts, shared with doctor and the proof tools; re-exported here for existing callers.
27
+ export { cargoBinDir, cargoBinOnPath, cargoPathFix } from './tool-path.js';
28
+ import { cargoBinDir, cargoBinOnPath, cargoPathFix } from './tool-path.js';
47
29
  // @comment -- "Use fixed package-manager argv in a private scratch directory, outside the customer repository. Ignore inherited Git working-tree overrides and relative PATH entries, so the checkout cannot supply a .cargo/config.toml, .npmrc, Git config or executable for the install."
48
30
  export function installProofTool(name, env, echo, pins = PROOF_TOOL_PINS) {
49
31
  const pin = pins[name];
@@ -1,15 +1,17 @@
1
1
  import { spawnSync } from 'node:child_process';
2
2
  import { resolve } from 'node:path';
3
- import { whichBin } from './guardlink.js';
3
+ import { findTool, withToolDir } from './tool-path.js';
4
4
  // @comment -- "Checks the CLI interface in the executable that will run. Release and development binaries can have identical version strings. Only fixed help arguments are passed, with no shell, bounded output and a deadline (10 s: a cold start on a busy machine can take several); no URL, credentials or template is supplied."
5
5
  export function checkProofTool(name, env, timeoutMs = 10000) {
6
6
  const guardlink = name === 'guardlink';
7
7
  const capability = guardlink ? 'in-session probe translation' : 'plain scan of supplied JS probes with zero model calls';
8
- const binary = whichBin(name, env);
8
+ // Found on PATH or, for cxg, in cargo's folder off PATH: it is checked, and later run, by its full path.
9
+ const found = findTool(name, env);
10
+ const binary = found?.path;
9
11
  if (!binary)
10
12
  return { name, capability, status: 'missing' };
11
13
  const args = guardlink ? ['translate', '--help'] : ['--disable-update-check', 'scan', '--help'];
12
- const help = spawnSync(resolve(binary), args, { env, encoding: 'utf8', timeout: timeoutMs, maxBuffer: 512 * 1024, stdio: ['ignore', 'pipe', 'pipe'] });
14
+ const help = spawnSync(resolve(binary), args, { env: withToolDir(env, found), encoding: 'utf8', timeout: timeoutMs, maxBuffer: 512 * 1024, stdio: ['ignore', 'pipe', 'pipe'] });
13
15
  if (help.error || help.status !== 0)
14
16
  return { name, capability, status: 'unavailable' };
15
17
  const flags = guardlink ? ['--stdout', '--contract', '--threat'] : ['--no-author', '--templates', '--scope-file', '--auth-dir', '--session-dir'];
@@ -2,6 +2,7 @@ import { spawnSync } from 'node:child_process';
2
2
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
3
3
  import { basename, join, relative } from 'node:path';
4
4
  import { graphBin } from '../codegraph.js';
5
+ import { findTool } from '../tool-path.js';
5
6
  import { version } from '../paths.js';
6
7
  import { graphDetail, lib, parseJson, runner } from '../watch.js';
7
8
  import { readRuns } from './runs.js';
@@ -45,7 +46,7 @@ export async function gatherEvidence(root, env, opts) {
45
46
  run('guardlink', ['hypothesis', 'list', '--json', '.'], o),
46
47
  run('guardlink', ['hypothesis', 'boundaries', '--json', '.'], o),
47
48
  run('guardlink', ['--version'], quick),
48
- run('cxg', ['--version'], quick),
49
+ run(findTool('cxg', env)?.path ?? 'cxg', ['--version'], quick),
49
50
  (() => { const b = graphBin('codegraph-build', env); return b ? run(b, ['--version'], quick) : Promise.resolve(null); })(),
50
51
  opts.graph === false ? Promise.resolve(null) : graphDetail(root, env),
51
52
  ]);
@@ -0,0 +1,58 @@
1
+ // @comment -- "Where Bravos finds the tools it runs when they are not on PATH. cxg is built by cargo into cargo's own folder (CARGO_INSTALL_ROOT, else CARGO_HOME, else ~/.cargo, then /bin). A cargo from Homebrew or a package manager runs fine while that folder is missing from PATH, and a session started from a desktop app or a non-interactive shell often has a shorter PATH than the person's terminal, so 'not on PATH' must not read as 'not installed'. PATH lookups and file checks only; nothing is run."
2
+ import { accessSync, constants, statSync } from 'node:fs';
3
+ import { delimiter, isAbsolute, join, resolve } from 'node:path';
4
+ /** Where cargo puts what it installs, or null when there is no home to find it in. */
5
+ export function cargoBinDir(env) {
6
+ const root = env.CARGO_INSTALL_ROOT || env.CARGO_HOME || (env.HOME ? join(env.HOME, '.cargo') : null);
7
+ return root ? join(isAbsolute(root) ? root : resolve(root), 'bin') : null;
8
+ }
9
+ export function cargoBinOnPath(env) {
10
+ const dir = cargoBinDir(env);
11
+ if (!dir)
12
+ return true;
13
+ return (env.PATH ?? '').split(delimiter).some((p) => p && resolve(p) === dir);
14
+ }
15
+ // @comment -- "The line that puts cargo's folder on PATH, for the person's own shell profile. For zsh it is ~/.zshenv, which every zsh reads (a script, an agent's shell, a desktop app's), not ~/.zshrc, which only interactive terminals read: that difference is how a session ended up unable to see a cxg the terminal could run."
16
+ export function cargoPathFix(env) {
17
+ const dir = cargoBinDir(env) ?? '~/.cargo/bin';
18
+ const shown = env.HOME && dir.startsWith(env.HOME + '/') ? `$HOME${dir.slice(env.HOME.length)}` : dir;
19
+ const shell = (env.SHELL ?? '').split('/').pop();
20
+ const profile = shell === 'zsh' ? '~/.zshenv' : shell === 'bash' ? '~/.bash_profile' : shell === 'fish' ? null : '~/.profile';
21
+ return profile
22
+ ? `echo 'export PATH="${shown}:$PATH"' >> ${profile}, then open a new terminal`
23
+ : `fish_add_path ${shown}, then open a new terminal`;
24
+ }
25
+ const executable = (file) => {
26
+ try {
27
+ if (!statSync(file).isFile())
28
+ return false;
29
+ accessSync(file, constants.X_OK);
30
+ return true;
31
+ }
32
+ catch {
33
+ return false;
34
+ }
35
+ };
36
+ /** The folders a tool may sit in when PATH does not have it: cargo's, for cxg (cargo installs it there). Other tools are found on PATH only. */
37
+ export function fallbackDirs(name, env) {
38
+ const dir = name === 'cxg' ? cargoBinDir(env) : null;
39
+ return dir ? [dir] : [];
40
+ }
41
+ // @comment -- "Finds a tool: the first executable on PATH, else the first in its fallback folders. onPath says which, so a caller can run it by its full path and tell the person the one line that fixes their PATH. Null only when it is in neither."
42
+ export function findTool(name, env = process.env) {
43
+ for (const dir of (env.PATH ?? '').split(delimiter)) {
44
+ if (dir && executable(join(dir, name)))
45
+ return { path: join(dir, name), onPath: true, dir };
46
+ }
47
+ for (const dir of fallbackDirs(name, env)) {
48
+ if (executable(join(dir, name)))
49
+ return { path: join(dir, name), onPath: false, dir };
50
+ }
51
+ return null;
52
+ }
53
+ /** env with the tool's folder added to the end of PATH, so the tool and anything it starts can be found. */
54
+ export function withToolDir(env, found) {
55
+ if (!found || found.onPath)
56
+ return env;
57
+ return { ...env, PATH: [env.PATH, found.dir].filter(Boolean).join(delimiter) };
58
+ }
package/docs/UPGRADING.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  After `npm install -g @bugb-technologies/bravos`, run **`bravos setup`** in a repository you work in: it brings this machine and that repository up to date. In repositories you work in with an agent you can skip even that: the agent runs it at the start of a session. From 1.12 on you do not have to watch for releases: Bravos tells you when a newer version is out, and after you install it the agent brings each repository up to date. The notes below say what else changes, newest first. (Before 1.9 the same was `bravos setup --tools -y` per machine and `bravos sync` per repository; both still work.)
4
4
 
5
+ ## 1.12.1
6
+
7
+ - **Bravos finds cxg when your PATH doesn't have it.** cargo installs cxg into its own folder (`~/.cargo/bin`, or `CARGO_HOME`/`CARGO_INSTALL_ROOT`). A session started from a desktop app or a non-interactive shell often lacks that folder on PATH, and Bravos used to read that as "cxg is not installed".
8
+ - Bravos now looks in cargo's folder too, and runs cxg from there by its full path.
9
+ - `bravos doctor` shows it as installed, with where it is and the line that fixes PATH.
10
+ - The session briefing tells the agent that cxg isn't missing and how to run it.
11
+ - In CI the replay runner still runs only the cxg the job put on PATH.
12
+ - **The PATH fix for zsh now goes in `~/.zshenv`,** which every zsh reads, including the shells agents and desktop apps start. `~/.zshrc` is read only by interactive terminals. To fix it once, run `echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.zshenv`, then open a new terminal.
13
+ - **For scripts:** each tool entry in `bravos doctor --json` gains `onPath` (and `fix` when it is false).
14
+
5
15
  ## 1.12.0
6
16
 
7
17
  - **Bravos tells you when it is updated.**
@@ -8,6 +8,7 @@ import { legacySkills, legacySkillsLine } from './legacy-skills.mjs';
8
8
  import { THEMES } from './palette.mjs';
9
9
  import { commitsLine, commonDirFrom, readHandoff, readPrefs } from './prefs.mjs';
10
10
  import { cliVersion, newer, readUpdate, updateLine } from './update-check.mjs';
11
+ import { cxgPathLine, findTool } from './tool-path.mjs';
11
12
  import { readProving } from './proving.mjs';
12
13
  import { planLabel, planLine, status as licenceStatus } from './licence.mjs';
13
14
  import { readLicenceNote, refreshIfDue } from './refresh.mjs';
@@ -282,6 +283,8 @@ export function buildBriefing(inputs) {
282
283
  // A newer Bravos published than the one installed (hooks/lib/update-check.mjs): the person installs it.
283
284
  const update = updateLine(i.update, i.cli);
284
285
  if (update) tail.push(update);
286
+ const cxgLine = cxgPathLine(i.cxg, { HOME: i.env?.HOME ?? process.env.HOME, SHELL: i.env?.SHELL ?? process.env.SHELL });
287
+ if (cxgLine) tail.push(cxgLine);
285
288
  // The portal's last refusal to renew this machine, until it is signed in again (a revocation) or renewed (a plan that ended).
286
289
  if (i.licenceNote && (i.licenceNote.outcome === 'lapsed' || i.licence?.licensed === false)) tail.push(`Licence: ${i.licenceNote.note} Tell the person once, in plain words.`);
287
290
  // Skills the retired Python bravos left at user level: the agent must not follow them (hooks/lib/legacy-skills.mjs).
@@ -590,6 +593,8 @@ export async function collect(root, env, { deadlineMs = 20000, nextCount = 3 } =
590
593
  // The last daily update check (~/.bravos/update-check.json) and the installed CLI's version, both file reads.
591
594
  update: readUpdate(env.HOME || homedir()),
592
595
  cli: cliVersion(env),
596
+ // Where cxg is, when it is installed: off PATH in this session is not missing (hooks/lib/tool-path.mjs).
597
+ cxg: findTool('cxg', { ...env, HOME: env.HOME || homedir() }),
593
598
  annotationMode: readAnnotationMode(root),
594
599
  // bravos on PATH: what its probe says (a graph for this commit or not); else codegraph-mcp on PATH means the MCP route.
595
600
  codegraph: graphState ?? (whichOnPath('codegraph-mcp', env) ? 'unknown' : 'unavailable'),
@@ -1,5 +1,6 @@
1
1
  // @comment -- "Run one supplied, bound JavaScript probe per CXG process. Authority for target contact comes from the reviewed policy and scope; a kit controls neither. Only an engine verdict and an unchanged binding can update an exposure."
2
2
  import { createHash, randomUUID } from 'node:crypto';
3
+ import { findTool, withToolDir } from './tool-path.mjs';
3
4
  import { spawnSync } from 'node:child_process';
4
5
  import { closeSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readSync, readlinkSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
5
6
  import { createConnection } from 'node:net';
@@ -23,8 +24,19 @@ function localFile(root, name) {
23
24
  return file;
24
25
  }
25
26
 
27
+ // @comment -- "Runs a fixed command with no shell. cxg is found on PATH or, when the session's PATH lacks it, in cargo's folder (hooks/lib/tool-path.mjs), and run by that full path with its folder added to PATH, so 'not on PATH' never stops a replay of an installed cxg. In CI there is no fallback: only the job's own cxg on PATH runs."
28
+ // @mitigates #replay-ledger against #tool-tampering using #cache-isolation -- "invoke() looks outside PATH for cxg only off CI, so a CI replay runs only the cxg its own job installed"
26
29
  function invoke(command, args, cwd, opts = {}) {
27
- const result = spawnSync(command, args, { cwd, env: opts.env ?? sanitizedEnv(process.env), input: opts.input, encoding: 'utf8', timeout: opts.timeout ?? 120000,
30
+ let env = opts.env ?? sanitizedEnv(process.env);
31
+ if (command === 'cxg') {
32
+ // In CI only the cxg the job put on PATH runs: a binary left in a home folder by an earlier step is never picked up.
33
+ const found = findTool('cxg', { ...env, HOME: env.HOME ?? process.env.HOME }, { fallback: !(process.env.CI || process.env.GITHUB_ACTIONS) });
34
+ if (found) {
35
+ command = found.path;
36
+ env = withToolDir(env, found);
37
+ }
38
+ }
39
+ const result = spawnSync(command, args, { cwd, env, input: opts.input, encoding: 'utf8', timeout: opts.timeout ?? 120000,
28
40
  stdio: ['pipe', 'pipe', 'pipe'], maxBuffer: 64 * 1024 * 1024 });
29
41
  if (result.error || !(opts.allowed ?? [0]).includes(result.status)) {
30
42
  // Tool stderr can include provider bodies, session details or scan evidence.
@@ -0,0 +1,56 @@
1
+ // @comment -- "The hooks' copy of src/tool-path.ts (the hook scripts are installed apart from the CLI and cannot import it): finds a tool on PATH or, for cxg, in cargo's folder (CARGO_INSTALL_ROOT, else CARGO_HOME, else ~/.cargo, then /bin) so a session whose PATH is shorter than the person's terminal still runs cxg and is told how to fix PATH. File checks only; nothing is run. Dependency-free."
2
+ import { accessSync, constants, statSync } from 'node:fs';
3
+ import { delimiter, isAbsolute, join, resolve } from 'node:path';
4
+
5
+ export function cargoBinDir(env) {
6
+ const root = env.CARGO_INSTALL_ROOT || env.CARGO_HOME || (env.HOME ? join(env.HOME, '.cargo') : null);
7
+ return root ? join(isAbsolute(root) ? root : resolve(root), 'bin') : null;
8
+ }
9
+
10
+ const executable = (file) => {
11
+ try {
12
+ if (!statSync(file).isFile()) return false;
13
+ accessSync(file, constants.X_OK);
14
+ return true;
15
+ } catch {
16
+ return false;
17
+ }
18
+ };
19
+
20
+ // cargo's folder, for cxg: other tools are found on PATH only.
21
+ export function fallbackDirs(name, env) {
22
+ const dir = name === 'cxg' ? cargoBinDir(env) : null;
23
+ return dir ? [dir] : [];
24
+ }
25
+
26
+ // @comment -- "The first executable named name on PATH, else (unless fallback is false) in its fallback folders; { path, onPath, dir } or null."
27
+ export function findTool(name, env = process.env, { fallback = true } = {}) {
28
+ for (const dir of String(env.PATH ?? '').split(delimiter)) {
29
+ if (dir && executable(join(dir, name))) return { path: join(dir, name), onPath: true, dir };
30
+ }
31
+ if (!fallback) return null;
32
+ for (const dir of fallbackDirs(name, env)) {
33
+ if (executable(join(dir, name))) return { path: join(dir, name), onPath: false, dir };
34
+ }
35
+ return null;
36
+ }
37
+
38
+ /** env with the tool's folder added to the end of PATH, so the tool and what it starts are found. */
39
+ export function withToolDir(env, found) {
40
+ if (!found || found.onPath) return env;
41
+ return { ...env, PATH: [env.PATH, found.dir].filter(Boolean).join(delimiter) };
42
+ }
43
+
44
+ /** How to put the folder on PATH for good, in the person's own shell: ~/.zshenv for zsh, which every zsh reads. */
45
+ export function pathFix(dir, env) {
46
+ const shown = env.HOME && dir.startsWith(env.HOME + '/') ? `$HOME${dir.slice(env.HOME.length)}` : dir;
47
+ const shell = String(env.SHELL ?? '').split('/').pop();
48
+ if (shell === 'fish') return `fish_add_path ${shown}`;
49
+ return `echo 'export PATH="${shown}:$PATH"' >> ${shell === 'bash' ? '~/.bash_profile' : shell === 'zsh' ? '~/.zshenv' : '~/.profile'}`;
50
+ }
51
+
52
+ // @comment -- "The briefing's cxg line when cxg is installed but its folder is not on this session's PATH: run it by its full path (or put the folder in front of PATH for the command), never say it is not installed, and tell the person once the line that fixes their shell. Null when cxg is on PATH or not installed at all."
53
+ export function cxgPathLine(found, env) {
54
+ if (!found || found.onPath) return null;
55
+ return `cxg: installed at ${found.path}, but its folder is not on PATH in this session. It is not missing: run it as ${found.path} (or start the command with PATH="${found.dir}:$PATH"), and tell the person once that ${pathFix(found.dir, env)} makes every new session find it.`;
56
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bugb-technologies/bravos",
3
- "version": "1.12.0",
3
+ "version": "1.12.1",
4
4
  "description": "Skills pack and installer that make Claude Code and Codex power users of guardlink (threat-model-as-code) and cert-x-gen (pentest-as-code).",
5
5
  "keywords": [
6
6
  "security",
@@ -9,6 +9,7 @@ description: "Bring up a test target the user owns and prepare it for an authori
9
9
  - bravos-prove or bravos-recheck needs a running target and none is up.
10
10
  - The user asks to start the app for testing, seed test users, roles or orgs, or capture a login session.
11
11
  - A run was refused at pre-flight (cxg exit 4) or stopped on a dead session (exit 5).
12
+ - cxg looks missing: Before you say cxg is missing, check where it is: the briefing's `cxg:` line or `bravos doctor` names it when it is installed but its folder is not on this session's PATH (cxg lives in cargo's folder, `~/.cargo/bin`). Then it is not missing: run it by that full path, or start each command with `PATH="$HOME/.cargo/bin:$PATH"`, and tell the person once the line that fixes their shell. Only `bravos doctor` saying `✘ cxg` means it is not installed (`bravos setup --tools` installs it, with their go-ahead).
12
13
 
13
14
  ## Do
14
15
 
@@ -12,7 +12,7 @@ description: "Prove a new or changed GuardLink claim, or replay it after a fix,
12
12
 
13
13
  ## Do
14
14
 
15
- 1. Check the preconditions from bravos-env before any traffic: authorization for this run, a target that answers, `.guardlink/scope.yaml` committed, each profile passing `cxg pentest auth verify --profile <name>`, and for any non-loopback target both a reviewed scope and the human's authorization typed in this session. If one is missing, stop and hand back to bravos-env. Read the effort: the user's words ("at high"), else a `bravos effort: <level>` line in `AGENTS.md` / `CLAUDE.md`, else medium. It sets a starting budget, not a limit; go beyond it when the work needs it and say why in one line. Starting budget — low: replay a matching kit; medium: also author the first missing test in this session; high: include affected callers and controls; max: cover the testable in-scope queue. A higher effort does not authorize spending on an external model.
15
+ 1. Before you say cxg is missing, check where it is: the briefing's `cxg:` line or `bravos doctor` names it when it is installed but its folder is not on this session's PATH (cxg lives in cargo's folder, `~/.cargo/bin`). Then it is not missing: run it by that full path, or start each command with `PATH="$HOME/.cargo/bin:$PATH"`, and tell the person once the line that fixes their shell. Only `bravos doctor` saying `✘ cxg` means it is not installed (`bravos setup --tools` installs it, with their go-ahead). Check the preconditions from bravos-env before any traffic: authorization for this run, a target that answers, `.guardlink/scope.yaml` committed, each profile passing `cxg pentest auth verify --profile <name>`, and for any non-loopback target both a reviewed scope and the human's authorization typed in this session. If one is missing, stop and hand back to bravos-env. Read the effort: the user's words ("at high"), else a `bravos effort: <level>` line in `AGENTS.md` / `CLAUDE.md`, else medium. It sets a starting budget, not a limit; go beyond it when the work needs it and say why in one line. Starting budget — low: replay a matching kit; medium: also author the first missing test in this session; high: include affected callers and controls; max: cover the testable in-scope queue. A higher effort does not authorize spending on an external model.
16
16
  2. Order what to test, then read how the person wants proving handled. With the code graph (its MCP tools, or `bravos graph <question> --json` — same answers; see bravos-codegraph) (briefing `Code graph:` says `current`): `codegraph_untested_exposures` and `codegraph_untested_reach` rank untested exposures by reach; test the ones intent.md's Assumptions put in scope first, least privileged entry point first, and report exposures only an out-of-scope attacker reaches instead of running them. Without the graph, say "code graph unavailable; using guardlink hypothesis next order" and use that queue. Within that order, an exposure with a reachable SAST finding joined to it (`bravos sast candidates`) goes before one without, and its route goes into the run notes; with no SAST report or SAST unavailable, skip this. Then, for how the person wants proving handled: the briefing's `Proving:` line, from `.guardlink/proving.md`. If it is not set, ask them once, with a suggestion drawn from the repo (for example, "you have a docker-compose; I'd prove automatically on 127.0.0.1:8080"): prove automatically on their loopback target whenever new or changed exposures appear, ask each time, on a schedule (bravos-schedule's nightly), or not now. Record their answer in `.guardlink/proving.md`: lines `choice: auto|ask|schedule|none`, `target: <loopback url>`, `start: <start command>`, `generation: no` (Bravos never uses cxg's model generation), their words quoted verbatim, and `— confirmed by <their name>, <date>`. Before offering or following `auto`, check that `git symbolic-ref --quiet refs/remotes/origin/HEAD` names an existing commit. If missing, warn: fetch the default branch, then `git remote set-head origin --auto` (or `git remote set-head origin <branch>`); use `ask` meanwhile. Then follow it: `auto` proceeds on that target with their quoted words as the attestation; `ask` asks now; `schedule` hands to bravos-schedule; `none` stops here and says so. When they change their mind, rewrite the file with their new words.
17
17
  3. Read the affected claim from `guardlink hypothesis list --json`. Include a declared mitigation awaiting its first test and a previously confirmed claim now marked retest. Match its key to the logical source location in `guardlink sarif . --profile pentest -o whitebox/findings.sarif`; external annotations also have a physical declaration in a .gal file. Keep both locations. Record the tested source revision or worktree, application build, identity roles and intended oracle.
18
18
  4. For a web claim, use its bound JavaScript kit in .guardlink/cxg-replay/. For a missing or mismatched kit, follow bravos-templatize in this session. A matching kit exercises the intended operation and includes a positive control for a claimed defense. Validate the kit and review its scope. Honor the recorded kit policy and the person’s stated limits. An automatic reviewed-only policy requires identical bound test bytes on the default branch. On a clone whose upstream has no testing policy, use `ask` with locally committed policy and scope and typed authorization for loopback `run-once`. The earlier wizard’s “only replay tests I approved” choice retains that restriction.