teamsmith 0.3.0 → 0.3.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/README.md +4 -4
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +41 -0
- package/skills/teamsmith/SKILL.md +7 -7
- package/skills/teamsmith/extension/team-inbox-watch.ts +5 -3
- package/skills/teamsmith/references/protocol.md +33 -19
- package/skills/teamsmith/references/troubleshooting.md +6 -3
- package/skills/teamsmith/scripts/lib/cmd-review.sh +15 -10
- package/skills/teamsmith/scripts/lib/cmd-status.sh +8 -4
- package/skills/teamsmith/scripts/lib/common.sh +301 -267
- package/skills/teamsmith/scripts/lib/gate-lock.sh +66 -28
- package/skills/teamsmith/scripts/panel/panel.js +64 -64
- package/skills/teamsmith/scripts/panel/src/clipboard.ts +2 -1
- package/skills/teamsmith/scripts/panel/src/data.ts +40 -2
- package/skills/teamsmith/scripts/panel/src/main.tsx +5 -1
- package/skills/teamsmith/scripts/shim/killall +10 -0
- package/skills/teamsmith/scripts/shim/pgrep +10 -0
- package/skills/teamsmith/scripts/shim/pidof +10 -0
- package/skills/teamsmith/scripts/shim/pkill +10 -0
- package/skills/teamsmith/scripts/shim/signal-gate +108 -31
- package/skills/teamsmith/tests/README.md +31 -0
- package/skills/teamsmith/tests/checkout-shape-probe.sh +80 -53
- package/skills/teamsmith/tests/config-cli.sh +28 -22
- package/skills/teamsmith/tests/flip-p310-lock.sh +3 -9
- package/skills/teamsmith/tests/gate-guard.sh +52 -79
- package/skills/teamsmith/tests/help-surface.sh +2 -2
- package/skills/teamsmith/tests/install-shape.sh +80 -2
- package/skills/teamsmith/tests/key-replies-ui.sh +2 -1
- package/skills/teamsmith/tests/key-replies.sh +41 -27
- package/skills/teamsmith/tests/lib/pty-wait.sh +21 -111
- package/skills/teamsmith/tests/lib/section-guard.sh +104 -197
- package/skills/teamsmith/tests/loop-inventory.tsv +83 -89
- package/skills/teamsmith/tests/panel-b2.sh +351 -376
- package/skills/teamsmith/tests/panel-b3.sh +139 -43
- package/skills/teamsmith/tests/panel-cpu.sh +41 -129
- package/skills/teamsmith/tests/panel-p21.sh +96 -193
- package/skills/teamsmith/tests/perf.sh +83 -383
- package/skills/teamsmith/tests/routes.sh +115 -26
- package/skills/teamsmith/tests/seat-interrupt.sh +20 -10
- package/skills/teamsmith/tests/seat-visibility.sh +1 -1
- package/skills/teamsmith/tests/section-guard.sh +7 -101
- package/skills/teamsmith/tests/section-paths.tsv +15 -7
- package/skills/teamsmith/tests/section-select.sh +363 -18
- package/skills/teamsmith/tests/signal-gate.sh +249 -27
- package/skills/teamsmith/tests/signal-lint-legacy.txt +4 -1
- package/skills/teamsmith/tests/slash-team-e2e.sh +4 -4
- package/skills/teamsmith/tests/slice-coverage.sh +206 -0
- package/skills/teamsmith/tests/smoke.sh +856 -581
- package/skills/teamsmith/tests/task-model-routing.sh +25 -7
- package/skills/teamsmith/tests/team-bg-stop.sh +18 -10
- package/skills/teamsmith/tests/workflow-entry.sh +207 -0
- package/skills/teamsmith-init/SKILL.md +1 -1
- package/skills/teamsmith/tests/flip-glue.sh +0 -162
- package/skills/teamsmith/tests/flip-m12-26c.sh +0 -129
- package/skills/teamsmith/tests/flip-m12.sh +0 -185
- package/skills/teamsmith/tests/flip-m16.sh +0 -166
- package/skills/teamsmith/tests/flip-m17.sh +0 -204
- package/skills/teamsmith/tests/flip-m34.sh +0 -96
- package/skills/teamsmith/tests/flip-m37.sh +0 -188
- package/skills/teamsmith/tests/flip-m4.3.sh +0 -378
- package/skills/teamsmith/tests/flip-m43.sh +0 -128
- package/skills/teamsmith/tests/flip-m45.sh +0 -244
- package/skills/teamsmith/tests/flip-m46.sh +0 -238
- package/skills/teamsmith/tests/flip-m48.sh +0 -304
- package/skills/teamsmith/tests/flip-m6.2.sh +0 -205
- package/skills/teamsmith/tests/flip-m6.3.sh +0 -286
- package/skills/teamsmith/tests/flip-m6.4.sh +0 -267
- package/skills/teamsmith/tests/flip-m6.5.sh +0 -116
- package/skills/teamsmith/tests/flip-m7.1.sh +0 -135
- package/skills/teamsmith/tests/flip-m7.2.sh +0 -324
- package/skills/teamsmith/tests/flip-p144.sh +0 -112
- package/skills/teamsmith/tests/flip-p156.sh +0 -133
- package/skills/teamsmith/tests/flip-p160.sh +0 -182
- package/skills/teamsmith/tests/flip-p171.sh +0 -249
- package/skills/teamsmith/tests/flip-p18.1.sh +0 -95
- package/skills/teamsmith/tests/flip-p20.sh +0 -286
- package/skills/teamsmith/tests/flip-p201.sh +0 -249
- package/skills/teamsmith/tests/flip-p210.sh +0 -242
- package/skills/teamsmith/tests/flip-p211.sh +0 -152
- package/skills/teamsmith/tests/flip-p217.sh +0 -291
- package/skills/teamsmith/tests/flip-p22.sh +0 -123
- package/skills/teamsmith/tests/flip-p23.sh +0 -239
- package/skills/teamsmith/tests/flip-p25.sh +0 -165
- package/skills/teamsmith/tests/flip-p287-lock.sh +0 -342
- package/skills/teamsmith/tests/flip-p287-name.sh +0 -279
- package/skills/teamsmith/tests/flip-p304-read-side.sh +0 -98
- package/skills/teamsmith/tests/flip-p309-p162-deep.sh +0 -122
- package/skills/teamsmith/tests/flip-p71.sh +0 -184
- package/skills/teamsmith/tests/flip-p72.sh +0 -202
- package/skills/teamsmith/tests/load-experiment.sh +0 -290
- package/skills/teamsmith/tests/panel-cpu-premise.sh +0 -173
- package/skills/teamsmith/tests/panel-flip-m54.sh +0 -207
- package/skills/teamsmith/tests/panel-flip-p123.sh +0 -278
- package/skills/teamsmith/tests/panel-flip-p125.sh +0 -318
- package/skills/teamsmith/tests/panel-flip-p128.sh +0 -259
- package/skills/teamsmith/tests/panel-keyprobe-stub.sh +0 -41
- package/skills/teamsmith/tests/panel-keyprobe.sh +0 -82
- package/skills/teamsmith/tests/panel-knobs.sh +0 -89
- package/skills/teamsmith/tests/section-budgets.tsv +0 -164
- package/skills/teamsmith/tests/team-bg-flip.sh +0 -239
- package/skills/teamsmith/tests/team-inbox-watch-flip.sh +0 -191
|
@@ -89,7 +89,8 @@ export async function readClipboard(run: ClipboardRunner): Promise<ClipboardRead
|
|
|
89
89
|
* The temporary path the paste writes: `<resolved temp root>/teamsmith-paste-<uuid>.<ext>`.
|
|
90
90
|
*
|
|
91
91
|
* P309: the directory is **given** by the caller — the same `team_tmp_root` answer the rest of the
|
|
92
|
-
* tool prints (`capacity.temp_root` in the panel data
|
|
92
|
+
* tool prints (`capacity.temp_root` in the panel data, taken even when that block degrades to `—`
|
|
93
|
+
* for want of a capacity log, P331). Deriving it here again would be a second
|
|
93
94
|
* implementation of the resolution order (`process.env.TMPDIR || tmpdir()` was exactly that), and
|
|
94
95
|
* two answers is how the paste file ends up outside the root `--status`/`--sweep` judge.
|
|
95
96
|
*/
|
|
@@ -146,6 +146,13 @@ export interface DataResult {
|
|
|
146
146
|
blocks?: PanelBlocks
|
|
147
147
|
/** Blocks whose source failed, timed out or is unreadable in this snapshot (rendered as `—`). */
|
|
148
148
|
degraded?: BlockName[]
|
|
149
|
+
/**
|
|
150
|
+
* P331: the paste's temp root — the `temp_root` the **capacity** block puts in its payload. It is
|
|
151
|
+
* kept out of `data.capacity` on purpose: that block degrades to `—` while the project has no
|
|
152
|
+
* `capacity.log` (a fresh `team init` project, and the log is history written by patrol ticks),
|
|
153
|
+
* and the paste still needs the root there. Nothing renders it; no other block's payload is kept.
|
|
154
|
+
*/
|
|
155
|
+
tempRoot?: string
|
|
149
156
|
/** Why each degraded block is degraded (diagnostics; never rendered as data). */
|
|
150
157
|
errors?: Partial<Record<BlockName, string>>
|
|
151
158
|
error?: string
|
|
@@ -249,6 +256,20 @@ interface BlockOutcome {
|
|
|
249
256
|
ok: boolean
|
|
250
257
|
value?: unknown
|
|
251
258
|
error?: string
|
|
259
|
+
/** P331: the `temp_root` a non-zero `capacity` exit nevertheless printed (see `DataResult.tempRoot`). */
|
|
260
|
+
tempRoot?: string
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** The `temp_root` in the JSON a child printed before exiting non-zero, or undefined. */
|
|
264
|
+
function tempRootOf(raw: string): string | undefined {
|
|
265
|
+
const text = raw.trim()
|
|
266
|
+
if (!text) return undefined
|
|
267
|
+
try {
|
|
268
|
+
const root = (JSON.parse(text) as { temp_root?: unknown } | null)?.temp_root
|
|
269
|
+
return typeof root === 'string' && root ? root : undefined
|
|
270
|
+
} catch {
|
|
271
|
+
return undefined
|
|
272
|
+
}
|
|
252
273
|
}
|
|
253
274
|
|
|
254
275
|
/** One block, one child, one timeout. Never throws and never blocks the loop. */
|
|
@@ -310,7 +331,15 @@ function runBlock(
|
|
|
310
331
|
if (settled) return
|
|
311
332
|
const tail = err.trim().split('\n').filter(Boolean).slice(-2).join(' · ')
|
|
312
333
|
if (code !== 0) {
|
|
313
|
-
|
|
334
|
+
// P331: the capacity block prints its JSON and exits 1 while the project has no
|
|
335
|
+
// `capacity.log` yet. The paste's temp root rides that payload and is not a capacity
|
|
336
|
+
// figure, so it survives the failure — one string, and only from this block. `ok: false`
|
|
337
|
+
// keeps the block itself degraded in the frame and in `--json`.
|
|
338
|
+
done({
|
|
339
|
+
ok: false,
|
|
340
|
+
error: `rc=${code ?? '?'}${tail ? `: ${tail}` : ''}`,
|
|
341
|
+
tempRoot: name === 'capacity' ? tempRootOf(out) : undefined,
|
|
342
|
+
})
|
|
314
343
|
return
|
|
315
344
|
}
|
|
316
345
|
const raw = out.trim()
|
|
@@ -385,6 +414,8 @@ interface BlockState {
|
|
|
385
414
|
error?: string
|
|
386
415
|
/** The request key the cached value was built for (`reply_list` cursor / `reply_body` number). */
|
|
387
416
|
key?: string
|
|
417
|
+
/** P331: the temp root a degraded capacity build printed (see `DataResult.tempRoot`). */
|
|
418
|
+
tempRoot?: string
|
|
388
419
|
}
|
|
389
420
|
|
|
390
421
|
const PANEL_BLOCK_NAMES: readonly BlockName[] = [
|
|
@@ -489,7 +520,11 @@ export function createPanelCache(opts: DataOptions): PanelCache {
|
|
|
489
520
|
applyBlock(data, name, s.value)
|
|
490
521
|
}
|
|
491
522
|
mergeActivity(data, activity)
|
|
492
|
-
|
|
523
|
+
// The paste's temp root: the live capacity block while it is fresh, else the string a degraded
|
|
524
|
+
// capacity payload carried (fresh project: no capacity.log). A capacity block that is merely
|
|
525
|
+
// not built yet leaves it undefined, and the paste writes nothing — never a guessed root.
|
|
526
|
+
const tempRoot = (data.capacity as PanelData['capacity'] | undefined)?.temp_root ?? state.capacity?.tempRoot
|
|
527
|
+
return { ok: true, data, activity, blocks, degraded, errors, ...(tempRoot ? { tempRoot } : {}) }
|
|
493
528
|
}
|
|
494
529
|
|
|
495
530
|
function build(name: BlockName, key: string): Promise<void> {
|
|
@@ -502,10 +537,13 @@ export function createPanelCache(opts: DataOptions): PanelCache {
|
|
|
502
537
|
s.value = outcome.value
|
|
503
538
|
s.at = Date.now()
|
|
504
539
|
s.error = undefined
|
|
540
|
+
s.tempRoot = undefined
|
|
505
541
|
} else {
|
|
506
542
|
// A block that failed is not dressed in last week's number: it renders `—` until the
|
|
507
543
|
// next successful build (the design's stale-data trade-off, made explicit).
|
|
508
544
|
s.error = outcome.error || 'failed'
|
|
545
|
+
// P331: the one fact that outlives the failure is the paste's temp root (capacity only).
|
|
546
|
+
s.tempRoot = outcome.tempRoot
|
|
509
547
|
}
|
|
510
548
|
})
|
|
511
549
|
}
|
|
@@ -814,7 +814,11 @@ async function main(): Promise<void> {
|
|
|
814
814
|
if (!read) return { kind: 'none' as const, value: '' }
|
|
815
815
|
if (read.kind === 'text') return { kind: 'text' as const, value: read.text }
|
|
816
816
|
// P309: the paste path uses the resolved temp root the data layer reports (no second resolution).
|
|
817
|
-
|
|
817
|
+
// P331: `tempRoot` also carries the root a **degraded** capacity block printed — that block
|
|
818
|
+
// renders `—` while the project has no `capacity.log` yet, which is every fresh `team init`
|
|
819
|
+
// project (the log is history written by patrol ticks). The root is not a capacity figure, so
|
|
820
|
+
// losing the figure must not lose the paste.
|
|
821
|
+
const file = writePasteFile(read.bytes, read.mime, cache.snapshot().tempRoot)
|
|
818
822
|
if (!file) return { kind: 'none' as const, value: '' }
|
|
819
823
|
return { kind: 'path' as const, value: file }
|
|
820
824
|
},
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# teamsmith · 信号闸门的入口之一(pkill / killall / pgrep / pidof 共用一个实现)
|
|
3
|
+
#
|
|
4
|
+
# 为什么是普通文件而不是软链:npm 的 tarball 不携带 120000 软链 —— 0.3.0 的包里这四个名字全部缺失,
|
|
5
|
+
# 安装后 PATH 解析到 /usr/bin 的系统命令(docs/team/reviews/release-0.3.0.md)。本文件只做一件事:
|
|
6
|
+
# 把自己的**名字**和调用者的原始 argv 原样交给同目录的共享实现 signal-gate —— 判定与记录只有一份,
|
|
7
|
+
# 不是四份闸门。
|
|
8
|
+
set -u
|
|
9
|
+
_self="$(readlink -f "$0" 2>/dev/null || printf '%s' "$0")"
|
|
10
|
+
exec "$(dirname "$_self")/signal-gate" "$(basename "$0")" "$@"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# teamsmith · 信号闸门的入口之一(pkill / killall / pgrep / pidof 共用一个实现)
|
|
3
|
+
#
|
|
4
|
+
# 为什么是普通文件而不是软链:npm 的 tarball 不携带 120000 软链 —— 0.3.0 的包里这四个名字全部缺失,
|
|
5
|
+
# 安装后 PATH 解析到 /usr/bin 的系统命令(docs/team/reviews/release-0.3.0.md)。本文件只做一件事:
|
|
6
|
+
# 把自己的**名字**和调用者的原始 argv 原样交给同目录的共享实现 signal-gate —— 判定与记录只有一份,
|
|
7
|
+
# 不是四份闸门。
|
|
8
|
+
set -u
|
|
9
|
+
_self="$(readlink -f "$0" 2>/dev/null || printf '%s' "$0")"
|
|
10
|
+
exec "$(dirname "$_self")/signal-gate" "$(basename "$0")" "$@"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# teamsmith · 信号闸门的入口之一(pkill / killall / pgrep / pidof 共用一个实现)
|
|
3
|
+
#
|
|
4
|
+
# 为什么是普通文件而不是软链:npm 的 tarball 不携带 120000 软链 —— 0.3.0 的包里这四个名字全部缺失,
|
|
5
|
+
# 安装后 PATH 解析到 /usr/bin 的系统命令(docs/team/reviews/release-0.3.0.md)。本文件只做一件事:
|
|
6
|
+
# 把自己的**名字**和调用者的原始 argv 原样交给同目录的共享实现 signal-gate —— 判定与记录只有一份,
|
|
7
|
+
# 不是四份闸门。
|
|
8
|
+
set -u
|
|
9
|
+
_self="$(readlink -f "$0" 2>/dev/null || printf '%s' "$0")"
|
|
10
|
+
exec "$(dirname "$_self")/signal-gate" "$(basename "$0")" "$@"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# teamsmith · 信号闸门的入口之一(pkill / killall / pgrep / pidof 共用一个实现)
|
|
3
|
+
#
|
|
4
|
+
# 为什么是普通文件而不是软链:npm 的 tarball 不携带 120000 软链 —— 0.3.0 的包里这四个名字全部缺失,
|
|
5
|
+
# 安装后 PATH 解析到 /usr/bin 的系统命令(docs/team/reviews/release-0.3.0.md)。本文件只做一件事:
|
|
6
|
+
# 把自己的**名字**和调用者的原始 argv 原样交给同目录的共享实现 signal-gate —— 判定与记录只有一份,
|
|
7
|
+
# 不是四份闸门。
|
|
8
|
+
set -u
|
|
9
|
+
_self="$(readlink -f "$0" 2>/dev/null || printf '%s' "$0")"
|
|
10
|
+
exec "$(dirname "$_self")/signal-gate" "$(basename "$0")" "$@"
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# teamsmith · 信号闸门(P159 · safe-signal-discipline
|
|
3
|
-
# PATH
|
|
2
|
+
# teamsmith · 信号闸门(P159 · safe-signal-discipline;P167/P321 · 选择器入口)—— 被注入到 agent
|
|
3
|
+
# 会话(PM 与 worker 窗口)PATH 最前的包装:`pkill` / `killall` / `pgrep` / `pidof` 四个名字共用本实现。
|
|
4
|
+
#
|
|
5
|
+
# 入口形状(P321):同目录的四个名字是**普通文件**(各自几行的 wrapper),不是软链 —— npm 的 tarball
|
|
6
|
+
# 不携带 120000 软链,0.3.0 的包里四个入口全部缺失、装完落到 /usr/bin(docs/team/reviews/release-0.3.0.md)。
|
|
7
|
+
# wrapper 把自己的名字作为**第一个参数**交给本文件;本文件被软链直接调用(历史形状)时按 basename 认名字。
|
|
8
|
+
# 入口名只决定「哪个工具被拦」,不授予任何放行:四个名字走同一套判定、同一份记录。
|
|
4
9
|
#
|
|
5
10
|
# 为什么存在:三次同族事故都是「按名字/命令行模式选进程」——模式命中了别的项目、别的会话里的同名
|
|
6
11
|
# 进程,也命中了调用者自己的 shell(模式串就在那条命令行里):
|
|
@@ -10,37 +15,63 @@
|
|
|
10
15
|
# · D72 dev-bob 的 `pkill -f` 误杀了同期的门禁客户端。
|
|
11
16
|
# 名字/命令行模式不是身份。闸门管的正是窗口里的 ad-hoc 调用(静态那一半由 tests/signal-lint.pl 管)。
|
|
12
17
|
#
|
|
13
|
-
# 判定(D1/D2/D3,见 openspec/changes/safe-signal-discipline/design.md
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
+
# 判定(D1/D2/D3,见 openspec/changes/safe-signal-discipline/design.md;选择器语法 = 已归档的
|
|
19
|
+
# openspec/changes/2026-10-03-signal-gate-pgrep,`boundary#Signals go to a recorded pid …`):
|
|
20
|
+
# · **没有可证明的选择形式**:`pkill`/`killall` 的 `-f <模式>`、`-x <名字>`、`-P <pid>`、`-u <user>`、
|
|
21
|
+
# 裸名字;`pgrep` 的按名字/模式/所有者选择(裸名字、`-f` 出 PID、`-u`/`-U`/`-G`…)、`pidof` 的
|
|
22
|
+
# **一切选择形态** —— 一律拒绝(exit 64),不执行真身、不发任何信号、stdout 留空;
|
|
23
|
+
# · 放行的只有三类形态,**都不授予任何信号权限**:
|
|
24
|
+
# ① 帮助/版本:单个 `--help` / `-h` / `-V` / `--version`(四个工具都有)—— 不选择任何进程;
|
|
25
|
+
# ② 显式 group/parent 的 PID 查询:`pgrep -g N` / `-P N`(N 是显式正整数)—— 诊断查询,
|
|
26
|
+
# 输出 PID 列表;
|
|
27
|
+
# ③ 整命令模式计数:`pgrep -fc P` / `-f -c P` / `-c -f P`(P 非空且不以 `-` 开头)——
|
|
28
|
+
# **按完整命令行模式匹配、只输出个数**,不出 PID 列表;分类看的是**整个 argv**,
|
|
29
|
+
# 不是「成员里有没有某个旗标」;
|
|
30
|
+
# · 诊断不等于授权:`-g`/`-P` 交出的 PID 列表是**查询结果**,不是任何 spawner 记录过的身份;
|
|
31
|
+
# `-fc` 的计数连 PID 都不是。拿它去发信号与 `kill $(ps …)` 同类 —— 闸门不把它当许可:
|
|
32
|
+
# 放行只意味着「原样递给真身并记 act=pass」;
|
|
18
33
|
# · **没有带内放行 token**(tmux 闸门有 `--teamsmith-allow-destructive`,因为人在 argv 里能点名
|
|
19
34
|
# 对象;信号没有对象可点,那正是问题本身),也**不读任何环境变量当授权**
|
|
20
35
|
# (TEAM_ALLOW_PATTERN_KILL=1 之类的继承值不改变任何判定);
|
|
21
|
-
# · `kill` / `
|
|
36
|
+
# · `kill` / `ps` / `fuser` **不拦**:闸门是 PATH shim,exec 时只看到展开后的 argv,
|
|
22
37
|
# `kill $(pgrep -f x)` 与 `kill $(cat job.pid)` 在它看来同样四个词 —— 拦 `kill` 要么堵死安全
|
|
23
|
-
# 路线、要么放过不安全的那条。绝对路径(/usr/bin/pkill)与没有把闸门目录放
|
|
24
|
-
#
|
|
38
|
+
# 路线、要么放过不安全的那条。绝对路径(/usr/bin/pkill、/usr/bin/pgrep)与没有把闸门目录放
|
|
39
|
+
# PATH 最前的 shell、shell 函数、其它产 PID 列表的工具**同样是明说的边界**,由
|
|
40
|
+
# tests/signal-lint.pl 静态覆盖仓库脚本。
|
|
25
41
|
#
|
|
26
42
|
# 记录(D4,与 tmux 家族同形):每次调用追加一行到 $TEAM_SIGNAL_CALLS_LOG
|
|
27
|
-
# `<ISO> · act=<pass|refused> · tool=<pkill|killall> · argv=<…> · pid=<…> ppid=<…> cwd=<…>`
|
|
43
|
+
# `<ISO> · act=<pass|refused> · tool=<pkill|killall|pgrep|pidof> · argv=<…> · pid=<…> ppid=<…> cwd=<…>`
|
|
28
44
|
# 上限 2000 条**调用行**(超了留最新 1000 条;首行 `<ISO> · rotation · dropped=<N>` 轮转标记自述
|
|
29
45
|
# 被裁掉多少,N 读不出时从 0 重算)。`act=refused` 的行在写主日志**之前**先逐字节复制进
|
|
30
46
|
# `<log>.forensics` —— 拒绝记录熬得过主日志轮转;复制失败仍走原判定与退出码,只在本行末尾补
|
|
31
47
|
# `retention=failed` + stderr 一行 ✗ 点名路径(失败可见,绝不改判定,也绝不挂住调用)。
|
|
32
48
|
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
49
|
+
# 真身解析(只读形式才需要):`pkill`/`killall` 优先 TEAM_SIGNAL_REAL(fixture 钉桩用,与
|
|
50
|
+
# TEAM_TMUX_REAL 同形);`pgrep`/`pidof` **忽略**这个旧 pin(它通常钉在 pkill 上 —— 把放行的诊断
|
|
51
|
+
# 调用路由过去等于换个名字发信号),只按自己的名字在 PATH 里找第一个**闸门目录之外**的同名文件。
|
|
52
|
+
# 拒绝**不依赖**真身能不能解析出来。
|
|
35
53
|
set -u
|
|
36
54
|
|
|
37
|
-
# ──
|
|
55
|
+
# ── 我是谁:入口名 = 被拦截的工具(只应是 pkill / killall / pgrep / pidof)──────────────────
|
|
56
|
+
# 两种入口都认:① 同名软链/同名文件(basename 就是工具名);② 普通文件 wrapper —— npm 带不了软链,
|
|
57
|
+
# 所以 wrapper 把自己的名字作为**第一个参数**传进来,这里摘掉它,剩下的才是调用者的原始 argv
|
|
58
|
+
# (记录与透传都用摘掉之后的那份)。
|
|
38
59
|
_shim_self="$(readlink -f "$0" 2>/dev/null || printf '%s' "$0")"
|
|
39
|
-
|
|
60
|
+
_gate_dir="$(cd -P "$(dirname "$_shim_self")" 2>/dev/null && pwd -P)" || _gate_dir="$(dirname "$_shim_self")"
|
|
61
|
+
_argv0="$(basename "$0")"
|
|
62
|
+
case "$_argv0" in
|
|
63
|
+
pkill|killall|pgrep|pidof) _tool="$_argv0" ;;
|
|
64
|
+
signal-gate)
|
|
65
|
+
if [ "$#" -gt 0 ]; then _tool="$1"; shift; else _tool=""; fi ;;
|
|
66
|
+
*)
|
|
67
|
+
printf '✗ teamsmith 信号闸门:本文件只应以 pkill / killall / pgrep / pidof 的名字被调用(当前 %s)—— 同目录的同名入口是 wrapper\n' \
|
|
68
|
+
"${_argv0:-?}" >&2
|
|
69
|
+
exit 2 ;;
|
|
70
|
+
esac
|
|
40
71
|
case "$_tool" in
|
|
41
|
-
pkill|killall) ;;
|
|
72
|
+
pkill|killall|pgrep|pidof) ;;
|
|
42
73
|
*)
|
|
43
|
-
printf '✗ teamsmith 信号闸门:本文件只应以 pkill / killall 的名字被调用(当前 %s)——
|
|
74
|
+
printf '✗ teamsmith 信号闸门:本文件只应以 pkill / killall / pgrep / pidof 的名字被调用(当前 %s)—— 同目录的同名入口是 wrapper\n' \
|
|
44
75
|
"${_tool:-?}" >&2
|
|
45
76
|
exit 2 ;;
|
|
46
77
|
esac
|
|
@@ -51,15 +82,44 @@ _shim_argc=$#
|
|
|
51
82
|
_shim_cwd="$(pwd -P 2>/dev/null || printf '%s' "${PWD:-}")"
|
|
52
83
|
_argv="$(printf '%s' "$*" | tr '\r\n' ' ')"
|
|
53
84
|
|
|
54
|
-
# ──
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
85
|
+
# ── 判定:按**整个 argv** 分类(D2/D3)───────────────────────────────────────────────────────
|
|
86
|
+
# `_is_positive_int` 只认 [1-9][0-9]*:0 是「隐式调用者进程组/父进程」的简写、负数与前导 0 都是
|
|
87
|
+
# 非显式 ID,一律不算可证明的显式标量。`_is_info_token` 是四个工具共享的只读信息词。
|
|
88
|
+
_is_positive_int() { # <v> → 0 = 显式正整数
|
|
89
|
+
case "${1:-}" in
|
|
90
|
+
''|*[!0-9]*) return 1 ;;
|
|
91
|
+
0*) return 1 ;;
|
|
92
|
+
*) return 0 ;;
|
|
59
93
|
esac
|
|
60
|
-
|
|
94
|
+
}
|
|
95
|
+
_is_info_token() { case "${1:-}" in --help|-h|-V|--version) return 0 ;; *) return 1 ;; esac; }
|
|
96
|
+
|
|
61
97
|
_act="refused"
|
|
62
|
-
|
|
98
|
+
_pat=""
|
|
99
|
+
case "$_tool" in
|
|
100
|
+
pkill|killall)
|
|
101
|
+
[ "$_shim_argc" -eq 1 ] && _is_info_token "$1" && _act="pass"
|
|
102
|
+
;;
|
|
103
|
+
pgrep)
|
|
104
|
+
if [ "$_shim_argc" -eq 1 ]; then
|
|
105
|
+
_is_info_token "$1" && _act="pass"
|
|
106
|
+
elif [ "$_shim_argc" -eq 2 ]; then
|
|
107
|
+
case "$1" in
|
|
108
|
+
-g|-P) _is_positive_int "$2" && _act="pass" ;;
|
|
109
|
+
-fc) [ -n "$2" ] && [ "${2#-}" = "$2" ] && _act="pass" ;;
|
|
110
|
+
esac
|
|
111
|
+
elif [ "$_shim_argc" -eq 3 ]; then
|
|
112
|
+
case "$1" in
|
|
113
|
+
-f) [ "$2" = "-c" ] && _pat="$3" ;;
|
|
114
|
+
-c) [ "$2" = "-f" ] && _pat="$3" ;;
|
|
115
|
+
esac
|
|
116
|
+
[ -n "$_pat" ] && [ "${_pat#-}" = "$_pat" ] && _act="pass"
|
|
117
|
+
fi
|
|
118
|
+
;;
|
|
119
|
+
pidof)
|
|
120
|
+
[ "$_shim_argc" -eq 1 ] && _is_info_token "$1" && _act="pass"
|
|
121
|
+
;;
|
|
122
|
+
esac
|
|
63
123
|
|
|
64
124
|
# ── 有界追加(与 tmux 闸门逐字同源,P132/P77/P87):<file> ← $_line ─────────────────────────────
|
|
65
125
|
# 写不进去不挡路;FIFO 目标直接判失败(日志绝不能挂住调用);超 2000 条调用行留最新 1000 条,
|
|
@@ -122,6 +182,12 @@ if [ "$_act" = "refused" ]; then
|
|
|
122
182
|
printf '✗ teamsmith 信号闸门:已拒绝 %s —— 名字或命令行模式**不是身份**,无法证明这些进程归调用者\n' "$_tool" >&2
|
|
123
183
|
printf ' 调用参数:%s\n' "$_tool${_argv:+ $_argv}" >&2
|
|
124
184
|
printf ' 为什么:模式/名字会同时命中别的项目、别的会话里的同名进程,也会命中调用者自己的 shell(模式串就在这条命令行里)。\n' >&2
|
|
185
|
+
case "$_tool" in
|
|
186
|
+
pgrep)
|
|
187
|
+
printf ' pgrep 只放行三类形态,**都不授予信号权限**:\n · 帮助/版本:`--help` / `-h` / `-V` / `--version`(不选择任何进程);\n · 显式 group/parent 的 PID 查询:`-g <正整数>` / `-P <正整数>`(输出 PID 列表)——\n 结果是查询输出,不是任何记录过的身份;\n · 整命令模式计数:`-fc <命令>`(含 `-f -c` / `-c -f`)—— 按完整命令行模式匹配,\n 只出个数不出 PID 列表。\n' >&2 ;;
|
|
188
|
+
pidof)
|
|
189
|
+
printf ' pidof 按名字选择是它的定义:只放行单个 `--help`/`-h`/`-V`/`--version`。\n' >&2 ;;
|
|
190
|
+
esac
|
|
125
191
|
printf ' 安全路线(信号只发给**记录过的 pid**):\n' >&2
|
|
126
192
|
printf ' · team bg list 看本项目后台作业记录到的 pid\n' >&2
|
|
127
193
|
printf ' · team bg stop <id> 按记录停作业(先验 pid + 启动时间指纹)\n' >&2
|
|
@@ -129,11 +195,14 @@ if [ "$_act" = "refused" ]; then
|
|
|
129
195
|
exit 64
|
|
130
196
|
fi
|
|
131
197
|
|
|
132
|
-
# ── 放行:解析真身(
|
|
198
|
+
# ── 放行:解析真身(pkill/killall 认 TEAM_SIGNAL_REAL;选择器只认自己的名字、跳过闸门目录),透传 ──
|
|
133
199
|
_real=""
|
|
134
|
-
if [
|
|
135
|
-
|
|
136
|
-
|
|
200
|
+
if [ "$_tool" = "pkill" ] || [ "$_tool" = "killall" ]; then
|
|
201
|
+
if [ -n "${TEAM_SIGNAL_REAL:-}" ] && [ -x "${TEAM_SIGNAL_REAL:-}" ]; then
|
|
202
|
+
_c="$(readlink -f "$TEAM_SIGNAL_REAL" 2>/dev/null || printf '%s' "$TEAM_SIGNAL_REAL")"
|
|
203
|
+
_cd="$(cd -P "$(dirname "$_c")" 2>/dev/null && pwd -P)"
|
|
204
|
+
if [ "$_c" != "$_shim_self" ] && [ "$_cd" != "$_gate_dir" ]; then _real="$TEAM_SIGNAL_REAL"; fi
|
|
205
|
+
fi
|
|
137
206
|
fi
|
|
138
207
|
if [ -z "$_real" ]; then
|
|
139
208
|
_oldifs="$IFS"; IFS=':'
|
|
@@ -143,14 +212,22 @@ if [ -z "$_real" ]; then
|
|
|
143
212
|
_cand="$_d/$_tool"
|
|
144
213
|
[ -x "$_cand" ] || continue
|
|
145
214
|
_cc="$(readlink -f "$_cand" 2>/dev/null || printf '%s' "$_cand")"
|
|
146
|
-
[ "$_cc" = "$_shim_self" ]
|
|
215
|
+
if [ "$_cc" = "$_shim_self" ]; then continue; fi
|
|
216
|
+
_cd="$(cd -P "$(dirname "$_cc")" 2>/dev/null && pwd -P)"
|
|
217
|
+
[ "$_cd" = "$_gate_dir" ] && continue
|
|
147
218
|
_real="$_cand"; break
|
|
148
219
|
done
|
|
149
220
|
IFS="$_oldifs"
|
|
150
221
|
fi
|
|
151
222
|
if [ -z "$_real" ]; then
|
|
152
|
-
|
|
153
|
-
|
|
223
|
+
case "$_tool" in
|
|
224
|
+
pkill|killall)
|
|
225
|
+
printf '✗ teamsmith 信号闸门:PATH 里找不到真的 %s(只找到我自己)——把真身的目录加进 PATH,或设 TEAM_SIGNAL_REAL=<绝对路径>\n' \
|
|
226
|
+
"$_tool" >&2 ;;
|
|
227
|
+
*)
|
|
228
|
+
printf '✗ teamsmith 信号闸门:PATH 里找不到真的 %s(闸门目录之外)——把真身的目录加进 PATH(%s 不读 TEAM_SIGNAL_REAL)\n' \
|
|
229
|
+
"$_tool" "$_tool" >&2 ;;
|
|
230
|
+
esac
|
|
154
231
|
exit 127
|
|
155
232
|
fi
|
|
156
233
|
exec "$_real" ${_shim_argv[@]+"${_shim_argv[@]}"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# `tests/` — 谁能判门禁,谁只是人工工具
|
|
2
|
+
|
|
3
|
+
这个目录里有两类东西,**外观一样,性质不同**。混起来读会把「有文件」当成「有守卫」。
|
|
4
|
+
|
|
5
|
+
- **门禁夹具**:被 `smoke.sh` 的某个段、CI 步或另一个有根的夹具调用。它们每轮都跑,坏了当场红。
|
|
6
|
+
一个夹具算不算这一类,只认一件事:**有没有执行点**(`section-select.sh --paths` 能给出段号,或
|
|
7
|
+
`smoke.sh` / `workflow-entry.sh` / 另一个有根的夹具里有一处真正的调用)。
|
|
8
|
+
- **人工工具**:下面这五个。**它们不在任何门禁段里**(任何段都不调用、CI 也不调用),是发布前或
|
|
9
|
+
排障时**人**跑的取证/审计工具。跑绿了不代表门禁绿,跑红了也不拦合并——它值钱的地方在于它**自己**
|
|
10
|
+
带红侧(把实现/现场弄坏,它必须变红),所以它的结论是一次性证据,不是长期守卫。
|
|
11
|
+
|
|
12
|
+
判据来由:D201(「不粘锅」代码)与 P353 的普查——19 个夹具当时没有任何执行路径,其中 7 个在修复进
|
|
13
|
+
`main` 之后连「一次性证据」都产不出了。P354 按 PM 裁定删掉 13 个(墓碑在 `docs/team/DECISIONS.md`
|
|
14
|
+
的同日条),只留下下面五个**可重跑、且守的东西确实贵**的。加新夹具时请顺手回答一句:它的执行点是哪
|
|
15
|
+
一段?没有执行点、又不是人工工具的,就不该进这个目录。
|
|
16
|
+
|
|
17
|
+
## 人工验收工具(发布前 / 排障时跑)
|
|
18
|
+
|
|
19
|
+
| 命令 | 守什么(点名事故或契约面) | 成本与前提 |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| `bash skills/teamsmith/tests/flip-m33.sh` | bg6(2026-09-18)场景目录 `$TMP` 在门禁跑动中被外部删掉 → 半红半绿、没有一条红说得清。它证明 `smoke.sh` **前导**里的哨兵(每轮都跑)**真的会咬人**:一条点名红 + 停跑(exit 2)+ `$TMP` 之外的诊断。 | 默认跑本树的**一遍 FAST smoke**(外加可选的 pre 树腿);`--break-sentinel` 是反向腿(哨兵弄瞎 → 期望必须不成立)。 |
|
|
22
|
+
| `bash skills/teamsmith/tests/flip-m44.sh` | M44(2026-09-19)PM 用 `add -A` 把 `merge --squash` 的冲突三件套提交进被保护分支,而当时的门禁没有任何一条断言能拦。它用九个现场(真事故 / 解掉冲突 / 未跟踪不算 / 索引侧 / 三条变异)证 §0d 的判据(不是抄一份,是同一份前导 + §0d)。 | 九条腿,约 2 分钟;不需要 tmux。 |
|
|
23
|
+
| `bash skills/teamsmith/tests/flip-p308-skip-not-pass.sh` | V48 F1′:`tmux-identity-leak.sh` 的收口按「PASS==0 && FAIL==0」判,于是「tmux 坏了、七段全跳过」拿到 rc=0(跳过被当成通过)。它用四条腿证收口已改按段数判(red-now / 旧判据 rc=0 的对照 / 合法单跑 / 正常环境)。 | 需要真 tmux;`green-normal` 测不了时退出码是 **77**(脚本自己也守「跳过不是通过」),不是绿。 |
|
|
24
|
+
| `bash skills/teamsmith/tests/section-needs-audit.sh` | P112 §5.2 的 needs 缺口(`--paths` 的结论是若干键的并集,一个键缺前提会被别的键的绿遮住),P297 实测 FAST 绿、真跑 ✗9。逐键跑 `smoke.sh --select K`,断言 K 自己的段真的跑了且 ✗0。 | **贵**:默认每个键一遍 smoke,整表以小时计。收窄用 `--keys k1,k2`;验真进程前提用 `--live`(默认 FAST 会跳过真 pane 半段)。必须顺序跑。 |
|
|
25
|
+
| `bash skills/teamsmith/tests/lib/tmp-root.sh --self-test` | 临时根创建者的契约:`TMPDIR` / 归属 / 回收 / 嵌套各自记账 / 不 export、不改 shell 选项。`--break=<stage>` 把某条规则变回旧行为,守门断言必须变红(翻转腿)。 | 纯逻辑,快。部分拷贝的夹具要显式给 `TEAM_TMP_SKILL_DIR` 指回真 `scripts/lib/common.sh`(解析器只有一处实现)。 |
|
|
26
|
+
|
|
27
|
+
## 已知缺口(不要误以为有人在守)
|
|
28
|
+
|
|
29
|
+
`panel-keyprobe.sh`(刷新期间敲键不丢、草稿逐字到达)在 P354 里删掉了,**这条契约今天没有活守门人**:
|
|
30
|
+
§27 只守块协议,§28 只覆盖 headless 半边。面板 pty 面接进门禁(P349)时,这个场景要在那里补上;在那
|
|
31
|
+
之前,它属于「没人跑、也没人替」的格子,写在这里是为了不让下一个读目录的人把它当成已覆盖。
|