teamsmith 0.1.2 → 0.3.0
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 +13 -7
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +67 -0
- package/skills/teamsmith/SKILL.md +26 -8
- package/skills/teamsmith/extension/team-notify.ts +37 -6
- package/skills/teamsmith/extension/team.ts +438 -0
- package/skills/teamsmith/references/agent-adapters.md +7 -7
- package/skills/teamsmith/references/config.md +65 -18
- package/skills/teamsmith/references/migration.md +220 -34
- package/skills/teamsmith/references/protocol.md +250 -25
- package/skills/teamsmith/references/troubleshooting.md +124 -7
- package/skills/teamsmith/references/workflows.md +66 -20
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +525 -90
- package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +71 -10
- package/skills/teamsmith/scripts/lib/cmd-config.sh +562 -128
- package/skills/teamsmith/scripts/lib/cmd-death.sh +2 -15
- package/skills/teamsmith/scripts/lib/cmd-docs.sh +6 -3
- package/skills/teamsmith/scripts/lib/cmd-draft.sh +4 -4
- package/skills/teamsmith/scripts/lib/cmd-help.sh +677 -0
- package/skills/teamsmith/scripts/lib/cmd-init.sh +157 -5
- package/skills/teamsmith/scripts/lib/cmd-interrupt.sh +461 -0
- package/skills/teamsmith/scripts/lib/cmd-meeting.sh +2 -25
- package/skills/teamsmith/scripts/lib/cmd-project.sh +149 -105
- package/skills/teamsmith/scripts/lib/cmd-reap.sh +277 -0
- package/skills/teamsmith/scripts/lib/cmd-reply.sh +96 -0
- package/skills/teamsmith/scripts/lib/cmd-review.sh +188 -40
- package/skills/teamsmith/scripts/lib/cmd-status.sh +268 -30
- package/skills/teamsmith/scripts/lib/cmd-update.sh +36 -7
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +634 -54
- package/skills/teamsmith/scripts/lib/common.sh +1560 -109
- package/skills/teamsmith/scripts/lib/gate-lock.sh +544 -0
- package/skills/teamsmith/scripts/monitor.mjs +34 -3
- package/skills/teamsmith/scripts/panel/README.md +22 -11
- package/skills/teamsmith/scripts/panel/draft-send.sh +11 -1
- package/skills/teamsmith/scripts/panel/panel.js +226 -224
- package/skills/teamsmith/scripts/panel/src/App.tsx +478 -184
- package/skills/teamsmith/scripts/panel/src/clipboard.ts +11 -5
- package/skills/teamsmith/scripts/panel/src/compose.ts +6 -3
- package/skills/teamsmith/scripts/panel/src/data.ts +95 -7
- package/skills/teamsmith/scripts/panel/src/layout.ts +703 -152
- package/skills/teamsmith/scripts/panel/src/main.tsx +129 -19
- package/skills/teamsmith/scripts/panel/src/settings.ts +1 -1
- package/skills/teamsmith/scripts/panel/src/strings/en.ts +76 -31
- package/skills/teamsmith/scripts/panel/src/strings/zh.ts +78 -33
- package/skills/teamsmith/scripts/panel/src/types.ts +204 -17
- package/skills/teamsmith/scripts/replies.mjs +896 -0
- package/skills/teamsmith/scripts/shim/tmux +18 -0
- package/skills/teamsmith/scripts/strings/commands.tsv +86 -0
- package/skills/teamsmith/scripts/strings/help.en.tsv +503 -0
- package/skills/teamsmith/scripts/strings/help.zh.tsv +489 -0
- package/skills/teamsmith/scripts/team +20 -6
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +23 -3
- package/skills/teamsmith/templates/BOARD.md.tmpl +2 -2
- package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +7 -3
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +17 -0
- package/skills/teamsmith/templates/config.sh.tmpl +29 -5
- package/skills/teamsmith/templates/memory-seed.md.tmpl +3 -0
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +41 -1
- package/skills/teamsmith/templates/report.md.tmpl +12 -0
- package/skills/teamsmith/templates/task.md.tmpl +4 -0
- package/skills/teamsmith/tests/bg-ledger-harness.mjs +464 -40
- package/skills/teamsmith/tests/bg-ledger.sh +168 -10
- package/skills/teamsmith/tests/checkout-shape-probe.sh +3 -1
- package/skills/teamsmith/tests/config-cli.sh +320 -300
- package/skills/teamsmith/tests/death-cause.sh +5 -2
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +7 -1
- package/skills/teamsmith/tests/fixtures/p287/lint-good.sh.in +3 -0
- package/skills/teamsmith/tests/fixtures/p287/lint-hardcoded.sh.in +3 -0
- package/skills/teamsmith/tests/fixtures/p287/lint-no-ns.sh.in +3 -0
- package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +18 -6
- package/skills/teamsmith/tests/flip-m33.sh +5 -3
- package/skills/teamsmith/tests/flip-m37.sh +4 -1
- package/skills/teamsmith/tests/flip-m4.3.sh +4 -1
- package/skills/teamsmith/tests/flip-m6.3.sh +4 -1
- package/skills/teamsmith/tests/flip-m6.5.sh +4 -1
- package/skills/teamsmith/tests/flip-m7.2.sh +4 -1
- package/skills/teamsmith/tests/flip-p158.sh +2 -1
- package/skills/teamsmith/tests/flip-p210.sh +4 -1
- package/skills/teamsmith/tests/flip-p217.sh +4 -1
- package/skills/teamsmith/tests/flip-p287-lock.sh +342 -0
- package/skills/teamsmith/tests/flip-p287-name.sh +279 -0
- package/skills/teamsmith/tests/flip-p304-read-side.sh +98 -0
- package/skills/teamsmith/tests/flip-p308-skip-not-pass.sh +151 -0
- package/skills/teamsmith/tests/flip-p309-p162-deep.sh +122 -0
- package/skills/teamsmith/tests/flip-p310-lock.sh +216 -0
- package/skills/teamsmith/tests/flip-p310-socket.sh +125 -0
- package/skills/teamsmith/tests/help-surface.sh +1664 -0
- package/skills/teamsmith/tests/install-shape.sh +283 -22
- package/skills/teamsmith/tests/key-replies-pty.sh +374 -0
- package/skills/teamsmith/tests/key-replies-ui.sh +325 -0
- package/skills/teamsmith/tests/key-replies.sh +1314 -0
- package/skills/teamsmith/tests/ledger-ban.sh +9 -8
- package/skills/teamsmith/tests/ledger-claim.sh +248 -0
- package/skills/teamsmith/tests/lib/bounded-spin.sh +90 -0
- package/skills/teamsmith/tests/lib/model-policy.sh +30 -0
- package/skills/teamsmith/tests/lib/model-routing-boundary.sh +420 -0
- package/skills/teamsmith/tests/lib/model-routing-expansion.sh +155 -0
- package/skills/teamsmith/tests/lib/model-routing-flips.py +187 -0
- package/skills/teamsmith/tests/lib/model-routing-roles.sh +250 -0
- package/skills/teamsmith/tests/lib/proc-io.sh +103 -0
- package/skills/teamsmith/tests/lib/reply-fixture.sh +367 -0
- package/skills/teamsmith/tests/lib/section-guard.sh +258 -13
- package/skills/teamsmith/tests/lib/tmp-root.sh +139 -27
- package/skills/teamsmith/tests/lib/tmux-cap.sh +10 -1
- package/skills/teamsmith/tests/lib/tmux-iso.sh +39 -13
- package/skills/teamsmith/tests/loop-inventory.tsv +59 -47
- package/skills/teamsmith/tests/panel-b2.sh +107 -4
- package/skills/teamsmith/tests/panel-b3-stub.sh +139 -4
- package/skills/teamsmith/tests/panel-b3.sh +189 -29
- package/skills/teamsmith/tests/panel-choices.sh +81 -63
- package/skills/teamsmith/tests/panel-cpu.sh +3 -2
- package/skills/teamsmith/tests/panel-knobs.sh +7 -1
- package/skills/teamsmith/tests/panel-p21.sh +445 -241
- package/skills/teamsmith/tests/panel-snapshots.sh +41 -225
- package/skills/teamsmith/tests/panel-strings.mjs +33 -18
- package/skills/teamsmith/tests/perf.sh +122 -31
- package/skills/teamsmith/tests/pm-box-real.sh +1 -1
- package/skills/teamsmith/tests/pulse-nudge-key.sh +1 -1
- package/skills/teamsmith/tests/routes.sh +364 -109
- package/skills/teamsmith/tests/seat-interrupt.sh +1002 -0
- package/skills/teamsmith/tests/seat-visibility.sh +675 -0
- package/skills/teamsmith/tests/section-budgets.tsv +26 -12
- package/skills/teamsmith/tests/section-guard.sh +6 -1
- package/skills/teamsmith/tests/section-needs-audit.sh +24 -7
- package/skills/teamsmith/tests/section-paths.tsv +42 -26
- package/skills/teamsmith/tests/section-select.sh +90 -7
- package/skills/teamsmith/tests/slash-team-e2e.sh +323 -0
- package/skills/teamsmith/tests/slash-team.sh +617 -0
- package/skills/teamsmith/tests/smoke.sh +3762 -628
- package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-120.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-160.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-light-59.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-99.txt +5 -5
- package/skills/teamsmith/tests/task-header-model.sh +2 -1
- package/skills/teamsmith/tests/task-model-routing.sh +1511 -0
- package/skills/teamsmith/tests/tmp-hygiene.sh +782 -45
- package/skills/teamsmith/tests/tmux-identity-leak.sh +773 -0
- package/skills/teamsmith/tests/tmux-lint-legacy.txt +12 -18
- package/skills/teamsmith/tests/upgrade-recipe.sh +537 -0
- package/skills/teamsmith-init/SKILL.md +43 -43
- package/skills/teamsmith-init/references/bootstrap.md +8 -6
- package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +9 -5
|
@@ -53,6 +53,12 @@ PERF_SAMPLES=5
|
|
|
53
53
|
here="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
54
54
|
# P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
|
|
55
55
|
. "$here/lib/tmp-root.sh"
|
|
56
|
+
# P287:门禁锁的伴生锁路径与「记录读哪一份」只在 scripts/lib/gate-lock.sh 里实现一次 ——
|
|
57
|
+
# 只读探活要按新位置读(互斥在伴生锁上,发布路径是兼容声明;旧写入者的记录仍在发布路径边上)
|
|
58
|
+
if [ -f "$here/../scripts/lib/gate-lock.sh" ]; then
|
|
59
|
+
# shellcheck source=../scripts/lib/gate-lock.sh
|
|
60
|
+
. "$here/../scripts/lib/gate-lock.sh"
|
|
61
|
+
fi
|
|
56
62
|
self="$here/perf.sh"
|
|
57
63
|
ORIG_ARGS=("$@")
|
|
58
64
|
tree=""
|
|
@@ -164,51 +170,129 @@ perf_require_pinned_container() {
|
|
|
164
170
|
|
|
165
171
|
# ── 锁:自己一把(TEAM_PERF_LOCK),绝不拿门禁锁 ─────────────────────────────────────────────
|
|
166
172
|
# 两次性能运行必须串行(夹具量的是真 pane / CPU 份额,互相测量会让数字失去意义)。
|
|
167
|
-
#
|
|
168
|
-
#
|
|
173
|
+
# P287(D4 裁定「性能套件那把锁一并」):与正确性门禁**同一套锁机器** ——
|
|
174
|
+
# ① 两把锁、顺序固定(发布路径 = 兼容声明 → 伴生锁 = 运行互斥;同行同目录、`.machine`、点开头);
|
|
175
|
+
# 性能锁没有外部旧写入者,但同一套纪律买的是同一件事:别人的清理命令够不着互斥。
|
|
176
|
+
# ② 取锁的进程自己握 fd,套件跑在它的**子进程**里、两个锁 fd 关掉(`8>&- 9>&-`)——
|
|
177
|
+
# M23 的漏锁教训在这里同样是构造性关掉的;收尾只删**自己的记录**,锁文件永不 unlink。
|
|
178
|
+
# ③ 记录写在伴生锁边上(`<companion>.holder`),带 `lock_identity=fd|path` 与 `lock_dev_ino`。
|
|
179
|
+
# ④ 运行期间互斥被破坏(伴生锁被删/被换)⇒ 读数不可信:打印一行 + 判红(exit 2)。
|
|
180
|
+
perf_lock_companion() { printf '%s\n' "$(gate_lock_companion_path "${1:-${TEAM_PERF_LOCK:-$(team_tmp_root)/teamsmith-perf.lock}}")"; }
|
|
169
181
|
perf_lock_or_continue() {
|
|
170
|
-
[ "${
|
|
182
|
+
[ "${PERF_LOCK_TAKEN:-0}" = "1" ] && return 0 # 子进程(真正跑套件的那个):锁由父进程取到了
|
|
183
|
+
# 容器里的那一层由**宿主这一层**持锁(引擎是 P0 的子进程,锁 fd 已被 8>&- 9>&- 关掉):
|
|
184
|
+
# 不再取锁、也不认领(认领判据在宿主那层已经判过)。
|
|
185
|
+
[ "${TEAM_PERF_LOCK_HELD_BY_RUNNER:-0}" = "1" ] && { note "性能锁由调用方(宿主运行)持有 → 容器内不再取锁"; return 0; }
|
|
171
186
|
[ "${TEAM_PERF_NO_LOCK:-0}" = "1" ] && { note "TEAM_PERF_NO_LOCK=1 → 不与别的性能运行串行(自担并发干扰)"; return 0; }
|
|
172
187
|
if ! command -v flock >/dev/null 2>&1; then
|
|
173
188
|
note "本机没有 flock → 不与别的性能运行串行(自担并发干扰)"
|
|
174
189
|
return 0
|
|
175
190
|
fi
|
|
176
|
-
local lock="${TEAM_PERF_LOCK:-$
|
|
191
|
+
local lock="${TEAM_PERF_LOCK:-$(team_tmp_root)/teamsmith-perf.lock}" wait_s="${TEAM_PERF_LOCK_WAIT:-1800}"
|
|
177
192
|
case "$wait_s" in ''|*[!0-9]*) wait_s=1800 ;; esac
|
|
193
|
+
local comp; comp="$(perf_lock_companion "$lock")"
|
|
178
194
|
mkdir -p "$(dirname "$lock")" 2>/dev/null || true
|
|
179
195
|
: >>"$lock" 2>/dev/null || { note "锁文件 $lock 建不了 → 不串行"; return 0; }
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
196
|
+
# 有界轮询取两把锁(每轮重算上限:持有者公布的 expected 优先,缺则 wait_s)——
|
|
197
|
+
# 上限到点留下可读的一句(性能套件的退出码是 0/2/3/4,拿不到锁 = 没结论 → exit 3)。
|
|
198
|
+
local rc=0 t0 queued=0 cap wait_used=0
|
|
199
|
+
t0="$(date +%s)"
|
|
200
|
+
while :; do
|
|
201
|
+
rc=0; gate_lock_acquire_pair "$lock" || rc=$?
|
|
202
|
+
[ "$rc" = "0" ] && break
|
|
203
|
+
if [ "$rc" = "2" ]; then
|
|
204
|
+
note "锁文件 $lock 建不了 → 不串行"; return 0
|
|
205
|
+
fi
|
|
206
|
+
IFS=$'\t' read -r cap _ _ _ < <(gate_lock_cap_pair "$lock" "$wait_s")
|
|
207
|
+
case "$cap" in ''|*[!0-9]*) cap="$wait_s" ;; esac
|
|
208
|
+
if [ "$queued" = "0" ]; then
|
|
209
|
+
queued=1
|
|
210
|
+
say "另一个性能运行正在跑($(gate_lock_describe_pair "$lock"));本次排队,最多等 ${cap}s"
|
|
211
|
+
fi
|
|
212
|
+
wait_used=$(( $(date +%s) - t0 ))
|
|
213
|
+
if [ "$wait_used" -ge "$cap" ]; then
|
|
214
|
+
printf 'perf: 等待 %ss 仍拿不到性能锁(持有者:%s)—— 另一个性能运行还没结束;不并发测量(exit 3)\n' \
|
|
215
|
+
"$wait_used" "$(gate_lock_describe_pair "$lock")" >&2
|
|
216
|
+
exit 3
|
|
217
|
+
fi
|
|
218
|
+
sleep 1
|
|
219
|
+
done
|
|
220
|
+
# 记录由**取锁的进程**(本 shell)写;两把锁的 mtime 刷一次(按 age 的清理器不该删活锁)
|
|
221
|
+
touch "$lock" "$comp" 2>/dev/null || true
|
|
222
|
+
local ident ino
|
|
223
|
+
IFS=$'\t' read -r ident ino < <(gate_lock_claim_identity "$comp")
|
|
224
|
+
gate_lock_write_holder "$comp" "$$" top "perf.sh" "perf" "$PWD" "$(date +%s)" - - - 0 - - "$ident" "$ino" || true
|
|
225
|
+
export PERF_LOCK_TAKEN=1 PERF_LOCK_CLAIMER_PID="$$" PERF_LOCK_CLAIMER_IDENTITY="$ident" PERF_LOCK_CLAIMER_DEV_INO="$ino"
|
|
226
|
+
export PERF_LOCK="$lock" PERF_LOCK_COMPANION="$comp"
|
|
227
|
+
local rc2=0
|
|
228
|
+
bash "$self" "${ORIG_ARGS[@]}" 8>&- 9>&- || rc2=$?
|
|
229
|
+
# 收尾:只删自己的记录;两把锁文件都留着(unlink 一个还有等待者阻塞在它 inode 上的锁,正是要消灭的静默分裂)
|
|
230
|
+
if gate_lock_holder_claimable "$comp" "$$"; then gate_lock_remove_holder "$comp"; fi
|
|
231
|
+
rmdir "$comp.runs" 2>/dev/null || true
|
|
232
|
+
exit "$rc2"
|
|
233
|
+
}
|
|
234
|
+
# 子进程认领:两条独立证据(记录里活着的是它 / 它的 /proc 里真有一个身份相符的锁描述符),
|
|
235
|
+
# 环境变量单独不作数;认领人还必须是**我的严格祖辈**(子套件那一层)。
|
|
236
|
+
perf_lock_claim_from_parent() {
|
|
237
|
+
[ "${PERF_LOCK_TAKEN:-0}" = "1" ] || return 0
|
|
238
|
+
[ -n "${PERF_LOCK_CLAIMER_PID:-}" ] || return 0
|
|
239
|
+
PERF_LOCK="${PERF_LOCK:-${TEAM_PERF_LOCK:-$(team_tmp_root)/teamsmith-perf.lock}}"
|
|
240
|
+
PERF_LOCK_COMPANION="$(perf_lock_companion "$PERF_LOCK")"
|
|
241
|
+
local p q ok=0
|
|
242
|
+
for q in $(gate_lock_ancestry_chain "$$"); do [ "$q" = "$PERF_LOCK_CLAIMER_PID" ] && ok=1 && break; done
|
|
243
|
+
[ "$ok" = "1" ] || { printf 'perf: 锁认领人 pid=%s 不在我的进程链上 → 按未持锁处理\n' "$PERF_LOCK_CLAIMER_PID" >&2; PERF_LOCK_TAKEN=0; return 0; }
|
|
244
|
+
if [ -s "$(gate_lock_holder_file "$PERF_LOCK_COMPANION")" ] \
|
|
245
|
+
&& [ "$(gate_lock_record_get "$(gate_lock_holder_file "$PERF_LOCK_COMPANION")" pid)" = "$PERF_LOCK_CLAIMER_PID" ] \
|
|
246
|
+
&& gate_lock_record_live "$(gate_lock_holder_file "$PERF_LOCK_COMPANION")"; then
|
|
247
|
+
PERF_LOCK_DEV_INO="$(gate_lock_record_get "$(gate_lock_holder_file "$PERF_LOCK_COMPANION")" lock_dev_ino)"
|
|
248
|
+
PERF_LOCK_IDENTITY="$(gate_lock_record_get "$(gate_lock_holder_file "$PERF_LOCK_COMPANION")" lock_identity)"
|
|
249
|
+
elif [ -n "${PERF_LOCK_CLAIMER_DEV_INO:-}" ] \
|
|
250
|
+
&& gate_lock_pid_holds_path "$PERF_LOCK_CLAIMER_PID" "$PERF_LOCK_COMPANION" "$PERF_LOCK_CLAIMER_DEV_INO"; then
|
|
251
|
+
PERF_LOCK_DEV_INO="$PERF_LOCK_CLAIMER_DEV_INO"; PERF_LOCK_IDENTITY="${PERF_LOCK_CLAIMER_IDENTITY:-fd}"
|
|
252
|
+
else
|
|
253
|
+
printf 'perf: 自述持锁(pid=%s)但记录与 /proc 都对不上 → 按未持锁处理(不并发测量)\n' "$PERF_LOCK_CLAIMER_PID" >&2
|
|
254
|
+
PERF_LOCK_TAKEN=0
|
|
194
255
|
fi
|
|
195
|
-
exit "$rc"
|
|
196
256
|
}
|
|
257
|
+
# 运行期间互斥被破坏 ⇒ 读数不可信(判红,exit 2)
|
|
258
|
+
perf_lock_identity_check() {
|
|
259
|
+
[ "${PERF_LOCK_TAKEN:-0}" = "1" ] && [ -n "${PERF_LOCK_DEV_INO:-}" ] || return 0
|
|
260
|
+
local r; r="$(gate_lock_snapshot "$PERF_LOCK_COMPANION" "${PERF_LOCK_IDENTITY:-fd}" "$PERF_LOCK_DEV_INO" "$PERF_LOCK_CLAIMER_PID")"
|
|
261
|
+
case "$r" in
|
|
262
|
+
ok|'') return 0 ;;
|
|
263
|
+
*) printf '\n \033[31m✗\033[0m perf:运行期间性能锁的互斥被破坏(%s)—— 本次读数不可信(exit 2)\n' "$(printf '%s' "$r" | tr '\t' ' ')"
|
|
264
|
+
return 2 ;;
|
|
265
|
+
esac
|
|
266
|
+
}
|
|
267
|
+
if [ "${PERF_LOCK_TAKEN:-0}" = "1" ]; then perf_lock_claim_from_parent; fi
|
|
197
268
|
# --in-container 先验身份信号:缺了在这里就 exit 3,锁、临时目录、测量一样不沾。
|
|
198
269
|
if [ "$IN_CONTAINER" = "1" ]; then perf_require_pinned_container; fi
|
|
199
270
|
perf_lock_or_continue
|
|
200
|
-
if [ "${
|
|
201
|
-
|
|
202
|
-
|
|
271
|
+
if [ "${PERF_LOCK_TAKEN:-0}" = "1" ]; then
|
|
272
|
+
printf ' · 性能锁:互斥在伴生锁 %s(发布路径 %s 是兼容声明;两把都永不 unlink)\n' \
|
|
273
|
+
"$PERF_LOCK_COMPANION" "$PERF_LOCK"
|
|
203
274
|
fi
|
|
204
275
|
|
|
205
276
|
# 只读探活门禁锁:门禁在跑时性能读数会被它影响,打印持有者;**不排队等它**(性能锁独立)。
|
|
206
277
|
perf_smoke_lock_probe() {
|
|
207
|
-
local lock="${TEAM_SMOKE_LOCK:-$
|
|
208
|
-
|
|
209
|
-
if
|
|
210
|
-
|
|
278
|
+
local lock="${TEAM_SMOKE_LOCK:-$(team_tmp_root)/teamsmith-smoke.lock}" comp probe busy=0
|
|
279
|
+
comp="$lock"
|
|
280
|
+
if declare -F gate_lock_companion_path >/dev/null 2>&1; then comp="$(gate_lock_companion_path "$lock")"; fi
|
|
281
|
+
if ! command -v flock >/dev/null 2>&1; then return 0; fi
|
|
282
|
+
# P287:互斥在**伴生锁**上(发布路径是兼容声明,P287 之前的写入者只认它)—— 两把都只读探一次,
|
|
283
|
+
# 任一把被持有就算「门禁在跑」;记录按 pair 读(伴生锁边上优先,退回发布路径那条并标 version=legacy)。
|
|
284
|
+
for probe in "$comp" "$lock"; do
|
|
285
|
+
[ -e "$probe" ] || continue
|
|
286
|
+
flock -n "$probe" true 2>/dev/null || { busy=1; break; }
|
|
287
|
+
done
|
|
288
|
+
[ "$busy" = "1" ] || return 0
|
|
289
|
+
local who
|
|
290
|
+
if declare -F gate_lock_describe_pair >/dev/null 2>&1; then
|
|
291
|
+
who="$(gate_lock_describe_pair "$lock")"
|
|
292
|
+
else
|
|
293
|
+
who="$(cat "$lock.holder" 2>/dev/null || printf '持有者未知')"
|
|
211
294
|
fi
|
|
295
|
+
note "正确性门禁正在跑($who)—— 本次性能读数可能受它影响(性能锁独立,不等它)"
|
|
212
296
|
}
|
|
213
297
|
|
|
214
298
|
# ── 夹具旋钮(只在 TEAM_PERF_FIXTURE=1 时生效;真路径忽略且打印)────────────────────────────
|
|
@@ -328,8 +412,10 @@ perf_run_in_container() {
|
|
|
328
412
|
eng_env=(-e HOME=/tmp -e TEAM_PERF_MODE=container -e "TEAM_PERF_REV=$(git -C "$tree" rev-parse --short HEAD 2>/dev/null || printf 'unknown')")
|
|
329
413
|
# 夹具旋钮与锁身份透传进容器(A1 的注入翻转就在容器里跑)。
|
|
330
414
|
local k
|
|
415
|
+
# 锁的身份**不**透传:容器那一层不取锁(宿主持有),只带一句「锁由调用方持有」。
|
|
416
|
+
TEAM_PERF_LOCK_HELD_BY_RUNNER=1
|
|
331
417
|
for k in TEAM_PERF_FIXTURE TEAM_PERF_LOADAVG TEAM_PERF_CORES TEAM_PERF_FRAME_DELAY_MS \
|
|
332
|
-
|
|
418
|
+
TEAM_PERF_NO_LOCK TEAM_PANEL_CPU_SECS TEAM_PERF_LOCK_HELD_BY_RUNNER; do
|
|
333
419
|
[ -n "${!k:-}" ] && eng_env+=(-e "$k=${!k}")
|
|
334
420
|
done
|
|
335
421
|
say "参考环境:镜像 $PERF_IMAGE(引擎 ${PERF_ENGINE[*]})"
|
|
@@ -355,7 +441,7 @@ perf_setup_fixture() { # 夹具仓库(装配判定测的是面板装配,不
|
|
|
355
441
|
&& git config user.name perf && printf '# perf fixture\n' > README.md && git add -A && git commit -qm init ) >/dev/null 2>&1 || return 1
|
|
356
442
|
mkdir -p "$PERF_FIX/openspec" "$PERF_FIX/.pi/team/state" "$PERF_FIX/docs/team/reports" "$PERF_FIX/docs/team/reviews"
|
|
357
443
|
( cd "$PERF_FIX" && perf_team_env_init bash "$team_bin" init --session "teamsmith-perf-$$" \
|
|
358
|
-
--agents "dev verify" --vcs local --gates "true" --docs docs/team ) >"$PERF_TMP/init.log" 2>&1 || return 1
|
|
444
|
+
--agents "dev verify" --vcs local --gates "true" --docs docs/team --task-models 'routine=deepseek/deepseek-flash analysis=xai/grok-4.6 verify=kimi-coding/k3-256k' --pm-model 'deepseek/deepseek-flash' ) >"$PERF_TMP/init.log" 2>&1 || return 1
|
|
359
445
|
printf '2026-01-01T00:00:01Z RAM 可用 4000MB | 磁盘 swap 空闲 3000MB | 估算可再加 5 个 agent\n' \
|
|
360
446
|
> "$PERF_FIX/.pi/team/state/capacity.log"
|
|
361
447
|
return 0
|
|
@@ -575,7 +661,7 @@ perf_self_tests() {
|
|
|
575
661
|
st "挂载判定:mounts 表读不到 → 这一条判不了,不据此拒绝" 1 "$st_rc"
|
|
576
662
|
local wir_rc wir_log="$PERF_TMP/m66-wiring.log"
|
|
577
663
|
wir_rc=0
|
|
578
|
-
timeout 10 env -u TEAM_PERF_PINNED_CONTAINER -u
|
|
664
|
+
timeout 10 env -u TEAM_PERF_PINNED_CONTAINER -u TEAM_PERF_LOCK_HELD_BY_RUNNER -u PERF_LOCK_TAKEN -u TEAM_PERF_NO_LOCK \
|
|
579
665
|
bash "$self" --in-container >"$wir_log" 2>&1 || wir_rc=$?
|
|
580
666
|
st "入口接线:缺信号 → 真 CLI 可见拒绝 exit 3" 3 "$wir_rc"
|
|
581
667
|
if [ "$wir_rc" = "3" ] && grep -q 'TEAM_PERF_PINNED_CONTAINER' "$wir_log" && grep -q -- '--host' "$wir_log"; then
|
|
@@ -585,14 +671,14 @@ perf_self_tests() {
|
|
|
585
671
|
SELFTEST_FAIL=$((SELFTEST_FAIL + 1))
|
|
586
672
|
fi
|
|
587
673
|
wir_rc=0
|
|
588
|
-
timeout 10 env -u
|
|
674
|
+
timeout 10 env -u TEAM_PERF_LOCK_HELD_BY_RUNNER -u PERF_LOCK_TAKEN -u TEAM_PERF_NO_LOCK TEAM_PERF_PINNED_CONTAINER=0 \
|
|
589
675
|
bash "$self" --in-container >"$wir_log" 2>&1 || wir_rc=$?
|
|
590
676
|
st "入口接线:错信号(=0)→ 真 CLI 可见拒绝 exit 3" 3 "$wir_rc"
|
|
591
677
|
# M69 接线:ENV 信号齐全但标识文件缺失/不符(= M64 F2 的宿主伪造形状)也必须瞬时拒绝。
|
|
592
678
|
# 在真镜像里文件本就在 —— 换成钉「镜像里的文件逐字节等于 token」(镜像构建错了在这里红)。
|
|
593
679
|
if [ ! -e "$PERF_IMAGE_IDENTITY_FILE" ]; then
|
|
594
680
|
wir_rc=0
|
|
595
|
-
timeout 10 env -u
|
|
681
|
+
timeout 10 env -u TEAM_PERF_LOCK_HELD_BY_RUNNER -u PERF_LOCK_TAKEN -u TEAM_PERF_NO_LOCK TEAM_PERF_PINNED_CONTAINER=1 \
|
|
596
682
|
bash "$self" --in-container >"$wir_log" 2>&1 || wir_rc=$?
|
|
597
683
|
st "入口接线:有 ENV 信号但缺标识文件(宿主伪造形状)→ 真 CLI 可见拒绝 exit 3" 3 "$wir_rc"
|
|
598
684
|
if [ "$wir_rc" = "3" ] && grep -q 'teamsmith-gate-image' "$wir_log"; then
|
|
@@ -709,7 +795,12 @@ perf_run_suite() { # <mode-label> <reference yes|no> [unavailable]
|
|
|
709
795
|
perf_judge_assembly
|
|
710
796
|
perf_judge_panel
|
|
711
797
|
perf_self_tests
|
|
798
|
+
# 运行期间互斥被破坏 ⇒ 读数不可信:判红(exit 2),不再输出一份看起来正常的结论
|
|
799
|
+
if ! perf_lock_identity_check; then
|
|
800
|
+
perf_lock_broken=1
|
|
801
|
+
fi
|
|
712
802
|
perf_summary
|
|
803
|
+
[ "${perf_lock_broken:-0}" = "1" ] && return 2
|
|
713
804
|
}
|
|
714
805
|
|
|
715
806
|
# ── 入口 ────────────────────────────────────────────────────────────────────────────────────
|
|
@@ -151,7 +151,7 @@ fi
|
|
|
151
151
|
( cd "$REPO" && git init -q -b main && git config user.email pmbox@teamsmith && git config user.name pmbox \
|
|
152
152
|
&& echo "# pmbox" > README.md && git add -A && git commit -qm init )
|
|
153
153
|
( cd "$REPO" && env -u TMUX -u TMUX_PANE TMUX_TMPDIR="$SOCKDIR" TEAM_SESSION="$SESS" \
|
|
154
|
-
$TEAM init --session "$SESS" --agents "dev" --vcs local --gates "true" --docs docs/team ) >"$TMP/init.log" 2>&1 \
|
|
154
|
+
$TEAM init --session "$SESS" --agents "dev" --vcs local --gates "true" --docs docs/team --task-models 'routine=deepseek/deepseek-flash analysis=xai/grok-4.6 verify=kimi-coding/k3-256k' --pm-model 'deepseek/deepseek-flash' ) >"$TMP/init.log" 2>&1 \
|
|
155
155
|
|| { printf '夹具 init 失败\n'; tail -3 "$TMP/init.log"; }
|
|
156
156
|
|
|
157
157
|
# 真 pi:真 HOME(沿用使用者的 provider/配置)+ 临时 session 目录(不碰真实会话文件)
|
|
@@ -402,7 +402,7 @@ pk_mode_observers() {
|
|
|
402
402
|
&& printf '# P174 observers\n' > README.md && git add -A && git commit -qm init ) >/dev/null 2>&1 \
|
|
403
403
|
|| { bad "observers:建夹具仓库失败"; return; }
|
|
404
404
|
( cd "$R" && env "${pk_clean_env[@]}" bash "$SKILL_DIR/scripts/team" init \
|
|
405
|
-
--session "pk-obs-$$" --agents "dev" --vcs local --gates "true" --docs docs/team ) >"$O/init.log" 2>&1 \
|
|
405
|
+
--session "pk-obs-$$" --agents "dev" --vcs local --gates "true" --docs docs/team --task-models 'routine=deepseek/deepseek-flash analysis=xai/grok-4.6 verify=kimi-coding/k3-256k' --pm-model 'deepseek/deepseek-flash' ) >"$O/init.log" 2>&1 \
|
|
406
406
|
|| { bad "observers:team init 失败(见 $O/init.log)"; tail -3 "$O/init.log" | sed 's/^/ /'; return; }
|
|
407
407
|
|
|
408
408
|
# 私有 tmux shim:只读,回答「没有 pm 窗口」
|