@chrono-meta/fh-gate 3.43.0 → 3.44.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 (43) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/AGENTS.md +5 -1
  3. package/docs/USER_GUIDE.md +95 -0
  4. package/knowledge/shared/harness-core/governance_engineering_definition.md +16 -0
  5. package/knowledge/shared/learnings/subagent_invocations_log.yaml +12 -0
  6. package/knowledge/shared/plugin-catalog/recommended_plugins.md +53 -9
  7. package/package.json +8 -1
  8. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  9. package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +47 -12
  10. package/plugins/fh-commons/skills/ko-tech-writer/SKILL_detail.md +60 -0
  11. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/sense_negative.md +30 -0
  12. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/sense_positive.md +56 -0
  13. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  14. package/plugins/fh-meta/CHANGELOG.md +23 -0
  15. package/plugins/fh-meta/skills/auto-decorrelation/SKILL.md +45 -1
  16. package/plugins/fh-meta/skills/sim-conductor/SKILL_detail.md +3 -3
  17. package/plugins/fh-meta/skills/steel-quench/SKILL_detail.md +8 -4
  18. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  19. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  20. package/scripts/agy_launch_guard.sh +49 -0
  21. package/scripts/agy_remote_run.sh +187 -0
  22. package/scripts/codex_launch_guard.sh +87 -0
  23. package/scripts/finding_fleet.sh +35 -2
  24. package/scripts/finding_verifier.sh +6 -2
  25. package/scripts/ko_tech_writer_calibrate.py +88 -1
  26. package/scripts/live_eval_trace.py +23 -4
  27. package/scripts/prepush_guard_check.sh +33 -20
  28. package/scripts/probe_live_eval.sh +1 -1
  29. package/scripts/probe_live_eval_lib.py +7 -5
  30. package/scripts/selfcheck.sh +51 -2
  31. package/scripts/session_checklist.py +109 -5
  32. package/scripts/sidecar_calibrate.sh +10 -2
  33. package/scripts/sidecar_wait.sh +21 -1
  34. package/scripts/test_agy_launch_guard_lanes.sh +227 -0
  35. package/scripts/test_agy_remote_run_lanes.sh +228 -0
  36. package/scripts/test_codex_launch_guard_lanes.sh +138 -0
  37. package/scripts/test_finding_pipeline_lanes.sh +6 -2
  38. package/scripts/test_live_eval_trace_lanes.sh +54 -8
  39. package/scripts/test_preprep_speech_coach_lanes.sh +18 -2
  40. package/scripts/test_prepush_guard_failure_visibility_lanes.sh +152 -0
  41. package/scripts/test_session_checklist_lanes.sh +205 -0
  42. package/scripts/test_sidecar_calibrate_lanes.sh +4 -0
  43. package/scripts/test_sidecar_wait_stdin.sh +18 -0
@@ -660,21 +660,119 @@ def _cells(line):
660
660
 
661
661
 
662
662
  CARRY_HEADING = "## 이전 결과서에서 이어받지 못한 판정"
663
+ KEEP_HEADING = "## 이전 결과서의 표 밖 내용 (extract 가 다시 만들지 않는 줄 — 원래 순서)"
664
+ # Lines do_extract writes itself, matched by their WHOLE shape (a stale copy, whose counts changed between runs, is not
665
+ # the operator's content). Whole-line, not prefix: a note the person starts with «🟥 훅 기록 …» or appends to a status
666
+ # line is theirs and must survive (independent review 2026-11-15 reproduced prefix matching dropping both).
667
+ _GENERATED_LINE_RES = tuple(re.compile(p) for p in (
668
+ r"^# 세션 요청 체크리스트 \(스켈레톤\) — [^\n]+$",
669
+ r"^채널 2/2 열음 — raw \d+건 · 압축 요약 \d+건\(중복 제거 후 \d+건 추가\)$",
670
+ "^" + chr(0x1F4CE) + r" 원장 = .* \(\d+ lines\)$",
671
+ r"^🟥 JSONL 파싱 실패 \d+줄 — 그 줄의 발화는 이 표에 없다 \(rc=2\)$",
672
+ r"^🪝 훅 기록 채널 읽음 — \d+건 · 전사와 일치 \d+건 · 훅 전용 \d+건 \(행 번호 H = 훅 전용, S = 요약, 숫자 = 전사\)$",
673
+ r"^🟨 훅 기록 채널 안 읽음 — 파일 없음: .* \(0건이 아니라 미열람; 훅이 안 걸렸거나 다른 허브일 수 있다\)$",
674
+ r"^🟥 훅 기록 채널 오류 — .*: .* \(rc=2; 전사 행은 그대로 아래에 있다\)$",
675
+ r"^🟥 훅 기록 \d+줄 해석 실패 — 그 줄의 발화는 이 표에 없을 수 있다 \(rc=2\)$",
676
+ r"^↩️ 이전 결과서에서 판정 \d+줄 이어받음 · 못 맞춘 판정 \d+줄은 맨 아래 «이전 결과서에서 이어받지 못한 판정»에 보존"
677
+ r"( · 표 밖 줄 \d+줄은 맨 아래 «이전 결과서의 표 밖 내용»에 보존)?$",
678
+ ))
679
+ _GENERATED_ROW_ID_RE = re.compile(r"^(\d+|H\d+|S\d+)$") # the «#» ids do_extract writes: 7 · H2 · S1
680
+ _GENERATED_HEADER = "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안(이번 세션 vs 이월) |"
681
+ _GENERATED_SEPARATOR = "|---|---|---|---|---|---|---|"
682
+
683
+
684
+ def _carry_skip(c):
685
+ """rows carry_forward never reads as a checklist row: a header («#» · empty first cell) or a separator in any
686
+ markdown spelling. ONE definition for both passes — when carry_forward skipped a row and _unconsumed assumed
687
+ carry_forward had it, the row vanished (review R3: «| --- | … |», «| :--- | … |», a person's «| # | … |» header)."""
688
+ if c[0] in ("#", "") or all(re.fullmatch(r":?-+:?", x) for x in c):
689
+ return True
690
+ return c[0] != "-" and set(c[0]) <= set("-") # «-» alone is an orphan row, not a separator
691
+
692
+
693
+ def _is_generated(line):
694
+ return line in (CARRY_HEADING, KEEP_HEADING) or any(r.match(line) for r in _GENERATED_LINE_RES)
695
+
696
+
697
+ def _fenced(old):
698
+ """indices of lines inside a CLOSED fenced code block, markers included — a person's code is kept verbatim, never
699
+ read as table rows or separators (review 2026-11-15). Same opener rule as load_tables (FENCE_RE: same character,
700
+ closer at least as long). An unclosed fence is ignored here, and so is an opener whose closer lies beyond extract's
701
+ own table header: either way the live table was swallowed and every judgment below it detached (review R2)."""
702
+ idx, opened = set(), None # opened = (index, char, length)
703
+ for i, l in enumerate(old):
704
+ if l == _GENERATED_HEADER and opened is not None:
705
+ opened = None # a fence never spans extract's own table: an opener above it is unclosed (review R2 repro)
706
+ continue
707
+ m = FENCE_RE.match(l)
708
+ if not m:
709
+ continue
710
+ tick = m.group(1)
711
+ if opened is None:
712
+ opened = (i, tick[0], len(tick))
713
+ elif tick[0] == opened[1] and len(tick) >= opened[2] and l.strip() == tick:
714
+ idx.update(range(opened[0], i + 1)); opened = None
715
+ return idx
716
+
717
+
718
+ def _unconsumed(old, lines_out):
719
+ """lines of the previous sheet that the table parser does not consume and extract does not regenerate —
720
+ a result-sheet section written below the table, a preface above it, prose between (2026-11-14 harvest H3: 13 such
721
+ lines vanished on one re-extract), closed fenced code verbatim, a person's own 7-column separator, and a hand-added
722
+ row with empty judgment cells whose «#» is not an id extract writes. Kept in their original order; outside fences blank runs collapse and edges are
723
+ trimmed, so a re-run over its own output yields the same block (idempotent)."""
724
+ regenerated = set(lines_out)
725
+ fenced = _fenced(old)
726
+ kept = []
727
+ for i, l in enumerate(old):
728
+ if i in fenced:
729
+ kept.append(l); continue
730
+ if not l.strip():
731
+ if kept and kept[-1] != "":
732
+ kept.append("")
733
+ continue
734
+ if l == _GENERATED_SEPARATOR:
735
+ # regenerated only where extract writes it — right under its own header; a person's 7-column table keeps it
736
+ if i > 0 and old[i - 1] == _GENERATED_HEADER:
737
+ continue
738
+ kept.append(l); continue
739
+ if l in regenerated or _is_generated(l):
740
+ continue
741
+ c = _cells(l)
742
+ if c is not None:
743
+ # a row carry_forward reads (not _carry_skip, has a judgment) is carried or orphaned there; an empty row
744
+ # with an id extract writes (7 · H2 · S1) is a skeleton row from some run — never the person's content,
745
+ # even when this run no longer writes it (review R2). Everything else — a person's own header, separator
746
+ # or empty labelled row — is kept here (the generated header was already dropped as `regenerated`).
747
+ if not _carry_skip(c) and any(c[3:]):
748
+ continue # carry_forward carries or orphans it
749
+ if not _carry_skip(c) and _GENERATED_ROW_ID_RE.match(c[0]):
750
+ continue # an empty skeleton row from some run
751
+ kept.append(l)
752
+ while kept and kept[-1] == "":
753
+ kept.pop()
754
+ return kept
663
755
 
664
756
 
665
757
  def carry_forward(lines_out, out_path):
666
758
  try:
667
759
  with open(out_path, "r", encoding="utf-8", errors="replace") as f:
668
- old = f.read().split("\n")
760
+ text = f.read()
669
761
  except OSError:
670
762
  return lines_out
763
+ old = (text[1:] if text.startswith("\ufeff") else text).split("\n") # a BOM (Notepad) broke every ^-anchored match
671
764
  prev, orphans_prev = {}, []
672
765
  in_orphans = False
673
- for l in old:
766
+ fenced = _fenced(old)
767
+ for i, l in enumerate(old):
768
+ if i in fenced:
769
+ continue # a person's code block: kept verbatim by _unconsumed
674
770
  if l.startswith(CARRY_HEADING):
675
771
  in_orphans = True; continue
676
772
  c = _cells(l)
677
- if not c or c[0] in ("#", "---") or set(c[0]) <= set("-"):
773
+ # «-» alone is how an orphan row is written (below) — not a separator. Reading it as one dropped every orphan
774
+ # judgment on the SECOND re-extract (found 2026-11-15 by the idempotency lane L55; origin/main reproduces it).
775
+ if not c or _carry_skip(c):
678
776
  continue
679
777
  if not any(c[3:]):
680
778
  continue # an empty row has nothing to carry
@@ -691,11 +789,17 @@ def carry_forward(lines_out, out_path):
691
789
  out.append(l)
692
790
  orphans = ["| %s | %s | %s | %s | %s | %s | %s |" % ((("-",) + k + tuple(v))) for k, vs in prev.items() for v in vs]
693
791
  orphans += orphans_prev
694
- if used or orphans:
695
- out.insert(4, "↩️ 이전 결과서에서 판정 %d줄 이어받음 · 못 맞춘 판정 %d줄은 맨 아래 «이전 결과서에서 이어받지 못한 판정»에 보존" % (used, len(orphans)))
792
+ kept = _unconsumed(old, lines_out)
793
+ if used or orphans or kept:
794
+ msg = "↩️ 이전 결과서에서 판정 %d줄 이어받음 · 못 맞춘 판정 %d줄은 맨 아래 «이전 결과서에서 이어받지 못한 판정»에 보존" % (used, len(orphans))
795
+ if kept:
796
+ msg += " · 표 밖 줄 %d줄은 맨 아래 «이전 결과서의 표 밖 내용»에 보존" % sum(1 for l in kept if l)
797
+ out.insert(4, msg)
696
798
  if orphans:
697
799
  out += ["", CARRY_HEADING, "", "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안(이번 세션 vs 이월) |",
698
800
  "|---|---|---|---|---|---|---|"] + orphans
801
+ if kept:
802
+ out += ["", KEEP_HEADING, ""] + kept
699
803
  return out
700
804
 
701
805
 
@@ -94,6 +94,8 @@ VERDICT_PROMPT="Reply with exactly one word, PASS or FAIL, and nothing else. The
94
94
  BOGUS_MODEL="zzz-nonexistent-model-9.9"
95
95
 
96
96
  PANEL=""
97
+ AGY_GUARD="$(cd "$(dirname "$0")" && pwd)/agy_launch_guard.sh"
98
+ CODEX_GUARD="$(cd "$(dirname "$0")" && pwd)/codex_launch_guard.sh"
97
99
 
98
100
  # build_cmd <runtime> <model> <prompt> — fills CMD as an argv array.
99
101
  # NOT a shell function passed to the watchdog: `timeout`/`gtimeout` exec a BINARY and cannot see
@@ -101,8 +103,8 @@ PANEL=""
101
103
  # runtime failing to run (caught by lane 3/4b/5b, not by reading).
102
104
  build_cmd() {
103
105
  case "$1" in
104
- codex) CMD=(codex exec -m "$2" -c model_reasoning_effort=high --skip-git-repo-check "$3") ;;
105
- agy) CMD=(agy -p "$3" --model "$2" --print-timeout 170s) ;;
106
+ codex) CMD=(bash "$CODEX_GUARD" codex exec -m "$2" -c model_reasoning_effort=high --skip-git-repo-check "$3") ;; # company-root paths refused
107
+ agy) CMD=(bash "$AGY_GUARD" agy -p "$3" --model "$2" --print-timeout 170s) ;; # refuses unless FH_AGY_ISOLATION=container|os-user
106
108
  *) CMD=("$1" "$3") ;;
107
109
  esac
108
110
  }
@@ -125,6 +127,12 @@ probe_runtime() {
125
127
  # (`${PIPESTATUS[0]}` 는 bash 전용이고, 정본은 «파이프를 쓰지 않는 것» 이다.)
126
128
  id_raw="$(_run 200 "${CMD[@]}" 2>&1)"; id_rc=$?
127
129
  id_out="$(printf '%s\n' "$id_raw" | _answer)"
130
+ # The isolation guard refused before agy started: nothing was measured. Say so instead of reading
131
+ # the refusal text as the model's answer (it rendered REACHABLE · control: rejects-bogus before).
132
+ if [ "$id_rc" -eq 3 ] && printf '%s\n' "$id_raw" | grep -q '^AGY-REFUSED'; then
133
+ printf '%-6s REFUSED — agy_launch_guard: FH_AGY_ISOLATION is not container|os-user, agy not started, nothing measured\n' "$rt"
134
+ return 0
135
+ fi
128
136
 
129
137
  # Discriminating check — the answer must be the MODEL's self-report naming the model that was
130
138
  # pinned. What counts as "naming it" is the VERSION token, not every token of the pin slug:
@@ -27,12 +27,18 @@
27
27
  # SIDECAR_VERDICT=TIMEOUT waited=<n>s bytes=<n> still alive when the budget ran out; NOT a result
28
28
  # SIDECAR_VERDICT=EMPTY exit=<n> exited cleanly having written nothing — the only
29
29
  # state in which "the sidecar said nothing" is true
30
+ # SIDECAR_VERDICT=HARNESS-ERROR exit=<n> reason=model-not-available|guard-refused the CLI refused the
31
+ # model, or a launch guard refused to start it
32
+ # (exit 3) — nothing was reviewed; never read as 0 findings
30
33
  #
31
34
  # Usage:
32
35
  # bash scripts/sidecar_wait.sh <outfile> <timeout_seconds> -- <command> [args...]
33
- # printf '%s' "$prompt" | bash scripts/sidecar_wait.sh out.txt 600 -- codex exec -m gpt-5.5 -
36
+ # printf '%s' "$prompt" | bash scripts/sidecar_wait.sh out.txt 600 -- bash scripts/codex_launch_guard.sh codex exec -
37
+ # (no -m: the CLI default answers; a pinned model can be retired — gpt-5.5 / gpt-5 return HTTP 400
38
+ # on 2026-11-16 — and then this wrapper reports HARNESS-ERROR, not a result)
34
39
  #
35
40
  # Exit: 0 = COMPLETE (with or without output) · 1 = TIMEOUT (verdict withheld, not a failure claim)
41
+ # · 3 = HARNESS-ERROR (the CLI refused the model; nothing was reviewed)
36
42
  set -uo pipefail
37
43
 
38
44
  OUT="${1:?usage: sidecar_wait.sh <outfile> <timeout_s> -- <cmd...>}"
@@ -118,6 +124,20 @@ done
118
124
 
119
125
  wait "$PID"; rc=$?
120
126
  size=$(wc -c < "$OUT" 2>/dev/null | tr -d ' ')
127
+ # A model the CLI refuses (measured 2026-11-16: codex `-m gpt-5.5` → HTTP 400 «not supported when using
128
+ # Codex with a ChatGPT account», rc 1) is a broken instrument, not a review that found nothing. COMPLETE
129
+ # with that body reads as «the reviewer answered», so it gets its own verdict and a non-zero exit.
130
+ if [ "$rc" -ne 0 ] && grep -qE 'model_not_found|model is not supported|requires a newer version of Codex' "$OUT" 2>/dev/null; then
131
+ echo "SIDECAR_VERDICT=HARNESS-ERROR exit=$rc reason=model-not-available bytes=${size:-0}"
132
+ echo " the sidecar refused the requested model — nothing was reviewed. Drop the -m pin (CLI default) or pin a model that answers." >&2
133
+ exit 3
134
+ fi
135
+ # A launch guard that refused (codex_launch_guard.sh / agy_launch_guard.sh) started nothing: same verdict.
136
+ if [ "$rc" -ne 0 ] && grep -qE 'CODEX-REFUSED|AGY-REFUSED' "$OUT" 2>/dev/null; then
137
+ echo "SIDECAR_VERDICT=HARNESS-ERROR exit=$rc reason=guard-refused bytes=${size:-0}"
138
+ echo " a launch guard refused — the sidecar was never started, so nothing was reviewed." >&2
139
+ exit 3
140
+ fi
121
141
  if [ "${size:-0}" -eq 0 ]; then
122
142
  echo "SIDECAR_VERDICT=EMPTY exit=$rc"
123
143
  else
@@ -0,0 +1,227 @@
1
+ #!/usr/bin/env bash
2
+ # test_agy_launch_guard_lanes.sh — lanes for scripts/agy_launch_guard.sh and the three FH callers that
3
+ # launch agy (finding_fleet.sh default fleet · finding_verifier.sh --family gemini · sidecar_calibrate.sh).
4
+ #
5
+ # WHAT IS CHECKED: that no FH caller starts agy unless FH_AGY_ISOLATION is exactly `container` or
6
+ # `os-user`, that a refused launch is visible (AGY-REFUSED on stderr, non-zero), and that with the marker
7
+ # the call goes through with its arguments intact. Every lane uses a FAKE agy that only records that it
8
+ # was started — no real agy runs here.
9
+ # WHAT IS NOT CHECKED: whether the isolation the marker names is real. The marker is self-declared;
10
+ # no lane here can see a container or an OS user. Doc snippets (steel-quench / sim-conductor) that show
11
+ # `agy -p` are prose, not scripts, and are outside the static scan in G9.
12
+ #
13
+ # Usage: bash scripts/test_agy_launch_guard_lanes.sh Exit: 0 all pass · 1 any fail
14
+ set -uo pipefail
15
+ REPO="$(cd "$(dirname "$0")/.." && pwd)"
16
+ GUARD="$REPO/scripts/agy_launch_guard.sh"
17
+ FLEET="$REPO/scripts/finding_fleet.sh"
18
+ VERIFIER="$REPO/scripts/finding_verifier.sh"
19
+ CAL="$REPO/scripts/sidecar_calibrate.sh"
20
+ D="$(mktemp -d "${TMPDIR:-/tmp}/agyguard.XXXXXX")" || { echo "ENV-BLOCKED: mktemp failed — unmeasured, not a pass"; exit 1; }
21
+ trap 'rm -rf "$D"' EXIT
22
+ unset FH_AGY_ISOLATION
23
+ PASS=0; FAIL=0
24
+ ok() { PASS=$((PASS+1)); echo " ✅ $1"; }
25
+ bad() { FAIL=$((FAIL+1)); echo " ❌ $1"; }
26
+
27
+ # Fake agy: records that it started (and its argv, one per line), prints one JSONL finding / one word.
28
+ mkfake() { # $1 = path $2 = sentinel
29
+ cat > "$1" <<EOF
30
+ #!/usr/bin/env bash
31
+ printf '%s\n' "\$@" > "$2"
32
+ cat >/dev/null 2>&1 || true
33
+ echo '{"title":"fake finding","file":"t.py","line":1,"severity":"B","category":"x","detail":"d","defeater":"df","confidence":0.5}'
34
+ EOF
35
+ chmod +x "$1"
36
+ }
37
+ mkfake "$D/agy_fake" "$D/ran"
38
+ # Hermetic floor: a recording `agy` on the underlying PATH. If interception ever breaks, a bare `agy`
39
+ # lands here (recorded in ran_host) instead of on a real CLI. Every lane also asserts it never started.
40
+ mkdir -p "$D/hostbin"; mkfake "$D/hostbin/agy" "$D/ran_host"
41
+ export PATH="$D/hostbin:$PATH"
42
+ printf 'def f():\n return 1\n' > "$D/t.py"
43
+
44
+ echo "── guard alone"
45
+ # G1 no marker → refused, fake never started
46
+ rm -f "$D/ran"
47
+ out=$(bash "$GUARD" "$D/agy_fake" -p "hello" < /dev/null 2>&1); rc=$?
48
+ if [ "$rc" -eq 3 ] && [ ! -e "$D/ran" ] && printf '%s' "$out" | grep -q 'AGY-REFUSED'; then ok "G1 no marker: rc=3, AGY-REFUSED, agy not started"
49
+ else bad "G1 no marker: rc=$rc ran=$([ -e "$D/ran" ] && echo yes || echo no) out=${out:0:120}"; fi
50
+
51
+ # G2 marker=container → started, argv intact (an argument with spaces survives as one)
52
+ rm -f "$D/ran"
53
+ FH_AGY_ISOLATION=container bash "$GUARD" "$D/agy_fake" -p "two words" --mode plan < /dev/null >/dev/null 2>&1; rc=$?
54
+ if [ "$rc" -eq 0 ] && [ -e "$D/ran" ] && [ "$(sed -n 2p "$D/ran")" = "two words" ] && [ "$(wc -l < "$D/ran" | tr -d ' ')" = 4 ]; then
55
+ ok "G2 container: started, argv intact"
56
+ else bad "G2 container: rc=$rc argv=$(tr '\n' '|' < "$D/ran" 2>/dev/null)"; fi
57
+
58
+ # G3 marker=os-user → started
59
+ rm -f "$D/ran"
60
+ FH_AGY_ISOLATION=os-user bash "$GUARD" "$D/agy_fake" -p x < /dev/null >/dev/null 2>&1; rc=$?
61
+ [ "$rc" -eq 0 ] && [ -e "$D/ran" ] && ok "G3 os-user: started" || bad "G3 os-user: rc=$rc"
62
+
63
+ # G4 near-miss values → refused (a truthy word is not an isolation statement)
64
+ for v in 1 yes true Container "container " none ""; do
65
+ rm -f "$D/ran"
66
+ FH_AGY_ISOLATION="$v" bash "$GUARD" "$D/agy_fake" -p x < /dev/null >/dev/null 2>&1; rc=$?
67
+ if [ "$rc" -eq 3 ] && [ ! -e "$D/ran" ]; then ok "G4 value '$v': refused"; else bad "G4 value '$v': rc=$rc started=$([ -e "$D/ran" ] && echo yes || echo no)"; fi
68
+ done
69
+
70
+ # G5 no binary given → usage, nothing started
71
+ bash "$GUARD" < /dev/null >/dev/null 2>&1; rc=$?
72
+ [ "$rc" -eq 2 ] && ok "G5 no args: rc=2" || bad "G5 no args: rc=$rc"
73
+
74
+ # G15 remote-os-user with any other target → refused, target not started
75
+ rm -f "$D/ran"
76
+ FH_AGY_ISOLATION=remote-os-user bash "$GUARD" "$D/agy_fake" -p x < /dev/null >/dev/null 2>&1; rc=$?
77
+ if [ "$rc" -eq 3 ] && [ ! -e "$D/ran" ]; then ok "G15 remote-os-user + other target: refused"; else bad "G15 remote-os-user + other target: rc=$rc started=$([ -e "$D/ran" ] && echo yes || echo no)"; fi
78
+ # G16 remote-os-user with a file NAMED agy_remote_run.sh elsewhere → refused (the path, not the name, is the route)
79
+ mkdir -p "$D/elsewhere"; mkfake "$D/elsewhere/agy_remote_run.sh" "$D/ran"
80
+ rm -f "$D/ran"
81
+ FH_AGY_ISOLATION=remote-os-user bash "$GUARD" "$D/elsewhere/agy_remote_run.sh" -p x < /dev/null >/dev/null 2>&1; rc=$?
82
+ if [ "$rc" -eq 3 ] && [ ! -e "$D/ran" ]; then ok "G16 remote-os-user + same-named file elsewhere: refused"; else bad "G16 same-named file elsewhere: rc=$rc started=$([ -e "$D/ran" ] && echo yes || echo no)"; fi
83
+
84
+ echo "── finding_fleet.sh default fleet (gemini row)"
85
+ cat > "$D/codex_fake" <<'EOF'
86
+ #!/usr/bin/env bash
87
+ cat >/dev/null 2>&1 || true
88
+ echo '{"title":"codex finding","file":"t.py","line":1,"severity":"B","category":"x","detail":"d","defeater":"df","confidence":0.5}'
89
+ EOF
90
+ chmod +x "$D/codex_fake"
91
+ # G6 no marker → gemini member not started and recorded as failed with the refusal; codex still runs
92
+ rm -f "$D/ran"
93
+ FH_CODEX_BIN="$D/codex_fake" FH_AGY_BIN="$D/agy_fake" bash "$FLEET" "$D/t.py" --out "$D/f6" < /dev/null > "$D/f6.out" 2>&1; rc=$?
94
+ if [ ! -e "$D/ran" ] && grep -qs 'AGY-REFUSED' "$D/f6/err_gemini_security.txt" && [ "$rc" -eq 0 ]; then
95
+ ok "G6 fleet no marker: gemini refused (err file), codex member kept rc=0"
96
+ else bad "G6 fleet no marker: rc=$rc agy_started=$([ -e "$D/ran" ] && echo yes || echo no) err=$(head -c 120 "$D/f6/err_gemini_security.txt" 2>/dev/null)"; fi
97
+ # G7 control — with the marker the same fleet DOES start the fake (the lane can see a start)
98
+ rm -f "$D/ran"
99
+ FH_AGY_ISOLATION=container FH_CODEX_BIN="$D/codex_fake" FH_AGY_BIN="$D/agy_fake" bash "$FLEET" "$D/t.py" --out "$D/f7" < /dev/null > "$D/f7.out" 2>&1; rc=$?
100
+ [ -e "$D/ran" ] && [ "$rc" -eq 0 ] && ok "G7 fleet with marker: gemini member started (control alive)" || bad "G7 fleet with marker: rc=$rc started=$([ -e "$D/ran" ] && echo yes || echo no)"
101
+
102
+ # G7b round 2 without the marker (reusing G7's round-1 findings) → not started, refusal in the r2 err file
103
+ rm -f "$D/ran"
104
+ FH_CODEX_BIN="$D/codex_fake" FH_AGY_BIN="$D/agy_fake" bash "$FLEET" "$D/t.py" --out "$D/f7b" --reuse-r1 "$D/f7" --round2 < /dev/null > "$D/f7b.out" 2>&1
105
+ if [ ! -e "$D/ran" ] && grep -qs 'AGY-REFUSED' "$D/f7b/err2_gemini_security.txt"; then ok "G7b fleet round 2 no marker: gemini refused"
106
+ else bad "G7b fleet round 2 no marker: started=$([ -e "$D/ran" ] && echo yes || echo no) err=$(head -c 120 "$D/f7b/err2_gemini_security.txt" 2>/dev/null)"; fi
107
+ # G7c control — round 2 with the marker starts it
108
+ rm -f "$D/ran"
109
+ FH_AGY_ISOLATION=container FH_CODEX_BIN="$D/codex_fake" FH_AGY_BIN="$D/agy_fake" bash "$FLEET" "$D/t.py" --out "$D/f7c" --reuse-r1 "$D/f7" --round2 < /dev/null > "$D/f7c.out" 2>&1
110
+ [ -e "$D/ran" ] && ok "G7c fleet round 2 with marker: started (control alive)" || bad "G7c fleet round 2 with marker: not started"
111
+ # G7d custom table rows that reach agy by NAME, in shapes a word match misses (redirection glued to the
112
+ # name, behind `env`, AGY_BIN behind `env`) → refused without the marker; G7e same rows with it → started.
113
+ # The real binary is FH_AGY_BIN (the fake); the shim on PATH is what a bare `agy` resolves to.
114
+ n=0
115
+ for row in 'agy -p "$(cat PROMPT_FILE)"' 'agy</dev/null -p hello' 'env agy -p hello' 'env AGY_BIN -p hello'; do
116
+ n=$((n+1)); printf 'gemini|security|%s\n' "$row" > "$D/direct$n.tbl"
117
+ rm -f "$D/ran"
118
+ FH_AGY_BIN="$D/agy_fake" bash "$FLEET" "$D/t.py" --out "$D/f7d$n" --fleet "$D/direct$n.tbl" < /dev/null > "$D/f7d$n.out" 2>&1
119
+ if [ ! -e "$D/ran" ] && grep -qs 'AGY-REFUSED' "$D/f7d$n/err_gemini_security.txt"; then ok "G7d row [$row]: refused without marker"
120
+ else bad "G7d row [$row]: started=$([ -e "$D/ran" ] && echo yes || echo no)"; fi
121
+ rm -f "$D/ran"
122
+ FH_AGY_ISOLATION=os-user FH_AGY_BIN="$D/agy_fake" bash "$FLEET" "$D/t.py" --out "$D/f7e$n" --fleet "$D/direct$n.tbl" < /dev/null > "$D/f7e$n.out" 2>&1
123
+ [ -e "$D/ran" ] && ok "G7e row [$row]: started with marker (control alive)" || bad "G7e row [$row]: not started with marker ($(head -c 100 "$D/f7e$n/err_gemini_security.txt" 2>/dev/null))"
124
+ done
125
+ # G7d-r2 a by-name row in ROUND 2 without the marker → refused (refusal text in the r2 err file);
126
+ # G7e-r2 same with the marker → started. Round-1 findings come from G7's run.
127
+ printf 'gemini|security|%s\n' 'agy -p "$(cat PROMPT_FILE)"' > "$D/direct_r2.tbl"
128
+ # --reuse-r1 takes the fleet from the round-1 dir, so round 1 runs with THIS table (marker on, r1 only)
129
+ FH_AGY_ISOLATION=container FH_AGY_BIN="$D/agy_fake" bash "$FLEET" "$D/t.py" --out "$D/f7r1d" --fleet "$D/direct_r2.tbl" --r1-only < /dev/null > /dev/null 2>&1
130
+ rm -f "$D/ran"
131
+ FH_AGY_BIN="$D/agy_fake" bash "$FLEET" "$D/t.py" --out "$D/f7dr2" --reuse-r1 "$D/f7r1d" --round2 < /dev/null > "$D/f7dr2.out" 2>&1
132
+ if [ ! -e "$D/ran" ] && grep -qs 'AGY-REFUSED' "$D/f7dr2/err2_gemini_security.txt"; then ok "G7d-r2 by-name row in round 2: refused without marker"
133
+ else bad "G7d-r2 by-name row in round 2: started=$([ -e "$D/ran" ] && echo yes || echo no) err=$(head -c 100 "$D/f7dr2/err2_gemini_security.txt" 2>/dev/null)"; fi
134
+ rm -f "$D/ran"
135
+ FH_AGY_ISOLATION=container FH_AGY_BIN="$D/agy_fake" bash "$FLEET" "$D/t.py" --out "$D/f7er2" --reuse-r1 "$D/f7r1d" --round2 < /dev/null > "$D/f7er2.out" 2>&1
136
+ [ -e "$D/ran" ] && ok "G7e-r2 by-name row in round 2 with marker: started (control alive)" || bad "G7e-r2 by-name row in round 2 with marker: not started"
137
+ # G7j an exported shell function named agy does not outrank the shim
138
+ agy() { : > "$D/ran_func"; }; export -f agy
139
+ rm -f "$D/ran" "$D/ran_func"
140
+ FH_AGY_BIN="$D/agy_fake" bash "$FLEET" "$D/t.py" --out "$D/f7j" --fleet "$D/direct1.tbl" < /dev/null > "$D/f7j.out" 2>&1
141
+ unset -f agy
142
+ if [ ! -e "$D/ran_func" ] && [ ! -e "$D/ran" ] && grep -qs 'AGY-REFUSED' "$D/f7j/err_gemini_security.txt"; then ok "G7j exported agy function: shim still wins, refused"
143
+ else bad "G7j exported agy function: func_ran=$([ -e "$D/ran_func" ] && echo yes || echo no)"; fi
144
+ # G14a hermetic floor so far — no unmarked lane above reached the underlying-PATH agy (G7k below starts it on purpose)
145
+ [ ! -e "$D/ran_host" ] && ok "G14a underlying-PATH agy not started by G1–G7j" || bad "G14a underlying-PATH agy was started before G7k — interception broke"
146
+ # G7k FH_AGY_BIN given as a bare name resolves once (no shim loop) — with the marker the PATH agy starts
147
+ rm -f "$D/ran_host"
148
+ FH_AGY_ISOLATION=container FH_CODEX_BIN="$D/codex_fake" FH_AGY_BIN=agy bash "$FLEET" "$D/t.py" --out "$D/f7k" < /dev/null > "$D/f7k.out" 2>&1 &
149
+ kpid=$!; k=0; while kill -0 "$kpid" 2>/dev/null && [ "$k" -lt 30 ]; do sleep 1; k=$((k+1)); done
150
+ if kill -0 "$kpid" 2>/dev/null; then kill "$kpid" 2>/dev/null; bad "G7k bare FH_AGY_BIN: still running after 30s (shim loop)"
151
+ elif [ -e "$D/ran_host" ]; then ok "G7k bare FH_AGY_BIN=agy: resolved to the PATH binary once"
152
+ else bad "G7k bare FH_AGY_BIN=agy: PATH agy never started"; fi
153
+ rm -f "$D/ran_host"
154
+ # G7h over-block control — a codex row whose TEXT mentions agy is not refused
155
+ printf 'codex|logic|%s\n' 'CODEX_BIN exec "review agy behavior"' > "$D/text.tbl"
156
+ FH_CODEX_BIN="$D/codex_fake" bash "$FLEET" "$D/t.py" --out "$D/f7i" --fleet "$D/text.tbl" < /dev/null > "$D/f7i.out" 2>&1; rc=$?
157
+ if [ "$rc" -eq 0 ] && ! grep -qs 'AGY-REFUSED' "$D/f7i/err_codex_logic.txt"; then ok "G7h codex row mentioning agy in text: runs (no over-block)"
158
+ else bad "G7h codex row mentioning agy in text: rc=$rc"; fi
159
+ # G7f a row that quotes the token ("AGY_BIN") still names one command (with the marker it starts)
160
+ printf 'gemini|security|%s\n' '"AGY_BIN" -p "$(cat PROMPT_FILE)"' > "$D/quoted.tbl"
161
+ rm -f "$D/ran"
162
+ FH_AGY_ISOLATION=container FH_AGY_BIN="$D/agy_fake" bash "$FLEET" "$D/t.py" --out "$D/f7f" --fleet "$D/quoted.tbl" < /dev/null > "$D/f7f.out" 2>&1
163
+ [ -e "$D/ran" ] && ok "G7f quoted \"AGY_BIN\" row: started with the marker" || bad "G7f quoted \"AGY_BIN\" row: not started ($(head -c 120 "$D/f7f/err_gemini_security.txt" 2>/dev/null))"
164
+ # G7g scripts installed under a directory whose name holds `&` and the text PROMPT_FILE: no marker → refused,
165
+ # marker → started (a pasted path could otherwise background the launch or be rewritten)
166
+ W="$D/a&agy&PROMPT_FILE"; mkdir -p "$W"; cp "$FLEET" "$GUARD" "$W/"
167
+ rm -f "$D/ran"
168
+ FH_CODEX_BIN="$D/codex_fake" FH_AGY_BIN="$D/agy_fake" bash "$W/finding_fleet.sh" "$D/t.py" --out "$D/f7g" < /dev/null > "$D/f7g.out" 2>&1
169
+ g1=$([ -e "$D/ran" ] && echo started || echo not-started)
170
+ rm -f "$D/ran"
171
+ FH_AGY_ISOLATION=container FH_CODEX_BIN="$D/codex_fake" FH_AGY_BIN="$D/agy_fake" bash "$W/finding_fleet.sh" "$D/t.py" --out "$D/f7h" < /dev/null > "$D/f7h.out" 2>&1
172
+ g2=$([ -e "$D/ran" ] && echo started || echo not-started)
173
+ [ "$g1" = not-started ] && [ "$g2" = started ] && ok "G7g odd install path: refused without marker, started with it" || bad "G7g odd install path: without=$g1 with=$g2"
174
+
175
+ echo "── finding_verifier.sh --family gemini"
176
+ printf '%s\n' '{"id":"x1","title":"t","file":"t.py","line":1,"severity":"B","category":"x","detail":"d","defeater":"df","confidence":0.5}' > "$D/claims.jsonl"
177
+ # G8 no marker → not started, non-zero
178
+ rm -f "$D/ran"
179
+ FH_AGY_BIN="$D/agy_fake" bash "$VERIFIER" --family gemini --target "$D/t.py" < "$D/claims.jsonl" > "$D/v8.out" 2> "$D/v8.err"; rc=$?
180
+ if [ ! -e "$D/ran" ] && [ "$rc" -ne 0 ]; then ok "G8 verifier no marker: agy not started, rc=$rc"
181
+ else bad "G8 verifier no marker: rc=$rc started=$([ -e "$D/ran" ] && echo yes || echo no)"; fi
182
+ # G9 control — with the marker the verifier starts it
183
+ rm -f "$D/ran"
184
+ FH_AGY_ISOLATION=container FH_AGY_BIN="$D/agy_fake" bash "$VERIFIER" --family gemini --target "$D/t.py" < "$D/claims.jsonl" >/dev/null 2>&1
185
+ [ -e "$D/ran" ] && ok "G9 verifier with marker: started (control alive)" || bad "G9 verifier with marker: not started"
186
+
187
+ echo "── sidecar_calibrate.sh --only agy"
188
+ mkdir -p "$D/bin"; mkfake "$D/bin/agy" "$D/ran"
189
+ # G10 no marker → the PATH agy is not started; the row is not PINNED/PASS
190
+ rm -f "$D/ran"
191
+ c_out=$(PATH="$D/bin:$PATH" bash "$CAL" --only agy 2>&1 < /dev/null)
192
+ if [ ! -e "$D/ran" ] && printf '%s' "$c_out" | grep -qE '^agy +REFUSED' && ! printf '%s' "$c_out" | grep -qE '^agy +.*REACHABLE'; then ok "G10 calibrate no marker: agy not started, row says REFUSED (not REACHABLE)"
193
+ else bad "G10 calibrate no marker: started=$([ -e "$D/ran" ] && echo yes || echo no) out=$(printf '%s' "$c_out" | grep -m1 '^agy' | cut -c1-120)"; fi
194
+ # G11 control — with the marker the probe starts the PATH agy
195
+ rm -f "$D/ran"
196
+ FH_AGY_ISOLATION=container PATH="$D/bin:$PATH" bash "$CAL" --only agy >/dev/null 2>&1 < /dev/null
197
+ [ -e "$D/ran" ] && ok "G11 calibrate with marker: started (control alive)" || bad "G11 calibrate with marker: not started"
198
+
199
+ echo "── static: no shipped script launches agy around the guard"
200
+ # G12 every line in scripts/*.sh (not lanes, not the guard) that starts agy with a prompt/mode flag must
201
+ # go through the guard. Comment lines are skipped. Known residual: a launch built from pieces
202
+ # (variables, eval of a table row other than AGY_BIN) is not seen by a line scan.
203
+ hits=$(cd "$REPO/scripts" && grep -nE '(^|[[:space:]("=])("?\$\{?AGY\}?"?|agy)[[:space:]]+(-p|--print|--prompt|--mode|-i)([[:space:]]|$)' \
204
+ $(ls *.sh | grep -vE '^(test_|agy_launch_guard\.sh$)') 2>/dev/null \
205
+ | grep -vE ':[0-9]+:[[:space:]]*#' | grep -v 'AGY_GUARD' || true)
206
+ if [ -z "$hits" ]; then ok "G12 static scan: no unguarded agy launch in shipped scripts"
207
+ else bad "G12 static scan: unguarded launch(es):"; printf ' %s\n' "$hits"; fi
208
+ # G13 control for G12 — the same pattern DOES see an unguarded line
209
+ printf 'out=$(agy -p "$1")\n' > "$D/probe.sh"
210
+ grep -qE '(^|[[:space:]("=])("?\$\{?AGY\}?"?|agy)[[:space:]]+(-p|--print|--prompt|--mode|-i)([[:space:]]|$)' "$D/probe.sh" \
211
+ && ok "G13 static pattern sees a known unguarded line (control alive)" || bad "G13 static pattern blind to a known unguarded line"
212
+
213
+ # G7l exported agy function AND bare FH_AGY_BIN AND marker — still resolves to the PATH binary (no loop)
214
+ agy() { : > "$D/ran_func"; }; export -f agy
215
+ rm -f "$D/ran_host" "$D/ran_func"
216
+ FH_AGY_ISOLATION=container FH_CODEX_BIN="$D/codex_fake" FH_AGY_BIN=agy bash "$FLEET" "$D/t.py" --out "$D/f7l" < /dev/null > "$D/f7l.out" 2>&1 &
217
+ kpid=$!; k=0; while kill -0 "$kpid" 2>/dev/null && [ "$k" -lt 30 ]; do sleep 1; k=$((k+1)); done
218
+ unset -f agy
219
+ if kill -0 "$kpid" 2>/dev/null; then kill "$kpid" 2>/dev/null; bad "G7l exported function + bare name: still running after 30s (loop)"
220
+ elif [ -e "$D/ran_host" ] && [ ! -e "$D/ran_func" ]; then ok "G7l exported function + bare name: PATH agy started once, function ignored"
221
+ else bad "G7l exported function + bare name: host=$([ -e "$D/ran_host" ] && echo yes || echo no) func=$([ -e "$D/ran_func" ] && echo yes || echo no)"; fi
222
+ rm -f "$D/ran_host"
223
+ # G14b hermetic floor after G7k — the lanes after it (verifier, calibrate, static) did not reach it either
224
+ [ ! -e "$D/ran_host" ] && ok "G14b underlying-PATH agy not started after G7k" || bad "G14b underlying-PATH agy was started after G7k"
225
+ echo
226
+ echo "agy launch guard lanes: $PASS passed, $FAIL failed"
227
+ [ "$FAIL" -eq 0 ]