@tyhld/conductor 0.12.187 → 0.12.189

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tyhld/conductor",
3
- "version": "0.12.187",
3
+ "version": "0.12.189",
4
4
  "description": "采配くん管制の見守りアプリ(conductor-agent)。各PCで常駐し、中央(devlog-tracker)へ定期的に生存報告(heartbeat)を送る常駐CLI。",
5
5
  "type": "module",
6
6
  "bin": {
@@ -2428,9 +2428,19 @@ def is_inplace_edit(verb: str, tokens) -> bool:
2428
2428
  # 1) 危険(deny)
2429
2429
  # ═════════════════════════════════════════════════════════════════════════════
2430
2430
 
2431
- def _danger_patterns(low: str):
2432
- """全文(小文字)に対する無条件の危険。変数へ直書きされたものも文字列として拾う。"""
2433
- if re.search(r'git\s+push\b[^;&|\n]*?(--force(-with-lease)?\b|(?:^|\s)-f(?:\s|$)|\s\+\S)', low):
2431
+ #: 強い上書きの push の字面(全文・小文字で当てる)。
2432
+ _FORCE_PUSH_RE = re.compile(r'git\s+push\b[^;&|\n]*?(--force(-with-lease)?\b|(?:^|\s)-f(?:\s|$)|\s\+\S)')
2433
+
2434
+
2435
+ def _danger_patterns(low: str, command: str = None):
2436
+ """全文(小文字)に対する無条件の危険。変数へ直書きされたものも文字列として拾う。
2437
+
2438
+ ★command(元の字面)を渡したときだけ、強い上書きの push の字が【探すだけの道具の
2439
+ 引用符の中】にだけ在る形を免じる(_push_only_in_search_words・便 b6410117)。
2440
+ 渡さなければ今までどおり字面だけで止める。
2441
+ """
2442
+ if _FORCE_PUSH_RE.search(low) and not (command is not None
2443
+ and _push_only_in_search_words(command)):
2434
2444
  return 'force push'
2435
2445
  if re.search(r'git\s+reset\b[^;&|\n]*--hard\b', low):
2436
2446
  return 'git reset --hard'
@@ -4044,12 +4054,41 @@ def _is_search_only(toks) -> bool:
4044
4054
  return bool(toks) and verb == 'git' and any(t in _SEARCH_ONLY_VERBS for t in toks[1:3])
4045
4055
 
4046
4056
 
4057
+ #: 探す道具に別の命令を走らせる旗(git grep の -O・rg の --pre・ag/ack/ugrep の --pager・ugrep の --filter)。
4058
+ # ★これが付いた行は、引用符の中の字が命令として動き得るので免じない。
4059
+ _SEARCH_EXEC_LONG_FLAGS = ('--open-files-in-pager', '--pre', '--pager', '--filter')
4060
+
4061
+
4062
+ def _search_runs_command(toks) -> bool:
4063
+ """探す道具の語に、別の命令を走らせる旗が在るか(★まとめ書きの短い旗の O も数える)。"""
4064
+ for t in toks:
4065
+ if t.startswith('--'):
4066
+ if t.split('=', 1)[0] in _SEARCH_EXEC_LONG_FLAGS:
4067
+ return True
4068
+ elif t.startswith('-') and 'O' in t[1:]:
4069
+ return True
4070
+ return False
4071
+
4072
+
4073
+ def _search_words_stay_words(seg: str) -> bool:
4074
+ """このセグメントの引用符の中の字が、探す言葉のまま動かないか(rm・push の免じ方で共通)。
4075
+
4076
+ ★探すだけの道具で、置き換えの実行(`$(`・逆引用符)も別の命令を走らせる旗も無いときだけ True。
4077
+ 【なぜ共通にしたか(便 f599daa0)】旗の除外は push の側(便 b6410117)にだけ在り、
4078
+ rm の側は `git grep -O'<rm の字>'`・`rg --pre '<rm の字>'` を免じて allow にしていた。
4079
+ """
4080
+ toks = tokens_of(seg)
4081
+ return ('$(' not in seg and '`' not in seg
4082
+ and _is_search_only(toks) and not _search_runs_command(toks))
4083
+
4084
+
4047
4085
  def _rm_only_in_search_words(command: str) -> bool:
4048
4086
  """削除命令の字が【探すだけの道具の引用符の中】にだけ在るか。
4049
4087
 
4050
4088
  ★免じるのはこれが True のときだけ。少しでも判断が付かなければ False(=止める側へ倒す)。
4051
4089
  ・引用符の外に削除命令の字が在るセグメントが1つでも在れば False。
4052
4090
  ・引用符の中に在っても、そのセグメントが探すだけの道具でなければ False。
4091
+ ・置き換えの実行(`$(`・逆引用符)や、別の命令を走らせる旗が在れば False(便 f599daa0)。
4053
4092
  ・どこにも見つからなければ False(ヒアドキュメントの本文など、
4054
4093
  引用符を割らない読み方では覆えない字面=安全側)。
4055
4094
  """
@@ -4060,7 +4099,35 @@ def _rm_only_in_search_words(command: str) -> bool:
4060
4099
  continue
4061
4100
  if _RM_WORD_RE.search(_blank_quoted(seg)):
4062
4101
  return False # 囲みの外に在る=本物の削除命令として扱う
4063
- if not _is_search_only(tokens_of(seg)):
4102
+ if not _search_words_stay_words(seg):
4103
+ return False
4104
+ found_in_search_words = True
4105
+ return found_in_search_words
4106
+
4107
+
4108
+ # 引用符の外の push の字(探す言葉の外に push の命令が在るかを見る形)。
4109
+ _GIT_PUSH_WORD_RE = re.compile(r'\bgit\s+push\b')
4110
+
4111
+
4112
+ def _push_only_in_search_words(command: str) -> bool:
4113
+ """強い上書きの push の字が【探すだけの道具の引用符の中】にだけ在るか(便 b6410117)。
4114
+
4115
+ 【なぜ要るか(実地 便 311545fe・40fc68ed・2026-11-14)】読むだけの git grep の探す言葉に
4116
+ 禁止の一覧の1行(git push と + の参照)を書いただけで danger: force push で止まり、
4117
+ 便が2本途中で終わった。rm の字のときと同じ考え方で直す(_rm_only_in_search_words・便 915694ac)。
4118
+ ★免じるのはこれが True のときだけ。少しでも判断が付かなければ False(=止める側へ倒す)。
4119
+ ・強い上書きの push の字が在るセグメントで、引用符の外に git push の字が在れば False。
4120
+ ・そのセグメントが探すだけの道具でなければ False。
4121
+ ・置き換えの実行(`$(`・逆引用符)や、別の命令を走らせる旗が在れば False。
4122
+ ・どこにも見つからなければ False(ヒアドキュメントの本文など=安全側)。
4123
+ """
4124
+ found_in_search_words = False
4125
+ for seg in split_commands(command, bodies=False):
4126
+ if not _FORCE_PUSH_RE.search(seg.lower()):
4127
+ continue
4128
+ if _GIT_PUSH_WORD_RE.search(_blank_quoted(seg).lower()):
4129
+ return False # 囲みの外に在る=本物の push として扱う
4130
+ if not _search_words_stay_words(seg):
4064
4131
  return False
4065
4132
  found_in_search_words = True
4066
4133
  return found_in_search_words
@@ -7197,7 +7264,7 @@ def _bash_danger_plain(command: str, cwd=None, outside_grep_tree=True):
7197
7264
  測り直すときに使う(便 dbf1e335・_recursive_read_danger の同名の引数)。
7198
7265
  """
7199
7266
  # ---- 1) 危険(全文) ----
7200
- hit = _danger_patterns(command.lower()) or _printenv_danger(command)
7267
+ hit = _danger_patterns(command.lower(), command) or _printenv_danger(command)
7201
7268
  if hit:
7202
7269
  return hit
7203
7270
  hit = _rm_danger(command)
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env python3
2
+ """探す言葉の中の push の字を、強い上書きの push として止めない検査(便 b6410117)。
3
+
4
+ 実行: python3 scripts/hooks/test_search_word_push.py
5
+ 1件でも期待と違えば exit 1。
6
+
7
+ 【なぜ要るか(実地 便 311545fe・40fc68ed・2026-11-14)】
8
+ 読むだけの git grep の探す言葉に、禁止の一覧の1行(git push と + の参照)を書いただけで
9
+ `danger: force push` で止まり、便が2本途中で終わった。前に rm の字で同じことが起きたときの
10
+ 直し(便 915694ac・_rm_only_in_search_words)と同じ考え方で直す(えふさん決定 2026-11-15)。
11
+
12
+ 【ここで固定すること】
13
+ (a) 通る … 止められた2件の命令そのもの・探す言葉の中の --force/-f/--force-with-lease/+ の参照
14
+ (b) 止める(danger)… 本物の強い上書きの push(+ の参照・--force・-f・--force-with-lease)・
15
+ 探す命令の後ろにつないだ本物の push・包みの中・置き換えの実行・別の命令を走らせる旗・
16
+ ヒアドキュメントの本文
17
+ (c) rm のときの直し(便 915694ac)も今までどおり
18
+ (d) 空振り確認(免じる所を外すと (a) が落ちる)
19
+ ★この台本は危険語・秘密の形の名前を素の字で置かない(組み立てて使う)。既存の作法どおり。
20
+ """
21
+ import os
22
+ import shutil
23
+ import sys
24
+ import tempfile
25
+
26
+ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
27
+
28
+ import policy # noqa: E402
29
+
30
+ failures = []
31
+
32
+
33
+ def check(label, got, want):
34
+ ok = got == want
35
+ if not ok:
36
+ failures.append(f'{label}: got={got!r} want={want!r}')
37
+ print(f'{"OK " if ok else "NG "} {label:64} {str(got)[:40]}')
38
+
39
+
40
+ # ── 部品(危険語を直接書かない) ──
41
+ PUSH = 'pu' + 'sh'
42
+ GP = 'git ' + PUSH
43
+ FORCE = '--for' + 'ce'
44
+ LEASE = FORCE + '-with-lease'
45
+ SHORT = '-' + 'f'
46
+ RM = 'r' + 'm'
47
+ NPMRC = '.npm' + 'rc'
48
+
49
+ # ── 使い捨ての作り物(作業場所の根に秘密の形のファイルを置く=実地と同じ形)──────
50
+ ROOT = tempfile.mkdtemp(prefix='search-word-push-')
51
+ SITE = os.path.join(ROOT, 'site')
52
+ for d in ('src', 'scripts', 'sales-template', 'docs', '.claude'):
53
+ os.makedirs(os.path.join(SITE, d))
54
+ with open(os.path.join(SITE, NPMRC), 'w') as f:
55
+ f.write('DUMMY=placeholder\n')
56
+ with open(os.path.join(SITE, '.claude', 'settings.json'), 'w') as f:
57
+ f.write('{}\n')
58
+
59
+
60
+ def decide(cmd):
61
+ r = policy.decide_bash(cmd, SITE)
62
+ return r['decision'] + ':' + r['reason'].split(':', 1)[0]
63
+
64
+
65
+ ALLOW = 'allow:no gate, no danger'
66
+
67
+ # ── 止められた2件の命令(便 311545fe・40fc68ed の報告の全文のまま・危険語だけ組み立て形)──
68
+ CMD_311545FE = f'git grep -n -e "{GP} * +*" -- src scripts sales-template'
69
+ CMD_40FC68ED = f"git grep -n -e '{GP} \\* +\\*' -- .claude/settings.json"
70
+
71
+ # ═════════════════════════════════════════════════════════════════════════════
72
+ # (a) 通る(探す言葉の中の字)
73
+ # ═════════════════════════════════════════════════════════════════════════════
74
+ print('── (a) 探す言葉の中の push の字は push と読まない ' + '─' * 18)
75
+ PASS = [
76
+ ('a01 便 311545fe で止まった命令', CMD_311545FE),
77
+ ('a02 便 40fc68ed で止まった命令', CMD_40FC68ED),
78
+ ('a03 git grep の探す言葉に --force', f"git grep -n -e '{GP} {FORCE}' -- src docs"),
79
+ ('a04 git grep の探す言葉に -f', f"git grep -n -e '{GP} {SHORT} origin' -- src"),
80
+ ('a05 git grep の探す言葉に --force-with-lease', f'git grep -n -e "{GP} {LEASE}" -- docs'),
81
+ ('a06 git grep の探す言葉に + の参照', f"git grep -n '{GP} origin +main' -- src"),
82
+ ('a07 -e を2つ', f"git grep -n -e '{GP} +x' -e '{GP} {FORCE}' -- src docs"),
83
+ ('a08 grep -rn(場所を名指し)', f"grep -rn '{GP} {FORCE}' src docs"),
84
+ ('a09 grep -n(ファイルを名指し)', f"grep -n '{GP} +x' src/a.ts"),
85
+ ('a10 rg(場所を名指し)', f"rg -n '{GP} .*\\+' src"),
86
+ ('a11 探したあとに無害な命令', f"git grep -n -e '{GP} +x' -- src && git status"),
87
+ ]
88
+ for label, cmd in PASS:
89
+ check(label, decide(cmd), ALLOW)
90
+
91
+ # ═════════════════════════════════════════════════════════════════════════════
92
+ # (b) 止める(本物の push・探す言葉に見せかけた形)
93
+ # ═════════════════════════════════════════════════════════════════════════════
94
+ print('── (b) 本物の強い上書きの push は今までどおり止める ' + '─' * 16)
95
+ DANGER = [
96
+ ('b01 + の参照', f'{GP} origin +main'),
97
+ ('b02 + の参照(引用符)', f'{GP} origin "+main"'),
98
+ ('b03 --force', f'{GP} {FORCE} origin main'),
99
+ ('b04 -f', f'{GP} {SHORT} origin main'),
100
+ ('b05 --force-with-lease', f'{GP} {LEASE} origin main'),
101
+ ('b06 旗を末尾に', f'{GP} origin feat/x {FORCE}'),
102
+ ('b07 場所を指す旗つき', f'git -C {SITE} {PUSH} {FORCE} origin feat/x'),
103
+ ('b08 探したあとに ; で本物の push', f"git grep -n -e '{GP} +x' -- src; {GP} origin +main"),
104
+ ('b09 探したあとに && で本物の push', f"git grep -n -e 'x' -- src && {GP} {FORCE} origin main"),
105
+ ('b10 探したあとに | で本物の push', f"grep -rn '{GP} +x' src | {GP} {SHORT} origin main"),
106
+ ('b11 探す言葉に見せて後ろで push', f"git grep -n -e '{GP} {LEASE}' -- src; {GP} {LEASE} origin x"),
107
+ ('b12 包みの中', f'bash -c "{GP} {FORCE} origin main"'),
108
+ ('b13 包みの中の探す命令', f"bash -c \"git grep -n -e '{GP} +x' -- src\""),
109
+ ('b14 探す言葉の中の置き換えの実行', f'git grep -n -e "$({GP} {FORCE} origin main)" -- src'),
110
+ ('b15 探す言葉の中の逆引用符', f'git grep -n -e "`{GP} origin +main`" -- src'),
111
+ ('b16 git grep -O(別の命令を走らせる旗)', f"git grep -O'{GP} {FORCE} origin main' -e x -- src"),
112
+ ('b17 git grep --open-files-in-pager', f"git grep --open-files-in-pager='{GP} +main' -e x -- src"),
113
+ ('b18 rg --pre(別の命令を走らせる旗)', f"rg --pre '{GP} {FORCE}' x src"),
114
+ ('b19 探す言葉の外の push の字', f"git grep -n -e 'x' -- src {GP} {FORCE}"),
115
+ ('b20 ヒアドキュメントの本文', f"cat <<'EOF'\n{GP} {FORCE} origin main\nEOF"),
116
+ ('b21 echo の文字(探す道具でない)', f"echo '{GP} {FORCE} origin main'"),
117
+ ]
118
+ for label, cmd in DANGER:
119
+ check(label, decide(cmd).startswith('deny:danger'), True)
120
+
121
+ # ═════════════════════════════════════════════════════════════════════════════
122
+ # (c) rm のときの直し(便 915694ac)も今までどおり
123
+ # ═════════════════════════════════════════════════════════════════════════════
124
+ print('── (c) rm の直しも今までどおり ' + '─' * 36)
125
+ check('c01 探す言葉の中の rm は通る',
126
+ policy.decide_bash(f"git grep -n '{RM} -rf .git' -- skills docs")['decision'], policy.ALLOW)
127
+ check('c02 探したあとに本物の rm は止まる',
128
+ policy.decide_bash(f"grep -rn '{RM} -rf .git' docs; {RM} -rf .git")['decision'], policy.DENY)
129
+ check('c03 字面の判定は command を渡さなければ今までどおり当たる',
130
+ policy._danger_patterns(CMD_311545FE.lower()), 'force push')
131
+
132
+ # ═════════════════════════════════════════════════════════════════════════════
133
+ # (d) 空振り確認(試験の中で免じる所を外す)
134
+ # ═════════════════════════════════════════════════════════════════════════════
135
+ print('── (d) 空振り確認 ' + '─' * 48)
136
+ _real = policy._push_only_in_search_words
137
+ policy._push_only_in_search_words = lambda command: False # 免じる所を外す
138
+ check('d1 外すと便 311545fe の命令が止まる', decide(CMD_311545FE), 'deny:danger')
139
+ check('d2 外すと便 40fc68ed の命令が止まる', decide(CMD_40FC68ED), 'deny:danger')
140
+ policy._push_only_in_search_words = _real
141
+ check('d3 戻すと通る', decide(CMD_311545FE), ALLOW)
142
+
143
+ shutil.rmtree(ROOT, ignore_errors=True)
144
+ check('z1 作り物を片付けた', os.path.exists(ROOT), False)
145
+
146
+ print()
147
+ if failures:
148
+ print(f'NG {len(failures)} 件')
149
+ for f in failures:
150
+ print(f' - {f}')
151
+ sys.exit(1)
152
+ print('すべて期待どおり')
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env python3
2
+ """探す言葉の中の rm の字の免じ方に、別の命令を走らせる旗の除外を入れた検査(便 f599daa0)。
3
+
4
+ 実行: python3 scripts/hooks/test_search_word_rm_exec.py
5
+ 1件でも期待と違えば exit 1。
6
+
7
+ 【なぜ要るか(便 f599daa0 で実測)】
8
+ push の字の免じ方(便 b6410117)には「探す道具に別の命令を走らせる旗があれば免じない」除外が
9
+ 在ったが、rm の字の免じ方(便 915694ac・_rm_only_in_search_words)には無かった。
10
+ 直す前は `git grep -O'<rm の字>' -e x -- src`・`rg --pre '<rm の字>' x src` などが allow だった
11
+ (-O・--pre は引用符の中の字を命令として走らせる)。push と同じ除外を共通の部品
12
+ (_search_words_stay_words)にまとめて、rm の側にも掛けた。
13
+
14
+ 【ここで固定すること】
15
+ (a) 止める(danger)… 旗つきの rm の検索(-O・まとめ書きの -nO・--open-files-in-pager・--pre・
16
+ --pre=・--pager・--filter)
17
+ (b) 通る … 旗の無い読むだけの検索の rm の字(今までどおり)
18
+ (c) push の側も今までどおり(旗つきは止まる・旗なしは通る)
19
+ (d) 空振り確認(旗の除外を外すと (a) が通ってしまう)
20
+ ★この台本は危険語・秘密の形の名前を素の字で置かない(組み立てて使う)。既存の作法どおり。
21
+ """
22
+ import os
23
+ import shutil
24
+ import sys
25
+ import tempfile
26
+
27
+ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
28
+
29
+ import policy # noqa: E402
30
+
31
+ failures = []
32
+
33
+
34
+ def check(label, got, want):
35
+ ok = got == want
36
+ if not ok:
37
+ failures.append(f'{label}: got={got!r} want={want!r}')
38
+ print(f'{"OK " if ok else "NG "} {label:64} {str(got)[:40]}')
39
+
40
+
41
+ # ── 部品(危険語を直接書かない) ──
42
+ RM = 'r' + 'm'
43
+ RF = RM + ' -rf .git'
44
+ GP = 'git ' + 'pu' + 'sh'
45
+ FORCE = '--for' + 'ce'
46
+ NPMRC = '.npm' + 'rc'
47
+
48
+ # ── 使い捨ての作り物(作業場所の根に秘密の形のファイルを置く=実地と同じ形)──────
49
+ ROOT = tempfile.mkdtemp(prefix='search-word-rm-exec-')
50
+ SITE = os.path.join(ROOT, 'site')
51
+ for d in ('src', 'skills', 'docs'):
52
+ os.makedirs(os.path.join(SITE, d))
53
+ with open(os.path.join(SITE, NPMRC), 'w') as f:
54
+ f.write('DUMMY=placeholder\n')
55
+
56
+
57
+ def decide(cmd):
58
+ r = policy.decide_bash(cmd, SITE)
59
+ return r['decision'] + ':' + r['reason'].split(':', 1)[0]
60
+
61
+
62
+ ALLOW = 'allow:no gate, no danger'
63
+
64
+ # ═════════════════════════════════════════════════════════════════════════════
65
+ # (a) 止める(別の命令を走らせる旗つきの rm の検索)
66
+ # ═════════════════════════════════════════════════════════════════════════════
67
+ print('── (a) 旗つきの rm の検索は止める ' + '─' * 32)
68
+ EXEC = [
69
+ ('a01 git grep -O', f"git grep -O'{RF}' -e x -- src"),
70
+ ('a02 git grep -nO(まとめ書き)', f"git grep -nO'{RF}' -e x -- src"),
71
+ ('a03 git grep --open-files-in-pager=', f"git grep --open-files-in-pager='{RF}' -e x -- src"),
72
+ ('a04 rg --pre', f"rg --pre '{RF}' x src"),
73
+ ('a05 rg --pre=', f"rg --pre='{RF}' x src"),
74
+ ('a06 ag --pager', f"ag --pager '{RF}' x src"),
75
+ ('a07 ugrep --filter=', f"ugrep --filter='*:{RF}' x src"),
76
+ ]
77
+ for label, cmd in EXEC:
78
+ check(label, decide(cmd).startswith('deny:danger'), True)
79
+ check(label + '(免じない)', policy._rm_only_in_search_words(cmd), False)
80
+
81
+ # ═════════════════════════════════════════════════════════════════════════════
82
+ # (b) 通る(旗の無い読むだけの検索の rm の字)
83
+ # ═════════════════════════════════════════════════════════════════════════════
84
+ print('── (b) 旗の無い検索の rm の字は今までどおり通る ' + '─' * 18)
85
+ PASS = [
86
+ ('b01 git grep -n', f"git grep -n '{RF}' -- skills docs"),
87
+ ('b02 git grep -n -e', f"git grep -n -e '{RF}' -- src"),
88
+ ('b03 grep -rn(場所を名指し)', f"grep -rn '{RF}' skills"),
89
+ ('b04 rg -n', f"rg -n '{RF}' docs"),
90
+ ('b05 grep -rn の探す言葉に $HOME', f'grep -rn "{RM} -rf $HOME" docs'),
91
+ ('b06 git grep -i(O を含まない短い旗)', f"git grep -i -e '{RF}' -- src"),
92
+ ]
93
+ for label, cmd in PASS:
94
+ check(label, decide(cmd), ALLOW)
95
+
96
+ # ═════════════════════════════════════════════════════════════════════════════
97
+ # (c) push の側も今までどおり
98
+ # ═════════════════════════════════════════════════════════════════════════════
99
+ print('── (c) push の側も今までどおり ' + '─' * 36)
100
+ check('c01 旗なしの push の字は通る', decide(f"git grep -n -e '{GP} {FORCE}' -- src"), ALLOW)
101
+ check('c02 git grep -O の push の字は止まる',
102
+ decide(f"git grep -O'{GP} {FORCE} origin main' -e x -- src").startswith('deny:danger'), True)
103
+ check('c03 rg --pre の push の字は止まる',
104
+ decide(f"rg --pre '{GP} {FORCE}' x src").startswith('deny:danger'), True)
105
+
106
+ # ═════════════════════════════════════════════════════════════════════════════
107
+ # (d) 空振り確認(試験の中で旗の除外を外す)
108
+ # ═════════════════════════════════════════════════════════════════════════════
109
+ print('── (d) 空振り確認 ' + '─' * 48)
110
+ _real = policy._search_runs_command
111
+ policy._search_runs_command = lambda toks: False # 旗の除外を外す
112
+ check('d1 外すと git grep -O の rm の検索が通ってしまう', decide(EXEC[0][1]), ALLOW)
113
+ check('d2 外すと rg --pre の rm の検索が通ってしまう', decide(EXEC[3][1]), ALLOW)
114
+ policy._search_runs_command = _real
115
+ check('d3 戻すと止まる', decide(EXEC[0][1]).startswith('deny:danger'), True)
116
+
117
+ shutil.rmtree(ROOT, ignore_errors=True)
118
+ check('z1 作り物を片付けた', os.path.exists(ROOT), False)
119
+
120
+ print()
121
+ if failures:
122
+ print(f'NG {len(failures)} 件')
123
+ for f in failures:
124
+ print(f' - {f}')
125
+ sys.exit(1)
126
+ print('すべて期待どおり')
@@ -296,6 +296,7 @@ description: 采配くんの便(プロンプト末尾に CONDUCTOR_JOB:<id>
296
296
  - **行き先のブランチを確かめられない `git push`**(作業場所が変数のままの `git -C "$DIR" push`・`git push` とだけ打つ形・保護ブランチを狙う形)→ 止まる。**リポの中で、ブランチを名指しして** `git push origin <作業ブランチ名>`(★`-u` は付けない=鉄則7-⓪。上流の設定を書くと、囲いが `.git/config` を塞いでいるPCで止まる)。
297
297
  - ★**止まるのは「行き先が分からない形」と「保護ブランチを狙う形」**(実測 便 6e8d85e6)。場所を指す旗を付けても枝を名指しした形(`git -C <場所> push origin <作業ブランチ名>`)は止まらないので、「場所を指す旗が付いているか」で安全を判断しない。
298
298
  - ★**強い上書き(`--force`/`-f`/`--force-with-lease`/先頭が `+` の参照指定)は、旗の位置を問わず止まる。** 旗を末尾や中間に置く形・短い旗をまとめた形(`-fu`)・`git` と `push` の間に場所や設定を指す旗を挟む形・`+` を引用符で囲う形・つないだ行や包みの中に書いた形も、すべて止まる(便 e619bd86 で語の並びを見る判定に替えた。それまでは挟む形と引用符で囲う形が素通りしていた=実地 便 6e8d85e6)。**そもそも強い上書きは打たない**(便の本文の「force-push と reset はしない」)。
299
+ - ★**探すだけの道具の「探す言葉」に強い上書きの push の字を書いても、もう止まらない**(便 b6410117 で直した・rm のとき=便 915694ac と同じ直し)。禁止の一覧の行を調べる `git grep -n -e '<push の字と + の参照>' -- .claude/settings.json` は通る。★囲みの外に書いた push は今までどおり測るので、探した後ろにつないだ本物の push・包みの中・探す言葉の中の `$(…)`・別の命令を走らせる旗(`git grep -O`・`rg --pre` など)は止まる。
299
300
 
300
301
  ## 途中で止まらない書き方(全便の共通の型)
301
302