teamsmith 0.1.1 → 0.2.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.
Files changed (104) hide show
  1. package/README.md +16 -8
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +55 -0
  4. package/skills/teamsmith/SKILL.md +18 -7
  5. package/skills/teamsmith/extension/team-bg.ts +47 -11
  6. package/skills/teamsmith/extension/team-notify.ts +143 -4
  7. package/skills/teamsmith/references/agent-adapters.md +7 -7
  8. package/skills/teamsmith/references/config.md +29 -15
  9. package/skills/teamsmith/references/migration.md +38 -2
  10. package/skills/teamsmith/references/openspec.md +23 -9
  11. package/skills/teamsmith/references/protocol.md +81 -13
  12. package/skills/teamsmith/references/workflows.md +31 -19
  13. package/skills/teamsmith/scripts/lib/cmd-agents.sh +210 -70
  14. package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +70 -9
  15. package/skills/teamsmith/scripts/lib/cmd-config.sh +222 -70
  16. package/skills/teamsmith/scripts/lib/cmd-death.sh +2 -15
  17. package/skills/teamsmith/scripts/lib/cmd-docs.sh +6 -3
  18. package/skills/teamsmith/scripts/lib/cmd-project.sh +134 -17
  19. package/skills/teamsmith/scripts/lib/cmd-reply.sh +96 -0
  20. package/skills/teamsmith/scripts/lib/cmd-review.sh +13 -10
  21. package/skills/teamsmith/scripts/lib/cmd-status.sh +42 -13
  22. package/skills/teamsmith/scripts/lib/cmd-watch.sh +75 -13
  23. package/skills/teamsmith/scripts/lib/common.sh +797 -71
  24. package/skills/teamsmith/scripts/monitor.mjs +34 -3
  25. package/skills/teamsmith/scripts/panel/README.md +22 -11
  26. package/skills/teamsmith/scripts/panel/panel.js +217 -215
  27. package/skills/teamsmith/scripts/panel/src/App.tsx +421 -164
  28. package/skills/teamsmith/scripts/panel/src/data.ts +84 -4
  29. package/skills/teamsmith/scripts/panel/src/layout.ts +502 -91
  30. package/skills/teamsmith/scripts/panel/src/main.tsx +97 -12
  31. package/skills/teamsmith/scripts/panel/src/settings.ts +1 -1
  32. package/skills/teamsmith/scripts/panel/src/strings/en.ts +56 -21
  33. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +56 -21
  34. package/skills/teamsmith/scripts/panel/src/types.ts +178 -16
  35. package/skills/teamsmith/scripts/replies.mjs +893 -0
  36. package/skills/teamsmith/scripts/team +1 -0
  37. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +15 -2
  38. package/skills/teamsmith/templates/BOARD.md.tmpl +2 -2
  39. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +7 -3
  40. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +17 -0
  41. package/skills/teamsmith/templates/config.sh.tmpl +10 -5
  42. package/skills/teamsmith/templates/memory-seed.md.tmpl +3 -0
  43. package/skills/teamsmith/templates/pm-prompt.md.tmpl +20 -1
  44. package/skills/teamsmith/templates/report.md.tmpl +12 -0
  45. package/skills/teamsmith/templates/task.md.tmpl +4 -0
  46. package/skills/teamsmith/tests/bg-ledger-harness.mjs +682 -0
  47. package/skills/teamsmith/tests/bg-ledger.sh +307 -0
  48. package/skills/teamsmith/tests/checkout-shape-probe.sh +287 -58
  49. package/skills/teamsmith/tests/config-cli.sh +162 -288
  50. package/skills/teamsmith/tests/death-cause.sh +5 -2
  51. package/skills/teamsmith/tests/install-shape.sh +4 -2
  52. package/skills/teamsmith/tests/key-replies-pty.sh +375 -0
  53. package/skills/teamsmith/tests/key-replies-ui.sh +332 -0
  54. package/skills/teamsmith/tests/key-replies.sh +1075 -0
  55. package/skills/teamsmith/tests/ledger-ban.sh +5 -5
  56. package/skills/teamsmith/tests/ledger-claim.sh +247 -0
  57. package/skills/teamsmith/tests/lib/checkout-shape.sh +66 -14
  58. package/skills/teamsmith/tests/lib/model-policy.sh +26 -0
  59. package/skills/teamsmith/tests/lib/model-routing-boundary.sh +420 -0
  60. package/skills/teamsmith/tests/lib/model-routing-expansion.sh +155 -0
  61. package/skills/teamsmith/tests/lib/model-routing-flips.py +136 -0
  62. package/skills/teamsmith/tests/lib/model-routing-roles.sh +250 -0
  63. package/skills/teamsmith/tests/lib/proc-io.sh +103 -0
  64. package/skills/teamsmith/tests/lib/reply-fixture.sh +372 -0
  65. package/skills/teamsmith/tests/lib/tmux-iso.sh +8 -0
  66. package/skills/teamsmith/tests/panel-b2.sh +1 -1
  67. package/skills/teamsmith/tests/panel-b3-stub.sh +27 -0
  68. package/skills/teamsmith/tests/panel-b3.sh +14 -10
  69. package/skills/teamsmith/tests/panel-choices.sh +74 -61
  70. package/skills/teamsmith/tests/panel-cpu.sh +1 -1
  71. package/skills/teamsmith/tests/panel-p21.sh +311 -190
  72. package/skills/teamsmith/tests/perf.sh +1 -1
  73. package/skills/teamsmith/tests/pm-box-real.sh +1 -1
  74. package/skills/teamsmith/tests/pulse-nudge-key.sh +1 -1
  75. package/skills/teamsmith/tests/routes.sh +43 -22
  76. package/skills/teamsmith/tests/section-budgets.tsv +9 -5
  77. package/skills/teamsmith/tests/section-paths.tsv +26 -16
  78. package/skills/teamsmith/tests/section-select.sh +99 -16
  79. package/skills/teamsmith/tests/smoke.sh +930 -216
  80. package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +2 -2
  81. package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +2 -2
  82. package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +9 -9
  83. package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +2 -2
  84. package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +9 -9
  85. package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +1 -1
  86. package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +1 -1
  87. package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +5 -5
  88. package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +2 -2
  89. package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +5 -5
  90. package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +2 -2
  91. package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +2 -2
  92. package/skills/teamsmith/tests/snapshots/zh-light-120.txt +9 -9
  93. package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +2 -2
  94. package/skills/teamsmith/tests/snapshots/zh-light-160.txt +9 -9
  95. package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +1 -1
  96. package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +1 -1
  97. package/skills/teamsmith/tests/snapshots/zh-light-59.txt +5 -5
  98. package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +2 -2
  99. package/skills/teamsmith/tests/snapshots/zh-light-99.txt +5 -5
  100. package/skills/teamsmith/tests/task-header-model.sh +2 -1
  101. package/skills/teamsmith/tests/task-model-routing.sh +1014 -0
  102. package/skills/teamsmith-init/SKILL.md +38 -38
  103. package/skills/teamsmith-init/references/bootstrap.md +6 -4
  104. package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +9 -5
@@ -15,9 +15,17 @@
15
15
  # 2 = 用法错误、表畸形、未知 key、路径出界。
16
16
  #
17
17
  # 决定语义(保守方向永远是「多跑」):
18
- # NONE = 给的路径全在豁免类(docs/*,团队账本)且没有行声明它 → 没有段需要跑
18
+ # NONE = 给的路径全在豁免类(docs/*,团队账本)且没有被表头 ledger-scan 归属模式覆盖
19
+ # → 没有段需要跑
19
20
  # RUN = 给的路径每条都被某些行声明 → 这些 key + 前导段 + needs 闭包,按源序
20
21
  # FULL = 至少一条路径没有任何行声明、也不在豁免类 → 跑全套(兜底不可绕过)
22
+ #
23
+ # 账本(docs/team/**)的归属(P239):patterns 列**不允许**声明豁免类(--check ④ 守着这条),
24
+ # 所以账本路径的归属写在表头一行 `# ledger-scan: <key> <pattern…>`:命中的路径归那一段。
25
+ # 删掉这行(或它的归属模式)→ 账本路径回到豁免类(NONE);--check ⑦ 会对「缺头 / 指向未知段 /
26
+ # 没有模式 / 模式没盖住账本样例」逐条判红。
27
+ # P231:这行还必须**唯一**,且指向**承载账本禁令的那一段**(patterns 列声明了 $LSC_CARRIER)——
28
+ # 两份表头(旧行为:最后一行赢)或指向别的段都不再放行,**装载时就报错点名**(die,rc=2)。
21
29
  set -uo pipefail
22
30
 
23
31
  here="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -73,9 +81,10 @@ else
73
81
  fi
74
82
  TSV="$ROOT/skills/teamsmith/tests/section-paths.tsv"
75
83
  SUITE="$ROOT/skills/teamsmith/tests/smoke.sh"
76
- # ── 检出形状(change: product-checkout-gate)────────────────────────────────────────────
77
- # 与门禁共用同一份「产品面检出」判据(纯文件,不看 TEAM_* / git / CI):§③ 的字面存在性检查
78
- # 只有在**产品面检出**里、且字面量落在那四个**精确**内部前提上时才允许按缺失跳过。
84
+ # ── 检出形状(change: product-checkout-gate;P222 加机器生成面)────────────────────────
85
+ # 与门禁共用同一份判据(纯文件,不看 TEAM_* / git / CI):§③ 的字面存在性检查里,机器生成面
86
+ # (`.pi/prompts` / `.pi/skills`)整棵不在时按缺失跳过;其余字面量只有在**产品面检出**里、且落在
87
+ # 那几个**精确**内部前提上时才允许按缺失跳过。
79
88
  # shellcheck source=tests/lib/checkout-shape.sh
80
89
  . "$SEL_DIR/lib/checkout-shape.sh"
81
90
  CHECKOUT_SHAPE="$(checkout_shape "$ROOT")"
@@ -89,17 +98,27 @@ CHECKOUT_SHAPE="$(checkout_shape "$ROOT")"
89
98
  # needs :必须先跑的段 key(逗号分隔);`-` = 无。选段时它们连同自己的 needs 一起进闭包。
90
99
  P_EXEMPT=""
91
100
  P_PROLOGUE=""
101
+ P_LEDGER_SCAN="" # 表头 `# ledger-scan: <key> <pattern…>`:账本(docs/team/**)的归属行(P239)
102
+ P_LEDGER_PAT="" # 上面那行的归属模式(空格分隔,同 patterns 列的 case glob 语义)
103
+ P_LEDGER_LINE="" # 上面那行的原文载荷(解析用;空 = 表里没有这行)
104
+ P_LEDGER_LNS=() # 上面那行在表里的行号(P231:>1 行 = 重复声明,装载即拒绝)
105
+ LSC_CARRIER="skills/teamsmith/tests/ledger-ban.sh" # 承载账本禁令的段:patterns 列里必须有它(P231)
92
106
  T_N=0
93
107
  T_KEY=(); T_ID=(); T_PAT=(); T_NEEDS=(); T_BASIS=()
94
108
 
95
109
  load_table() {
96
110
  [ -r "$TSV" ] || die "读不到映射表 $TSV"
97
- local line nf
111
+ local line nf ln=0
98
112
  T_N=0
99
113
  while IFS= read -r line || [ -n "$line" ]; do
114
+ ln=$((ln + 1))
100
115
  case "$line" in
101
116
  "# exempt:"*) P_EXEMPT="${line#\# exempt:}"; P_EXEMPT="${P_EXEMPT# }"; P_EXEMPT="${P_EXEMPT% }"; continue ;;
102
117
  "# prologue:"*) P_PROLOGUE="${line#\# prologue:}"; P_PROLOGUE="${P_PROLOGUE# }"; P_PROLOGUE="${P_PROLOGUE% }"; continue ;;
118
+ "# ledger-scan:"*) P_LEDGER_LINE="${line#\# ledger-scan:}"; P_LEDGER_LINE="${P_LEDGER_LINE# }"; P_LEDGER_LINE="${P_LEDGER_LINE% }"
119
+ P_LEDGER_SCAN="${P_LEDGER_LINE%% *}"; P_LEDGER_PAT="${P_LEDGER_LINE#"$P_LEDGER_SCAN"}"; P_LEDGER_PAT="${P_LEDGER_PAT# }"
120
+ P_LEDGER_LNS+=("$ln")
121
+ continue ;;
103
122
  "#"*|"") continue ;;
104
123
  esac
105
124
  IFS=$'\t' read -r -a F <<<"$line"
@@ -113,6 +132,25 @@ load_table() {
113
132
  [ "$T_N" -gt 0 ] || die "映射表是空的:$TSV"
114
133
  [ -n "$P_EXEMPT" ] || die "映射表缺 exempt 头(豁免类声明)"
115
134
  [ -n "$P_PROLOGUE" ] || die "映射表缺 prologue 头(前导段声明)"
135
+ load_table_check_ledger_head
136
+ }
137
+
138
+ # P231:ledger-scan 头的两条装载期铁律 —— 必须是**唯一**一行,且指向**承载账本禁令的那一段**
139
+ # (那一段的 patterns 列声明了 $LSC_CARRIER)。两种违反过去都能过:两份表头是最后一行赢,指向
140
+ # 别的段只看「段在不在」。现在都在装载时报错点名(文件 + 行号),不静默选一边。
141
+ load_table_check_ledger_head() {
142
+ local row
143
+ if [ "${#P_LEDGER_LNS[@]}" -gt 1 ]; then
144
+ die "映射表有 ${#P_LEDGER_LNS[@]} 行 ledger-scan 头($TSV:$(printf '%s' "${P_LEDGER_LNS[*]}" | tr ' ' ','))—— 归属只许声明一处(旧行为是最后一行赢,已拒绝)"
145
+ fi
146
+ [ -n "$P_LEDGER_SCAN" ] || return 0 # 缺头不是装载错:--check ⑦ 判红(账本路径回到 NONE)
147
+ if ! row="$(row_idx "$P_LEDGER_SCAN")"; then
148
+ die "ledger-scan 头($TSV:${P_LEDGER_LNS[0]})指向未知段 [$P_LEDGER_SCAN] —— 归属必须落在承载账本禁令的那一段(patterns 里有 $LSC_CARRIER)"
149
+ fi
150
+ case " ${T_PAT[row]} " in
151
+ *" $LSC_CARRIER "*) ;;
152
+ *) die "ledger-scan 头($TSV:${P_LEDGER_LNS[0]})指向 [$P_LEDGER_SCAN],但那一行的 patterns 列没有 $LSC_CARRIER —— 归属必须落在承载账本禁令的那一段" ;;
153
+ esac
116
154
  }
117
155
 
118
156
  # ── 门禁源码里的段(顺序 = 源序)──────────────────────────────────────────────────────────
@@ -418,6 +456,15 @@ do_paths() {
418
456
  fi
419
457
  done
420
458
  done
459
+ if [ "$claimed" = "0" ]; then
460
+ # 账本归属(P239):patterns 列不许声明豁免类,所以账本路径的归属由表头 ledger-scan 行提供。
461
+ if [ -n "$P_LEDGER_PAT" ]; then
462
+ IFS=' ' read -r -a PARR <<<"$P_LEDGER_PAT"
463
+ for pp in "${PARR[@]}"; do
464
+ if pat_match "$pp" "$p"; then claimed=1; add_key "$P_LEDGER_SCAN" "$p"; break; fi
465
+ done
466
+ fi
467
+ fi
421
468
  if [ "$claimed" = "0" ]; then
422
469
  if pat_match "$P_EXEMPT" "$p"; then exempted+=("$p"); else unclaimed+=("$p"); fi
423
470
  fi
@@ -434,7 +481,7 @@ do_paths() {
434
481
  printf 'decision=NONE\n'
435
482
  printf 'sections=%s\n' "$S_N"
436
483
  printf 'keys=0\n'
437
- for p in "${exempted[@]}"; do printf 'reason=%s ← 豁免类(%s):团队账本,门禁不为它开火\n' "$p" "$P_EXEMPT"; done
484
+ for p in "${exempted[@]}"; do printf 'reason=%s ← 豁免类(%s)且没有被账本归属(ledger-scan)覆盖:门禁不为它开火\n' "$p" "$P_EXEMPT"; done
438
485
  printf 'reason=没有段落需要运行(no section needs to run)\n'
439
486
  return 0
440
487
  fi
@@ -473,19 +520,23 @@ do_list() {
473
520
  # ① 段 ↔ 行一一对应(段没行 / 行没段 / 重复 key)
474
521
  # ② needs 存在且指向**更早**的段
475
522
  # ③ 字面模式(无通配)存在于工作树
476
- # ④ 豁免类没有任何行声明
523
+ # ④ 豁免类没有任何行声明(patterns 列)
477
524
  # ⑤ 前导段的 key 都在(否则选段会少跑前导)
478
525
  # ⑥ 段正文里点名的**真实**路径 token 必须被该行的 patterns 覆盖(token 与行号都点名);
479
- # 豁免类(docs/**)的 token 不参与该检查 —— 按 ④ 没有任何行可以声明它们(选择器对它们的
480
- # 回答是 NONE,不是某一段)
526
+ # 豁免类(docs/**)的 token 不参与该检查 —— 按 ④ 没有任何行可以声明它们(账本路径的归属由
527
+ # 表头 ledger-scan 行担当,不写进 patterns,所以这里也不参与;它有自己的 ⑦)
528
+ # ⑦ 账本归属(P239):表头 ledger-scan 行必须在、指向已存在的段、有归属模式,且模式盖住
529
+ # 每一个账本样例(缺一样 = 账本文本的改动不再选中任何段 → 红)。
530
+ # P231:「唯一 + 指向承载禁令的段」这两条在装载期就 die(load_table_check_ledger_head),
531
+ # 走到这里时它们已经成立 —— 下面「指向未知段」那一支只是防御,不是第一道门。
481
532
  # 段正文的 normalizer(与 P97 探针同一口径):$SKILL_DIR→skills/teamsmith、
482
533
  # $SKILL_INIT_DIR→skills/teamsmith-init、$SRC_ROOT/$OS_ROOT/$V94_ROOT→仓库根;
483
534
  # 裸前缀 skills/ panel/ extension/ openspec/ ci/;根文件 SCOPE.md/README.md/AGENTS.md/CHANGELOG.md。
484
535
  CHECK_OK=0; CHECK_BAD=0; CHECK_SKIP=0
485
536
  cok() { printf 'ok: %s\n' "$1"; CHECK_OK=$((CHECK_OK + 1)); }
486
537
  cbad() { printf 'bad: %s\n' "$1"; CHECK_BAD=$((CHECK_BAD + 1)); }
487
- # 前提缺失(产品面检出里刻意不存在的内部开发面):与 ok/bad 分开点名、分开计数(SKIP 不是通过,
488
- # 也不是失败)。行里带行 key 与精确路径 —— 读者能照着重跑、也能照着核。
538
+ # 前提缺失(机器生成面整棵不在;或产品面检出里刻意不存在的内部开发面):与 ok/bad 分开点名、
539
+ # 分开计数(SKIP 不是通过,也不是失败)。行里带行 key 与精确路径 —— 读者能照着重跑、也能照着核。
489
540
  csk() { printf 'SKIP(条件不满足): %s\n' "$1"; CHECK_SKIP=$((CHECK_SKIP + 1)); }
490
541
 
491
542
  # 一行 → 追加规范化 token 到全局数组 TOKS(纯内建,无 fork)
@@ -530,7 +581,7 @@ trim_token() {
530
581
  do_check() {
531
582
  local i j k line n=0 pp dup="" missing_rows=() missing_rows_n=() missing_secs=()
532
583
  local nb=0 n_ok=0 lit_bad=0 lit_n=0 lit_skip_c=0 ex_bad=0 pro_bad=0 tok_bad=0 tok_n=0 ex_tok_n=0
533
- local cur="" curline=0 ri="" covered pp PARR=() TOKS=() t
584
+ local cur="" curline=0 ri="" covered pp PARR=() TOKS=() t _lit_why=""
534
585
  # ① 段 ↔ 行
535
586
  for ((i = 0; i < T_N; i++)); do
536
587
  for ((j = i + 1; j < T_N; j++)); do [ "${T_KEY[i]}" = "${T_KEY[j]}" ] && dup="${dup} ${T_KEY[i]}"; done
@@ -560,7 +611,8 @@ do_check() {
560
611
  done
561
612
  done
562
613
  [ "$nb" -eq "$n_ok" ] && cok "needs 声明全部存在且指向更早的段($nb 条)"
563
- # ③ 字面模式存在(产品面检出里,四个**精确**内部前提按缺失跳过 —— 不是前缀豁免、不是整表放行)
614
+ # ③ 字面模式存在(机器生成面整棵不在、或产品面检出里的**精确**内部前提按缺失跳过 ——
615
+ # 不是前缀豁免、不是整表放行;其余缺失一律红)
564
616
  for ((i = 0; i < T_N; i++)); do
565
617
  [ "${T_PAT[i]}" = "-" ] && continue
566
618
  IFS=' ' read -r -a PARR <<<"${T_PAT[i]}"
@@ -568,8 +620,13 @@ do_check() {
568
620
  case "$pp" in *'*'*) continue ;; esac
569
621
  lit_n=$((lit_n + 1))
570
622
  [ -e "$ROOT/$pp" ] && continue
571
- if checkout_literal_skippable "$CHECKOUT_SHAPE" "$pp"; then
572
- csk "行 ${T_KEY[i]} 的字面模式在检出里不存在(产品面检出,内部开发面前提):$pp"
623
+ if checkout_literal_skippable "$ROOT" "$CHECKOUT_SHAPE" "$pp"; then
624
+ if checkout_generated_surface_absent "$ROOT" "$pp"; then
625
+ _lit_why="机器生成面(工具在本机生成、不进仓库)"
626
+ else
627
+ _lit_why="内部开发面前提"
628
+ fi
629
+ csk "行 ${T_KEY[i]} 的字面模式在检出里不存在(检出形状 $CHECKOUT_SHAPE,$_lit_why):$pp"
573
630
  lit_skip_c=$((lit_skip_c + 1))
574
631
  else
575
632
  cbad "行 ${T_KEY[i]} 的字面模式在工作树里不存在:$pp"
@@ -580,7 +637,7 @@ do_check() {
580
637
  if [ "$lit_bad" -eq 0 ] && [ "$lit_skip_c" -eq 0 ]; then
581
638
  cok "字面模式全部存在于工作树($lit_n 条)"
582
639
  elif [ "$lit_bad" -eq 0 ]; then
583
- cok "字面模式($lit_n 条)里 $((lit_n - lit_skip_c)) 条在位;$lit_skip_c 条内部开发面前提按缺失跳过(跳过不等于检查过)"
640
+ cok "字面模式($lit_n 条)里 $((lit_n - lit_skip_c)) 条在位;$lit_skip_c 条检出前提按缺失跳过(跳过不等于检查过)"
584
641
  fi
585
642
  # ④ 豁免类没有任何行声明
586
643
  for ((i = 0; i < T_N; i++)); do
@@ -633,6 +690,32 @@ do_check() {
633
690
  done < "$SUITE"
634
691
  [ "$tok_bad" -eq 0 ] && cok "段正文点名的真实路径 token 都被各自的行覆盖($tok_n 个 token 检查过;$ex_tok_n 个豁免类 token 不参与)"
635
692
 
693
+ # ⑦ 账本归属(P239):表头 ledger-scan 行必须在、指向已存在的段、有归属模式,且模式盖住每个账本样例。
694
+ # 缺一样 = 账本文本的改动不再选中任何段(回到 NONE);这一条是它的静态牙(行为面在 §60 的夹具里)。
695
+ local lsc_bad=0 lsc_n=0 lsc_row=""
696
+ if [ -z "$P_LEDGER_SCAN" ]; then
697
+ cbad "映射表缺 ledger-scan 头(账本路径没有归属声明处)"; lsc_bad=$((lsc_bad + 1))
698
+ else
699
+ lsc_row="$(row_idx "$P_LEDGER_SCAN" || true)"
700
+ [ -n "$lsc_row" ] || { cbad "ledger-scan 头 [$P_LEDGER_SCAN] 不在映射表里(归属指向未知段)"; lsc_bad=$((lsc_bad + 1)); }
701
+ [ -n "$P_LEDGER_PAT" ] || { cbad "ledger-scan 头没有归属模式($P_LEDGER_SCAN)"; lsc_bad=$((lsc_bad + 1)); }
702
+ fi
703
+ if [ -n "$lsc_row" ] && [ -n "$P_LEDGER_PAT" ]; then
704
+ IFS=' ' read -r -a LSPART <<<"$P_LEDGER_PAT"
705
+ for j in docs/team/BOARD.md docs/team/ROADMAP.md docs/team/reports/X.md docs/team/tasks/X.md \
706
+ docs/team/threads/dev.md docs/team/inbox/dev.md docs/team/reviews/X.md \
707
+ docs/team/OWNERSHIP.md docs/team/DECISIONS.md; do
708
+ covered=0
709
+ for pp in "${LSPART[@]}"; do pat_match "$pp" "$j" && { covered=1; break; }; done
710
+ if [ "$covered" = "0" ]; then
711
+ cbad "ledger-scan 归属模式没有覆盖 $j(改这个路径不会选中它)"; lsc_bad=$((lsc_bad + 1))
712
+ else
713
+ lsc_n=$((lsc_n + 1))
714
+ fi
715
+ done
716
+ fi
717
+ [ "$lsc_bad" -eq 0 ] && cok "账本归属(ledger-scan $P_LEDGER_SCAN)声明有效:$lsc_n/9 个账本样例被它覆盖"
718
+
636
719
  printf '== 选段自检 == ok %d bad %d SKIP %d\n' "$CHECK_OK" "$CHECK_BAD" "$CHECK_SKIP"
637
720
  [ "$CHECK_BAD" -eq 0 ] || return 1
638
721
  return 0