pi-evals 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,128 @@
1
+ import { Type } from "typebox";
2
+ import { agentLabel, appendLabel, cleanNote, FAILURE_TYPES, itemOnBranch, RULES, ruleLabel, undoLast, VERDICT_META, VERDICTS } from "./labels.js";
3
+ import { context } from "./ops.js";
4
+ import { projectKey } from "./project.js";
5
+ const VERDICT_WORDS = new Map(VERDICTS.flatMap((v) => [[v, v], [VERDICT_META[v].zh, v]]));
6
+ const USAGE = `pi-evals 用法:/evals label(一步步選)、/evals label <規則> pass|fail|unclear [說明],或 /evals label <你的話>(交給代理人整理成標記);規則:${RULES.join("、")};/evals label undo 撤銷這段工作上一筆當下標記。`;
7
+ /** The turn that formats the user's words: the instruction to the agent, with the words last and verbatim. */
8
+ export function promptFor(words) {
9
+ return [
10
+ "[/evals label] Below, in the user's own words, is the user's verdict on how this session's work followed the process rules.",
11
+ `Record it with evals_label, once per rule the words judge: on_behalf "user", rule (one of ${RULES.join(", ")}), label as the user judged it (pass, fail or unclear), and type when it is a fail.`,
12
+ "Record only what the user said, add no judgement of your own, then confirm in one line, in plain words and the user's language, what you recorded.",
13
+ "",
14
+ `User's words: ${words}`,
15
+ ].join("\n");
16
+ }
17
+ export function liveLabels(pi, options) {
18
+ const { env, now, observed } = options;
19
+ /** The user's words waiting for their turn to start, and the turn that may speak for the user. */
20
+ let waiting;
21
+ let speaking;
22
+ const textOf = (content) => typeof content === "string" ? content : Array.isArray(content) ? content.map((p) => (p && typeof p === "object" && typeof p.text === "string" ? p.text : "")).join("") : "";
23
+ const start = (text) => {
24
+ if (waiting && text === waiting.prompt) {
25
+ speaking = { ...waiting };
26
+ waiting = undefined;
27
+ }
28
+ };
29
+ pi.on("before_agent_start", (event) => start(event.prompt));
30
+ // A prompt queued behind a running turn starts its own run without before_agent_start: its user message opens it.
31
+ pi.on("message_end", (event) => {
32
+ const message = event.message;
33
+ if (message?.role !== "user")
34
+ return;
35
+ const text = textOf(message.content);
36
+ // Another message from the user in the same run is not part of the words the agent is formatting.
37
+ if (speaking && text !== speaking.prompt)
38
+ speaking = undefined;
39
+ start(text);
40
+ });
41
+ pi.on("agent_end", () => {
42
+ speaking = undefined;
43
+ });
44
+ pi.on("session_start", () => {
45
+ waiting = speaking = undefined;
46
+ });
47
+ const where = (ctx) => {
48
+ const c = context(env);
49
+ const session = ctx.sessionManager.getSessionId();
50
+ let branch;
51
+ try {
52
+ branch = ctx.sessionManager.getBranch?.();
53
+ }
54
+ catch { }
55
+ return { file: c.layout.labels, session, item: itemOnBranch(branch, session), project: projectKey(ctx.cwd, c.home), at: new Date(now()).toISOString() };
56
+ };
57
+ async function command(words, ctx) {
58
+ const say = (text, level = "info") => ctx.ui.notify(text, level);
59
+ const w = where(ctx);
60
+ if (words[0] === "undo") {
61
+ const last = undoLast(w.file, w.session, w.at);
62
+ say(last ? `pi-evals:已撤銷這段工作上一筆當下標記「${ruleLabel(last.evaluation_name, "zh")}」${VERDICT_META[last.label].zh}。` : "pi-evals:這段工作沒有可撤銷的當下標記。");
63
+ return;
64
+ }
65
+ let rule;
66
+ let verdict;
67
+ let note;
68
+ if (words.length) {
69
+ rule = RULES.find((r) => r === words[0]);
70
+ verdict = VERDICT_WORDS.get(words[1] ?? "");
71
+ note = words.slice(2).join(" ");
72
+ if (!rule || !verdict) {
73
+ const text = cleanNote(words.join(" "));
74
+ waiting = { session: w.session, prompt: promptFor(text), note: text };
75
+ pi.sendUserMessage(waiting.prompt, ctx.isIdle() ? undefined : { deliverAs: "followUp" });
76
+ return say(`pi-evals:已把你的話交給代理人,請它整理成標記${ctx.isIdle() ? "" : "(等目前的工作告一段落)"};它會回報記了什麼,不對就用 /evals label undo 撤銷。`);
77
+ }
78
+ }
79
+ else {
80
+ if (!ctx.hasUI)
81
+ return say(USAGE, "warning");
82
+ const cancelled = () => say("pi-evals:已取消,沒有記下標記。");
83
+ const names = RULES.map((r) => ruleLabel(r, "zh"));
84
+ const picked = await ctx.ui.select("要標記哪一條規則?", names);
85
+ rule = RULES[names.indexOf(picked ?? "")];
86
+ if (!rule)
87
+ return cancelled();
88
+ const verdicts = VERDICTS.map((v) => VERDICT_META[v].zh);
89
+ verdict = VERDICTS[verdicts.indexOf((await ctx.ui.select(`這段工作有照做「${ruleLabel(rule, "zh")}」嗎?`, verdicts)) ?? "")];
90
+ if (!verdict)
91
+ return cancelled();
92
+ const typed = await ctx.ui.input("補充說明(用你自己的話,可留空,直接按 Enter)", "");
93
+ if (typed === undefined)
94
+ return cancelled();
95
+ note = typed;
96
+ }
97
+ const row = { session_id: w.session, evaluation_name: rule, label: verdict, at: w.at, annotator: "human", source: "live", item: w.item, project: w.project, note: cleanNote(note) };
98
+ appendLabel(w.file, row);
99
+ say(`pi-evals:已記下「${ruleLabel(rule, "zh")}」${VERDICT_META[verdict].zh}${row.item ? `,進行中的待辦 ${row.item}` : ""}${row.note ? ",附說明" : ""};/evals label undo 可撤銷。`);
100
+ }
101
+ pi.registerTool({
102
+ name: "evals_label",
103
+ label: "Evals Label",
104
+ description: "Log a user's correction of how you worked: rule broken (or other), type of slip; on_behalf user only in a /evals label turn.",
105
+ promptSnippet: "When the user corrects how you worked (skipped a check, wrong order, ignored a rule), log it once",
106
+ parameters: Type.Object({
107
+ rule: Type.Unsafe({ type: "string", enum: [...RULES] }),
108
+ label: Type.Optional(Type.Unsafe({ type: "string", enum: [...VERDICTS] })),
109
+ type: Type.Optional(Type.Unsafe({ type: "string", enum: [...FAILURE_TYPES] })),
110
+ on_behalf: Type.Optional(Type.Unsafe({ type: "string", enum: ["user"] })),
111
+ }, { additionalProperties: false }),
112
+ async execute(_id, params, _signal, _onUpdate, ctx) {
113
+ const session = ctx.sessionManager.getSessionId();
114
+ const voice = speaking?.session === session ? speaking : undefined;
115
+ const { rule, label, type, onBehalf } = agentLabel(params, !!voice);
116
+ const w = where(ctx);
117
+ if (onBehalf) {
118
+ // The user's judgement, the agent only formatted it: the note is the user's words, never the agent's.
119
+ appendLabel(w.file, { session_id: w.session, evaluation_name: rule, label, at: w.at, annotator: "human", source: "live-prompt", type, item: w.item, project: w.project, note: voice?.note });
120
+ return { content: [{ type: "text", text: `logged the user's label: ${rule} ${label}${type ? ` (${type})` : ""}` }], details: { rule, label, type, onBehalf } };
121
+ }
122
+ const skills = observed.skills();
123
+ appendLabel(w.file, { session_id: w.session, evaluation_name: rule, label: "fail", at: w.at, annotator: "agent", source: "correction", type, item: w.item, project: w.project, skills: skills.length ? skills : undefined });
124
+ return { content: [{ type: "text", text: `logged correction: ${rule}${type ? ` (${type})` : ""}` }], details: { rule, label, type, onBehalf } };
125
+ },
126
+ });
127
+ return { command };
128
+ }
package/dist/meta.js CHANGED
@@ -222,7 +222,7 @@ export const DETECTOR_META = {
222
222
  label: t("Said how to check before editing", "動手前先說好怎麼驗證"),
223
223
  meaning: t("The agent named the check that proves the work (its Anchor) before changing any file.", "代理人在改任何檔案前,先說出用什麼檢查證明工作完成(Anchor)。"),
224
224
  goodDirection: "higher",
225
- howComputed: t("Passes when an Anchor line or a todo anchor appears before the first successful edit or write; sessions without edits do not count.", "第一次成功修改或寫檔之前出現 Anchor 行或待辦的 anchor 即通過;沒改檔的工作階段不算。"),
225
+ howComputed: t("Passes when, before the first successful edit or write, the agent or its brief named the check (an Anchor, Gates, Checks or 驗證 line, a todo anchor or check spec, or a check command in the brief), or the first change was a test file; sessions without edits do not count.", "第一次成功修改或寫檔之前,代理人或交辦內容已說出檢查(Anchor、Gates、Checks、驗證 等標示行,待辦的 anchor 或檢查設定,或交辦內容裡的檢查指令),或第一個修改的就是測試檔,即通過;沒改檔的工作階段不算。"),
226
226
  example: {
227
227
  pass: t("Writes 'Anchor: `npm test`', then edits src/app.ts.", "先寫「Anchor: `npm test`」,再修改 src/app.ts。"),
228
228
  fail: t("Edits src/app.ts first and names the check afterwards.", "先修改 src/app.ts,之後才說要怎麼檢查。"),
@@ -232,7 +232,7 @@ export const DETECTOR_META = {
232
232
  label: t("Ran the check after the last edit", "最後一次修改後有跑檢查"),
233
233
  meaning: t("After its final change, the agent ran the check it named and the check passed.", "最後一次修改後,代理人有跑它說好的檢查,而且通過。"),
234
234
  goodDirection: "higher",
235
- howComputed: t("Passes when every command in the Anchor has a passing run after the last edit; sessions with no edit or no runnable Anchor do not count.", "Anchor 裡每個指令在最後一次修改後都有通過的執行即通過;沒改檔或 Anchor 不是可執行指令的不算。"),
235
+ howComputed: t("Passes when, after the last edit, every Anchor command passed (in bash or a monitor), the agent recorded passing evidence, or a test, build, lint or type-check run passed; a failing Anchor run fails it. Edits to Markdown or text after the check do not count as edits. Sessions with no edit, only prose edits, or an Anchor that is not a command and no run do not count.", "最後一次修改後,Anchor 每個指令都通過(bash 或 monitor),或代理人記下通過的證據,或有測試、建置、lint、型別檢查通過,即通過;Anchor 指令失敗則不通過。檢查之後才改的 Markdown 或文字檔不算修改。沒改檔、只改文字,或 Anchor 不是指令又沒有執行的不算。"),
236
236
  example: {
237
237
  pass: t("Edits a file, then runs `npm test`, which exits 0.", "改完檔案後執行 `npm test`,結束碼 0。"),
238
238
  fail: t("Runs `npm test`, edits one more file, and stops.", "跑完 `npm test` 又改了一個檔案就結束。"),
package/dist/model.js CHANGED
@@ -2,13 +2,15 @@
2
2
  * The ReportModel: every number the report can show, each with its n and window, plus the plain-language
3
3
  * metadata to explain it. The renderer reads only this; `evals_query` reads parts of it.
4
4
  */
5
- import { existsSync, readFileSync } from "node:fs";
5
+ import { existsSync } from "node:fs";
6
6
  import { ASK_BUCKETS, emptyDay, mergeDay } from "./aggregate.js";
7
+ import { versionAt } from "./changes.js";
7
8
  import { DETECTORS, ERA_START } from "./detectors.js";
8
9
  import { CHANGE_KIND_META, CLOSE_KIND_META, DETECTOR_META, METRICS, NOTICE_META, STALL_KIND_META } from "./meta.js";
9
10
  import { staticOwner } from "./owners.js";
10
11
  import { weeklyRises } from "./trends.js";
11
- import { traceId } from "./schema.js";
12
+ import { labelsModel } from "./labels.js";
13
+ import { ANCHORLOOP } from "./work/join.js";
12
14
  import { workModel } from "./work/model.js";
13
15
  export const SMALL_SAMPLE = 20;
14
16
  /** Data older than this (hours) is reported as stale. */
@@ -153,46 +155,6 @@ export function impactFromRows(rows, change, all, windowDays, range, ownerOf) {
153
155
  confounders: kinds,
154
156
  };
155
157
  }
156
- function labelsJoin(labelsFile, evalsFile, sessionIds) {
157
- if (!existsSync(labelsFile))
158
- return { present: false, n: 0, unclear: 0, agreement: [] };
159
- const codeLabels = existsSync(evalsFile) ? JSON.parse(readFileSync(evalsFile, "utf8")) : {};
160
- const rows = readFileSync(labelsFile, "utf8")
161
- .split("\n")
162
- .filter(Boolean)
163
- .flatMap((line) => {
164
- try {
165
- return [JSON.parse(line)];
166
- }
167
- catch {
168
- return [];
169
- }
170
- });
171
- const by = new Map();
172
- let n = 0;
173
- let unclear = 0;
174
- for (const row of rows) {
175
- if (sessionIds && !sessionIds.has(traceId(row.session_id, "labels")))
176
- continue;
177
- n++;
178
- const t = by.get(row.evaluation_name) ?? { n: 0, agree: 0, unclear: 0 };
179
- // "Cannot tell" is the reader's honest answer, not a disagreement: count it apart from the agreement rate.
180
- if (row.label === "unclear") {
181
- unclear += 1;
182
- t.unclear += 1;
183
- by.set(row.evaluation_name, t);
184
- continue;
185
- }
186
- const code = codeLabels[row.session_id]?.[row.evaluation_name];
187
- if (!code || code === "na")
188
- continue;
189
- t.n += 1;
190
- if (code === row.label)
191
- t.agree += 1;
192
- by.set(row.evaluation_name, t);
193
- }
194
- return { present: true, n, unclear, agreement: [...by].map(([detector, t]) => ({ detector, n: t.n, agree: t.agree, rate: rate(t.agree, t.n), unclear: t.unclear })) };
195
- }
196
158
  export function buildModel(options) {
197
159
  const { index, filter } = options;
198
160
  const now = options.now ?? new Date();
@@ -225,6 +187,7 @@ export function buildModel(options) {
225
187
  const scoped = Boolean(filter.since || filter.until || filter.project);
226
188
  const hasSessionIds = selected.every(r => r.id !== undefined);
227
189
  const labelIds = scoped && existsSync(options.labelsFile) ? new Set(selected.flatMap(r => r.id ? [r.id] : [])) : undefined;
190
+ const indexedIds = labelIds && new Set(options.rows.flatMap(r => r.id ? [r.id] : []));
228
191
  const calls = Object.values(total.tools).reduce((s, t) => s + t.calls, 0);
229
192
  const errors = Object.values(total.tools).reduce((s, t) => s + t.errors, 0);
230
193
  const tokens = total.usage.input + total.usage.output + total.usage.cacheRead + total.usage.cacheWrite;
@@ -331,7 +294,10 @@ export function buildModel(options) {
331
294
  changes: options.comparisons?.filter(c => inRange(c.at)) ?? sortedChanges
332
295
  .filter((c) => inRange(c.at))
333
296
  .map((c) => ({ ...c, impact: index.range.start && c.at > index.range.start ? impactFromRows(projectRows, c, sortedChanges, options.windowDays, index.range, owner) : null })),
334
- labels: { ...labelsJoin(options.labelsFile, options.sessionEvalsFile, labelIds), needsIndex: !!labelIds && !hasSessionIds },
297
+ labels: {
298
+ ...labelsModel(options.labelsFile, options.sessionEvalsFile, { ...filter, until: options.openEnd ? undefined : filter.until, selected: labelIds, indexed: indexedIds }, (at) => versionAt(sortedChanges, ANCHORLOOP, at)),
299
+ needsIndex: !!labelIds && !hasSessionIds,
300
+ },
335
301
  coverage: options.coverage ?? null,
336
302
  work: workModel(options.work, filter),
337
303
  };
package/dist/observer.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ownerOf } from "./owners.js";
2
2
  import { projectKey } from "./project.js";
3
- import { NAMES, record, spanId, traceId } from "./schema.js";
3
+ import { NAMES, record, safeName, spanId, traceId } from "./schema.js";
4
4
  import { skillFromPath, skillsFromBlocks, skillsFromCommand } from "./skills.js";
5
5
  import { liveWriter } from "./store.js";
6
6
  import { logicalIdOf } from "./extract/session.js";
@@ -21,10 +21,14 @@ export function observe(pi, options) {
21
21
  let unsubscribe = [];
22
22
  let write = () => { };
23
23
  let hasUI = false;
24
+ let loaded = new Set();
24
25
  const iso = (t) => new Date(t).toISOString();
25
26
  const base = () => ({ "session.id": sessionId, "pi.project": project });
26
27
  const emit = (fields) => write(record(fields));
27
- const skillLoad = (skill, trigger, callId) => emit({ name: NAMES.skill, kind: "event", ts: iso(now()), source: "live", trace_id: trace, attrs: { ...base(), "gen_ai.skill.name": skill, "pi.skill.trigger": trigger, "gen_ai.tool.call.id": callId } });
28
+ const skillLoad = (skill, trigger, callId) => {
29
+ loaded.add(skill);
30
+ emit({ name: NAMES.skill, kind: "event", ts: iso(now()), source: "live", trace_id: trace, attrs: { ...base(), "gen_ai.skill.name": skill, "pi.skill.trigger": trigger, "gen_ai.tool.call.id": callId } });
31
+ };
28
32
  const snapshot = () => {
29
33
  if (snapshotTaken)
30
34
  return;
@@ -89,6 +93,7 @@ export function observe(pi, options) {
89
93
  remoteAnswers = new Set();
90
94
  monitorStarts = new Map();
91
95
  monitorsDone = new Set();
96
+ loaded = new Set();
92
97
  let file;
93
98
  try {
94
99
  file = ctx.sessionManager.getSessionFile?.();
@@ -237,4 +242,5 @@ export function observe(pi, options) {
237
242
  attrs,
238
243
  });
239
244
  });
245
+ return { skills: () => [...new Set([...loaded].map((name) => safeName(name)))].filter((n) => n !== "redacted").sort() };
240
246
  }
package/dist/ops.js CHANGED
@@ -66,7 +66,8 @@ function snapshot(env, withCoverage = true) {
66
66
  const cov = withCoverage ? coverageReader(ctx, now) : undefined;
67
67
  return { index, build(input, preset, comparisons) {
68
68
  const filter = rangeFilter(input, index.lastExtract ?? now.toISOString(), preset);
69
- return buildModel({ index, rows, changes, comparisons, filter, now, windowDays: ctx.settings.impactWindowDays,
69
+ // A range ends at the last extract unless the user ends it; a label given since then has no session in the index yet.
70
+ return buildModel({ index, rows, changes, comparisons, filter, now, windowDays: ctx.settings.impactWindowDays, openEnd: input.until === undefined,
70
71
  labelsFile: ctx.layout.labels, sessionEvalsFile: ctx.layout.sessionEvals, coverage: cov?.(filter), work });
71
72
  } };
72
73
  }
package/dist/query.js CHANGED
@@ -1,9 +1,10 @@
1
1
  /** `evals_query`: bounded plain-text summaries of the index for an agent (names and numbers only, under 2 KB). */
2
2
  import { coverageInRange, indexedModel, reportPath } from "./ops.js";
3
3
  import { findings } from "./findings.js";
4
+ import { labelsView } from "./labels-query.js";
4
5
  import { select } from "./report/findings.js";
5
6
  import { itemsView } from "./work/query.js";
6
- export const VIEWS = ["findings", "items", "skills", "packages", "ask_user", "monitors", "subagents", "process", "cost", "changes", "coverage"];
7
+ export const VIEWS = ["findings", "items", "labels", "skills", "packages", "ask_user", "monitors", "subagents", "process", "cost", "changes", "coverage"];
7
8
  export const MAX_BYTES = 1900;
8
9
  const pct = (r) => (r && r.value !== null ? `${(r.value * 100).toFixed(1)}% (n=${r.n})` : `n/a (n=${r?.n ?? 0})`);
9
10
  const sec = (v) => (v === null ? "n/a" : `${(v / 1000).toFixed(1)}s`);
@@ -99,6 +100,9 @@ export function query(view, options = {}) {
99
100
  else if (view === "items") {
100
101
  body.push(...itemsView(m.work));
101
102
  }
103
+ else if (view === "labels") {
104
+ body.push(...labelsView(m));
105
+ }
102
106
  else if (view === "changes") {
103
107
  body.push("highlighted then newest changes, sessions split at the change time, metric before -> after; flags: small = <20 sessions a side, incomplete = a window runs past the data, confounded = other commits nearby");
104
108
  const { highlighted, folded } = select(m);
package/dist/render.js CHANGED
@@ -27,6 +27,7 @@ export function renderHtml(m, lang = "zh", range = "custom") {
27
27
  ["cost", L("Cost", "費用")],
28
28
  ["coverage", L("Cleanup", "清理門檻")],
29
29
  ["labels", L("Labels", "你的標記")],
30
+ ["corrections", L("Corrections", "被糾正")],
30
31
  ["concepts", L("Concepts", "概念")],
31
32
  ];
32
33
  const date = m.generated.slice(0, 10);
@@ -20,6 +20,19 @@ function workCards(m, L) {
20
20
  ],
21
21
  };
22
22
  }
23
+ /** When a label was given, with this report's numbers. */
24
+ function labelTiming(m, L) {
25
+ const l = m.labels, name = (d) => m.meta.detectors[d]?.label[L("en", "zh")] ?? d;
26
+ const pairs = l.agreement.filter((r) => r.bySource.batch.n).map((r) => [name(r.detector), `${num(r.bySource.batch.agree)}/${num(r.bySource.batch.n)}`]);
27
+ const en = pairs.map(([d, v]) => `${v} on "${d}"`).join(", "), zh = pairs.map(([d, v]) => `「${d}」${v}`).join("、");
28
+ const fact = l.sessions.batch
29
+ ? L(`So far ${num(l.sessions.batch)} sessions were labelled after the fact; the code agreed with you ${en || "on none that it judged"}.`, `目前事後標了 ${num(l.sessions.batch)} 段工作,程式和你一致的有:${zh || "沒有程式判斷可比"}。`)
30
+ : L("No sessions were labelled after the fact yet.", "目前還沒有事後標記。");
31
+ return [
32
+ L("Labelled in the moment vs after the fact", "當下標記 vs 事後標記"),
33
+ L(`After the fact means judging later from a summary an AI wrote; in the moment means judging with /evals label while the work is in front of you. ${fact} A summary leaves things out, so when agreement is low it may be the summary or the code; labels after the fact alone cannot tell which. In-the-moment labels so far: ${num(l.bySource.live)}. Once each kind has at least 20, comparing their agreement shows where the gap comes from.`, `事後標記是事情過了,讀 AI 寫的摘要再判斷;當下標記是工作還在眼前時,用 /evals label 直接判斷。${fact}摘要會漏掉細節,所以一致比例偏低時,可能是摘要沒寫清楚,也可能是程式判斷錯了,只看事後標記分不出來。當下標記目前 ${num(l.bySource.live)} 筆;兩種各累積到至少 20 筆,比較兩邊的一致比例,才看得出落差從哪裡來。`),
34
+ ];
35
+ }
23
36
  export function concepts(m, week, c, L) {
24
37
  const i = c?.impact, n = num(week.reduce((s, r) => s + r.sessions, 0)), d = m.process.detectors.find((r) => r.name === "anchor_before_first_edit");
25
38
  return {
@@ -44,6 +57,7 @@ export function concepts(m, week, c, L) {
44
57
  : L(`There are ${num(m.changes.length)} changes on this timeline. Check what else changed before crediting a new version.`, `時間軸有 ${num(m.changes.length)} 筆調整。要把差異歸給某個版本,得先查同一期間還改了什麼。`),
45
58
  ],
46
59
  ...workCards(m, L),
60
+ labelTiming: labelTiming(m, L),
47
61
  check: [
48
62
  L("Code check", "程式檢查"),
49
63
  L(`In ${num(d?.passRate.n ?? 0)} eligible sessions, code checked whether the agent named a check before editing. It cannot judge whether that check tested the right thing.`, `程式在 ${num(d?.passRate.n ?? 0)} 段適用的工作裡查「改檔前有沒有先說怎麼驗證」。它看得出先後順序,判斷不了方法好不好。`),
@@ -1,3 +1,5 @@
1
+ import { FAILURE_TYPE_META, ruleLabel } from "../labels.js";
2
+ import { SMALL_SAMPLE } from "../model.js";
1
3
  import { lesson, selfCheck } from "./concepts.js";
2
4
  import { duration, esc, num, pct, table, usd, words } from "./format.js";
3
5
  import { workSection } from "./work.js";
@@ -44,9 +46,21 @@ export function sections(m, lang, cards) {
44
46
  const coverage = section("coverage", L("When is cleanup safe?", "何時可以開啟清理?"), L("Only consider cleanup when all old files match the index, by both file count and bytes. This report never deletes a file.", "所有舊檔的大小和修改時間都要和索引相符,未建索引的檔案數和位元組數都歸零,才考慮開啟清理。報表不會刪檔。"), cov
45
47
  ? `<p>${L("Files modified in the selected dates, indexed (all projects)", "選定日期內有修改的檔案,已建索引(全部專案)")}:${num(cov.inRange?.indexed ?? 0)} / ${num(cov.inRange?.files ?? 0)}</p><p>${L("Cleanup gate across all dates", "清理門檻不分日期")} · ${L("Inactive days", "閒置天數")} &gt; ${cov.cutDays} / ${L("Files indexed", "已建索引")} ${num(cov.indexed.files)} / ${num(cov.old.files)}</p><p>${L("Not indexed", "未建索引")}:${num(cov.notIndexed.files)} ${L("files", "個檔案")} · ${num(cov.notIndexed.bytes)} bytes</p>`
46
48
  : `<p>${L("Coverage not measured; keep cleanup off.", "沒有索引覆蓋資料,請勿開啟清理。")}</p>`);
47
- const labels = section("labels", L("Your labels", "你的標記"), meta.agreement.meaning[lang], m.labels.needsIndex ? `<p>${L("Run /evals extract to count labels in this period.", "請執行 /evals extract 以計算這段期間的標記。")}</p>` : m.labels.present && m.labels.n
48
- ? T([L("Check", "檢查"), L("Labelled", "已標記"), L("Agreement", "一致比例"), L("Cannot tell", "看不出來")], m.labels.agreement.map((r) => [m.meta.detectors[r.detector]?.label[lang] ?? r.detector, r.n, pct(r.rate), r.unclear])) + `<p class="muted">${L(`Cannot tell ${num(m.labels.unclear)}: labels marked unclear are left out of the agreement rate.`, `看不出來 ${num(m.labels.unclear)}:標成「看不出來」的不算進一致比例。`)}</p>`
49
- : `<p>${L("No labels yet. In phase 2 you will judge sessions yourself and compare your answers with the code checks.", "還沒有標記。第二階段會讓你親自判讀工作紀錄,再對照程式與你的判斷是否一致。")}</p>`);
49
+ const lb = m.labels, rule = (r) => ruleLabel(r, lang);
50
+ const pair = (c) => (c.n ? `${num(c.agree)} / ${num(c.n)}` : "—");
51
+ const labels = section("labels", L("Your labels", "你的標記"), meta.agreement.meaning[lang], lb.needsIndex ? `<p>${L("Run /evals extract to count labels in this period.", "請執行 /evals extract 以計算這段期間的標記。")}</p>` : lb.present && lb.n
52
+ ? `<p>${L(`After the fact ${num(lb.bySource.batch)} (${num(lb.sessions.batch)} sessions) / In the moment ${num(lb.bySource.live)} (${num(lb.sessions.live)} sessions)`, `事後標 ${num(lb.bySource.batch)} 筆(${num(lb.sessions.batch)} 段工作) / 當下標 ${num(lb.bySource.live)} 筆(${num(lb.sessions.live)} 段工作)`)}${lb.fromWords ? L(`; ${num(lb.fromWords)} of them the agent wrote from your words`, `;其中 ${num(lb.fromWords)} 筆是代理人依你的話整理的`) : ""}</p>` +
53
+ T([L("Check", "檢查"), L("Agreement", "一致比例"), L("After the fact: agreed / compared", "事後標:一致 / 比對"), L("In the moment: agreed / compared", "當下標:一致 / 比對"), L("Cannot tell", "看不出來")], lb.agreement.map((r) => [rule(r.detector), `${pct(r.rate)}(${num(r.n)})`, pair(r.bySource.batch), pair(r.bySource.live), r.unclear])) +
54
+ `<p class="muted">${L(`Cannot tell ${num(lb.unclear)}: labels marked unclear are left out of the agreement rate.`, `看不出來 ${num(lb.unclear)}:標成「看不出來」的不算進一致比例。`)}${lb.noCode ? L(` ${num(lb.noCode)} labels have no code verdict to compare: the session is not extracted yet (run /evals extract), or the rule did not apply to it.`, `另有 ${num(lb.noCode)} 筆沒有程式判斷可比:那段工作還沒整理(執行 /evals extract 後就能比),或這條規則不適用於它。`) : ""}${lb.other ? L(` ${num(lb.other)} labels are on "Other", which no code check covers.`, `${num(lb.other)} 筆標在「其他」,沒有程式檢查可比。`) : ""}</p>` + lesson(cards.labelTiming, L)
55
+ : `<p>${L("No labels yet. Type /evals label in any session to say, while the work is in front of you, whether the agent followed a rule.", "還沒有標記。在任何工作階段輸入 /evals label,就能趁工作還在眼前,標記代理人有沒有照規則做。")}</p>` + lesson(cards.labelTiming, L));
56
+ const c = lb.corrections, few = c.n < SMALL_SAMPLE;
57
+ const corrections = section("corrections", L("Times the agent was corrected", "被糾正"), L("When you correct how the agent worked, it logs one line with evals_label. This counts the corrections it logged, not all its mistakes: a slip nobody caught, or one it forgot to log, is not here.", "你糾正代理人的做法時,它會用 evals_label 自己記一筆。這裡數的是它記下的被糾正次數,不是所有錯誤:沒人發現、沒被糾正,或它忘了記的,都不在這裡。"), c.n
58
+ ? `<p class="big">${num(c.n)} <small>${L("corrections", "次")} · ${num(c.sessions)} ${L("sessions", "段工作")}</small></p>${few ? `<p class="stale">${L(`Only ${num(c.n)}: too few to show a trend. Read it as a hint of where slips may recur.`, `只有 ${num(c.n)} 次,太少,看不出趨勢;只能當提醒,看哪裡可能常出錯。`)}</p>` : ""}<div class="pair"><article class="panel"><h3>${L("By rule", "依規則")}</h3>${T([L("Rule", "規則"), L("Times", "次數")], c.byRule.map((r) => [rule(r.rule), r.n]))}</article><article class="panel"><h3>${L("By kind of slip", "依錯誤類型")}</h3>${T([L("Kind", "類型"), L("Times", "次數")], c.byType.map((r) => [FAILURE_TYPE_META[r.type]?.[lang] ?? r.type, r.n]))}</article></div>` +
59
+ more(L("By skill loaded and by anchorloop version", "依載入的技能、anchorloop 版本"), `<p class="muted">${L("Skills the session had loaded before the correction. One correction counts for each of them; this does not mean the skill caused it.", "被糾正時這段工作已載入的技能。一次糾正會算進每個已載入的技能,不代表是技能造成的。")}</p>` +
60
+ T([L("Skill", "技能"), L("Times", "次數"), L("Sessions", "工作段數")], c.bySkill.map((r) => [r.skill || L("(none loaded)", "(沒載入技能)"), r.n, r.sessions])) +
61
+ `<p class="muted">${L("The anchorloop version in use when the correction was logged.", "依糾正當時使用的 anchorloop 版本。")}</p>` +
62
+ T([L("Version", "版本"), L("Times", "次數"), L("Sessions", "工作段數")], c.byVersion.map((r) => [r.version === "unknown" ? L("unknown", "不明") : r.version, r.n, r.sessions])))
63
+ : `<p>${L("None logged in this period. When you correct the agent, it logs one line here.", "這段期間沒有紀錄。你糾正代理人時,它會在這裡記一筆。")}</p>`);
50
64
  return [
51
65
  workSection(m, lang, cards, lesson),
52
66
  skills,
@@ -58,6 +72,7 @@ export function sections(m, lang, cards) {
58
72
  cost,
59
73
  coverage,
60
74
  labels,
75
+ corrections,
61
76
  section("concepts", L("Concepts", "概念"), L(`Use these ${Object.keys(cards).length} ideas when you read the next report.`, `下次讀報表時,可以用這 ${Object.keys(cards).length} 個概念判讀數字。`), `<div class="notes-grid">${Object.values(cards).map((c) => lesson(c, L)).join("")}</div>${selfCheck(L)}`),
62
77
  ].join("");
63
78
  }
@@ -46,6 +46,13 @@ function liteOf(raw) {
46
46
  blockedBy: Array.isArray(t.blockedBy) ? t.blockedBy.length : 0,
47
47
  };
48
48
  }
49
+ /** A task's own key: its uid, else `<origin session>#<id>` for a task handed over from another session. */
50
+ const ownKey = (task) => task.uid ?? (task.origin ? `${task.origin}#${task.id}` : undefined);
51
+ /** The key of the task in progress in a live todo list, as the back-fill keys it on the session's main branch. */
52
+ export function liveItemKey(tasks, session) {
53
+ const task = tasks.map(liteOf).find((x) => x?.status === "in_progress");
54
+ return task && (ownKey(task) ?? `${session}#${task.id}`);
55
+ }
49
56
  /** The kind of stall a waking entry ends, or undefined when the entry does not start a turn. */
50
57
  export function wakeOf(entry) {
51
58
  const type = entry.type;
@@ -264,10 +271,9 @@ export class WorkTracker {
264
271
  }
265
272
  newItem(session, nested, task, snap, si, main, reuse) {
266
273
  let key;
267
- if (task.uid)
268
- key = task.uid;
269
- else if (task.origin)
270
- key = `${task.origin}#${task.id}`;
274
+ const own = ownKey(task);
275
+ if (own)
276
+ key = own;
271
277
  else if (main.has(si)) {
272
278
  const count = (reuse.get(task.id) ?? 0) + 1;
273
279
  reuse.set(task.id, count);
package/docs/design.md CHANGED
@@ -19,9 +19,10 @@ Decisions on 2026-11-26, binding for this package:
19
19
  | 「用 pi command 操作,這樣 agent 也可以自己去看」 | `/evals` (status, extract, report, mark) is the main surface, and one tool, `evals_query`, lets an agent read bounded summaries. The CLI is a thin wrapper over the same functions. |
20
20
  | 「報表的設計會很重要,要注重人類可讀性,最好是可以記錄我做出的架構調整所造成的影響」 | A change timeline (pins, model routing, rules, skills, agent roles, live version changes, manual marks) with the same numbers before and after each change. The data (ReportModel, `model.json`) is separate from the renderer; this release ships a plain renderer, and the designed one will replace it after a mockup round. |
21
21
  | 「先索引,穩定後再開清理」 | No cleanup code. `/evals status` and `evals_query coverage` report how many session files older than the cut (default 60 days without changes) the index fully covers, by count and bytes: the gate before a retention tool may delete them. Extra session roots (a future trash dir) are a setting. |
22
+ | 「我認為應該是 /eval 當下就可以做標記,也可以讓 agent 在做錯被糾正的時候標記,這樣才有辦法正確反映當下情境」 | `/evals label` records the user's verdict on a rule in the current session, and the `evals_label` tool lets the agent log a correction it was given; see [Labels in the moment](#labels-in-the-moment-050). |
22
23
  | 「記得我對 evals 是門外漢,你的報表和標記網頁要讓我有辦法看懂」 | Every metric and detector in the ReportModel carries a label, one sentence of meaning, the better direction, one sentence on how it is computed, and for detectors a pass and a fail example, in English and Traditional Chinese. No unexplained statistics terms in what the reader sees. |
23
24
 
24
- Later phases, not built here, each with a seam left open: human labels (phase 2; `labels.jsonl` is joined if present), with-and-without-skill A/B runs (phase 3), and session cleanup through a retention tool once the index covers old sessions (phase 4; `extraRoots` reads its trash dir).
25
+ Later phases, not built here, each with a seam left open: with-and-without-skill A/B runs (phase 3), and session cleanup through a retention tool once the index covers old sessions (phase 4; `extraRoots` reads its trash dir).
25
26
 
26
27
  ## Decisions
27
28
 
@@ -58,8 +59,8 @@ It appends to the state dir, never to the session file, and a failed write warns
58
59
  Four session-scoped checks, each a `gen_ai.evaluation.result` with `annotator_kind` CODE.
59
60
  Anchor and change reading is ported from anchorloop's close guard (`pi/close-guard.ts` `read()`, 3.3.0), whose repository rules keep the guard small, so the evals live outside it (inventory §1).
60
61
 
61
- - `anchor_before_first_edit`: an `Anchor:` line or todo anchor appears before the first successful `write` or `edit`. An anchor stated only in a subagent's brief is still a fail, named `anchor_only_in_brief`, so the report can tell the two apart.
62
- - `check_after_last_edit`: every command of the anchor has a passing run after the last change.
62
+ - `anchor_before_first_edit`: before the first successful `write` or `edit`, the agent states the check (`anchor_first`: an `Anchor:` line, a labelled `Gates:`, `Checks:`, `Verify:` or `驗證:` line, a todo anchor, or a todo's sb check spec), its brief does (`anchor_in_brief`: such a line, or a check command it names), or the first change is a test file (`test_first`, red first). The brief counts because anchorloop has the coordinator put the unit's anchor there. 0.5.0 read only the `Anchor:` line and todo anchor and failed a brief's anchor as `anchor_only_in_brief`; 30 human labels (2026-11-26) passed all of these shapes.
63
+ - `check_after_last_edit`: after the last change, every command of the anchor has a passing run (bash, or a monitor by its exit code; `anchor_green`), the agent recorded passing todo evidence (`evidence_after_change`), or, when no anchor command ran and failed, the latest test, build, lint or type-check run passed (`check_run_after_change`). A check run is a segment of the command that starts with a known runner (`npm test`, `vitest`, `tsc`, `pytest`, `dotnet test` and the like) or a script named for checking (`check-*.py`, `gates.sh`, `measure.mjs`, `tests/*.py`); a command that only mentions tests (`rg test`, `git commit`) is not one. Edits to Markdown or text files do not move the last change, so a report or changelog written after the check does not undo it; a session that changed only such files is `prose_only` unless a check ran. With no anchor and no check it fails as `no_check_after_change`.
63
64
  - `todo_evidence`: completed tasks in the final todo list carry evidence; the value is the share that do.
64
65
  - `close_guard_quiet`: an editing session got no close-guard reminder about a missing or failing check (an evidence hand-off reminder does not count).
65
66
 
@@ -108,6 +109,23 @@ It counts tool errors over calls per package and job endings marked `error` over
108
109
  If several packages qualify, the largest rise wins, then the larger recent call count, then the package name.
109
110
  No flag means no rise met that rule, not proof that nothing went wrong.
110
111
 
112
+ ### Labels in the moment (0.5.0)
113
+
114
+ The first 20 labelled sessions were judged after the fact from AI summaries, and the code agreed on 10 of 20 and 4 of 11.
115
+ A summary can leave out what decided the verdict, so the gap cannot be put on the code or on the summary.
116
+ A label given while the work is in front of the user does not have that problem, so the report keeps the two apart and shows agreement for each.
117
+
118
+ `/evals label` asks three plain questions (which rule, followed or not, an optional note) and needs no arguments; the one-line form is for speed.
119
+ A label is tied to the session and the todo item in progress, keyed as back-filled work items are, so it can later join the item.
120
+ `undo` appends a withdrawal instead of rewriting the file, so a label another session appends at the same moment cannot be lost.
121
+ `/evals label <your words>` (「/evals label 後面應該允許接 prompt。要求 agent 根據格式標注」) sends the words to the agent, which formats them into rows; the command, not the agent, supplies the note, and the right to write a human row (`on_behalf: "user"`) opens when that turn starts and closes at its end.
122
+
123
+ The agent's `evals_label` takes enumerated names and nothing else, and its tool text stays near 690 bytes, since every session pays for it.
124
+ Its rows never enter the agreement: an agent's own account of being corrected is not a verdict on the code.
125
+ They are counted as 「被糾正」 by rule, failure type, the skills loaded before the correction, and the anchorloop version at the time.
126
+ The count covers corrections that were logged, not every mistake; with fewer than 20, the report says it is too few to show a trend.
127
+ A label whose session is not extracted yet enters a date or project filter by its own time and project, and is not cut at the last extract unless the user set an end date, so it shows up at once.
128
+
111
129
  ### Storage choices
112
130
 
113
131
  JSON lines and JSON files, no database: the index is rebuilt from per-session summaries in about a second, and the reader needs no service (research §4: everything reduces to files plus one static page).
package/docs/schema.md CHANGED
@@ -45,22 +45,40 @@ Back-fill rebuilds each session's items from its `todo/v1` snapshots, diffed alo
45
45
 
46
46
  | `gen_ai.evaluation.name` | `pass` | `fail` explanations | `na` explanations |
47
47
  | --- | --- | --- | --- |
48
- | `anchor_before_first_edit` | `anchor_first` | `change_before_anchor`, `anchor_only_in_brief` | `no_edit` |
49
- | `check_after_last_edit` | `anchor_green` | `no_passing_run_after_change` | `no_edit`, `no_anchor`, `anchor_without_command` |
48
+ | `anchor_before_first_edit` | `anchor_first`, `anchor_in_brief`, `test_first` | `change_before_anchor` | `no_edit` |
49
+ | `check_after_last_edit` | `anchor_green`, `evidence_after_change`, `check_run_after_change` | `no_passing_run_after_change`, `no_check_after_change` | `no_edit`, `prose_only`, `anchor_without_command` |
50
50
  | `todo_evidence` | `all_evidenced` | `completed_without_evidence` (value = share with evidence) | `no_completed_task` |
51
51
  | `close_guard_quiet` | `no_notice` | the commonest notice kind | `no_edit` |
52
52
 
53
53
  Sessions that started before 2026-11-23T10:51:07Z (the anchorloop 3.0.0 pin) get `na` with `out_of_scope_pre_3.0` for all four.
54
54
 
55
- ## Labels (for a later phase)
55
+ ## Labels
56
56
 
57
- `labels.jsonl` in the state dir, one human verdict per line:
57
+ `labels.jsonl` in the state dir is appended to, one row per line, and read at every report and query, with no extract needed.
58
+ There are three kinds of rows:
58
59
 
59
60
  ```json
60
- { "session_id": "01a2…", "evaluation_name": "anchor_before_first_edit", "label": "fail", "at": "2026-12-01T09:00:00Z", "note": "optional" }
61
+ { "session_id": "01a2…", "evaluation_name": "anchor_before_first_edit", "label": "fail", "at": "2026-11-26T05:51:51Z", "annotator": "human" }
62
+ { "session_id": "01a2…", "evaluation_name": "check_after_last_edit", "label": "fail", "at": "2026-11-26T06:00:00Z", "annotator": "human", "source": "live", "item": "MP-1234", "project": "demo-repo", "note": "optional, the user's own words" }
63
+ { "session_id": "01a2…", "evaluation_name": "other", "label": "fail", "at": "2026-11-26T06:10:00Z", "annotator": "agent", "source": "correction", "type": "ignored_instruction", "item": "01a2…#3", "project": "demo-repo", "skills": ["coding"] }
61
64
  ```
62
65
 
63
- `label` is `pass`, `fail`, or `unclear` (the reader could not tell). The report joins these with `index/session-evals.json` (the code labels per session) and shows how often they agree; `unclear` labels are left out of the agreement rate and counted on their own (「看不出來 N」).
66
+ - A row without `source` is a human verdict given after the fact (the report calls it 事後標, the code `batch`).
67
+ - `source: "live"` is a human verdict given in the moment with `/evals label`. `/evals label undo` appends `{ …, "source": "live", "undo": "<at of the withdrawn row>" }`, which withdraws the session's latest live row still in effect.
68
+ - `source: "live-prompt"` is a human verdict too: the user's words after `/evals label`, which the agent turned into rows with `evals_label` and `on_behalf: "user"` during the turn those words started. The note is the user's words, taken from the command, never from the agent.
69
+ - `source: "correction"` is an agent's `evals_label` call: `label` is always `fail`, and `type` is one of `no_check_stated`, `no_check_run`, `skipped_rule`, `wrong_order`, `unverified_claim`, `ignored_instruction`, `other`. The tool accepts no other field or value, and refuses `on_behalf` outside such a turn.
70
+
71
+ `evaluation_name` is a process check name or `other`.
72
+ `label` is `pass`, `fail`, or `unclear` (the reader could not tell).
73
+ `item` is the key of the todo item in progress when the label was given: its `uid`, else `<origin session>#<id>` for a task carried over from another session, else `<session>#<id>`.
74
+ `note` is the only free text, always the user's own words, and is never shown in the report or a query result.
75
+
76
+ The report joins human rows with `index/session-evals.json` (the code labels per session) and shows how often they agree, by when the labels were given (`live` and `live-prompt` both count as in the moment).
77
+ `unclear` labels are left out of the agreement rate and counted on their own (「看不出來 N」); labels on `other`, or on a session the code has not judged, are counted apart.
78
+ Agent rows never enter the agreement; they make the 「被糾正」 section.
79
+ With a date or project filter, a row belongs to the range by its session's start when the session is indexed, and by its own `at` and `project` otherwise.
80
+ A range without an end date the user gave ends at the last extract, but a row of a session not indexed yet is not cut there, so a label given after the last extract still shows.
81
+ The report counts the `live-prompt` rows among 當下標 and says how many there are.
64
82
 
65
83
  ## Change timeline
66
84
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-evals",
3
- "version": "0.4.1",
3
+ "version": "0.5.1",
4
4
  "description": "Usage and process records for pi: how skills, packages, ask-user, monitors and subagents are used, back-filled from past sessions, with a static report and an evals_query tool",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -37,7 +37,9 @@
37
37
  "extensions": [
38
38
  "./src/index.ts"
39
39
  ],
40
- "skills": ["./skills"]
40
+ "skills": [
41
+ "./skills"
42
+ ]
41
43
  },
42
44
  "scripts": {
43
45
  "build": "tsc -p tsconfig.build.json",
@@ -6,7 +6,7 @@ description: Use when the user asks how their agents, skills or packages are doi
6
6
  # Analyze agent activity
7
7
 
8
8
  1. Call `evals_query` with `view: "findings"` first. Check the dates and last extraction; default is the latest 30 UTC dates in the index. Use `since` or `project` when the question specifies a narrower scope.
9
- 2. Follow **one** pointer that answers the question. For a weekly change in tool errors use `packages`; for a rule about editing use `process`; for what a piece of work cost, where it closed, where it stalled, or whether one way of working is cheaper, use `items`. Keep the same filters. Stop when the numbers answer the question.
9
+ 2. Follow **one** pointer that answers the question. For a weekly change in tool errors use `packages`; for a rule about editing use `process`; for what a piece of work cost, where it closed, where it stalled, or whether one way of working is cheaper, use `items`; for how far the code checks match the user's labels, or what the user corrected, use `labels`. Keep the same filters. Stop when the numbers answer the question.
10
10
  3. If one detail is still missing, run one script below. Set `SCRIPTS` to the absolute path on the `Scripts:` line or in `details.scriptsDir`. For a default npm install, the fallback is `SCRIPTS="$HOME/.pi/agent/npm/node_modules/pi-evals/scripts"`. Check `test -f "$SCRIPTS/query-lib.mjs"` before running a query; if it fails, stop rather than guessing another path. Use exact identifiers returned by the view; none of these commands reads a transcript.
11
11
 
12
12
  ```sh
@@ -18,6 +18,8 @@ node "$SCRIPTS/package-errors.mjs" PACKAGE [PROJECT]
18
18
  The first reads the saved `reports/model.json`: check its extract time and project before using the comparison. For a different saved page, prefix the command with `PI_EVALS_REPORT_RANGE=14`, `90`, `all` or `custom`. If the file is missing or out of date, say so; `/evals report` rebuilds the preset pages.
19
19
  The other two read the last 14 complete UTC dates in the index. Skill sessions count on their start date; package errors count on the date of the call. Neither script treats zero calls as a 0% error rate.
20
20
 
21
+ Reading `labels`: agreement counts the user's verdicts only, split into after the fact (from summaries) and in the moment (`/evals label`); corrections are what agents logged with `evals_label`, not all their mistakes, so do not read a count as an error rate.
22
+
21
23
  Reading `items`: an item is one todo task from `in_progress` to done or deleted. Subagent cost is exact; main cost is an estimate, split evenly among items in progress at the same moment, so say which part you quote. Compare only like with like (the view already separates work handed to subagents from work the main did itself); when it says "too few items to tell", say that in those words rather than reading the medians. A stall says what woke the main (`human`, `peer`, `child`, `timer`, `ci`, `device`), not why it waited; `on` names the subagent, peer session or sb wait (`W12`, `L340`, `T5`) when known.
22
24
 
23
25
  Lead with what rose, fell or held steady, and give the counts behind the rates. Say “too early to tell” when a side is short or too small; when other changes landed nearby, say “we cannot tell which change mattered.” Even a clear difference is not proof of cause. More sessions or skill loads measure activity, not better work.