pi-evals 0.6.0 → 0.6.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.
- package/CHANGELOG.md +7 -0
- package/README.md +3 -3
- package/dist/changes.js +15 -0
- package/dist/detectors.js +25 -3
- package/dist/extract/run.js +5 -7
- package/dist/extract/session.js +1 -1
- package/dist/meta.js +11 -0
- package/dist/model.js +37 -1
- package/dist/plan-graph.js +116 -0
- package/dist/query.js +5 -0
- package/dist/report/findings.js +17 -4
- package/dist/report/sections.js +5 -1
- package/dist/report/strip.js +2 -1
- package/docs/design.md +5 -3
- package/docs/schema.md +2 -1
- package/package.json +1 -1
- package/skills/analyzing-evals/SKILL.md +8 -0
- package/src/changes.ts +14 -0
- package/src/detectors.ts +7 -3
- package/src/extract/run.ts +11 -6
- package/src/extract/session.ts +1 -1
- package/src/meta.ts +19 -0
- package/src/model.ts +34 -1
- package/src/plan-graph.ts +117 -0
- package/src/query.ts +5 -0
- package/src/report/findings.ts +16 -3
- package/src/report/sections.ts +5 -1
- package/src/report/strip.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
- An extract stopped part-way after an extractor upgrade no longer passes off old results as current. Each session file's summary now records the extractor version that wrote it, and any other version is read again. Before, the first 0.6.0 extract was killed by a timeout and saved the new version mark while most summaries were still old, so the next run skipped them: check agreement read 11/20 instead of 23/24 until a full rebuild. Every session is read once more (extractor version 6).
|
|
6
|
+
- New check 「排工作時說清楚怎麼分工」 (`plan_names_graph`): whether a Straw Boss coordinator or standing main names its plan's graph (`single-loop`, `fan-out/fan-in`, `orchestrator-worker`; the todo's `graph` field or an older `metadata.graph`) when it first creates open todos. It also passes when the next todo call adds the graph after sb's planning reminder (sb 0.101.0 and later). It fails when the main keeps planning without one. Unlike the anchorloop checks, it is judged in sessions of any age, since sb mains live for weeks.
|
|
7
|
+
- The process view and report also split this check by pi-straw-boss version at session start, before and from 0.101.0. The change strip always highlights the sb pin that brings 0.101.0, including one that skips it (0.100.2 → 0.102.0, captioned 「含 0.101.0」).
|
|
8
|
+
- The analyzing-evals skill gains 「When a number looks wrong」: check freshness first, validate a detector against your labels, group misses by cause, keep a guard set, and treat hand labels as the reference.
|
|
9
|
+
|
|
3
10
|
## 0.6.0
|
|
4
11
|
|
|
5
12
|
- New command `/ask-ai <question>` has the agent answer you now instead of taking the question as a reproach and starting new work. The question goes in with a short instruction: answer first, in your language, change nothing, start no work, and end with at most one line of suggested next step. While that run lasts (until it ends or you send another message), `write`, `edit`, `subagent`, `boss_pair`, `MonitorCreate`, `LoopCreate`, `call_tower`, `todo` (except `list`/`get`) and `intercom` (`send`/`ask`/`handover`) are refused with a one-line reason; `bash`, `read` and other tools still run.
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Agents can read the same numbers through one tool, `evals_query`, and log a corr
|
|
|
11
11
|
- **Ask-user**: questions asked, how long you took to answer, how many you dismissed, and whether the answer came from the terminal or a remote channel.
|
|
12
12
|
- **Monitors**: background jobs by outcome and duration.
|
|
13
13
|
- **Subagents**: launches by role and model, and their cost by role.
|
|
14
|
-
- **Process**: four checks of the anchorloop rules per session, for sessions started after anchorloop 3.0.0 was pinned (2026-11-23T10:51:07Z); see [docs/design.md](docs/design.md#process-detectors).
|
|
14
|
+
- **Process**: four checks of the anchorloop rules per session, and one of the Straw Boss planning rule (a coordinator or standing main names its plan's graph), for sessions started after anchorloop 3.0.0 was pinned (2026-11-23T10:51:07Z); see [docs/design.md](docs/design.md#process-detectors).
|
|
15
15
|
- **Cost**: model cost and tokens, and the cost of the sessions that loaded each skill.
|
|
16
16
|
- **Work items**: each todo task from the moment it is switched to in progress until it is done or deleted: what it cost (subagents exactly, the main agent as an even share), where it closed (reviewer approval, a landed car, a wrap, evidence), where it stalled and on whom, and whether one way of working is cheaper than another of the same kind.
|
|
17
17
|
- **Your labels and corrections**: your verdict on a process rule, given in the moment with `/evals label` or after the fact, and the corrections an agent logs when you correct how it worked.
|
|
@@ -48,7 +48,7 @@ The observer loads in every session, subagents included.
|
|
|
48
48
|
| `/evals report [--since YYYY-MM-DD \| --days N] [--project <key>]` | Builds the linked date ranges, or one custom report when a start date or day count is given. |
|
|
49
49
|
| `/evals mark <note>` | Adds a note to the change timeline, e.g. `/evals mark workers moved to gpt-6.2-astra`. |
|
|
50
50
|
| `/evals label` | Labels the current session while the work is in front of you: pick a rule (or 「其他」), then 照做, 沒照做 or 看不出來, then an optional note in your own words. |
|
|
51
|
-
| `/evals label <rule> pass\|fail\|unclear [note]` | The same in one line; `<rule>` is a check name (`anchor_before_first_edit`, `check_after_last_edit`, `todo_evidence`, `close_guard_quiet`) or `other`. |
|
|
51
|
+
| `/evals label <rule> pass\|fail\|unclear [note]` | The same in one line; `<rule>` is a check name (`anchor_before_first_edit`, `check_after_last_edit`, `todo_evidence`, `close_guard_quiet`, `plan_names_graph`) or `other`. |
|
|
52
52
|
| `/evals label <your words>` | Anything else, e.g. `/evals label 剛剛沒先跑測試就說完成`: the agent turns your words into labels with `evals_label` and says in one line what it recorded. The verdict is yours and your words are kept as the note. |
|
|
53
53
|
| `/evals label undo` | Withdraws the current session's last label given in the moment. |
|
|
54
54
|
|
|
@@ -150,7 +150,7 @@ Use the section links for usage, process checks, cost and cleanup coverage, or r
|
|
|
150
150
|
| --- | --- |
|
|
151
151
|
| `events/<YYYY-MM-DD>.jsonl` | Live observer records. |
|
|
152
152
|
| `index/records/<YYYY-MM>/<key>.jsonl` | Back-filled records, one file per session file. |
|
|
153
|
-
| `index/checkpoint.json` | Size, modification time and
|
|
153
|
+
| `index/checkpoint.json` | Size, modification time, summary and the extractor version that wrote it, per session file. |
|
|
154
154
|
| `index/days.json` | Aggregates by day and project. |
|
|
155
155
|
| `index/sessions.json` | A few numbers per session with its start time, for splitting sessions at a change's time. |
|
|
156
156
|
| `index/session-evals.json` | Process check results per session, for joining your labels. |
|
package/dist/changes.js
CHANGED
|
@@ -168,3 +168,18 @@ export function versionAt(changes, pkg, at) {
|
|
|
168
168
|
}
|
|
169
169
|
return version;
|
|
170
170
|
}
|
|
171
|
+
/** Whether a dotted version is at or after `min`, by numeric parts; a version that is not dotted numbers (a git sha) is undefined. */
|
|
172
|
+
export function atLeast(version, min) {
|
|
173
|
+
const parts = (v) => (v && /^\d+(\.\d+)*$/.test(v) ? v.split(".").map(Number) : undefined);
|
|
174
|
+
const a = parts(version), b = parts(min);
|
|
175
|
+
if (!a || !b)
|
|
176
|
+
return undefined;
|
|
177
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++)
|
|
178
|
+
if ((a[i] ?? 0) !== (b[i] ?? 0))
|
|
179
|
+
return (a[i] ?? 0) > (b[i] ?? 0);
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
/** Whether a pin change brings `pkg` to `version` or past it, from a version before it (or none): a version it skipped counts. */
|
|
183
|
+
export function crosses(c, pkg, version) {
|
|
184
|
+
return c.kind === "pin" && c.package === pkg && atLeast(c.to, version) === true && atLeast(c.from, version) !== true;
|
|
185
|
+
}
|
package/dist/detectors.js
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process detectors over one session, fed entries in file order. Each yields a session-scoped
|
|
3
|
+
* `gen_ai.evaluation.result` (annotator CODE). Commands and text are held in memory only while the
|
|
4
|
+
* session is read; results carry fixed reason codes, never text.
|
|
5
|
+
*
|
|
6
|
+
* Anchor and change reading is ported from pi-anchorloop's close guard (`pi/close-guard.ts` `read()`,
|
|
7
|
+
* MIT, Copyright (c) 2026 Wei Hung, anchorloop 3.3.0 at 7614445): the last `Anchor:` line or todo anchor,
|
|
8
|
+
* backticked commands (a todo's bare value is one command), a change is a successful `write` or `edit`,
|
|
9
|
+
* a bash run passes on exit code 0 (else on `isError` false), and a run matches an anchor command when it contains it.
|
|
10
|
+
* Like the guard, an edit made through bash is not seen as a change.
|
|
11
|
+
*
|
|
12
|
+
* Unlike the guard, these read the other shapes agents state and run a check in (0.5.1, from human labels): an anchor
|
|
13
|
+
* in the brief (`Anchor:`, `Gates:`, `Checks:`, or a check command it names), a labelled check line in the agent's
|
|
14
|
+
* words (`驗證:`, `Verify:`), a todo's sb check spec, or a first change to a test file (red first); and a check run
|
|
15
|
+
* in a monitor (by its exit code), passing evidence recorded after the last change, or, when no anchor command ran,
|
|
16
|
+
* a test, build, lint or type-check run after it.
|
|
17
|
+
*/
|
|
18
|
+
import { PlanGraphTracker } from "./plan-graph.js";
|
|
1
19
|
/**
|
|
2
20
|
* anchorloop 3.0.0 (one anchor rule and the close guard) reached this setup when weihung-basic-agent pinned it
|
|
3
21
|
* (commit 9f72366, 2026-11-23T10:51:07Z). Sessions that started earlier are out of scope.
|
|
4
22
|
*/
|
|
5
23
|
export const ERA_START = "2026-11-23T10:51:07.000Z";
|
|
6
|
-
export const DETECTORS = ["anchor_before_first_edit", "check_after_last_edit", "todo_evidence", "close_guard_quiet"];
|
|
24
|
+
export const DETECTORS = ["anchor_before_first_edit", "check_after_last_edit", "todo_evidence", "close_guard_quiet", "plan_names_graph"];
|
|
7
25
|
const NOTICE_TYPE = "anchorloop-close-guard";
|
|
8
26
|
const MAX_RUNS = 5000;
|
|
9
27
|
export function noticeKind(text) {
|
|
@@ -74,10 +92,13 @@ export class ProcessTracker {
|
|
|
74
92
|
sawUser = false;
|
|
75
93
|
briefAnchor = false;
|
|
76
94
|
notices = new Map();
|
|
95
|
+
plan = new PlanGraphTracker();
|
|
77
96
|
/** Notice kinds seen so far, for `anchorloop.close_guard.notice` records. */
|
|
78
97
|
feed(raw) {
|
|
79
98
|
const entry = raw;
|
|
80
99
|
const seq = ++this.seq;
|
|
100
|
+
if (entry && typeof entry === "object")
|
|
101
|
+
this.plan.feed(entry);
|
|
81
102
|
if (entry?.type === "custom" && entry.customType === "todo/v1" && entry.data?.v === 1 && Array.isArray(entry.data.tasks)) {
|
|
82
103
|
this.tasks = entry.data.tasks;
|
|
83
104
|
return undefined;
|
|
@@ -176,9 +197,10 @@ export class ProcessTracker {
|
|
|
176
197
|
this.runs.splice(0, this.runs.length - MAX_RUNS);
|
|
177
198
|
}
|
|
178
199
|
results(inScope) {
|
|
200
|
+
// The anchorloop era bounds the anchorloop rules only; the sb planning rule is judged in every session (long-lived mains started earlier).
|
|
179
201
|
if (!inScope)
|
|
180
|
-
return DETECTORS_ALL.map((name) => ({ name, label: "na", explanation: "out_of_scope_pre_3.0" }));
|
|
181
|
-
return [this.anchorFirst(), this.checkAfter(), this.todoEvidence(), this.quiet()];
|
|
202
|
+
return [...DETECTORS_ALL.filter((name) => name !== "plan_names_graph").map((name) => ({ name, label: "na", explanation: "out_of_scope_pre_3.0" })), this.plan.results()];
|
|
203
|
+
return [this.anchorFirst(), this.checkAfter(), this.todoEvidence(), this.quiet(), this.plan.results()];
|
|
182
204
|
}
|
|
183
205
|
anchorFirst() {
|
|
184
206
|
const name = "anchor_before_first_edit";
|
package/dist/extract/run.js
CHANGED
|
@@ -6,8 +6,8 @@ import { dirname, join } from "node:path";
|
|
|
6
6
|
import { Worker } from "node:worker_threads";
|
|
7
7
|
import { fileKey } from "../schema.js";
|
|
8
8
|
import { extractFile } from "./file.js";
|
|
9
|
-
/** Bump when extraction changes what it derives;
|
|
10
|
-
export const EXTRACTOR_VERSION =
|
|
9
|
+
/** Bump when extraction changes what it derives; every summary written by another version is read again. */
|
|
10
|
+
export const EXTRACTOR_VERSION = 6;
|
|
11
11
|
export function loadCheckpoint(file) {
|
|
12
12
|
if (!existsSync(file))
|
|
13
13
|
return { v: 1, extractor: EXTRACTOR_VERSION, files: {}, catalogs: {} };
|
|
@@ -93,13 +93,11 @@ export async function extract(options) {
|
|
|
93
93
|
const started = Date.now();
|
|
94
94
|
const checkpoint = loadCheckpoint(options.layout.checkpoint);
|
|
95
95
|
const files = listSessionFiles(options.roots);
|
|
96
|
-
|
|
96
|
+
// The checkpoint-wide field only says which version last ran; staleness is per entry (an interrupted run saves both kinds).
|
|
97
97
|
checkpoint.extractor = EXTRACTOR_VERSION;
|
|
98
98
|
const changed = files.filter((f) => {
|
|
99
99
|
const known = checkpoint.files[f.path];
|
|
100
|
-
|
|
101
|
-
return true;
|
|
102
|
-
return !known || known.size !== f.size || known.mtimeMs !== f.mtimeMs;
|
|
100
|
+
return !known || known.extractor !== EXTRACTOR_VERSION || known.size !== f.size || known.mtimeMs !== f.mtimeMs;
|
|
103
101
|
});
|
|
104
102
|
const stats = { files: files.length, changed: changed.length, failed: 0, bytes: 0, records: 0, ms: 0, errors: [] };
|
|
105
103
|
const byPath = new Map(changed.map((f) => [f.path, f]));
|
|
@@ -127,7 +125,7 @@ export async function extract(options) {
|
|
|
127
125
|
else {
|
|
128
126
|
stats.records += result.records;
|
|
129
127
|
const key = fileKey(file.path);
|
|
130
|
-
checkpoint.files[file.path] = { size: file.size, mtimeMs: file.mtimeMs, key, month: monthOf(file.path), summary: result.summary };
|
|
128
|
+
checkpoint.files[file.path] = { size: file.size, mtimeMs: file.mtimeMs, key, month: monthOf(file.path), summary: result.summary, extractor: EXTRACTOR_VERSION };
|
|
131
129
|
if (result.catalog?.length) {
|
|
132
130
|
const hash = createHash("sha1").update(result.catalog.join("\n")).digest("hex").slice(0, 16);
|
|
133
131
|
result.summary.catalog = hash;
|
package/dist/extract/session.js
CHANGED
|
@@ -405,7 +405,7 @@ export class SessionReader {
|
|
|
405
405
|
const evals = {};
|
|
406
406
|
for (const result of this.tracker.results(inScope)) {
|
|
407
407
|
evals[result.name] = { label: result.label, value: result.value, explanation: result.explanation };
|
|
408
|
-
if (
|
|
408
|
+
if (result.explanation !== "out_of_scope_pre_3.0") {
|
|
409
409
|
const t = (startDay.detectors[result.name] ??= { pass: 0, fail: 0, na: 0 });
|
|
410
410
|
t[result.label] += 1;
|
|
411
411
|
}
|
package/dist/meta.js
CHANGED
|
@@ -258,6 +258,17 @@ export const DETECTOR_META = {
|
|
|
258
258
|
fail: t("Edits and ends; the guard adds 'no passing run of `npm test`'.", "改檔就結束,收尾檢查加上「沒有 `npm test` 的通過紀錄」。"),
|
|
259
259
|
},
|
|
260
260
|
},
|
|
261
|
+
plan_names_graph: {
|
|
262
|
+
introducedIn: { package: "pi-straw-boss", version: "0.101.0" },
|
|
263
|
+
label: t("Plan says how the work splits", "排工作時說清楚怎麼分工"),
|
|
264
|
+
meaning: t("When a Straw Boss main (coordinator or standing) writes its plan as todos, it names the plan's shape: one loop it runs itself, parallel workers it merges, or an orchestrator handing work out.", "Straw Boss 的主代理(協調或常駐)把計畫寫成待辦時,有說明這份計畫的分工方式:自己一路做完、分給幾個人平行做再合併,或由主代理派工給工作者。"),
|
|
265
|
+
goodDirection: "higher",
|
|
266
|
+
howComputed: t("Passes when the open todos left by the main's first todo create carry a graph (the todo's graph field, or an older metadata.graph), or when its next todo call adds one, as sb 0.101.0 and later ask on that create. Fails when it went on planning without one. Sessions that are not such a main, or never planned, do not count.", "主代理第一次建立待辦後,還沒完成的待辦有標分工方式(待辦的 graph 欄位,或舊版的 metadata.graph)即通過;第一次沒標、但下一次動待辦時補上的也算通過(sb 0.101.0 起會在那次建立待辦時提醒)。沒標就繼續排工作的不通過。不是這類主代理、或從沒排過工作的不算。"),
|
|
267
|
+
example: {
|
|
268
|
+
pass: t("Creates three todos with graph 'fan-out/fan-in', then dispatches them.", "建立三項待辦並標上「fan-out/fan-in」,再派出去。"),
|
|
269
|
+
fail: t("Creates three todos with no graph, gets sb's reminder, and adds a fourth without one.", "建立三項待辦沒標分工方式,收到 sb 提醒後又加了第四項,仍然沒標。"),
|
|
270
|
+
},
|
|
271
|
+
},
|
|
261
272
|
};
|
|
262
273
|
export const NOTICE_META = {
|
|
263
274
|
no_anchor: t("Files changed but no Anchor was stated", "改了檔案但沒說要怎麼驗證"),
|
package/dist/model.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { ASK_BUCKETS, emptyDay, mergeDay } from "./aggregate.js";
|
|
7
|
-
import { versionAt } from "./changes.js";
|
|
7
|
+
import { atLeast, versionAt } from "./changes.js";
|
|
8
8
|
import { DETECTORS, ERA_START } from "./detectors.js";
|
|
9
9
|
import { CHANGE_KIND_META, CLOSE_KIND_META, DETECTOR_META, METRICS, NOTICE_META, STALL_KIND_META } from "./meta.js";
|
|
10
10
|
import { staticOwner } from "./owners.js";
|
|
@@ -108,6 +108,41 @@ export function impactMetrics(rows, ownerOf, pkg) {
|
|
|
108
108
|
anchor_before_first_edit: d("anchor_before_first_edit"),
|
|
109
109
|
check_after_last_edit: d("check_after_last_edit"),
|
|
110
110
|
todo_evidence: d("todo_evidence"),
|
|
111
|
+
plan_names_graph: d("plan_names_graph"),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/** Dotted versions in numeric order; anything else (unknown, a sha) after them. */
|
|
115
|
+
const byVersion = (a, b) => {
|
|
116
|
+
const pa = /^\d+(\.\d+)*$/.test(a) ? a.split(".").map(Number) : undefined, pb = /^\d+(\.\d+)*$/.test(b) ? b.split(".").map(Number) : undefined;
|
|
117
|
+
if (!pa || !pb)
|
|
118
|
+
return pa ? -1 : pb ? 1 : a.localeCompare(b);
|
|
119
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++)
|
|
120
|
+
if ((pa[i] ?? 0) !== (pb[i] ?? 0))
|
|
121
|
+
return (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
122
|
+
return 0;
|
|
123
|
+
};
|
|
124
|
+
/** A detector's results by the version of the package it measures, at each session's start, and before and from the version that brought it. */
|
|
125
|
+
export function packageSplit(rows, changes, detector, since) {
|
|
126
|
+
const versions = new Map();
|
|
127
|
+
const sides = { before: { pass: 0, fail: 0 }, after: { pass: 0, fail: 0 } };
|
|
128
|
+
for (const r of rows) {
|
|
129
|
+
const v = r.ev[detector];
|
|
130
|
+
if (v === undefined)
|
|
131
|
+
continue;
|
|
132
|
+
const version = versionAt(changes, since.package, r.s) ?? "unknown";
|
|
133
|
+
const cell = versions.get(version) ?? { pass: 0, fail: 0 };
|
|
134
|
+
cell[v ? "pass" : "fail"] += 1;
|
|
135
|
+
versions.set(version, cell);
|
|
136
|
+
const later = atLeast(version, since.version);
|
|
137
|
+
if (later !== undefined)
|
|
138
|
+
sides[later ? "after" : "before"][v ? "pass" : "fail"] += 1;
|
|
139
|
+
}
|
|
140
|
+
const withRate = (x) => ({ ...x, passRate: rate(x.pass, x.pass + x.fail) });
|
|
141
|
+
return {
|
|
142
|
+
...since,
|
|
143
|
+
versions: [...versions].sort(([a], [b]) => byVersion(a, b)).map(([version, x]) => ({ version, ...withRate(x) })),
|
|
144
|
+
before: withRate(sides.before),
|
|
145
|
+
after: withRate(sides.after),
|
|
111
146
|
};
|
|
112
147
|
}
|
|
113
148
|
/** Changes from one commit (or one mark) count once. */
|
|
@@ -278,6 +313,7 @@ export function buildModel(options) {
|
|
|
278
313
|
return { day, pass: x.pass, fail: x.fail };
|
|
279
314
|
}),
|
|
280
315
|
byVersion: (versions.get(d.name) ?? []).map((v) => ({ ...v, passRate: rate(v.pass, v.pass + v.fail) })),
|
|
316
|
+
byPackage: DETECTOR_META[d.name]?.introducedIn ? packageSplit(selected, sortedChanges, d.name, DETECTOR_META[d.name].introducedIn) : null,
|
|
281
317
|
})),
|
|
282
318
|
notices: total.notices,
|
|
283
319
|
},
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/** The planning-rule block's first line (sb `planhint.ts` OPENING). */
|
|
2
|
+
const RULE_OPENING = "sb: your open todos name no graph.";
|
|
3
|
+
const GRAPHS = new Set(["single-loop", "fan-out/fan-in", "orchestrator-worker"]);
|
|
4
|
+
const JUDGED = new Set(["coordinator", "standing"]);
|
|
5
|
+
const MAIN_PROMPT = /You are the main agent of Herdr tab .*?,? of kind ([a-z]+)/;
|
|
6
|
+
const STANDING_PROMPT = /You are the standing main of Herdr tab /;
|
|
7
|
+
const obj = (v) => (v && typeof v === "object" ? v : {});
|
|
8
|
+
/** A legacy `metadata.graph` as mains wrote it, normalised like sb's `graphOf`. */
|
|
9
|
+
export function legacyGraph(v) {
|
|
10
|
+
if (v === "orchestrator-worker")
|
|
11
|
+
return v;
|
|
12
|
+
if (v === "fan-out/fan-in" || v === "fan-out")
|
|
13
|
+
return "fan-out/fan-in";
|
|
14
|
+
if (v === "single" || (typeof v === "string" && v.startsWith("single-loop")))
|
|
15
|
+
return "single-loop";
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
/** A todo's graph: its own field when it is a graph name, else its legacy metadata. */
|
|
19
|
+
export function graphOfTodo(todo) {
|
|
20
|
+
const t = obj(todo);
|
|
21
|
+
if (typeof t.graph === "string" && GRAPHS.has(t.graph))
|
|
22
|
+
return t.graph;
|
|
23
|
+
return legacyGraph(obj(t.metadata).graph);
|
|
24
|
+
}
|
|
25
|
+
/** The plan's open todos: not completed or deleted, and not a train's step. */
|
|
26
|
+
function openOf(tasks) {
|
|
27
|
+
return tasks.map(obj).filter((t) => t.status !== "completed" && t.status !== "deleted" && !obj(t.metadata).sb);
|
|
28
|
+
}
|
|
29
|
+
function text(content) {
|
|
30
|
+
if (typeof content === "string")
|
|
31
|
+
return content;
|
|
32
|
+
return Array.isArray(content) ? content.map((p) => (obj(p).type === "text" ? String(obj(p).text ?? "") : "")).join("\n") : "";
|
|
33
|
+
}
|
|
34
|
+
export class PlanGraphTracker {
|
|
35
|
+
kind;
|
|
36
|
+
wasMain = false;
|
|
37
|
+
tasks;
|
|
38
|
+
calls = new Map();
|
|
39
|
+
/** The first plan (a create leaving open todos) named no graph; `rule`: sb's block came with it. */
|
|
40
|
+
missed;
|
|
41
|
+
result;
|
|
42
|
+
feed(entry) {
|
|
43
|
+
if (this.result)
|
|
44
|
+
return;
|
|
45
|
+
const type = entry.type;
|
|
46
|
+
if (type === "custom") {
|
|
47
|
+
const data = obj(entry.data);
|
|
48
|
+
if (entry.customType === "todo/v1" && Array.isArray(data.tasks))
|
|
49
|
+
this.tasks = data.tasks;
|
|
50
|
+
else if (entry.customType === "straw-boss" && typeof data.duty === "string" && this.kind)
|
|
51
|
+
this.setKind(data.duty);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (type === "custom_message" && entry.customType === "straw-boss") {
|
|
55
|
+
const briefed = obj(obj(entry.details).briefed);
|
|
56
|
+
const role = briefed.name ?? briefed.role;
|
|
57
|
+
if (typeof role === "string")
|
|
58
|
+
this.setKind(role === "main" && typeof briefed.duty === "string" ? briefed.duty : undefined);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (type !== "message")
|
|
62
|
+
return;
|
|
63
|
+
const message = obj(entry.message);
|
|
64
|
+
if (message.role === "system") {
|
|
65
|
+
const section = obj(message.sections)["straw-boss"];
|
|
66
|
+
if (typeof section !== "string")
|
|
67
|
+
return;
|
|
68
|
+
this.setKind(STANDING_PROMPT.test(section) ? "standing" : MAIN_PROMPT.exec(section)?.[1]);
|
|
69
|
+
}
|
|
70
|
+
else if (message.role === "assistant" && Array.isArray(message.content)) {
|
|
71
|
+
for (const raw of message.content) {
|
|
72
|
+
const part = obj(raw);
|
|
73
|
+
if (part.type === "toolCall" && part.name === "todo" && typeof part.id === "string")
|
|
74
|
+
this.calls.set(part.id, obj(part.arguments).action === "create");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else if (message.role === "toolResult" && typeof message.toolCallId === "string" && this.calls.has(message.toolCallId)) {
|
|
78
|
+
const create = this.calls.get(message.toolCallId);
|
|
79
|
+
this.calls.delete(message.toolCallId);
|
|
80
|
+
if (message.isError === true || !this.kind || !JUDGED.has(this.kind))
|
|
81
|
+
return;
|
|
82
|
+
const listed = obj(message.details).tasks;
|
|
83
|
+
this.todoResult(create, Array.isArray(listed) ? listed : (this.tasks ?? []), text(message.content).includes(RULE_OPENING));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
setKind(kind) {
|
|
87
|
+
this.kind = kind;
|
|
88
|
+
if (kind && JUDGED.has(kind))
|
|
89
|
+
this.wasMain = true;
|
|
90
|
+
}
|
|
91
|
+
todoResult(create, tasks, rule) {
|
|
92
|
+
const name = "plan_names_graph";
|
|
93
|
+
const open = openOf(tasks);
|
|
94
|
+
const named = open.some((t) => graphOfTodo(t));
|
|
95
|
+
if (!this.missed) {
|
|
96
|
+
if (!create || !open.length)
|
|
97
|
+
return;
|
|
98
|
+
if (named)
|
|
99
|
+
this.result = { name, label: "pass", explanation: "graph_at_first_create" };
|
|
100
|
+
else
|
|
101
|
+
this.missed = { rule };
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
this.result = named
|
|
105
|
+
? { name, label: "pass", explanation: this.missed.rule ? "graph_after_rule" : "graph_next_todo_call" }
|
|
106
|
+
: { name, label: "fail", explanation: "kept_planning_without_graph" };
|
|
107
|
+
}
|
|
108
|
+
results() {
|
|
109
|
+
const name = "plan_names_graph";
|
|
110
|
+
if (this.result)
|
|
111
|
+
return this.result;
|
|
112
|
+
if (this.missed)
|
|
113
|
+
return { name, label: "fail", explanation: "plan_without_graph" };
|
|
114
|
+
return { name, label: "na", explanation: this.wasMain ? "no_plan" : "not_sb_main" };
|
|
115
|
+
}
|
|
116
|
+
}
|
package/dist/query.js
CHANGED
|
@@ -88,6 +88,11 @@ export function query(view, options = {}) {
|
|
|
88
88
|
const versions = d.byVersion.filter((v) => v.pass + v.fail > 0).map((v) => `${v.version} ${pct(v.passRate)}`);
|
|
89
89
|
if (versions.length)
|
|
90
90
|
body.push(` by anchorloop version: ${versions.slice(-4).join("; ")}`);
|
|
91
|
+
const p = d.byPackage;
|
|
92
|
+
if (p) {
|
|
93
|
+
const byV = p.versions.filter((v) => v.pass + v.fail > 0).map((v) => `${v.version} ${pct(v.passRate)}`);
|
|
94
|
+
body.push(` by ${p.package} version: ${byV.slice(-6).join("; ") || "n/a"}; before ${p.version} ${pct(p.before.passRate)}, from ${p.version} ${pct(p.after.passRate)}`);
|
|
95
|
+
}
|
|
91
96
|
}
|
|
92
97
|
body.push(`close-guard reminders: ${Object.entries(m.process.notices).map(([k, v]) => `${k} ${v}`).join(", ") || "none"}`);
|
|
93
98
|
}
|
package/dist/report/findings.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
+
import { crosses } from "../changes.js";
|
|
1
2
|
import { num, pct, usd, words } from "./format.js";
|
|
3
|
+
/** The detector whose package version this pin change brings in (or skips past), with that version. */
|
|
4
|
+
export function introduced(c, m) {
|
|
5
|
+
for (const [name, md] of Object.entries(m.meta.detectors)) {
|
|
6
|
+
if (md.introducedIn && crosses(c, md.introducedIn.package, md.introducedIn.version))
|
|
7
|
+
return { detector: name, version: md.introducedIn.version };
|
|
8
|
+
}
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
2
11
|
export function readings(c, m, lang) {
|
|
3
12
|
const L = words(lang), i = c.impact;
|
|
4
13
|
const has = (k) => i?.before[k]?.value != null && i.after[k]?.value != null;
|
|
5
14
|
const process = c.package === "pi-anchorloop" && has("anchor_before_first_edit");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
15
|
+
const brings = introduced(c, m);
|
|
16
|
+
const keys = brings
|
|
17
|
+
? [brings.detector, "cost_per_session"]
|
|
18
|
+
: process
|
|
19
|
+
? ["anchor_before_first_edit", "check_after_last_edit"]
|
|
20
|
+
: [has("package_error_rate") ? "package_error_rate" : "tool_error_rate", "cost_per_session"];
|
|
9
21
|
return keys.map((key) => {
|
|
10
22
|
const meta = m.meta.detectors[key] ?? m.meta.metrics[key === "package_error_rate" ? "tool_error_rate" : key];
|
|
11
23
|
return {
|
|
@@ -54,7 +66,8 @@ export function select(m) {
|
|
|
54
66
|
const rest = candidates.filter((c) => c !== lead && c.at <= lead.at && (!lead.sha || c.sha !== lead.sha));
|
|
55
67
|
const second = rest.find((c) => c.impact?.smallSample && c.impact.before.sessions && c.impact.after.sessions) ??
|
|
56
68
|
rest.find((c) => (c.kind === "pin" || c.kind === "model-routing") && c.impact && !c.impact.incomplete) ?? rest[0];
|
|
57
|
-
|
|
69
|
+
// A pin change that brings a detector's package version is always shown: it is what that detector measures.
|
|
70
|
+
const highlighted = all.filter((c) => c === lead || c === second || !!introduced(c, m));
|
|
58
71
|
return { all, lead, highlighted, folded: all.filter((c) => !highlighted.includes(c)) };
|
|
59
72
|
}
|
|
60
73
|
/** Editorial choices shared by the HTML timeline and the compact query. */
|
package/dist/report/sections.js
CHANGED
|
@@ -36,7 +36,11 @@ export function sections(m, lang, cards) {
|
|
|
36
36
|
const process = section("process", L("Did the agent follow the steps?", "工作有沒有照說好的步驟走?"), L(`Only sessions starting from ${m.process.eraStart} are judged. Earlier work is not a failure.`, `只檢查 ${m.process.eraStart} 起的工作;更早的工作不算失敗。`), lesson(cards.check, L) + `<div class="pair checks">${m.process.detectors.map((d) => {
|
|
37
37
|
const md = m.meta.detectors[d.name];
|
|
38
38
|
return `<article class="panel"><p class="eyebrow">${L("Code check", "程式檢查")} / ${L("higher is better", "越高越好")}</p><h3>${esc(md.label[lang])}</h3><p class="big">${pct(d.passRate)} <small>${num(d.pass)} / ${num(d.passRate.n)} ${L("sessions", "段")}</small></p><p>${esc(md.howComputed[lang])}</p><p><b>${L("Pass", "通過")}</b> ${esc(md.example.pass[lang])}<br><b>${L("Fail", "未通過")}</b> ${esc(md.example.fail[lang])}</p>${more(L("By day and version", "查看每日與各版本的通過數"), T([L("Day", "日期"), L("Pass", "通過"), L("Fail", "未通過")], d.perDay.map((r) => [r.day, r.pass, r.fail])) +
|
|
39
|
-
T([L("Version", "版本"), L("Pass", "通過"), L("Fail", "未通過")], d.byVersion.map((r) => [r.version, r.pass, r.fail]))
|
|
39
|
+
T([L("Version", "版本"), L("Pass", "通過"), L("Fail", "未通過")], d.byVersion.map((r) => [r.version, r.pass, r.fail])) +
|
|
40
|
+
(d.byPackage
|
|
41
|
+
? `<p>${esc(L(`By ${d.byPackage.package} version: before ${d.byPackage.version} ${pct(d.byPackage.before.passRate)}, from ${d.byPackage.version} ${pct(d.byPackage.after.passRate)}.`, `依 ${d.byPackage.package} 版本:${d.byPackage.version} 之前 ${pct(d.byPackage.before.passRate)},${d.byPackage.version} 起 ${pct(d.byPackage.after.passRate)}。`))}</p>` +
|
|
42
|
+
T([L(`${d.byPackage.package} version`, `${d.byPackage.package} 版本`), L("Pass", "通過"), L("Fail", "未通過")], d.byPackage.versions.map((r) => [r.version, r.pass, r.fail]))
|
|
43
|
+
: ""))}</article>`;
|
|
40
44
|
}).join("")}</div>` +
|
|
41
45
|
more(L("Close-guard reminders", "收尾提醒"), T([L("Kind", "種類"), L("Count", "次數")], entries(m.process.notices).map(([k, n]) => [m.meta.notices[k]?.[lang] ?? k, n]))));
|
|
42
46
|
const cost = section("cost", L("What the work cost", "工作花了多少錢"), meta.cost.meaning[lang], `<p class="big">${usd(m.cost.total)} <small>USD</small></p><p>${label("cost_per_session")} ${usd(m.cost.perSession.value)}(${num(m.cost.perSession.n)} ${L("sessions", "段")})</p><p>${esc(meta.skill_cost.meaning[lang])}</p>` +
|
package/dist/report/strip.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { introduced } from "./findings.js";
|
|
1
2
|
import { esc, num, words } from "./format.js";
|
|
2
3
|
const KINDS = ["pin", "model-routing", "rule", "agent-role", "skill", "manual"];
|
|
3
4
|
/** Dense time slots get a count; every change still has its own mark and title. */
|
|
@@ -34,7 +35,7 @@ export function changeStrip(m, all, picks, ids, lang, range) {
|
|
|
34
35
|
marks.push(`<text class="slot-count" x="${left + 14}" y="28" text-anchor="middle">×${cells.length}</text>`);
|
|
35
36
|
}
|
|
36
37
|
const links = picks.map((c, i) => {
|
|
37
|
-
const { px, py, dot } = labeled.get(c), end = px > 700, caption = c.package ? `${c.package} ${c.to ?? ""}` : `${label(c.kind)} · ${c.at.slice(5, 16).replace("T", " ")}`;
|
|
38
|
+
const { px, py, dot } = labeled.get(c), end = px > 700, brings = introduced(c, m), skipped = brings && brings.version !== c.to ? L(` (includes ${brings.version})`, `(含 ${brings.version})`) : "", caption = c.package ? `${c.package} ${c.to ?? ""}${skipped}` : `${label(c.kind)} · ${c.at.slice(5, 16).replace("T", " ")}`;
|
|
38
39
|
const y = 87 + i * 23;
|
|
39
40
|
return `<a href="#${ids.get(c)}"><title>${esc(caption)}</title><path class="guide" d="M${px} ${py}V${y - 6}h${end ? -7 : 7}"/>${dot}<text x="${px + (end ? -10 : 10)}" y="${y}" text-anchor="${end ? "end" : "start"}">${esc(Array.from(caption).length > 48 ? Array.from(caption).slice(0, 47).join("") + "…" : caption)}</text></a>`;
|
|
40
41
|
}).join("");
|
package/docs/design.md
CHANGED
|
@@ -45,7 +45,7 @@ The privacy test was written first and failed on exactly that: a secret placed i
|
|
|
45
45
|
|
|
46
46
|
The session files hold almost everything (instrumentation §5): tool calls with `durationMs` (from October on; older calls use the time between call and result), the ask-user results in both the current and the retired `pi-ask-user` shapes, the skill catalog pi offered (the system message's `skills` section), monitor endings delivered as `pi-loop-monitor` messages, and close-guard notices.
|
|
47
47
|
Extraction streams each file line by line on a pool of worker threads and writes one record file per session file atomically.
|
|
48
|
-
It is incremental by path, size and modification time, so a later extract reads only active sessions;
|
|
48
|
+
It is incremental by path, size and modification time, so a later extract reads only active sessions; each file's summary carries the extractor version that wrote it, and a summary from another version is read again. The stamp is per file because an extract stopped after a version bump (0.6.0's first run was killed by a 900 s timeout) saved a checkpoint marked with the new version while most summaries were still old, and the next run skipped them.
|
|
49
49
|
A subagent session is linked to its parent three ways: the parent's `subagent` result (`details.id`, the child's logical id), `~/.pi/agent/dispatch-ledger/<parent>.json`, and the artifacts path in the child's brief.
|
|
50
50
|
Live records and back-fill meet by session id: back-fill counts win, and live adds monitor lifecycles and answer sources.
|
|
51
51
|
|
|
@@ -56,18 +56,20 @@ It appends to the state dir, never to the session file, and a failed write warns
|
|
|
56
56
|
|
|
57
57
|
### Process detectors
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
Five session-scoped checks, each a `gen_ai.evaluation.result` with `annotator_kind` CODE.
|
|
60
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).
|
|
61
61
|
|
|
62
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
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`.
|
|
64
64
|
- `todo_evidence`: completed tasks in the final todo list carry evidence; the value is the share that do.
|
|
65
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).
|
|
66
|
+
- `plan_names_graph`: a Straw Boss main of kind coordinator or standing names its plan's graph when it plans. The kind comes from the sb role prompt (system section `straw-boss`: "of kind <kind>", or "the standing main"), role steers (`details.briefed`), and kind entries (`data.duty`); an integrator, a member or a session with no sb role is `not_sb_main`. The plan is the open todos (not completed or deleted, not a train's `metadata.sb` step) a `todo` result lists. It passes when the first create that leaves open todos has one with a graph (the todo's `graph`, a name of pi-todo-ledger 0.4.0's three, else a legacy `metadata.graph` normalised as sb's `graphOf`; `graph_at_first_create`), or when the next todo call's open todos have one (`graph_after_rule` when sb's planning-rule block came on the create, sb 0.101.0 and later, else `graph_next_todo_call`). It fails when the next todo call still names none (`kept_planning_without_graph`) or there is none (`plan_without_graph`).
|
|
66
67
|
|
|
67
|
-
Only sessions that started after anchorloop 3.0.0 reached this setup are judged: the pin commit in weihung-basic-agent, 2026-11-23T10:51:07Z. Older sessions are out of scope rather than failing (inventory, Gotchas), and they are left out of the "not applicable" counts.
|
|
68
|
+
Only sessions that started after anchorloop 3.0.0 reached this setup are judged by the four anchorloop checks (`plan_names_graph` is judged in every session: sb mains live for weeks): the pin commit in weihung-basic-agent, 2026-11-23T10:51:07Z. Older sessions are out of scope rather than failing (inventory, Gotchas), and they are left out of the "not applicable" counts.
|
|
68
69
|
Like the guard, an edit made through bash is not seen as a change.
|
|
69
70
|
These are process checks on observable events, which suits a process skill whose path is the product (research §1); they say how often the rules were followed, not whether the work was right.
|
|
70
71
|
A session's anchorloop version is the newest pin in the change timeline at or before the session's start, so a pin at 16:46 splits that day's sessions at 16:46.
|
|
72
|
+
A detector that measures a package version's arrival names it in its metadata (`introducedIn`; `plan_names_graph`: pi-straw-boss 0.101.0). The process view and the report then also split its results by that package's version at each session's start, and before and from that version; the pin change that brings the version, or skips past it (0.100.2 → 0.102.0), is always highlighted on the change strip and captioned with the version it includes. A session picks up a new package version only after `/reload` or a restart, and it is split by its start, so a long-lived main reloaded after the pin still counts on the earlier side; read the "from" side as fresh sessions only.
|
|
71
73
|
|
|
72
74
|
### Change impact
|
|
73
75
|
|
package/docs/schema.md
CHANGED
|
@@ -49,8 +49,9 @@ Back-fill rebuilds each session's items from its `todo/v1` snapshots, diffed alo
|
|
|
49
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
|
+
| `plan_names_graph` | `graph_at_first_create`, `graph_after_rule`, `graph_next_todo_call` | `kept_planning_without_graph`, `plan_without_graph` | `not_sb_main`, `no_plan` |
|
|
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
|
|
54
|
+
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 the four anchorloop checks; `plan_names_graph` is judged in every session, since sb mains live for weeks.
|
|
54
55
|
|
|
55
56
|
## Labels
|
|
56
57
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-evals",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.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",
|
|
@@ -23,3 +23,11 @@ Reading `labels`: agreement counts the user's verdicts only, split into after th
|
|
|
23
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.
|
|
24
24
|
|
|
25
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.
|
|
26
|
+
|
|
27
|
+
## When a number looks wrong
|
|
28
|
+
|
|
29
|
+
1. Check freshness first: the last extract time, and the `extractor` stamp on the summaries in `index/checkpoint.json` against the current version. A run stopped mid-way once left old summaries under a new checkpoint (check agreement read 11/20; a clean rebuild gave 23/24). If they disagree, say the number is stale and do not interpret it.
|
|
30
|
+
2. Before trusting a detector's rate, check it against the user's labels: the `labels` view, then the disagreeing sessions one by one, and which way they lean. All code=fail with human=pass means the detector undercounts (an anchor rate read 20% that was about 73%).
|
|
31
|
+
3. Error analysis: read the disagreeing sessions' structure (entry types, tool names, order; no transcript text into records), group the misses by cause, count each group, and fix the biggest first.
|
|
32
|
+
4. When loosening a detector, keep a guard set of real should-fail sessions that must stay fail. A rule ambiguity (an anchor stated after the first edit) is the user's decision: ask, record it as a `recheck` label, and do not settle it silently in code.
|
|
33
|
+
5. Have the user label about 30 sessions by hand before trusting any automated grader; human labels are the reference. Observational numbers are monitoring; whether skill X helped needs a controlled experiment, not this report.
|
package/src/changes.ts
CHANGED
|
@@ -176,3 +176,17 @@ export function versionAt(changes: Change[], pkg: string | string[], at: string)
|
|
|
176
176
|
}
|
|
177
177
|
return version;
|
|
178
178
|
}
|
|
179
|
+
|
|
180
|
+
/** Whether a dotted version is at or after `min`, by numeric parts; a version that is not dotted numbers (a git sha) is undefined. */
|
|
181
|
+
export function atLeast(version: string | undefined, min: string): boolean | undefined {
|
|
182
|
+
const parts = (v: string | undefined) => (v && /^\d+(\.\d+)*$/.test(v) ? v.split(".").map(Number) : undefined);
|
|
183
|
+
const a = parts(version), b = parts(min);
|
|
184
|
+
if (!a || !b) return undefined;
|
|
185
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) if ((a[i] ?? 0) !== (b[i] ?? 0)) return (a[i] ?? 0) > (b[i] ?? 0);
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Whether a pin change brings `pkg` to `version` or past it, from a version before it (or none): a version it skipped counts. */
|
|
190
|
+
export function crosses(c: Pick<Change, "kind" | "package" | "from" | "to">, pkg: string, version: string): boolean {
|
|
191
|
+
return c.kind === "pin" && c.package === pkg && atLeast(c.to, version) === true && atLeast(c.from, version) !== true;
|
|
192
|
+
}
|
package/src/detectors.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* in a monitor (by its exit code), passing evidence recorded after the last change, or, when no anchor command ran,
|
|
16
16
|
* a test, build, lint or type-check run after it.
|
|
17
17
|
*/
|
|
18
|
+
import { PlanGraphTracker } from "./plan-graph.ts";
|
|
18
19
|
import type { Label } from "./schema.ts";
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -22,7 +23,7 @@ import type { Label } from "./schema.ts";
|
|
|
22
23
|
* (commit 9f72366, 2026-11-23T10:51:07Z). Sessions that started earlier are out of scope.
|
|
23
24
|
*/
|
|
24
25
|
export const ERA_START = "2026-11-23T10:51:07.000Z";
|
|
25
|
-
export const DETECTORS = ["anchor_before_first_edit", "check_after_last_edit", "todo_evidence", "close_guard_quiet"] as const;
|
|
26
|
+
export const DETECTORS = ["anchor_before_first_edit", "check_after_last_edit", "todo_evidence", "close_guard_quiet", "plan_names_graph"] as const;
|
|
26
27
|
export type DetectorName = (typeof DETECTORS)[number];
|
|
27
28
|
export interface DetectorResult {
|
|
28
29
|
name: DetectorName;
|
|
@@ -123,11 +124,13 @@ export class ProcessTracker {
|
|
|
123
124
|
private sawUser = false;
|
|
124
125
|
private briefAnchor = false;
|
|
125
126
|
private notices = new Map<NoticeKind, number>();
|
|
127
|
+
private plan = new PlanGraphTracker();
|
|
126
128
|
|
|
127
129
|
/** Notice kinds seen so far, for `anchorloop.close_guard.notice` records. */
|
|
128
130
|
feed(raw: unknown): NoticeKind | undefined {
|
|
129
131
|
const entry = raw as Entry;
|
|
130
132
|
const seq = ++this.seq;
|
|
133
|
+
if (entry && typeof entry === "object") this.plan.feed(entry as Record<string, unknown>);
|
|
131
134
|
if (entry?.type === "custom" && entry.customType === "todo/v1" && entry.data?.v === 1 && Array.isArray(entry.data.tasks)) {
|
|
132
135
|
this.tasks = entry.data.tasks;
|
|
133
136
|
return undefined;
|
|
@@ -212,8 +215,9 @@ export class ProcessTracker {
|
|
|
212
215
|
}
|
|
213
216
|
|
|
214
217
|
results(inScope: boolean): DetectorResult[] {
|
|
215
|
-
|
|
216
|
-
return [
|
|
218
|
+
// The anchorloop era bounds the anchorloop rules only; the sb planning rule is judged in every session (long-lived mains started earlier).
|
|
219
|
+
if (!inScope) return [...DETECTORS_ALL.filter((name) => name !== "plan_names_graph").map((name): DetectorResult => ({ name, label: "na", explanation: "out_of_scope_pre_3.0" })), this.plan.results()];
|
|
220
|
+
return [this.anchorFirst(), this.checkAfter(), this.todoEvidence(), this.quiet(), this.plan.results()];
|
|
217
221
|
}
|
|
218
222
|
|
|
219
223
|
private anchorFirst(): DetectorResult {
|
package/src/extract/run.ts
CHANGED
|
@@ -15,10 +15,16 @@ export interface FileEntry {
|
|
|
15
15
|
key: string;
|
|
16
16
|
month: string;
|
|
17
17
|
summary: SessionSummary;
|
|
18
|
+
/**
|
|
19
|
+
* The extractor version that wrote this summary. A summary is current only when it equals EXTRACTOR_VERSION, so an
|
|
20
|
+
* extract stopped after a version bump leaves the files it did not reach stale for the next run. Entries from 0.6.0
|
|
21
|
+
* and before carry none and are read again.
|
|
22
|
+
*/
|
|
23
|
+
extractor?: number;
|
|
18
24
|
}
|
|
19
25
|
|
|
20
|
-
/** Bump when extraction changes what it derives;
|
|
21
|
-
export const EXTRACTOR_VERSION =
|
|
26
|
+
/** Bump when extraction changes what it derives; every summary written by another version is read again. */
|
|
27
|
+
export const EXTRACTOR_VERSION = 6;
|
|
22
28
|
|
|
23
29
|
export interface Checkpoint {
|
|
24
30
|
v: 1;
|
|
@@ -141,12 +147,11 @@ export async function extract(options: {
|
|
|
141
147
|
const started = Date.now();
|
|
142
148
|
const checkpoint = loadCheckpoint(options.layout.checkpoint);
|
|
143
149
|
const files = listSessionFiles(options.roots);
|
|
144
|
-
|
|
150
|
+
// The checkpoint-wide field only says which version last ran; staleness is per entry (an interrupted run saves both kinds).
|
|
145
151
|
checkpoint.extractor = EXTRACTOR_VERSION;
|
|
146
152
|
const changed = files.filter((f) => {
|
|
147
153
|
const known = checkpoint.files[f.path];
|
|
148
|
-
|
|
149
|
-
return !known || known.size !== f.size || known.mtimeMs !== f.mtimeMs;
|
|
154
|
+
return !known || known.extractor !== EXTRACTOR_VERSION || known.size !== f.size || known.mtimeMs !== f.mtimeMs;
|
|
150
155
|
});
|
|
151
156
|
const stats: ExtractStats = { files: files.length, changed: changed.length, failed: 0, bytes: 0, records: 0, ms: 0, errors: [] };
|
|
152
157
|
const byPath = new Map(changed.map((f) => [f.path, f]));
|
|
@@ -175,7 +180,7 @@ export async function extract(options: {
|
|
|
175
180
|
} else {
|
|
176
181
|
stats.records += result.records;
|
|
177
182
|
const key = fileKey(file.path);
|
|
178
|
-
checkpoint.files[file.path] = { size: file.size, mtimeMs: file.mtimeMs, key, month: monthOf(file.path), summary: result.summary };
|
|
183
|
+
checkpoint.files[file.path] = { size: file.size, mtimeMs: file.mtimeMs, key, month: monthOf(file.path), summary: result.summary, extractor: EXTRACTOR_VERSION };
|
|
179
184
|
if (result.catalog?.length) {
|
|
180
185
|
const hash = createHash("sha1").update(result.catalog.join("\n")).digest("hex").slice(0, 16);
|
|
181
186
|
result.summary.catalog = hash;
|
package/src/extract/session.ts
CHANGED
|
@@ -396,7 +396,7 @@ export class SessionReader {
|
|
|
396
396
|
const evals: SessionSummary["evals"] = {};
|
|
397
397
|
for (const result of this.tracker.results(inScope)) {
|
|
398
398
|
evals[result.name] = { label: result.label, value: result.value, explanation: result.explanation };
|
|
399
|
-
if (
|
|
399
|
+
if (result.explanation !== "out_of_scope_pre_3.0") {
|
|
400
400
|
const t = (startDay.detectors[result.name] ??= { pass: 0, fail: 0, na: 0 });
|
|
401
401
|
t[result.label] += 1;
|
|
402
402
|
}
|
package/src/meta.ts
CHANGED
|
@@ -18,6 +18,8 @@ export interface MetricMeta {
|
|
|
18
18
|
|
|
19
19
|
export interface DetectorMeta extends MetricMeta {
|
|
20
20
|
example: { pass: Text; fail: Text };
|
|
21
|
+
/** The package version whose arrival this detector measures: its results are also split by that package's version, and the pin change that brings it is highlighted. */
|
|
22
|
+
introducedIn?: { package: string; version: string };
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
const t = (en: string, zh: string): Text => ({ en, zh });
|
|
@@ -290,6 +292,23 @@ export const DETECTOR_META: Record<string, DetectorMeta> = {
|
|
|
290
292
|
fail: t("Edits and ends; the guard adds 'no passing run of `npm test`'.", "改檔就結束,收尾檢查加上「沒有 `npm test` 的通過紀錄」。"),
|
|
291
293
|
},
|
|
292
294
|
},
|
|
295
|
+
plan_names_graph: {
|
|
296
|
+
introducedIn: { package: "pi-straw-boss", version: "0.101.0" },
|
|
297
|
+
label: t("Plan says how the work splits", "排工作時說清楚怎麼分工"),
|
|
298
|
+
meaning: t(
|
|
299
|
+
"When a Straw Boss main (coordinator or standing) writes its plan as todos, it names the plan's shape: one loop it runs itself, parallel workers it merges, or an orchestrator handing work out.",
|
|
300
|
+
"Straw Boss 的主代理(協調或常駐)把計畫寫成待辦時,有說明這份計畫的分工方式:自己一路做完、分給幾個人平行做再合併,或由主代理派工給工作者。",
|
|
301
|
+
),
|
|
302
|
+
goodDirection: "higher",
|
|
303
|
+
howComputed: t(
|
|
304
|
+
"Passes when the open todos left by the main's first todo create carry a graph (the todo's graph field, or an older metadata.graph), or when its next todo call adds one, as sb 0.101.0 and later ask on that create. Fails when it went on planning without one. Sessions that are not such a main, or never planned, do not count.",
|
|
305
|
+
"主代理第一次建立待辦後,還沒完成的待辦有標分工方式(待辦的 graph 欄位,或舊版的 metadata.graph)即通過;第一次沒標、但下一次動待辦時補上的也算通過(sb 0.101.0 起會在那次建立待辦時提醒)。沒標就繼續排工作的不通過。不是這類主代理、或從沒排過工作的不算。",
|
|
306
|
+
),
|
|
307
|
+
example: {
|
|
308
|
+
pass: t("Creates three todos with graph 'fan-out/fan-in', then dispatches them.", "建立三項待辦並標上「fan-out/fan-in」,再派出去。"),
|
|
309
|
+
fail: t("Creates three todos with no graph, gets sb's reminder, and adds a fourth without one.", "建立三項待辦沒標分工方式,收到 sb 提醒後又加了第四項,仍然沒標。"),
|
|
310
|
+
},
|
|
311
|
+
},
|
|
293
312
|
};
|
|
294
313
|
|
|
295
314
|
export const NOTICE_META: Record<string, Text> = {
|
package/src/model.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { ASK_BUCKETS, type DayAgg, emptyDay, mergeDay, type SessionRow } from "./aggregate.ts";
|
|
7
7
|
import type { DaysIndex } from "./build.ts";
|
|
8
|
-
import { type Change, versionAt } from "./changes.ts";
|
|
8
|
+
import { atLeast, type Change, versionAt } from "./changes.ts";
|
|
9
9
|
import type { Coverage } from "./coverage.ts";
|
|
10
10
|
import { DETECTORS, ERA_START } from "./detectors.ts";
|
|
11
11
|
import { CHANGE_KIND_META, CLOSE_KIND_META, DETECTOR_META, METRICS, NOTICE_META, STALL_KIND_META } from "./meta.ts";
|
|
@@ -126,6 +126,38 @@ export function impactMetrics(rows: SessionRow[], ownerOf: (tool: string) => str
|
|
|
126
126
|
anchor_before_first_edit: d("anchor_before_first_edit"),
|
|
127
127
|
check_after_last_edit: d("check_after_last_edit"),
|
|
128
128
|
todo_evidence: d("todo_evidence"),
|
|
129
|
+
plan_names_graph: d("plan_names_graph"),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Dotted versions in numeric order; anything else (unknown, a sha) after them. */
|
|
134
|
+
const byVersion = (a: string, b: string) => {
|
|
135
|
+
const pa = /^\d+(\.\d+)*$/.test(a) ? a.split(".").map(Number) : undefined, pb = /^\d+(\.\d+)*$/.test(b) ? b.split(".").map(Number) : undefined;
|
|
136
|
+
if (!pa || !pb) return pa ? -1 : pb ? 1 : a.localeCompare(b);
|
|
137
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) if ((pa[i] ?? 0) !== (pb[i] ?? 0)) return (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
138
|
+
return 0;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/** A detector's results by the version of the package it measures, at each session's start, and before and from the version that brought it. */
|
|
142
|
+
export function packageSplit(rows: SessionRow[], changes: Change[], detector: string, since: { package: string; version: string }) {
|
|
143
|
+
const versions = new Map<string, { pass: number; fail: number }>();
|
|
144
|
+
const sides = { before: { pass: 0, fail: 0 }, after: { pass: 0, fail: 0 } };
|
|
145
|
+
for (const r of rows) {
|
|
146
|
+
const v = r.ev[detector];
|
|
147
|
+
if (v === undefined) continue;
|
|
148
|
+
const version = versionAt(changes, since.package, r.s) ?? "unknown";
|
|
149
|
+
const cell = versions.get(version) ?? { pass: 0, fail: 0 };
|
|
150
|
+
cell[v ? "pass" : "fail"] += 1;
|
|
151
|
+
versions.set(version, cell);
|
|
152
|
+
const later = atLeast(version, since.version);
|
|
153
|
+
if (later !== undefined) sides[later ? "after" : "before"][v ? "pass" : "fail"] += 1;
|
|
154
|
+
}
|
|
155
|
+
const withRate = (x: { pass: number; fail: number }) => ({ ...x, passRate: rate(x.pass, x.pass + x.fail) });
|
|
156
|
+
return {
|
|
157
|
+
...since,
|
|
158
|
+
versions: [...versions].sort(([a], [b]) => byVersion(a, b)).map(([version, x]) => ({ version, ...withRate(x) })),
|
|
159
|
+
before: withRate(sides.before),
|
|
160
|
+
after: withRate(sides.after),
|
|
129
161
|
};
|
|
130
162
|
}
|
|
131
163
|
|
|
@@ -309,6 +341,7 @@ export function buildModel(options: {
|
|
|
309
341
|
return { day, pass: x.pass, fail: x.fail };
|
|
310
342
|
}),
|
|
311
343
|
byVersion: (versions.get(d.name) ?? []).map((v) => ({ ...v, passRate: rate(v.pass, v.pass + v.fail) })),
|
|
344
|
+
byPackage: DETECTOR_META[d.name]?.introducedIn ? packageSplit(selected, sortedChanges, d.name, DETECTOR_META[d.name].introducedIn!) : null,
|
|
312
345
|
})),
|
|
313
346
|
notices: total.notices,
|
|
314
347
|
},
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `plan_names_graph`: whether a Straw Boss main of kind coordinator or standing names its plan's graph when it plans.
|
|
3
|
+
*
|
|
4
|
+
* The graph is a todo's own `graph` (pi-todo-ledger 0.4.0: `single-loop`, `fan-out/fan-in`, `orchestrator-worker`), else a
|
|
5
|
+
* legacy `metadata.graph`, read as pi-straw-boss reads it (`items.ts` `todosOf`, `duty.ts` `graphOf`, MIT, Copyright (c) 2026
|
|
6
|
+
* Wei Hung, sb 0.103.0). From sb 0.101.0 a main whose `todo` create leaves open todos with no graph gets planning.md §1-§2
|
|
7
|
+
* on that result (`planhint.ts`); the next todo call shows whether the main took it. A train's steps (`metadata.sb`) are not
|
|
8
|
+
* the plan. The main's kind comes from its role prompt (system section or a role steer) and its kind entries.
|
|
9
|
+
*/
|
|
10
|
+
import type { DetectorResult } from "./detectors.ts";
|
|
11
|
+
|
|
12
|
+
/** The planning-rule block's first line (sb `planhint.ts` OPENING). */
|
|
13
|
+
const RULE_OPENING = "sb: your open todos name no graph.";
|
|
14
|
+
const GRAPHS = new Set(["single-loop", "fan-out/fan-in", "orchestrator-worker"]);
|
|
15
|
+
const JUDGED = new Set(["coordinator", "standing"]);
|
|
16
|
+
const MAIN_PROMPT = /You are the main agent of Herdr tab .*?,? of kind ([a-z]+)/;
|
|
17
|
+
const STANDING_PROMPT = /You are the standing main of Herdr tab /;
|
|
18
|
+
|
|
19
|
+
type Obj = Record<string, unknown>;
|
|
20
|
+
const obj = (v: unknown): Obj => (v && typeof v === "object" ? (v as Obj) : {});
|
|
21
|
+
|
|
22
|
+
/** A legacy `metadata.graph` as mains wrote it, normalised like sb's `graphOf`. */
|
|
23
|
+
export function legacyGraph(v: unknown): string | undefined {
|
|
24
|
+
if (v === "orchestrator-worker") return v;
|
|
25
|
+
if (v === "fan-out/fan-in" || v === "fan-out") return "fan-out/fan-in";
|
|
26
|
+
if (v === "single" || (typeof v === "string" && v.startsWith("single-loop"))) return "single-loop";
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** A todo's graph: its own field when it is a graph name, else its legacy metadata. */
|
|
31
|
+
export function graphOfTodo(todo: unknown): string | undefined {
|
|
32
|
+
const t = obj(todo);
|
|
33
|
+
if (typeof t.graph === "string" && GRAPHS.has(t.graph)) return t.graph;
|
|
34
|
+
return legacyGraph(obj(t.metadata).graph);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The plan's open todos: not completed or deleted, and not a train's step. */
|
|
38
|
+
function openOf(tasks: unknown[]): Obj[] {
|
|
39
|
+
return tasks.map(obj).filter((t) => t.status !== "completed" && t.status !== "deleted" && !obj(t.metadata).sb);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function text(content: unknown): string {
|
|
43
|
+
if (typeof content === "string") return content;
|
|
44
|
+
return Array.isArray(content) ? content.map((p) => (obj(p).type === "text" ? String(obj(p).text ?? "") : "")).join("\n") : "";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class PlanGraphTracker {
|
|
48
|
+
private kind: string | undefined;
|
|
49
|
+
private wasMain = false;
|
|
50
|
+
private tasks: unknown[] | undefined;
|
|
51
|
+
private calls = new Map<string, boolean>();
|
|
52
|
+
/** The first plan (a create leaving open todos) named no graph; `rule`: sb's block came with it. */
|
|
53
|
+
private missed: { rule: boolean } | undefined;
|
|
54
|
+
private result: DetectorResult | undefined;
|
|
55
|
+
|
|
56
|
+
feed(entry: Obj): void {
|
|
57
|
+
if (this.result) return;
|
|
58
|
+
const type = entry.type;
|
|
59
|
+
if (type === "custom") {
|
|
60
|
+
const data = obj(entry.data);
|
|
61
|
+
if (entry.customType === "todo/v1" && Array.isArray(data.tasks)) this.tasks = data.tasks;
|
|
62
|
+
else if (entry.customType === "straw-boss" && typeof data.duty === "string" && this.kind) this.setKind(data.duty);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (type === "custom_message" && entry.customType === "straw-boss") {
|
|
66
|
+
const briefed = obj(obj(entry.details).briefed);
|
|
67
|
+
const role = briefed.name ?? briefed.role;
|
|
68
|
+
if (typeof role === "string") this.setKind(role === "main" && typeof briefed.duty === "string" ? briefed.duty : undefined);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (type !== "message") return;
|
|
72
|
+
const message = obj(entry.message);
|
|
73
|
+
if (message.role === "system") {
|
|
74
|
+
const section = obj(message.sections)["straw-boss"];
|
|
75
|
+
if (typeof section !== "string") return;
|
|
76
|
+
this.setKind(STANDING_PROMPT.test(section) ? "standing" : MAIN_PROMPT.exec(section)?.[1]);
|
|
77
|
+
} else if (message.role === "assistant" && Array.isArray(message.content)) {
|
|
78
|
+
for (const raw of message.content) {
|
|
79
|
+
const part = obj(raw);
|
|
80
|
+
if (part.type === "toolCall" && part.name === "todo" && typeof part.id === "string") this.calls.set(part.id, obj(part.arguments).action === "create");
|
|
81
|
+
}
|
|
82
|
+
} else if (message.role === "toolResult" && typeof message.toolCallId === "string" && this.calls.has(message.toolCallId)) {
|
|
83
|
+
const create = this.calls.get(message.toolCallId)!;
|
|
84
|
+
this.calls.delete(message.toolCallId);
|
|
85
|
+
if (message.isError === true || !this.kind || !JUDGED.has(this.kind)) return;
|
|
86
|
+
const listed = obj(message.details).tasks;
|
|
87
|
+
this.todoResult(create, Array.isArray(listed) ? listed : (this.tasks ?? []), text(message.content).includes(RULE_OPENING));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private setKind(kind: string | undefined) {
|
|
92
|
+
this.kind = kind;
|
|
93
|
+
if (kind && JUDGED.has(kind)) this.wasMain = true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private todoResult(create: boolean, tasks: unknown[], rule: boolean) {
|
|
97
|
+
const name = "plan_names_graph";
|
|
98
|
+
const open = openOf(tasks);
|
|
99
|
+
const named = open.some((t) => graphOfTodo(t));
|
|
100
|
+
if (!this.missed) {
|
|
101
|
+
if (!create || !open.length) return;
|
|
102
|
+
if (named) this.result = { name, label: "pass", explanation: "graph_at_first_create" };
|
|
103
|
+
else this.missed = { rule };
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
this.result = named
|
|
107
|
+
? { name, label: "pass", explanation: this.missed.rule ? "graph_after_rule" : "graph_next_todo_call" }
|
|
108
|
+
: { name, label: "fail", explanation: "kept_planning_without_graph" };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
results(): DetectorResult {
|
|
112
|
+
const name = "plan_names_graph";
|
|
113
|
+
if (this.result) return this.result;
|
|
114
|
+
if (this.missed) return { name, label: "fail", explanation: "plan_without_graph" };
|
|
115
|
+
return { name, label: "na", explanation: this.wasMain ? "no_plan" : "not_sb_main" };
|
|
116
|
+
}
|
|
117
|
+
}
|
package/src/query.ts
CHANGED
|
@@ -81,6 +81,11 @@ export function query(view: View, options: { since?: string; days?: number; proj
|
|
|
81
81
|
body.push(`${d.name} (${label}): ${pct(d.passRate)}, not applicable ${d.na}`);
|
|
82
82
|
const versions = d.byVersion.filter((v) => v.pass + v.fail > 0).map((v) => `${v.version} ${pct(v.passRate)}`);
|
|
83
83
|
if (versions.length) body.push(` by anchorloop version: ${versions.slice(-4).join("; ")}`);
|
|
84
|
+
const p = d.byPackage;
|
|
85
|
+
if (p) {
|
|
86
|
+
const byV = p.versions.filter((v) => v.pass + v.fail > 0).map((v) => `${v.version} ${pct(v.passRate)}`);
|
|
87
|
+
body.push(` by ${p.package} version: ${byV.slice(-6).join("; ") || "n/a"}; before ${p.version} ${pct(p.before.passRate)}, from ${p.version} ${pct(p.after.passRate)}`);
|
|
88
|
+
}
|
|
84
89
|
}
|
|
85
90
|
body.push(`close-guard reminders: ${Object.entries(m.process.notices).map(([k, v]) => `${k} ${v}`).join(", ") || "none"}`);
|
|
86
91
|
} else if (view === "cost") {
|
package/src/report/findings.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import { crosses } from "../changes.ts";
|
|
1
2
|
import type { Rate, ReportModel } from "../model.ts";
|
|
2
3
|
import { type Change, type Lang, num, pct, usd, type Words, words } from "./format.ts";
|
|
3
4
|
|
|
4
|
-
type Key = "anchor_before_first_edit" | "check_after_last_edit" | "package_error_rate" | "tool_error_rate" | "cost_per_session";
|
|
5
|
+
type Key = "anchor_before_first_edit" | "check_after_last_edit" | "plan_names_graph" | "package_error_rate" | "tool_error_rate" | "cost_per_session";
|
|
6
|
+
|
|
7
|
+
/** The detector whose package version this pin change brings in (or skips past), with that version. */
|
|
8
|
+
export function introduced(c: Pick<Change, "kind" | "package" | "from" | "to">, m: Pick<ReportModel, "meta">): { detector: Key; version: string } | undefined {
|
|
9
|
+
for (const [name, md] of Object.entries(m.meta.detectors)) {
|
|
10
|
+
if (md.introducedIn && crosses(c, md.introducedIn.package, md.introducedIn.version)) return { detector: name as Key, version: md.introducedIn.version };
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
5
14
|
export interface Reading {
|
|
6
15
|
key: Key;
|
|
7
16
|
label: string;
|
|
@@ -14,7 +23,10 @@ export function readings(c: Change, m: ReportModel, lang: Lang): Reading[] {
|
|
|
14
23
|
const L = words(lang), i = c.impact;
|
|
15
24
|
const has = (k: Key) => i?.before[k]?.value != null && i.after[k]?.value != null;
|
|
16
25
|
const process = c.package === "pi-anchorloop" && has("anchor_before_first_edit");
|
|
17
|
-
const
|
|
26
|
+
const brings = introduced(c, m);
|
|
27
|
+
const keys: Key[] = brings
|
|
28
|
+
? [brings.detector, "cost_per_session"]
|
|
29
|
+
: process
|
|
18
30
|
? ["anchor_before_first_edit", "check_after_last_edit"]
|
|
19
31
|
: [has("package_error_rate") ? "package_error_rate" : "tool_error_rate", "cost_per_session"];
|
|
20
32
|
return keys.map((key) => {
|
|
@@ -64,7 +76,8 @@ export function select(m: ReportModel) {
|
|
|
64
76
|
const rest = candidates.filter((c) => c !== lead && c.at <= lead.at && (!lead.sha || c.sha !== lead.sha));
|
|
65
77
|
const second = rest.find((c) => c.impact?.smallSample && c.impact.before.sessions && c.impact.after.sessions) ??
|
|
66
78
|
rest.find((c) => (c.kind === "pin" || c.kind === "model-routing") && c.impact && !c.impact.incomplete) ?? rest[0];
|
|
67
|
-
|
|
79
|
+
// A pin change that brings a detector's package version is always shown: it is what that detector measures.
|
|
80
|
+
const highlighted = all.filter((c) => c === lead || c === second || !!introduced(c, m));
|
|
68
81
|
return { all, lead, highlighted, folded: all.filter((c) => !highlighted.includes(c)) };
|
|
69
82
|
}
|
|
70
83
|
/** Editorial choices shared by the HTML timeline and the compact query. */
|
package/src/report/sections.ts
CHANGED
|
@@ -113,7 +113,11 @@ export function sections(m: ReportModel, lang: Lang, cards: ReturnType<typeof co
|
|
|
113
113
|
more(
|
|
114
114
|
L("By day and version", "查看每日與各版本的通過數"),
|
|
115
115
|
T([L("Day", "日期"), L("Pass", "通過"), L("Fail", "未通過")], d.perDay.map((r) => [r.day, r.pass, r.fail])) +
|
|
116
|
-
T([L("Version", "版本"), L("Pass", "通過"), L("Fail", "未通過")], d.byVersion.map((r) => [r.version, r.pass, r.fail]))
|
|
116
|
+
T([L("Version", "版本"), L("Pass", "通過"), L("Fail", "未通過")], d.byVersion.map((r) => [r.version, r.pass, r.fail])) +
|
|
117
|
+
(d.byPackage
|
|
118
|
+
? `<p>${esc(L(`By ${d.byPackage.package} version: before ${d.byPackage.version} ${pct(d.byPackage.before.passRate)}, from ${d.byPackage.version} ${pct(d.byPackage.after.passRate)}.`, `依 ${d.byPackage.package} 版本:${d.byPackage.version} 之前 ${pct(d.byPackage.before.passRate)},${d.byPackage.version} 起 ${pct(d.byPackage.after.passRate)}。`))}</p>` +
|
|
119
|
+
T([L(`${d.byPackage.package} version`, `${d.byPackage.package} 版本`), L("Pass", "通過"), L("Fail", "未通過")], d.byPackage.versions.map((r) => [r.version, r.pass, r.fail]))
|
|
120
|
+
: ""),
|
|
117
121
|
)
|
|
118
122
|
}</article>`;
|
|
119
123
|
}).join("")
|
package/src/report/strip.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReportModel } from "../model.ts";
|
|
2
2
|
import type { Preset } from "../ranges.ts";
|
|
3
|
+
import { introduced } from "./findings.ts";
|
|
3
4
|
import { type Change, esc, type Lang, num, words } from "./format.ts";
|
|
4
5
|
|
|
5
6
|
const KINDS = ["pin", "model-routing", "rule", "agent-role", "skill", "manual"] as const;
|
|
@@ -32,7 +33,8 @@ export function changeStrip(m: ReportModel, all: Change[], picks: Change[], ids:
|
|
|
32
33
|
if (cells.length > 5) marks.push(`<text class="slot-count" x="${left + 14}" y="28" text-anchor="middle">×${cells.length}</text>`);
|
|
33
34
|
}
|
|
34
35
|
const links = picks.map((c,i) => {
|
|
35
|
-
const {px, py, dot} = labeled.get(c)!, end = px > 700,
|
|
36
|
+
const {px, py, dot} = labeled.get(c)!, end = px > 700, brings = introduced(c, m), skipped = brings && brings.version !== c.to ? L(` (includes ${brings.version})`, `(含 ${brings.version})`) : "",
|
|
37
|
+
caption = c.package ? `${c.package} ${c.to ?? ""}${skipped}` : `${label(c.kind)} · ${c.at.slice(5,16).replace("T", " ")}`;
|
|
36
38
|
const y = 87 + i * 23;
|
|
37
39
|
return `<a href="#${ids.get(c)}"><title>${esc(caption)}</title><path class="guide" d="M${px} ${py}V${y - 6}h${end ? -7 : 7}"/>${dot}<text x="${px + (end ? -10 : 10)}" y="${y}" text-anchor="${end ? "end" : "start"}">${esc(Array.from(caption).length > 48 ? Array.from(caption).slice(0, 47).join("") + "…" : caption)}</text></a>`;
|
|
38
40
|
}).join("");
|