teamsmith 0.4.6 → 0.4.8
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 +6 -6
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +35 -0
- package/skills/teamsmith/SKILL.md +43 -30
- package/skills/teamsmith/extension/team-bg.ts +5 -3
- package/skills/teamsmith/extension/team-inbox-watch.ts +14 -3
- package/skills/teamsmith/extension/team-notify.ts +20 -13
- package/skills/teamsmith/extension/team-remind.ts +189 -0
- package/skills/teamsmith/extension/team-reply.ts +4 -7
- package/skills/teamsmith/references/config.md +11 -12
- package/skills/teamsmith/references/migration.md +101 -0
- package/skills/teamsmith/references/openspec.md +43 -27
- package/skills/teamsmith/references/protocol.md +26 -15
- package/skills/teamsmith/references/reminders.md +153 -161
- package/skills/teamsmith/references/troubleshooting.md +12 -7
- package/skills/teamsmith/references/workflows.md +84 -31
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +10 -4
- package/skills/teamsmith/scripts/lib/cmd-project.sh +88 -6
- package/skills/teamsmith/scripts/lib/cmd-remind.sh +88 -2
- package/skills/teamsmith/scripts/lib/cmd-review.sh +61 -35
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +48 -11
- package/skills/teamsmith/scripts/lib/common.sh +83 -13
- package/skills/teamsmith/scripts/panel/README.md +35 -33
- package/skills/teamsmith/scripts/panel/panel.js +217 -199
- package/skills/teamsmith/scripts/panel/src/App.tsx +221 -66
- package/skills/teamsmith/scripts/panel/src/data.ts +71 -15
- package/skills/teamsmith/scripts/panel/src/layout.ts +159 -310
- package/skills/teamsmith/scripts/panel/src/main.tsx +83 -21
- package/skills/teamsmith/scripts/panel/src/project-settings.ts +46 -0
- package/skills/teamsmith/scripts/panel/src/strings/en.ts +71 -205
- package/skills/teamsmith/scripts/panel/src/strings/index.ts +3 -5
- package/skills/teamsmith/scripts/panel/src/strings/zh.ts +72 -204
- package/skills/teamsmith/scripts/panel/src/types.ts +23 -4
- package/skills/teamsmith/scripts/remind-capability.mjs +261 -0
- package/skills/teamsmith/scripts/remind-store.mjs +55 -24
- package/skills/teamsmith/scripts/remind-tick.mjs +5 -2
- package/skills/teamsmith/scripts/reply-capture.mjs +8 -9
- package/skills/teamsmith/scripts/state-authority.mjs +72 -6
- package/skills/teamsmith/scripts/strings/commands.tsv +1 -1
- package/skills/teamsmith/scripts/team +1 -0
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +18 -8
- package/skills/teamsmith/templates/DECISIONS.md.tmpl +2 -2
- package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +3 -3
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +19 -14
- package/skills/teamsmith/templates/memory-seed.md.tmpl +2 -2
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +41 -25
- package/skills/teamsmith/templates/report.md.tmpl +33 -0
- package/skills/teamsmith/tests/bg-ledger-harness.mjs +217 -33
- package/skills/teamsmith/tests/bg-ledger.sh +24 -10
- package/skills/teamsmith/tests/checkout-shape-probe.sh +7 -6
- package/skills/teamsmith/tests/fixtures/remind-adversarial-delay.ts +27 -0
- package/skills/teamsmith/tests/fixtures/remind-tool-provider.ts +65 -0
- package/skills/teamsmith/tests/help-surface.sh +78 -12
- package/skills/teamsmith/tests/install-shape.sh +7 -7
- package/skills/teamsmith/tests/isolation-ledger.sh +6 -2
- package/skills/teamsmith/tests/key-replies-ui.sh +64 -5
- package/skills/teamsmith/tests/key-replies.sh +307 -106
- package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +2 -0
- package/skills/teamsmith/tests/lib/model-routing-boundary.sh +255 -90
- package/skills/teamsmith/tests/lib/model-routing-expansion.sh +181 -61
- package/skills/teamsmith/tests/lib/model-routing-roles.sh +125 -67
- package/skills/teamsmith/tests/lib/reply-fixture.sh +14 -9
- package/skills/teamsmith/tests/lib/routes-pages.sh +243 -0
- package/skills/teamsmith/tests/lib/tmp-root.sh +1 -1
- package/skills/teamsmith/tests/loop-inventory.tsv +3 -0
- package/skills/teamsmith/tests/panel-b2.sh +91 -31
- package/skills/teamsmith/tests/panel-b3-stub.sh +9 -2
- package/skills/teamsmith/tests/panel-p21.sh +607 -1162
- package/skills/teamsmith/tests/panel-strings.mjs +21 -113
- package/skills/teamsmith/tests/remind-adversarial-faults.mjs +190 -0
- package/skills/teamsmith/tests/remind-adversarial-faults.sh +78 -0
- package/skills/teamsmith/tests/remind-adversarial-real.sh +28 -0
- package/skills/teamsmith/tests/remind-cli.sh +108 -3
- package/skills/teamsmith/tests/remind-delivery-node.mjs +13 -0
- package/skills/teamsmith/tests/remind-delivery.sh +123 -35
- package/skills/teamsmith/tests/remind-lifecycle.sh +197 -0
- package/skills/teamsmith/tests/remind-pulse.sh +199 -0
- package/skills/teamsmith/tests/remind-recovery-real.sh +5 -0
- package/skills/teamsmith/tests/remind-recovery-unit.sh +118 -0
- package/skills/teamsmith/tests/remind-tool-node.mjs +159 -0
- package/skills/teamsmith/tests/remind-tool-real.mjs +801 -0
- package/skills/teamsmith/tests/remind-tool-real.sh +180 -0
- package/skills/teamsmith/tests/reply-capture-real.mjs +93 -2
- package/skills/teamsmith/tests/routes.sh +213 -293
- package/skills/teamsmith/tests/section-paths.tsv +19 -17
- package/skills/teamsmith/tests/smoke.sh +583 -133
- package/skills/teamsmith/tests/state-authority.sh +152 -8
- package/skills/teamsmith/tests/task-model-routing.sh +57 -26
- package/skills/teamsmith/tests/tmp-hygiene.sh +1 -1
- package/skills/teamsmith-init/SKILL.md +5 -5
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
|
@@ -1763,13 +1763,14 @@ team_inbox_append() { # <agent> <tag> <msg> [<sender>]
|
|
|
1763
1763
|
# 明细记录数;明细写失败 → 本事件不合并、行带 `detail=unavailable`、日志点名,该行也不做锚;
|
|
1764
1764
|
# ④ 只有 [auto*] 类行参与合并与明细;[manual]/[draft]/[nudge]/pulse 行原样追加。
|
|
1765
1765
|
|
|
1766
|
-
# 行 → 合并键(seat|class|task|awaiting)。非 [auto*] 类 / 解析不成立 → rc 1
|
|
1766
|
+
# 行 → 合并键(seat|class|task|awaiting|delivered-tip)。非 [auto*] 类 / 解析不成立 → rc 1。
|
|
1767
1767
|
# awaiting 是**集合**(去重、排序;缺字段与空集是两个不同的值);task 取 task= 戳里的 ID,否则取
|
|
1768
|
-
# agent 后的第一个 <ID> token
|
|
1768
|
+
# agent 后的第一个 <ID> token。只有 delivered 用十二位 tip 分量区分修订;无戳发送者用统一的 NOREV,
|
|
1769
|
+
# suspended/interrupted 用空标记,所以它们的跨 tip 进度仍合并。branch/uncommitted 只更新显示值。
|
|
1769
1770
|
team_notify_line_key() {
|
|
1770
1771
|
local body="$1"
|
|
1771
1772
|
case "$body" in '- '*) body="${body#- }" ;; esac
|
|
1772
|
-
local iso rest tag class seat fields aw nrm t
|
|
1773
|
+
local iso rest tag class seat fields aw nrm t rev
|
|
1773
1774
|
iso="${body%% *}"
|
|
1774
1775
|
case "$iso" in ''|*[!0-9TZ:.-]*) return 1 ;; esac
|
|
1775
1776
|
rest="${body#"$iso" }"
|
|
@@ -1811,7 +1812,12 @@ team_notify_line_key() {
|
|
|
1811
1812
|
t="${t%% *}"
|
|
1812
1813
|
fi
|
|
1813
1814
|
[ -n "$t" ] || t='?'
|
|
1814
|
-
|
|
1815
|
+
rev='-'
|
|
1816
|
+
if [ "$class" = delivered ]; then
|
|
1817
|
+
rev='NOREV'
|
|
1818
|
+
if [[ "$fields" =~ tip=([0-9a-f]{12})([[:space:]]|$) ]]; then rev="T:${BASH_REMATCH[1]}"; fi
|
|
1819
|
+
fi
|
|
1820
|
+
printf '%s|%s|%s|%s|%s\n' "$seat" "$class" "$t" "$nrm" "$rev"
|
|
1815
1821
|
}
|
|
1816
1822
|
|
|
1817
1823
|
# 尾行能不能当锚:带 detail=unavailable 的行不是锚(否则下一次成功的事件会把它抹掉,缺口就不可见了)。
|
|
@@ -254,6 +254,20 @@ team_init_model_policy_resolve() { # <cfg> <task_models|''> <pm_model|''> <task_
|
|
|
254
254
|
return 0
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
+
# PROTOCOL 是公开账本:命令路径从项目根解析,不记录运行 CLI 的绝对家目录。
|
|
258
|
+
# 源仓直接使用随仓库提交的技能;普通项目使用 init 随后安装的项目副本;跳过安装时只给明确占位。
|
|
259
|
+
team_init_protocol_skill_dir() { # <install-mode>
|
|
260
|
+
case "$1" in
|
|
261
|
+
--no-skills) printf '<skill-dir>\n'; return 0 ;;
|
|
262
|
+
esac
|
|
263
|
+
if [ -f "$TEAM_MAIN_ROOT/skills/teamsmith/SKILL.md" ] \
|
|
264
|
+
&& [ -f "$TEAM_MAIN_ROOT/skills/teamsmith/scripts/team" ]; then
|
|
265
|
+
printf 'skills/teamsmith\n'
|
|
266
|
+
else
|
|
267
|
+
printf '.pi/skills/teamsmith\n'
|
|
268
|
+
fi
|
|
269
|
+
}
|
|
270
|
+
|
|
257
271
|
team_cmd_init() {
|
|
258
272
|
local session="" agents="" vcs="" gates="" docs="" pmwin="" force=0 install_mode=""
|
|
259
273
|
local task_models="" pm_model="" task_models_set=0 pm_model_set=0
|
|
@@ -399,6 +413,7 @@ team_cmd_init() {
|
|
|
399
413
|
|
|
400
414
|
# 2) 文档骨架
|
|
401
415
|
local tdir; tdir="$(team_tmpl_dir)"
|
|
416
|
+
local docs_skill_dir; docs_skill_dir="$(team_init_protocol_skill_dir "$install_mode")"
|
|
402
417
|
TEAM_DOCS_ABS="$TEAM_MAIN_ROOT/$docs"
|
|
403
418
|
mkdir -p "$TEAM_DOCS_ABS"/{tasks,reports,threads,inbox,reviews}
|
|
404
419
|
team_render_to "$tdir/BOARD.md.tmpl" "$TEAM_DOCS_ABS/BOARD.md" "$force" "PROJECT=$project" "TODAY=$(date +%F)"
|
|
@@ -408,7 +423,7 @@ team_cmd_init() {
|
|
|
408
423
|
team_render_to "$tdir/threads-README.md" "$TEAM_DOCS_ABS/threads/README.md" "$force" "PROJECT=$project" "AGENTS=$agents"
|
|
409
424
|
team_render_to "$tdir/PROTOCOL.md.tmpl" "$TEAM_DOCS_ABS/PROTOCOL.md" "$force" \
|
|
410
425
|
"PROJECT=$project" "DOCS_DIR=$docs" "WORKTREES_DIR=$(basename "${TEAM_WORKTREES_DIR:-.worktrees}")" \
|
|
411
|
-
"SKILL_DIR=$
|
|
426
|
+
"SKILL_DIR=$docs_skill_dir" "GATES=${gates:-<未配置>}" "SESSION=$session"
|
|
412
427
|
for d in tasks reports reviews; do
|
|
413
428
|
[ -f "$TEAM_DOCS_ABS/$d/.gitkeep" ] || : > "$TEAM_DOCS_ABS/$d/.gitkeep"
|
|
414
429
|
done
|
|
@@ -416,10 +431,16 @@ team_cmd_init() {
|
|
|
416
431
|
printf '# 复验日志:本地证据,不入库\n*.log\n' > "$TEAM_DOCS_ABS/reviews/.gitignore"
|
|
417
432
|
|
|
418
433
|
# 3) AGENTS.md 协议段落
|
|
434
|
+
# 普通项目的技能只装在主检出:worker 从 worktree 调命令时也通过 git common-dir 找同一份安装。
|
|
435
|
+
# 源仓的 skills/ 随分支检出,直接复用 PROTOCOL 的仓库相对路径;--no-skills 保留明确占位。
|
|
436
|
+
local agents_skill_dir="$docs_skill_dir"
|
|
437
|
+
if [ "$agents_skill_dir" = '.pi/skills/teamsmith' ]; then
|
|
438
|
+
agents_skill_dir='"$(git rev-parse --path-format=absolute --git-common-dir)/../.pi/skills/teamsmith"'
|
|
439
|
+
fi
|
|
419
440
|
local section; section="$(mktemp)"
|
|
420
441
|
team_render "$tdir/AGENTS.section.md.tmpl" \
|
|
421
442
|
"PROJECT=$project" "DOCS_DIR=$docs" "SESSION=$session" "PM_WINDOW=$pmwin" \
|
|
422
|
-
"SKILL_DIR=$
|
|
443
|
+
"SKILL_DIR=$agents_skill_dir" "AGENTS=$agents" "GATES=${gates:-<未配置>}" \
|
|
423
444
|
"WORKTREES_DIR=${TEAM_WORKTREES_DIR:-.worktrees}" "PROTECTED_BRANCH=main" > "$section"
|
|
424
445
|
# 旧名标记迁移(<=1.12 的项目 AGENTS.md 里是 pi-team:begin/end):交给同一个写入器,按同一处
|
|
425
446
|
# 范围编辑把标记行的文字换掉(围栏外那对才动,示例里的旧标记逐字节保留)。
|
|
@@ -561,11 +582,13 @@ team_cmd_doctor() {
|
|
|
561
582
|
fi
|
|
562
583
|
fi
|
|
563
584
|
|
|
585
|
+
# P427:doctor 是只读面 —— 外部命令一律走 team_readonly_run(关掉子进程的编译缓存 / jiti 缓存 /
|
|
586
|
+
# 插件日志:`pi` 的入口会调 enableCompileCache(),拿到 TMPDIR 就把它建出来了)。
|
|
564
587
|
check "pi"; if [ -n "${TEAM_AGENT_CMD:-}" ]; then
|
|
565
588
|
pass "本项目用自定义 agent adapter:不需要 pi"
|
|
566
589
|
elif team_have_cmd pi; then
|
|
567
|
-
local pv; pv="$(pi --version 2>/dev/null | head -1 || true)"
|
|
568
|
-
if pi --help 2>&1 | grep -q -- '--session-id'; then pass "${pv:-present}"; else fail "pi 版本过旧:缺 --session-id"; fi
|
|
590
|
+
local pv; pv="$(team_readonly_run pi --version 2>/dev/null | head -1 || true)"
|
|
591
|
+
if team_readonly_run pi --help 2>&1 | grep -q -- '--session-id'; then pass "${pv:-present}"; else fail "pi 版本过旧:缺 --session-id"; fi
|
|
569
592
|
else fail "缺 pi(PATH 里没有)"; fi
|
|
570
593
|
|
|
571
594
|
# agent adapter:空 TEAM_AGENT_CMD = 内置 Pi(默认);配了就用任意 TUI agent 的命令模板。
|
|
@@ -668,7 +691,7 @@ team_cmd_doctor() {
|
|
|
668
691
|
local os_bin os_ver
|
|
669
692
|
os_bin="$(team_openspec_bin_path)"
|
|
670
693
|
if command -v "$os_bin" >/dev/null 2>&1; then
|
|
671
|
-
os_ver="$("$os_bin" --version 2>/dev/null | head -1)"
|
|
694
|
+
os_ver="$(team_readonly_run "$os_bin" --version 2>/dev/null | head -1)"
|
|
672
695
|
pass "${os_ver:-已解析}($os_bin)"
|
|
673
696
|
elif [ "${TEAM_REQUIRE_OPENSPEC:-1}" = "1" ]; then
|
|
674
697
|
fail "找不到:$os_bin(装上 OpenSpec CLI 并确保在 PATH 里,或设 TEAM_OPENSPEC_BIN;临时可 TEAM_REQUIRE_OPENSPEC=0 降级)"
|
|
@@ -705,6 +728,35 @@ team_cmd_doctor() {
|
|
|
705
728
|
warn "找到了但版本判不出:${js_path:-?} ${js_ver:-}${js_detail:+($js_detail)}——确认它能跑 --version" ;;
|
|
706
729
|
esac
|
|
707
730
|
|
|
731
|
+
# Standby 与 Reminder 共用这一个 OS 锁;没有 Reminder 的项目也不能缺少它。
|
|
732
|
+
# 已初始化时再对真实 authority.lock 取一次锁:PATH 里有可执行文件不等于这个文件系统支持锁。
|
|
733
|
+
check "状态锁 flock"
|
|
734
|
+
local flock_st flock_path flock_detail flock_probe="" flock_probe_rc=0
|
|
735
|
+
IFS=$'\t' read -r flock_st flock_path flock_detail <<< "$(team_flock_check)"
|
|
736
|
+
case "$flock_st" in
|
|
737
|
+
missing)
|
|
738
|
+
fail "PATH 里没有可执行 flock:安装 util-linux(提供 flock),或把可执行文件放进 PATH;Standby/Reminder 不会无锁写入" ;;
|
|
739
|
+
unusable)
|
|
740
|
+
fail "$flock_path 存在但不可执行或不是普通文件:修复执行权限(chmod +x $(printf '%q' "$flock_path")),或安装 util-linux 并修正 PATH" ;;
|
|
741
|
+
unavailable)
|
|
742
|
+
if [ "${TEAM_REQUIRE_JS:-1}" = "1" ]; then fail "$flock_detail:先修上面的 JS 运行时,再重跑 doctor"
|
|
743
|
+
else warn "$flock_detail(TEAM_REQUIRE_JS=0 已降级);Standby/Reminder 仍需 JS 与 flock" ; fi ;;
|
|
744
|
+
ok)
|
|
745
|
+
if ! "$flock_path" --version >/dev/null 2>&1; then
|
|
746
|
+
fail "$flock_path 无法执行(--version 失败):重新安装 util-linux,或修正 PATH 指向可用的 flock;不会无锁降级"
|
|
747
|
+
elif [ -f "$TEAM_MAIN_ROOT/.pi/team/reminder-locator.json" ] && [ -f "$TEAM_STATE_DIR/reminders/authority.lock" ]; then
|
|
748
|
+
flock_probe="$(team_authority_flock_probe 2>&1)" || flock_probe_rc=$?
|
|
749
|
+
if [ "$flock_probe_rc" -eq 0 ]; then
|
|
750
|
+
pass "$flock_path(真实 authority.lock 排他锁可用)"
|
|
751
|
+
else
|
|
752
|
+
fail "真实 authority.lock 加锁失败:$flock_probe;检查 $TEAM_STATE_DIR/reminders 所在文件系统是否支持 flock,修复或迁到支持排他锁的文件系统;不会无锁降级"
|
|
753
|
+
fi
|
|
754
|
+
else
|
|
755
|
+
pass "$flock_path(状态权威尚未初始化;首次 Standby/Reminder 写入会验证文件系统锁)"
|
|
756
|
+
fi ;;
|
|
757
|
+
*) fail "flock 诊断返回未知状态:$flock_st $flock_detail" ;;
|
|
758
|
+
esac
|
|
759
|
+
|
|
708
760
|
# M53 · wake 通道的 inotify 余量:额度 + **可证明**的占用 + 一次性注册探针。降级 ≠ 故障 ——
|
|
709
761
|
# 这是环境事实,只警告(fails 不动)并给修法;探针不是 ok 或已知余量低于底线才开口。
|
|
710
762
|
check "inotify 额度"
|
|
@@ -751,6 +803,36 @@ team_cmd_doctor() {
|
|
|
751
803
|
fi ;;
|
|
752
804
|
esac
|
|
753
805
|
|
|
806
|
+
# P442 · PM 自我提醒工具:证据只来自当前扩展自己发布的注册/错误记录,并与活进程和启动记录核对。
|
|
807
|
+
# 查不到另一个 Pi 进程里的工具表,所以缺失/过期/不匹配只能报 unknown,不能报加载失败或成功。
|
|
808
|
+
check "PM 提醒工具"
|
|
809
|
+
local remind_runner remind_runtime="" remind_inspect_rc=0
|
|
810
|
+
remind_runner="$(team_js_runner)"
|
|
811
|
+
if [ -n "$remind_runner" ] && { [[ "$pmstate" == running:* ]] || [ -f "$TEAM_STATE_DIR/remind-tool/current.json" ]; }; then
|
|
812
|
+
remind_runtime="$(team_readonly_run "$remind_runner" -e '
|
|
813
|
+
import(require("node:url").pathToFileURL(process.argv[1]).href).then(m => {
|
|
814
|
+
const [root,state,config,session,window,skill] = process.argv.slice(2);
|
|
815
|
+
const r = m.inspectRemindCapability({root,state,config,session,window,skill});
|
|
816
|
+
console.log(`${r.state} ${r.reason}; at=${r.at || "unknown"}; loaded=${r.loaded || "unknown"}; disk=${r.disk || "unknown"}`);
|
|
817
|
+
}).catch(e => { console.error(`capability diagnostic unavailable: ${e.code || e.name}`); process.exitCode=1 })
|
|
818
|
+
' "$TEAM_SKILL_DIR/scripts/remind-capability.mjs" "$TEAM_MAIN_ROOT" "$TEAM_STATE_DIR" "${TEAM_CONFIG:-${TEAM_CONFIG_FILE:-}}" "$TEAM_SESSION" "$TEAM_PM_WINDOW" "$TEAM_SKILL_DIR")" || remind_inspect_rc=$?
|
|
819
|
+
fi
|
|
820
|
+
if [ -n "$(team_trim "${TEAM_PM_CMD:-}${TEAM_PM_BIN:-}")" ]; then
|
|
821
|
+
warn "unknown:自定义 PM adapter 不支持 team_remind 能力证据"
|
|
822
|
+
elif [[ "$remind_runtime" == error\ * ]]; then
|
|
823
|
+
# A live extension can diagnose a bad generated session/window even though that same config hides the PM pane.
|
|
824
|
+
warn "$remind_runtime"
|
|
825
|
+
elif [[ "$pmstate" != running:* ]]; then
|
|
826
|
+
warn "not-running:PM 未在运行($pmstate)"
|
|
827
|
+
elif [ -z "$remind_runner" ]; then
|
|
828
|
+
warn "unknown:无可用 JS 运行时,未核实注册证据"
|
|
829
|
+
elif [ "$remind_inspect_rc" -eq 0 ] && [ -n "$remind_runtime" ]; then
|
|
830
|
+
case "$remind_runtime" in
|
|
831
|
+
ready\ *) pass "$remind_runtime" ;;
|
|
832
|
+
*) warn "$remind_runtime" ;;
|
|
833
|
+
esac
|
|
834
|
+
else warn "unknown:注册证据诊断执行失败(未当作启用或加载失败)"; fi
|
|
835
|
+
|
|
754
836
|
# M46 · 投递通道:PM 没有 inbox-watch 注册时,通知会退回输入框粘贴慢路径 —— 这条降级必须看得见。
|
|
755
837
|
# 只在「内置 Pi 的 PM」这条 lane 上判(自定义 PM CLI 不吃这个扩展,绝不劝告);PM 没在跑且
|
|
756
838
|
# 没有活痕迹时不刷行(没有可降级的目标);注册在 → pass 一行,让人知道快路径真的连着。
|
|
@@ -778,7 +860,7 @@ team_cmd_doctor() {
|
|
|
778
860
|
reply_runner="$(team_js_runner)"
|
|
779
861
|
if [ -z "$reply_runner" ]; then
|
|
780
862
|
warn "unknown:无可用 JS 运行时,未核实 live 注册"
|
|
781
|
-
elif reply_runtime="$("$reply_runner" -e '
|
|
863
|
+
elif reply_runtime="$(team_readonly_run "$reply_runner" -e '
|
|
782
864
|
import(require("node:url").pathToFileURL(process.argv[1]).href).then(m => {
|
|
783
865
|
const [root,state,config,session,window,skill] = process.argv.slice(2);
|
|
784
866
|
const r = m.inspectRuntime({root,state,config,session,window,skill});
|
|
@@ -27,15 +27,101 @@ team_remind_usage() {
|
|
|
27
27
|
# tick:巡检窗口的**轻量**到期检查(agent-self-reminder 4.1)。两种巡检形态都调同一份入口:
|
|
28
28
|
# 它只读一份有界快照,没到点就直接退出(不拿锁、不扫项目、不调模型);到点才提交入队。
|
|
29
29
|
# 失败必须看得见(不是静默跳过),但不能把巡检循环带走 —— 记一行 watchdog.log 后返回 0。
|
|
30
|
-
team_remind_due_tick() { # <pulse 实例起点 ISO
|
|
30
|
+
team_remind_due_tick() { # <pulse 实例起点 ISO>;同时给出是否需要一个 Reminder-only 恢复决定
|
|
31
31
|
local runner out rc
|
|
32
|
+
TEAM_REMIND_RECOVERY_REQUIRED=0; TEAM_REMIND_RECOVERY_SIGNATURE=''
|
|
32
33
|
runner="$(team_js_runner)"
|
|
33
34
|
[ -n "$runner" ] || { team_warn "remind: 缺 JS 运行时,到期检查没跑(显式失败,不是通过)"; return 0; }
|
|
34
35
|
out="$("$runner" "${TEAM_SKILL_DIR:-$(team_skill_dir)}/scripts/remind-tick.mjs" \
|
|
35
|
-
--root "$TEAM_MAIN_ROOT" --state-dir "$TEAM_STATE_DIR" --pulse-started "${1:-}" 2>&1)"
|
|
36
|
+
--root "$TEAM_MAIN_ROOT" --state-dir "$TEAM_STATE_DIR" --pulse-started "${1:-}" --json 2>&1)"
|
|
36
37
|
rc=$?
|
|
37
38
|
if [ "$rc" -ne 0 ]; then
|
|
38
39
|
team_wlog "remind tick 失败(rc=$rc):$(printf '%s' "$out" | head -2 | tr '\n' ' ')"
|
|
40
|
+
elif printf '%s' "$out" | grep -q '"recoveryRequired":true'; then
|
|
41
|
+
TEAM_REMIND_RECOVERY_REQUIRED=1
|
|
42
|
+
TEAM_REMIND_RECOVERY_SIGNATURE="$(printf '%s' "$out" | sed -n 's/.*"recoveryIds":\[\([^]]*\)\].*/\1/p')"
|
|
43
|
+
fi
|
|
44
|
+
return 0
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# Reminder-only 恢复:只处理权威里已 queued、尚未进入 intent 的提醒。它复用普通 PM 启动的
|
|
48
|
+
# 身份、continuity、starting、窗口与重启额度判据,但不写/不带通用 pm-prompt,也不先处理 backlog。
|
|
49
|
+
team_remind_recovery_log() { # <结果> [证据]
|
|
50
|
+
local line="$(team_timestamp) reminder-recovery $1${2:+ $2}"
|
|
51
|
+
printf '%s\n' "$line" >> "$TEAM_STATE_DIR/reminders.log"
|
|
52
|
+
printf '%s\n' "$line"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
team_remind_recovery() { # [pulse 实例起点 ISO]
|
|
56
|
+
mkdir -p "$TEAM_STATE_DIR"
|
|
57
|
+
team_remind_due_tick "${1:-$(date -u +%Y-%m-%dT%H:%M:%SZ)}"
|
|
58
|
+
[ "${TEAM_REMIND_RECOVERY_REQUIRED:-0}" = "1" ] || return 0
|
|
59
|
+
|
|
60
|
+
if [ -n "$(team_trim "${TEAM_PM_CMD:-}")" ]; then
|
|
61
|
+
team_remind_recovery_log 'result=unsupported-adapter' 'reason=custom PM adapter has no prompt-free Pi watcher contract'
|
|
62
|
+
return 0
|
|
63
|
+
fi
|
|
64
|
+
local required
|
|
65
|
+
for required in extension/team-bg.ts extension/team-inbox-watch.ts extension/team-reply.ts extension/team-remind.ts \
|
|
66
|
+
scripts/state-authority.mjs scripts/reminder-delivery.mjs; do
|
|
67
|
+
if [ ! -f "$TEAM_SKILL_DIR/$required" ]; then
|
|
68
|
+
team_remind_recovery_log 'result=missing-extension' "path=$TEAM_SKILL_DIR/$required"
|
|
69
|
+
return 0
|
|
70
|
+
fi
|
|
71
|
+
done
|
|
72
|
+
|
|
73
|
+
local st; st="$(team_pm_state)"
|
|
74
|
+
case "$st" in
|
|
75
|
+
running:*)
|
|
76
|
+
team_remind_recovery_log 'result=running' "evidence=$(team_pm_evidence "$st")"
|
|
77
|
+
return 0 ;;
|
|
78
|
+
starting:*)
|
|
79
|
+
team_remind_recovery_log 'result=starting' "evidence=$(team_pm_evidence "$st")"
|
|
80
|
+
return 0 ;;
|
|
81
|
+
esac
|
|
82
|
+
|
|
83
|
+
# 与普通 patrol 相同:缺窗口时默认只报告,不由 Pulse 改建 tmux;显式允许时才走同一组身份检查。
|
|
84
|
+
case "$st" in
|
|
85
|
+
idle:*|unknown:*) ;;
|
|
86
|
+
foreign:*)
|
|
87
|
+
team_remind_recovery_log 'result=foreign-window' "evidence=$(team_pm_evidence "$st")"
|
|
88
|
+
return 0 ;;
|
|
89
|
+
*)
|
|
90
|
+
if [ "$TEAM_PULSE_REBUILD_TMUX" != "1" ]; then
|
|
91
|
+
team_remind_recovery_log 'result=missing-window' "evidence=$(team_pm_evidence "$st")"
|
|
92
|
+
return 0
|
|
93
|
+
fi
|
|
94
|
+
if ! team_assert_own_session 'reminder recovery 重建 tmux'; then
|
|
95
|
+
team_remind_recovery_log 'result=foreign-session' 'reason=refused to rebuild a session owned by another project'
|
|
96
|
+
return 0
|
|
97
|
+
fi
|
|
98
|
+
if ! team_tmux_has_session "$TEAM_SESSION"; then
|
|
99
|
+
team_tmux_ensure_session || { team_remind_recovery_log 'result=start-failed' 'reason=tmux session creation failed'; return 0; }
|
|
100
|
+
team_tmux set-option -t "$TEAM_SESSION" destroy-unattached off >/dev/null 2>&1 || true
|
|
101
|
+
fi
|
|
102
|
+
if ! team_pm_window_exists; then
|
|
103
|
+
team_tmux_new_window "$TEAM_SESSION" "$TEAM_PM_WINDOW" || { team_remind_recovery_log 'result=start-failed' 'reason=PM window creation failed'; return 0; }
|
|
104
|
+
fi ;;
|
|
105
|
+
esac
|
|
106
|
+
|
|
107
|
+
if ! team_pm_identity_guard; then
|
|
108
|
+
team_remind_recovery_log 'result=identity-refused' 'reason=PM model/continuity/launch identity guard rejected the start'
|
|
109
|
+
return 0
|
|
110
|
+
fi
|
|
111
|
+
if ! team_pm_restart_allowed; then
|
|
112
|
+
team_remind_recovery_log 'result=quota-refused' "evidence=$(team_pm_evidence "$st")"
|
|
113
|
+
return 0
|
|
114
|
+
fi
|
|
115
|
+
team_pm_attempt_record "reason=reminder state=${st%%:*} evidence=$(team_pm_evidence "$st")"
|
|
116
|
+
if TEAM_REMINDER_ONLY_RECOVERY=1 team_pm_start; then
|
|
117
|
+
if [ "${TEAM_PM_START_OUTCOME:-}" = 'started' ]; then
|
|
118
|
+
team_pm_restart_record "reason=reminder state=${st%%:*} evidence=$(team_pm_evidence "$st")"
|
|
119
|
+
team_remind_recovery_log 'result=started' "pid=$(team_pm_recorded_pid) capacity=$(team_capacity_line)"
|
|
120
|
+
else
|
|
121
|
+
team_remind_recovery_log "result=${TEAM_PM_START_OUTCOME:-running}" 'reason=another start won the race; no second restart was recorded'
|
|
122
|
+
fi
|
|
123
|
+
else
|
|
124
|
+
team_remind_recovery_log 'result=start-failed' 'reason=PM did not obtain launch proof; Standby and Reminder outcome are unchanged'
|
|
39
125
|
fi
|
|
40
126
|
return 0
|
|
41
127
|
}
|
|
@@ -90,6 +90,43 @@ team_task_title() { # <ID> → 标题(BOARD 的「任务」列,其次任务
|
|
|
90
90
|
# 分支不是被判对象;其余任务仍是任务分支当前 tip。
|
|
91
91
|
team_review_record_path() { printf '%s\n' "$TEAM_DOCS_ABS/reviews/$1.md"; }
|
|
92
92
|
|
|
93
|
+
# root 左侧不能仍是路径字符,避免 HOME=/tmp 改坏 /var/tmp;root/ 的子路径仍可替换。
|
|
94
|
+
# 裸 root 的 ASCII 字母数字后缀,以及后随字母数字的 -_. 才算兄弟路径延续。
|
|
95
|
+
# 句末 -_. 与其它右边界(含所有中文标点)都接受,不维护分隔符白名单,也不依赖 locale 的字符分类。
|
|
96
|
+
team_review_ledger_display_root() { # <文本> <绝对根> <占位>
|
|
97
|
+
local rest="$1" root="$2" marker="$3" out="" before after right continuation skip
|
|
98
|
+
[ -n "$root" ] || { printf '%s' "$rest"; return 0; }
|
|
99
|
+
while [[ "$rest" == *"$root"* ]]; do
|
|
100
|
+
before="${rest%%"$root"*}"
|
|
101
|
+
after="${rest#*"$root"}"
|
|
102
|
+
right="${after:0:1}"
|
|
103
|
+
continuation=0
|
|
104
|
+
case "${before: -1}" in [A-Za-z0-9/_.-]) continuation=1 ;; esac
|
|
105
|
+
case "$right" in
|
|
106
|
+
[A-Za-z0-9]) continuation=1 ;;
|
|
107
|
+
[-_.]) case "${after:1:1}" in [A-Za-z0-9]) continuation=1 ;; esac ;;
|
|
108
|
+
esac
|
|
109
|
+
if [ "$continuation" = "1" ]; then
|
|
110
|
+
skip=$(( ${#before} + 1 ))
|
|
111
|
+
out="$out${rest:0:skip}"; rest="${rest:skip}"
|
|
112
|
+
else
|
|
113
|
+
out="$out$before$marker"; rest="$after"
|
|
114
|
+
fi
|
|
115
|
+
done
|
|
116
|
+
printf '%s' "$out$rest"
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
# 公开账本只保留可移植的显示路径。执行仍使用真实绝对路径;这里只净化最终 Markdown,
|
|
120
|
+
# 因而模板字段、锁记录、报告摘录与门禁输出都走同一规则,独立 /var/tmp checkout 不受影响。
|
|
121
|
+
team_review_ledger_display() {
|
|
122
|
+
local line main="${TEAM_MAIN_ROOT%/}" home="${HOME%/}"
|
|
123
|
+
while IFS= read -r line || [ -n "$line" ]; do
|
|
124
|
+
line="$(team_review_ledger_display_root "$line" "$main" '<main-root>')"
|
|
125
|
+
line="$(team_review_ledger_display_root "$line" "$home" '<home>')"
|
|
126
|
+
printf '%s\n' "$line"
|
|
127
|
+
done
|
|
128
|
+
}
|
|
129
|
+
|
|
93
130
|
# 128+n → 信号名(写复验记录用;认不出来就给数字,不编名字)
|
|
94
131
|
team_review_signal_name() { # <signal number> → SIGTERM / SIGKILL / SIG<n>
|
|
95
132
|
local n="${1:-}" name=""
|
|
@@ -1027,13 +1064,17 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1027
1064
|
team_ok "已摘录 agent 报告:${branch_report#"$revdir"/}"
|
|
1028
1065
|
done
|
|
1029
1066
|
|
|
1067
|
+
# 门禁准备失败不算一次复验:不取锁,也不改旧记录或日志。
|
|
1068
|
+
if [ "$no_gates" = "0" ] && [ -n "$TEAM_GATES" ]; then
|
|
1069
|
+
team_tmp_root_prepare || return 1
|
|
1070
|
+
fi
|
|
1030
1071
|
mkdir -p "$TEAM_DOCS_ABS/reviews"
|
|
1031
1072
|
local log="$TEAM_DOCS_ABS/reviews/$id-verify.log"
|
|
1032
1073
|
local verdict="PASS" gates_out="" gate_timeout="${TEAM_REVIEW_TIMEOUT:-1800}" gates_marker="ran"
|
|
1033
1074
|
local gate_elapsed="" gate_signal="" # 门禁实际用时 / 被信号终止的信号名(写进复验记录)
|
|
1034
|
-
# G1(P26):门禁锁的排队阶段与记账。queue_state: none
|
|
1035
|
-
#
|
|
1036
|
-
local queue_state="none"
|
|
1075
|
+
# G1(P26):门禁锁的排队阶段与记账。queue_state: none(不执行门禁)/ held(祖先持有)/
|
|
1076
|
+
# queued(本次自己排队)/ noqueue(无法取锁,降级)/ broken(入场互斥检查拒绝)。
|
|
1077
|
+
local queue_state="none" queued_elapsed="" queue_holder="" used_lock="" lock_cap=""
|
|
1037
1078
|
local lock_note=""
|
|
1038
1079
|
if [ "$no_gates" = "1" ]; then
|
|
1039
1080
|
verdict="SKIPPED"; gates_marker="none"
|
|
@@ -1092,7 +1133,7 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1092
1133
|
local lock; lock="$(gate_lock_default_path)"
|
|
1093
1134
|
local lock_comp; lock_comp="$(gate_lock_companion_path "$lock")"
|
|
1094
1135
|
local lock_dev_ino="" lock_cap_hit=0 lock_broken="" gate_rc=0
|
|
1095
|
-
local queue_started
|
|
1136
|
+
local queue_started
|
|
1096
1137
|
# P281:排队上限不再是「一律 W」——它跟着**持有者的心跳**(change: gate-waiter-patience · P338):
|
|
1097
1138
|
# 心跳还在动(任一活登记公布的心跳文件 < W 秒前更新)→ 4×W(硬顶);
|
|
1098
1139
|
# 心跳停了 / 没有可用心跳(旧记录、`heartbeat=-`、文件不在)→ W(与今天一字不改)。
|
|
@@ -1104,8 +1145,6 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1104
1145
|
lock_wait="$lock_cap"
|
|
1105
1146
|
queue_started="$(date +%s)"
|
|
1106
1147
|
local lock_record_written=0
|
|
1107
|
-
team_tmp_root_prepare >/dev/null 2>&1 || true
|
|
1108
|
-
queue_marker="$(mktemp "$(team_tmp_root)/teamsmith-review-queue.$(team_project_ns).XXXXXX" 2>/dev/null || true)"
|
|
1109
1148
|
queue_holder="$(gate_lock_describe_pair "$lock")"
|
|
1110
1149
|
# P310:祖先持锁的判据 = **进程树 + starttime 的证明**(不是环境里一个可继承的标记)
|
|
1111
1150
|
local lock_ancestor=""
|
|
@@ -1121,8 +1160,7 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1121
1160
|
team_warn "锁文件 $lock 建不了 → 门禁排队未启用(并发两套门禁时可能互相干扰)"
|
|
1122
1161
|
else
|
|
1123
1162
|
queue_state="queued"
|
|
1124
|
-
# 有界轮询取**两把**锁(P287
|
|
1125
|
-
# (与 flock 包装器同形):没写 = 这套没跑起来(排队被上限掐掉 / 取锁起不来)。
|
|
1163
|
+
# 有界轮询取**两把**锁(P287);排队到取锁成功或等满上限为止。
|
|
1126
1164
|
local lock_probe=0 lock_reported=0 lock_waited_path="" lock_waited_id="" lock_probe_id=""
|
|
1127
1165
|
local lock_role=""
|
|
1128
1166
|
while :; do
|
|
@@ -1162,6 +1200,10 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1162
1200
|
fi
|
|
1163
1201
|
sleep 1
|
|
1164
1202
|
done
|
|
1203
|
+
if [ "$queue_state" = "queued" ]; then
|
|
1204
|
+
queued_elapsed=$(( $(date +%s) - queue_started ))
|
|
1205
|
+
[ "$queued_elapsed" -lt 0 ] && queued_elapsed=0
|
|
1206
|
+
fi
|
|
1165
1207
|
if [ "$lock_cap_hit" = "0" ] && [ "$queue_state" = "queued" ]; then
|
|
1166
1208
|
export SMOKE_LOCK_WRAPPED=1
|
|
1167
1209
|
export TEAM_SMOKE_LOCK="$lock"
|
|
@@ -1184,8 +1226,6 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1184
1226
|
else
|
|
1185
1227
|
team_warn "拿到锁了,但 $(gate_lock_holder_file "$lock_comp") 里的持有记录是**另一个活着的进程**($(gate_lock_describe_one "$(gate_lock_holder_file "$lock_comp")"))→ 不覆写它"
|
|
1186
1228
|
fi
|
|
1187
|
-
# marker:真的拿到锁、接下来跑门禁(P66 语义;`<epoch> <pid>` 与 smoke.sh 同形)
|
|
1188
|
-
printf '%s %s\n' "$(date +%s)" "$$" > "$queue_marker" 2>/dev/null || true
|
|
1189
1229
|
# 入场检查(P287 §4.2):活的 top 登记记着另一个身份 ⇒ 互斥已断 ⇒ 不跑门禁
|
|
1190
1230
|
local entry_chain entry_msg
|
|
1191
1231
|
entry_chain="$(gate_lock_ancestry_chain "$$" | tr '\n' ' ')"
|
|
@@ -1193,7 +1233,6 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1193
1233
|
if [ -n "$entry_msg" ]; then
|
|
1194
1234
|
lock_broken="入场检查:$entry_msg"
|
|
1195
1235
|
team_err "入场检查:$entry_msg → 本次**不跑门禁**(互斥已经断了;这不是对代码的判定)"
|
|
1196
|
-
: > "$queue_marker" 2>/dev/null || true # marker 清空 = 这套没有跑起来(与排队超限同形)
|
|
1197
1236
|
gate_rc=2
|
|
1198
1237
|
fi
|
|
1199
1238
|
fi
|
|
@@ -1221,7 +1260,10 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1221
1260
|
: > "$log"
|
|
1222
1261
|
[ -n "$lock_broken" ] && queue_state="broken"
|
|
1223
1262
|
else
|
|
1263
|
+
# 只量实际命令,不把入场检查、排队或锁的收尾算进硬超时证据。
|
|
1264
|
+
gate_started="$(date +%s)"
|
|
1224
1265
|
( cd "$revdir" && "${gate_cmd[@]}" 8>&- 9>&- ) > "$log" 2>&1 < /dev/null || gate_rc=$?
|
|
1266
|
+
gate_elapsed=$(( $(date +%s) - gate_started ))
|
|
1225
1267
|
fi
|
|
1226
1268
|
# P287:收尾只删**自己**写的持有者记录(锁文件永不 unlink;别人的活记录绝不碰)——
|
|
1227
1269
|
# 留下一条陈旧记录会把后来者的排队上限与点名带偏(34②/34⑦ 实测过)。
|
|
@@ -1229,36 +1271,19 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1229
1271
|
gate_lock_remove_holder "$lock_comp"
|
|
1230
1272
|
rmdir "$lock_comp.runs" 2>/dev/null || true
|
|
1231
1273
|
fi
|
|
1232
|
-
|
|
1233
|
-
if [ -n "$queue_marker" ] && [ -s "$queue_marker" ]; then
|
|
1234
|
-
marker_epoch="$(cat "$queue_marker" 2>/dev/null)"
|
|
1235
|
-
# P281:marker 现在是 `<epoch> <pid>`(与 smoke.sh 同一约定)—— 只取第一个字段当时刻
|
|
1236
|
-
marker_epoch="${marker_epoch%% *}"
|
|
1237
|
-
case "$marker_epoch" in ''|*[!0-9]*) marker_epoch="$(date +%s)" ;; esac
|
|
1238
|
-
queued_elapsed=$(( marker_epoch - queue_started ))
|
|
1239
|
-
[ "$queued_elapsed" -lt 0 ] && queued_elapsed=0
|
|
1240
|
-
gate_elapsed=$(( gate_end - marker_epoch ))
|
|
1241
|
-
else
|
|
1242
|
-
gate_elapsed=$(( gate_end - queue_started ))
|
|
1243
|
-
fi
|
|
1244
|
-
# 排队超上限:flock 没拿到锁(没有 marker)→ 门禁**没有运行**。判定 FAIL 而不是 TIMEOUT:
|
|
1245
|
-
# 「没跑」和「跑了被杀」必须能分开(记录里点名持锁者与上限)。
|
|
1274
|
+
# 只有等待循环确实等满上限才记 queuecap;未运行的路径不填写运行用时。
|
|
1246
1275
|
if [ "$queue_state" = "broken" ]; then
|
|
1247
1276
|
verdict="FAIL"
|
|
1248
1277
|
gates_marker="mutexbroken"
|
|
1249
1278
|
queue_holder="$(gate_lock_describe_pair "$lock")"
|
|
1250
1279
|
gates_out="(互斥已断:**门禁没有运行**。${lock_broken}。实际持有者(读伴生锁边上的记录):${queue_holder}。这不是对代码的判定 —— 等那个运行结束后重跑。)"
|
|
1251
|
-
gate_elapsed=""
|
|
1252
1280
|
used_timeout=0
|
|
1253
1281
|
used_lock="$lock"
|
|
1254
|
-
elif [ "$
|
|
1282
|
+
elif [ "$lock_cap_hit" = "1" ]; then
|
|
1255
1283
|
verdict="FAIL"
|
|
1256
1284
|
gates_marker="queuecap"
|
|
1257
|
-
queued_elapsed=$(( gate_end - queue_started ))
|
|
1258
|
-
[ "$queued_elapsed" -lt 0 ] && queued_elapsed=0
|
|
1259
1285
|
queue_holder="$(gate_lock_describe_pair "$lock")" # 撞上限时**重读**:等的这段时间持有者可能换了
|
|
1260
1286
|
gates_out="(门禁锁排队超过上限 ${lock_cap}s:**门禁没有运行**。持锁者:${queue_holder}。${lock_note}这不是对代码的判定 —— 等持锁者结束,或抬 TEAM_SMOKE_LOCK_WAIT 后重跑。)"
|
|
1261
|
-
gate_elapsed=""
|
|
1262
1287
|
used_timeout=0
|
|
1263
1288
|
used_lock="$lock"
|
|
1264
1289
|
team_err "门禁锁排队超过上限 ${lock_cap}s → 门禁没有运行(持锁者:${queue_holder};${lock_note})"
|
|
@@ -1349,11 +1374,13 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1349
1374
|
[ "$gates_marker" = "mutexbroken" ] && head_flags="$head_flags · gate mutex broken(互斥被破坏:判定不可信)"
|
|
1350
1375
|
# 被信号终止(不是超时):把信号名写进抬头,别拿「超时」顶替「被杀」(M6.5 / F15)
|
|
1351
1376
|
[ -n "$gate_signal" ] && head_flags="$head_flags · gate killed: $gate_signal"
|
|
1377
|
+
local executor; executor="$(team_sender_from_dir)"; [ -n "$executor" ] || executor="unknown"
|
|
1352
1378
|
{
|
|
1353
|
-
printf '# %s ·
|
|
1379
|
+
printf '# %s · 独立复验\n\n' "$id"
|
|
1354
1380
|
printf '时间: %s · 分支: `%s` · HEAD: `%s` · 判定: **%s**%s\n\n' "$(team_timestamp)" "$branch" "${head:0:9}" "$verdict" "$head_flags"
|
|
1355
1381
|
printf '## 复验方式\n\n'
|
|
1356
|
-
printf -- '-
|
|
1382
|
+
printf -- '- 实际执行者:`%s`(从调用者的运行时工作树身份解析;与 checkout 准备者、实现作者及 PM 接受分开)\n' "$executor"
|
|
1383
|
+
printf -- '- 独立 checkout:`%s`(PM 准备;被验内容只读,不信任 agent 工作区)\n' "$revdir"
|
|
1357
1384
|
printf -- '- 记录绑定:本判定只对上面的 HEAD `%s` 负责(分支再动一格,digest/status 会把它重新列为待复验)\n' "${head:0:9}"
|
|
1358
1385
|
printf -- '- 门禁命令:`%s`(硬超时 %ss%s;TIMEOUT 需要「包装器 124/137 + 用时贴住 deadline」两条证据,按失败处理)\n' \
|
|
1359
1386
|
"${TEAM_GATES:-<未配置>}" "${TEAM_REVIEW_TIMEOUT:-1800}" "${gate_elapsed:+,实际用时 ${gate_elapsed}s}"
|
|
@@ -1434,7 +1461,7 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1434
1461
|
else
|
|
1435
1462
|
printf '## agent 报告原文\n\n**缺失**:分支上没有 `%s/reports/%s-<agent>.md`,这本身就是问题。\n\n' "$TEAM_DOCS_DIR" "$id"
|
|
1436
1463
|
fi
|
|
1437
|
-
printf '## PM
|
|
1464
|
+
printf '## PM 接受清单(由 PM 审阅填写;不代表 PM 执行了上述门禁)\n\n'
|
|
1438
1465
|
case "$verdict" in
|
|
1439
1466
|
PASS) printf -- '- [ ] 已读 diff,与任务书交付物一致\n- [ ] 未发现「报告与实际不符」\n- [ ] 可以合并:squash 到 `%s` 并 push 之后,再 `%s board set %s done`\n' "$TEAM_PROTECTED_BRANCH" "$TEAM_CLI" "$id" ;;
|
|
1440
1467
|
FAIL) printf -- '- [ ] 门禁失败:退回 agent(`%s say <agent> "..."`)或 PM 自行修复\n' "$TEAM_CLI"
|
|
@@ -1447,9 +1474,8 @@ $(printf '%s\n' "$ignored_list" | head -5)
|
|
|
1447
1474
|
TIMEOUT) printf -- '- [ ] 门禁被硬超时终止(TIMEOUT→按失败处理):查门禁自己为何挂死,或调 `TEAM_REVIEW_TIMEOUT` 后重跑\n' ;;
|
|
1448
1475
|
*) printf -- '- [ ] 人工评审(门禁未跑/未配置:这不等于通过,digest 会继续把它列为待复验)\n' ;;
|
|
1449
1476
|
esac
|
|
1450
|
-
} > "$report"
|
|
1477
|
+
} | team_review_ledger_display > "$report"
|
|
1451
1478
|
team_scan_invalidate review # M50:同进程里「写完再读」必须读到新记录
|
|
1452
|
-
[ -n "$queue_marker" ] && rm -f "$queue_marker" 2>/dev/null
|
|
1453
1479
|
team_ok "复验记录:${report#"$TEAM_MAIN_ROOT"/}($verdict)"
|
|
1454
1480
|
|
|
1455
1481
|
case "$verdict" in FAIL|TIMEOUT) return 1 ;; esac
|
|
@@ -731,10 +731,27 @@ team_cmd_watch() {
|
|
|
731
731
|
|
|
732
732
|
team_require_cmd tmux "pulse 需要 tmux 来拉起 PM/agent"
|
|
733
733
|
team_watch_lock || return 1
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
734
|
+
local patrol_pid='' recovery_pid='' sleep_pid='' recovery_pending=0 recovery_seen=''
|
|
735
|
+
team_watch_loop_alive() { # <pid>:kill -0 对等待 wait 的僵尸仍为真,不能拿它当“还在跑”
|
|
736
|
+
local stat; stat="$(ps -o stat= -p "$1" 2>/dev/null | tr -d '[:space:]')"
|
|
737
|
+
[ -n "$stat" ] && [[ "$stat" != Z* ]]
|
|
738
|
+
}
|
|
739
|
+
team_watch_loop_cleanup() {
|
|
740
|
+
local pid child
|
|
741
|
+
for pid in "$patrol_pid" "$recovery_pid" "$sleep_pid"; do
|
|
742
|
+
[ -n "$pid" ] || continue
|
|
743
|
+
# The patrol/recovery is a shell child; stop its current external command too (for example a
|
|
744
|
+
# patrol sleep), then wait for the direct child. A process that already exited is expected here.
|
|
745
|
+
for child in $(ps -o pid= --ppid "$pid" 2>/dev/null); do
|
|
746
|
+
kill "$child" 2>/dev/null || true # 留:外部命令可能已先退出;仍须继续回收其余子进程
|
|
747
|
+
done
|
|
748
|
+
kill "$pid" 2>/dev/null || true # 留:登记的子进程可能已先退出;继续解锁
|
|
749
|
+
wait "$pid" 2>/dev/null || true # 留:被 TERM 的子进程 wait 返回 143(或已被回收),这不是清理失败
|
|
750
|
+
done
|
|
751
|
+
team_watch_unlock
|
|
752
|
+
}
|
|
753
|
+
trap 'team_watch_loop_cleanup' EXIT
|
|
754
|
+
# INT/TERM 必须立刻生效:sleep 放后台 + wait(被捕获的信号会立刻打断 wait),handler 里 exit 走 EXIT trap。
|
|
738
755
|
trap 'exit 130' INT
|
|
739
756
|
trap 'exit 143' TERM
|
|
740
757
|
fp0="$(team_watch_code_fp)"
|
|
@@ -748,15 +765,35 @@ team_cmd_watch() {
|
|
|
748
765
|
case "$slice" in ''|*[!0-9]*|0) slice=10 ;; esac
|
|
749
766
|
pulse_started="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
750
767
|
while :; do
|
|
751
|
-
|
|
768
|
+
# Reap first: a finished child must never look like an in-flight reason to skip the coalesced recheck.
|
|
769
|
+
if [ -n "$patrol_pid" ] && ! team_watch_loop_alive "$patrol_pid"; then
|
|
770
|
+
wait "$patrol_pid"; patrol_pid=''; next_patrol=$(( $(date +%s) + interval )); recovery_seen=''
|
|
771
|
+
fi
|
|
772
|
+
if [ -n "$recovery_pid" ] && ! team_watch_loop_alive "$recovery_pid"; then
|
|
773
|
+
wait "$recovery_pid"; recovery_pid=''
|
|
774
|
+
fi
|
|
775
|
+
|
|
776
|
+
# The lightweight child is synchronous and independent of the long patrol below. Queueing can
|
|
777
|
+
# therefore commit during that patrol; one bit coalesces every recovery need until it ends.
|
|
752
778
|
team_remind_due_tick "$pulse_started"
|
|
753
|
-
if [ "$
|
|
779
|
+
if [ "${TEAM_REMIND_RECOVERY_REQUIRED:-0}" = "1" ] && [ "${TEAM_REMIND_RECOVERY_SIGNATURE:-}" != "$recovery_seen" ]; then
|
|
780
|
+
recovery_pending=1
|
|
781
|
+
fi
|
|
782
|
+
|
|
783
|
+
# A due ordinary patrol goes first; recovery runs in the gap after it. Without this priority a
|
|
784
|
+
# permanently refused recovery would consume every free slot and starve the ordinary patrol.
|
|
785
|
+
now="$(date +%s)"
|
|
786
|
+
if [ "$now" -ge "$next_patrol" ] && [ -z "$patrol_pid" ] && [ -z "$recovery_pid" ]; then
|
|
754
787
|
# M9.8:判定必须用磁盘上的代码(漂移就重启本进程)—— 否则唤醒理由可能比 digest 旧
|
|
755
788
|
team_watch_reexec_if_stale "$fp0" watch ${argv[@]+"${argv[@]}"}
|
|
756
|
-
team_watch_once
|
|
757
|
-
|
|
789
|
+
team_watch_once & patrol_pid=$!
|
|
790
|
+
fi
|
|
791
|
+
if [ -z "$patrol_pid" ] && [ -z "$recovery_pid" ] && [ "$recovery_pending" = "1" ]; then
|
|
792
|
+
recovery_pending=0; recovery_seen="${TEAM_REMIND_RECOVERY_SIGNATURE:-}"
|
|
793
|
+
team_remind_recovery "$pulse_started" & recovery_pid=$!
|
|
758
794
|
fi
|
|
759
|
-
sleep "$slice" &
|
|
795
|
+
sleep "$slice" & sleep_pid=$!
|
|
796
|
+
wait "$sleep_pid"; sleep_pid=''
|
|
760
797
|
done
|
|
761
798
|
}
|
|
762
799
|
|
|
@@ -1463,8 +1500,8 @@ team_panel_detail_rel() { # <绝对路径> → 相对 main root(不在 root
|
|
|
1463
1500
|
}
|
|
1464
1501
|
|
|
1465
1502
|
# ---- 详情读路径的落点判据(P424)---------------------------------------------------------
|
|
1466
|
-
# 软链不再按「路径上任一段是软链」一律拒绝:项目内的软链是用户自己的账本摆放(例如
|
|
1467
|
-
# `docs/team →
|
|
1503
|
+
# 软链不再按「路径上任一段是软链」一律拒绝:项目内的软链是用户自己的账本摆放(例如
|
|
1504
|
+
# `docs/team → module/docs/team`),读它没有越界风险。越界的定义是**解析后的落点**:
|
|
1468
1505
|
# * 落点在边界内(允许根在项目内时 = 项目根的物理路径)→ 可读,并把经过的软链段如实报给详情块;
|
|
1469
1506
|
# * 落点在边界外 → 拒绝,点名「真实落点」与边界(不再只报「哪一段是软链」);
|
|
1470
1507
|
# * 允许根**在项目外**(绝对路径的 TEAM_DOCS_DIR / TEAM_SPEC_DIR)时没有更外层的可信锚点 ——
|