neurastream 0.2.12 → 0.2.13

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/README.md CHANGED
@@ -94,11 +94,15 @@ Owner rule: never write a plan when another agent is doing the research or readi
94
94
 
95
95
  A plan parked for the owner has one line: `WAITING on owner: <what>`. That line is the only hold, and only Main writes it (plan-guard refuses subagents). The queue summary shows it as a flag on the plan, cut at 80 characters. Compaction and the rollover handoff read the same lines through `ownerHolds`: the compaction context lists each `<plan file>: WAITING on owner: <text>` line (or `none`) and says any other "needs the owner" or "paused" claim is unverified; the handoff's generated state carries the same lines. Main does not keep holds in a handoff note.
96
96
 
97
+ ## Queue priority
98
+
99
+ `INDEX.md` order is priority: the top line is rank 1. The queue summary lists plans in that order (`N. <file> [flags] <goal>`). Before a spawn, the guard checks every plan above each plan the brief names: a higher plan that is idle (open, no `WAITING on owner:`, not awaiting merge, still has an unticked phase) and not staffed by a running job must be named in a `Priority skip: <plan> — <why>` line, or the spawn is refused. Staffing is `<queue_state>/staffing.json` (each plan's newest spawn's task names) matched against omp's running job labels. The owner reorders the queue by dragging cards on the phone page.
100
+
97
101
  ## Owner page (`neurastream ui`)
98
102
 
99
103
  `neurastream ui on --login <tailscale login> [--port N]` does the whole setup in one sentence: it writes `ui.enabled: true` and `ui.owner_login` (plus `ui.port` with `--port`) into `~/.config/neurastream/config.yml` — every other line of the file is kept byte-for-byte — copies `templates/systemd/neurastream-ui.service` to `~/.config/systemd/user/neurastream-ui.service`, runs `systemctl --user daemon-reload`, `enable` and `restart`, then prints the phone link `http://<MagicDNS name>:<port>`. The login must be one the tailnet knows (`tailscale status --json`); when tailscale cannot answer, the check is skipped with a printed warning, never a refusal. `neurastream ui off` stops and disables the unit and sets `ui.enabled: false`, keeping `ui.owner_login` for the next `on`.
100
104
 
101
- With `ui.enabled: true` and `ui.owner_login` set (`neurastream config`, `docs/config.md`), `neurastream ui` serves one page bound to this machine's tailnet address only (port `ui.port`, default 7787; `templates/systemd/neurastream-ui.service` runs it as a user unit). It shows the plans whose `WAITING on owner:` line is open, with answer buttons; the guard unlock (`unlock 5/15/30`, `lock now`); the running agents; the queue; recent merges/CI; open incidents; agent scores; and machine health. No chat, no plan editing, no shell.
105
+ With `ui.enabled: true` and `ui.owner_login` set (`neurastream config`, `docs/config.md`), `neurastream ui` serves one page bound to this machine's tailnet address only (port `ui.port`, default 7787; `templates/systemd/neurastream-ui.service` runs it as a user unit). The page reads top to bottom: a sticky status strip with the amber "needs you" count plus working/CI/disk signals that turn red only when something is actually wrong; one card per open `WAITING on owner:` plan — the plan's `#` title, the ask in plain words, the goal folded into a Background block, and named actions ("Yes, go ahead", "No", "Reply…") whose answer shows as a one-time receipt ("Sent to Main · 08:12"); a working-now row per running or waiting agent; and closed details blocks for the queue (one flat list in `INDEX.md` order — drag a card by its handle, or tap "↑ top"/"↑"/"↓"; the drop rewrites `INDEX.md`, Main gets the move as a message and the page confirms "Moved to #2"), merges/CI, incidents, agent scores (a real table) and machine health. A sticky bottom bar holds the guard unlock ("Unlock 15 min", "Unlock 30 min", "Lock now") and, when `guards.chat_unlock` is off, says so in plain words with the exact config line. Light and dark follow the OS; there are no external assets and no build step — one server-rendered HTML string, inline CSS and one small inline script under a per-response CSP nonce (`bun scripts/ui-preview.ts <out.html>` renders a preview without a server). No chat, no plan editing, no shell.
102
106
 
103
107
  A request is served only when the peer is a tailnet address that is neither loopback nor this machine's own tailnet IP, `tailscale whois` names the `ui.owner_login` login — and the Host header is this machine: the tailnet address or the MagicDNS name, with the served port. The Host check runs on every request before whois, and a POST's Origin must match it, so a DNS-rebinding page (foreign Host, matching Origin, owner's phone) gets a 403 like everyone else. Every request logs one `UI <method> <path> login=<l> → <code>` line to the guard log.
104
108
 
@@ -172,6 +176,18 @@ Guard rules around it:
172
176
 
173
177
  "Needs you" pings use the same channels so the owner learns on the phone that a decision is his: when a Main turn ends with an open plan whose `WAITING on owner:` line was not pinged before, neurastream posts `🔔 Needs you — <plan>: <question>` (with the `neurastream ui` phone-page link when `ui.enabled: true`), and when the guard refuses a Main tool call because it touches a protected guard file, it posts `🔓 Main needs an unlock to continue (<file>)` — the unlock ping at most once per 30 minutes, each waiting question once until its line changes or disappears, remembered in `<queue_state>/notify-waiting.json`. Every decision logs one `notify: needs-you posted|skipped (<why>)` guard-log line.
174
178
 
179
+ ## Trace claims (`neurastream traces claims`)
180
+
181
+ Agents' final reports assert results — "530 passed", "exit 0", commit SHAs, heavy-run labels, changed files. This command reads a run's trace (its session file, read-only) and checks each claim in the run's last assistant message against what the run's own tool activity shows: a count or exit code must appear in some tool output, a commit SHA must be printed by the output of a git command the run itself ran, a heavy-run label must appear in a quoted heavy-run call, and a changed path must be carried by an edit/write call or a shell write in the path's own command segment. A claim nothing shows becomes a `claim-unbacked` finding.
182
+
183
+ ```
184
+ neurastream traces claims --since 24h # every run touched in the window
185
+ neurastream traces claims NsTracesVerifyGlm # one run, by id
186
+ neurastream traces claims --since 24h --json # machine-readable
187
+ ```
188
+
189
+ Known boundary: a report that cites other runs' work (Main quoting a subagent, a relaunched agent quoting its predecessor) can produce `claim-unbacked` findings that are true in this run's trace but provable only in the cited run's own trace.
190
+
175
191
  ## Self-metrics
176
192
 
177
193
  `neurastream metrics report [--days N]` compares this window (the last `metrics.report_days`, default 7) with the one before it, writes `<paths.notes>/metrics.md`, and prints the same report. Worst change is marked `◀ worst`. The five numbers:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neurastream",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "description": "Guardrails for running many AI coding agents at once: plan queue, blockers, call budgets, provider caps, scoring, merge-verified close.",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -583,11 +583,14 @@ export function createOmpAdapter(pi: ExtensionHost, cfg: Config): void {
583
583
  const snap = new Map<string, string>();
584
584
  snapshotPlans(tool, input, cwd, snap, !isSub);
585
585
  // Drain (src/core/rollover.ts): while a rollover is pending no new subagent starts; the
586
- // running ones finish first. Subagents' own tool calls are unaffected.
587
- if (!isSub && tool === "task" && cfg.rollover.enabled) {
586
+ // running ones finish first. Subagents' own tool calls are unaffected. Main's task calls
587
+ // also carry the running job labels for the priority gate (20261025_0215 P2).
588
+ let runningJobs: string[] | undefined;
589
+ if (!isSub && tool === "task") {
588
590
  const rc = asRolloverCtx(ctx);
589
- if (rc) {
590
- const why = spawnRefusal(rolloverSnapshot(rc).state, rc.runningJobs());
591
+ runningJobs = rc?.runningJobs();
592
+ if (cfg.rollover.enabled && rc) {
593
+ const why = spawnRefusal(rolloverSnapshot(rc).state, runningJobs ?? []);
591
594
  if (why) {
592
595
  const tasks = Array.isArray(input.tasks) ? input.tasks : [];
593
596
  adapterLog(cfg, `BLOCK spawn ${String(asRecord(tasks[0]).agent ?? "task")}: rollover pending`);
@@ -596,7 +599,7 @@ export function createOmpAdapter(pi: ExtensionHost, cfg: Config): void {
596
599
  }
597
600
  }
598
601
  const d = checkTool(
599
- { tool, input, cwd, agent, agentId: id, calls: n - 1, paths: [], writes: [], command: asString(input.command) },
602
+ { tool, input, cwd, agent, agentId: id, calls: n - 1, paths: [], writes: [], command: asString(input.command), runningJobs },
600
603
  cfg,
601
604
  );
602
605
  if (!d.allow) {
@@ -27,13 +27,13 @@ function walk(dir: string, depth: number, out: string[]): void {
27
27
  }
28
28
  }
29
29
 
30
- function jsonlAt(root: string, levels: number): string[] {
30
+ export function jsonlAt(root: string, levels: number): string[] {
31
31
  const out: string[] = [];
32
32
  walk(root, levels, out);
33
33
  return out;
34
34
  }
35
35
 
36
- function parseTs(ts: string): number | null {
36
+ export function parseTs(ts: string): number | null {
37
37
  const s = ts.slice(0, 19);
38
38
  if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(s)) return null;
39
39
  const [date, time] = s.split("T") as [string, string];
@@ -45,7 +45,7 @@ function parseTs(ts: string): number | null {
45
45
  return local.getTime() / 1000 - timezone;
46
46
  }
47
47
 
48
- function asObj(v: unknown): Record<string, unknown> | null {
48
+ export function asObj(v: unknown): Record<string, unknown> | null {
49
49
  return typeof v === "object" && v !== null && !Array.isArray(v) ? (v as Record<string, unknown>) : null;
50
50
  }
51
51
 
@@ -55,6 +55,12 @@ function costOf(m: Record<string, unknown>): number {
55
55
  return c && typeof c.total === "number" ? c.total : 0;
56
56
  }
57
57
 
58
+ /** Ledger run id for a session file: `MAIN <HH-MM-SS>` for dated main files, stem otherwise. */
59
+ export function runIdOf(file: string): string {
60
+ const stem = basename(file).slice(0, -6);
61
+ return /^\d{4}/.test(stem) ? `MAIN ${stem.slice(11, 19)}` : stem;
62
+ }
63
+
58
64
  function build(file: string, cfg: Config, mtime: number): Run | null {
59
65
  let text: string;
60
66
  try {
@@ -64,7 +70,7 @@ function build(file: string, cfg: Config, mtime: number): Run | null {
64
70
  }
65
71
  const stem = basename(file).slice(0, -6);
66
72
  const isMain = /^\d{4}/.test(stem);
67
- const id = isMain ? `MAIN ${stem.slice(11, 19)}` : stem;
73
+ const id = runIdOf(file);
68
74
  let model = "?";
69
75
  let scoreModel = "?";
70
76
  let calls = 0;
@@ -0,0 +1,140 @@
1
+ // Session-file trace reader: replays one run's raw activity as TraceEvents (plan
2
+ // 20261024_0300 P1). Run-id derivation matches the ledger (src/adapters/omp/sessions.ts):
3
+ // dated depth-1 files are main runs with id `MAIN <HH-MM-SS>` from the stem, deeper files are
4
+ // subagent runs with the bare stem as id. Every line type this harness writes that carries
5
+ // trace-relevant data is mapped; anything else (session banners, custom lines, compaction
6
+ // notes, unparseable lines) is skipped.
7
+
8
+ import { readFileSync, statSync } from "node:fs";
9
+ import type { TraceEvent, TraceSource, TraceUsage } from "../../core/adapter.ts";
10
+ import { asObj, jsonlAt, parseTs, runIdOf } from "./sessions.ts";
11
+
12
+ function str(v: unknown): string | undefined {
13
+ return typeof v === "string" && v !== "" ? v : undefined;
14
+ }
15
+
16
+ function num(v: unknown): number {
17
+ return typeof v === "number" && Number.isFinite(v) ? v : 0;
18
+ }
19
+
20
+ function usageOf(u: unknown): TraceUsage | undefined {
21
+ const o = asObj(u);
22
+ if (!o) return undefined;
23
+ const c = asObj(o.cost);
24
+ return {
25
+ input: num(o.input),
26
+ output: num(o.output),
27
+ cacheRead: num(o.cacheRead),
28
+ cacheWrite: num(o.cacheWrite),
29
+ totalTokens: num(o.totalTokens),
30
+ cost: c ? num(c.total) : 0,
31
+ };
32
+ }
33
+
34
+ function textOf(content: unknown): string {
35
+ if (typeof content === "string") return content;
36
+ if (!Array.isArray(content)) return "";
37
+ return content
38
+ .map((p) => (asObj(p)?.type === "text" ? String(asObj(p)?.text ?? "") : ""))
39
+ .filter((t) => t !== "")
40
+ .join("\n");
41
+ }
42
+
43
+ /** Every trace event in one session file, in file order. */
44
+ export function parseTraceFile(file: string, runId: string): TraceEvent[] {
45
+ let text: string;
46
+ try {
47
+ text = readFileSync(file, "utf8");
48
+ } catch {
49
+ return [];
50
+ }
51
+ const out: TraceEvent[] = [];
52
+ for (const line of text.split("\n")) {
53
+ if (!line.trim()) continue;
54
+ let parsed: unknown;
55
+ try {
56
+ parsed = JSON.parse(line);
57
+ } catch {
58
+ continue;
59
+ }
60
+ const d = asObj(parsed);
61
+ if (!d) continue;
62
+ const ts = typeof d.timestamp === "string" ? parseTs(d.timestamp) : null;
63
+ if (d.type === "model_change") {
64
+ out.push({ kind: "modelChange", ts, runId, model: str(d.model), provider: str(d.provider) });
65
+ continue;
66
+ }
67
+ if (d.type === "model_usage") {
68
+ const usage = usageOf(d.usage);
69
+ if (usage) out.push({ kind: "usage", ts, runId, model: str(d.model), provider: str(d.provider), usage });
70
+ continue;
71
+ }
72
+ const m = asObj(d.message) ?? (d.type === "message" || d.role ? d : null);
73
+ if (!m) continue;
74
+ const role = str(m.role);
75
+ const model = str(m.model);
76
+ const provider = str(m.provider);
77
+ const usage = usageOf(m.usage);
78
+ if (role === "assistant") {
79
+ const content = Array.isArray(m.content) ? m.content : [];
80
+ for (const part of content) {
81
+ const p = asObj(part);
82
+ if (!p) continue;
83
+ if (p.type === "text") {
84
+ const t = String(p.text ?? "");
85
+ if (t.trim()) out.push({ kind: "assistantText", ts, runId, text: t, model, provider, usage });
86
+ } else if (p.type === "toolCall") {
87
+ out.push({
88
+ kind: "toolCall",
89
+ ts,
90
+ runId,
91
+ tool: str(p.name) ?? "?",
92
+ args: asObj(p.arguments) ?? {},
93
+ model,
94
+ provider,
95
+ usage,
96
+ });
97
+ }
98
+ }
99
+ } else if (role === "toolResult") {
100
+ out.push({
101
+ kind: "toolResult",
102
+ ts,
103
+ runId,
104
+ tool: str(m.toolName) ?? "?",
105
+ isError: m.isError === true,
106
+ text: textOf(m.content),
107
+ usage,
108
+ });
109
+ }
110
+ }
111
+ return out;
112
+ }
113
+
114
+ /** Every run id with a trace under the root, each mapped to its newest file. */
115
+ export function ompTraceRuns(root: string): { runId: string; file: string; mtimeSec: number }[] {
116
+ const newest: Record<string, { file: string; mtimeSec: number }> = {};
117
+ for (const file of [...jsonlAt(root, 1), ...jsonlAt(root, 2)]) {
118
+ let mt: number;
119
+ try {
120
+ mt = statSync(file).mtimeMs;
121
+ } catch {
122
+ continue;
123
+ }
124
+ const mtimeSec = mt / 1000;
125
+ const id = runIdOf(file);
126
+ const prev = newest[id];
127
+ if (!prev || mtimeSec > prev.mtimeSec) newest[id] = { file, mtimeSec };
128
+ }
129
+ return Object.entries(newest).map(([runId, v]) => ({ runId, file: v.file, mtimeSec: v.mtimeSec }));
130
+ }
131
+
132
+ /** TraceSource over a sessions root: dated main files at depth 1, subagent files at depth 2. */
133
+ export function ompTraceSource(root: string): TraceSource {
134
+ return {
135
+ events(runId: string): TraceEvent[] {
136
+ const file = ompTraceRuns(root).find((r) => r.runId === runId)?.file;
137
+ return file ? parseTraceFile(file, runId) : [];
138
+ },
139
+ };
140
+ }
@@ -8,6 +8,7 @@ import { runInit } from "./init.ts";
8
8
  import { PORTED, runMain, runPorted } from "./commands.ts";
9
9
  import { runMetrics } from "./metrics.ts";
10
10
  import { runIncident } from "./incident.ts";
11
+ import { runTraces } from "./traces.ts";
11
12
  import { runUi } from "./ui.ts";
12
13
  import { runUninstall } from "../core/uninstall.ts";
13
14
  import { queueMigrate } from "../core/queue-migrate.ts";
@@ -61,6 +62,10 @@ export function helpText(): string {
61
62
  " neurastream main [args] run omp under the launcher (automatic session rollover)",
62
63
  " neurastream metrics <cmd> self-metrics: report, ci, false-alarm, rule (see README)",
63
64
  " neurastream incident <cmd> incidents Main must act on: list, add, plan, dismiss (see README)",
65
+ " neurastream traces claims <runId|--since 24h> [--json]",
66
+ " check a run's final-report claims (test counts, exit codes,",
67
+ " SHAs, heavy-run labels, changed paths) against the run's own",
68
+ " tool activity; unmatched ones print as claim-unbacked findings",
64
69
  " neurastream ui serve the owner's phone page on the tailnet address (ui.enabled, ui.owner_login)",
65
70
  " neurastream ui on --login <tailscale login> [--port N]",
66
71
  " one go: writes ui.enabled/owner_login (and port) into the config,",
@@ -86,6 +91,7 @@ export async function run(cmd: string, args: string[]): Promise<number> {
86
91
  if (cmd === "init") return runInit(args);
87
92
  if (cmd === "metrics") return runMetrics(args);
88
93
  if (cmd === "incident") return runIncident(args);
94
+ if (cmd === "traces") return runTraces(args);
89
95
  if (cmd === "ui") return runUi(args);
90
96
  if (cmd === "adapter") return runAdapterInstall(args);
91
97
  if (cmd === "config") {
package/src/cli/guard.ts CHANGED
@@ -44,6 +44,7 @@ function toolEvent(p: Record<string, unknown>): ToolEvent {
44
44
  paths: asStringList(p.paths),
45
45
  writes: asStringList(p.writes),
46
46
  command: asString(p.command),
47
+ ...(p.runningJobs === undefined ? {} : { runningJobs: asStringList(p.runningJobs) }),
47
48
  };
48
49
  }
49
50
 
@@ -59,7 +60,12 @@ function decide(event: string, p: Record<string, unknown>, cfg: Config): Decisio
59
60
  return checkInject(e, cfg);
60
61
  }
61
62
  case "spawn": {
62
- const e: SpawnEvent = { agent: asString(p.agent), invocationKind: asString(p.invocationKind, "task"), brief: asString(p.brief ?? p.context ?? p.task) };
63
+ const e: SpawnEvent = {
64
+ agent: asString(p.agent),
65
+ invocationKind: asString(p.invocationKind, "task"),
66
+ brief: asString(p.brief ?? p.context ?? p.task),
67
+ ...(p.runningJobs === undefined ? {} : { runningJobs: asStringList(p.runningJobs) }),
68
+ };
63
69
  return checkSpawn(e, cfg);
64
70
  }
65
71
  case "plan-edit": {
@@ -0,0 +1,115 @@
1
+ // `neurastream traces claims …` (plan 20261024_0300 P3): check what a run's final report CLAIMS
2
+ // against what the same run's tool activity shows. Claims come from the run's last assistant
3
+ // message; a claim with no backing toolResult line, git output, heavy-run call or edit/write is
4
+ // reported as a claim-unbacked finding (src/core/incident-detectors.ts D5). Read-only over the
5
+ // sessions root; --json prints machine-readable records.
6
+
7
+ import { join } from "node:path";
8
+ import { nowSec } from "../core/clock.ts";
9
+ import type { TraceSource } from "../core/adapter.ts";
10
+ import { ConfigError, loadConfig, type Config } from "../core/config.ts";
11
+ import { claimUnbacked } from "../core/incident-detectors.ts";
12
+ import { claimsFromEvents } from "../core/trace-claims.ts";
13
+ import { ompTraceRuns, ompTraceSource } from "../adapters/omp/traces.ts";
14
+
15
+ export const TRACES_USAGE = [
16
+ "usage: neurastream traces claims <runId> [--json]",
17
+ " neurastream traces claims --since <N m|h|d> [--json]",
18
+ ].join("\n");
19
+
20
+ const SINCE = /^(\d+)(m|h|d)$/;
21
+
22
+ export interface RunClaimsReport {
23
+ runId: string;
24
+ claims: number;
25
+ backed: number;
26
+ unbacked: { kind: string; summary: string; evidence?: string }[];
27
+ }
28
+
29
+ /** Verify one run: claims from its final report, findings for the ones no tool output backs. */
30
+ export function claimsReport(src: TraceSource, runId: string): RunClaimsReport {
31
+ const events = src.events(runId);
32
+ const claims = claimsFromEvents(events);
33
+ const findings = claimUnbacked(claims, events);
34
+ return {
35
+ runId,
36
+ claims: claims.length,
37
+ backed: claims.length - findings.length,
38
+ unbacked: findings.map((f) => ({ kind: f.kind, summary: f.summary, evidence: f.evidence })),
39
+ };
40
+ }
41
+
42
+ /** `neurastream traces claims`: one run by id, or every run touched inside a --since window. */
43
+ export async function runTraces(args: string[]): Promise<number> {
44
+ if (args[0] !== "claims") {
45
+ console.error(TRACES_USAGE);
46
+ return 2;
47
+ }
48
+ let cfg: Config;
49
+ try {
50
+ cfg = loadConfig();
51
+ } catch (err) {
52
+ console.error(err instanceof ConfigError ? err.message : String(err));
53
+ return 1;
54
+ }
55
+ const root = cfg.adapter?.sessions || join(cfg.paths.home, ".omp", "agent", "sessions");
56
+ const rest = args.slice(1);
57
+ let runId: string | undefined;
58
+ let windowSec: number | undefined;
59
+ let json = false;
60
+ for (let i = 0; i < rest.length; i++) {
61
+ const a = rest[i]!;
62
+ if (a === "--json") {
63
+ json = true;
64
+ } else if (a === "--since") {
65
+ const m = SINCE.exec(rest[++i] ?? "");
66
+ if (!m) {
67
+ console.error(TRACES_USAGE);
68
+ return 2;
69
+ }
70
+ // SINCE only matches digits followed by m, h or d, so the unit is one of the three.
71
+ windowSec = Number(m[1]) * (m[2] === "h" ? 3600 : m[2] === "d" ? 86400 : 60);
72
+ } else if (runId !== undefined) {
73
+ console.error(TRACES_USAGE);
74
+ return 2;
75
+ } else {
76
+ runId = a;
77
+ }
78
+ }
79
+ if ((runId !== undefined) === (windowSec !== undefined)) {
80
+ console.error(TRACES_USAGE);
81
+ return 2;
82
+ }
83
+ const runs = ompTraceRuns(root);
84
+ const src = ompTraceSource(root);
85
+ const reports: RunClaimsReport[] = [];
86
+ if (windowSec !== undefined) {
87
+ const cutoff = nowSec() - windowSec;
88
+ for (const r of runs) {
89
+ if (r.mtimeSec < cutoff) continue;
90
+ reports.push(claimsReport(src, r.runId));
91
+ }
92
+ } else {
93
+ if (!runs.some((r) => r.runId === runId)) {
94
+ console.error(`no trace for run ${runId}`);
95
+ return 1;
96
+ }
97
+ reports.push(claimsReport(src, runId!));
98
+ }
99
+ if (json) {
100
+ console.log(JSON.stringify(reports, null, 2));
101
+ return 0;
102
+ }
103
+ for (const r of reports) {
104
+ if (r.claims === 0) {
105
+ console.log(`${r.runId}: no verifiable claims in the final report`);
106
+ continue;
107
+ }
108
+ console.log(`${r.runId}: ${r.claims} claims, ${r.backed} backed, ${r.unbacked.length} unbacked`);
109
+ for (const u of r.unbacked) {
110
+ console.log(` ${u.kind}: ${u.summary}`);
111
+ if (u.evidence) console.log(` evidence: ${u.evidence}`);
112
+ }
113
+ }
114
+ return 0;
115
+ }
@@ -42,6 +42,38 @@ export interface RunSource {
42
42
  mainSession(file?: string): MainSession | null;
43
43
  }
44
44
 
45
+ // Trace events: the raw activity of one run, used for claimed-vs-done checks and cross-run
46
+ // questions. Harness-specific parsing lives in the adapters; core only defines the shape.
47
+
48
+ export interface TraceUsage {
49
+ input: number;
50
+ output: number;
51
+ cacheRead: number;
52
+ cacheWrite: number;
53
+ totalTokens: number;
54
+ cost: number;
55
+ }
56
+
57
+ export type TraceEventKind = "toolCall" | "toolResult" | "usage" | "modelChange" | "assistantText";
58
+
59
+ export interface TraceEvent {
60
+ kind: TraceEventKind;
61
+ /** Unix seconds; null when the source line carries no readable timestamp. */
62
+ ts: number | null;
63
+ runId: string;
64
+ tool?: string;
65
+ args?: Record<string, unknown>;
66
+ isError?: boolean;
67
+ text?: string;
68
+ model?: string;
69
+ provider?: string;
70
+ usage?: TraceUsage;
71
+ }
72
+
73
+ export interface TraceSource {
74
+ events(runId: string): TraceEvent[];
75
+ }
76
+
45
77
  export interface Decision {
46
78
  allow: boolean;
47
79
  reason: string;
@@ -61,12 +93,16 @@ export interface ToolEvent {
61
93
  paths: string[];
62
94
  writes: string[];
63
95
  command: string;
96
+ /** Labels of the harness's own running background jobs at call time; undefined when the caller has no job info (CLI without it). */
97
+ runningJobs?: string[];
64
98
  }
65
99
 
66
100
  export interface SpawnEvent {
67
101
  agent: string;
68
102
  invocationKind: string;
69
103
  brief: string;
104
+ /** Labels of the harness's own running background jobs; undefined when the caller has no job info. */
105
+ runningJobs?: string[];
70
106
  }
71
107
 
72
108
  export interface InjectEvent {