@chrono-meta/fh-gate 3.12.0 → 3.13.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fh-qp",
3
- "version": "3.12.0",
3
+ "version": "3.13.0",
4
4
  "engines": {
5
5
  "claudeCode": ">=1.0.0"
6
6
  },
@@ -0,0 +1,283 @@
1
+ #!/usr/bin/env bash
2
+ # outbound_pr_gate.sh — PreToolUse(Bash): a PR about to be OPENED on a repo we do not own.
3
+ #
4
+ # THE DEFECT (measured, outbound corpus to non-owned repos, 2026-06-20..09-18)
5
+ # Counted by outcome: 4 merged · 1 declined-on-SCOPE (we were right — no defect to fix) ·
6
+ # 1 closed-on-DEFECT · 2 CHANGES_REQUESTED · 1 awaiting. THREE carry a technical-defect
7
+ # finding, and all three are ONE shape: our guard and our test ran on OUR MODEL of the target,
8
+ # and the maintainer's evidence was an execution we had never run.
9
+ # tt-a1i/archify#328 a pre-write source-hash check "cannot catch damage caused by
10
+ # the write itself" (destination symlinked to the input).
11
+ # clawd-on-desk#1025 the test asserted attribute removal and then called the
12
+ # next-stage handler SYNCHRONOUSLY, so the IPC round-trip that IS
13
+ # the regression window did not exist in the test at all.
14
+ # clawd-on-desk#1021 "every exception fixture contains only one effective
15
+ # destructive decision, so they cannot detect this composition
16
+ # failure" — the maintainer's own words for why our suite was
17
+ # green while 13 of 16 composed commands auto-allowed.
18
+ # All three were submitted after a STATIC read of the target.
19
+ # `[[feedback_fixture_shape_from_artifact_not_mental_model]]` (N>=6 across repos/languages).
20
+ #
21
+ # WHY A HOOK AND NOT PROSE
22
+ # CLAUDE.md §Skeleton-Not-Muscle already scopes "code contributed upstream to someone else's
23
+ # repo", and §7's `standpoint:` enum already has the rung that separates the two outcomes
24
+ # (#888 merged exactly-as-submitted ran the consumer path; #1025 read it). The rule exists and
25
+ # was NOT wired. Measured precedent for why prose is not the fix: the same rule as a CLAUDE.md
26
+ # table row fired 1/15 at floor tier; as a PreToolUse hook, 9/9 (proposal_hook r3/r4).
27
+ #
28
+ # WHY *THIS* SURFACE AND NOT pre-commit
29
+ # An outbound PR is authored in the TARGET's clone and committed under the TARGET's hooks.
30
+ # forge-harness' pre-commit/pre-push are structurally not on that path — no FH commit occurs.
31
+ # `gh pr create` IS the outbound executor, and PreToolUse is the only place that sits on it
32
+ # ([[feedback_instrument_not_on_the_path]], same reasoning as outbound_query_hook's).
33
+ #
34
+ # DEGRADE DIRECTION — split by what we could ESTABLISH, and the split is the design
35
+ # target positively NON-OWNED -> DENY (exit 2). Opening a PR on a stranger's repo is
36
+ # publish-class: CLAUDE.md §Autonomous-Initiative already lists
37
+ # "opening/updating a PR" as publish intent, and
38
+ # §Irreversibility Gates says that surface fails CLOSED.
39
+ # target positively OWNED -> silent. FH's own PRs must never be touched; a gate that
40
+ # blocks every internal PR is a bypass trainer.
41
+ # applicability UNDETERMINED -> ADVISORY, never deny. We have not established that we are on
42
+ # the protected surface at all, and denying here would block
43
+ # every bare `gh pr create`. NAMED RECALL RESIDUAL: an external
44
+ # PR opened from an already-`cd`-ed shell with no -R and no cwd
45
+ # in the payload gets an advisory that arrives on the next turn,
46
+ # i.e. after the PR is open. That residue is swept post-hoc by
47
+ # session_close_check.sh ①-b (cross-repo + reviewDecision).
48
+ # instrument incomplete on a
49
+ # NON-OWNED target -> DENY. NOT SCANNED is not clean.
50
+ # not an FH checkout -> silent (mechanical: is the tracked anchor file here?).
51
+ #
52
+ # WHAT IT CHECKS — the RECORD's shape, never the claim's truth (§Mechanization Boundary)
53
+ # A record file tracks/_meta/outbound_pr_<TODAY>_<slug>.md carrying three typed lines:
54
+ # standpoint: tier2(<repo>) — ran `<cmd>` there, output: <what you saw>
55
+ # generated-path: none-found(<the generator grep you ran>) | found(<path> -> <generator>)
56
+ # fixture-carries: asserted(<cmd>, <what you saw>) | not-applicable(<grounds>)
57
+ # `standpoint:` is the EXISTING closed enum (CLAUDE.md §7). This gate applies an ALLOW-LIST of
58
+ # its strong rungs — tier2 / tier2b / tier3 — so tier1, tier1b, not-applicable, UNKNOWN, every
59
+ # DEGRADED_*, and ANY FUTURE MEMBER block by default. Default-deny on an unknown value is the
60
+ # same contract validate_standpoint_leg() uses; lane L8 fails if a new enum member is added
61
+ # without being classified here.
62
+ # `generated-path:` closes archify#328② (editing a build OUTPUT: the canon is the generator's
63
+ # input). NONE FOUND is printed as UNPROVEN, never as safe.
64
+ # `fixture-carries:` closes archify#328①, clawd#1025③④ AND clawd#1021 — all three are ONE
65
+ # proposition: "the fixture never put the system into the state where the defect is
66
+ # OBSERVABLE." Three spellings measured so far, all from our own closed/blocked PRs:
67
+ # A the destination was never a symlink to the input, so a pre-write hash check could not
68
+ # see the damage the write itself caused (archify#328①)
69
+ # B the IPC round-trip never existed in the test, because the next-stage handler was called
70
+ # synchronously, so the transition window was not in the fixture at all (clawd#1025③④)
71
+ # C every exception fixture carried exactly ONE effective destructive decision, so a
72
+ # first-match-only evaluator could not be told from an all-match one (clawd#1021 —
73
+ # maintainer's own words, and reproduced by the governor: 13 of 16 composed commands
74
+ # AUTO-ALLOW, e.g. `npm publish --dry-run && rm -rf /`, with live controls `ls -la`→null
75
+ # and `rm -rf /`→HOLD)
76
+ # ONE FIELD, NOT ONE PER DEFECT. A fourth spelling lands as a fourth bullet in the deny text —
77
+ # zero enum change, zero lane change. Growing the FIELD set one-per-defect is how a gate turns
78
+ # into a form: with `not-applicable` available, a field that is almost always not-applicable
79
+ # trains rubber-stamping (measured in this repo's own standpoint corpus: 6 bare
80
+ # `not-applicable`). 🟥 NAMED RESIDUAL of folding: a session can answer spelling A and never
81
+ # consider C, and the gate is satisfied. Closing that would need a grounds-vocabulary grep,
82
+ # i.e. a frozen judgment about what an adequate answer sounds like — deliberately not built.
83
+ # It is a FIELD and not a detector on purpose: a grep for "next-stage handler called on the
84
+ # following line" asserts a CONCLUSION about test adequacy.
85
+ #
86
+ # 🟥 SELF-ATTESTED, AND THAT IS THE INTENDED RESIDUE. This blocks the record's FORM (present,
87
+ # typed, attributable, non-vacuous), never whether the run was real — the same boundary the
88
+ # crossfamily/standpoint/thirdparty commit lanes already live on.
89
+ #
90
+ # Override, recorded by construction: put FH_OUTBOUND_PR_OK=1 in the command itself. The hook
91
+ # reads the COMMAND STRING (an env var exported in the session is not in the hook's env), so
92
+ # the override lands in the transcript, and the PR it lets out is itself swept by ①-b.
93
+ #
94
+ # Ownership discriminator — CALIBRATED, offline, zero network (2026-09-18, this machine):
95
+ # a clone of a repo we do not own carries an `upstream` remote under a foreign owner.
96
+ # ~/projects/archify upstream tt-a1i/archify -> NON-OWNED (known-pos)
97
+ # ~/projects/clawd-on-desk upstream rullerzhou-afk/clawd-on-desk-> NON-OWNED (known-pos)
98
+ # ~/projects/forge-harness no upstream -> OWNED (known-neg)
99
+ # ~/projects/qasp-dev no upstream (has ghe/tst) -> OWNED (known-neg)
100
+ # Both directions separate, so the discriminator measures rather than generates.
101
+ #
102
+ # Usage: hook: PreToolUse matcher "Bash" -> bash scripts/outbound_pr_gate.sh
103
+ # test: printf '%s' '<json>' | bash scripts/outbound_pr_gate.sh
104
+ # Lanes: bash scripts/test_outbound_pr_gate_lanes.sh
105
+ set -uo pipefail
106
+
107
+ SELF_DIR="$(cd "$(dirname "$0")" && pwd)"
108
+ FH="${CLAUDE_PROJECT_DIR:-}"
109
+ [ -n "$FH" ] || FH="$(cd "$SELF_DIR/.." && pwd)"
110
+ # Applicability of the whole hook: only inside an FH checkout. Mechanical, never self-judged —
111
+ # same test shape as outbound_query_hook's (a tracked anchor that only this repo ships).
112
+ ANCHOR="${FH_OUTBOUND_ANCHOR:-$FH/scripts/session_close_check.sh}"
113
+ [ -f "$ANCHOR" ] || exit 0
114
+
115
+ TODAY="${FH_OUTBOUND_TODAY:-$(date +%Y-%m-%d)}"
116
+ RECDIR="${FH_OUTBOUND_RECDIR:-$FH/tracks/_meta}"
117
+
118
+ # ── read the payload ──────────────────────────────────────────────────────────────────────────
119
+ # python3 is used ONLY to parse. The DENY path below needs no interpreter (exit 2 + stderr), so a
120
+ # dead python3 cannot silently unblock this surface — it makes us read nothing and exit 0, which
121
+ # is the one documented fail-open and is identical to the hook not being wired at all.
122
+ RAW=$(cat)
123
+ PARSED=$(printf '%s' "$RAW" | python3 -c '
124
+ import json,sys
125
+ try: d=json.load(sys.stdin)
126
+ except Exception: sys.exit(0)
127
+ if not isinstance(d,dict) or d.get("tool_name")!="Bash": sys.exit(0)
128
+ ti=d.get("tool_input") or {}
129
+ cmd=(ti.get("command") if isinstance(ti,dict) else str(ti)) or ""
130
+ cwd=str(d.get("cwd") or "")
131
+ sys.stdout.buffer.write(("CWD\t"+cwd.replace("\t"," ").replace("\n"," ")+"\n").encode("utf-8"))
132
+ sys.stdout.buffer.write(("CMD\t"+cmd.replace("\t"," ").replace("\n","; ")+"\n").encode("utf-8"))
133
+ ' 2>/dev/null) || exit 0
134
+ [ -n "$PARSED" ] || exit 0
135
+ PAY_CWD=$(printf '%s\n' "$PARSED" | sed -n 's/^CWD\t//p' | head -1)
136
+ CMD=$(printf '%s\n' "$PARSED" | sed -n 's/^CMD\t//p' | head -1)
137
+ [ -n "$CMD" ] || exit 0
138
+
139
+ # ── is this the outbound act? ─────────────────────────────────────────────────────────────────
140
+ # create / reopen / ready: the three ways a PR is put in front of a stranger. `gh pr edit --body`
141
+ # is publish per CLAUDE.md too and is a NAMED GAP here, not a claimed coverage.
142
+ # 🟥 cross-family (codex, 2026-09-18) 이 트리거를 공격했고, **주장 7건 중 5건은 실측에서 틀렸다** —
143
+ # `command gh` · `env X=1 gh` · `time gh` · `noglob gh` · `gh pr create --repo 'o/r'` 는 종전 식으로도
144
+ # 전부 잡힌다(선행 문자가 공백이므로). 실제로 안 잡히던 것은 셋이고, 그중 둘을 여기서 닫는다:
145
+ # ⓐ 경로 형태 `/opt/homebrew/bin/gh pr create` · `./gh pr create` → `([^ ;&|]*/)?` 추가
146
+ # ⓑ 인용 안쪽 `sh -c 'gh pr create …'` → 선행 문자류에 ' " ` 추가
147
+ # 🟥 셋째는 **정규식으로 닫히지 않는다**: 변수 간접(`GH_CMD=gh; $GH_CMD pr create`) · 셸 alias ·
148
+ # gh 를 감싼 스크립트. 이름으로 남긴 잔여이고, 이 훅은 그래서 «상기시키는 층» 이지 floor 가 아니다.
149
+ # ⚠️ 알려진 과차단 하나: `echo gh pr create` 도 잡힌다. 과차단 방향이라 그대로 둔다
150
+ # (막는 쪽으로 틀리는 것이 이 표면에서 옳다).
151
+ printf '%s' "$CMD" | LC_ALL=C grep -qE '(^|[ ;&|('"'"'"`])([^ ;&|]*/)?gh +([^ ;&|]+ +)*pr +(create|reopen|ready)([ ;&|]|$)' || exit 0
152
+
153
+ # ── owned-owner set ───────────────────────────────────────────────────────────────────────────
154
+ OWNERS=""
155
+ _origin=$(git -C "$FH" remote get-url origin 2>/dev/null || true)
156
+ _o=$(printf '%s' "$_origin" | sed -E 's#^.*[/:]([^/:]+)/[^/]+$#\1#')
157
+ [ -n "$_o" ] && [ "$_o" != "$_origin" ] && OWNERS="$_o"
158
+ # Optional operator layer; absent by construction in a consumer install.
159
+ OWNFILE="${FH_OWNED_OWNERS_FILE:-$FH/.claude/rules/.owned-owners}"
160
+ [ -f "$OWNFILE" ] && OWNERS="$OWNERS
161
+ $(grep -vE '^[[:space:]]*(#|$)' "$OWNFILE" 2>/dev/null || true)"
162
+
163
+ _is_owned() { # $1 = owner login
164
+ [ -n "${1:-}" ] || return 1
165
+ printf '%s\n' "$OWNERS" | grep -qxF "$1"
166
+ }
167
+
168
+ # A clone's BASE repo, as `gh pr create` resolves it: the fork parent (`upstream`) when the clone
169
+ # is a fork, otherwise `origin` itself. Reading only `upstream` would call a DIRECT clone of a
170
+ # foreign repo "ours" — that is the same not-found-is-not-zero face this repo keeps meeting.
171
+ _base_repo_of() { # $1 = a directory; echoes "owner/repo", or nothing
172
+ local d="$1" u r
173
+ [ -n "$d" ] && [ -d "$d" ] || return 1
174
+ git -C "$d" rev-parse --git-dir >/dev/null 2>&1 || return 1
175
+ u=$(git -C "$d" remote get-url upstream 2>/dev/null)
176
+ [ -n "$u" ] || u=$(git -C "$d" remote get-url origin 2>/dev/null)
177
+ [ -n "$u" ] || return 1
178
+ r=$(printf '%s' "$u" | sed -E 's#\.git$##; s#^.*[/:]([^/:]+/[^/:]+)$#\1#')
179
+ case "$r" in */*) printf '%s' "$r" ;; *) return 1 ;; esac
180
+ }
181
+
182
+ # ── resolve the target, first hit wins ────────────────────────────────────────────────────────
183
+ TARGET=""; OWNER=""; HOW=""
184
+ _spec=$(printf '%s' "$CMD" | LC_ALL=C grep -oE '(^|[ ;&|])(-R|--repo)[= ]+[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+' | head -1 \
185
+ | sed -E 's#.*[= ]([A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+)$#\1#')
186
+ if [ -n "$_spec" ]; then
187
+ TARGET="$_spec"; OWNER="${_spec%%/*}"; HOW="-R/--repo in the command"
188
+ else
189
+ _cd=$(printf '%s' "$CMD" | LC_ALL=C grep -oE '(^|[ ;&|])cd +[^ ;&|]+' | head -1 | sed -E 's#.*cd +##')
190
+ for _d in "$_cd" "$PAY_CWD"; do
191
+ [ -n "$_d" ] || continue
192
+ if _b=$(_base_repo_of "$_d"); then
193
+ TARGET="$_b"; OWNER="${_b%%/*}"; HOW="base repo of $_d (upstream, else origin)"; break
194
+ fi
195
+ done
196
+ fi
197
+
198
+ if [ -z "$OWNER" ]; then
199
+ VERDICT="UNDETERMINED"
200
+ elif _is_owned "$OWNER"; then
201
+ exit 0 # positively ours — silent, always
202
+ else
203
+ VERDICT="NON-OWNED"
204
+ fi
205
+
206
+ # ── record check (only reached on NON-OWNED / UNDETERMINED) ───────────────────────────────────
207
+ # Grounds bar is 20 chars, deliberately the SAME number validate_standpoint_leg() uses — one bar,
208
+ # not a second one that drifts.
209
+ STRONG_RUNGS="tier2 tier2b tier3"
210
+ WEAK_RUNGS="tier1 tier1b not-applicable UNKNOWN DEGRADED_NO_TARGET_ACCESS DEGRADED_NOT_RUN"
211
+ REASONS=""
212
+ _add() { REASONS="${REASONS} - $1
213
+ "; }
214
+
215
+ _field() { # $1 = field name; echoes the value line or nothing
216
+ ls -1 "$RECDIR"/outbound_pr_"$TODAY"_*.md 2>/dev/null | while read -r f; do
217
+ grep -m1 -E "^[[:space:]]*$1:" "$f" 2>/dev/null
218
+ done | head -1
219
+ }
220
+ _records=$(ls -1 "$RECDIR"/outbound_pr_"$TODAY"_*.md 2>/dev/null | wc -l | tr -d ' ')
221
+
222
+ if [ "${_records:-0}" -eq 0 ]; then
223
+ _add "no record: expected $RECDIR/outbound_pr_${TODAY}_<slug>.md — none exists."
224
+ else
225
+ _sp=$(_field standpoint); _sp=${_sp#*:}
226
+ _spv=$(printf '%s' "$_sp" | sed -E 's/^[[:space:]]*//; s/[[:space:]]*(—|--).*$//; s/[[:space:]]+$//; s/^["'"'"']//')
227
+ _spg=$(printf '%s' "$_sp" | sed -E 's/^[^—-]*((—|--)[[:space:]]*)?//')
228
+ case "$_spv" in
229
+ tier2\(*\)|tier2b\(*\)|tier3\(*\))
230
+ [ "${#_spg}" -lt 20 ] && _add "standpoint: $_spv — grounds do not name the command you ran and the output you saw." ;;
231
+ "") _add "standpoint: line absent from the record. The enum is CLAUDE.md §7; only $STRONG_RUNGS clear this gate." ;;
232
+ *) _add "standpoint: '$_spv' is not a strong rung. tier1b means you READ the target and ran nothing — that is the signal that it is NOT time to submit (clawd#1025 was exactly this). Strong rungs: $STRONG_RUNGS." ;;
233
+ esac
234
+ _gp=$(_field generated-path); _gp=${_gp#*:}
235
+ _gpv=$(printf '%s' "$_gp" | sed -E 's/^[[:space:]]*//; s/\(.*$//; s/[[:space:]]+$//')
236
+ _gpg=$(printf '%s' "$_gp" | sed -E 's/^[^(]*\(//; s/\)[[:space:]]*$//')
237
+ case "$_gpv" in
238
+ found|none-found) [ "${#_gpg}" -lt 20 ] && _add "generated-path: $_gpv() carries no grounds — name the generator grep you ran over the target repo." ;;
239
+ "") _add "generated-path: line absent. For every path this patch touches, grep the target's own generators (package.json scripts, *.mjs|*.js|*.sh that WRITE that path). A hit means the edit is in the wrong place — the canon is the generator's input (archify#328②). Absence is 'none-found', i.e. UNPROVEN, never 'safe'." ;;
240
+ *) _add "generated-path: '$_gpv' is not one of: found(...) | none-found(...)." ;;
241
+ esac
242
+ _ar=$(_field fixture-carries); _ar=${_ar#*:}
243
+ _arv=$(printf '%s' "$_ar" | sed -E 's/^[[:space:]]*//; s/\(.*$//; s/[[:space:]]+$//')
244
+ _arg=$(printf '%s' "$_ar" | sed -E 's/^[^(]*\(//; s/\)[[:space:]]*$//')
245
+ case "$_arv" in
246
+ asserted|not-applicable) [ "${#_arg}" -lt 20 ] && _add "fixture-carries: $_arv() carries no grounds." ;;
247
+ "") _add "fixture-carries: line absent. The fixture must put the system into the state where the defect is OBSERVABLE; three spellings measured in our own closed PRs — (A) destination pre-made as a symlink to the input, assert the INPUT's post-state [archify#328]; (B) assert INSIDE the async window, do not call the next-stage handler synchronously [clawd#1025]; (C) the input carries >=2 effective decisions with the FIRST one excepted, so a first-match-only evaluator is distinguishable [clawd#1021]. Answer whichever applies, and name the run. Values: asserted(<cmd>, <what you saw>) | not-applicable(<grounds>)." ;;
248
+ DEGRADED_NOT_RUN) _add "fixture-carries: DEGRADED_NOT_RUN — 'did not run it' is an honest record and it is also the answer 'not yet ready to submit'. Run it, or record not-applicable(<grounds>)." ;;
249
+ *) _add "fixture-carries: '$_arv' is not one of: asserted(...) | not-applicable(...) | DEGRADED_NOT_RUN(...)." ;;
250
+ esac
251
+ fi
252
+
253
+ # ── verdict ───────────────────────────────────────────────────────────────────────────────────
254
+ HDR="OUTBOUND-PR GATE — target $TARGET ($HOW)"
255
+ if [ "$VERDICT" = "UNDETERMINED" ]; then
256
+ [ -n "$REASONS" ] || exit 0
257
+ BODY=" ⚠️ OUTBOUND-PR GATE — could not establish whether this PR's base repo is ours.
258
+ Advisory only (denying here would block every bare \`gh pr create\`), and it reaches you on
259
+ the NEXT turn — the PR may already be open. If the base repo is NOT ours, the record is owed:
260
+ ${REASONS} Re-run with -R <owner>/<repo> to get a decided verdict instead of this one."
261
+ if json=$(printf '%s' "$BODY" | PYTHONIOENCODING=utf-8 python3 -c '
262
+ import json,sys
263
+ h=sys.stdin.read()
264
+ print(json.dumps({"systemMessage":h,"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":h}}))
265
+ ' 2>/dev/null) && [ -n "$json" ]; then printf '%s\n' "$json"; exit 0; fi
266
+ printf '%s\n' "$BODY" >&2
267
+ exit 0
268
+ fi
269
+
270
+ # NON-OWNED from here down.
271
+ if printf '%s' "$CMD" | LC_ALL=C grep -qE 'FH_OUTBOUND_PR_OK=1'; then
272
+ printf '%s\n' " ⚠️ $HDR — FH_OUTBOUND_PR_OK=1 in the command: gate acknowledged, not satisfied." >&2
273
+ exit 0
274
+ fi
275
+ [ -n "$REASONS" ] || exit 0
276
+ printf '%s\n' " ❌ $HDR
277
+ A PR on a repo we do not own is publish-class and this gate fails CLOSED.
278
+ Owed, in $RECDIR/outbound_pr_${TODAY}_<slug>.md:
279
+ ${REASONS} Three of our outbound PRs carry a technical-defect finding (#1025 closed, #328 and #1021
280
+ changes-requested) and all three were submitted after a STATIC read of the target. This gate
281
+ blocks the RECORD's shape, never the truth of the run.
282
+ Deliberate and reviewed -> prefix the command with FH_OUTBOUND_PR_OK=1." >&2
283
+ exit 2
@@ -316,6 +316,16 @@ ACCEPTED_ABSENT=(
316
316
  # runner (labelled hub-local at the reference), which is a pointer for contributors, not a promise
317
317
  # of a shipped artifact — the skill's own save path works without it.
318
318
  "scripts/frontier_digest_daily.sh"
319
+ # 🟥 2026-09-18 — 발행 «확인» 3종. 이 레포 자기 릴리스 파이프라인의 부품이고 소비자 호출부가 없다.
320
+ # `publish_verify_poll.sh` 는 `.github/workflows/publish.yml` 의 verify 단계가 유일한 호출부이고,
321
+ # 워크플로 자체가 출하되지 않는다. 소비자는 `@chrono-meta/fh-gate` 를 발행하지 않으므로
322
+ # 이 스크립트를 부를 이유가 구조적으로 없다(PKG_NAME 으로 매개화돼 있긴 하다 — 그래서
323
+ # «불가능» 이 아니라 «호출부 부재» 라고 적는다).
324
+ # ⚠️ 그 결과 소비자 install 에서는 이 셋이 없고, selfcheck 의 해당 레인은 SKIP 으로 렌더된다.
325
+ # SKIP 은 PASS 가 아니다 — 이 레포에서는 레인이 실제로 돌고, 그것이 이 배선의 검증면이다.
326
+ "scripts/publish_verify_poll.sh"
327
+ "scripts/publish_verify_poll_stub_npm.sh"
328
+ "scripts/test_publish_verify_poll_lanes.sh"
319
329
  )
320
330
 
321
331
  # `--list-accepted`: print the ACCEPTED_ABSENT paths, one per line, and exit — no git/package.json
@@ -700,6 +700,10 @@ for _pair in \
700
700
  "scripts/map_postprocess.py|scripts/test_map_postprocess_lanes.sh" \
701
701
  `# ── 플로어 없는 채널(2026-09-14): 원격 자율 노드가 FH 자산을 바꾸면 마커가 tracks/ 와 함께 휘발한다. 실측 2/2(#675·#716). CI 가 gitignored 마커를 구조적으로 못 보므로, 그 채널에만 «마커가 커밋 기록에 실려 왔나» 를 건다 ──` \
702
702
  "scripts/remote_marker_gate.sh|scripts/test_remote_marker_gate_lanes.sh" \
703
+ `# ── 발신 전 3프로브(2026-09-18): 비소유 레포에 PR 을 «열기 직전» 에 건다. 실측 — outbound 9건 중 기술 결함 지적 3건이 전부 같은 형태다: 우리 가드와 우리 테스트가 «대상의 모형» 위에서 돌았고, 메인테이너의 증거는 우리가 한 번도 안 돌린 실행이었다 ──` \
704
+ "scripts/outbound_pr_gate.sh|scripts/test_outbound_pr_gate_lanes.sh" \
705
+ `# ── 발행 «확인» 예산(2026-09-18): npm publish 는 이미 rc=0 으로 끝났고 이 스크립트는 전파만 관측한다. 둘을 한 종료코드로 접으면 성공한 발행이 빨간 잡이 되고, 그 빨강이 정확히 «손 발행» 을 훈련시킨다(v3.2.0·v3.4.0) ──` \
706
+ "scripts/publish_verify_poll.sh|scripts/test_publish_verify_poll_lanes.sh" \
703
707
  ".github/workflows/validate.yml|scripts/test_remote_marker_gate_lanes.sh" \
704
708
  "templates/.git-hooks/pre-commit|scripts/test_precommit_staged_drift_lanes.sh" \
705
709
  "templates/.git-hooks/pre-commit|scripts/test_precommit_gitlink_lanes.sh" \
@@ -2014,6 +2018,41 @@ elif _ships_per_files "scripts/test_lane_runner_lanes.sh"; then
2014
2018
  fail=1
2015
2019
  fi
2016
2020
 
2021
+ # test_outbound_pr_gate_lanes.sh — 발신 전 3프로브의 앵커. 출하물이므로 파일이 있으면 무조건 돈다.
2022
+ # 🟥 배선을 같은 변경에서 한다: 실측 — 비소유 레포 outbound 9건 중 기술 결함 지적 3건이 전부 같은
2023
+ # 형태(우리 가드·테스트가 «대상의 모형» 위에서 돌았고 메인테이너의 증거는 우리가 한 번도 안 돌린
2024
+ # 실행)였고, 규칙은 CLAUDE.md 에 이미 있었으나 배선이 없었다. 산문으로 둔 채 올리면 그 1/15 를 반복한다.
2025
+ if [ -f scripts/test_outbound_pr_gate_lanes.sh ]; then
2026
+ if _out=$(bash scripts/test_outbound_pr_gate_lanes.sh 2>&1); then
2027
+ echo "PASS test_outbound_pr_gate_lanes.sh (trigger scoping · standpoint rung · enum class-closing · revert probe)"
2028
+ else
2029
+ echo "FAIL test_outbound_pr_gate_lanes.sh: the outbound-PR gate's verdicts have drifted"
2030
+ _show_failure "$_out"
2031
+ fail=1
2032
+ fi
2033
+ elif _ships_per_files "scripts/test_outbound_pr_gate_lanes.sh"; then
2034
+ echo "FAIL test_outbound_pr_gate_lanes.sh is DECLARED SHIPPED but absent — deletion or broken install"
2035
+ fail=1
2036
+ fi
2037
+
2038
+ # test_publish_verify_poll_lanes.sh — 발행 «확인» 예산의 앵커. 주체가 ACCEPTED_ABSENT(이 레포의
2039
+ # 릴리스 파이프라인 부품, 소비자 호출부 없음)이므로 소비자 install 에서는 파일이 없고 SKIP 이다.
2040
+ # 🟥 SKIP 은 PASS 가 아니다 — 이 레포에서 실제로 도는 것이 이 배선의 유일한 검증면이다.
2041
+ # 무엇을 지키나: 「전파 지연」과 「발행 실패」가 같은 종료코드로 접히지 않는 것. 접혔던 실측이
2042
+ # v3.12.0 이고, 그 빨강이 v3.2.0·v3.4.0 에서 손 발행을 훈련시켜 OIDC 경로를 깨뜨렸다.
2043
+ if [ -f scripts/test_publish_verify_poll_lanes.sh ]; then
2044
+ if _out=$(bash scripts/test_publish_verify_poll_lanes.sh 2>&1); then
2045
+ echo "PASS test_publish_verify_poll_lanes.sh (not_yet_visible != failure · instrument-error stays distinct · calibration)"
2046
+ else
2047
+ echo "FAIL test_publish_verify_poll_lanes.sh: propagation-lag and publish-failure have been conflated again"
2048
+ _show_failure "$_out"
2049
+ fail=1
2050
+ fi
2051
+ elif _ships_per_files "scripts/test_publish_verify_poll_lanes.sh"; then
2052
+ echo "FAIL test_publish_verify_poll_lanes.sh is DECLARED SHIPPED but absent — deletion or broken install"
2053
+ fail=1
2054
+ fi
2055
+
2017
2056
  # sync_from_be_lanes.sh — the RETURN path's anchor. Wired in the same change that ships it: the
2018
2057
  # script had an operator-side caller (a SessionStart hook outside this repo) while its 70 lanes had
2019
2058
  # NO caller anywhere, which is the shape this repo keeps re-finding — a transport that writes into
@@ -0,0 +1,214 @@
1
+ #!/usr/bin/env bash
2
+ # test_outbound_pr_gate_lanes.sh — known pairs for scripts/outbound_pr_gate.sh.
3
+ #
4
+ # Both directions on every axis: the applicability test (owned vs non-owned), the record test
5
+ # (strong rung vs weak rung, present vs absent, grounded vs vacuous), and the delivery test
6
+ # (deny = exit 2, advisory = exit 0 with output, silent = exit 0 with none).
7
+ # L8 is the CLASS-CLOSING arm: it reads the `standpoint:` closed enum out of
8
+ # templates/.git-hooks/pre-commit and fails if the gate classifies neither strong nor weak — so a
9
+ # new enum member cannot be added without deciding what it means on the outbound surface.
10
+ # L9 is the REVERT probe: neuter the strong-rung allow-list and L1 must go red.
11
+ set -uo pipefail
12
+ HERE="$(cd "$(dirname "$0")" && pwd)"
13
+ REPO="$(cd "$HERE/.." && pwd)"
14
+ GATE="$HERE/outbound_pr_gate.sh"
15
+ PRECOMMIT="${FH_PRECOMMIT_FILE:-$REPO/templates/.git-hooks/pre-commit}"
16
+ fail=0; n=0
17
+ TMP=$(mktemp -d) || { echo "FAIL mktemp"; exit 1; }
18
+ trap 'rm -rf "$TMP"' EXIT
19
+
20
+ # ── fixture world ─────────────────────────────────────────────────────────────────────────────
21
+ FHROOT="$TMP/fh"; mkdir -p "$FHROOT/scripts" "$FHROOT/tracks/_meta"
22
+ : > "$FHROOT/scripts/session_close_check.sh" # the applicability anchor
23
+ git init -q "$FHROOT" 2>/dev/null
24
+ git -C "$FHROOT" remote add origin https://github.com/ownerco/forge-harness.git 2>/dev/null
25
+ mkfork() { # $1 = dir, $2 = origin spec, $3 = upstream spec (empty = none)
26
+ mkdir -p "$1"; git init -q "$1" 2>/dev/null
27
+ git -C "$1" remote add origin "https://github.com/$2.git" 2>/dev/null
28
+ [ -n "${3:-}" ] && git -C "$1" remote add upstream "https://github.com/$3.git" 2>/dev/null
29
+ return 0
30
+ }
31
+ mkfork "$TMP/foreignfork" "ownerco/archify" "tt-a1i/archify" # fork of a repo we do NOT own
32
+ mkfork "$TMP/ourclone" "ownerco/forge-harness" "" # our own repo, no fork parent
33
+ mkfork "$TMP/directclone" "someoneelse/tool" "" # DIRECT clone of a foreign repo
34
+
35
+ TODAY="2026-01-01"
36
+ rec() { # $1 = standpoint value, $2 = generated-path, $3 = fixture-carries ("" = omit the line)
37
+ rm -f "$FHROOT/tracks/_meta"/outbound_pr_*.md
38
+ local f="$FHROOT/tracks/_meta/outbound_pr_${TODAY}_fixture.md"
39
+ : > "$f"
40
+ [ -n "${1:-}" ] && printf 'standpoint: %s\n' "$1" >> "$f"
41
+ [ -n "${2:-}" ] && printf 'generated-path: %s\n' "$2" >> "$f"
42
+ [ -n "${3:-}" ] && printf 'fixture-carries: %s\n' "$3" >> "$f"
43
+ return 0
44
+ }
45
+ FULL_SP='tier2(archify) — ran `node scripts/export.mjs` there, output: wrote 3 files, input intact'
46
+ FULL_GP='none-found(grepped package.json scripts and every *.mjs for a writer of that path)'
47
+ FULL_AR='asserted(`node t.mjs` with dest symlinked to the input, output: input bytes unchanged)'
48
+
49
+ run() { # $1 = label, $2 = expected verdict deny|advisory|silent, $3 = command string, $4 = cwd
50
+ n=$((n+1))
51
+ local out rc
52
+ out=$(printf '{"tool_name":"Bash","cwd":"%s","tool_input":{"command":"%s"}}' "${4:-}" "$3" \
53
+ | CLAUDE_PROJECT_DIR="$FHROOT" FH_OUTBOUND_TODAY="$TODAY" \
54
+ FH_OUTBOUND_RECDIR="$FHROOT/tracks/_meta" bash "$GATE" 2>&1); rc=$?
55
+ local got="silent"
56
+ [ "$rc" -eq 2 ] && got="deny"
57
+ [ "$rc" -eq 0 ] && [ -n "$out" ] && got="advisory"
58
+ if [ "$got" = "$2" ]; then
59
+ echo "PASS $1 ($got)"
60
+ else
61
+ echo "FAIL $1: expected $2, got $got (rc=$rc)"
62
+ printf '%s\n' "$out" | sed 's/^/ /' | head -6
63
+ fail=1
64
+ fi
65
+ }
66
+
67
+ # ── L1 known-POSITIVE: non-owned target, weak rung -> deny ────────────────────────────────────
68
+ rec 'tier1b(archify) — read their export path end to end' "$FULL_GP" "$FULL_AR"
69
+ run "L1 non-owned + standpoint tier1b" deny "gh pr create -R tt-a1i/archify --title x"
70
+
71
+ # ── L2 known-NEGATIVE: same target, full record -> silent ─────────────────────────────────────
72
+ rec "$FULL_SP" "$FULL_GP" "$FULL_AR"
73
+ run "L2 non-owned + full record" silent "gh pr create -R tt-a1i/archify --title x"
74
+
75
+ # ── L3 our own repo: never blocked, record or not ─────────────────────────────────────────────
76
+ rec "" "" ""
77
+ run "L3 owned target, no record" silent "gh pr create -R ownerco/forge-harness --title x"
78
+
79
+ # ── L4 applicability undetermined -> advisory, NEVER deny ─────────────────────────────────────
80
+ rec "" "" ""
81
+ run "L4 bare gh pr create, no cwd" advisory "gh pr create --title x"
82
+
83
+ # ── L5 not the outbound act ───────────────────────────────────────────────────────────────────
84
+ run "L5 unrelated command" silent "gh pr list --state open"
85
+ run "L5b gh pr merge is not create" silent "gh pr merge 12 --squash"
86
+
87
+ # ── L6 record absent entirely on a non-owned target ───────────────────────────────────────────
88
+ rec "" "" ""
89
+ run "L6 non-owned + no record at all" deny "gh pr create -R tt-a1i/archify --title x"
90
+
91
+ # ── L7 vacuous grounds ────────────────────────────────────────────────────────────────────────
92
+ rec "$FULL_SP" 'none-found()' "$FULL_AR"
93
+ run "L7 generated-path with empty grounds" deny "gh pr create -R tt-a1i/archify --title x"
94
+ rec 'tier2(archify) — looked' "$FULL_GP" "$FULL_AR"
95
+ run "L7b standpoint tier2 naming no execution" deny "gh pr create -R tt-a1i/archify --title x"
96
+
97
+ # ── L10 DEGRADED_NOT_RUN is an honest record AND a not-ready verdict ──────────────────────────
98
+ rec "$FULL_SP" "$FULL_GP" 'DEGRADED_NOT_RUN(no local chromium on this machine, nothing was run)'
99
+ run "L10 fixture-carries DEGRADED_NOT_RUN" deny "gh pr create -R tt-a1i/archify --title x"
100
+
101
+ # ── L10b spelling C (composition / first-match-only) is an accepted answer on the SAME field ──
102
+ # Rationale for folding rather than adding a 4th field is in the gate header. This lane pins that
103
+ # the C answer clears the gate, so the folding is real and not just documentation.
104
+ rec "$FULL_SP" "$FULL_GP" 'asserted(`node t.mjs "npm publish --dry-run && rm -rf /"` — 2 effective decisions, first excepted; saw hold:false, expected hold:true)'
105
+ run "L10b fixture-carries answered with spelling C" silent "gh pr create -R tt-a1i/archify --title x"
106
+
107
+ # ── L11 fork detection, both directions, via cwd (no -R in the command) ───────────────────────
108
+ rec 'tier1b(archify) — read only' "$FULL_GP" "$FULL_AR"
109
+ run "L11a cwd is a fork of a foreign repo" deny "gh pr create --title x" "$TMP/foreignfork"
110
+ run "L11b cwd is our own clone" silent "gh pr create --title x" "$TMP/ourclone"
111
+ run "L11c cwd is a DIRECT clone of a foreign repo" deny "gh pr create --title x" "$TMP/directclone"
112
+
113
+ # ── L12 override is acknowledged, recorded in the command, and does not satisfy ───────────────
114
+ rec "" "" ""
115
+ run "L12 FH_OUTBOUND_PR_OK=1 in the command" advisory "FH_OUTBOUND_PR_OK=1 gh pr create -R tt-a1i/archify --title x"
116
+
117
+ # ── L13 not an FH checkout -> silent, and we create nothing there ─────────────────────────────
118
+ n=$((n+1))
119
+ _out=$(printf '{"tool_name":"Bash","tool_input":{"command":"gh pr create -R tt-a1i/archify"}}' \
120
+ | CLAUDE_PROJECT_DIR="$TMP/notfh" FH_OUTBOUND_ANCHOR="$TMP/notfh/nope" bash "$GATE" 2>&1); _rc=$?
121
+ if [ "$_rc" -eq 0 ] && [ -z "$_out" ]; then echo "PASS L13 non-FH checkout is silent"
122
+ else echo "FAIL L13 non-FH checkout: rc=$_rc out='$_out'"; fail=1; fi
123
+
124
+ # ── L8 CLASS-CLOSING: every standpoint: enum member must be classified by this gate ───────────
125
+ n=$((n+1))
126
+ # Scope the read to validate_standpoint_leg()'s own body first — an unscoped grep for the enum
127
+ # text picked up three unrelated lines elsewhere in the hook and reported them as members
128
+ # (first run of this lane, 2026-09-18: the instrument had to be calibrated before it measured).
129
+ ENUM=$(awk '/^validate_standpoint_leg\(\)/{f=1} f&&/^}/{f=0} f' "$PRECOMMIT" 2>/dev/null \
130
+ | awk '/Closed enum:/{print; getline; print}' \
131
+ | tr '·' '\n' | sed -E 's/^[[:space:]]*echo[[:space:]]+"//; s/.*Closed enum:[[:space:]]*//; s/\(<h>\)//g; s/[^A-Za-z0-9_-]//g' \
132
+ | grep -E '^[A-Za-z]' | sort -u)
133
+ if [ -z "$ENUM" ]; then
134
+ echo "FAIL L8 INSTRUMENT ERROR — could not extract the standpoint enum from $PRECOMMIT"
135
+ fail=1
136
+ else
137
+ DECLARED=$( { grep -m1 '^STRONG_RUNGS=' "$GATE"; grep -m1 '^WEAK_RUNGS=' "$GATE"; } \
138
+ | sed -E 's/^[A-Z_]+="//; s/"$//' | tr ' ' '\n' | grep -E '^[A-Za-z]' | sort -u)
139
+ missing=$(comm -23 <(printf '%s\n' "$ENUM") <(printf '%s\n' "$DECLARED"))
140
+ if [ -n "$missing" ]; then
141
+ echo "FAIL L8 standpoint enum member(s) unclassified by outbound_pr_gate.sh:"
142
+ printf '%s\n' "$missing" | sed 's/^/ /'
143
+ echo " Classify each as STRONG_RUNGS (clears the outbound gate) or WEAK_RUNGS (blocks it)."
144
+ fail=1
145
+ else
146
+ echo "PASS L8 class-closing: all $(printf '%s\n' "$ENUM" | wc -l | tr -d ' ') enum members classified"
147
+ fi
148
+ fi
149
+
150
+ # ── L8b known-POSITIVE for the class-closing arm: add a member, L8's comparison must name it ──
151
+ n=$((n+1))
152
+ FAKEPC="$TMP/pre-commit-with-new-member"
153
+ sed -E 's/(Closed enum: tier1 )/\1· tier4(<h>) /' "$PRECOMMIT" > "$FAKEPC" 2>/dev/null
154
+ ENUM2=$(awk '/^validate_standpoint_leg\(\)/{f=1} f&&/^}/{f=0} f' "$FAKEPC" 2>/dev/null \
155
+ | awk '/Closed enum:/{print; getline; print}' \
156
+ | tr '·' '\n' | sed -E 's/^[[:space:]]*echo[[:space:]]+"//; s/.*Closed enum:[[:space:]]*//; s/\(<h>\)//g; s/[^A-Za-z0-9_-]//g' \
157
+ | grep -E '^[A-Za-z]' | sort -u)
158
+ DECLARED2=$( { grep -m1 '^STRONG_RUNGS=' "$GATE"; grep -m1 '^WEAK_RUNGS=' "$GATE"; } \
159
+ | sed -E 's/^[A-Z_]+="//; s/"$//' | tr ' ' '\n' | grep -E '^[A-Za-z]' | sort -u)
160
+ if printf '%s\n' "$(comm -23 <(printf '%s\n' "$ENUM2") <(printf '%s\n' "$DECLARED2"))" | grep -qx 'tier4'; then
161
+ echo "PASS L8b class-closing arm goes RED when an enum member is added"
162
+ else
163
+ echo "FAIL L8b class-closing arm did NOT notice an added enum member — L8 green means nothing"
164
+ fail=1
165
+ fi
166
+
167
+ # ── L9 REVERT PROBE: neuter the allow-list; L1 must go red ────────────────────────────────────
168
+ n=$((n+1))
169
+ MUT="$TMP/mutant.sh"
170
+ sed -E 's/^([[:space:]]*)tier2\\\(\*\\\)\|tier2b\\\(\*\\\)\|tier3\\\(\*\\\)\)/\1*)/' "$GATE" > "$MUT"
171
+ if ! grep -qE '^[[:space:]]*\*\)$' "$MUT"; then
172
+ echo "FAIL L9 INSTRUMENT ERROR — the mutation did not apply; the probe would pass vacuously"
173
+ fail=1
174
+ else
175
+ rec 'tier1b(archify) — read their export path end to end' "$FULL_GP" "$FULL_AR"
176
+ _o=$(printf '{"tool_name":"Bash","tool_input":{"command":"gh pr create -R tt-a1i/archify"}}' \
177
+ | CLAUDE_PROJECT_DIR="$FHROOT" FH_OUTBOUND_TODAY="$TODAY" \
178
+ FH_OUTBOUND_RECDIR="$FHROOT/tracks/_meta" bash "$MUT" 2>&1); _r=$?
179
+ if [ "$_r" -eq 2 ]; then
180
+ echo "FAIL L9 revert probe: the neutered allow-list STILL denied — L1 is not anchored to it"
181
+ fail=1
182
+ else
183
+ echo "PASS L9 revert probe: neutering the allow-list turns L1's deny off (rc=$_r)"
184
+ fi
185
+ fi
186
+
187
+
188
+ # ── L14 트리거 형태 — cross-family(codex 2026-09-18)가 공격한 자리 ───────────────────────────
189
+ # 🟥 그 지적 7건 중 5건은 실측에서 **틀렸다**(`command gh`·`env X=1 gh`·`time gh`·`noglob gh`·
190
+ # 인용 repo 는 종전 식으로도 잡혔다). 아래 셋만 진짜였고, 앞의 둘을 수리로 닫았다.
191
+ # 이 레인들은 그 수리의 회귀 앵커다 — 정규식이 좁아지면 여기가 적색이 된다.
192
+ rec 'tier1b(archify) — read their export path end to end' "$FULL_GP" "$FULL_AR"
193
+ run "L14a 절대경로 gh 도 잡힌다" deny "/opt/homebrew/bin/gh pr create -R tt-a1i/archify --title x"
194
+ rec 'tier1b(archify) — read their export path end to end' "$FULL_GP" "$FULL_AR"
195
+ run "L14b 상대경로 ./gh 도 잡힌다" deny "./gh pr create -R tt-a1i/archify --title x"
196
+ rec 'tier1b(archify) — read their export path end to end' "$FULL_GP" "$FULL_AR"
197
+ run "L14c 인용 안쪽 sh -c 도 잡힌다" deny "sh -c 'gh pr create -R tt-a1i/archify --title x'"
198
+
199
+ # ── L15 구조적 잔여를 «핀» 으로 박는다 (커버리지 주장이 아니라 잔여 선언) ────────────────────
200
+ # 🟥 변수 간접은 정규식으로 닫히지 않는다. 이 레인은 그 사실을 **고정**한다 — 누가 「닫혔다」고
201
+ # 적으면 여기가 적색이 되어 거짓 주장을 막는다. silent 를 기대하는 것이 의도다.
202
+ rec 'tier1b(archify) — read their export path end to end' "$FULL_GP" "$FULL_AR"
203
+ # 🟥 `$GH_CMD` 는 **리터럴로 가야 한다** — 초판이 이중인용에 그대로 써서 레인 셸이 확장했고
204
+ # `set -u` 에서 그 자리에서 죽었다(L14 까지만 돌고 스위트 중단). 단일인용으로 고정한다.
205
+ run "L15 변수 간접은 NAMED GAP 이다 (silent 가 기대값)" silent 'GH_CMD=gh; $GH_CMD pr create -R tt-a1i/archify'
206
+
207
+ # ── L16 known-NEGATIVE: 넓힌 문자류가 관계없는 명령을 잡지 않는가 ─────────────────────────────
208
+ rec "$FULL_SP" "$FULL_GP" "$FULL_AR"
209
+ run "L16 gh pr edit 는 여전히 NAMED GAP" silent "gh pr edit --body x -R tt-a1i/archify"
210
+ rec "$FULL_SP" "$FULL_GP" "$FULL_AR"
211
+ run "L16b gh pr list 는 트리거 아님" silent "gh pr list -R tt-a1i/archify"
212
+
213
+ echo "── $n lanes, $( [ $fail -eq 0 ] && echo 'all green' || echo 'FAILURES above' ) ──"
214
+ exit $fail