@bugb-technologies/bravos 1.6.0 → 1.8.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/dist/cli.js +82 -17
  2. package/dist/codegraph.js +21 -0
  3. package/dist/context.js +36 -0
  4. package/dist/graphbin.js +2 -0
  5. package/dist/guide.js +7 -5
  6. package/dist/help.js +24 -5
  7. package/dist/install.js +2 -1
  8. package/dist/lock.js +1 -0
  9. package/dist/mcp.js +18 -3
  10. package/dist/palette.js +4 -4
  11. package/dist/prefs.js +47 -0
  12. package/dist/review-server.js +4 -4
  13. package/dist/review-wait.js +76 -0
  14. package/dist/review.js +103 -18
  15. package/dist/start/answers.js +33 -4
  16. package/dist/start/index.js +138 -57
  17. package/dist/upkeep.js +89 -0
  18. package/dist/watch-frame.js +67 -42
  19. package/dist/watch.js +21 -7
  20. package/docs/GUIDE.md +17 -5
  21. package/docs/UPGRADING.md +27 -0
  22. package/hooks/lib/autopilot.mjs +3 -18
  23. package/hooks/lib/briefing.mjs +250 -173
  24. package/hooks/lib/graph-autobuild.mjs +131 -0
  25. package/hooks/lib/palette.mjs +4 -4
  26. package/hooks/lib/prefs.mjs +108 -0
  27. package/hooks/lib/refresh.mjs +45 -1
  28. package/hooks/lib/setup.mjs +1 -1
  29. package/hooks/lib/snapshot.mjs +19 -1
  30. package/hooks/session-start.mjs +29 -2
  31. package/package.json +1 -1
  32. package/skills/bravos/SKILL.md +4 -3
  33. package/skills/bravos-annotate/SKILL.md +2 -2
  34. package/skills/bravos-context/SKILL.md +7 -6
  35. package/skills/bravos-env/SKILL.md +2 -2
  36. package/skills/bravos-env/scope.example.yaml +2 -1
  37. package/skills/bravos-prove/SKILL.md +2 -2
  38. package/skills/bravos-recheck/SKILL.md +1 -1
  39. package/skills/bravos-resync/SKILL.md +1 -1
  40. package/skills/bravos-ship/SKILL.md +1 -1
  41. package/skills/bravos-templatize/SKILL.md +1 -1
  42. package/templates/review/review.html +369 -124
@@ -13,13 +13,13 @@ description: "Prove a new or changed GuardLink claim, or replay it after a fix,
13
13
  ## Do
14
14
 
15
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
- 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>`. 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 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.
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.
19
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
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
21
  7. For workspaces, bind each hop to its own service URL and authorized scope. Every run is plain `cxg scan`, through the replay helper or directly with the same scope, attestation and identities: for Electron add `--target-type electron` with `--app-cmd` or `--app-binary` and the verified desktop profile; for Tauri's in-process proof add `--tauri-prove`. Ordinary network or local CLI scanner templates use the scanner contract and produce leads. Probes are written in this session by bravos-templatize, never generated by cxg. Use the reviewed scope, approved target and identities, and keep the 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. After a recorded engine confirmation, offer to promote the verified kit into `security/` (or `.guardlink/config.json`'s `security_tests_dir`) as a curated regression test. With the person's agreement, review its scope, stable oracle and runner, then retain only portable test code; keep credentials and raw run evidence outside Git. Confirmation alone never promotes a kit. Keep the run ID and replay kit for bravos-recheck.
22
+ 8. Report which claims were confirmed or refuted, which still need testing and which were actually recorded. After a recorded engine confirmation, offer to promote the verified kit into `security/` (or `.guardlink/config.json`'s `security_tests_dir`) as a curated regression test, and say why: a promoted kit runs in every pre-PR check, so the fix cannot regress unnoticed. With the person's agreement, review its scope, stable oracle and runner, then retain only portable test code; keep credentials and raw run evidence outside Git. Confirmation alone never promotes a kit. Keep the run ID and replay kit for bravos-recheck.
23
23
 
24
24
  ## Never
25
25
 
@@ -36,7 +36,7 @@ description: "Keep findings from going stale after code changes: list the claims
36
36
  - Every confirmed threat on a changed path was replayed, or you said why it was not.
37
37
  - `guardlink diff <base> --fail-on-new --markdown` exits 0, or each new exposure it lists is reported as open.
38
38
  - You named the three states for each claim you touched and what was not tested.
39
- - If a dashboard was built earlier (the briefing's `Dashboard:` line, or one you opened this session), you said it is now behind these changes and offered to rebuild it with `bravos dashboard`.
39
+ - If a dashboard was built earlier (the briefing's `Dashboard:` line, or one you opened this session), you rebuilt it with `bravos dashboard --no-open` and gave the path.
40
40
 
41
41
  ## What it leaves for the next skill
42
42
 
@@ -13,7 +13,7 @@ description: "Carry annotation work that never reached the base branch onto it,
13
13
  ## Do
14
14
 
15
15
  1. Find the base: `git symbolic-ref -q --short refs/remotes/origin/HEAD` prints `origin/<base>` (if empty, use `origin/main`). Run `bravos resync --list` to see how far this checkout is behind and which idle branches carry `.guardlink/` work the base lacks. Tell the user what you found in two lines and ask before you move their checkout.
16
- 2. Make uncommitted work safe before anything else: on the old branch, commit it as it is with a message that says it is unreviewed work in progress (`git add -A` then `git commit -m "wip: unreviewed annotation drafts, kept for bravos resync"`). That commit is the only copy; a stash can be popped by another session, so never stash.
16
+ 2. Make uncommitted work safe before anything else. It holds the person's own code as well as annotations, so say what you are about to commit and ask once; then, on the old branch, commit it as it is with a message that says it is unreviewed work in progress (`git add -A` then `git commit -m "wip: unreviewed annotation drafts, kept for bravos resync"`). That commit is the only copy; a stash can be popped by another session, so never stash.
17
17
  3. Start fresh from the base: `git fetch origin`, then `git switch -c resync/<old-branch> origin/<base>` (in a worktree when this checkout is shared with another session).
18
18
  4. Preview: `bravos resync --from <old-branch>`. Read the counts: sidecars to carry, sidecars both sides have, definitions to carry, possible duplicates, and files changed since the claims were written. With inline annotations it copies nothing and says to bring the commits over with `git cherry-pick` or `git merge` instead; do that, then continue at step 7.
19
19
  5. Apply: `bravos resync --from <old-branch> --apply`. It writes the sidecars and a marked block of carried definitions, runs `guardlink reanchor . --apply`, validates, and saves the full lists to `.bravos/resync/last.json`.
@@ -14,7 +14,7 @@ description: "The no-mistakes security gate before a pull request: validate the
14
14
 
15
15
  **Plan check first.** The pre-PR gate is on the Team plan. Run `bravos licence --json` once per session (the briefing's `Plan:` line says the same); if `licensed` is false, tell the person in two sentences what this skill would do here and that it needs a Team licence — `bravos account activate` starts a 30-day trial with no card, or https://account.bugb.io/pricing — then stop, and do nothing else from this skill. A licence in grace still counts.
16
16
 
17
- 1. Find the base. Commit or stash work in progress first; the gate judges `HEAD`. The default branch is `git symbolic-ref -q refs/remotes/origin/HEAD` (strip `refs/remotes/origin/`; if it prints nothing, use `main`). Run `git fetch origin <default>` so the merge-base is current (if the fetch fails, offline or with no `origin`, say so and continue with the local ref), then `<base>` = `git merge-base HEAD origin/<default>`. Every gate below is deterministic and spends no model. 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: the deterministic gates (steps 2–4); medium: also the code-graph gaps; high: also SAST; max: also bravos-recheck on the changed paths.
17
+ 1. Find the base. The gate judges `HEAD`, so commit work in progress first, with the person's go-ahead (for Bravos's own files the briefing's `Commits:` line is their standing answer; for their code, or with no such line, ask once per session unless they already asked for commits); never stash, because another session can pop a stash. The default branch is `git symbolic-ref -q refs/remotes/origin/HEAD` (strip `refs/remotes/origin/`; if it prints nothing, use `main`). Run `git fetch origin <default>` so the merge-base is current (if the fetch fails, offline or with no `origin`, say so and continue with the local ref), then `<base>` = `git merge-base HEAD origin/<default>`. Every gate below is deterministic and spends no model. 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: the deterministic gates (steps 2–4); medium: also the code-graph gaps; high: also SAST; max: also bravos-recheck on the changed paths.
18
18
  2. Run `guardlink validate .` and fix what it reports.
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.
@@ -20,7 +20,7 @@ description: "Turn the threat model's open exposures into correct, testable cxg
20
20
  6. Record repo context for the probes you write. 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. Read it before writing each kit; cxg never generates probes for this repository.
21
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. A rule that holds has its `@exposes` beside a `@mitigates` (bravos-annotate step 5), and its kit is a regression test: sign in as the role or user the rule forbids, make the request the rule is about, and report a finding only when it succeeds; a refusal is the expected result and records the rule as held. Bind it to that `@exposes` like any other kit. If cxg cannot tell a refusal from a success for that request, record the rule as unsupported instead of writing a kit that always passes.
23
- 9. With the person's go-ahead (ask once per session unless they already asked for commits), commit the templates, the README and the filled guidance together, and hand the template ids and threat ids to bravos-prove.
23
+ 9. With the person's go-ahead (the briefing's `Commits:` line is their standing answer; with no such line, ask once per session unless they already asked for commits), commit the templates, the README and the filled guidance together, and hand the template ids and threat ids to bravos-prove.
24
24
 
25
25
  ## Never
26
26