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
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# teamsmith · `team reply` —— 关键回复(key replies)的命令面。
|
|
3
|
+
#
|
|
4
|
+
# team reply post --from <label> --title <title> --stdin 显式发布一份正文(正文只从 stdin 来)
|
|
5
|
+
# team reply list [--before <no>] [--json] 当前页元数据(body-free)
|
|
6
|
+
# team reply show <no> [--json|--raw] 一份正文;--raw 只在非 TTY 上导出原文
|
|
7
|
+
#
|
|
8
|
+
# 存储与格式在 scripts/replies.mjs(change: pulse-key-replies · design §2/§3)。
|
|
9
|
+
# 身份分类:list/show 是纯观察;post 是修改入口(身份冲突时不许静默按目录动手)。
|
|
10
|
+
# 退出码透传 helper:0 成功 / 2 输入 / 4 存储不可用 / 5 锁竞争 / 6 已可见但持久性未确认。
|
|
11
|
+
|
|
12
|
+
team_reply_usage() {
|
|
13
|
+
cat <<'EOF'
|
|
14
|
+
用法:
|
|
15
|
+
team reply post --from <label> --title <title> --stdin
|
|
16
|
+
把 stdin 的原文发布为一份关键回复。--from 是调用方填的标签(1–48 个 [A-Za-z0-9._-]);
|
|
17
|
+
工具不核对它是谁;--title 单行、最多 160 个码点、不含终端控制/双向控制;正文 1–131072 字节的合法
|
|
18
|
+
UTF-8、不含 NUL。成功只打印 body-free 回执与编号;保存失败不阻止你照常发送答复。
|
|
19
|
+
退出码:0 已持久化 / 2 输入 / 4 存储不可用 / 5 写锁竞争(≤2s) / 6 已可见但持久性未确认。
|
|
20
|
+
team reply list [--before <no>] [--json]
|
|
21
|
+
最新在前,每页最多 50 个编号槽位;`--before` 是排他游标(正整数)。文本模式每行
|
|
22
|
+
`#no <时间> <发布者标签> <标题>`,坏槽位显示为不可用行。空存储返回 0。
|
|
23
|
+
team reply show <no> [--json|--raw]
|
|
24
|
+
默认打印安全显示文本(终端控制已剥除,正文以原文保存);`--json` 给机读结构
|
|
25
|
+
(display_text/bytes/sha256,标明是显示表示);`--raw` 只在非 TTY stdout 上导出**原始字节**,
|
|
26
|
+
不加换行、不执行、不跟随链接。
|
|
27
|
+
EOF
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
team_reply_helper_path() {
|
|
31
|
+
local p="$TEAM_SKILL_DIR/scripts/replies.mjs"
|
|
32
|
+
[ -f "$p" ] || p="$(cd -P "$(dirname "${BASH_SOURCE[0]}")/../.." 2>/dev/null && pwd)/scripts/replies.mjs"
|
|
33
|
+
printf '%s\n' "$p"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
team_cmd_reply() {
|
|
37
|
+
local sub="${1:-}"
|
|
38
|
+
case "$sub" in
|
|
39
|
+
post|list|show) shift ;;
|
|
40
|
+
-h|--help|"") team_reply_usage; return 0 ;;
|
|
41
|
+
*) team_usage_die "reply: 未知子命令 ${sub:-}(post|list|show;team reply --help)" ;;
|
|
42
|
+
esac
|
|
43
|
+
local helper; helper="$(team_reply_helper_path)"
|
|
44
|
+
if [ ! -f "$helper" ]; then
|
|
45
|
+
team_err "reply: 缺存储 helper($helper)——skill 安装不完整"
|
|
46
|
+
return 4
|
|
47
|
+
fi
|
|
48
|
+
local runner; runner="$(team_js_runner)"
|
|
49
|
+
if [ -z "$runner" ]; then
|
|
50
|
+
team_err "reply: 缺少 JS 运行时(node/bun/tsx 都解析不到)——装 node ≥ ${TEAM_JS_MIN_NODE_MAJOR},或设 TEAM_JS_BIN"
|
|
51
|
+
return 4
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
local state_dir="${TEAM_STATE_DIR:-$TEAM_MAIN_ROOT/.pi/team/state}"
|
|
55
|
+
local -a extra=()
|
|
56
|
+
case "$sub" in
|
|
57
|
+
post)
|
|
58
|
+
# 论据透传;helper 自己校验输入(顺序也是合同的一部分:校验先于开锁)。
|
|
59
|
+
exec "$runner" "$helper" post --main-root "$TEAM_MAIN_ROOT" --state-dir "$state_dir" "$@"
|
|
60
|
+
;;
|
|
61
|
+
list)
|
|
62
|
+
extra=(--format json)
|
|
63
|
+
while [ $# -gt 0 ]; do
|
|
64
|
+
case "$1" in
|
|
65
|
+
# `+=` 不是 `=`:list 的默认参数已经是 `--format json`,而这里若用赋值会把先前解析到的
|
|
66
|
+
# `--before` 整个丢掉(V27 实测 `--before <no> --json` 静默返回最新页)。
|
|
67
|
+
--json) extra+=(--format json); shift ;;
|
|
68
|
+
--before) extra+=(--before "${2:?--before 需要编号}"); shift 2 ;;
|
|
69
|
+
--before=*) extra+=(--before "${1#*=}"); shift ;;
|
|
70
|
+
-h|--help) team_reply_usage; return 0 ;;
|
|
71
|
+
-*) team_usage_die "reply list: 未知参数 $1" ;;
|
|
72
|
+
*) team_usage_die "reply list: 多余参数 $1" ;;
|
|
73
|
+
esac
|
|
74
|
+
done
|
|
75
|
+
exec "$runner" "$helper" list --main-root "$TEAM_MAIN_ROOT" --state-dir "$state_dir" "${extra[@]}"
|
|
76
|
+
;;
|
|
77
|
+
show)
|
|
78
|
+
local no="" format="text"
|
|
79
|
+
while [ $# -gt 0 ]; do
|
|
80
|
+
case "$1" in
|
|
81
|
+
--json) format="json"; shift ;;
|
|
82
|
+
--raw) format="raw"; shift ;;
|
|
83
|
+
-h|--help) team_reply_usage; return 0 ;;
|
|
84
|
+
-*) team_usage_die "reply show: 未知参数 $1" ;;
|
|
85
|
+
*) if [ -z "$no" ]; then no="$1"; shift; else team_usage_die "reply show: 多余参数 $1"; fi ;;
|
|
86
|
+
esac
|
|
87
|
+
done
|
|
88
|
+
[ -n "$no" ] || team_usage_die "reply show: 需要编号(team reply show <no> [--json|--raw])"
|
|
89
|
+
if [ "$format" = "raw" ] && [ -t 1 ]; then
|
|
90
|
+
team_err "reply show --raw 只导出到非 TTY stdout(重定向到文件或管道)"
|
|
91
|
+
return 2
|
|
92
|
+
fi
|
|
93
|
+
exec "$runner" "$helper" show --main-root "$TEAM_MAIN_ROOT" --state-dir "$state_dir" --no "$no" --format "$format"
|
|
94
|
+
;;
|
|
95
|
+
esac
|
|
96
|
+
}
|
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
#
|
|
4
4
|
# 设计要点(来自 CEP 的教训):agent 的自述不算证据,PM 必须在**独立 worktree** 上
|
|
5
5
|
# checkout 该分支、跑门禁、看 diff,并把结论写成 <docs>/reviews/<ID>.md。
|
|
6
|
+
#
|
|
7
|
+
# P281(change: gate-lock-hygiene):门禁共享锁的记录格式与读写是 `lib/gate-lock.sh` 里的**唯一**
|
|
8
|
+
# 实现(`tests/smoke.sh` 共用同一份)。它不叫 `cmd-*.sh`(不是一条命令),所以不在 `scripts/team`
|
|
9
|
+
# 的 `lib/cmd-*.sh` 装载循环里 —— 这里显式装。
|
|
10
|
+
REVIEW_LIB_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd || printf '%s' "$SELF_DIR/lib")"
|
|
11
|
+
if [ -z "${GATE_LOCK_LIB:-}" ]; then
|
|
12
|
+
# shellcheck source=lib/gate-lock.sh
|
|
13
|
+
. "$REVIEW_LIB_DIR/gate-lock.sh"
|
|
14
|
+
fi
|
|
6
15
|
|
|
7
16
|
# 解析分支:--branch > 任务在跑的 agent 的当前分支 > 唯一的 task/<ID>-* 分支
|
|
8
17
|
team__resolve_branch() { # <ID> → _R;rc:0=唯一命中 1=找不到 2=歧义。M50 进程内变体(永不 team_die)
|
|
@@ -369,7 +378,8 @@ team_review_postmerge_merge3() { # <base> <branch> <path> → stdout 三路合
|
|
|
369
378
|
# 两边都动过、blob 历史又都判不出来时,用 git 自己的合并引擎当裁判(不用自己的行集合启发式:
|
|
370
379
|
# 结果 == main = main 已含分支的改动;== 分支 = 分支更新;冲突/第三个结果 = 不确定。
|
|
371
380
|
local base="$1" branch="$2" path="$3" root="$TEAM_MAIN_ROOT" d rc=0
|
|
372
|
-
|
|
381
|
+
team_tmp_root_prepare >/dev/null 2>&1 || true
|
|
382
|
+
d="$(mktemp -d "$(team_tmp_root)/teamsmith-p91-merge3-$(team_project_ns).XXXXXX")" || return 1
|
|
373
383
|
git -C "$root" show "$TEAM_PROTECTED_BRANCH:$path" > "$d/main" 2>/dev/null || : > "$d/main"
|
|
374
384
|
git -C "$root" show "$base:$path" > "$d/base" 2>/dev/null || : > "$d/base"
|
|
375
385
|
git -C "$root" show "$branch:$path" > "$d/branch" 2>/dev/null || : > "$d/branch"
|
|
@@ -1059,20 +1069,47 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1059
1069
|
# (smoke.sh 的 M23 互斥)—— 那一轮排了 930s、跑 870s,硬超时在 28-i 段掐断的是**运行**,
|
|
1060
1070
|
# 记录却写成 TIMEOUT,而同一个 HEAD 在机器安静后是 PASS 的。硬超时只该量运行:排队是 review
|
|
1061
1071
|
# 自己的、有上限、可记账的阶段。
|
|
1062
|
-
# held ——
|
|
1063
|
-
#
|
|
1072
|
+
# held —— **证明得出**「某个祖辈正握着这把锁」:沿进程树 + starttime 逐层核对记录(P281 的
|
|
1073
|
+
# gate_lock_prove_ancestor_pair),子树已被串行化,不再二次排队(否则每一层 team review
|
|
1074
|
+
# 都会和自己的祖先死锁)。
|
|
1075
|
+
# P310(回归):这里以前看 `SMOKE_LOCK_WRAPPED` 这个**可继承的环境标记**,而 P288
|
|
1076
|
+
# (6f1ed69d,F4 的正确修法)让套件拿到锁后 unset 了它 —— 于是嵌套 review 认不出
|
|
1077
|
+
# 「祖辈正握着锁」,反向排到祖先前头(等满上限 / 段预算超时)。判断改成**读证明**,
|
|
1078
|
+
# 不把标记恢复成可继承(写权仍只认记录里活着的 pid,F4 不放宽)。
|
|
1064
1079
|
# noqueue —— 没有 flock:打印降级,照跑(**不是**静默跳过;见 references/protocol.md §9b)。
|
|
1065
1080
|
# 其它用具:TEAM_SMOKE_LOCK(路径,默认同 smoke)、TEAM_SMOKE_LOCK_WAIT(上限,默认 1800s)。
|
|
1066
|
-
|
|
1081
|
+
# P287(change: gate-lock-external-deletion):与 smoke.sh **同一套**锁机器 ——
|
|
1082
|
+
# ① 取两把锁、顺序固定(发布路径 = 兼容声明 → 伴生锁 = 运行互斥;同行同目录、`.machine`、点开头);
|
|
1083
|
+
# ② 记录写在**伴生锁**边上(`<companion>.holder`),由**取锁的那个进程**(本 shell)写,含
|
|
1084
|
+
# `lock_identity=fd` 与 `lock_dev_ino=<dev:ino>`;取锁时刷两把锁的 mtime;
|
|
1085
|
+
# ③ 有界轮询(每轮短 `flock -n`、每轮重新解析路径、每轮重算上限)—— 我再等的那把被换掉会印一行;
|
|
1086
|
+
# ④ 入场检查:拿到锁后读 `<companion>.runs/*`,活的 `top` 登记记着另一个身份 ⇒ 互斥已断 ⇒
|
|
1087
|
+
# **不跑门禁**、判定 FAIL(`gates_marker=mutexbroken`,与 `queuecap` 同形:门禁没有运行)。
|
|
1088
|
+
# ⑤ 门禁跑完后复核身份:运行期间互斥被破坏 ⇒ 这次判定不可信 ⇒ FAIL(同样点名)。
|
|
1089
|
+
# 上限算式、marker 语义(P66)、超限与降级的文案/退出码**一字不改**。
|
|
1090
|
+
# P309:锁的发布路径**不搬**(P287 的跨版本串行)—— 只从它的唯一实现处读。
|
|
1091
|
+
local lock; lock="$(gate_lock_default_path)"
|
|
1092
|
+
local lock_comp; lock_comp="$(gate_lock_companion_path "$lock")"
|
|
1093
|
+
local lock_dev_ino="" lock_cap_hit=0 lock_broken="" gate_rc=0
|
|
1067
1094
|
local queue_started gate_end marker_epoch
|
|
1095
|
+
# P281:排队上限不再是「一律 W」——持有者公布了 expected 就按
|
|
1096
|
+
# cap = clamp(remaining + 60s, W, 4×W) (remaining = expected − (now − started))
|
|
1097
|
+
# 算,并打印算式与三个数;记录里没有 expected(旧写入者 / 读不到)→ 退回 W(一字不改)。
|
|
1098
|
+
local lock_wait cap_remaining cap_expected cap_started
|
|
1068
1099
|
lock_cap="${TEAM_SMOKE_LOCK_WAIT:-1800}"
|
|
1069
1100
|
case "$lock_cap" in ''|*[!0-9]*) lock_cap=1800 ;; esac
|
|
1101
|
+
lock_wait="$lock_cap"
|
|
1070
1102
|
queue_started="$(date +%s)"
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1103
|
+
local lock_record_written=0
|
|
1104
|
+
team_tmp_root_prepare >/dev/null 2>&1 || true
|
|
1105
|
+
queue_marker="$(mktemp "$(team_tmp_root)/teamsmith-review-queue.$(team_project_ns).XXXXXX" 2>/dev/null || true)"
|
|
1106
|
+
queue_holder="$(gate_lock_describe_pair "$lock")"
|
|
1107
|
+
# P310:祖先持锁的判据 = **进程树 + starttime 的证明**(不是环境里一个可继承的标记)
|
|
1108
|
+
local lock_ancestor=""
|
|
1109
|
+
lock_ancestor="$(gate_lock_prove_ancestor_pair "$lock" 2>/dev/null || true)"
|
|
1110
|
+
if [ -n "$lock_ancestor" ]; then
|
|
1074
1111
|
queue_state="held"
|
|
1075
|
-
team_info "
|
|
1112
|
+
team_info "门禁锁:已由祖辈 pid=${lock_ancestor} 持有(进程树 + starttime 证明)→ 本次不排队"
|
|
1076
1113
|
elif ! command -v flock >/dev/null 2>&1; then
|
|
1077
1114
|
queue_state="noqueue"
|
|
1078
1115
|
team_warn "本机没有 flock → 门禁排队未启用(并发两套门禁时可能互相干扰;见 references/protocol.md §9b)"
|
|
@@ -1081,36 +1118,117 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1081
1118
|
team_warn "锁文件 $lock 建不了 → 门禁排队未启用(并发两套门禁时可能互相干扰)"
|
|
1082
1119
|
else
|
|
1083
1120
|
queue_state="queued"
|
|
1084
|
-
#
|
|
1085
|
-
#
|
|
1086
|
-
local lock_probe=0
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1121
|
+
# 有界轮询取**两把**锁(P287)。marker 文件在排队**之前**就存在、但**只在真的拿到锁时才写入**
|
|
1122
|
+
# (与 flock 包装器同形):没写 = 这套没跑起来(排队被上限掐掉 / 取锁起不来)。
|
|
1123
|
+
local lock_probe=0 lock_reported=0 lock_waited_path="" lock_waited_id="" lock_probe_id=""
|
|
1124
|
+
local lock_role=""
|
|
1125
|
+
while :; do
|
|
1126
|
+
lock_probe=0
|
|
1127
|
+
gate_lock_acquire_pair "$lock" || lock_probe=$?
|
|
1128
|
+
[ "$lock_probe" = "0" ] && break
|
|
1129
|
+
if [ "$lock_probe" = "2" ]; then
|
|
1130
|
+
queue_state="noqueue"
|
|
1131
|
+
team_warn "锁文件 $lock 建不了 → 门禁排队未启用(并发两套门禁时可能互相干扰)"
|
|
1132
|
+
break
|
|
1133
|
+
fi
|
|
1134
|
+
# 我上一轮等的那把还在吗?换过就印一行(两个身份),再按路径重新解析(P287)
|
|
1135
|
+
if [ -n "$lock_waited_path" ]; then
|
|
1136
|
+
lock_probe_id="$(gate_lock_path_identity "$lock_waited_path" 2>/dev/null || true)"
|
|
1137
|
+
if [ "$lock_probe_id" != "$lock_waited_id" ]; then
|
|
1138
|
+
team_warn "我等的那把锁($lock_waited_path)已经变了 —— 旧身份 ${lock_waited_id:-(已不在)},现在 ${lock_probe_id:-(已不在)};按路径重新解析后继续等"
|
|
1139
|
+
fi
|
|
1140
|
+
lock_waited_id="$lock_probe_id"
|
|
1141
|
+
fi
|
|
1142
|
+
# 上限按持有者公布的 expected 算(P281 的算式与文案一字不改);拿到锁的那一轮也要重算过
|
|
1143
|
+
IFS=$'\t' read -r lock_cap cap_remaining cap_expected cap_started \
|
|
1144
|
+
< <(gate_lock_cap_pair "$lock" "$lock_wait")
|
|
1145
|
+
case "$lock_cap" in ''|*[!0-9]*) lock_cap="$lock_wait" ;; esac
|
|
1146
|
+
if [ "$lock_reported" = "0" ]; then
|
|
1147
|
+
lock_reported=1
|
|
1148
|
+
lock_role="$([ "$lock_probe" = "1" ] && printf '发布路径(兼容声明)' || printf '伴生锁(运行互斥)')"
|
|
1149
|
+
queue_holder="$(gate_lock_describe_pair "$lock")"
|
|
1150
|
+
team_info "门禁锁正被持有(${queue_holder});排队,最多等 ${lock_cap}s(算式:remaining=${cap_remaining}s + 60s → cap=${lock_cap}s,下限 TEAM_SMOKE_LOCK_WAIT=${lock_wait}s,上限 4×=$(( lock_wait * 4 ))s;TEAM_SMOKE_LOCK_WAIT 可调)"
|
|
1151
|
+
fi
|
|
1152
|
+
if [ "$lock_probe" = "1" ]; then lock_waited_path="$lock"; else lock_waited_path="$lock_comp"; fi
|
|
1153
|
+
[ -n "$lock_waited_id" ] || lock_waited_id="$(gate_lock_path_identity "$lock_waited_path" 2>/dev/null || true)"
|
|
1154
|
+
if [ "$(( $(date +%s) - queue_started ))" -ge "$lock_cap" ]; then
|
|
1155
|
+
lock_cap_hit=1; gate_rc=1
|
|
1156
|
+
break
|
|
1157
|
+
fi
|
|
1158
|
+
sleep 1
|
|
1159
|
+
done
|
|
1160
|
+
if [ "$lock_cap_hit" = "0" ] && [ "$queue_state" = "queued" ]; then
|
|
1161
|
+
export SMOKE_LOCK_WRAPPED=1
|
|
1162
|
+
export TEAM_SMOKE_LOCK="$lock"
|
|
1163
|
+
used_lock="$lock"
|
|
1164
|
+
# 记录由**取锁的进程**(本 shell)写:字段与 smoke.sh 同形 + 身份(P287 §3.1)
|
|
1165
|
+
touch "$lock" "$lock_comp" 2>/dev/null || true # P255 §1.6:按 age 的清理器不该删活锁
|
|
1166
|
+
IFS=$'\t' read -r lock_identity lock_dev_ino < <(gate_lock_claim_identity "$lock_comp")
|
|
1167
|
+
export GATE_KIND=top GATE_CMD="team review $id" GATE_NOLOCK=0 GATE_ANCESTOR=-
|
|
1168
|
+
export GATE_AGENT="$(gate_lock_seat_of_dir "${TEAM_CWD:-$PWD}")" GATE_WT="$(gate_lock_worktree_of_dir "${TEAM_CWD:-$PWD}")"
|
|
1169
|
+
export GATE_STARTED="$(date +%s)" GATE_HB=-
|
|
1170
|
+
IFS=$'\t' read -r GATE_EXP GATE_BND GATE_SECS \
|
|
1171
|
+
< <(gate_lock_expected "${TEAM_SKILL_DIR:-$SELF_DIR/..}/tests/smoke.sh" "${TEAM_SKILL_DIR:-$SELF_DIR/..}/tests/section-budgets.tsv")
|
|
1172
|
+
export GATE_EXP GATE_BND GATE_SECS
|
|
1173
|
+
if gate_lock_holder_claimable "$lock_comp" "$$"; then
|
|
1174
|
+
# `write_holder` 会写 <lock>.holder —— 记录**绝不**写进锁文件本身(锁文件的内容永远不被写:
|
|
1175
|
+
# 它是 flock 的对象、身份由 inode 认;写它 = 换 inode = 自己把自己的互斥判成「已替换」)
|
|
1176
|
+
gate_lock_write_holder "$lock_comp" "$$" top "team review $id" "$GATE_AGENT" "$GATE_WT" \
|
|
1177
|
+
"$GATE_STARTED" "$GATE_EXP" "$GATE_BND" "$GATE_SECS" 0 - - "$lock_identity" "$lock_dev_ino" \
|
|
1178
|
+
&& lock_record_written=1
|
|
1179
|
+
else
|
|
1180
|
+
team_warn "拿到锁了,但 $(gate_lock_holder_file "$lock_comp") 里的持有记录是**另一个活着的进程**($(gate_lock_describe_one "$(gate_lock_holder_file "$lock_comp")"))→ 不覆写它"
|
|
1181
|
+
fi
|
|
1182
|
+
# marker:真的拿到锁、接下来跑门禁(P66 语义;`<epoch> <pid>` 与 smoke.sh 同形)
|
|
1183
|
+
printf '%s %s\n' "$(date +%s)" "$$" > "$queue_marker" 2>/dev/null || true
|
|
1184
|
+
# 入场检查(P287 §4.2):活的 top 登记记着另一个身份 ⇒ 互斥已断 ⇒ 不跑门禁
|
|
1185
|
+
local entry_chain entry_msg
|
|
1186
|
+
entry_chain="$(gate_lock_ancestry_chain "$$" | tr '\n' ' ')"
|
|
1187
|
+
entry_msg="$(gate_lock_entry_conflict "$lock_comp" "$lock_dev_ino" "$$" "$entry_chain")"
|
|
1188
|
+
if [ -n "$entry_msg" ]; then
|
|
1189
|
+
lock_broken="入场检查:$entry_msg"
|
|
1190
|
+
team_err "入场检查:$entry_msg → 本次**不跑门禁**(互斥已经断了;这不是对代码的判定)"
|
|
1191
|
+
: > "$queue_marker" 2>/dev/null || true # marker 清空 = 这套没有跑起来(与排队超限同形)
|
|
1192
|
+
gate_rc=2
|
|
1193
|
+
fi
|
|
1092
1194
|
fi
|
|
1093
|
-
#
|
|
1094
|
-
#
|
|
1095
|
-
#
|
|
1096
|
-
export
|
|
1097
|
-
export
|
|
1098
|
-
|
|
1195
|
+
# P281:持有者记录由**真的拿到锁的那个进程**写(就是下面那个 bash -c,拿到锁之后、跑门禁之前),
|
|
1196
|
+
# 字段与 smoke.sh 同形。行格式只在 gate-lock.sh 里定义一次:包装器 . 上那个库、调同一个写函数
|
|
1197
|
+
# (`start=` 是**它自己**的 starttime,所以必须在包装器里算,不能在 review 进程里预算)。
|
|
1198
|
+
export GATE_KIND=top GATE_CMD="team review $id" GATE_NOLOCK=0 GATE_ANCESTOR=-
|
|
1199
|
+
export GATE_AGENT="$(gate_lock_seat_of_dir "${TEAM_CWD:-$PWD}")" GATE_WT="$(gate_lock_worktree_of_dir "${TEAM_CWD:-$PWD}")"
|
|
1200
|
+
export GATE_STARTED="$(date +%s)" GATE_HB=-
|
|
1201
|
+
IFS=$'\t' read -r GATE_EXP GATE_BND GATE_SECS \
|
|
1202
|
+
< <(gate_lock_expected "${TEAM_SKILL_DIR:-$SELF_DIR/..}/tests/smoke.sh" "${TEAM_SKILL_DIR:-$SELF_DIR/..}/tests/section-budgets.tsv")
|
|
1203
|
+
export GATE_EXP GATE_BND GATE_SECS
|
|
1099
1204
|
fi
|
|
1100
|
-
local
|
|
1101
|
-
local QUEUE_WRAP='marker="$1"; holder="$2"; id="$3"; shift 3; date +%s > "$marker"; printf "%s pid=%s cmd=team review %s\n" "$(date -Is)" "$$" "$id" > "$holder" 2>/dev/null || true; exec "$@"'
|
|
1205
|
+
local gate_started grace deadline_min
|
|
1102
1206
|
local -a gate_cmd=()
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1207
|
+
# P287:锁由本 shell 自己握着(fd 8/9)—— 门禁**及其子孙**用 `8>&- 9>&-` 把这两个 fd 关掉,
|
|
1208
|
+
# 等价于原来 `flock --close` 的那条保证(M23 的漏锁教训:夹具留下的后台进程继承 fd,脚本退出后
|
|
1209
|
+
# 锁还挂着)。入场检查已经拒绝时(lock_broken 非空)不跑门禁。
|
|
1106
1210
|
gate_cmd+=(${runner[@]+"${runner[@]}"} env ${gate_env[@]+"${gate_env[@]}"} bash -c "$TEAM_GATES")
|
|
1107
1211
|
# M25-②:门禁的 stdin 必须是 /dev/null,**不能**是调用者的 tty。实测(tests/smoke.sh 6i-b):
|
|
1108
1212
|
# 后台进程组里的子进程一读 tty 就吃 SIGTTIN 被**停住**(STAT=TN,0% CPU,看着像挂死;
|
|
1109
1213
|
# 登录 profile 里的 host-spawn 就会碰 tty)。复验常在后台窗口里跑,门禁不能依赖 tty。
|
|
1110
|
-
|
|
1214
|
+
if [ -n "$lock_broken" ] || [ "$lock_cap_hit" = "1" ]; then
|
|
1215
|
+
# 入场检查拒绝(互斥已断)或排队撞上限:**门禁不跑**(判定与记账在各分支里)
|
|
1216
|
+
: > "$log"
|
|
1217
|
+
[ -n "$lock_broken" ] && queue_state="broken"
|
|
1218
|
+
else
|
|
1219
|
+
( cd "$revdir" && "${gate_cmd[@]}" 8>&- 9>&- ) > "$log" 2>&1 < /dev/null || gate_rc=$?
|
|
1220
|
+
fi
|
|
1221
|
+
# P287:收尾只删**自己**写的持有者记录(锁文件永不 unlink;别人的活记录绝不碰)——
|
|
1222
|
+
# 留下一条陈旧记录会把后来者的排队上限与点名带偏(34②/34⑦ 实测过)。
|
|
1223
|
+
if [ "$lock_record_written" = "1" ] && gate_lock_holder_claimable "$lock_comp" "$$"; then
|
|
1224
|
+
gate_lock_remove_holder "$lock_comp"
|
|
1225
|
+
rmdir "$lock_comp.runs" 2>/dev/null || true
|
|
1226
|
+
fi
|
|
1111
1227
|
gate_end="$(date +%s)"
|
|
1112
1228
|
if [ -n "$queue_marker" ] && [ -s "$queue_marker" ]; then
|
|
1113
1229
|
marker_epoch="$(cat "$queue_marker" 2>/dev/null)"
|
|
1230
|
+
# P281:marker 现在是 `<epoch> <pid>`(与 smoke.sh 同一约定)—— 只取第一个字段当时刻
|
|
1231
|
+
marker_epoch="${marker_epoch%% *}"
|
|
1114
1232
|
case "$marker_epoch" in ''|*[!0-9]*) marker_epoch="$(date +%s)" ;; esac
|
|
1115
1233
|
queued_elapsed=$(( marker_epoch - queue_started ))
|
|
1116
1234
|
[ "$queued_elapsed" -lt 0 ] && queued_elapsed=0
|
|
@@ -1120,11 +1238,20 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1120
1238
|
fi
|
|
1121
1239
|
# 排队超上限:flock 没拿到锁(没有 marker)→ 门禁**没有运行**。判定 FAIL 而不是 TIMEOUT:
|
|
1122
1240
|
# 「没跑」和「跑了被杀」必须能分开(记录里点名持锁者与上限)。
|
|
1123
|
-
if [ "$queue_state" = "
|
|
1241
|
+
if [ "$queue_state" = "broken" ]; then
|
|
1242
|
+
verdict="FAIL"
|
|
1243
|
+
gates_marker="mutexbroken"
|
|
1244
|
+
queue_holder="$(gate_lock_describe_pair "$lock")"
|
|
1245
|
+
gates_out="(互斥已断:**门禁没有运行**。${lock_broken}。实际持有者(读伴生锁边上的记录):${queue_holder}。这不是对代码的判定 —— 等那个运行结束后重跑。)"
|
|
1246
|
+
gate_elapsed=""
|
|
1247
|
+
used_timeout=0
|
|
1248
|
+
used_lock="$lock"
|
|
1249
|
+
elif [ "$queue_state" = "queued" ] && [ -z "$(cat "$queue_marker" 2>/dev/null)" ]; then
|
|
1124
1250
|
verdict="FAIL"
|
|
1125
1251
|
gates_marker="queuecap"
|
|
1126
1252
|
queued_elapsed=$(( gate_end - queue_started ))
|
|
1127
1253
|
[ "$queued_elapsed" -lt 0 ] && queued_elapsed=0
|
|
1254
|
+
queue_holder="$(gate_lock_describe_pair "$lock")" # 撞上限时**重读**:等的这段时间持有者可能换了
|
|
1128
1255
|
gates_out="(门禁锁排队超过上限 ${lock_cap}s:**门禁没有运行**。持锁者:${queue_holder}。这不是对代码的判定 —— 等持锁者结束,或抬 TEAM_SMOKE_LOCK_WAIT 后重跑。)"
|
|
1129
1256
|
gate_elapsed=""
|
|
1130
1257
|
used_timeout=0
|
|
@@ -1160,7 +1287,22 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1160
1287
|
esac
|
|
1161
1288
|
fi
|
|
1162
1289
|
fi
|
|
1290
|
+
# P287 §3.2 的等价物(review 侧):门禁跑完后复核「我还握着入场时那个 inode 吗」——
|
|
1291
|
+
# 运行期间锁被外部删/换 ⇒ 这次判定不可信(与哨兵同一判据、同一措辞);正常时一行不加。
|
|
1292
|
+
if [ "$queue_state" = "queued" ] && [ -n "$lock_dev_ino" ]; then
|
|
1293
|
+
local lock_now
|
|
1294
|
+
lock_now="$(gate_lock_snapshot "$lock_comp" "$lock_identity" "$lock_dev_ino" "$$")"
|
|
1295
|
+
case "$lock_now" in
|
|
1296
|
+
ok|'') ;; # 完好;或读不出来(/proc 不在等)—— 不误报
|
|
1297
|
+
*) lock_broken="$(printf '%s' "$lock_now" | cut -s -f1) 现场:$(printf '%s' "$lock_now" | cut -s -f2-)"
|
|
1298
|
+
team_err "门禁运行期间互斥被破坏($(printf '%s' "$lock_now" | tr '\t' ' '))→ 这次判定不可信,判 FAIL"
|
|
1299
|
+
verdict="FAIL"; gates_marker="mutexbroken" ;;
|
|
1300
|
+
esac
|
|
1301
|
+
fi
|
|
1163
1302
|
gates_out="$(tail -25 "$log")"
|
|
1303
|
+
if [ -n "$lock_broken" ] && [ "$queue_state" = "queued" ]; then
|
|
1304
|
+
gates_out="(互斥在运行期间被破坏,这次判定不可信;判 FAIL。现场:${lock_broken})$(printf '\n')${gates_out}"
|
|
1305
|
+
fi
|
|
1164
1306
|
team_ok "门禁输出:${log#"$TEAM_MAIN_ROOT"/}(${verdict},${gate_elapsed}s)"
|
|
1165
1307
|
fi
|
|
1166
1308
|
|
|
@@ -1197,6 +1339,9 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1197
1339
|
[ "$unresolved_override" = "1" ] && head_flags="$head_flags · branch-unresolved (override)"
|
|
1198
1340
|
[ "$gates_marker" = "none" ] && head_flags="$head_flags · gates: none"
|
|
1199
1341
|
[ "$gates_marker" = "queuecap" ] && head_flags="$head_flags · gate queue cap exceeded(门禁没跑)"
|
|
1342
|
+
# P287:互斥被破坏(入场检查拒绝 → 门禁没跑;或跑完复核发现锁没了 → 判定不可信)。抬头里点名,
|
|
1343
|
+
# 与 `queuecap` 同形 —— 这条也必须是机器可读的。
|
|
1344
|
+
[ "$gates_marker" = "mutexbroken" ] && head_flags="$head_flags · gate mutex broken(互斥被破坏:判定不可信)"
|
|
1200
1345
|
# 被信号终止(不是超时):把信号名写进抬头,别拿「超时」顶替「被杀」(M6.5 / F15)
|
|
1201
1346
|
[ -n "$gate_signal" ] && head_flags="$head_flags · gate killed: $gate_signal"
|
|
1202
1347
|
{
|
|
@@ -1219,7 +1364,7 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1219
1364
|
else
|
|
1220
1365
|
printf -- '- 门禁锁:`%s`;本次排队 %ss(上限 %ss,持有者:%s)\n' "${used_lock:-$lock}" "$q_acc" "$lock_cap" "${queue_holder:-未知}"
|
|
1221
1366
|
fi ;;
|
|
1222
|
-
held) printf -- '- 门禁锁:`%s
|
|
1367
|
+
held) printf -- '- 门禁锁:`%s`;**已由祖先持有**(进程树 + starttime 证明:祖辈 pid=%s)→ 本次不排队(queued=0s;避免与自己祖先死锁)\n' "${used_lock:-$lock}" "${lock_ancestor:--}" ;;
|
|
1223
1368
|
noqueue) printf -- '- 门禁锁:**排队未启用**(本机无 flock 或锁文件建不了)→ 并发两套门禁时可能互相干扰\n' ;;
|
|
1224
1369
|
*) ;;
|
|
1225
1370
|
esac
|
|
@@ -1306,6 +1451,18 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1306
1451
|
return 0
|
|
1307
1452
|
}
|
|
1308
1453
|
|
|
1454
|
+
# Only close owns this helper. Final identity check and kill/clear share dispatch locks.
|
|
1455
|
+
team_close_seat_locked() {
|
|
1456
|
+
local a="$1" id="$2" keep="$3" window
|
|
1457
|
+
[ "$(team_state_get "$a" task '')" = "$id" ] || { team_err "close: $a assignment changed,未杀窗/清记录"; return 1; }
|
|
1458
|
+
window="$(team_state_get "$a" window "$a")"
|
|
1459
|
+
if [ "$keep" != 1 ] && team_tmux_has_window "$TEAM_SESSION" "$window"; then
|
|
1460
|
+
tmux kill-window -t "$TEAM_SESSION:$window" 2>/dev/null || return 1
|
|
1461
|
+
team_ok "kill window $TEAM_SESSION:$window"
|
|
1462
|
+
fi
|
|
1463
|
+
team_state_clear "$a"
|
|
1464
|
+
rm -f "$TEAM_STATE_DIR/$a.pending" "$TEAM_STATE_DIR"/.assignment-"$a"-*
|
|
1465
|
+
}
|
|
1309
1466
|
team_cmd_close() {
|
|
1310
1467
|
team_require_docs
|
|
1311
1468
|
local id="" status="done" keep_window=0 force=0 reason=""
|
|
@@ -1356,16 +1513,7 @@ team_cmd_close() {
|
|
|
1356
1513
|
|
|
1357
1514
|
for a in $(team_agents); do
|
|
1358
1515
|
[ "$(team_state_get "$a" task '')" = "$id" ] || continue
|
|
1359
|
-
|
|
1360
|
-
if [ "$keep_window" != "1" ] && team_tmux_has_window "$TEAM_SESSION" "$w"; then
|
|
1361
|
-
tmux kill-window -t "$TEAM_SESSION:$w" 2>/dev/null && team_ok "kill window $TEAM_SESSION:$w"
|
|
1362
|
-
fi
|
|
1363
|
-
team_state_set "$a" task ""
|
|
1364
|
-
# D62-a:任务结束就把 state 里的 branch= 一起清掉 —— 否则下一次派单的分支守卫会读到
|
|
1365
|
-
# 上一个任务的分支名,把「工作树已按规矩切回/准备好」的席位误判成「还停在旧任务分支上」而拒单。
|
|
1366
|
-
# 分支记录只是「这个席位正在跑什么」的一部分,和 task= 同生命周期;工作树实际在哪个分支
|
|
1367
|
-
# 由下面的 `git -C … rev-parse` 现场读,不受这一行影响。
|
|
1368
|
-
team_state_set "$a" branch ""
|
|
1516
|
+
team_with_lock "seat:$a" team_with_lock worker-admission team_close_seat_locked "$a" "$id" "$keep_window" || return 1
|
|
1369
1517
|
# 分支归 PM:这里只说清楚「现在在哪、复位命令是什么」,不替 PM 切分支(见 openspec board-and-status)
|
|
1370
1518
|
b="$(git -C "$(team_agent_worktree "$a")" rev-parse --abbrev-ref HEAD 2>/dev/null || true)"
|
|
1371
1519
|
case "$b" in
|