@bugb-technologies/bravos 1.3.0 → 1.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.
Files changed (42) hide show
  1. package/README.md +16 -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 +31 -16
  15. package/dist/start/answers.js +5 -3
  16. package/dist/start/index.js +28 -14
  17. package/dist/versions.js +4 -3
  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
@@ -1,7 +1,7 @@
1
1
  // @comment -- "The session-start snapshot autopilot compares against: the working-tree changes present when a session began (path to content fingerprint) and HEAD at that moment, written to .bravos/watch/turn-base/<session_id>.json (the watch folder ignores itself), plus the read-only spawn runner both hooks use. Kept apart from autopilot.mjs because the session-start hook imports it and plugin hook bundles ship without the autopilot module."
2
2
  import { createHash } from 'node:crypto';
3
3
  import { spawn } from 'node:child_process';
4
- import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs';
4
+ import { existsSync, mkdirSync, readFileSync, readdirSync, readlinkSync, lstatSync, rmSync, statSync, writeFileSync } from 'node:fs';
5
5
  import { join } from 'node:path';
6
6
 
7
7
  const OUTPUT_CAP = 64 * 1024 * 1024;
@@ -26,8 +26,11 @@ export function asyncRunner(cmd, args, { cwd, env, timeoutMs = 20000 }) {
26
26
  resolve(r);
27
27
  };
28
28
  child.stdout.on('data', (b) => {
29
- if (size < OUTPUT_CAP) chunks.push(b);
30
29
  size += b.length;
30
+ if (size > OUTPUT_CAP) {
31
+ child.kill('SIGKILL');
32
+ finish({ status: null, error: 'EOUTPUTLIMIT', stdout: '' });
33
+ } else chunks.push(b);
31
34
  });
32
35
  const timer = setTimeout(() => {
33
36
  child.kill('SIGKILL');
@@ -43,9 +46,13 @@ export function asyncRunner(cmd, args, { cwd, env, timeoutMs = 20000 }) {
43
46
  export async function workingChanges(root, env, run) {
44
47
  const o = { cwd: root, env };
45
48
  const out = new Set();
46
- const [diff, untracked] = await Promise.all([run('git', ['diff', '--name-only', 'HEAD'], o), run('git', ['ls-files', '--others', '--exclude-standard'], o)]);
47
- if (diff.status === 0) for (const l of diff.stdout.split('\n')) if (l.trim()) out.add(l.trim());
48
- if (untracked.status === 0) for (const l of untracked.stdout.split('\n')) if (l.trim()) out.add(l.trim());
49
+ const [diff, untracked] = await Promise.all([
50
+ run('git', ['diff', '--name-only', 'HEAD', '-z', '--no-renames', '--'], o),
51
+ run('git', ['ls-files', '-z', '--others', '--exclude-standard'], o),
52
+ ]);
53
+ for (const result of [diff, untracked]) {
54
+ if (result.status === 0) for (const path of result.stdout.split('\0')) if (path) out.add(path);
55
+ }
49
56
  return out;
50
57
  }
51
58
 
@@ -63,7 +70,9 @@ const snapshotDir = (root) => join(root, '.bravos', 'watch', 'turn-base');
63
70
  // @comment -- "A cheap fingerprint of one working-tree file: sha1 of its content, size and mtime for a file over 2 MB, 'absent' when it cannot be read (deleted counts as a state too)."
64
71
  export function fingerprint(root, rel) {
65
72
  try {
66
- const st = statSync(join(root, rel));
73
+ const st = lstatSync(join(root, rel));
74
+ if (st.isSymbolicLink()) return createHash('sha1').update(readlinkSync(join(root, rel))).digest('hex');
75
+ if (!st.isFile()) return 'non-file';
67
76
  if (st.size > SNAPSHOT_MAX_BYTES) return `size:${st.size}:${st.mtimeMs}`;
68
77
  return 'sha1:' + createHash('sha1').update(readFileSync(join(root, rel))).digest('hex');
69
78
  } catch {
@@ -71,6 +80,57 @@ export function fingerprint(root, rel) {
71
80
  }
72
81
  }
73
82
 
83
+ // Git quotes paths containing controls. core.quotePath=false keeps Unicode as UTF-8;
84
+ // the remaining escapes are Git's C-style control and quote escapes.
85
+ function patchPath(header) {
86
+ const path = header.split('\t')[0];
87
+ if (path === '/dev/null') return null;
88
+ const escapes = { a: '\x07', b: '\b', t: '\t', n: '\n', v: '\v', f: '\f', r: '\r' };
89
+ const unquoted = path.startsWith('"')
90
+ ? path.slice(1, -1).replace(/\\([0-7]{3}|.)/g, (_, c) => c.length === 3 ? String.fromCharCode(parseInt(c, 8)) : escapes[c] ?? c)
91
+ : path;
92
+ return unquoted.slice(2);
93
+ }
94
+
95
+ // @comment -- "Read a zero-context Git patch from a fixed revision to disk, with external diff and text conversion disabled. Keep line ranges and hashes only. Old-side coordinates identify pre-existing dirty hunks even when a later insertion shifts their new line numbers."
96
+ export function gitPatchArgs(base, head) {
97
+ return ['-c', 'core.quotePath=false', 'diff', '--no-ext-diff', '--no-textconv', '--no-renames',
98
+ '--no-color', '--unified=0', '--src-prefix=a/', '--dst-prefix=b/', '--end-of-options', base, ...(head ? [head] : []), '--'];
99
+ }
100
+
101
+ export async function changedHunks(root, env, run, base, timeoutMs = 10000) {
102
+ const result = await run('git', gitPatchArgs(base), { cwd: root, env, timeoutMs });
103
+ return result.status === 0 ? parseChangedHunks(result.stdout) : new Map();
104
+ }
105
+
106
+ export function parseChangedHunks(patch) {
107
+ const files = new Map();
108
+ let oldFile, file, hunk, deleted;
109
+ for (const line of patch.split('\n')) {
110
+ if (line.startsWith('diff --git ')) {
111
+ oldFile = file = hunk = null;
112
+ deleted = false;
113
+ } else if (!hunk && line.startsWith('--- ')) {
114
+ oldFile = patchPath(line.slice(4));
115
+ } else if (!hunk && line.startsWith('+++ ')) {
116
+ const destination = patchPath(line.slice(4));
117
+ deleted = destination === null;
118
+ file = destination ?? oldFile;
119
+ } else if (file && line.startsWith('@@ ')) {
120
+ const m = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/.exec(line);
121
+ if (!m) continue;
122
+ const start = Math.max(1, Number(m[3]));
123
+ hunk = { start, deleted, end: start + Math.max(1, Number(m[4] ?? 1)) - 1, hash: createHash('sha256').update(m[1] + ':' + (m[2] ?? '1')) };
124
+ if (!files.has(file)) files.set(file, []);
125
+ files.get(file).push(hunk);
126
+ } else if (hunk && (line.startsWith('+') || line.startsWith('-'))) {
127
+ hunk.hash.update('\n' + line);
128
+ }
129
+ }
130
+ for (const hunks of files.values()) for (const h of hunks) h.hash = h.hash.digest('hex');
131
+ return files;
132
+ }
133
+
74
134
  /**
75
135
  * Records what the working tree already held when a session started, so the end-of-turn check can
76
136
  * tell this session's changes from edits that were there before it. Never throws.
@@ -86,16 +146,19 @@ export async function takeSnapshot(root, sessionId, { env = process.env, run = a
86
146
  const o = { cwd: root, env, timeoutMs: 5000 };
87
147
  const head = await run('git', ['rev-parse', 'HEAD'], o);
88
148
  if (head.status !== 0) return null;
89
- const files = {};
149
+ const files = Object.create(null);
90
150
  let n = 0;
91
151
  for (const rel of await workingChanges(root, env, run)) {
92
152
  if (n++ >= SNAPSHOT_MAX_FILES) break;
93
153
  files[rel] = fingerprint(root, rel);
94
154
  }
155
+ const initialHunks = n ? await changedHunks(root, env, run, head.stdout.trim(), 5000) : new Map();
156
+ const hunks = Object.fromEntries(Object.keys(files).filter(path => initialHunks.has(path))
157
+ .map(path => [path, initialHunks.get(path).map(h => h.hash)]));
95
158
  mkdirSync(dir, { recursive: true });
96
159
  const ignore = join(root, '.bravos', 'watch', '.gitignore');
97
160
  if (!existsSync(ignore)) writeFileSync(ignore, '*\n');
98
- writeFileSync(file, JSON.stringify({ at: new Date(now).toISOString(), head: head.stdout.trim(), files, truncated: n > SNAPSHOT_MAX_FILES }));
161
+ writeFileSync(file, JSON.stringify({ at: new Date(now).toISOString(), head: head.stdout.trim(), files, hunks, truncated: n > SNAPSHOT_MAX_FILES }));
99
162
  for (const f of readdirSync(dir)) {
100
163
  try {
101
164
  if (f.endsWith('.json') && now - statSync(join(dir, f)).mtimeMs > SNAPSHOT_KEEP_MS) rmSync(join(dir, f));
@@ -115,7 +178,10 @@ export function readSnapshot(root, sessionId) {
115
178
  if (!id) return null;
116
179
  try {
117
180
  const s = JSON.parse(readFileSync(join(snapshotDir(root), `${id}.json`), 'utf8'));
118
- return s && typeof s.head === 'string' && s.files && typeof s.files === 'object' ? s : null;
181
+ if (!s || !/^[a-zA-Z0-9]+$/.test(s.head) || !s.files || typeof s.files !== 'object' || Array.isArray(s.files)) return null;
182
+ // Snapshot files are local inputs. Never fingerprint an absolute or traversing path.
183
+ if (Object.keys(s.files).some(p => !p || p.startsWith('/') || p.split('/').includes('..'))) return null;
184
+ return s;
119
185
  } catch {
120
186
  return null;
121
187
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bugb-technologies/bravos",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
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",
@@ -57,7 +57,7 @@ description: "Start here in any repo bravos is installed in: reads the security
57
57
 
58
58
  ## Go deeper
59
59
 
60
- - Autopilot (`bravos init --autopilot`): an end-of-turn check sends you back once when changed code lacks annotations, sits under a confirmed or stale claim, or adds exposures; the briefing's `Autopilot:` and `Proving:` lines say whether it is on and how the person wants proving handled.
60
+ - Autopilot (`bravos init --autopilot`): an end-of-turn check points you to changed code and affected claims, including untested controls and claims due for retest; the briefing's `Autopilot:` and `Proving:` lines say whether it is on and how the person wants proving handled.
61
61
  - `bravos guide` (in a shell; no model) explains bravos by role, by task and skill by skill, with the safety rules; `docs/GUIDE.md` in the bravos package is the same text. Point a person there when they ask how to use bravos.
62
62
  - `docs/GUARDLINK_REFERENCE.md` — annotation syntax and verbs.
63
63
  - `.guardlink/README.md` — where annotations go in this repo.
@@ -16,17 +16,18 @@ description: "Keep the GuardLink threat model correct and growing, in this sessi
16
16
  1. Set up. You annotate in this session: guardlink supplies the method (its playbook skills), you supply the edits. `<base>` below is the base branch name, e.g. `main`; the briefing prints it as `base origin/<base>`, and without a briefing `git symbolic-ref -q --short refs/remotes/origin/HEAD` prints `origin/<base>` (if it prints nothing, use `main`). Run `git fetch origin <base>` before you use `origin/<base>`, so it is current; if the fetch fails (offline, no `origin`), say so and continue with the local ref. Record `git rev-parse HEAD` now as `<start>`: the lint gate judges only what this session writes. Definitions (`@asset`, `@threat`, `@control` with `#id`) live in `.guardlink/definitions.*`; reuse those ids and never redefine one. Read `.guardlink/intent.md`: its invariants (`INV-n`), intended-by-design items (`INT-n`), actors and crown jewels shape every claim below. If it is missing, run bravos-context first; if the user declines, carry on and tell them severities are not calibrated to the product.
17
17
  2. Run `guardlink ci -f json`. Note `summary.coverage.percent` as p0 and the worklist size from the briefing or `guardlink unannotated --json` (`summary.worklist`).
18
18
  3. Read the effort: the user's words ("at high"), else a `bravos effort: <level>` line in `AGENTS.md` / `CLAUDE.md`, else medium. Starting budgets — low: the changed files only; medium: changed plus 5 from the worklist; high: 25 per round, then the `chains` playbook; max: rounds until the worklist is empty (bravos-campaign runs those with subagents). These are defaults, not limits: take more or fewer when the code calls for it, and say why in one line ("12 files, not 5: the auth path spans them"). For a large pick, tell the user the files and rounds before you start.
19
- 4. Run `node {{SKILL_DIR}}/scripts/slice.mjs --base origin/<base> --n <budget>` (`--deep` for no limit, `--batches <k>` to split the pick for parallel work, `--prefer <file>` for entry points `codegraph_entry_points` found). It prints one JSON object: `diff` (changed files), `coverage` (unannotated files to cover, entry points and trust code first, generated, test and CI files last), `coverage_detail` (`{path, tier, why}`), `batches`, `skipped` (`{path, reason}`), `coverage_before`, `notes`. The order is advice: if your reading of the code says a different file matters more, take it and say why. Tell the user which `skipped` files teammates have in flight. Report every `notes` entry to the user; if one says gh was unavailable, say in-flight PRs were not checked before you take the `coverage` files. Exit 1 means `guardlink unannotated --json` failed: report it and stop. When the briefing's `SAST:` line shows a run, `bravos sast candidates` lists reachable findings not in the threat model yet: add their files to the pick as leads, open each, and annotate only what meets the evidence bar, as `@exposes` + `@audit` citing the rule and route, or an `@audit` naming a false positive. A static finding is never `@confirmed`. With SAST unavailable or no report, pick as usual.
20
- 5. Pick the playbook: `diff` files → `diff`; `coverage` files → `coverage`. Deep rounds run `exploitable`, then `chains`, then `coverage`, then `verify`. Add a logic pass when intent.md lists invariants (always at high and max, or when guardlink offers a `logic` playbook use it): walk each user journey that touches an invariant — signup, invite, role change, checkout, refund, export — and at each step ask what it assumes about the caller and the step before: ownership, tenant, state, amount, rate. The sink of a logic claim is the state change (the write, the transfer, the grant); the absent control is the missing ownership or state check. Claim it against the invariant's threat: `@mitigates <Asset> against #inv-… using #<control>` for a check that holds, `@exposes <Asset> to #inv-…` for one that is missing and meets the evidence bar, `@audit` for a doubt.
19
+ 4. Run `node {{SKILL_DIR}}/scripts/slice.mjs --base origin/<base> --n <budget>` (`--deep` for no limit, `--batches <k>` to split the pick for parallel work, `--prefer <file>` for entry points `codegraph_entry_points` found). It prints one JSON object: `diff` (files changed from the merge base to disk, including staged, unstaged and untracked source), `coverage` (unannotated files to cover, entry points and trust code first, generated, test and CI files last), `coverage_detail` (`{path, tier, why}`), `batches`, `skipped` (`{path, reason}`), `coverage_before`, `notes`. The order is advice: if your reading of the code says a different file matters more, take it and say why. Tell the user which `skipped` files teammates have in flight. Report every `notes` entry to the user; if one says gh was unavailable, say in-flight PRs were not checked before you take the `coverage` files. Exit 1 means `guardlink unannotated --json` failed: report it and stop. When the briefing's `SAST:` line shows a run, `bravos sast candidates` lists reachable findings not in the threat model yet: add their files to the pick as leads, open each, and annotate only what meets the evidence bar, as `@exposes` + `@audit` citing the rule and route, or an `@audit` naming a false positive. A static finding is never `@confirmed`. With SAST unavailable or no report, pick as usual.
20
+ 5. When a Stop hook names files or lines, review those changes first, including already annotated files. Read the actual patch and both sides of a move or deletion. Open each affected handler, guard and caller. With a current graph, ask `codegraph_annotation_gaps` with explicit new-side file ranges for working edits or the merge base for committed changes. Inspect stale and unindexed files and read unsupported routes from source. An existing annotation in the file does not establish that it describes the new behavior. Record the changed threat, guard, or flow, recheck an affected existing claim, or finish the review quietly when the change has no security consequence. Keep ordinary turn-end review to the changed code. Pick the playbook: `diff` files → `diff`; `coverage` files → `coverage`. Deep rounds run `exploitable`, then `chains`, then `coverage`, then `verify`. Add a logic pass when intent.md lists invariants (always at high and max, or when guardlink offers a `logic` playbook use it): walk each user journey that touches an invariant — signup, invite, role change, checkout, refund, export — and at each step ask what it assumes about the caller and the step before: ownership, tenant, state, amount, rate. The sink of a logic claim is the state change (the write, the transfer, the grant); the absent control is the missing ownership or state check. Claim it against the invariant's threat: `@mitigates <Asset> against #inv-… using #<control>` for a check that holds, `@exposes <Asset> to #inv-…` for one that is missing and meets the evidence bar, `@audit` for a doubt.
21
21
  6. Open `{{SKILLS_ROOT}}/guardlink-annotate-<id>/SKILL.md` (guardlink writes it under `.claude/skills/`, and `bravos init` mirrors it into `.agents/skills/` for Codex) and follow it. Otherwise call the MCP tool `guardlink_annotate` (server `guardlink`) with `prompt: "<scope>"` and `playbook: "<id>"`, or run `guardlink annotate --stdout --playbook <id> "<scope>"` (for the `diff` playbook, `guardlink annotate --stdout --playbook diff --since origin/<base> "<scope>"`, since `--since` defaults to HEAD and would list no changed files), and follow the prompt it returns.
22
- 7. Write the annotations in each file's own comment syntax, directly above the code they describe, coupled: every `@exposes` with its `@mitigates` or `@audit`, the `@flows` the data takes, and a `@comment` on what the code does. Each claim meets the evidence bar: it names the code, the threat and the control by id, and you could point at the line that makes it true.
22
+ 7. Read the repository's annotation mode in `.guardlink/README.md` and its configuration. In inline mode write annotations in the file's comment syntax directly above the code. In external mode update its `.guardlink/annotations/<source-path>.gal` sidecar and anchor the block to the logical source line and symbol using the local GuardLink playbook. Couple the claims: every `@exposes` with its `@mitigates` or `@audit`, the `@flows` the data takes, and a `@comment` on what the code does. Each claim meets the evidence bar: it names the code, the threat and the control by id, and you could point at the line that makes it true.
23
23
  Rate each `@exposes` by impact × reach × ease, within its threat's band, under intent.md's `## Assumptions` when it has them (the configuration baseline, deployment and attackers in scope; an exposure only an out-of-scope attacker reaches gets an `@audit`, not a severity): impact from the asset's `@handles` class and intent.md's crown jewels; reach from the boundary in front of it (public, then signed-in, then admin-only, then internal; with the code graph (its MCP tools, or `bravos graph <question> --json` — same answers; see bravos-codegraph), `codegraph_auth_boundary` for the route and `codegraph_reachable_sinks` for what the handler reaches; code `codegraph_entry_reach` or `codegraph_dead_code` shows no entry point reaches gets an `@audit` "not reachable per code graph", not a severity; without the graph, judge reach by reading the code and say the graph was unavailable); ease from its preconditions. Write the severity inline and the reason in the description ("high: reachable unauthenticated, touches payment records").
24
24
  Intended? When the code does what an intent.md `INT-n` item says the product does on purpose, write no `@exposes`: write an `@audit` citing it ("by design per intent.md INT-2; check only admins reach it") and annotate the guard that should hold. When it looks intended but intent.md is silent, write an `@audit` asking "intended?" with your reason, and list it for the user. They answer with a fix, an intent.md line or their own `@accepts`; you never accept it. In a bravos workspace (the briefing's `Workspace:` line, or `.bravos/workspace/workspace.json`), define only this service's own assets, with ids prefixed by the service (`#orders-create`), never another service's; declare each call to another service as `@flows #<this>-<x> -> #<other>-<y> via http|grpc|queue -- "..."` with the other service's own id. Do not write the dotted `#repo.tag` form that guardlink's Workspace Context block suggests: cxg cannot chain it, so the cross-service attack is never tested.
25
+ If a patch changes a caller, destination, trust boundary or security control, trace who can reach it, the data crossing it, the guard and where it is enforced. Reconcile the specific `@flows`, `@boundary` and control claims with the new behavior. For tools the application gives an agent, review `@agents` or `@reaches` at registration, `@effects` where the action occurs and `@gates` where approval is enforced. For coding-agent configuration, run `guardlink lookup "unentitled coding-agent reach"` and inspect the changed configuration lines. GuardLink derives the agent's reach from those files. Propose a missing entitlement for the human's decision; report an unapproved capability and the evidence separately from an exploitable finding.
25
26
  8. Gate: run `guardlink lint . --since <start> --json`. For each entry in `violations[]`, apply its `fix`. Repeat until `summary.errors` is 0. A violation on a line you did not write this session is not yours: leave the line as it is and report it to the user.
26
27
  9. Run `guardlink validate .` and fix what it reports in the lines you wrote.
27
28
  10. Run `guardlink ci -f json` again and report `+<files>, <p0>% → <p1>%, <errors> lint errors`. Deep only: repeat steps 4–10 once per round, and stop when `coverage` comes back empty or a round adds no claims.
28
- 11. Commit the slice on its own: `git add` only the annotated files, message `annotate: <n> files, <playbook>`. Ship it as a small PR or on the feature branch, whichever the team does.
29
- 12. Hand the new claims to bravos-ship, and the new `@exposes` ids to bravos-templatize so they become testable.
29
+ 11. On a normal coding turn keep annotations with the code change and preserve the user's staged and uncommitted edits. For a requested standalone coverage slice, commit the slice on its own: `git add` only the annotated files, message `annotate: <n> files, <playbook>`. Ship it as a small PR or on the feature branch, whichever the team does.
30
+ 12. Read `guardlink hypothesis list --json`. Keep each changed exposure's stable key, source location, sidecar location when applicable, and tested state. Include untested claims with a declared mitigation. Hand new claims to bravos-templatize for a concrete kit; expired or previously tested claims go to bravos-recheck. Apply the recorded proving choice before execution: auto follows bravos-env and bravos-prove in its authorized scope; ask seeks a decision; schedule leaves the claim queued; none records that it was not tested. Evidence from a real run is required before marking a claim confirmed or refuted. Hand the change to bravos-ship before a PR.
30
31
 
31
32
  ## Never
32
33
 
@@ -63,13 +63,20 @@ if (!base) {
63
63
  base = r.status === 0 && r.stdout.trim() ? r.stdout.trim() : 'origin/main';
64
64
  }
65
65
 
66
- let changed = [];
67
- const d = spawnSync('git', ['diff', '--name-only', '--diff-filter=ACMR', `${base}...HEAD`], { cwd, encoding: 'utf8', timeout: 10000, maxBuffer: 64 * 1024 * 1024, stdio: ['ignore', 'pipe', 'pipe'] });
68
- if (d.error || d.status !== 0) {
69
- const why = d.error ? (d.error.code ?? d.error.message) : (d.stderr || '').trim().split('\n')[0] || `exited ${d.status}`;
70
- notes.push(`git diff failed: ${why}`);
71
- } else {
72
- changed = d.stdout.split('\n').filter(Boolean);
66
+ // @comment -- "Review committed changes since the merge base and what is on disk, including the index and nonignored untracked files. Git's NUL-terminated path output preserves spaces and newlines. A missing remote base still permits reviewing local changes."
67
+ const gitOptions = { cwd, encoding: 'utf8', timeout: 10000, maxBuffer: 64 * 1024 * 1024, stdio: ['ignore', 'pipe', 'pipe'] };
68
+ const ancestor = spawnSync('git', ['merge-base', '--', base, 'HEAD'], gitOptions);
69
+ const from = ancestor.status === 0 ? ancestor.stdout.trim() : 'HEAD';
70
+ if (ancestor.status !== 0) notes.push('no merge base for ' + base + '; reviewing changes since HEAD and untracked files');
71
+ const changed = new Set();
72
+ for (const args of [
73
+ ['diff', '--name-only', '-z', '--no-renames', from, '--'],
74
+ ['ls-files', '-z', '--others', '--exclude-standard'],
75
+ ]) {
76
+ const result = spawnSync('git', args, gitOptions);
77
+ if (result.status === 0) {
78
+ for (const path of result.stdout.split('\0')) if (path) changed.add(path);
79
+ } else notes.push('git ' + args[0] + ' failed: ' + (result.error?.code ?? result.status));
73
80
  }
74
81
 
75
82
  const un = runJson('guardlink', ['unannotated', '--json'], { cwd });
@@ -114,7 +121,7 @@ const picked = pickSlice({
114
121
  worklist: worklistPaths,
115
122
  annotated: paths(un.json?.annotated),
116
123
  excluded: paths(un.json?.excluded),
117
- changed,
124
+ changed: [...changed],
118
125
  inFlight,
119
126
  ownedDirs: [],
120
127
  generated,
@@ -28,7 +28,7 @@ description: "Audit and write the repo's security CI: the bravos PR gate (valida
28
28
  - Write a secret, token, licence or session into a workflow or any committed file.
29
29
  - Interpolate pull-request, issue or comment text, or a branch name, directly into a `run:` line.
30
30
  - Use `guardlink validate . --strict` as a PR gate on a repo with recorded legacy exposures; it fails on every one of them, not on what the PR adds.
31
- - Add a job that runs a live test or scan unattended; that needs the human's authorization typed in a session.
31
+ - Add live testing to the PR gate. Only the reviewed scheduled workflow may replay bound kits under a current scheduled proving grant and committed scope. Check that disabling the policy stops replay before any target contact.
32
32
  - Delete or rewrite a workflow bravos did not write without the user's go-ahead.
33
33
  - Write `@accepts`, `@entitles` or `@confirmed`.
34
34
 
@@ -12,12 +12,12 @@ description: "Bring up a test target the user owns and prepare it for an authori
12
12
 
13
13
  ## Do
14
14
 
15
- 1. Decide the target with the user. The default is the app running on this machine at a loopback address (`127.0.0.1`, `localhost`, `[::1]`). Start it with the repo's own tooling (its compose file, dev server script or desktop build) and wait until it answers. In a bravos workspace each service has its own target: take the URLs from `bravos workspace show` (set a missing one with `bravos workspace target <name> <service>=http://127.0.0.1:<port>`), bring up every service the test crosses, and list every service host in the reviewed scope's `host_allowlist`.
16
- 2. On loopback, a recorded proving preference (`.guardlink/proving.md`, `choice: auto`) is the person's go-ahead for its target: start it with the recorded command and do not ask again. If the user names a non-loopback target, stop and get two things before going on: the host listed in a committed `scope.yaml` that has been through a reviewed PR, and the human's authorization typed by them in this session in their own words. Without both, the target is out of scope; say so and stay on loopback.
15
+ 1. Read the current proving choice before target contact, login or auth verification. Use the owned local app named in the standing authorization or the target explicitly authorized for this invocation. The default is a loopback address (`127.0.0.1`, `localhost`, `[::1]`). Start it with the repo's own tooling (its compose file, dev server script or desktop build) and wait until it answers. In a bravos workspace each service has its own target: take the URLs from `bravos workspace show` (set a missing one with `bravos workspace target <name> <service>=http://127.0.0.1:<port>`), bring up every service the test crosses, and list every service host in the reviewed scope's `host_allowlist`.
16
+ 2. On loopback, a recorded proving preference (`.guardlink/proving.md`, `choice: auto`) is the person's go-ahead for its target: use the recorded target and start command. If the setup wizard left them empty, inspect the repository’s documented development command and listening address. When these match the app the person authorized, record the actual target and start command alongside their original words. Commit the policy and scope before automatic replay. Ask only if the target or authority is ambiguous. If the user names a non-loopback target, stop and get two things before going on: the host listed in a committed `scope.yaml` that has been through a reviewed PR, and the human's authorization typed by them in this session in their own words. Without both, the target is out of scope; say so and stay on loopback.
17
17
  3. Write the scope. Copy `{{SKILL_DIR}}/scope.example.yaml` to `.guardlink/scope.yaml`, or run `cxg pentest scope-init -o .guardlink/scope.yaml` for the full field reference, then narrow `url_allowlist` to the routes under test. `method_allowlist` is a strict bound: cxg refuses every method it does not list, even with `--destructive-ok`, so a test that needs PUT, PATCH or DELETE needs the target's owner to add them in the reviewed PR; never add them yourself. scope-init pre-fills `authorization_attestation` with an example sentence: blank it. Leave that field for the human to fill. Commit it and ship it as a PR for review before any non-loopback run.
18
18
  4. Seed test data with the repo's own fixtures, seed scripts or admin endpoints: the roles and users the threats need, such as two users of different tenants for an ownership check. Name any test that needs production-like data as such, and run it only where that data is synthetic.
19
19
  5. Get a session. On loopback, do it yourself: create the test accounts through the app's own signup, seed script or admin endpoint, write their email and password to a gitignored file under `.bravos/`, and log in with `cxg pentest auth --target <url> --profile <name> --creds-file <file> --login-path <login route>`, one profile per identity a check needs. If the app's login is not a JSON POST, drive the signup and login in your own browser tool and capture the session interactively with `cxg pentest auth --target <url> --profile <name>`. For an authorized non-loopback target, ask the human to capture the session in their own browser with the same command, or to paste a storage state you import with `cxg pentest auth import --storage-state <file> --profile <name> --target <url>`; CI uses the import with a session the human exported once.
20
- 6. Confirm each session is live with `cxg pentest auth verify --profile <name>` before handing the target on, so a run never spends its budget unauthenticated.
20
+ 6. Verify the target URL and scope against the current recorded policy before sending any request. For a fresh local build or launch from this repository, capture the matching worktree witness at that time with `bravos hook replay build <loopback-url>`. Pass that output to bravos-prove in BRAVOS_REPLAY_BUILD, recording the actual target and revision. A hash computed beside a previously running app does not establish which code it serves. If a remote or already-running service cannot be tied to this build, report observations without updating the current claim. Confirm each required session is live with `cxg pentest auth verify --profile <name>` before handing the target on, so a run never spends its budget unauthenticated.
21
21
  7. Record the target URL, the profile names, the scope path and whether the target is loopback, and hand them to bravos-prove.
22
22
 
23
23
  ## Never
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: bravos-prove
3
- description: "Run the authorized test against a target the user owns and record what it showed: export the claims for cxg, replay the kits written in this session, let cxg generate probes for the rest through a model API, read the report's buckets and exit code, and write outcomes back only through guardlink's hypothesis ledger. Use when asked to prove, test or verify a finding, to check whether an exposure is exploitable, or after bravos-templatize and bravos-env have prepared a run."
3
+ description: "Prove a new or changed GuardLink claim, or replay it after a fix, against an authorized target. Use the active coding agent to author a missing kit, run the selected kit through CXG, and record the evidence for that exact claim."
4
4
  ---
5
5
  # Bravos prove: an authorized run, and only a run decides
6
6
 
@@ -12,18 +12,14 @@ description: "Run the authorized test against a target the user owns and record
12
12
 
13
13
  ## Do
14
14
 
15
- 1. Check the preconditions from bravos-env: 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 existing kits only; medium: also cxg generation for exposures without a kit, `--max-templates 8`, after asking about the spend; high: `--max-templates 32` with `--enable-chaining`; max: every testable class, spend pre-approved (no question).
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.
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; and whether cxg may generate probes through a model API, which spends money. Record their answer in `.guardlink/proving.md`: lines `choice: auto|ask|schedule|none`, `target: <loopback url>`, `start: <start command>`, `generation: yes|no`, their words quoted verbatim, and `— confirmed by <their name>, <date>`. Then follow it: `auto` proceeds on that target with their quoted words as the attestation and, with `generation: yes`, the spend approved; `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
- 3. Export the claims cxg reads: `guardlink sarif . --profile pentest -o whitebox/findings.sarif`.
18
- 4. Web or Electron target: replay the kits written in this session with `cxg pentest run --codebase . --target <url> --auth <profiles> --no-author --template-dir .guardlink/cxg-replay/ --scope-file .guardlink/scope.yaml --attestation "<the human's words>" --session-dir .guardlink/pentest-findings/<run> --ci`, adding `--target-type electron` for an Electron app. `<profiles>` is every login the kits' `@requires_identities` lines name, comma-separated (`victim,attacker` for an IDOR kit), each verified in bravos-env; a kit whose login is missing is skipped. `--no-author` keeps a replay to zero model calls: without it cxg can rewrite an ambiguous probe through the claude CLI. Copy the attestation verbatim from what the human typed; leave the flag off on loopback if they gave none. In a bravos workspace, run each kit against the URL of the service that owns its file (`bravos workspace show` lists the services, their URLs and the calls between them); a chain that crosses services is run one hop at a time, each hop against its own service's URL under that service's scope and authorization, with the previous hop's result carried as the next hop's input — never one run pointed at several hosts.
19
- 5. Exposures with no kit yet: let cxg generate probes from the exported claims, steered by the operator guidance. First tell the user the run calls a model API (up to the template budget) and get their go-ahead, unless they already approved the spend (effort max, or a standing line saying so); then run `cxg pentest run --codebase . --target <url> --auth <profile> --ai --ai-provider anthropic --max-templates 8 --skills-file .guardlink/operator-guidance.md --scope-file .guardlink/scope.yaml --attestation "<the human's words>" --session-dir .guardlink/pentest-findings/<run> --ci` (use `openai` if that is the key the user has). Copy every generated template that confirmed or refuted into `.guardlink/cxg-replay/` so the next run replays it.
20
- 6. Network or CLI templates from the translate method: run `cxg scan --scope <url> --template-dir .guardlink/cxg-templates/ --output .guardlink/pentest-findings/<run> --output-format json,sarif`, with a loopback URL or `cli:///absolute/path/to/binary` as the scope. That folder holds scanner templates only (bravos-templatize keeps probes in `.guardlink/cxg-replay/`); if a JavaScript probe is in it, cxg runs it under its default scope, so move the probe out, or add `--scope-file .guardlink/scope.yaml --auth <profiles> --session-dir .guardlink/pentest-findings/<run>` before running.
21
- 7. Read the exit code before the report. For `cxg pentest run`: 0 none confirmed, 1 no templates ran, 2 confirmed findings, 3 hard-killed (5xx streak, scope violation, target died), 4 refused (at pre-flight, or a supplied probe was skipped for a missing login or refused), 5 session dead in CI. On 3 or 5 stop: nothing was proven, so report the cause and hand back to bravos-env. On 4 read the report before concluding: its `status`, `auth_skipped` and `probe_refusals` say what was skipped and why, and any probe that did run keeps its confirmed or refuted result. Write back those results, report the skipped ones as untested with their cause, and hand a missing login to bravos-env. For `cxg scan` with probes: 2 means confirmed, 4 a probe refused.
22
- 8. Read the report's buckets: confirmed, refuted (a mitigation held), ambiguous, and not run with its cause. Ambiguous and not-run results prove nothing either way; report them as untested.
23
- 9. Write back the confirmations: `guardlink hypothesis confirm --from-scan .guardlink/pentest-findings/<run>/report.json --write`. It records only findings whose claim key resolves, and writes the source line only for uncontested ones.
24
- 10. Record each refuted result against its claim: `guardlink hypothesis refute <file:line> --evidence "<request sent and response received>"`, quoting the report entry.
25
- 11. Run `guardlink hypothesis list --state confirmed --json` and report each new confirmation with its threat, asset and file:line, plus the refutations and every result left untested.
26
- 12. Hand confirmed threats to the user as fix-first, and to bravos-recheck once a fix lands.
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
+ 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 (the consent commit when Git has no local origin/HEAD). The earlier wizard’s “only replay tests I approved” choice retains that restriction.
19
+ 5. Pass the build witness that bravos-env captured at launch in BRAVOS_REPLAY_BUILD. Without fresh build provenance, retain the observation and leave the current-code claim pending. Under a recorded automatic loopback policy, run `bravos hook replay run <kit.js>`. For a one-time approved run under an ask policy, use `bravos hook replay run-once <kit.js>` with the target in BRAVOS_SCAN_TARGET and the person's exact words in BRAVOS_REPLAY_ATTESTATION for that invocation. Keep private identity state outside Git. A scheduled-only policy hands the kit to bravos-schedule. A disabled policy leaves the claim pending. The helper selects one file through plain CXG scan with model authoring disabled. Only evidence tied to the exact claim, tested source and kit is eligible for writeback.
20
+ 6. Read the individual native CXG execution and ledger result. A reproduced exploit needs an engine-adjudicated confirmation. A held control needs observed denial and a working positive control. Missing roles, ambiguous tests, incomplete imports, a different target build or stale inputs stay pending with the reason. Exit 4 can include both a refusal and valid results from other probes. An ordinary scanner's template-reported match is a lead for a runtime test. Keep private HTTP and auth material out of reports and commits.
21
+ 7. For workspaces, bind each hop to its own service URL and authorized scope. For Electron, use its configured launch and verified desktop profile. Ordinary network or local CLI scanner templates use the scanner contract and produce leads. Use explicit CXG orchestration only when the requested target or technique needs it, for example Tauri's in-process proof or operator-requested CXG model generation. Check the CXG pentest run help for the selected platform, method and authorization before execution. For generation require the recorded permission for the API spend, available provider credentials and a specific threat selector for fresh web probes. Use the reviewed scope, approved target and identities. Keep the resulting native evidence separate. For an independently stamped result, the GuardLink import is `guardlink hypothesis confirm --from-scan <native-report.json> --write`; check every intended claim key and tested anchor, import only an uncontested exact match, and reread the ledger. A missing key, changed build or failed write is unrecorded. Boundary outcomes use GuardLink's boundary ledger.
22
+ 8. Report which claims were confirmed or refuted, which still need testing and which were actually recorded. Keep the run ID and the kit for bravos-recheck.
27
23
 
28
24
  ## Never
29
25
 
@@ -32,14 +28,14 @@ description: "Run the authorized test against a target the user owns and record
32
28
  - Write `--attestation` text the human did not type, here or in `.guardlink/proving.md`.
33
29
  - Record a proving preference the person did not state, or read one as covering more than it says: it never covers a non-loopback target or a destructive class.
34
30
  - Use `--destructive-ok` unless the target is a disposable loopback instance and the human asked for it.
35
- - Write `@confirmed` yourself, or treat reading code as a confirmation; only `guardlink hypothesis confirm --from-scan` from a real report writes it.
31
+ - Write `@confirmed` yourself, or treat reading code as a confirmation; the replay helper uses GuardLink to persist the actual engine verdict and rereads the intended entry.
36
32
  - Call an exposure refuted because a run found nothing, or because the run was killed, refused or never ran its template.
37
33
  - Write `@accepts` or `@entitles`.
38
34
 
39
35
  ## Done when
40
36
 
41
- - The run exited 0 or 2 and its report was read bucket by bucket, or you reported why it stopped.
42
- - Every confirmed finding went through `guardlink hypothesis confirm --from-scan`, and every refutation cites its request and response.
37
+ - Each selected kit has a native outcome and a verified ledger result, or an explicit reason it remains pending.
38
+ - Every recorded outcome is bound to the selected claim and tested inputs. A refutation includes evidence of the working control.
43
39
  - For each claim you reported its three states: open or mitigated, confirmed, refuted or untested, and verified or stale, plus what was not tested.
44
40
 
45
41
  ## What it leaves for the next skill
@@ -16,9 +16,9 @@ description: "Keep findings from going stale after code changes: list the claims
16
16
  2. List what went stale: run `guardlink ci -f json` and take each `stale[]` entry whose file is in `git diff --name-only <base>...HEAD`. Then widen it past the changed files. With the code graph (its MCP tools, or `bravos graph <question> --json` — same answers; see bravos-codegraph) (briefing `Code graph:` says `current`; rebuild with `no-exec` when `diverged`): `codegraph_impact` on each changed symbol, and `codegraph_callers` where a control moved, give the code whose path runs through the change; add the claims in those files to the list. A fix that removes the only route to a sink (`codegraph_entry_reach` now says unreachable) is a reason to replay its kit and refute it with a run, never a refutation by itself. Read `verdict` and `confidence` first. Without the graph, say "code graph unavailable; rechecking the changed files only". When SAST is available and a run exists, rerun it on the changed files (bravos-sast, `--scope <file>` for each) and compare with `bravos-cli diff <new>.json <old>.json`: a finding that is gone is a reason to replay its kit and refute it with a run, never a refutation by itself. With SAST unavailable, say so and skip it.
17
17
  3. For each stale claim, re-read the code beneath it and decide whether the claim still says what the code does. If it does not, fix the annotation in this session with bravos-annotate's rules (write an `@audit` beside a claim you did not write rather than editing it).
18
18
  4. Re-lock only the claims you re-read and still hold: preview with `guardlink verify <file:line> --dry-run`, then run `guardlink verify <file:line>`. Never re-lock a claim you did not read.
19
- 5. List confirmed threats on the changed files: `guardlink hypothesis list --state confirmed --json`, keeping those in the diff.
20
- 6. Replay each one's retest kit against the authorized target from bravos-env: `cxg pentest run --codebase . --target <url> --auth <profile> --template-dir .guardlink/cxg-replay/ --scope-file .guardlink/scope.yaml --attestation "<the human's words>" --session-dir .guardlink/pentest-findings/<run> --ci`. Copy the attestation verbatim from what the human typed; leave the flag off on loopback if they gave none. No kit yet: hand the threat to bravos-templatize first.
21
- 7. Read the result as bravos-prove does. Still confirmed: the fix did not hold; say so. Refuted with the same request: record it with `guardlink hypothesis refute <file:line> --evidence "<request sent and response received>"`, and tell the user the confirmation line in the source is theirs to remove. Killed, refused or not run: nothing was rechecked.
19
+ 5. Use `guardlink hypothesis list --json` to select the affected exposure keys, including retest and previously tested claims whose result expired. Resolve a sidecar declaration against the logical application source in the model. Include affected callers and shared controls even when the route itself did not move.
20
+ 6. Follow bravos-prove with the previously bound kit and original positive control. Check the committed .guardlink/scope.yaml and the effective proving policy. Rebuild or restart the authorized target from the changed code before replay. If no matching kit exists, use bravos-templatize. Replaying with the same test bytes gives a comparable result.
21
+ 7. Confirm the ledger records this run on the intended claim. A previously reproduced exploit that no longer triggers is still pending until the engine supplies conclusive evidence that the control held. Report partial, refused and unrecorded outcomes individually. Preserve the earlier reproduction in history.
22
22
  8. Check the fix added nothing: `guardlink diff <base> --fail-on-new --markdown`, then `guardlink lint . --since <base> --json`, applying each `fix` only to lines this session wrote.
23
23
  9. Re-read the queue with `guardlink hypothesis next --json` and name the next item.
24
24
 
@@ -18,7 +18,7 @@ description: "Write a crisp, evidence-bound white-box VAPT write-up in this sess
18
18
  3. Read `.guardlink/intent.md` (in the bundle as `intent.text`): its Assumptions name the attacker starting positions, the configuration baseline and the scope decisions. Keep the tester's access (source code, admin credentials, the loopback target) apart from what an attacker needs: every finding states the attacker's prerequisites, never the tester's. Then collect what a reader needs to rebuild the test, from the run folders the bundle lists, `.guardlink/proving.md` (target and start command), `.guardlink/scope.yaml` and the session's own history: how the product was built; every config and feature-flag change; how keys and accounts were made and which permission each held; what was seeded; and every helper written to test it (a stub handler, a gRPC client or worker), with how to install and run it. Copy the config files and scripts, never keys or tokens, into the run folder so the report can point at them.
19
19
  4. Consolidate before you write: group exposures that share one root cause into one finding (cite every EXP id it covers); order findings by remediation priority (exposure, asset sensitivity, prerequisites, compensating controls), kept apart from technical severity; build an attack narrative only from steps the evidence links (a run's chained steps, flows in the model, a code-graph call chain), and cite each step.
20
20
  5. Write `.bravos/reports/<id>/report.md` from the template for the kind: `{{SKILL_DIR}}/assessment.md`, `{{SKILL_DIR}}/finding.md`, `{{SKILL_DIR}}/retest.md` or `{{SKILL_DIR}}/brief.md`, in the voice `{{SKILL_DIR}}/style.md` sets. Write for the team that has to act on it: plain words first; what the attacker wants and what they need; why it is a vulnerability; the weaknesses one by one and how they chain step by step; the environment and the roles table; a cxg reproduction (`cargo install cert-x-gen`, the template, the exact `cxg scan` command and its expected output); granular manual steps; what held; and the fix with how to check it. Evidence ids go in the closing Evidence section, not in the prose. When the proof is a script rather than a cxg template, hand it to bravos-templatize to become one, and have bravos-prove replay it under the person's authorization before you quote its output; otherwise say the cxg command was not run.
21
- 6. Give each finding a `**Status:**` line with the bundle's computed level for what it cites, word for word: `reproduced at runtime`, `control held at runtime`, `established by code or configuration review`, or `suspected, awaiting validation`. Repeat it in the Evidence section with the evidence ids in parentheses (the top line may say "see Evidence"). A weaker label than the evidence supports is allowed; a stronger one is not. "Not reproduced" names the conditions tested, from the run's not-run causes.
21
+ 6. Use each candidate’s current evidence level. A stale result describes the earlier build and needs a replay. Scanner-template observations, execution-status rows, ambiguous probes and missing sessions cannot establish a runtime verdict. Cite the native engine finding or positive mitigation evidence for a replay and record skipped, refused and truncated coverage. Give each finding a `**Status:**` line with the bundle's computed level for what it cites, word for word: `reproduced at runtime`, `control held at runtime`, `established by code or configuration review`, or `suspected, awaiting validation`. Repeat it in the Evidence section with the evidence ids in parentheses (the top line may say "see Evidence"). A weaker label than the evidence supports is allowed; a stronger one is not. "Not reproduced" names the conditions tested, from the run's not-run causes.
22
22
  7. Write coverage with its denominator ("cross-tenant reads exercised on 3 of 11 routes"; "83% of files, 1,417 of 1,712"), list the controls that held next to the weaknesses, and keep raw tool output in the appendices. Quote requests and responses from the run evidence with tokens and credentials redacted; the bundle already redacts what it recognises.
23
23
  8. Severity: give the rating and its rationale in this application's context. Use CVSS only when you can state the version and the full vector from facts in the bundle; never a bare score.
24
24
  9. Check: `bravos report check <id>`. Fix every error and rerun until it passes; read the warnings (long paragraphs, vague titles) and fix the ones that would slow a reader down.
@@ -19,7 +19,7 @@ description: "Set up recurring security upkeep with each harness's own mechanism
19
19
  3. Nightly workflow: run `bravos init --ci` (or `bravos sync --ci` in a repo bravos already set up), keep the variant for the team's harness (`bravos-nightly-claude.yml` or `bravos-nightly-codex.yml`) and delete the other. A team on GitHub Copilot uses `bravos init --workflows nightly-copilot` instead: it opens an issue each night and assigns it to Copilot's cloud agent, which needs the secret `COPILOT_ASSIGN_TOKEN` (a Copilot user's personal access token) and `BRAVOS_LICENCE` as an Agents secret. Tell the user the secret it needs (`CLAUDE_CODE_OAUTH_TOKEN` for Claude Code, made once with `claude setup-token` so the run uses their Claude plan, or `OPENAI_API_KEY` for Codex) and to allow GitHub Actions to create pull requests in the repo settings.
20
20
  4. Cloud scheduled task: a skill cannot create one. Give the user the prompt to paste into `/schedule`: follow bravos-annotate in slice mode on the next unannotated files, run its lint gate, and open one pull request whose body carries bravos-ship's Security gate section. Tell them the task clones the default branch and runs at most hourly.
21
21
  5. State the spend before the user starts any of them: files per run (the default slice is five) times runs per day, and that each run spends model tokens.
22
- 6. Nightly scan, opt-in: it replays the kits in `.guardlink/cxg-replay/` and records outcomes through `guardlink hypothesis confirm --from-scan`, and it runs only when `.guardlink/scope.yaml` is committed with an `authorization_attestation` a human typed and reviewed in a PR, and the repo variable `BRAVOS_SCAN_TARGET` is a loopback URL the job starts (repo variable `BRAVOS_APP_START`) or a host in that scope's `host_allowlist`. Otherwise the step prints why it skipped. Tell the user which variables to set and that the scope file is their standing authorization.
22
+ 6. For the Claude Code and Codex nightlies, select scheduled proving in the committed human policy and review the scope and exact target. Only checked-in, bound JavaScript kits are eligible. Configure BRAVOS_SCAN_TARGET and BRAVOS_APP_START for the disposable local build and the identities each kit requires. Keep session state in CI secrets. A disabled or ask-only policy skips the scan. Report missing prerequisites, partial executions and unrecorded results separately. Copilot schedules annotation only.
23
23
 
24
24
  ## Never
25
25
 
@@ -19,7 +19,7 @@ description: "The no-mistakes security gate before a pull request: validate the
19
19
  3. Run `guardlink lint . --since <base> --json`. This judges every claim on the branch, not only yours. Apply an entry's `fix` only to a line this session wrote, and rerun until `summary.errors` is 0. For `accepts-written`, `entitles-written` or `confirmed-without-evidence` on any other line, do not touch it: stop and report it to the user.
20
20
  4. Run `guardlink diff <base> --fail-on-new --markdown`. Exit 0 means no new unmitigated exposure. A non-zero exit lists new exposures with no `@mitigates`; an `@exposes` plus `@audit` written on this branch is new exposure and stays listed by design. Do not try to turn it green: report each listed exposure as open in the Security gate section and stop there for that exposure. Fixing the code or accepting the risk is the human's decision.
21
21
  5. Run `guardlink paths --json` and report how many undefended source-to-sink paths it lists. This is informational in this version and does not block. In a bravos workspace, also read the cross-service edges (`bravos workspace show --json`, `export.edges`) whose `dstMember` is this service and whose target id is declared in a file this branch changed: report them as "callers in other services" in the Security gate section, so the reviewer checks those callers too.
22
- 6. If the code graph is present, call `codegraph_annotation_gaps` on the changed files and send each gap to bravos-annotate (diff playbook).
22
+ 6. Review the security behavior in the changed hunks, including changes inside already annotated handlers. Check callers, affected guards and source or sidecar locations. If the graph is unavailable or reports incomplete resolution, inspect the changed code with the GuardLink diff playbook and report the gap. If the code graph is present, call `codegraph_annotation_gaps` on the changed files and send each gap to bravos-annotate (diff playbook).
23
23
  7. Run `guardlink ci -f json`. A `confirmed[]` entry whose `location.file` is in `git diff --name-only <base>...HEAD` blocks the PR unless a `@ticket` line written by a human carries it. Check who wrote the `@ticket` line with the MCP tool `guardlink_blame` on the file, or `git log -L <line>,<line>:<file>`, or ask the user. A code change does not clear it: only a human removes the confirmation after a reproduction shows the exploit no longer works. If it blocks, tell the user the threat, asset and file:line, and do not ship.
24
24
  8. Rerun steps 2–4 until validate and lint exit 0, and diff exits 0 or every new exposure it lists is reported as open.
25
25
  9. If the repo has `.guardlink/report.json`, refresh it with `guardlink parse . -o .guardlink/report.json` and include it in the change.
@@ -12,13 +12,13 @@ description: "Turn the threat model's open exposures into correct, testable cxg
12
12
 
13
13
  ## Do
14
14
 
15
- 1. Read the open exposures: `guardlink ci -f json` (`exposures[]`, `confirmed[]`) or the MCP tool `guardlink_lookup` with `unmitigated`. Pick the ones a request or a local invocation can show, and leave pure design or process gaps for an `@audit` note. 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: exposures in changed files; medium: the top 5 from `guardlink hypothesis next --json`; high: the top 20; max: every open exposure.
16
- 2. Get the method, in this order. First open `{{SKILLS_ROOT}}/guardlink-translate/SKILL.md` and follow it (`guardlink sync` writes it; if it is missing, say `guardlink sync` would add it). Else call the MCP tool `guardlink_translate` (server `guardlink`) with `prompt: "<scope>"`; it returns the prompt, its output locations and a separate execution step. Else, from a shell, run `guardlink translate --stdout "<scope>"` only if `guardlink translate --help` lists `--stdout`, and follow the prompt it prints. You are the agent: do the work here. If none of the three is available, tell the user this guardlink offers no way to hand the method to the agent already in session (guardlink PR #98 adds `--stdout` back), and stop. Never fall back to a bare `guardlink translate`: it launches Claude Code.
15
+ 1. Select affected keys from `guardlink hypothesis list --json` or the ranked `guardlink hypothesis next --json`. Include untested exposures with declared controls and previously confirmed claims marked retest. Use the pentest SARIF export to resolve the exact logical source reference. A pure design claim can stay pending with its reason. 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: exposures in changed files; medium: the top 5 from `guardlink hypothesis next --json`; high: the top 20; max: every open exposure.
16
+ 2. Follow the installed `{{SKILLS_ROOT}}/guardlink-translate/SKILL.md`. Request the probe contract for web runtime proof, with the exact threat reference and the known route, roles and intended assertion. Use the guardlink_translate MCP tool or `guardlink translate --stdout --contract probe --threat <threat@file:line>` to obtain instructions for the current agent. With named profiles, supply the per-threat context pack. Use the scanner contract for ordinary scanner observations. If in-session translation is unavailable, run `bravos doctor` and report the missing interface. The active coding agent writes the test.
17
17
  3. Find the request that reaches each sink before you write its template. With the code graph (its MCP tools, or `bravos graph <question> --json` — same answers; see bravos-codegraph) (the briefing's `Code graph:` line says `current`, or `diverged` until a `no-exec` rebuild, bravos-codegraph step 2): `codegraph_call_chain` from the entry points (`codegraph_entry_points`, `codegraph_routes`) to the claim's symbol gives the route or RPC method, its handler and the parameters that flow into the sink; `codegraph_auth_boundary` on that route gives the identity the request needs (anonymous, a signed-in tenant, admin). Target that route with those parameters and the matching auth profile, put the chain (entry → … → sink) in the template's notes, and when several entry points reach the sink template the least privileged first. When `codegraph_entry_reach` says no entry point reaches it at high confidence, write no template: record "unreachable from any entry point per code graph" in the README and hand the claim to bravos-annotate to re-rate. Read `verdict` and `confidence` first; `unknown` or `insufficient_resolution` is not determined, never unreachable. Without the graph, trace the route from the handler by reading the code and say "code graph unavailable; traced by reading". A SAST finding joined to the claim (`bravos sast candidates`) gives its `route`, `entryPoint` and taint path too; use it alongside the graph's chain, and note it in the template. SAST findings not in the threat model go to bravos-annotate first, since templates come from claims. With no SAST report or SAST unavailable, carry on without it.
18
18
  4. Write the templates under `.guardlink/cxg-templates/`, one per threat, following the engine contract and evidence shape the method gives. Keep every check non-destructive and scoped to confirming its one threat. Scanner templates (YAML, Python, shell) go there; JavaScript probes (`async function cxgProbe(cxg)`, `--contract probe`) go under `.guardlink/cxg-replay/` instead, because `cxg scan --template-dir` runs any probe it finds under cxg's default scope, not `.guardlink/scope.yaml`. In a probe, reach the target only through `cxg.fetch*` with well-formed arguments: cxg refuses at run time a probe that uses WebSocket, XMLHttpRequest, EventSource, `navigator.sendBeacon`, dynamic `import()`, or script or `innerHTML` injection, and `cxg template validate` does not catch it.
19
19
  5. Validate: `cxg template validate .guardlink/cxg-templates/ --recursive --json`, and the same for `.guardlink/cxg-replay/`. It exits 1 when any template fails; a banner line can precede the JSON, so read from the first `{` or `[`. Fix each error and rerun until it reports none.
20
20
  6. Record repo context for cxg's own generator. Copy `{{SKILL_DIR}}/operator-guidance.md` to `.guardlink/operator-guidance.md` if it is not there, and fill each section from the code: framework, auth shape, test identities, known false positives, out-of-bounds routes. bravos-prove passes it as `--skills-file` when cxg generates probes for exposures that have no kit.
21
- 7. For a confirmed threat that needs a retest kit, write a hand-written replay probe under `.guardlink/cxg-replay/`, kept apart from the scan templates. It carries `// @attach_scheme: path`, a `// @requires_identities:` line naming every login it needs (both sides of an IDOR; `anonymous` is the reserved no-login role), and no claim-identity stamps, so `--template-dir .guardlink/cxg-replay/` replays it against the same route. Keep that folder JavaScript probes only (a README is fine): one scanner file (`.yaml`, `.py`, `.sh`) there makes cxg refuse the whole replay run before it starts. cxg reads the folder recursively.
21
+ 7. For a first test or regression kit, write a single JavaScript probe in .guardlink/cxg-replay/. Include an exact `// @guardlink_threat: threat@logical/file:line`, `// @attach_scheme: path`, the required identity names, and a precise test with a positive control. Run `bravos hook replay bind <kit.js>` before executing it. The binding command associates the kit with the key of the current GuardLink exposure. Review that mapping when the claim is edited or moved. Leave native CXG identity stamps to the engine.
22
22
  8. Apply the oracle rule: a vulnerability class cxg cannot judge from a response has no oracle. Record it in `.guardlink/cxg-templates/README.md` as unsupported, with the threat id and why, instead of writing a template that pretends to prove it. An invariant threat (`#inv-…`, from intent.md) maps to the cxg class that can judge it: another user's or tenant's data → `idor`; a role or permission gained → `privilege_escalation`; a field the caller should not set → `mass_assignment`; a check bypassed by concurrent requests → `race_condition`; a workflow step skipped or reordered → `business_logic`. Record each invariant's class in the README.
23
23
  9. Commit the templates, the README and the filled guidance together, and hand the template ids and threat ids to bravos-prove.
24
24