dsh-trajectory-traceview-plus 0.11.2 → 0.11.4
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 +41 -0
- package/README.en.md +27 -16
- package/README.md +39 -23
- package/docs/DESIGN.md +1559 -0
- package/docs/PROVENANCE.md +3 -0
- package/lib/client.js +38 -21
- package/package.json +2 -2
- package/scripts/browser-check.mjs +14 -0
- package/scripts/guard-check.mjs +113 -0
- package/scripts/readme-numbers.mjs +17 -4
- package/scripts/release-status.mjs +141 -21
- package/scripts/shortcut-check.mjs +93 -0
- package/src/00-locale.js +17 -12
- package/src/40-view.js +21 -9
package/docs/PROVENANCE.md
CHANGED
|
@@ -36,9 +36,11 @@
|
|
|
36
36
|
- `scripts/build-client.mjs`
|
|
37
37
|
- `scripts/doc-heading-check.mjs`
|
|
38
38
|
- `scripts/doc-ref-check.mjs`
|
|
39
|
+
- `scripts/guard-check.mjs`
|
|
39
40
|
- `scripts/provenance.mjs`
|
|
40
41
|
- `scripts/readme-numbers.mjs`
|
|
41
42
|
- `scripts/release-status.mjs`
|
|
43
|
+
- `scripts/shortcut-check.mjs`
|
|
42
44
|
- `scripts/version-check.mjs`
|
|
43
45
|
- `src/00-locale.js`
|
|
44
46
|
- `src/10-styles.js`
|
|
@@ -47,6 +49,7 @@
|
|
|
47
49
|
- `src/40-view.js`
|
|
48
50
|
- `src/50-entry.js`
|
|
49
51
|
- `test/browser/fixture.js`
|
|
52
|
+
- `test/browser/probe-en.js`
|
|
50
53
|
- `test/browser/probe.js`
|
|
51
54
|
|
|
52
55
|
## 二、`lib/client.js` 函数级
|
package/lib/client.js
CHANGED
|
@@ -21,9 +21,6 @@ window.__ModuleLoader__.load({
|
|
|
21
21
|
"block.unknown": "[未知内容]",
|
|
22
22
|
"block.toolAdded": "[工具新增] {name}",
|
|
23
23
|
"block.toolRemoved": "[工具移除] {name}",
|
|
24
|
-
"block.toolsAdded": "[已添加工具] {names}",
|
|
25
|
-
"block.toolsRemoved": "[已移除工具] {names}",
|
|
26
|
-
"block.toolsChanged": "[工具变更] 新增 {added} 个、移除 {removed} 个",
|
|
27
24
|
"note.compaction": "上下文压缩:",
|
|
28
25
|
"note.compacted": "历史已压缩",
|
|
29
26
|
"note.replace": "替换",
|
|
@@ -76,6 +73,17 @@ window.__ModuleLoader__.load({
|
|
|
76
73
|
"kpi.tokensIn": "请求 tokens",
|
|
77
74
|
"kpi.tokensOut": "生成 tokens",
|
|
78
75
|
"kpi.errors": "错误",
|
|
76
|
+
// The Token-usage chips were hardcoded English ("in" / "out" / "cache-read" …)
|
|
77
|
+
// inside a Chinese panel, while README §2 describes this section as
|
|
78
|
+
// "入站(含缓存读 / 写)与出站(含思考)". Same words as the README, compact
|
|
79
|
+
// enough for a chip. `fresh` = input tokens that came from the prompt rather
|
|
80
|
+
// than from cache (the API's `inputTokens` minus cache read/write).
|
|
81
|
+
"usage.in": "入站",
|
|
82
|
+
"usage.fresh": "未缓存",
|
|
83
|
+
"usage.cacheRead": "缓存读",
|
|
84
|
+
"usage.cacheWrite": "缓存写",
|
|
85
|
+
"usage.out": "出站",
|
|
86
|
+
"usage.think": "思考",
|
|
79
87
|
"status.done": "已完成",
|
|
80
88
|
"status.retry": "重试",
|
|
81
89
|
"detail.args": "调用参数",
|
|
@@ -106,15 +114,12 @@ window.__ModuleLoader__.load({
|
|
|
106
114
|
"anchor.notLoaded": "该记录不在当前窗口,需先拉取更早历史",
|
|
107
115
|
"anchor.capped": "已向前翻页 {n} 页仍未找到;可先手动点「加载更早历史」再重试",
|
|
108
116
|
"anchor.bad": "锚点格式无法识别",
|
|
109
|
-
"anchor.jump": "跳转到锚点",
|
|
110
117
|
"anchor.clear": "清除锚点",
|
|
111
118
|
"anchor.jumpPlaceholder": "粘贴锚点,如 tvp1:e3019,回车定位",
|
|
112
119
|
"anchor.jumpTip": "粘贴任意站点详情里「复制锚点」得到的串,回车即可精确定位;目标在未加载的历史里时会自动向前翻页加载(有页数上限,超出会明确提示)。",
|
|
113
120
|
"anchor.searching": "正在向前加载更早历史以定位…",
|
|
114
121
|
"anchor.searchingPages": "正在向前加载更早历史以定位…(第 {n}/{max} 页,已载入 {stations} 站)",
|
|
115
122
|
"anchor.upgraded": "该记录已落定,请改用 {ref}",
|
|
116
|
-
"anchor.copiedLink": "已复制到你名下",
|
|
117
|
-
"anchor.badInput": "无法识别的锚点",
|
|
118
123
|
|
|
119
124
|
"detail.start": "开始",
|
|
120
125
|
"detail.end": "结束",
|
|
@@ -202,9 +207,6 @@ window.__ModuleLoader__.load({
|
|
|
202
207
|
"block.unknown": "[unknown content]",
|
|
203
208
|
"block.toolAdded": "[tool added] {name}",
|
|
204
209
|
"block.toolRemoved": "[tool removed] {name}",
|
|
205
|
-
"block.toolsAdded": "[tools added] {names}",
|
|
206
|
-
"block.toolsRemoved": "[tools removed] {names}",
|
|
207
|
-
"block.toolsChanged": "[tools changed] +{added} / -{removed}",
|
|
208
210
|
"note.compaction": "Context compacted: ",
|
|
209
211
|
"note.compacted": "history compacted",
|
|
210
212
|
"note.replace": "replaced",
|
|
@@ -257,6 +259,12 @@ window.__ModuleLoader__.load({
|
|
|
257
259
|
"kpi.tokensIn": "Prompt tokens",
|
|
258
260
|
"kpi.tokensOut": "Output tokens",
|
|
259
261
|
"kpi.errors": "Errors",
|
|
262
|
+
"usage.in": "in",
|
|
263
|
+
"usage.fresh": "fresh",
|
|
264
|
+
"usage.cacheRead": "cache-read",
|
|
265
|
+
"usage.cacheWrite": "cache-write",
|
|
266
|
+
"usage.out": "out",
|
|
267
|
+
"usage.think": "think",
|
|
260
268
|
"status.done": "Done",
|
|
261
269
|
"status.retry": "Retry",
|
|
262
270
|
"detail.args": "Call arguments",
|
|
@@ -287,15 +295,12 @@ window.__ModuleLoader__.load({
|
|
|
287
295
|
"anchor.notLoaded": "Not in the loaded window; load older history first",
|
|
288
296
|
"anchor.capped": "Paged back {n} pages without finding it; load older history manually and retry",
|
|
289
297
|
"anchor.bad": "Unrecognized anchor format",
|
|
290
|
-
"anchor.jump": "Jump to anchor",
|
|
291
298
|
"anchor.clear": "Clear anchor",
|
|
292
299
|
"anchor.jumpPlaceholder": "Paste an anchor (e.g. tvp1:e3019) and press Enter",
|
|
293
300
|
"anchor.jumpTip": "Paste the string produced by \"Copy anchor\" in any station detail, then press Enter. If the target sits in unloaded history, older pages are loaded automatically (page-bounded; you are told when the bound is hit).",
|
|
294
301
|
"anchor.searching": "Loading older history to locate it…",
|
|
295
302
|
"anchor.searchingPages": "Loading older history to locate it… (page {n}/{max}, {stations} stations loaded)",
|
|
296
303
|
"anchor.upgraded": "This record is now durable; use {ref}",
|
|
297
|
-
"anchor.copiedLink": "Link copied",
|
|
298
|
-
"anchor.badInput": "Unrecognized anchor",
|
|
299
304
|
|
|
300
305
|
"detail.start": "Start",
|
|
301
306
|
"detail.end": "End",
|
|
@@ -4177,6 +4182,18 @@ window.__ModuleLoader__.load({
|
|
|
4177
4182
|
const onSearchKey = (ev) => {
|
|
4178
4183
|
ev.stopPropagation();
|
|
4179
4184
|
if (ev.key === "Enter") { gotoMatch(ev.shiftKey ? -1 : 1); ev.preventDefault(); }
|
|
4185
|
+
// README §7 has promised `↑` / `↓` for previous/next match since the
|
|
4186
|
+
// shortcut table existed, and NOTHING implemented it: the panel handler
|
|
4187
|
+
// bails out for `input` targets and this handler only knew Enter/Escape,
|
|
4188
|
+
// so the two most natural keys did nothing at all. Measured in the
|
|
4189
|
+
// browser probe: focus the box with 2/3 shown, press ArrowDown, counter
|
|
4190
|
+
// stays "2/3" — the documented feature simply was not there (§13.57).
|
|
4191
|
+
//
|
|
4192
|
+
// Inside a single-line search box there is no vertical caret movement to
|
|
4193
|
+
// steal, so binding these two is what a user coming from browser find
|
|
4194
|
+
// expects.
|
|
4195
|
+
else if (ev.key === "ArrowDown") { gotoMatch(1); ev.preventDefault(); }
|
|
4196
|
+
else if (ev.key === "ArrowUp") { gotoMatch(-1); ev.preventDefault(); }
|
|
4180
4197
|
else if (ev.key === "Escape") { setQueryRaw(""); ev.preventDefault(); }
|
|
4181
4198
|
};
|
|
4182
4199
|
const clearSearch = () => {
|
|
@@ -5169,9 +5186,9 @@ window.__ModuleLoader__.load({
|
|
|
5169
5186
|
usage !== null && usage.input + usage.output > 0 ? jsxs("div", { className: "dstv_dSection", children: [
|
|
5170
5187
|
jsx("span", { className: "dstv_dLabel", children: `📊 ${t("detail.usage")}` }, "uLbl"),
|
|
5171
5188
|
jsx("div", { className: "dstv_cfgChips", children: [
|
|
5172
|
-
usage.input > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["in
|
|
5173
|
-
usage.cacheRead > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["
|
|
5174
|
-
usage.output > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["out
|
|
5189
|
+
usage.input > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.in")} `, jsx("b", { children: fmtInt(usage.input) }, "v")] }, "uIn") : null,
|
|
5190
|
+
usage.cacheRead > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.cacheRead")} `, jsx("b", { children: fmtInt(usage.cacheRead) }, "v")] }, "uCR") : null,
|
|
5191
|
+
usage.output > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.out")} `, jsx("b", { children: fmtInt(usage.output) }, "v")] }, "uOut") : null
|
|
5175
5192
|
] }, "uChips")
|
|
5176
5193
|
] }, "crUsage") : null,
|
|
5177
5194
|
cr.outputText !== "" ? jsxs("div", { className: "dstv_dSection", children: [
|
|
@@ -5305,12 +5322,12 @@ window.__ModuleLoader__.load({
|
|
|
5305
5322
|
usage !== null && usage.input + usage.output > 0 ? jsxs("div", { className: "dstv_dSection", children: [
|
|
5306
5323
|
jsx("span", { className: "dstv_dLabel", children: `📊 ${t("detail.usage")}` }, "uLbl"),
|
|
5307
5324
|
jsx("div", { className: "dstv_cfgChips", children: [
|
|
5308
|
-
usage.input > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["in
|
|
5309
|
-
usage.raw > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["fresh
|
|
5310
|
-
usage.cacheRead > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["
|
|
5311
|
-
usage.cacheWrite > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["
|
|
5312
|
-
usage.output > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["out
|
|
5313
|
-
usage.think > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["think
|
|
5325
|
+
usage.input > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.in")} `, jsx("b", { children: fmtInt(usage.input) }, "v")] }, "uIn") : null,
|
|
5326
|
+
usage.raw > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.fresh")} `, jsx("b", { children: fmtInt(usage.raw) }, "v")] }, "uFresh") : null,
|
|
5327
|
+
usage.cacheRead > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.cacheRead")} `, jsx("b", { children: fmtInt(usage.cacheRead) }, "v")] }, "uCR") : null,
|
|
5328
|
+
usage.cacheWrite > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.cacheWrite")} `, jsx("b", { children: fmtInt(usage.cacheWrite) }, "v")] }, "uCW") : null,
|
|
5329
|
+
usage.output > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.out")} `, jsx("b", { children: fmtInt(usage.output) }, "v")] }, "uOut") : null,
|
|
5330
|
+
usage.think > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.think")} `, jsx("b", { children: fmtInt(usage.think) }, "v")] }, "uThink") : null
|
|
5314
5331
|
] }, "uChips")
|
|
5315
5332
|
] }, "uSec") : null,
|
|
5316
5333
|
// messages
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-trajectory-traceview-plus",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4",
|
|
4
4
|
"description": "轨迹视图增强版(Plus):在「轨迹」标签旁新增可回放的横向时间轴——minimap、窗口内检索(显式标注覆盖边界)、回放、轮次跳转、跟随模式、历史分页、步骤/子调用耗时与吞吐、时钟轴切换、稳定锚点复制与深链、孤立工具结果站点、提示词变更对比、原始请求分析与 Markdown 导出。基于 AFAP/dsh-trajectory-traceview (MIT) 改造。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "node scripts/build-client.mjs",
|
|
65
|
-
"check": "node scripts/build-client.mjs --check && node scripts/provenance.mjs --check && node scripts/version-check.mjs && node scripts/doc-ref-check.mjs && node scripts/doc-heading-check.mjs && node test/smoke.test.cjs && node scripts/readme-numbers.mjs",
|
|
65
|
+
"check": "node scripts/build-client.mjs --check && node scripts/provenance.mjs --check && node scripts/version-check.mjs && node scripts/doc-ref-check.mjs && node scripts/doc-heading-check.mjs && node test/smoke.test.cjs && node scripts/readme-numbers.mjs && node scripts/shortcut-check.mjs",
|
|
66
66
|
"test": "node test/smoke.test.cjs",
|
|
67
67
|
"prepublishOnly": "npm run check"
|
|
68
68
|
}
|
|
@@ -40,6 +40,20 @@ try {
|
|
|
40
40
|
process.exit(1);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
// The English pass runs as a second eval. `agent-browser eval` aborts with
|
|
44
|
+
// "Resource temporarily unavailable" at 30 s, and the main probe alone is close to that;
|
|
45
|
+
// merging the two failed as an unparsable result instead of a red assertion.
|
|
46
|
+
const probeEn = fs.readFileSync(path.join(root, "test/browser/probe-en.js"), "utf8");
|
|
47
|
+
const outEn = run("agent-browser", ["eval", "--stdin"], probeEn);
|
|
48
|
+
try {
|
|
49
|
+
const outerEn = JSON.parse((outEn.stdout || "").trim());
|
|
50
|
+
const parsedEn = JSON.parse(outerEn);
|
|
51
|
+
if (Array.isArray(parsedEn.failures)) parsed.failures.push(...parsedEn.failures);
|
|
52
|
+
parsed.info.englishLeaks = parsedEn.info.englishLeaks;
|
|
53
|
+
} catch {
|
|
54
|
+
parsed.failures.push("the English pass did not return a parsable result");
|
|
55
|
+
}
|
|
56
|
+
|
|
43
57
|
if (shots) {
|
|
44
58
|
fs.mkdirSync(path.join(root, "test/browser/shots"), { recursive: true });
|
|
45
59
|
run("agent-browser", ["screenshot", "--screenshot-dir", "./test/browser/shots"]);
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Prove the P1 growth guard can still tell linear from quadratic.
|
|
4
|
+
*
|
|
5
|
+
* §13.55 found the guard was measuring the wrong thing: it took the MINIMUM of the
|
|
6
|
+
* three per-round ratios. Noise is one-sided (scheduling hiccups only lengthen a
|
|
7
|
+
* sample), so a round where the small sample got inflated and the big one did not
|
|
8
|
+
* produces an abnormally LOW ratio — and min() keeps exactly that round. With a
|
|
9
|
+
* known O(n^2) under jitter it missed 12 of 20 trials.
|
|
10
|
+
*
|
|
11
|
+
* Fixing the estimator is easy. Keeping it fixed is the hard part: nothing in the
|
|
12
|
+
* normal green suite would notice if a future edit reintroduced coupling, because
|
|
13
|
+
* the guard passes on healthy code either way. This script is the missing test —
|
|
14
|
+
* it feeds the SAME measurement protocol two functions whose complexity is known
|
|
15
|
+
* in advance and checks the verdict, under the same one-sided jitter that broke it.
|
|
16
|
+
*
|
|
17
|
+
* node scripts/bench-fold.mjs --guard-check
|
|
18
|
+
*
|
|
19
|
+
* Not in CI on purpose: it measures wall time, so a loaded machine makes it flaky,
|
|
20
|
+
* and a flaky gate trains people to ignore gates. Run it after touching the P1
|
|
21
|
+
* block, or when a performance claim is being made.
|
|
22
|
+
*/
|
|
23
|
+
const cpuMs = (fn, n, reps, jitter) => {
|
|
24
|
+
let best = Infinity;
|
|
25
|
+
for (let i = 0; i < 5; i += 1) {
|
|
26
|
+
const before = process.cpuUsage();
|
|
27
|
+
for (let r = 0; r < reps; r += 1) fn(n);
|
|
28
|
+
const used = process.cpuUsage(before);
|
|
29
|
+
// One-sided noise, exactly the shape real scheduling produces.
|
|
30
|
+
const ms = ((used.user + used.system) / 1000 / reps) * (1 + Math.random() * jitter);
|
|
31
|
+
if (ms < best) best = ms;
|
|
32
|
+
}
|
|
33
|
+
return best;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const callMs = (fn, n, jitter) => {
|
|
37
|
+
let reps = 1;
|
|
38
|
+
let ms = cpuMs(fn, n, 1, jitter);
|
|
39
|
+
while (ms * reps < 15 && reps < 64) {
|
|
40
|
+
reps *= 2;
|
|
41
|
+
ms = cpuMs(fn, n, reps, jitter);
|
|
42
|
+
}
|
|
43
|
+
return ms;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const linear = (n) => { let a = 0; for (let i = 0; i < n; i += 1) a += i; return a; };
|
|
47
|
+
const quadratic = (n) => { let a = 0; for (let i = 0; i < n; i += 1) for (let j = 0; j < n; j += 1) a += 1; return a; };
|
|
48
|
+
|
|
49
|
+
/** The production estimator: min of each size, then divide. */
|
|
50
|
+
const newEstimator = (fn, base, jitter) => {
|
|
51
|
+
const smalls = [];
|
|
52
|
+
const bigs = [];
|
|
53
|
+
for (let r = 0; r < 3; r += 1) {
|
|
54
|
+
smalls.push(callMs(fn, base, jitter));
|
|
55
|
+
bigs.push(callMs(fn, base * 2, jitter));
|
|
56
|
+
}
|
|
57
|
+
return Math.min(...bigs) / Math.min(...smalls);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/** The estimator §13.55 replaced — kept here so the regression is demonstrable. */
|
|
61
|
+
const oldEstimator = (fn, base, jitter) => {
|
|
62
|
+
const ratios = [];
|
|
63
|
+
for (let r = 0; r < 3; r += 1) {
|
|
64
|
+
ratios.push(callMs(fn, base * 2, jitter) / callMs(fn, base, jitter));
|
|
65
|
+
}
|
|
66
|
+
return Math.min(...ratios);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const THRESHOLD = 3;
|
|
70
|
+
const JITTER = 2;
|
|
71
|
+
const TRIALS = 12;
|
|
72
|
+
|
|
73
|
+
let oldMissed = 0;
|
|
74
|
+
let newMissed = 0;
|
|
75
|
+
let newFalseAlarm = 0;
|
|
76
|
+
for (let t = 0; t < TRIALS; t += 1) {
|
|
77
|
+
if (oldEstimator(quadratic, 3100, JITTER) <= THRESHOLD) oldMissed += 1;
|
|
78
|
+
if (newEstimator(quadratic, 3100, JITTER) <= THRESHOLD) newMissed += 1;
|
|
79
|
+
if (newEstimator(linear, 400000, JITTER) > THRESHOLD) newFalseAlarm += 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
console.log('guard-check: threshold ' + THRESHOLD + ', jitter ' + JITTER + 'x one-sided, ' + TRIALS + ' trials each');
|
|
83
|
+
console.log(' quadratic missed by min-of-ratios: ' + oldMissed + '/' + TRIALS
|
|
84
|
+
+ (oldMissed > TRIALS / 2 ? ' (this is the §13.55 bug — the estimator is blind)' : ''));
|
|
85
|
+
console.log(' quadratic missed by min/min: ' + newMissed + '/' + TRIALS);
|
|
86
|
+
console.log(' linear false alarms (min/min): ' + newFalseAlarm + '/' + TRIALS);
|
|
87
|
+
|
|
88
|
+
// The guard must (a) catch a real quadratic most of the time and (b) not cry wolf on
|
|
89
|
+
// linear code. Both bounds are loose because this measures wall time; the point is to
|
|
90
|
+
// fail loudly if the estimator regresses, not to certify a statistic.
|
|
91
|
+
//
|
|
92
|
+
// The decisive assertion is the COMPARISON, not either absolute number: if the current
|
|
93
|
+
// estimator misses at least as often as the one §13.55 replaced, the fix has been
|
|
94
|
+
// undone or neutralised and the guard is blind again. An absolute bound alone could
|
|
95
|
+
// not see that — replacing newEstimator with oldEstimator still scored 3/12 on one
|
|
96
|
+
// run, comfortably under a "> half" rule, because the two estimators draw different
|
|
97
|
+
// random jitter and the whole measurement is noisy.
|
|
98
|
+
if (newMissed >= oldMissed && oldMissed > 0) {
|
|
99
|
+
console.error('guard-check: FAIL — the current estimator is no better than the pre-§13.55 one ('
|
|
100
|
+
+ newMissed + '/' + TRIALS + ' vs ' + oldMissed + '/' + TRIALS + ' missed); the guard is blind again');
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
if (newMissed > TRIALS / 2) {
|
|
104
|
+
console.error('guard-check: FAIL — the current estimator misses a real O(n^2) more often than it catches it');
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
if (newFalseAlarm > 2) {
|
|
108
|
+
console.error('guard-check: FAIL — too many false alarms on linear code; the threshold or the estimator drifted');
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
console.log('guard-check: OK — the estimator separates the two complexities');
|
|
112
|
+
console.log(' (the comparison against the old estimator is what would catch a regression; the');
|
|
113
|
+
console.log(' absolute numbers alone are too noisy to rely on)');
|
|
@@ -35,9 +35,18 @@ const pkg = JSON.parse(read('package.json'));
|
|
|
35
35
|
const version = String(pkg.version);
|
|
36
36
|
const localSteps = pkg.scripts.check.split('&&').map((s) => s.trim()).filter(Boolean).length;
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
// Two probe files, one count. `probe-en.js` was split out because `agent-browser eval`
|
|
39
|
+
// aborts at 30 s and the language switch pushed the single file over it (§13.69) — and
|
|
40
|
+
// leaving it out of this count is exactly the one-source-vs-two-sources blindness this
|
|
41
|
+
// very block has already been fixed for once (§13.44).
|
|
42
|
+
const PROBE_FILES = ['test/browser/probe.js', 'test/browser/probe-en.js'];
|
|
43
|
+
const probes = PROBE_FILES.map((f) => read(f));
|
|
44
|
+
const observedGroups = new Set();
|
|
45
|
+
let assertions = 0;
|
|
46
|
+
for (const src of probes) {
|
|
47
|
+
for (const m of src.matchAll(/info\.([a-zA-Z]\w*)\s*=/g)) observedGroups.add(m[1]);
|
|
48
|
+
assertions += [...src.matchAll(/\bfail\(/g)].length;
|
|
49
|
+
}
|
|
41
50
|
|
|
42
51
|
// ── checks added OUTSIDE probe.js ────────────────────────────────────────────
|
|
43
52
|
//
|
|
@@ -55,7 +64,11 @@ const extraGroupNames = new Set(
|
|
|
55
64
|
.map((m) => m[1])
|
|
56
65
|
.filter((n) => !observedGroups.has(n)),
|
|
57
66
|
);
|
|
58
|
-
|
|
67
|
+
// Only `push("…")` is an assertion. `push(...other)` forwards failures produced
|
|
68
|
+
// ELSEWHERE (the English pass collects its own) — counting it as an assertion inflated the
|
|
69
|
+
// total by one for every forwarded bundle, and the gate would then demand README numbers
|
|
70
|
+
// that describe nothing a reader could point at.
|
|
71
|
+
const extraAssertions = [...browserCheck.matchAll(/(?:parsed\.)?failures\.push\(\s*["'`]/g)].length;
|
|
59
72
|
|
|
60
73
|
const truth = {
|
|
61
74
|
ciGates, localSteps, groups: observedGroups.size, assertions,
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* Report the
|
|
3
|
+
* Report the places a release has to exist, side by side.
|
|
4
4
|
*
|
|
5
|
-
* §13.43, §13.45 and §13.
|
|
6
|
-
* self-consistent while an outside world disagreed
|
|
5
|
+
* §13.43, §13.45, §13.47, §13.49, §13.51 and §13.52 are one failure repeated:
|
|
6
|
+
* the repository was self-consistent while an outside world disagreed, or while this
|
|
7
|
+
* very script reported success over a row it had just printed as missing.
|
|
7
8
|
*
|
|
8
9
|
* git tag ← what this checkout claims
|
|
10
|
+
* tag = shipped ← does the tree you would publish still match the tag?
|
|
9
11
|
* GitHub Release ← what the badge on the repo page reads
|
|
10
|
-
* npm registry ←
|
|
12
|
+
* npm registry ← metadata AND whether the tarball bytes actually serve
|
|
13
|
+
* npm @latest ← does the resolver hand out that version, or silently an older one?
|
|
11
14
|
*
|
|
12
|
-
* Each
|
|
15
|
+
* Each is invisible from inside the others. After `git push` + `git tag` +
|
|
13
16
|
* `gh release create` the repo looks finished; if `npm publish` never ran, everyone
|
|
14
17
|
* installing by package name still gets the previous version and nothing errors.
|
|
15
18
|
*
|
|
@@ -17,11 +20,12 @@
|
|
|
17
20
|
* api.github.com, and a gate that fails when the network is flaky trains people to
|
|
18
21
|
* ignore it. Run it before announcing a release:
|
|
19
22
|
*
|
|
20
|
-
* node scripts/release-status.mjs # report; exit 1 if
|
|
23
|
+
* node scripts/release-status.mjs # report; exit 1 if any row is missing
|
|
21
24
|
* node scripts/release-status.mjs --warn # report only, always exit 0
|
|
22
25
|
*/
|
|
23
26
|
import { execFileSync } from 'node:child_process';
|
|
24
|
-
import { readFileSync } from 'node:fs';
|
|
27
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
28
|
+
import { tmpdir } from 'node:os';
|
|
25
29
|
import { dirname, join } from 'node:path';
|
|
26
30
|
import { fileURLToPath } from 'node:url';
|
|
27
31
|
|
|
@@ -32,9 +36,9 @@ const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8'));
|
|
|
32
36
|
const version = String(pkg.version);
|
|
33
37
|
const name = String(pkg.name);
|
|
34
38
|
|
|
35
|
-
const run = (cmd, args) => {
|
|
39
|
+
const run = (cmd, args, cwd = ROOT) => {
|
|
36
40
|
try {
|
|
37
|
-
return { ok: true, out: execFileSync(cmd, args, { cwd
|
|
41
|
+
return { ok: true, out: execFileSync(cmd, args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim() };
|
|
38
42
|
} catch (e) {
|
|
39
43
|
return { ok: false, out: ((e.stdout ?? '') + (e.stderr ?? '')).trim() };
|
|
40
44
|
}
|
|
@@ -114,11 +118,13 @@ const npmView = run('npm', ['view', name + '@' + version, 'version']);
|
|
|
114
118
|
const latest = run('npm', ['view', name, 'dist-tags.latest']);
|
|
115
119
|
const published = npmView.ok && npmView.out.includes(version);
|
|
116
120
|
let tarballState = 'not checked';
|
|
121
|
+
let tarballCode = '';
|
|
117
122
|
if (published) {
|
|
118
123
|
const url = run('npm', ['view', name + '@' + version, 'dist.tarball']).out;
|
|
119
124
|
// HEAD, no cache-buster: a cache-buster would defeat the very cache that is stale,
|
|
120
125
|
// hiding exactly the window a real installer would fall into.
|
|
121
126
|
const code = run('curl', ['-s', '-o', '/dev/null', '-w', '%{http_code}', '-I', url]).out;
|
|
127
|
+
tarballCode = code;
|
|
122
128
|
tarballState = code === '200' ? 'tarball downloads' : 'tarball URL returns HTTP ' + code + ' (metadata is live, bytes are not)';
|
|
123
129
|
}
|
|
124
130
|
rows.push({
|
|
@@ -132,25 +138,139 @@ rows.push({
|
|
|
132
138
|
: 'npm publish',
|
|
133
139
|
});
|
|
134
140
|
|
|
141
|
+
// 5. npm @latest — does the resolver actually hand out that version?
|
|
142
|
+
//
|
|
143
|
+
// Advisory row, NOT part of the verdict. pnpm 12 applies a supply-chain delay
|
|
144
|
+
// (`minimumReleaseAge`) whose default appears in no config output: right after a
|
|
145
|
+
// publish, `pnpm add <pkg>@latest` silently resolves to the PREVIOUS version while
|
|
146
|
+
// `npm view` reports the new one (§13.49). The window clears by itself, so making it
|
|
147
|
+
// fail would light a red lamp for hours after every release and teach people to
|
|
148
|
+
// ignore the output — the exact way §13.45's permanent yellow was useless.
|
|
149
|
+
//
|
|
150
|
+
// The check is the pair a sibling session proposed: resolve `@latest` twice, once
|
|
151
|
+
// with the delay on and once with it disabled, `--lockfile-only` so nothing downloads.
|
|
152
|
+
// If the two disagree, the resolver is holding the new release back and anyone using
|
|
153
|
+
// `@latest` is getting the old one.
|
|
154
|
+
const resolveLatest = (extra) => {
|
|
155
|
+
const dir = mkdtempSync(join(tmpdir(), 'dsr-'));
|
|
156
|
+
try {
|
|
157
|
+
writeFileSync(join(dir, 'package.json'), '{"name":"probe","version":"1.0.0"}\n');
|
|
158
|
+
run('pnpm', ['add', name + '@latest', '--lockfile-only', ...extra], dir);
|
|
159
|
+
const lock = readFileSync(join(dir, 'pnpm-lock.yaml'), 'utf8');
|
|
160
|
+
const m = new RegExp('^\\s{2}' + name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '@([^:\\s]+):', 'm').exec(lock);
|
|
161
|
+
return m === null ? null : m[1];
|
|
162
|
+
} catch {
|
|
163
|
+
return null;
|
|
164
|
+
} finally {
|
|
165
|
+
rmSync(dir, { recursive: true, force: true });
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const resolvedDefault = resolveLatest([]);
|
|
169
|
+
const resolvedNoDelay = resolveLatest(['--config.minimumReleaseAge=0']);
|
|
170
|
+
if (resolvedDefault === null || resolvedNoDelay === null) {
|
|
171
|
+
// A row that quietly disappears is its own kind of blindness: the reader cannot
|
|
172
|
+
// tell "nothing to report" from "could not check". Say which it is.
|
|
173
|
+
rows.push({
|
|
174
|
+
place: 'npm @latest',
|
|
175
|
+
present: false,
|
|
176
|
+
advisory: true,
|
|
177
|
+
detail: 'could not resolve (pnpm unavailable, or the lockfile shape changed) — check by hand',
|
|
178
|
+
missing: '',
|
|
179
|
+
});
|
|
180
|
+
} else {
|
|
181
|
+
const held = resolvedDefault !== resolvedNoDelay;
|
|
182
|
+
// "self-heals" without a number is not information. pnpm's built-in default is
|
|
183
|
+
// 1440 minutes (24 h) — not the "few hours" an earlier version of this message
|
|
184
|
+
// implied, which is why the same advisory was still showing 6.2 h after the
|
|
185
|
+
// publish and looked like a bug. Say how old the release is and when it clears.
|
|
186
|
+
let window = '';
|
|
187
|
+
if (held) {
|
|
188
|
+
// A dotted key like `time.0.11.2` returns empty from npm (digit segments do not
|
|
189
|
+
// resolve), so read the whole time map and pick the key out of it.
|
|
190
|
+
// so read the whole time map and pick the key out of it.
|
|
191
|
+
const times = run('npm', ['view', name, 'time', '--json']);
|
|
192
|
+
let published = '';
|
|
193
|
+
try {
|
|
194
|
+
// `npm view … --json` wraps the object in an array; unwrap before reading the key.
|
|
195
|
+
const raw = JSON.parse(times.out);
|
|
196
|
+
const map = Array.isArray(raw) ? raw[0] : raw;
|
|
197
|
+
published = map?.[version] ?? '';
|
|
198
|
+
} catch { published = ''; }
|
|
199
|
+
const t = Date.parse(published);
|
|
200
|
+
if (Number.isFinite(t)) {
|
|
201
|
+
const ageH = (Date.now() - t) / 3_600_000;
|
|
202
|
+
const leftH = Math.max(0, 24 - ageH);
|
|
203
|
+
window = '; published ' + ageH.toFixed(1) + ' h ago, clears in ~' + leftH.toFixed(1)
|
|
204
|
+
+ ' h (pnpm default minimumReleaseAge = 1440 min)';
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
rows.push({
|
|
208
|
+
place: 'npm @latest',
|
|
209
|
+
present: !held,
|
|
210
|
+
advisory: true,
|
|
211
|
+
detail: held
|
|
212
|
+
? 'resolver holds the new release back: @latest → ' + resolvedDefault
|
|
213
|
+
+ ', with minimumReleaseAge=0 → ' + resolvedNoDelay
|
|
214
|
+
+ window + '; install docs pin the version'
|
|
215
|
+
: 'resolver reaches ' + resolvedDefault + (resolvedDefault === version ? ' (the current release)' : ''),
|
|
216
|
+
missing: '',
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
135
220
|
const pad = (s, n) => s + ' '.repeat(Math.max(0, n - [...s].length));
|
|
136
221
|
console.log('release-status: ' + name + '@' + version + '\n');
|
|
137
|
-
|
|
138
|
-
const
|
|
222
|
+
const mark = (r) => (r.advisory && !r.present ? '◐' : r.present ? '●' : '○');
|
|
223
|
+
for (const r of rows) console.log(' ' + mark(r) + ' ' + pad(r.place, 16) + r.detail);
|
|
224
|
+
const absent = rows.filter((r) => !r.present && !r.advisory);
|
|
225
|
+
const advisories = rows.filter((r) => r.advisory && !r.present);
|
|
139
226
|
if (absent.length > 0) {
|
|
140
227
|
console.log('\nmissing from ' + absent.length + ' place(s):');
|
|
141
228
|
for (const r of absent) if (r.missing) console.log(' ' + r.place + ': ' + r.missing);
|
|
142
229
|
}
|
|
230
|
+
if (advisories.length > 0) {
|
|
231
|
+
console.log('\n◐ = real but time-bounded, does not block:');
|
|
232
|
+
for (const r of advisories) console.log(' ' + r.place + ': ' + r.detail);
|
|
233
|
+
}
|
|
234
|
+
// ── verdict ──────────────────────────────────────────────────────────────────
|
|
235
|
+
//
|
|
236
|
+
// Every absent row must fail, not just npm. The first version only exited non-zero
|
|
237
|
+
// for the npm row and then printed "consistent everywhere" with a missing GitHub
|
|
238
|
+
// Release — a false green produced by this script itself, and exactly the shape
|
|
239
|
+
// §13.37 / §13.44 / §13.50 record three times over (the checker is wrong, not the
|
|
240
|
+
// state). The verdict is now derived from `absent` as a whole.
|
|
241
|
+
if (absent.length === 0) {
|
|
242
|
+
// Say the advisory out loud in the summary line. §13.52 was this script printing
|
|
243
|
+
// 'consistent everywhere' while a row above it said ○; a reader who skims the last
|
|
244
|
+
// line must not be able to come away believing there was nothing to see.
|
|
245
|
+
console.log('\nrelease-status: consistent everywhere'
|
|
246
|
+
+ (advisories.length > 0 ? ' (' + advisories.length + ' advisory above, not blocking)' : ''));
|
|
247
|
+
process.exit(0);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const reasons = [];
|
|
251
|
+
if (absent.some((r) => r.place === 'git tag')) {
|
|
252
|
+
reasons.push('no git tag claims this version — nothing else can be trusted');
|
|
253
|
+
}
|
|
254
|
+
if (absent.some((r) => r.place === 'tag = shipped')) {
|
|
255
|
+
reasons.push('the working tree\'s runtime files differ from the tag — a publish now would ship something the tag does not describe');
|
|
256
|
+
}
|
|
257
|
+
if (absent.some((r) => r.place === 'GitHub Release')) {
|
|
258
|
+
reasons.push('no GitHub Release — the version badge on the repo page shows a red "no releases"');
|
|
259
|
+
}
|
|
143
260
|
if (absent.some((r) => r.place === 'npm registry')) {
|
|
144
261
|
// Two very different causes read the same to a user ("install fails"), so the
|
|
145
262
|
// message has to name which one it is.
|
|
146
|
-
|
|
147
|
-
? '
|
|
148
|
-
: '
|
|
149
|
-
'rather than
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
263
|
+
reasons.push(!published
|
|
264
|
+
? 'not on npm at all — anyone installing by package name still gets the previous version'
|
|
265
|
+
: 'in the npm packument but the tarball is not downloadable yet (HTTP ' + tarballCode +
|
|
266
|
+
') — `dsh plugin add` fails rather than installing something wrong; this one is safe, wait for the CDN');
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (WARN_ONLY) {
|
|
270
|
+
console.log('\nrelease-status (warn only):');
|
|
271
|
+
for (const r of reasons) console.log(' · ' + r);
|
|
272
|
+
process.exit(0);
|
|
155
273
|
}
|
|
156
|
-
console.
|
|
274
|
+
console.error('\nrelease-status: NOT consistent — ' + reasons.length + ' problem(s):');
|
|
275
|
+
for (const r of reasons) console.error(' · ' + r);
|
|
276
|
+
process.exit(1);
|