@bugb-technologies/bravos 1.5.0 → 1.5.2

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/cli.js CHANGED
@@ -786,16 +786,18 @@ export function buildProgram(io, result) {
786
786
  }));
787
787
  program
788
788
  .command('dashboard [dir]')
789
- .description("One page for the repository's security picture, opened in the browser: GuardLink's threat model with who introduced and fixed each exposure and what changed since the default branch, and on the Team plan the code graph (map, owners, coupling, attack surface, entry points). Written to .bravos/dashboard/index.html (git-ignored); one self-contained file, no server, no network, no model.")
789
+ .description("One page for the repository's security picture, opened in the browser: GuardLink's threat model with who introduced and fixed each exposure and what changed since the default branch, and on the Team plan the code graph (map, owners, coupling, attack surface, entry points). Rebuilt from the code every time: on the Team plan a code graph that is missing or behind is rebuilt first. Written to .bravos/dashboard/index.html (git-ignored); one self-contained file, no server, no network, no model.")
790
790
  .option('--out <file>', 'write the page here instead; nothing is then written inside the repository')
791
791
  .option('--since <ref>', "compare against this branch, tag or commit instead of the repository's default branch")
792
792
  .option('--no-blame', 'leave git names out (who introduced and fixed each exposure, and the code graph\'s owners), for a page you will share')
793
793
  .option('--no-open', 'write the page and print its path without opening a browser')
794
+ .option('--no-graph-build', 'draw from the code graph as it is; do not rebuild it first when it is missing or behind the code')
794
795
  .option('--json', 'print the result as JSON (bravos.dashboard-run/v1)')
795
796
  .action((dir, opts) => guardedAsync(async (lines) => {
796
797
  const root = dirArg(dir);
797
798
  const { buildDashboard } = await import('./dashboard.js');
798
- const r = await buildDashboard(root, io.env, { out: opts.out, since: opts.since, blame: opts.blame });
799
+ // What takes minutes is said as it starts, on stderr, so --json output stays one document.
800
+ const r = await buildDashboard(root, io.env, { out: opts.out, since: opts.since, blame: opts.blame, graphBuild: opts.graphBuild, onProgress: (line) => io.stderr(line) });
799
801
  // Opening is a convenience: the path is always printed, and a session with no display just reads it.
800
802
  const opened = opts.open !== false && !opts.json && openInBrowser(r.path, io.env);
801
803
  if (opts.json) {
package/dist/codegraph.js CHANGED
@@ -174,46 +174,85 @@ export function open(root, env) {
174
174
  throw new GraphUnavailable('codegraph-mcp is not installed: bravos setup --codegraph fetches it (on the Team plan)');
175
175
  return new GraphSession(bin, root, env);
176
176
  }
177
+ // What codegraph-mcp answers when it finds no graph for the project. It gives the same answer, wrongly, to a
178
+ // session that opens the graph in the same few hundred milliseconds as another one (measured: two sessions
179
+ // started together, exactly one answers; a session started while another is mid-question answers fine).
180
+ const NO_GRAPH = /No CodeGraph for project/i;
181
+ // Two more tries, each after a short pause of uneven length so sessions that collided do not collide again, step
182
+ // out of another session's opening moment and keep a true "no graph" answer fast (about a second more; the
183
+ // session-start probe reads an answer slower than three seconds as a graph that is loading).
184
+ export const GRAPH_RETRIES = 2;
185
+ export const GRAPH_RETRY_MS = 250;
186
+ const pause = (ms) => new Promise((r) => setTimeout(r, ms));
187
+ // @comment -- "Runs one graph session and, when it reports no graph, runs it again, up to twice, after short pauses of uneven length, before believing it: codegraph-mcp gives that answer to a session that opens the graph at the same moment as another (a second terminal, the agent's own MCP server, bravos watch beside bravos dashboard). `noGraph` says whether a session's outcome was that answer. A real 'no graph' costs two extra short sessions, about a second; anything else is returned or thrown as it came."
188
+ export async function withGraphRetry(session, noGraph, retries = GRAPH_RETRIES, waitMs = GRAPH_RETRY_MS) {
189
+ for (let attempt = 0;; attempt++) {
190
+ let outcome;
191
+ try {
192
+ outcome = { value: await session() };
193
+ }
194
+ catch (e) {
195
+ outcome = { error: e };
196
+ }
197
+ if (attempt < retries && noGraph(outcome)) {
198
+ await pause(waitMs + Math.floor(Math.random() * waitMs * 1.4));
199
+ continue;
200
+ }
201
+ if (outcome.error)
202
+ throw outcome.error;
203
+ return outcome.value;
204
+ }
205
+ }
177
206
  // @comment -- "One question, in and out: `bravos graph attack-surface --json` becomes tools/call codegraph_attack_surface. Positional words fill the tool's first required string argument (symbol, query); --name value pairs fill the rest, parsed as JSON when they look like it. The tool list comes from the binary on this machine, never from a stored copy."
178
207
  export async function ask(root, env, question, argv, timeoutMs = 60000) {
179
- const s = open(root, env);
180
- try {
181
- await s.initialize(Math.min(timeoutMs, 30000));
182
- const tools = await s.tools(Math.min(timeoutMs, 30000));
183
- const name = question.startsWith('codegraph_') ? question : `codegraph_${question.replace(/-/g, '_')}`;
184
- const tool = tools.find((t) => t.name === name);
185
- if (!tool)
186
- throw new BravosError(`the graph has no question ${JSON.stringify(question)}; it answers: ${tools.map((t) => t.name.replace(/^codegraph_/, '').replace(/_/g, '-')).join(', ')}`);
187
- return await s.call(name, bindArguments(tool, argv), timeoutMs);
188
- }
189
- finally {
190
- s.close();
191
- }
208
+ const once = async () => {
209
+ const s = open(root, env);
210
+ try {
211
+ await s.initialize(Math.min(timeoutMs, 30000));
212
+ const tools = await s.tools(Math.min(timeoutMs, 30000));
213
+ const name = question.startsWith('codegraph_') ? question : `codegraph_${question.replace(/-/g, '_')}`;
214
+ const tool = tools.find((t) => t.name === name);
215
+ if (!tool)
216
+ throw new BravosError(`the graph has no question ${JSON.stringify(question)}; it answers: ${tools.map((t) => t.name.replace(/^codegraph_/, '').replace(/_/g, '-')).join(', ')}`);
217
+ return await s.call(name, bindArguments(tool, argv), timeoutMs);
218
+ }
219
+ finally {
220
+ s.close();
221
+ }
222
+ };
223
+ return withGraphRetry(once, (o) => !!o.error && NO_GRAPH.test(o.error.message ?? ''));
192
224
  }
193
- // @comment -- "Several questions in one session: the server loads the graph once instead of once per question. A tool the binary does not offer, or one that refuses or times out, is recorded as an error for that question alone; the others are still asked. Throws only when no session can be opened (codegraph-mcp missing or not starting)."
225
+ // @comment -- "Several questions in one session: the server loads the graph once instead of once per question. A tool the binary does not offer, or one that refuses or times out, is recorded as an error for that question alone; the others are still asked. A session whose first answer is 'no graph' is run again (withGraphRetry). Throws only when no session can be opened (codegraph-mcp missing or not starting)."
194
226
  export async function askMany(root, env, calls, timeoutMs = 60000) {
195
- const s = open(root, env);
196
- try {
197
- await s.initialize(Math.min(timeoutMs, 30000));
198
- const tools = (await s.tools(Math.min(timeoutMs, 30000))).map((t) => t.name);
199
- const answers = {};
200
- for (const c of calls) {
201
- if (!tools.includes(c.tool)) {
202
- answers[c.tool] = { error: 'this code graph does not answer that question' };
203
- continue;
204
- }
205
- try {
206
- answers[c.tool] = { result: await s.call(c.tool, c.args ?? {}, timeoutMs) };
207
- }
208
- catch (e) {
209
- answers[c.tool] = { error: e.message };
227
+ const once = async () => {
228
+ const s = open(root, env);
229
+ try {
230
+ await s.initialize(Math.min(timeoutMs, 30000));
231
+ const tools = (await s.tools(Math.min(timeoutMs, 30000))).map((t) => t.name);
232
+ const answers = {};
233
+ for (const c of calls) {
234
+ if (!tools.includes(c.tool)) {
235
+ answers[c.tool] = { error: 'this code graph does not answer that question' };
236
+ continue;
237
+ }
238
+ try {
239
+ answers[c.tool] = { result: await s.call(c.tool, c.args ?? {}, timeoutMs) };
240
+ }
241
+ catch (e) {
242
+ answers[c.tool] = { error: e.message };
243
+ }
210
244
  }
245
+ return { tools, answers };
211
246
  }
212
- return { tools, answers };
213
- }
214
- finally {
215
- s.close();
216
- }
247
+ finally {
248
+ s.close();
249
+ }
250
+ };
251
+ // The graph is opened by the session's first question, so "no graph" on the first one asked is the answer to retry.
252
+ return withGraphRetry(once, (o) => {
253
+ const first = o.value && calls.map((c) => o.value.answers[c.tool]).find((a) => a && !('error' in a && a.error === 'this code graph does not answer that question'));
254
+ return !!first && 'error' in first && NO_GRAPH.test(first.error);
255
+ });
217
256
  }
218
257
  export async function listTools(root, env, timeoutMs = 30000) {
219
258
  const s = open(root, env);
package/dist/dashboard.js CHANGED
@@ -8,6 +8,8 @@ import { templatesDir, version } from './paths.js';
8
8
  import { BravosError } from './types.js';
9
9
  export const DASHBOARD_DIR = '.bravos/dashboard';
10
10
  export const DASHBOARD_PATH = `${DASHBOARD_DIR}/index.html`;
11
+ /** What the saved page was built from, for the session briefing to tell a current page from an old one. */
12
+ export const DASHBOARD_META = `${DASHBOARD_DIR}/meta.json`;
11
13
  const git = (root, env, args) => {
12
14
  const r = spawnSync('git', args, { cwd: root, env, encoding: 'utf8', timeout: 10000, stdio: ['ignore', 'pipe', 'ignore'] });
13
15
  return r.error || r.status !== 0 ? null : r.stdout.trim();
@@ -135,7 +137,41 @@ export function codeGraphStore(answers) {
135
137
  links: { type: 'links', entryPoints: entries, asked: asked('entries') },
136
138
  };
137
139
  }
138
- // @comment -- "The Code graph part of the dashboard. The code graph is on the Team plan, so the licence is checked before anything is asked (a refusal is a note on the page, not an error, and the graph binary is never started without a licence). Then one session asks the eight questions the pages are drawn from; they read git history and the whole map, so each may take minutes on a large repository. A graph that is not installed, not built for this commit, or that answers nothing is a short note naming the command that fixes it. Read-only: the graph is asked, never built here."
140
+ const NOT_BUILT = /no graph|No CodeGraph|codegraph_unavailable|not built|nothing is there|not available for project/i;
141
+ // @comment -- "What the code graph says about itself for this checkout, from one cheap question: current, not-built (no graph for this commit), diverged (the working tree has moved since it was built), or unknown when it cannot say. Read-only."
142
+ export async function graphState(root, env) {
143
+ try {
144
+ const a = (await graph.askMany(root, env, [{ tool: 'codegraph_entry_points', args: { limit: 1 } }], 60000)).answers.codegraph_entry_points;
145
+ if (!a)
146
+ return 'unknown';
147
+ if ('error' in a)
148
+ return NOT_BUILT.test(a.error) ? 'not-built' : 'unknown';
149
+ const state = text(obj(obj(a.result).graph_currency).state);
150
+ return state === 'current' ? 'current' : state ? 'diverged' : 'unknown';
151
+ }
152
+ catch {
153
+ return 'unknown';
154
+ }
155
+ }
156
+ // @comment -- "Makes the code graph match the code before the dashboard draws from it, so a fresh page is never drawn from an old graph: no graph for this commit is built, and one the working tree has moved away from is rebuilt for the tree as it stands (--mode build; the default mode would reuse the commit's graph). Always --scip no-exec, which runs none of the repository's code, and no model. Returns a sentence for the page, empty when nothing was needed; a failed build is said, never thrown."
157
+ export async function refreshGraph(root, env, onProgress) {
158
+ const state = await graphState(root, env);
159
+ if (state !== 'not-built' && state !== 'diverged')
160
+ return '';
161
+ onProgress?.(state === 'not-built' ? 'Building the code graph for this commit first (no repository code runs; minutes on a large repository)…' : 'The code has moved since the code graph was built: rebuilding it first…');
162
+ const started = Date.now();
163
+ try {
164
+ const r = graph.build(root, env, { scip: 'no-exec', ...(state === 'diverged' ? { mode: 'build' } : {}) });
165
+ if (r.status === 0)
166
+ return ` The graph was rebuilt for this page (${Math.max(1, Math.round((Date.now() - started) / 1000))} s).`;
167
+ const why = `${r.stderr}\n${r.stdout}`.split('\n').map((l) => l.trim()).filter(Boolean).pop() ?? `exit ${r.status}`;
168
+ return ` The graph could not be rebuilt (${why.slice(0, 160)}).`;
169
+ }
170
+ catch (e) {
171
+ return ` The graph could not be rebuilt (${e.message.slice(0, 160)}).`;
172
+ }
173
+ }
174
+ // @comment -- "The Code graph part of the dashboard. The code graph is on the Team plan, so the licence is checked before anything is asked (a refusal is a note on the page, not an error, and the graph binary is never started without a licence). Then one session asks the eight questions the pages are drawn from; they read git history and the whole map, so each may take minutes on a large repository. Unless told not to, a graph that is missing for this commit or behind the code is rebuilt first (refreshGraph), so the page is drawn from the code as it stands. A graph that is not installed, still not built, or that answers nothing is a short note naming the command that fixes it."
139
175
  export async function buildCodeGraph(root, env, opts = {}) {
140
176
  const note = (state, sentence) => ({ state, note: sentence, store: null });
141
177
  let entitled = false;
@@ -149,6 +185,8 @@ export async function buildCodeGraph(root, env, opts = {}) {
149
185
  return note('locked', 'The code graph is on the Team plan: bravos account activate starts a 30-day trial, no card. The threat model tab is complete without it.');
150
186
  if (!graph.graphBin('codegraph-mcp', env))
151
187
  return note('missing', 'The code graph is not installed on this machine: run bravos setup --codegraph, then bravos graph build . and bravos dashboard again.');
188
+ // The licence and the binary are settled, so a missing or behind graph is rebuilt before it is asked.
189
+ const rebuilt = opts.refresh === false ? '' : await refreshGraph(root, env, opts.onProgress);
152
190
  let answered;
153
191
  try {
154
192
  answered = await graph.askMany(root, env, Object.values(QUESTIONS).map((q) => ({ tool: q.tool, args: { ...q.args } })), 300000);
@@ -157,8 +195,8 @@ export async function buildCodeGraph(root, env, opts = {}) {
157
195
  return note('failed', `The code graph could not be asked (${e.message.slice(0, 200)}).`);
158
196
  }
159
197
  const errors = Object.values(answered.answers).map((a) => ('error' in a ? a.error : ''));
160
- if (errors.some((m) => /no graph|No CodeGraph|codegraph_unavailable|not built|nothing is there|not available for project/i.test(m))) {
161
- return note('not-built', 'No code graph is built for this repository at this commit: run bravos graph build . (a few minutes, no tokens), then bravos dashboard again.');
198
+ if (errors.some((m) => NOT_BUILT.test(m))) {
199
+ return note('not-built', `No code graph is built for this repository at this commit: run bravos graph build . (a few minutes, no tokens), then bravos dashboard again.${rebuilt}`);
162
200
  }
163
201
  if (errors.every(Boolean))
164
202
  return note('failed', `The code graph answered none of the questions (${errors[0].slice(0, 200)}).`);
@@ -166,7 +204,7 @@ export async function buildCodeGraph(root, env, opts = {}) {
166
204
  const store = codeGraphStore(scrubAnswers(answered.answers, { root: resolve(root), repo: repoName(root, env), names: opts.names !== false }));
167
205
  const states = Object.values(answered.answers).map((a) => ('result' in a ? text(obj(obj(a.result).graph_currency).state) : '')).filter(Boolean);
168
206
  const stale = states.find((x) => x !== 'current');
169
- return { state: 'present', store, note: `The code graph's answers when this page was built: the map, owners and history, coupling, trust, attack surface, entry points and links.${stale ? ` The graph is ${stale}: the code has moved since it was built, so rebuild it with bravos graph build .` : ''}` };
207
+ return { state: 'present', store, note: `The code graph's answers when this page was built: the map, owners and history, coupling, trust, attack surface, entry points and links.${rebuilt}${stale ? ` The graph is ${stale}: the code has moved since it was built, so rebuild it with bravos graph build .` : ''}` };
170
208
  }
171
209
  /** A value as JSON that is safe inside a <script type="application/json"> tag: no '<' can close the tag, no raw line separators. */
172
210
  const inert = (value) => JSON.stringify(value).replace(/</g, '\\u003c').replace(/[\u2028\u2029]/g, (c) => `\\u${c.charCodeAt(0).toString(16)}`);
@@ -203,7 +241,7 @@ export async function buildDashboard(root, env, opts = {}) {
203
241
  }
204
242
  const base = opts.since ?? baseRef(root, env);
205
243
  const tm = buildThreatModel(root, env, { base, blame: opts.blame !== false });
206
- const cg = await buildCodeGraph(root, env, { names: opts.blame !== false });
244
+ const cg = await buildCodeGraph(root, env, { names: opts.blame !== false, refresh: opts.graphBuild !== false, onProgress: opts.onProgress });
207
245
  let plan = null;
208
246
  try {
209
247
  const L = (await licenceLib());
@@ -236,6 +274,9 @@ export async function buildDashboard(root, env, opts = {}) {
236
274
  if (!existsSync(ignore))
237
275
  writeFileSync(ignore, '*\n');
238
276
  path = join(root, DASHBOARD_PATH);
277
+ // Beside the page: what it was built from, so the session briefing can say when it has fallen behind.
278
+ const meta = { schema: 'bravos.dashboard-meta/v1', generatedAt: data.generatedAt, commit: git(root, env, ['rev-parse', 'HEAD']), branch: data.branch, threatModel: tm.state, codeGraph: cg.state };
279
+ writeFileSync(join(root, DASHBOARD_META), `${JSON.stringify(meta, null, 2)}\n`);
239
280
  }
240
281
  writeFileSync(path, page);
241
282
  return { path, threatModel: { state: tm.state, note: tm.note }, codeGraph: { state: cg.state, note: cg.note } };
package/dist/guide.js CHANGED
@@ -127,7 +127,7 @@ export const GUIDE_TOPICS = [
127
127
  { name: 'Keep it fresh while I work, or nightly', skills: ['bravos-schedule'], body: ['An in-session /loop from .claude/loop.md, the nightly workflow, or a cloud task you create. Loops never send test traffic.'] },
128
128
  { name: 'Add or fix security CI', skills: ['bravos-cicd'], body: ['PR gate, nightly annotation, SARIF to code scanning, script-injection fixes.'] },
129
129
  { name: 'An app made of several repositories (microservices)', skills: ['bravos-annotate', 'bravos-codegraph', 'bravos-prove'], body: ['Clone the services side by side in one folder, then run bravos workspace create NAME --member ./gateway=gateway@http://127.0.0.1:8080 --member ./orders=orders@http://127.0.0.1:8081 (bravos workspace plus guardlink link-project plus bravos in each repo and in the shared folder). Work on a service from its own repo; ask questions that cross services from the shared folder, where the briefing and bravos watch show every service. Declare each call to another service as @flows #<this>-<x> -> #<other>-<y> via http (plain ids, not #repo.tag). Build the code graph over the shared folder so it links one service\'s client calls to another\'s handlers. bravos report data --workspace writes one report across the services.'] },
130
- { name: 'See the findings on one page', skills: ['bravos'], body: ['Run bravos dashboard (free, no model): it writes one self-contained page under .bravos/dashboard/ (git-ignored) and opens it in your browser. It is GuardLink\'s threat model with who introduced and fixed each exposure and what changed since the default branch; on the Team plan, with the code graph built, a second tab shows the code graph: a map of where the risk sits, owners and history, coupling, trust, the attack surface, entry points and links. --no-blame leaves git names out of a page you will share; --no-open only prints the path. Or ask your agent "show me the findings".'] },
130
+ { name: 'See the findings on one page', skills: ['bravos'], body: ['Run bravos dashboard (free, no model): it writes one self-contained page under .bravos/dashboard/ (git-ignored) and opens it in your browser. It is GuardLink\'s threat model with who introduced and fixed each exposure and what changed since the default branch; on the Team plan, with the code graph built, a second tab shows the code graph: a map of where the risk sits, owners and history, coupling, trust, the attack surface, entry points and links. Run it again whenever you want the picture: it rebuilds from the code as it stands, rebuilding a code graph that is missing or behind first, and a saved page says when it is more than half a day old. --no-blame leaves git names out of a page you will share; --no-open only prints the path. Or ask your agent "show me the findings".'] },
131
131
  { name: 'Write up the assessment, a finding or a retest', skills: ['bravos-report'], body: ['Ask "write the assessment report" (or a finding, a retest, an executive brief). bravos report data gathers the evidence; the agent writes report.md in the eight-section reading order, with every proof claim citing its evidence; bravos report check refuses a finding labelled reproduced without a run or ledger record; bravos report export writes md, txt, html and pdf. bravos watch shows the newest report (p to read it, o to open the pdf or html).'] },
132
132
  ],
133
133
  },
package/dist/help.js CHANGED
@@ -31,8 +31,11 @@ Commands
31
31
  changed since the default branch, and on the Team plan the code graph: a map of
32
32
  where the risk sits, owners and history, coupling, trust, attack surface, entry
33
33
  points and links. One self-contained file under
34
- .bravos/dashboard/ (git-ignored); no server, no network, no model. --no-open
35
- prints the path only, --no-blame leaves git names out, --out writes elsewhere.
34
+ .bravos/dashboard/ (git-ignored); no server, no network, no model. Rebuilt from
35
+ the code every time: a code graph that is missing or behind is rebuilt first
36
+ (--no-graph-build skips that), and the page says when it has grown old.
37
+ --no-open prints the path only, --no-blame leaves git names out, --out writes
38
+ elsewhere.
36
39
  watch [dir] A live view for a second terminal pane beside any agent: setup, open and
37
40
  confirmed exposures, the hypothesis ledger, what to test next, stale claims, the
38
41
  code graph's resolution and entry points, SAST, the branch, PRs and autopilot
package/dist/watch.js CHANGED
@@ -99,19 +99,26 @@ export function summarizeGraph(a, askedAt) {
99
99
  acceptances: accept ? { total: Number(accept.total) || 0, expiring: arr(accept.acceptances).filter((x) => x.status === 'expiring').length } : null,
100
100
  };
101
101
  }
102
- // @comment -- "Asks the code graph five read-only questions at once through bravos graph --json (argv, no shell, 60 s cap each) and summarizes them; notBuilt when bravos reports no graph for this checkout, null when bravos is missing."
102
+ // @comment -- "Asks the code graph five read-only questions in one session (argv, no shell, 60 s cap each) and summarizes them; notBuilt when the graph reports none for this checkout, null when it is not installed or answers nothing. One session, not five at once: codegraph-mcp tells all but one of several sessions opened together that there is no graph, which made watch ask for a rebuild of a graph that was there."
103
103
  export async function graphDetail(root, env) {
104
104
  if (!graph.graphBin('codegraph-mcp', env))
105
105
  return null;
106
- const entry = await askGraph(root, env, 'entry-points');
107
- if (!entry)
106
+ const QUESTIONS = { entry: 'codegraph_entry_points', auth: 'codegraph_auth_boundary', tests: 'codegraph_untested_exposures', hot: 'codegraph_hotspots', accept: 'codegraph_acceptance_register' };
107
+ let got;
108
+ try {
109
+ got = await graph.askMany(root, env, Object.values(QUESTIONS).map((tool) => ({ tool })));
110
+ }
111
+ catch {
108
112
  return null;
109
- if (entry.error === 'codegraph_unavailable')
113
+ }
114
+ const entry = got.answers[QUESTIONS.entry];
115
+ if (entry && 'error' in entry && /no graph|No CodeGraph|codegraph_unavailable|not built/i.test(entry.error))
110
116
  return { notBuilt: true };
111
- // The first answer decided whether a graph is there; the other four run together on the same store.
112
- const [auth, tests, hot, accept] = await Promise.all(['auth-boundary', 'untested-exposures', 'hotspots', 'acceptance-register'].map((q) => askGraph(root, env, q)));
113
- const ok = (x) => (x && !x.error ? x : null);
114
- const answers = { entry: ok(entry), auth: ok(auth), tests: ok(tests), hot: ok(hot), accept: ok(accept) };
117
+ const ok = (tool) => {
118
+ const a = got.answers[tool];
119
+ return a && 'result' in a ? { result: a.result } : null;
120
+ };
121
+ const answers = { entry: ok(QUESTIONS.entry), auth: ok(QUESTIONS.auth), tests: ok(QUESTIONS.tests), hot: ok(QUESTIONS.hot), accept: ok(QUESTIONS.accept) };
115
122
  if (!Object.values(answers).some(Boolean))
116
123
  return null;
117
124
  return summarizeGraph(answers, new Date().toISOString());
@@ -155,15 +162,23 @@ export async function snapshot(root, env, opts = {}) {
155
162
  const prev = opts.previous ?? null;
156
163
  const slow = opts.refreshSlow || !prev;
157
164
  const gl = (args) => run('guardlink', args, { cwd: root, env, timeoutMs: 30000 });
165
+ const collecting = briefing.collect(root, env, { nextCount: 5 });
166
+ // The graph is asked only after collect()'s own probe of it has finished, so the two never open it at the same
167
+ // moment, and never for a person whose plan does not include it.
168
+ const graphing = opts.refreshGraph ? collecting.then((c) => (c.codegraph === 'locked' ? null : graphDetail(root, env)), () => null) : null;
158
169
  const [collected, ledgerR, boundR, statusR, unannR, graphR] = await Promise.all([
159
- briefing.collect(root, env, { nextCount: 5 }),
170
+ collecting,
160
171
  gl(['hypothesis', 'list', '--json', '.']),
161
172
  slow ? gl(['hypothesis', 'boundaries', '--json', '.']) : null,
162
173
  slow ? gl(['status', '.']) : null,
163
174
  slow ? gl(['unannotated', '--json']) : null,
164
- opts.refreshGraph ? graphDetail(root, env) : null,
175
+ graphing,
165
176
  ]);
166
177
  const i = collected;
178
+ // The graph's own answers outrank the probe: a graph that just answered five questions is there, whatever a
179
+ // probe that collided with another session said. Set before the setup score reads it.
180
+ if (graphR && !('notBuilt' in graphR) && (i.codegraph === 'not-built' || i.codegraph === 'unknown'))
181
+ i.codegraph = 'current';
167
182
  const g = i.guardlink === 'missing' ? null : (i.guardlink ?? {});
168
183
  const ci = g?.ci ?? null;
169
184
  const exposures = arr(ci?.exposures).map((e) => ({ key: keyOf(e), threat: String(e.threat ?? '?'), asset: String(e.asset ?? '?'), severity: String(e.severity ?? 'unset'), file: fileOf(e), line: lineOf(e) }));
package/docs/GUIDE.md CHANGED
@@ -188,7 +188,7 @@ Clone the services side by side in one folder, then run bravos workspace create
188
188
 
189
189
  Skills: `/bravos`
190
190
 
191
- Run bravos dashboard (free, no model): it writes one self-contained page under .bravos/dashboard/ (git-ignored) and opens it in your browser. It is GuardLink's threat model with who introduced and fixed each exposure and what changed since the default branch; on the Team plan, with the code graph built, a second tab shows the code graph: a map of where the risk sits, owners and history, coupling, trust, the attack surface, entry points and links. --no-blame leaves git names out of a page you will share; --no-open only prints the path. Or ask your agent "show me the findings".
191
+ Run bravos dashboard (free, no model): it writes one self-contained page under .bravos/dashboard/ (git-ignored) and opens it in your browser. It is GuardLink's threat model with who introduced and fixed each exposure and what changed since the default branch; on the Team plan, with the code graph built, a second tab shows the code graph: a map of where the risk sits, owners and history, coupling, trust, the attack surface, entry points and links. Run it again whenever you want the picture: it rebuilds from the code as it stands, rebuilding a code graph that is missing or behind first, and a saved page says when it is more than half a day old. --no-blame leaves git names out of a page you will share; --no-open only prints the path. Or ask your agent "show me the findings".
192
192
 
193
193
  ### Write up the assessment, a finding or a retest
194
194
 
package/docs/UPGRADING.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  After `npm install -g @bugb-technologies/bravos`, run **`bravos setup --tools -y`** once on each machine and **`bravos sync`** in each repository. The notes below say what else changes, newest first.
4
4
 
5
+ ## 1.5.2
6
+
7
+ - **`bravos watch` no longer says "no graph" for a graph that is there.** The code graph answers "no graph" to a question that arrives at the same moment as another one; Bravos now asks again before believing it, and `bravos watch` asks its questions in one go instead of several at once. If you rebuilt a graph because watch told you to, it was not needed.
8
+ - **One banner and one briefing per session.** Where a project has its own Bravos install and the Bravos plugin is also enabled, the plugin's hook now stays quiet. This reaches plugin users when the plugin is next published; until then, disable one of the two.
9
+ - Run `bravos sync` in each repository to get the updated hook.
10
+
11
+ ## 1.5.1
12
+
13
+ - **`bravos dashboard` makes the code graph current first** (Team plan). With no graph for this commit it builds one; when the code has moved since the graph was built, it rebuilds it. It says so as it starts and runs none of the repository's code. A first build on a large repository takes minutes; `--no-graph-build` draws from the graph as it is.
14
+ - **A saved dashboard says how old it is.** The bar shows when it was built, and a page opened more than half a day later says it may be behind the code and names the command.
15
+ - **Your agent keeps you off old pages.** The briefing has a `Dashboard:` line saying whether the saved page is current or how many commits behind it is, and the skills run `bravos dashboard` afresh instead of opening a saved copy. After annotating or rechecking, the agent says an earlier dashboard is now behind and offers to rebuild it.
16
+ - Run `bravos sync` in each repository to get the updated skills and briefing.
17
+
5
18
  ## 1.5.0
6
19
 
7
20
  1.5 adds a dashboard and tells you which plan you are on. It includes everything listed under 1.4.3, which was not published on its own.
@@ -77,6 +77,30 @@ export function readAnnotationMode(root) {
77
77
  }
78
78
  }
79
79
 
80
+ // @comment -- "Reads .bravos/dashboard/meta.json, which bravos dashboard writes beside the page it saves: when the page was built and from which commit. null when no page was saved here or the record is unreadable; the commit is returned only when it is a plain hex id, since it is handed to git. Read-only."
81
+ export function readDashboard(root) {
82
+ try {
83
+ const m = JSON.parse(readFileSync(join(root, '.bravos', 'dashboard', 'meta.json'), 'utf8'));
84
+ const at = Date.parse(m?.generatedAt);
85
+ if (!Number.isFinite(at)) return null;
86
+ return { generatedAt: at, commit: typeof m.commit === 'string' && /^[0-9a-f]{7,40}$/.test(m.commit) ? m.commit : null };
87
+ } catch {
88
+ return null;
89
+ }
90
+ }
91
+
92
+ // @comment -- "One briefing line about the saved dashboard, so the agent never sends the person to an old page: out of date when commits have landed since it was built or it is more than half a day old, with the one command that rebuilds it (and, on the Team plan, the code graph it draws from). Pure."
93
+ export function dashboardLine(d, now = Date.now()) {
94
+ if (!d || !Number.isFinite(d.generatedAt)) return null;
95
+ const minutes = Math.max(0, Math.round((now - d.generatedAt) / 60000));
96
+ const age = minutes < 2 ? 'just now' : minutes < 90 ? `${minutes} minutes ago` : minutes < 36 * 60 ? `${Math.round(minutes / 60)} hours ago` : `${Math.round(minutes / 1440)} days ago`;
97
+ const behind = num(d.behind);
98
+ if (behind > 0 || minutes > 12 * 60) {
99
+ return `Dashboard: the saved page is out of date (built ${age}${behind > 0 ? `, ${behind} commit${behind === 1 ? '' : 's'} behind` : ''}) — never send the person to it as it is; \`bravos dashboard\` rebuilds it from the code as it stands`;
100
+ }
101
+ return `Dashboard: built ${age} at this commit (.bravos/dashboard/index.html); after changes to code or annotations, \`bravos dashboard\` rebuilds it`;
102
+ }
103
+
80
104
  // @comment -- "Reads .guardlink/intent.md (written by bravos-context) and reports whether the product's intent is recorded: none, draft (any item marked '— draft') or confirmed, with the invariant count; read-only."
81
105
  export function readIntent(root) {
82
106
  let text;
@@ -118,7 +142,7 @@ function coachLines(i) {
118
142
  `- After you edit security-relevant code, offer to record what it exposes (${k('bravos-annotate')}); before a PR, run the ship check (${k('bravos-ship')}); after a fix, offer a recheck (${k('bravos-recheck')}).`,
119
143
  '- Commits are the person\'s call: before the first commit of a session ask once (commit now, or leave the files for them to review), even where a skill says to commit; skip the question only when they already asked for commits (a campaign, a schedule).',
120
144
  '- When a request would go better with the next unlock above, say what it would add, once. Plain words first, skill name second. Never send test traffic without the authorization bravos-env asks for.',
121
- '- Once, when it helps them follow along, mention that `bravos watch` in a second terminal pane shows this live as you work (free, read-only), and that `bravos dashboard` opens the findings as one page in their browser.',
145
+ '- Once, when it helps them follow along, mention that `bravos watch` in a second terminal pane shows this live as you work (free, read-only), and that `bravos dashboard` opens the findings as one page in their browser (rebuilt from the code each time; never open a saved copy instead).',
122
146
  );
123
147
  return out;
124
148
  }
@@ -214,6 +238,8 @@ export function buildBriefing(inputs) {
214
238
  else if (i.codegraph === 'locked') tail.push('Code graph: on the Team plan (see Plan above) — skills trace routes by reading until then');
215
239
  else if (i.codegraph === 'unavailable') tail.push('Code graph: unavailable — skills trace routes by reading; when the person asks, set it up yourself (bravos-codegraph step 1: bravos setup with their go-ahead, then bravos graph build .)');
216
240
  if (i.sast && typeof i.sast === 'object') tail.push(sastLine(i.sast.summary, i.sast.available));
241
+ const dash = dashboardLine(i.dashboard, i.now);
242
+ if (dash) tail.push(dash);
217
243
  if (i.workspace) tail.push(...workspaceLines(i.workspace, i.workspaceCounts));
218
244
 
219
245
  const sections = [fix, next, staleSec, tickets].filter((s) => s.items.length > 0);
@@ -361,11 +387,14 @@ export async function collect(root, env, { deadlineMs = 20000, nextCount = 3 } =
361
387
  const base = ref || 'origin/main';
362
388
  const name = branch && branch !== 'HEAD' ? branch : null;
363
389
  const later = (args) => git(args, budget());
364
- const [diff, behind, stranded, defaultHead] = await Promise.all([
390
+ const saved = readDashboard(root);
391
+ const [diff, behind, stranded, defaultHead, since] = await Promise.all([
365
392
  later(['diff', '--name-only', `${base}...HEAD`]),
366
393
  gitStaleness(later, base),
367
394
  strandedBranches(later, base, { current: name }),
368
395
  ref ? later(['rev-parse', '--verify', `${ref}^{commit}`]) : null,
396
+ // How many commits have landed since the saved dashboard was built; unknown (a rebased-away commit) reads as none.
397
+ saved?.commit ? later(['rev-list', '--count', `${saved.commit}..HEAD`]) : null,
369
398
  ]);
370
399
  return {
371
400
  sha: sha ?? 'unknown',
@@ -375,6 +404,7 @@ export async function collect(root, env, { deadlineMs = 20000, nextCount = 3 } =
375
404
  changedFiles: diff ? diff.split('\n').filter(Boolean) : [],
376
405
  stale: staleness({ ...behind, branch: name, base }),
377
406
  stranded,
407
+ dashboard: saved ? { ...saved, behind: /^\d+$/.test(since ?? '') ? Number(since) : 0 } : null,
378
408
  };
379
409
  })();
380
410
 
@@ -429,6 +459,7 @@ export async function collect(root, env, { deadlineMs = 20000, nextCount = 3 } =
429
459
  stranded: facts.stranded,
430
460
  guardlink,
431
461
  changedFiles: facts.changedFiles,
462
+ dashboard: facts.dashboard,
432
463
  inFlight,
433
464
  intent: readIntent(root),
434
465
  annotationMode: readAnnotationMode(root),
@@ -488,6 +519,18 @@ const TEAM_ADDS = 'autopilot, PR gate, SAST, code graph';
488
519
 
489
520
  export const fit = (s, w) => (s.length <= w ? s : s.slice(0, Math.max(0, w - 1)) + '…');
490
521
 
522
+ // @comment -- "True when the project registers its own Bravos session-start hook for this harness (Claude Code: .claude/settings.json, Codex: .codex/hooks.json), so another copy of the hook, the plugin's, can stay quiet and the banner and briefing arrive once. A file that is missing or unreadable reads as not registered, and so does any other harness. Read-only."
523
+ export function sessionHookRegistered(root, harness) {
524
+ const rel = harness === 'claude' ? '.claude/settings.json' : harness === 'codex' ? '.codex/hooks.json' : null;
525
+ if (!rel) return false;
526
+ try {
527
+ const groups = JSON.parse(readFileSync(join(root, rel), 'utf8'))?.hooks?.SessionStart;
528
+ return Array.isArray(groups) && groups.some((g) => arr(g?.hooks).some((h) => typeof h?.command === 'string' && h.command.includes('.bravos/hooks/session-start.mjs')));
529
+ } catch {
530
+ return false;
531
+ }
532
+ }
533
+
491
534
  // @comment -- "True when a harness settings file in the repo registers bravos's pre-PR gate; read-only, and unreadable files read as off."
492
535
  export function prePrRegistered(root) {
493
536
  for (const rel of ['.claude/settings.json', '.codex/hooks.json']) {
@@ -1,8 +1,8 @@
1
1
  // @comment -- "SessionStart hook entry (--global: the user-level copy, silent where the repo has its own bravos hook or no .guardlink/; --briefing prints only the briefing text, for a skill that runs it by hand): reads the hook payload from stdin (bounded wait, bad input ignored; source, and Antigravity's workspacePaths), awaits collect() (read-only guardlink, git and gh facts under a shared 20 s deadline) and, where autopilot is registered, the session-start snapshot of the working tree (.bravos/watch/turn-base), and prints one JSON envelope: the briefing as additionalContext for the model, plus on a fresh start a banner as systemMessage for the human (brand-coloured; a three-line summary for Codex). With --harness agy it prints Antigravity's injectSteps instead. Always exits 0 so a session never fails to start."
2
- import { existsSync } from 'node:fs';
2
+ import { existsSync, realpathSync } from 'node:fs';
3
3
  import { dirname, join } from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
- import { autopilotRegistered, buildBanner, buildBriefing, buildSummary, collect, readVersion } from './lib/briefing.mjs';
5
+ import { autopilotRegistered, buildBanner, buildBriefing, buildSummary, collect, readVersion, sessionHookRegistered } from './lib/briefing.mjs';
6
6
  import { resolveTheme } from './lib/palette.mjs';
7
7
  import { takeSnapshot } from './lib/snapshot.mjs';
8
8
 
@@ -32,6 +32,15 @@ function harnessArg(argv, env) {
32
32
  return env.CLAUDE_PROJECT_DIR ? 'claude' : 'other';
33
33
  }
34
34
 
35
+ // @comment -- "Whether the script running is the project's own .bravos/hooks/session-start.mjs (compared by real path, so a symlinked checkout still matches); false for the plugin's copy, the user-level copy and this repository's source."
36
+ function ownCopy(root) {
37
+ try {
38
+ return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(join(root, '.bravos', 'hooks', 'session-start.mjs'));
39
+ } catch {
40
+ return false;
41
+ }
42
+ }
43
+
35
44
  async function main() {
36
45
  const env = process.env;
37
46
  const harness = harnessArg(process.argv, env);
@@ -59,6 +68,9 @@ async function main() {
59
68
  if (process.argv.includes('--global') && (existsSync(join(root, '.bravos', 'hooks', 'session-start.mjs')) || !existsSync(join(root, '.guardlink')))) {
60
69
  process.exit(0);
61
70
  }
71
+ // A copy of this hook that is not the project's own (the Claude Code or Codex plugin's) stays quiet where the
72
+ // project registers its own: that one speaks, so the banner and the briefing never arrive twice.
73
+ if (!ownCopy(root) && existsSync(join(root, '.bravos', 'hooks', 'session-start.mjs')) && sessionHookRegistered(root, harness)) process.exit(0);
62
74
  // Where autopilot is on, record what the working tree held at the start, beside the briefing, so its
63
75
  // end-of-turn check judges only this session's changes (no autopilot, nothing written).
64
76
  const snap = autopilotRegistered(root) ? takeSnapshot(root, payload.session_id, { env }) : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bugb-technologies/bravos",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
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",
@@ -27,7 +27,7 @@ description: "Start here in any repo bravos is installed in: reads the security
27
27
  proving a finding, testing whether an exposure is exploitable → bravos-prove (after bravos-env).
28
28
  a fix landed, stale claims, closing a security ticket → bravos-recheck.
29
29
  the briefing says the branch is far behind its base, annotation work sits on an idle branch, a branch was moved or abandoned → bravos-resync.
30
- "what is open?", "show me the findings", "is there a dashboard?" → answer in two or three lines from the briefing, then offer the page: `bravos dashboard` writes one self-contained HTML page (GuardLink's threat model, who introduced and fixed each exposure, what changed since the default branch; on the Team plan with the code graph built, also a Code graph tab: a map of where the risk sits, owners and history, coupling, the attack surface and entry points) under `.bravos/dashboard/`, git-ignored, and opens it in their browser. Run it when they say yes or asked to see it; add `--no-open` and give the path when no browser can open here, and `--no-blame` when they will share the page.
30
+ "what is open?", "show me the findings", "is there a dashboard?" → answer in two or three lines from the briefing, then offer the page: `bravos dashboard` writes one self-contained HTML page (GuardLink's threat model, who introduced and fixed each exposure, what changed since the default branch; on the Team plan with the code graph built, also a Code graph tab: a map of where the risk sits, owners and history, coupling, the attack surface and entry points) under `.bravos/dashboard/`, git-ignored, and opens it in their browser. Run it when they say yes or asked to see it; add `--no-open` and give the path when no browser can open here, and `--no-blame` when they will share the page. Always run the command: it rebuilds the page from the code as it stands, and on the Team plan rebuilds a code graph that is missing or behind first. Never open or point to a saved page instead, and when the briefing's `Dashboard:` line says the saved page is out of date, say so.
31
31
  write up the assessment, a finding, a retest or a brief for leadership → bravos-report.
32
32
  static analysis, dependency, secret or IaC findings → bravos-sast; "what did SAST find" → `bravos sast candidates` (the briefing's `SAST:` line says whether a run exists, or that SAST is unavailable).
33
33
  keep annotating while I work, nightly or periodic runs → bravos-schedule.
@@ -45,6 +45,7 @@ description: "Keep the GuardLink threat model correct and growing, in this sessi
45
45
  - You reported the delta line from step 10, the files left in `skipped`, and any lint violation on a line you did not write.
46
46
  - Each new `@exposes` carries a severity with its reason, and every "intended?" `@audit` is listed for the user.
47
47
  - Each new claim's state is clear: open or mitigated (none accepted by you), untested (an annotation alone confirms or refutes nothing), and verified or stale per `guardlink ci`. Say what was not tested. Do not call the code clean; the lint gate judges annotations, not code.
48
+ - 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`.
48
49
 
49
50
  ## What it leaves for the next skill
50
51
 
@@ -16,7 +16,7 @@ description: "Ask the repo's code graph (codegraph-mcp) one bounded question —
16
16
  **Plan check first.** The code graph 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.
17
17
 
18
18
  1. Ask the graph one bounded question per call; a graph answer replaces reading or grepping the tree. There are two ways in, with the same answers: the MCP tools (`codegraph_attack_surface` …) when the `codegraph` server is connected, or `bravos graph <question> --json` in the shell, where the question is the tool name without `codegraph_` and with hyphens (`codegraph_attack_surface` → `bravos graph attack-surface --json`, `codegraph_callers` → `bravos graph callers '<file>::<symbol>' --json`; `bravos graph --json` lists every question and its arguments). The shell route needs no MCP reconnect and works in every harness. The briefing's `Code graph:` line says which route is there. If neither is (no codegraph-mcp), set it up yourself: `bravos setup --check` reports what is missing without changing anything; show the person `bravos setup --dry-run --codegraph` and with their go-ahead run `bravos setup --codegraph` (it fetches the signed bundle through the account portal and verifies it before anything lands). If an install fails, quote its error and give the exact command for their own terminal; until then say "code graph unavailable; the other skills read the code instead" and answer by reading. 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 one question asked; medium: whatever questions the task needs; high: start from `codegraph_attack_surface`; max: the full attack surface plus `codegraph_impact` on every changed symbol.
19
- 2. Build or refresh the graph when an answer says there is none for this repository, or its `graph_currency` is `diverged`: `bravos graph build . --scip no-exec` indexes without running the repository's build scripts (`--scip auto` and `--isolate` run them; use those only on a repo the user trusts and only when they say so). A build that reports `semantic <language>: off` lacks that language's type checker; say that calls through interfaces may not connect and that `bravos setup --indexers` (with their go-ahead) adds it. For the MCP route, `bravos sync` registers the server from the bravos install; the person reconnects MCP (`/mcp` in Claude Code) to load it. In a bravos workspace, build one graph over the app folder (`bravos graph build <app folder> --scip no-exec`, the folder the briefing's `Workspace:` line names) and ask cross-service questions there: only a graph that holds both services links one service's HTTP, gRPC, GraphQL or OpenAPI client call to the other's handler (`callees` shows `via_framework`). A graph built inside one member stops at its own repository.
19
+ 2. Build or refresh the graph when an answer says there is none for this repository, or its `graph_currency` is `diverged`: `bravos graph build . --scip no-exec` indexes without running the repository's build scripts (`--scip auto` and `--isolate` run them; use those only on a repo the user trusts and only when they say so). A build that reports `semantic <language>: off` lacks that language's type checker; say that calls through interfaces may not connect and that `bravos setup --indexers` (with their go-ahead) adds it. For the MCP route, `bravos sync` registers the server from the bravos install; the person reconnects MCP (`/mcp` in Claude Code) to load it. In a bravos workspace, build one graph over the app folder (`bravos graph build <app folder> --scip no-exec`, the folder the briefing's `Workspace:` line names) and ask cross-service questions there: only a graph that holds both services links one service's HTTP, gRPC, GraphQL or OpenAPI client call to the other's handler (`callees` shows `via_framework`). A graph built inside one member stops at its own repository. The graph can also answer "No CodeGraph for project" to a question that arrives at the same moment as another one (a second terminal, `bravos watch`, `bravos dashboard`): when a graph answered moments ago, ask once more before rebuilding. A graph belongs to the commit it was built at: after a commit it answers nothing until it is rebuilt, so rebuild before the next graph question and carry on with other work while it builds. `bravos dashboard` rebuilds a missing or behind graph itself and draws it as the Code graph tab (the map, owners and history, coupling, the attack surface, entry points), which is the view to offer a person who wants to see the graph.
20
20
  3. Pick the one tool that answers the question:
21
21
  find a symbol → `codegraph_search`
22
22
  routes → `codegraph_routes`
@@ -36,6 +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
40
 
40
41
  ## What it leaves for the next skill
41
42
 
@@ -39,6 +39,7 @@ description: "Write a crisp, evidence-bound white-box VAPT write-up in this sess
39
39
  - `bravos report check <id>` passes for the report.
40
40
  - The exports the user asked for exist beside `report.md`, and you named them.
41
41
  - The user knows what is reproduced, what is code-review only, what is suspected, and what was not tested.
42
+ - When the reader also wants the live picture, you offered `bravos dashboard --no-blame --out <file>`: one shareable page without git names, a snapshot of the commit it was built at.
42
43
 
43
44
  ## What it leaves for the next skill
44
45
 
@@ -50,6 +50,7 @@ description: "The no-mistakes security gate before a pull request: validate the
50
50
  ## What it leaves for the next skill
51
51
 
52
52
  - The Security gate section (in the PR body if one was asked for), the open exposures for the human to decide on, and the undefended-path count for the next bravos-annotate round.
53
+ - For a person who wants to see the change, `bravos dashboard` rebuilds one page showing what changed since the base; a dashboard saved before this check is out of date.
53
54
 
54
55
  ## Go deeper
55
56
 
@@ -53,6 +53,9 @@ main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
53
53
  section { flex: 1; min-height: 0; display: none; flex-direction: column; }
54
54
  section.on { display: flex; }
55
55
  iframe { flex: 1; width: 100%; border: 0; background: var(--canvas); }
56
+ .aged { padding: 8px 16px; font-size: 13px; color: var(--fg); background: var(--canvas-inset); border-bottom: 1px solid var(--border); border-left: 3px solid var(--review); }
57
+ .aged[hidden] { display: none; }
58
+ .aged p { margin: 0; }
56
59
  .strip { padding: 6px 16px; font-size: 12px; color: var(--fg-subtle); background: var(--canvas-inset); border-bottom: 1px solid var(--border); }
57
60
  .note { max-width: 640px; margin: 48px auto; padding: 20px 24px; background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--review); border-radius: var(--radius); }
58
61
  .note h2 { margin: 0 0 6px; font-size: 15px; }
@@ -66,6 +69,7 @@ code { font: 12.5px var(--mono); background: var(--raised); border: 1px solid va
66
69
  <span class="facts" id="facts"></span>
67
70
  <nav class="tabs" id="tabs" role="tablist" aria-label="Dashboard views"></nav>
68
71
  </div>
72
+ <div class="aged" id="aged" role="status" hidden></div>
69
73
  <main id="main"></main>
70
74
  <script type="application/json" id="bravos-data">__BRAVOS_DATA__</script>
71
75
  <script type="application/json" id="bravos-threat-model">__BRAVOS_THREAT_MODEL__</script>
@@ -104,7 +108,24 @@ code { font: 12.5px var(--mono); background: var(--raised); border: 1px solid va
104
108
  fact('repo', DATA.repo);
105
109
  fact('at', [DATA.branch, DATA.sha].filter(Boolean).join(' @ '));
106
110
  fact('plan', DATA.plan);
107
- fact('built', String(DATA.generatedAt || '').slice(0, 16).replace('T', ' ') + ' UTC');
111
+ // A saved page cannot see the repository, so its age is the honest signal it has: the bar says how long ago
112
+ // it was built, and past half a day a strip says it may be behind the code and how to rebuild it.
113
+ const builtAt = Date.parse(DATA.generatedAt);
114
+ const age = Number.isFinite(builtAt) ? Math.max(0, Date.now() - builtAt) : null;
115
+ const ago = (ms) => {
116
+ const minutes = Math.round(ms / 60000);
117
+ if (minutes < 2) return 'just now';
118
+ if (minutes < 90) return minutes + ' minutes ago';
119
+ if (minutes < 36 * 60) return Math.round(minutes / 60) + ' hours ago';
120
+ return Math.round(minutes / 1440) + ' days ago';
121
+ };
122
+ fact('built', String(DATA.generatedAt || '').slice(0, 16).replace('T', ' ') + ' UTC' + (age === null ? '' : ' (' + ago(age) + ')'));
123
+ const STALE_AFTER_MS = 12 * 60 * 60 * 1000;
124
+ if (age !== null && age > STALE_AFTER_MS) {
125
+ const aged = document.getElementById('aged');
126
+ aged.append(prose('This page was built ' + ago(age) + (DATA.sha ? ' at commit ' + DATA.sha : '') + ' and may be behind the code. Run bravos dashboard in the repository to rebuild it.'));
127
+ aged.hidden = false;
128
+ }
108
129
  document.title = `Bravos — ${DATA.repo}`;
109
130
 
110
131
  const views = [];