teamsmith 0.3.4 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +8 -8
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +40 -0
  4. package/skills/teamsmith/SKILL.md +83 -163
  5. package/skills/teamsmith/extension/team-notify.ts +1 -1
  6. package/skills/teamsmith/extension/team-reply.ts +105 -0
  7. package/skills/teamsmith/references/agent-adapters.md +1 -1
  8. package/skills/teamsmith/references/config.md +20 -11
  9. package/skills/teamsmith/references/migration.md +47 -3
  10. package/skills/teamsmith/references/protocol.md +64 -31
  11. package/skills/teamsmith/references/reminders.md +131 -0
  12. package/skills/teamsmith/references/troubleshooting.md +19 -5
  13. package/skills/teamsmith/references/workflows.md +18 -16
  14. package/skills/teamsmith/scripts/lib/cmd-agents.sh +77 -49
  15. package/skills/teamsmith/scripts/lib/cmd-project.sh +193 -21
  16. package/skills/teamsmith/scripts/lib/cmd-remind.sh +103 -0
  17. package/skills/teamsmith/scripts/lib/cmd-update.sh +7 -4
  18. package/skills/teamsmith/scripts/lib/common.sh +44 -4
  19. package/skills/teamsmith/scripts/lib/outbox.sh +72 -18
  20. package/skills/teamsmith/scripts/remind-store.mjs +529 -0
  21. package/skills/teamsmith/scripts/replies.mjs +9 -3
  22. package/skills/teamsmith/scripts/reply-capture.mjs +612 -0
  23. package/skills/teamsmith/scripts/state-authority.mjs +500 -0
  24. package/skills/teamsmith/scripts/strings/commands.tsv +2 -1
  25. package/skills/teamsmith/scripts/strings/help.en.tsv +16 -2
  26. package/skills/teamsmith/scripts/strings/help.zh.tsv +16 -2
  27. package/skills/teamsmith/scripts/team +1 -0
  28. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +68 -123
  29. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +48 -55
  30. package/skills/teamsmith/templates/pm-prompt.md.tmpl +126 -119
  31. package/skills/teamsmith/tests/checkout-shape-probe.sh +6 -5
  32. package/skills/teamsmith/tests/delivery-truth.sh +82 -47
  33. package/skills/teamsmith/tests/fixtures/delivery-truth-real/README.md +71 -23
  34. package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
  35. package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-dirty-ab.py +143 -0
  36. package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py +26 -9
  37. package/skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh +92 -20
  38. package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +47 -3
  39. package/skills/teamsmith/tests/fixtures/reply-capture-provider.ts +76 -0
  40. package/skills/teamsmith/tests/flip-p410-order2.sh +205 -0
  41. package/skills/teamsmith/tests/frames/README.md +3 -1
  42. package/skills/teamsmith/tests/gate-guard.sh +20 -4
  43. package/skills/teamsmith/tests/help-surface.sh +60 -2
  44. package/skills/teamsmith/tests/install-shape.sh +312 -0
  45. package/skills/teamsmith/tests/key-replies-pty.sh +197 -21
  46. package/skills/teamsmith/tests/key-replies.sh +187 -68
  47. package/skills/teamsmith/tests/ledger-claim.sh +8 -6
  48. package/skills/teamsmith/tests/lib/box-judge.sh +2 -1
  49. package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +104 -0
  50. package/skills/teamsmith/tests/lib/pm-window.sh +143 -0
  51. package/skills/teamsmith/tests/lib/reply-fixture.sh +7 -19
  52. package/skills/teamsmith/tests/lib/reply-guard.sh +188 -0
  53. package/skills/teamsmith/tests/lib/section-calls.pl +171 -0
  54. package/skills/teamsmith/tests/loop-inventory.tsv +7 -5
  55. package/skills/teamsmith/tests/meta-suite.sh +215 -0
  56. package/skills/teamsmith/tests/panel-b3-pty-mouse.py +154 -17
  57. package/skills/teamsmith/tests/panel-b3.sh +33 -4
  58. package/skills/teamsmith/tests/remind-cli.sh +574 -0
  59. package/skills/teamsmith/tests/reply-capture-real.mjs +360 -0
  60. package/skills/teamsmith/tests/reply-capture-real.sh +5 -0
  61. package/skills/teamsmith/tests/reply-capture.mjs +756 -0
  62. package/skills/teamsmith/tests/section-paths.tsv +40 -9
  63. package/skills/teamsmith/tests/section-select.sh +180 -26
  64. package/skills/teamsmith/tests/smoke.sh +1235 -238
  65. package/skills/teamsmith/tests/state-authority-node.mjs +42 -0
  66. package/skills/teamsmith/tests/state-authority.sh +629 -0
  67. package/skills/teamsmith/tests/workflow-entry.sh +123 -3
  68. package/skills/teamsmith-init/SKILL.md +1 -1
@@ -16,12 +16,14 @@
16
16
  # workflow 指引:fixture Agent 在五种结果后仍发同一正文、回执 body-free、账本不变(4.1)
17
17
  # flip 坏源码→红→还原→绿:九条具名 guard 的独立 scratch 源码 + 哈希(2.4)
18
18
  # skip-path 缺观测器(/proc/<pid>/io)时可见跳过并点名,而不是判红(V27 M3)
19
+ # capture marker parser/source/CAS/crash 及私有真 Pi 注入、终稿和依赖 reload(P396)
19
20
  # guide 指引面:PM 提示词/协议/命令表三处纪律在场 + 示例命令对拍真解析器 + 四变异红侧(change: pm-reply-discipline · P267)
20
21
  #
21
- # 隔离(M7.2 的纪律):夹具只在临时根里的私有仓库跑真 CLI;进入任何写盘命令前先断言
22
- # `team paths` 的 main_root 等于夹具仓库(不是真实仓库);跑完断言真实仓库的 docs/team/inbox
23
- # 与 .pi/team/state 逐字节不变。TEAM_REPLY_EVIDENCE=<dir> 时导出原始日志/IO trace/命令台账
24
- # (测试旋钮,不是产品配置)。
22
+ # 隔离(M7.2 的纪律,P399 收窄了比对范围):夹具只在临时根里的私有仓库跑真 CLI;进入任何写盘命令前先断言
23
+ # `team paths` 的 main_root 等于夹具仓库(不是真实仓库);跑完断言真实仓库的**编号回复存储**逐字节不变
24
+ # (`.pi/team/state/key-replies/**`,见 tests/lib/reply-guard.sh)。inbox 与投递账本是 append-only、
25
+ # 每次回合结束由收尾钩子写,不参与比对(PM 2026-11-02 裁定)。
26
+ # TEAM_REPLY_EVIDENCE=<dir> 时导出原始日志/IO trace/命令台账(测试旋钮,不是产品配置)。
25
27
  #
26
28
  # 退出码:0 全部成立;1 有失败;2 用法/环境错误;3 临时根建不起来。
27
29
  set -uo pipefail
@@ -45,7 +47,7 @@ while [ $# -gt 0 ]; do
45
47
  *) printf 'key-replies.sh:未知参数 %s(-h 看用法)\n' "$1" >&2; exit 2 ;;
46
48
  esac
47
49
  done
48
- KR_ALL_GROUPS=(input paths original concurrency receipts interrupt paging bounded readonly workflow flip skip-path guide)
50
+ KR_ALL_GROUPS=(input paths original concurrency receipts interrupt paging bounded readonly workflow flip skip-path guide capture)
49
51
  if [ "$ALL" = "1" ] && [ "${#KR_GROUPS[@]}" -gt 0 ]; then
50
52
  printf 'key-replies.sh:--all 与 --select 不同用\n' >&2; exit 2
51
53
  fi
@@ -91,26 +93,13 @@ kr_ev_save() { # <文件> <目标名>
91
93
  cp "$1" "$KR_EV/$2" 2>/dev/null || true
92
94
  }
93
95
 
94
- # ---------------------------------------------------------------- 真实仓库守卫(M7.2)
95
- REAL_ROOT="${TEAM_REPLY_REAL_ROOT:-$(cd -P "$SELF_DIR/../../.." && pwd)}"
96
- kr_tree_hash() { # <目录> → 内容 sha256(不存在 → missing)
97
- local d="$1"
98
- if [ ! -e "$d" ]; then printf 'missing\n'; return 0; fi
99
- ( cd "$d" 2>/dev/null && find . -type f -print0 2>/dev/null | sort -z | xargs -0 -r sha256sum 2>/dev/null | sha256sum | cut -d' ' -f1 )
100
- }
101
- REAL_INBOX_BEFORE="$(kr_tree_hash "$REAL_ROOT/docs/team/inbox")"
102
- REAL_STATE_BEFORE="$(kr_tree_hash "$REAL_ROOT/.pi/team/state")"
103
-
104
- kr_real_guard() {
105
- local inbox_after state_after
106
- inbox_after="$(kr_tree_hash "$REAL_ROOT/docs/team/inbox")"
107
- state_after="$(kr_tree_hash "$REAL_ROOT/.pi/team/state")"
108
- if [ "$inbox_after" = "$REAL_INBOX_BEFORE" ] && [ "$state_after" = "$REAL_STATE_BEFORE" ]; then
109
- ok "隔离守卫:真实仓库 $REAL_ROOT 的 inbox/state 前后逐字节不变"
110
- else
111
- bad "隔离守卫:真实仓库被改动了!inbox $REAL_INBOX_BEFORE → $inbox_after | state $REAL_STATE_BEFORE → $state_after"
112
- fi
113
- }
96
+ # ---------------------------------------------------------------- 真实仓库守卫(M7.2 / P399)
97
+ # 比对范围(只有编号回复存储 `state/key-replies/**`)、范围外的理由、以及 P399 要求的两条负对照
98
+ # 都是**一份实现**:tests/lib/reply-guard.sh
99
+ # (key-replies-ui.sh / key-replies-pty.sh 通过 lib/reply-fixture.sh 用的是同一份)。
100
+ # shellcheck source=tests/lib/reply-guard.sh
101
+ . "$SELF_DIR/lib/reply-guard.sh"
102
+ krg_guard_baseline
114
103
 
115
104
  # ---------------------------------------------------------------- 夹具仓库与 CLI
116
105
  KR_SKILL="${KR_SKILL:-$SKILL_DIR}"
@@ -1061,19 +1050,21 @@ kr_group_skip_path() {
1061
1050
  kr_ev_save "$out" "skip-path-bounded-flip.txt"
1062
1051
  }
1063
1052
 
1064
- # ---------------------------------------------------------------- 组:guide(change: pm-reply-discipline · P267;判据面 P301)
1065
- # 纪律要随工具走:三处指令面(注入的 PM 提示词 / 协议的 §4b / SKILL 命令表)各自带着同一套**语义锚点**
1066
- # (大小写不敏感;断言的是「义务在场」,不是逐字措辞),并且各自带着同一条**判据** `written for the user`
1067
- # ——写给用户的回复(回答/汇报/结论/裁定/请示/交付摘要)必须发布,写给巡检/席位/别的项目 PM 的与工具回执不算。
1068
- # 模板里印出来的示例命令必须被**真解析器**接受
1069
- # ——「印出来就能用」是承诺兑现;控制臂(同一 argv 追加未知旗标)必须被拒,否则这个探针是空对空。
1070
- # 五个 $TMP 变异副本必须红并点名被改的面(①②③⑤ 还要点名缺失的判据 token),重新从真树复制后绿。
1071
- # 真树与真项目在这一组里只读。
1053
+ # ---------------------------------------------------------------- 组:guide(change: pi-marker-key-replies · P396;判据面沿用 P267/P301)
1054
+ # 纪律要随工具走:三处指令面(注入的 PM 提示词 / 协议 §4b / SKILL 命令表)各自带着同一套**语义锚点**
1055
+ # (大小写不敏感;断言的是「义务在场」,不是逐字措辞):
1056
+ # · 读者判据 `written for the user`:回答/汇报/结论/裁定/请示/交付摘要写给用户就必须标记;
1057
+ # · 标记约定 `[[team-reply]]` / `[[team-reply:`:普通回答末尾的控制行,由定向 PM 扩展发布;
1058
+ # · `team reply post` 只是 manual/backfill/recovery 入口,任何指令面把它恢复成「先 post 再重复正文」的
1059
+ # 日常默认 → 必须红并点名那个面。
1060
+ # 模板里印出来的标记示例必须被**产品 parser** 认成候选、并由**真 writer** 发布一次(raw body 等于示例去掉
1061
+ # 控制行);示例改坏必须红,不能靠文档里出现同样的文字空对空。手工 CLI 示例仍对拍真解析器(含未知旗标控制臂)。
1062
+ # 所有变异都在 $TMP 副本上;真树与真项目在这一组里只读。
1072
1063
  guide_spec() { # <面名> → 分号分隔的锚点;`row:` 前缀 = 必须落在 SKILL 的 `| Key replies |` 行内
1073
1064
  case "$1" in
1074
- "prompt template") printf '%s' 'conclusion;milestone;ruling;ask the user;--stdin;team reply post;written for the user' ;;
1075
- "protocol reference") printf '%s' 'conclusion;milestone;ruling;ask the user;--stdin;team reply post;No tool can verify;written for the user' ;;
1076
- "command table") printf '%s' 'milestone;ruling;ask the user;row:conclusion;row:say;row:notify;row:--stdin;row:team reply post;row:written for the user' ;;
1065
+ "prompt template") printf '%s' 'conclusion;milestone;ruling;ask the user;written for the user;[[team-reply]];[[team-reply:;team reply post;--stdin;manual' ;;
1066
+ "protocol reference") printf '%s' 'conclusion;milestone;ruling;ask the user;written for the user;[[team-reply]];[[team-reply:;No tool can verify;team reply post;--stdin;manual' ;;
1067
+ "command table") printf '%s' 'milestone;ruling;ask the user;row:conclusion;row:say;row:notify;row:written for the user;row:[[team-reply]];row:team reply post;row:--stdin;row:manual' ;;
1077
1068
  esac
1078
1069
  }
1079
1070
 
@@ -1114,11 +1105,67 @@ guide_check_surface() { # <面名> <文件>:绿=0;红=1 并点名面 + 缺
1114
1105
  fi
1115
1106
  }
1116
1107
 
1117
- guide_example_cmd() { # <模板> → 唯一示例命令(去反引号);次数≠1/形状不全 → rc1 + stderr 说明
1108
+ # 旧默认(先 post 再在会话重复同一正文)不许回来:既查具体旧措辞,也查「team reply post 出现在一个
1109
+ # 没自报 manual/backfill/recovery 的段落里」——后者正是把 CLI 重新写成日常默认的形状。
1110
+ guide_no_post_first() { # <面名> <文件>:绿=0;红=1 并点名面
1111
+ local name="$1" f="$2" phrase out rc blockbad
1112
+ for phrase in 'then send that same body' 'send that same body normally' 'publish the body before you answer' 'go to the reply page first'; do
1113
+ if grep -qiF -- "$phrase" "$f" 2>/dev/null; then
1114
+ bad "guide-default:$name 又出现了「先 post 再回复」的旧默认([$phrase])—— 默认是标记捕获,CLI 只能写成 manual/backfill/recovery"
1115
+ return 1
1116
+ fi
1117
+ done
1118
+ # 段落里出现 `team reply post` 却没自报 manual/backfill/recovery → 又把 CLI 当成日常步骤
1119
+ out="$(awk 'BEGIN { RS = ""; ORS = "\n\n"; found = 0 }
1120
+ { low = tolower($0)
1121
+ if (index(low, "team reply post") && !index(low, "manual") && !index(low, "backfill") && !index(low, "recovery") && !index($0, "人工")) { print $0; found = 1 } }
1122
+ END { exit found ? 1 : 0 }' "$f" 2>/dev/null)"; rc=$?
1123
+ if [ "$rc" != "0" ]; then
1124
+ blockbad="$(printf '%s' "$out" | tr '\n' ' ' | cut -c1-200)"
1125
+ bad "guide-default:$name 把 team reply post 写成默认步骤(所在段落没有 manual/backfill/recovery):[$blockbad]"
1126
+ return 1
1127
+ fi
1128
+ ok "guide-default:$name 没有恢复「先 post 再重复正文」的旧默认(CLI 只作 manual/backfill/recovery)"
1129
+ }
1130
+
1131
+ guide_marker_example() { # <模板> → 打印第一个含标记行的 fenced 代码块(去围栏)
1132
+ awk '
1133
+ BEGIN { inblk = 0; has = 0; buf = "" }
1134
+ /^```/ {
1135
+ if (inblk) { if (has) { printf "%s", buf; exit } ; inblk = 0; has = 0; buf = "" ; next }
1136
+ inblk = 1; buf = ""; has = 0; next
1137
+ }
1138
+ inblk { buf = buf $0 "\n"; if ($0 ~ /\[\[team-reply/) has = 1 }
1139
+ ' "$1"
1140
+ }
1141
+
1142
+ guide_check_marker_example() { # <模板>:绿=0;红=1(产品 parser + 真 writer)
1143
+ local tmpl="$1" ex="$TMP/guide-marker-example.txt" out rc
1144
+ guide_marker_example "$tmpl" >"$ex"
1145
+ if [ ! -s "$ex" ]; then
1146
+ bad "guide-marker:$tmpl 里没有找到受代码保护的标记示例(含 [[team-reply]] 的 fenced 代码块)"
1147
+ return 1
1148
+ fi
1149
+ if ! tail -1 "$ex" | grep -qE '^\[\[team-reply(:[^]]*)?\]\]$'; then
1150
+ bad "guide-marker:提取到的标记示例末行不是完整的控制行([$(tail -1 "$ex" | cut -c1-80)])"
1151
+ return 1
1152
+ fi
1153
+ out="$(TEST_EXAMPLE_FILE="$ex" node "$SELF_DIR/reply-capture.mjs" --select example 2>&1)"; rc=$?
1154
+ printf '%s\n' "$out" >"$TMP/guide-marker.log"
1155
+ kr_ev_save "$TMP/guide-marker.log" guide-marker-example.log
1156
+ if [ "$rc" = "0" ]; then
1157
+ ok "guide-marker:印出来的标记示例被产品 parser 认成候选并由真 writer 保存一次($(printf '%s' "$out" | grep -m1 'PASS shipped' | cut -c1-160))"
1158
+ else
1159
+ bad "guide-marker:印出来的标记示例没有走通 parser/真 writer(rc=$rc,[$(printf '%s' "$out" | grep -m1 'FAIL example' | cut -c1-240);尾部:$(printf '%s' "$out" | tail -2 | tr '\n' '|' | cut -c1-160)])"
1160
+ fi
1161
+ return "$rc"
1162
+ }
1163
+
1164
+ guide_example_cmd() { # <模板> → 唯一的手工 CLI 示例(去反引号);次数≠1/形状不全 → rc1 + stderr 说明
1118
1165
  local tmpl="$1" n cmd
1119
1166
  n="$(grep -c -- 'team reply post' "$tmpl" 2>/dev/null || true)"
1120
1167
  if [ "${n:-0}" != "1" ]; then
1121
- printf '模板里 team reply post 出现 %s 次(示例命令必须是唯一一行)' "${n:-0}" >&2
1168
+ printf '模板里 team reply post 出现 %s 次(手工示例必须是唯一一行,不能是默认步骤)' "${n:-0}" >&2
1122
1169
  return 1
1123
1170
  fi
1124
1171
  cmd="$(grep -o 'team reply post[^`]*' "$tmpl" 2>/dev/null | head -1 | sed 's/[[:space:]]*$//')"
@@ -1126,14 +1173,10 @@ guide_example_cmd() { # <模板> → 唯一示例命令(去反引号);次
1126
1173
  printf '示例命令里没有 --stdin(取到 [%s])' "$cmd" >&2
1127
1174
  return 1
1128
1175
  fi
1129
- case "$cmd" in
1130
- *'< '*) ;;
1131
- *) printf '示例命令没有用 < <file> 把正文从文件重定向进来(取到 [%s])' "$cmd" >&2; return 1 ;;
1132
- esac
1133
1176
  printf '%s\n' "$cmd"
1134
1177
  }
1135
1178
 
1136
- guide_run_example() { # <夹具项目> <旗标文本(印刷原样,去掉重定向)> <正文文件> —— 行首 team 解析为真 CLI
1179
+ guide_run_example() { # <夹具项目> <旗标文本(印刷原样)> <正文文件> —— 行首 team 解析为真 CLI
1137
1180
  local p="$1" flags="$2" f="$3"
1138
1181
  ( cd "$p" && env "${KR_CLEAN[@]:1}" bash -c 'eval "bash \"$1\" --root \"$2\" $3 < \"$4\""' _ "$KR_TEAM" "$p" "$flags" "$f" )
1139
1182
  }
@@ -1145,8 +1188,8 @@ guide_check_example() { # <模板> <夹具项目>:绿=0;红=1(文案里点
1145
1188
  bad "guide-example:example command 在 $tmpl 里取不到可执行的样例($(head -c 160 "$TMP/guide-example.err" 2>/dev/null))"
1146
1189
  return 1
1147
1190
  fi
1148
- rest="${cmd#team }"; flags="${rest%% < *}" # 在重定向前的 ` < ` 处截断(题目的 `<short title>` 里没有这个分隔)
1149
- if [ "$flags" = "$rest" ] || ! printf '%s' "$flags" | grep -q -- '--stdin'; then
1191
+ rest="${cmd#team }"; flags="$rest"
1192
+ if ! printf '%s' "$flags" | grep -q -- '--stdin'; then
1150
1193
  bad "guide-example:example command 的旗标部分取不到(取到 [$(printf '%s' "$flags" | head -c 120)])"
1151
1194
  return 1
1152
1195
  fi
@@ -1157,17 +1200,17 @@ guide_check_example() { # <模板> <夹具项目>:绿=0;红=1(文案里点
1157
1200
  out="$(guide_run_example "$p" "$flags" "$body" 2>&1)"; rc=$?
1158
1201
  after="$(kr_cli "$p" reply list --json 2>/dev/null | jget /dev/stdin 'd["total_slots"]')"
1159
1202
  if [ "$rc" = "0" ]; then
1160
- ok "guide-example:示例命令被真解析器接受(rc=0,$cmd)"
1203
+ ok "guide-example:example command 被真解析器接受(rc=0,$cmd)"
1161
1204
  else
1162
1205
  bad "guide-example:example command 被真解析器拒绝(rc=$rc,输出 [$(printf '%s' "$out" | head -c 160)])"; red=1
1163
1206
  fi
1164
1207
  if jok "$out" 'd["outcome"]=="saved"'; then
1165
- ok "guide-example:示例命令的回执 outcome=saved(no=$(jget "$out" 'd.get("no")'))"
1208
+ ok "guide-example:example command 的回执 outcome=saved(no=$(jget "$out" 'd.get("no")'))"
1166
1209
  else
1167
1210
  bad "guide-example:example command 的回执不是 saved(rc=$rc,输出 [$(printf '%s' "$out" | head -c 160)])"; red=1
1168
1211
  fi
1169
1212
  if [ "${after:-x}" = "$(( ${before:-0} + 1 ))" ]; then
1170
- ok "guide-example:示例命令真的发布了一条(槽位 ${before:-?} → ${after:-?})"
1213
+ ok "guide-example:example command 真的发布了一条(槽位 ${before:-?} → ${after:-?})"
1171
1214
  else
1172
1215
  bad "guide-example:example command 发布后槽位不是 +1(${before:-?} → ${after:-?})"; red=1
1173
1216
  fi
@@ -1192,22 +1235,36 @@ guide_check_example() { # <模板> <夹具项目>:绿=0;红=1(文案里点
1192
1235
  }
1193
1236
 
1194
1237
  kr_group_guide() {
1195
- section "guide · 三处表面的纪律 + 按读者判据 + 示例命令对拍 + 五变异(change: pm-reply-discipline · P267 / P301)"
1238
+ section "guide · 三处表面的标记纪律 + 旧默认红侧 + 示例对拍 + 变异(change: pi-marker-key-replies · P396)"
1196
1239
  local TMPL PROTO SKILLMD pex mut MUTD out rc
1197
1240
  TMPL="$(guide_surface_path "prompt template")"
1198
1241
  PROTO="$(guide_surface_path "protocol reference")"
1199
1242
  SKILLMD="$(guide_surface_path "command table")"
1243
+ local have_node=0
1244
+ command -v node >/dev/null 2>&1 && have_node=1
1200
1245
 
1201
1246
  # ---- guide-surfaces:真树的三处表面各自带着自己的锚点(缺哪个点名哪个面)
1202
1247
  guide_check_surface "prompt template" "$TMPL"
1203
1248
  guide_check_surface "protocol reference" "$PROTO"
1204
1249
  guide_check_surface "command table" "$SKILLMD"
1205
1250
 
1206
- # ---- guide-example:印出来的示例命令必须被真解析器接受(真 CLI、私有夹具、重定向指向夹具正文)
1251
+ # ---- guide-default:旧默认(先 post 再重复正文)不许回来
1252
+ guide_no_post_first "prompt template" "$TMPL"
1253
+ guide_no_post_first "protocol reference" "$PROTO"
1254
+ guide_no_post_first "command table" "$SKILLMD"
1255
+
1256
+ # ---- guide-marker:印出来的标记示例走产品 parser + 真 writer(缺 node 时可见跳过,不静默通过)
1257
+ if [ "$have_node" = "1" ]; then
1258
+ guide_check_marker_example "$TMPL"
1259
+ else
1260
+ skip "guide-marker:缺 node,印出来的标记示例未跑(产品 parser/真 writer 对拍跳过)"
1261
+ fi
1262
+
1263
+ # ---- guide-example:印出来的手工 CLI 示例必须被真解析器接受(真 CLI、私有夹具)
1207
1264
  pex="$(kr_new_proj "guide-example")"
1208
1265
  guide_check_example "$TMPL" "$pex"
1209
1266
 
1210
- # ---- guide-flip:四个 $TMP 变异副本,每次必须红并点名被改的面;还原(重新从真树复制)后绿
1267
+ # ---- guide-flip:$TMP 变异副本,每次必须红并点名被改的面;还原(重新从真树复制)后绿
1211
1268
  MUTD="$TMP/guide-mut"; rm -rf "$MUTD"; mkdir -p "$MUTD"
1212
1269
 
1213
1270
  guide_flip_red() { # <标签> <期望点名的面> <rc> <断言文本>
@@ -1239,9 +1296,9 @@ kr_group_guide() {
1239
1296
  kr_ev_save "$TMP/guide-flip.out" "$1"
1240
1297
  }
1241
1298
 
1242
- # ① 模板:删掉持有 `Key conclusions` 锚点的整段 → 红并点名 prompt template
1299
+ # ① 模板:删掉整段「Key conclusions」纪律(含其示例与尾巴)→ 红并点名 prompt template
1243
1300
  mut="$MUTD/pm-prompt.md.tmpl"; cp -f "$TMPL" "$mut"
1244
- awk 'BEGIN{RS="";ORS="\n\n"} !index($0,"Key conclusions") {print}' "$mut" >"$mut.tmp" && mv "$mut.tmp" "$mut"
1301
+ awk '/^\*\*Key conclusions/ { skip = 1 } /^## First moves/ { skip = 0 } !skip' "$TMPL" >"$mut"
1245
1302
  if grep -qF -- 'Key conclusions' "$mut"; then bad "guide-flip/①:变异没应用上(Key conclusions 段还在)"; fi
1246
1303
  out="$(guide_check_surface "prompt template" "$mut" 2>&1)"; rc=$?
1247
1304
  guide_flip_red "①" "prompt template" "$rc" "$out"
@@ -1263,10 +1320,10 @@ kr_group_guide() {
1263
1320
  if [ "$rc" = "0" ]; then ok "guide-flip/②:还原(重新从真树复制)后绿"; else bad "guide-flip/②:还原后仍红([$(printf '%s' "$out" | tr '\n' '|' | cut -c1-200)])"; fi
1264
1321
  guide_flip_ev "guide-flip-2-restore-green.txt" "$out"
1265
1322
 
1266
- # ③ SKILL:把 `| Key replies |` 行换成不含锚点的行 → 红并点名 command table
1323
+ # ③ SKILL:把 `| Key replies |` 行换成不含锚点的行 → 红并点名 command table(含 row:[[team-reply]])
1267
1324
  mut="$MUTD/SKILL.md"; cp -f "$SKILLMD" "$mut"
1268
1325
  awk 'index($0, "| Key replies |") == 1 && !done { print "| Key replies | See `references/protocol.md` §4b. |"; done=1; next } { print }' "$mut" >"$mut.tmp" && mv "$mut.tmp" "$mut"
1269
- if grep -qF -- 'The outlet for key conclusions' "$mut"; then bad "guide-flip/③:变异没应用上(旧行还在)"; fi
1326
+ if grep -qF -- 'The outlet for replies written for the user' "$mut"; then bad "guide-flip/③:变异没应用上(旧行还在)"; fi
1270
1327
  out="$(guide_check_surface "command table" "$mut" 2>&1)"; rc=$?
1271
1328
  guide_flip_red "③" "command table" "$rc" "$out"
1272
1329
  guide_flip_names_criterion "③" "$out"
@@ -1275,28 +1332,66 @@ kr_group_guide() {
1275
1332
  if [ "$rc" = "0" ]; then ok "guide-flip/③:还原(重新从真树复制)后绿"; else bad "guide-flip/③:还原后仍红([$(printf '%s' "$out" | tr '\n' '|' | cut -c1-200)])"; fi
1276
1333
  guide_flip_ev "guide-flip-3-restore-green.txt" "$out"
1277
1334
 
1278
- # ④ 模板:示例行的 `--stdin` 改成 `--stdinX` → 真解析器拒绝 → 红并点名 example command
1335
+ # ④ 模板:把「先 post 再重复正文」的旧默认句子塞回指令 → guide-default 必须红并点名 prompt template
1279
1336
  mut="$MUTD/pm-prompt.md.tmpl"; cp -f "$TMPL" "$mut"
1280
- perl -pi -e 's/--stdin\b/--stdinX/ if /team reply post/' "$mut"
1281
- if ! grep -qF -- '--stdinX' "$mut"; then bad "guide-flip/④:变异没应用上(示例行没有 --stdinX)"; fi
1282
- out="$(guide_check_example "$mut" "$pex" 2>&1)"; rc=$?
1283
- guide_flip_red "④" "example command" "$rc" "$out"
1337
+ printf '\nPublish the complete reply first, then send that same body in the conversation.\n' >>"$mut"
1338
+ if ! grep -qF -- 'then send that same body' "$mut"; then bad "guide-flip/④:变异没应用上(旧默认句没塞进去)"; fi
1339
+ out="$(guide_no_post_first "prompt template" "$mut" 2>&1)"; rc=$?
1340
+ guide_flip_red "④" "prompt template" "$rc" "$out"
1341
+ if printf '%s' "$out" | grep -qF -- '先 post 再回复'; then
1342
+ ok "guide-flip/④:红文案点名「先 post 再回复」的旧默认"
1343
+ else
1344
+ bad "guide-flip/④:红文案没有点名旧默认([$(printf '%s' "$out" | tr '\n' '|' | cut -c1-220)])"
1345
+ fi
1284
1346
  cp -f "$TMPL" "$mut"
1285
- out="$(guide_check_example "$mut" "$pex" 2>&1)"; rc=$?
1347
+ out="$(guide_no_post_first "prompt template" "$mut" 2>&1)"; rc=$?
1286
1348
  if [ "$rc" = "0" ]; then ok "guide-flip/④:还原(重新从真树复制)后绿"; else bad "guide-flip/④:还原后仍红([$(printf '%s' "$out" | tr '\n' '|' | cut -c1-200)])"; fi
1287
1349
  guide_flip_ev "guide-flip-4-restore-green.txt" "$out"
1288
1350
 
1289
- # ⑤ 模板:只把判据 token 换成另一种说法(句子仍通顺)→ 红并点名 prompt template 与缺失的判据
1351
+ # ⑤ 模板:把标记示例改坏(显式空标题)→ 产品 parser 拒认,guide-marker 必须红
1352
+ if [ "$have_node" = "1" ]; then
1353
+ mut="$MUTD/pm-prompt.md.tmpl"; cp -f "$TMPL" "$mut"
1354
+ perl -pi -e 's/^\[\[team-reply\]\]$/[[team-reply:]]/' "$mut"
1355
+ if ! grep -qxF -- '[[team-reply:]]' "$mut"; then bad "guide-flip/⑤:变异没应用上(标记示例没改成空标题)"; fi
1356
+ out="$(guide_check_marker_example "$mut" 2>&1)"; rc=$?
1357
+ guide_flip_red "⑤" "guide-marker" "$rc" "$out"
1358
+ if printf '%s' "$out" | grep -q 'invalid-title'; then
1359
+ ok "guide-flip/⑤:产品 parser 以 invalid-title 拒认改坏的示例"
1360
+ else
1361
+ bad "guide-flip/⑤:红侧没有产品 parser 的 invalid-title([$(printf '%s' "$out" | tr '\n' '|' | cut -c1-220)])"
1362
+ fi
1363
+ cp -f "$TMPL" "$mut"
1364
+ out="$(guide_check_marker_example "$mut" 2>&1)"; rc=$?
1365
+ if [ "$rc" = "0" ]; then ok "guide-flip/⑤:还原(重新从真树复制)后绿"; else bad "guide-flip/⑤:还原后仍红([$(printf '%s' "$out" | tr '\n' '|' | cut -c1-200)])"; fi
1366
+ guide_flip_ev "guide-flip-5-restore-green.txt" "$out"
1367
+ fi
1368
+
1369
+ # ⑥ 模板:标记约定从模板里被抹掉(示例与正文的 [[team-reply]] → [[team-replied]])→ 点名 prompt template
1290
1370
  mut="$MUTD/pm-prompt.md.tmpl"; cp -f "$TMPL" "$mut"
1291
- perl -pi -e 's/written for the user/written for a person/g' "$mut"
1292
- if grep -qiF -- 'written for the user' "$mut"; then bad "guide-flip/⑤:变异没应用上(判据 token 还在)"; fi
1371
+ perl -pi -e 's/\[\[team-reply/[[team-replied/g' "$mut"
1372
+ if grep -qiF -- '[[team-reply]]' "$mut" && grep -qiF -- '[[team-reply:' "$mut"; then bad "guide-flip/⑥:变异没应用上(标记约定还在)"; fi
1293
1373
  out="$(guide_check_surface "prompt template" "$mut" 2>&1)"; rc=$?
1294
- guide_flip_red "⑤" "prompt template" "$rc" "$out"
1295
- guide_flip_names_criterion "⑤" "$out"
1374
+ guide_flip_red "⑥" "prompt template" "$rc" "$out"
1375
+ if printf '%s' "$out" | grep -qF -- '[[team-reply]]'; then
1376
+ ok "guide-flip/⑥:红文案点名缺失的标记约定 [[team-reply]]"
1377
+ else
1378
+ bad "guide-flip/⑥:红文案没有点名缺失的标记约定([$(printf '%s' "$out" | tr '\n' '|' | cut -c1-220)])"
1379
+ fi
1296
1380
  cp -f "$TMPL" "$mut"
1297
1381
  out="$(guide_check_surface "prompt template" "$mut" 2>&1)"; rc=$?
1298
- if [ "$rc" = "0" ]; then ok "guide-flip/⑤:还原(重新从真树复制)后绿"; else bad "guide-flip/⑤:还原后仍红([$(printf '%s' "$out" | tr '\n' '|' | cut -c1-200)])"; fi
1299
- guide_flip_ev "guide-flip-5-restore-green.txt" "$out"
1382
+ if [ "$rc" = "0" ]; then ok "guide-flip/⑥:还原(重新从真树复制)后绿"; else bad "guide-flip/⑥:还原后仍红([$(printf '%s' "$out" | tr '\n' '|' | cut -c1-200)])"; fi
1383
+ guide_flip_ev "guide-flip-6-restore-green.txt" "$out"
1384
+
1385
+ # ⑦ 模板:手工示例的 `--stdin` 改成 `--stdinX` → 真解析器拒绝 → 红并点名 example command
1386
+ mut="$MUTD/pm-prompt.md.tmpl"; cp -f "$TMPL" "$mut"
1387
+ perl -pi -e 's/--stdin\b/--stdinX/ if /team reply post/' "$mut"
1388
+ if ! grep -qF -- '--stdinX' "$mut"; then bad "guide-flip/⑦:变异没应用上(示例行没有 --stdinX)"; fi
1389
+ out="$(guide_check_example "$mut" "$pex" 2>&1)"; rc=$?
1390
+ guide_flip_red "⑦" "example command" "$rc" "$out"
1391
+ cp -f "$TMPL" "$mut"
1392
+ out="$(guide_check_example "$mut" "$pex" 2>&1)"; rc=$?
1393
+ if [ "$rc" = "0" ]; then ok "guide-flip/⑦:还原(重新从真树复制)后绿"; else bad "guide-flip/⑦:还原后仍红([$(printf '%s' "$out" | tr '\n' '|' | cut -c1-200)])"; fi
1394
+ guide_flip_ev "guide-flip-7-restore-green.txt" "$out"
1300
1395
  }
1301
1396
 
1302
1397
  # ---------------------------------------------------------------- 驱动
@@ -1306,6 +1401,28 @@ if ! kr_io_supported; then
1306
1401
  "$(kr_io_why)" >&2
1307
1402
  fi
1308
1403
 
1404
+ kr_group_capture() {
1405
+ section 'capture:真 parser/source/writer 与隔离 Pi 生命周期'
1406
+ # 真 Pi 段需要 node/tmux/pi 三件现实工具;缺哪件就点名跳过,绝不静默当通过。
1407
+ local pi="${P396_PI:-$HOME/.bun/bin/pi}" missing=()
1408
+ command -v node >/dev/null 2>&1 || missing+=(node)
1409
+ command -v tmux >/dev/null 2>&1 || missing+=(tmux)
1410
+ [ -x "$pi" ] || missing+=("pi($pi)")
1411
+ if [ "${#missing[@]}" -gt 0 ]; then skip "capture:缺 ${missing[*]},真 Pi 段未跑(parser/source 段仍跑)"; fi
1412
+ local parser_rc=0 pi_rc=0
1413
+ node "$SELF_DIR/reply-capture.mjs" --all >"$TMP/capture-source.log" 2>&1 || parser_rc=$?
1414
+ if [ "${#missing[@]}" -eq 0 ]; then bash "$SELF_DIR/reply-capture-real.sh" >"$TMP/capture-real-pi.log" 2>&1 || pi_rc=$?
1415
+ else printf 'SKIP:%s\n' "缺 ${missing[*]}" >"$TMP/capture-real-pi.log"; fi
1416
+ kr_ev_save "$TMP/capture-source.log" capture-source.log
1417
+ kr_ev_save "$TMP/capture-real-pi.log" capture-real-pi.log
1418
+ if [ "$parser_rc" -eq 0 ]; then ok 'capture:parser/source 具名行为与红绿变异'; else bad "capture:parser/source rc=$parser_rc"; fi
1419
+ if [ "${#missing[@]}" -eq 0 ]; then
1420
+ if [ "$pi_rc" -eq 0 ]; then ok 'capture:私有真 Pi 终稿、来源、定向身份与依赖 reload'; else bad "capture:真 Pi rc=$pi_rc"; fi
1421
+ fi
1422
+ # Full failing identities stay visible even when the outer smoke entry only retains its own complete log.
1423
+ cat "$TMP/capture-source.log" "$TMP/capture-real-pi.log" >&"${KR_REPORT_FD:-1}"
1424
+ }
1425
+
1309
1426
  kr_run_group() { # 组名 → 函数(`skip-path` 带连字符,$var 展开调不到)
1310
1427
  case "$1" in
1311
1428
  skip-path) kr_group_skip_path ;;
@@ -1320,6 +1437,8 @@ for g in "${KR_GROUPS[@]}"; do
1320
1437
  bad "${g}:零断言(依赖缺失/静默跳过不算通过)"
1321
1438
  fi
1322
1439
  done
1440
+ section "guard-selfcheck · 隔离守卫的比对范围(P399,合成根上的双向自检)"
1441
+ krg_self_check "$TMP"
1323
1442
  kr_real_guard
1324
1443
  [ -n "$KR_EV" ] && kr_ev_note "run end $(date -u +%Y-%m-%dT%H:%M:%SZ) pass=$PASS fail=$FAIL"
1325
1444
 
@@ -55,6 +55,8 @@ OKN=0; BADN=0
55
55
  case_ok() { OKN=$((OKN + 1)); printf ' ✓ %s\n' "$*"; }
56
56
  case_bad() { BADN=$((BADN + 1)); printf ' ✗ %s\n' "$*"; }
57
57
  one_line() { printf '%s' "$1" | tr '\n' '|' | cut -c1-220; }
58
+ # 这些扫描只查夹具树,不测本机用户名解析;给每次扫描固定用户名(含旧面副本)。
59
+ fixture_ban() { TEAM_SMOKE_FIXTURE=1 bash "$@" --user p239fixtureuser; }
58
60
 
59
61
  # ── 归属声明:表头 ledger-scan 行 + 它的 patterns ─────────────────────────────────────────
60
62
  BAN_HEAD="$(awk -F'\t' '/^# ledger-scan:/{ v = $0; sub(/^# ledger-scan:[[:space:]]*/, "", v); sub(/[[:space:]]*$/, "", v); print v; exit }' "$TABLE")"
@@ -139,7 +141,7 @@ printf '# 他项目名单(夹具)\nfixture-peer\n' >"$BRANCH/.pi/team/forbid
139
141
  printf '# 报告(夹具)\n\n干净:家目录占位 <home>/work/example\n' >"$BRANCH/docs/team/reports/leak-report.md"
140
142
  LEAK_DIR="/home"; LEAK_NAME="leakprobe"
141
143
 
142
- OUT="$(bash "$BAN" --all --root "$BRANCH" --names-file "$BRANCH/.pi/team/forbidden-names.txt" 2>&1)"; RC=$?
144
+ OUT="$(fixture_ban "$BAN" --all --root "$BRANCH" --names-file "$BRANCH/.pi/team/forbidden-names.txt" 2>&1)"; RC=$?
143
145
  if [ "$RC" = "0" ] && printf '%s\n' "$OUT" | grep -qF 'hits=0' && ! printf '%s\n' "$OUT" | grep -qF ': [home]'; then
144
146
  case_ok "③ 干净报告(只有占位符 <home>)→ rc=0 hits=0"
145
147
  else
@@ -149,7 +151,7 @@ fi
149
151
  printf '# 报告(夹具)\n\n干净:家目录占位 <home>/work/example\n泄漏:%s/%s/work/secret\n' \
150
152
  "$LEAK_DIR" "$LEAK_NAME" >"$BRANCH/docs/team/reports/planted-report.md"
151
153
 
152
- OUT="$(bash "$BAN" --all --root "$BRANCH" --names-file "$BRANCH/.pi/team/forbidden-names.txt" 2>&1)"; RC=$?
154
+ OUT="$(fixture_ban "$BAN" --all --root "$BRANCH" --names-file "$BRANCH/.pi/team/forbidden-names.txt" 2>&1)"; RC=$?
153
155
  if [ "$RC" = "1" ] && printf '%s\n' "$OUT" | grep -qF 'docs/team/reports/planted-report.md:4: [home]' \
154
156
  && printf '%s\n' "$OUT" | grep -qF 'hits=1' && ! printf '%s\n' "$OUT" | grep -qF "$LEAK_NAME"; then
155
157
  case_ok "③ 植入家目录字面量 → 红并点名 docs/team/reports/planted-report.md:4(原文被遮蔽)"
@@ -162,8 +164,8 @@ fi
162
164
  MAINLIKE="$TMP/mainlike-tree"; mkdir -p "$MAINLIKE/docs/team/reports" "$MAINLIKE/.pi/team"
163
165
  cp "$BRANCH/.pi/team/forbidden-names.txt" "$MAINLIKE/.pi/team/forbidden-names.txt"
164
166
  printf '# 主检出样的账本(没有本分支的新报告文件)\n' >"$MAINLIKE/docs/team/reports/existing-report.md"
165
- OUT_B="$(bash "$BAN" --all --root "$BRANCH" --names-file "$BRANCH/.pi/team/forbidden-names.txt" 2>&1)"
166
- OUT_M="$(bash "$BAN" --all --root "$MAINLIKE" --names-file "$MAINLIKE/.pi/team/forbidden-names.txt" 2>&1)"
167
+ OUT_B="$(fixture_ban "$BAN" --all --root "$BRANCH" --names-file "$BRANCH/.pi/team/forbidden-names.txt" 2>&1)"
168
+ OUT_M="$(fixture_ban "$BAN" --all --root "$MAINLIKE" --names-file "$MAINLIKE/.pi/team/forbidden-names.txt" 2>&1)"
167
169
  if printf '%s\n' "$OUT_B" | grep -qF 'hits=1' && printf '%s\n' "$OUT_M" | grep -qF 'hits=0'; then
168
170
  case_ok "③ 假绿对照:同一份报告——本分支树 hits=1 / 不含它的树 hits=0(所以在主检出跑扫不到本分支新文件)"
169
171
  printf ' 对照行:%s\n' "$(printf '%s\n' "$OUT_M" | grep -a '^ledger-ban: root=' | tail -1)"
@@ -213,7 +215,7 @@ FACE="$TMP/non-md-face"; mkdir -p "$FACE/docs/team/ledger" "$FACE/.pi/team"
213
215
  printf '# 他项目名单(夹具)\nfixture-peer\n' >"$FACE/.pi/team/forbidden-names.txt"
214
216
  printf '# 干净账本(夹具)\n\n- 他项目占位:<peer>\n' >"$FACE/docs/team/board.md"
215
217
  printf 'branch\ttip\tdate\nfixture-peer-branch\tabc123\t2026-01-01\n' >"$FACE/docs/team/ledger/planted.tsv"
216
- OUT="$(bash "$BAN" --all --root "$FACE" --names-file "$FACE/.pi/team/forbidden-names.txt" 2>&1)"; RC=$?
218
+ OUT="$(fixture_ban "$BAN" --all --root "$FACE" --names-file "$FACE/.pi/team/forbidden-names.txt" 2>&1)"; RC=$?
217
219
  if [ "$RC" = "1" ] && printf '%s\n' "$OUT" | grep -qF 'docs/team/ledger/planted.tsv:2: [names]' \
218
220
  && printf '%s\n' "$OUT" | grep -qF 'hits=1'; then
219
221
  case_ok "⑥ 账本面覆盖非 .md:ledger/*.tsv 里的名字 → 红并点名 planted.tsv:2(同一棵树里的 .md 是干净的)"
@@ -230,7 +232,7 @@ if [ "$(grep -cF -- "$OLD_PAT" "$OLDFACE/ledger-ban.sh")" = "1" ]; then
230
232
  "$OLDFACE/ledger-ban.sh" >"$OLDFACE/new" && mv "$OLDFACE/new" "$OLDFACE/ledger-ban.sh"
231
233
  if [ "$(grep -cF -- "$OLD_NEW" "$OLDFACE/ledger-ban.sh")" = "1" ]; then
232
234
  # 旧面副本只拷了 ledger-ban.sh + lib/tmp-root.sh → 指回真库(P309:解析器不在,创建者会具名失败)
233
- OUT="$(TEAM_TMP_SKILL_DIR="$SKILL_DIR" bash "$OLDFACE/ledger-ban.sh" --all --root "$FACE" --names-file "$FACE/.pi/team/forbidden-names.txt" 2>&1)"; RC=$?
235
+ OUT="$(TEAM_TMP_SKILL_DIR="$SKILL_DIR" fixture_ban "$OLDFACE/ledger-ban.sh" --all --root "$FACE" --names-file "$FACE/.pi/team/forbidden-names.txt" 2>&1)"; RC=$?
234
236
  if [ "$RC" = "0" ] && printf '%s\n' "$OUT" | grep -qF 'hits=0' \
235
237
  && ! printf '%s\n' "$OUT" | grep -qF 'planted.tsv'; then
236
238
  case_ok "⑥ 假绿对照:账本面退回「只扫 *.md」→ 同一棵树、同一个植入 hits=0(假绿就是这么来的)"
@@ -17,7 +17,8 @@
17
17
  # 翻转控制(可证伪):`M24_OVERLAY_DETECT=0` 关掉覆盖层判据 —— 同一份真实帧必须退回老判定
18
18
  # (`idle-read=NOT-EMPTY`、rc 1)。这只是让红侧可见,不是产品开关。
19
19
  #
20
- # 覆盖层判据只认**稳定文案标记**(不认行号,Pi 版本间行号会动;存下的真帧是 0.87.0,钉住的镜像是 0.86.0):
20
+ # 覆盖层判据只认**稳定文案标记**(不认行号,Pi 版本间行号会动;存下的真帧是 0.87.0,当时钉住的镜像曾是 0.86.0;
21
+ # P380 起镜像装的是每轮解析出的最新版,所以判据不依赖某个具体版本的页脚形状):
21
22
  # ① 一行去空白后恰好是 `Trust project folder?`;
22
23
  # ② 之后 16 行内出现 `Do not trust`(含 `Do not trust (this session only)`);
23
24
  # ③ 再之后 6 行内出现导航行(同时含 `navigate` 与 `enter select`)。
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env bash
2
+ # main-team-fingerprint.sh — the isolation ledger for the real project's `.pi/team` (P406/P409,
3
+ # change: agent-self-reminder).
4
+ #
5
+ # A live team is running while a fixture runs: the patrol, dispatches and launch logs really do move.
6
+ # So the judgement is not "skip everything under state/" -- that is exactly the defect shape P171
7
+ # allowed -- but a **named volatile whitelist**: only the shapes named here may appear or change;
8
+ # every other path appearing, disappearing or changing is a violation, including any stray file under
9
+ # state/. The authority's own write surface is never volatile, and that rule is independent of the
10
+ # whitelist, so "add a name to the list" cannot hide an accident.
11
+ #
12
+ # One implementation, two fixtures (tests/state-authority.sh and tests/remind-cli.sh): the isolation
13
+ # proof must be the same judgement in both, not two copies that can drift.
14
+ #
15
+ # main_team_snapshot <dir> → "path<TAB>hash", sorted (absent dir = empty ledger)
16
+ # main_team_volatile <./relpath> → 0 = the shape is allowed to move
17
+ # main_team_violations <before> <after> → one path per non-whitelisted change
18
+ # main_team_volatile_changes <b> <a> → count of whitelisted changes (proves the check sees motion)
19
+ #
20
+ # MAIN_TEAM_BREAK=skip-state is the fixtures' own red side: it restores the old "skip state/" shape so
21
+ # a stray file there stops being reported. Product code never reads it.
22
+
23
+ main_team_authority_surface() { # <relative path, starting with ./ >
24
+ case "$1" in
25
+ ./reminder-locator*|./state/reminders|./state/reminders/*|./state/standby|./state/standby.*) return 0 ;;
26
+ esac
27
+ return 1
28
+ }
29
+
30
+ # The live team's runtime writers, named by shape. Two stages on purpose: directly under the state root
31
+ # a file name is matched by suffix/prefix; subdirectories are only the known ones (bash `case` lets `*`
32
+ # cross `/`, so a subdirectory needs its own branch and cannot be covered by `./state/*.log`).
33
+ main_team_volatile() { # <relative path, starting with ./ >
34
+ local p="$1" rest dir base
35
+ main_team_authority_surface "$p" && return 1
36
+ case "$p" in
37
+ ./state/*)
38
+ rest="${p#./state/}"
39
+ case "$rest" in
40
+ */*)
41
+ dir="${rest%%/*}"
42
+ case "$dir" in
43
+ # meta-suite: tests/meta-suite.sh writes one run record per run into
44
+ # <project root>/.pi/team/state/meta-suite/ -- and the project root is the main checkout
45
+ # (taken from git-common-dir), so a run started from a worktree still lands there. The
46
+ # content is a run record, not product state: the same class as bg/*.log. Volatile
47
+ # because every run adds a new file (P411).
48
+ meta-suite) return 0 ;;
49
+ bg|inbox-watch|outbox|spool|draft|key-replies) return 0 ;;
50
+ release-*|product-field-trial) return 0 ;;
51
+ esac
52
+ return 1 ;;
53
+ esac
54
+ base="$rest"
55
+ case "$base" in
56
+ *.log|*.log.[0-9]*|*.last|*.nudge|*.tick|*.pid*) return 0 ;;
57
+ *.spawn|*.exit|*-tail.txt|*.tmp|*.attempts.*|*.pending|*.inbox|*.lock|*.conf) return 0 ;;
58
+ *.env|*.env.bak-*) return 0 ;;
59
+ inbox-*|pm-*|pm.*|dispatch-*|draft-*|held) return 0 ;;
60
+ notify*|nudge*|watchdog*|capacity*|digest-*|deaths.*|bg.log|panel*) return 0 ;;
61
+ changes.json|refs|pane|_watch.*|reload-requested|interrupt.*|update-check.*|config.*) return 0 ;;
62
+ summary-*|prompt-*|pm-loaded.*|pm-launch*) return 0 ;;
63
+ esac
64
+ return 1 ;;
65
+ esac
66
+ return 1
67
+ }
68
+
69
+ main_team_snapshot() { # <dir> → "path<TAB>hash", sorted by path (absent directory = empty ledger)
70
+ [ -d "$1" ] || return 0
71
+ ( cd "$1" && find . -type f -print0 | sort -z | xargs -0 -r sha256sum 2>/dev/null ) |
72
+ awk '{ h = $1; $1 = ""; sub(/^ /, ""); print $0 "\t" h }' | sort -t "$(printf '\t')" -k1,1
73
+ }
74
+
75
+ main_team_violations() { # <before> <after> → one line per non-whitelisted change
76
+ local before="$1" after="$2" path b a
77
+ join -t "$(printf '\t')" -a1 -a2 -e MISSING -o '0,1.2,2.2' "$before" "$after" |
78
+ while IFS="$(printf '\t')" read -r path b a; do
79
+ [ "$b" = "$a" ] && continue
80
+ if [ "${MAIN_TEAM_BREAK:-}" = "skip-state" ]; then
81
+ case "$path" in ./state/*) continue ;; esac
82
+ fi
83
+ main_team_volatile "$path" && continue
84
+ printf '%s\n' "$path"
85
+ done
86
+ }
87
+
88
+ main_team_volatile_changes() { # <before> <after> → number of whitelisted paths that changed
89
+ local before="$1" after="$2" path b a n=0
90
+ while IFS="$(printf '\t')" read -r path b a; do
91
+ [ "$b" = "$a" ] && continue
92
+ main_team_volatile "$path" && n=$((n + 1))
93
+ done < <(join -t "$(printf '\t')" -a1 -a2 -e MISSING -o '0,1.2,2.2' "$before" "$after")
94
+ printf '%s\n' "$n"
95
+ }
96
+
97
+ # The proof target is this project's **main checkout**, never this worktree: the fixture runs from a
98
+ # worktree while the authority must never land in the main checkout.
99
+ main_team_project_root() { # <skill-dir> → the main checkout (empty when this checkout has none)
100
+ local root
101
+ root="$(git -C "$1" rev-parse --path-format=absolute --git-common-dir 2>/dev/null | xargs -r dirname)"
102
+ [ -n "${root:-}" ] && [ -d "$root" ] || return 0
103
+ printf '%s\n' "$root"
104
+ }