@chrono-meta/fh-gate 3.15.0 → 3.17.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 (60) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/AGENTS.md +27 -0
  3. package/CATALOG.md +60 -0
  4. package/CLAUDE.md +5 -0
  5. package/README.ja.md +2 -2
  6. package/README.ko.md +2 -2
  7. package/README.md +2 -2
  8. package/README.zh.md +2 -2
  9. package/docs/OUTPUT_EVIDENCE.md +1 -1
  10. package/docs/codex-compat.md +24 -0
  11. package/knowledge/shared/harness-core/checkout_layer_drift.md +301 -0
  12. package/knowledge/shared/learnings/subagent_invocations_log.yaml +66 -0
  13. package/package.json +13 -1
  14. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  15. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  16. package/plugins/fh-meta/CHANGELOG.md +42 -0
  17. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  18. package/plugins/fh-preprep/skills/preprep/SKILL.md +5 -0
  19. package/plugins/fh-preprep/skills/preprep/lane_font_embed.py +235 -0
  20. package/plugins/fh-preprep/skills/preprep/ooxml/gate.py +67 -5
  21. package/plugins/fh-preprep/skills/preprep/ooxml/test_gate_exitcodes.py +136 -0
  22. package/plugins/fh-preprep/skills/preprep/preprep.py +16 -1
  23. package/plugins/fh-preprep/skills/preprep/presentation_checklist.md +108 -6
  24. package/plugins/fh-preprep/skills/preprep/safe_install.py +22 -3
  25. package/plugins/fh-preprep/skills/preprep/surfaces.example.yaml +11 -0
  26. package/plugins/fh-preprep/skills/preprep/test_lane_font_embed.py +117 -0
  27. package/plugins/fh-preprep/skills/preprep/test_safe_install_app_xml.py +77 -0
  28. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  29. package/scripts/count_check.sh +46 -14
  30. package/scripts/daily_report.sh +17 -1
  31. package/scripts/env_layer_fingerprint.sh +309 -0
  32. package/scripts/gate_bootstrap_ephemeral.sh +248 -0
  33. package/scripts/governor_board.sh +841 -0
  34. package/scripts/map_postprocess.py +89 -4
  35. package/scripts/multibyte_bracket_lint.sh +135 -0
  36. package/scripts/outbound_pr_gate.sh +12 -0
  37. package/scripts/package_coverage_check.sh +34 -0
  38. package/scripts/selfcheck.sh +263 -0
  39. package/scripts/session_close_check.sh +96 -1
  40. package/scripts/stale_ref_scan.py +511 -0
  41. package/scripts/test_count_check_decl_lanes.sh +176 -0
  42. package/scripts/test_env_layer_fingerprint_lanes.sh +192 -0
  43. package/scripts/test_gate_bootstrap_ephemeral_lanes.sh +262 -0
  44. package/scripts/test_locale_invariance_lanes.sh +581 -0
  45. package/scripts/test_map_postprocess_lanes.sh +84 -4
  46. package/scripts/test_marker_crossfamily_lanes.sh +5 -1
  47. package/scripts/test_marker_defense_lanes.sh +5 -1
  48. package/scripts/test_marker_standpoint_lanes.sh +5 -1
  49. package/scripts/test_marker_thirdparty_lanes.sh +5 -1
  50. package/scripts/test_multibyte_bracket_lint_lanes.sh +107 -0
  51. package/scripts/test_outbound_pr_gate_lanes.sh +133 -0
  52. package/scripts/test_preprep_drift_anchor.sh +34 -9
  53. package/scripts/test_preprep_drift_anchor_lanes.sh +64 -2
  54. package/scripts/test_session_close_chain_lanes.sh +45 -0
  55. package/scripts/test_stale_ref_close_lanes.sh +197 -0
  56. package/scripts/test_stale_ref_scan_lanes.sh +134 -0
  57. package/scripts/test_worktree_reclaim_lanes.sh +267 -1
  58. package/scripts/worktree_reclaim.sh +246 -11
  59. package/templates/.git-hooks/pre-commit +108 -27
  60. package/templates/settings.PreToolUse.snippet.json +54 -1
@@ -0,0 +1,235 @@
1
+ """lane_font_embed.py — L15-b: **쓰는 서체를 덱이 들고 다니나.**
2
+
3
+ 🟥 L15(lane_font.py)가 «서체가 템플릿 집합을 벗어났나»를 보는 반면, 이 레인은
4
+ «그 서체가 **발표장 PC 에 있다고 가정하고 있나**»를 본다. 둘은 다른 실패를 잡는다.
5
+
6
+ SKILL §L15 는 *「그 서체가 **설치돼 있는지**(파일은 이름만 적고, 없으면 렌더러가 조용히
7
+ 대체한다)」* 를 **구조적으로 못 보는 것 셋** 중 하나로 적어 두고 «파일 밖의 사실이라 0 으로
8
+ 세지 않는다» 고 했다. 맞다 — 그러나 **임베드 여부는 파일 «안»의 사실이다.**
9
+ 설치 여부는 못 봐도 **«설치에 기대고 있나»는 잰다.** 이 레인이 그 절반을 닫는다.
10
+
11
+ 재는 것
12
+ `ppt/presentation.xml` 의 `<p:embeddedFont>` 집합 ⊇ `ppt/slides/*.xml` 이 부르는
13
+ 서체 집합(`a:latin` · `a:ea`, 테마 참조 `+mn-*`/`+mj-*` 는 theme 에서 풀어서 포함)
14
+
15
+ 🟥 **이 축은 «부재가 곧 결함»이다 — 임베드 0 은 UNMEASURED 가 아니라 FAIL 이다.**
16
+ 다른 레인의 «부재 ↔ 0» 규율과 방향이 반대인 이유: 여기서 재는 것은 «측정할 수 있었나»가
17
+ 아니라 «덱이 무엇을 들고 다니나»이고, 아무것도 안 들고 다니는 것은 **측정된 사실**이다.
18
+
19
+ 면제는 선언으로만 — `surfaces.yaml`:
20
+
21
+ fonts:
22
+ embed_exempt:
23
+ - fonts: ["Arial"]
24
+ why: "시스템 기본 서체 — 어느 PC에나 있다"
25
+
26
+ 🟥 `why` 가 비면 «면제»가 아니라 **오류**다(SKILL §방법론 ⓕ ②). 면제된 것은 «면제됨»으로
27
+ 출력된다 — 조용히 사라지면 다음 감사자가 다시 «발견»한다(ⓕ ③).
28
+
29
+ 실사고(2026-09-21): 한 덱이 **안 쓰는 서체 하나를 임베드하고, 실제로 쓰는 둘을 안 넣은**
30
+ 채로 제출됐다 — `slides/` 의 `a:latin` 분포가 A 1,744회 · B 118회 · C 3회인데 임베드 목록은
31
+ «C 와, 분포에 0회인 D» 였다. 외부 디자인 검수에서 7종 전량 임베드로 바뀌었다.
32
+ """
33
+
34
+ import os
35
+ import re
36
+ import zipfile
37
+ from collections import Counter
38
+
39
+ _THEME_REF = re.compile(r'^\+(mj|mn)-(lt|ea|cs)$')
40
+
41
+
42
+ def embedded_fonts(z):
43
+ """(가족 이름 집합, 가족→선언된 스타일들, 참조가 끊긴 가족)"""
44
+ try:
45
+ pres = z.read('ppt/presentation.xml').decode('utf-8', 'replace')
46
+ except KeyError:
47
+ return set(), {}, []
48
+ try:
49
+ rels = z.read('ppt/_rels/presentation.xml.rels').decode('utf-8', 'replace')
50
+ except KeyError:
51
+ rels = ''
52
+ rel_targets = {}
53
+ for tag in re.findall(r'<Relationship\b[^>]*>', rels):
54
+ i = re.search(r'\bId="([^"]+)"', tag)
55
+ t = re.search(r'\bTarget="([^"]+)"', tag)
56
+ if i and t:
57
+ rel_targets[i.group(1)] = t.group(1)
58
+ names = z.namelist()
59
+ fams, styles, dangling = set(), {}, []
60
+ for blk in re.findall(r'<p:embeddedFont>.*?</p:embeddedFont>', pres, re.S):
61
+ m = re.search(r'<p:font\b[^>]*\btypeface="([^"]*)"', blk)
62
+ if not m:
63
+ continue
64
+ fam = m.group(1)
65
+ fams.add(fam)
66
+ st = []
67
+ for sm in re.finditer(r'<p:(regular|bold|italic|boldItalic)\b[^>]*r:id="([^"]+)"', blk):
68
+ st.append(sm.group(1))
69
+ tgt = rel_targets.get(sm.group(2))
70
+ if tgt:
71
+ part = os.path.normpath(os.path.join('ppt', tgt)).replace(os.sep, '/')
72
+ if part not in names:
73
+ dangling.append((fam, sm.group(1), part))
74
+ styles[fam] = st
75
+ return fams, styles, dangling
76
+
77
+
78
+ def theme_map(z):
79
+ """테마 참조(`+mn-ea` 등)를 실제 서체 이름으로 푸는 표."""
80
+ out = {}
81
+ for n in z.namelist():
82
+ if not re.match(r'ppt/theme/theme\d+\.xml$', n):
83
+ continue
84
+ x = z.read(n).decode('utf-8', 'replace')
85
+ for grp, key in (('majorFont', 'mj'), ('minorFont', 'mn')):
86
+ g = re.search(r'<a:%s>(.*?)</a:%s>' % (grp, grp), x, re.S)
87
+ if not g:
88
+ continue
89
+ for tag, slot in (('latin', 'lt'), ('ea', 'ea'), ('cs', 'cs')):
90
+ t = re.search(r'<a:%s\b[^>]*typeface="([^"]*)"' % tag, g.group(1))
91
+ if t and t.group(1):
92
+ out.setdefault('+%s-%s' % (key, slot), t.group(1))
93
+ break
94
+ return out
95
+
96
+
97
+ def used_fonts(z):
98
+ """slides/ 가 실제로 부르는 서체 → 횟수. 테마 참조는 풀어서 넣는다.
99
+
100
+ 🟥 `a:sym`·`a:cs` 는 안 센다 — 한국어 덱에서 렌더를 지는 것은 `a:latin`·`a:ea` 다.
101
+ 그 둘은 **UNMEASURED 로 노트에 적는다**(0 으로 접지 않는다)."""
102
+ tm = theme_map(z)
103
+ used, unresolved, sym_cs = Counter(), Counter(), Counter()
104
+ for n in sorted(z.namelist()):
105
+ if not re.match(r'ppt/slides/slide\d+\.xml$', n):
106
+ continue
107
+ x = z.read(n).decode('utf-8', 'replace')
108
+ for tag in ('latin', 'ea'):
109
+ for tf in re.findall(r'<a:%s\b[^>]*typeface="([^"]*)"' % tag, x):
110
+ if not tf:
111
+ continue
112
+ if _THEME_REF.match(tf):
113
+ r = tm.get(tf)
114
+ if r:
115
+ used[r] += 1
116
+ else:
117
+ unresolved[tf] += 1
118
+ else:
119
+ used[tf] += 1
120
+ for tag in ('sym', 'cs'):
121
+ for tf in re.findall(r'<a:%s\b[^>]*typeface="([^"]*)"' % tag, x):
122
+ if tf and not _THEME_REF.match(tf):
123
+ sym_cs[tf] += 1
124
+ return used, unresolved, sym_cs
125
+
126
+
127
+ def _norm(s):
128
+ return re.sub(r'\s+', ' ', (s or '')).strip().lower()
129
+
130
+
131
+ def _exempt_rules(cfg):
132
+ """(정규화된 이름 → why, 오류 메시지들)"""
133
+ spec = (cfg.get('fonts') or {})
134
+ out, errs = {}, []
135
+ for r in (spec.get('embed_exempt') or []):
136
+ why = (r or {}).get('why')
137
+ fonts = (r or {}).get('fonts') or []
138
+ if not why:
139
+ errs.append('L15-b font-embed : 🟥 `embed_exempt` 에 `why` 가 없다(%s) — '
140
+ '사유 없는 면제는 이 채널의 존재 이유를 지운다. **면제가 아니라 오류로 낸다**'
141
+ % (', '.join(map(str, fonts)) or '대상 미기재'))
142
+ continue
143
+ for f in fonts:
144
+ out[_norm(f)] = why
145
+ return out, errs
146
+
147
+
148
+ def _family_of(tf):
149
+ """가족 단위 비교 — 굵기 변형(Bold/Light/…)을 가족으로 접는다."""
150
+ return re.sub(r'\s+(bold|semibold|extrabold|black|light|thin|medium|regular|italic|oblique)$',
151
+ '', _norm(tf)).strip()
152
+
153
+
154
+ def scan(cfg, root):
155
+ """preprep.py 진입점. (findings, notes)"""
156
+ deck_s = (cfg.get('surfaces_by_id') or {}).get('built_deck')
157
+ if not deck_s:
158
+ return [], ['L15-b font-embed : built_deck 미선언 — NOT_CONFIGURED (0 아님)']
159
+ deck = os.path.normpath(os.path.join(root, os.path.expanduser(deck_s['path'])))
160
+ if not os.path.exists(deck):
161
+ return [], ['L15-b font-embed : built_deck 실물 없음(%s) — UNMEASURED (0 아님)' % deck]
162
+
163
+ try:
164
+ z = zipfile.ZipFile(deck)
165
+ emb, styles, dangling = embedded_fonts(z)
166
+ used, unresolved, sym_cs = used_fonts(z)
167
+ except Exception as e:
168
+ return [], ['L15-b font-embed : 계기 오류(%s: %s) — UNMEASURED (0 아님)'
169
+ % (type(e).__name__, e)]
170
+
171
+ findings, notes = [], []
172
+ exempt, errs = _exempt_rules(cfg)
173
+ findings += errs
174
+
175
+ if not used:
176
+ notes.append('L15-b font-embed : `slides/` 에서 읽은 서체 토큰 0 — 🟥 UNMEASURED, '
177
+ '「임베드 완전」이 아니다')
178
+ return findings, notes
179
+
180
+ emb_fams = {_family_of(f) for f in emb}
181
+ missing = Counter()
182
+ exempted = Counter()
183
+ for tf, c in used.items():
184
+ fam = _family_of(tf)
185
+ if fam in emb_fams or _norm(tf) in {_norm(f) for f in emb}:
186
+ continue
187
+ if _norm(tf) in exempt or fam in {_family_of(k) for k in exempt}:
188
+ exempted[tf] += c
189
+ continue
190
+ missing[tf] += c
191
+
192
+ if missing:
193
+ findings.append(
194
+ 'L15-b font-embed : **임베드 없이 이름만 부른 서체 %d종 / 런 %d회** — '
195
+ '이 서체가 없는 PC에서는 렌더러가 **조용히 대체**한다(대체는 파일에 안 남는다). '
196
+ '해당: %s' % (len(missing), sum(missing.values()),
197
+ ' · '.join('%s(%d회)' % (t, c) for t, c in missing.most_common())))
198
+ if not emb:
199
+ findings.append(
200
+ 'L15-b font-embed : 🟥 **임베드가 0 종이다.** 이 축에서 0 은 UNMEASURED 가 아니라 '
201
+ 'FAIL 이다 — 덱이 아무것도 들고 다니지 않는다는 것은 «못 쟀다»가 아니라 «잰 사실»이다')
202
+
203
+ # 🟥 임베드했는데 안 쓰는 것 — 목록이 손으로 채워졌다는 신호다(실사고의 절반)
204
+ unused = sorted(f for f in emb if _family_of(f) not in {_family_of(u) for u in used})
205
+ if unused:
206
+ notes.append('L15-b font-embed : ⓘ 임베드했지만 `slides/` 분포에 0회인 서체 — '
207
+ + ' · '.join(unused)
208
+ + '. 자체로는 결함이 아니지만, **쓰는 것이 빠진 것과 같이 나오면** 그 목록은 '
209
+ '실사용에서 유도된 게 아니라 손으로 채워진 것이다')
210
+
211
+ for fam, style, part in dangling:
212
+ findings.append('L15-b font-embed : 선언된 임베드의 실물이 없다 — %s/%s → %s '
213
+ '(선언만 있고 부품이 없으면 임베드가 아니다)' % (fam, style, part))
214
+
215
+ notes.append('L15-b font-embed : 임베드 %d종 · `slides/` 사용 %d종 / 런 %d회 — %s'
216
+ % (len(emb), len(used), sum(used.values()),
217
+ 'FAIL %d종 미임베드' % len(missing) if missing else '전량 임베드됨'))
218
+ for fam in sorted(emb):
219
+ st = styles.get(fam) or []
220
+ if st and 'bold' not in st and any(_family_of(u) == _family_of(fam) and
221
+ _norm(u) != _norm(fam) for u in used):
222
+ notes.append(' ⓘ %s — 임베드된 스타일이 %s 뿐인데 이 가족의 변형을 쓴다. '
223
+ '변형은 렌더러가 합성할 수 있고 그 결과는 파일에 안 남는다 (UNMEASURED)'
224
+ % (fam, '/'.join(st)))
225
+ for tf, c in exempted.most_common():
226
+ notes.append(' 면제됨 %s (%d회) — %s' % (tf, c, exempt.get(_norm(tf))
227
+ or exempt.get(_family_of(tf), '')))
228
+ if unresolved:
229
+ notes.append('L15-b font-embed : 🟥 테마 참조를 못 푼 토큰 — '
230
+ + ' · '.join('%s(%d)' % kv for kv in unresolved.most_common())
231
+ + ' — 그 자리의 실제 서체는 UNMEASURED (0 아님)')
232
+ if sym_cs:
233
+ notes.append('L15-b font-embed : ⓘ `a:sym`/`a:cs` 로만 지정된 서체 %d종 — 이 레인은 '
234
+ '`a:latin`·`a:ea` 만 판정한다. 그 자리는 UNMEASURED (0 아님)' % len(sym_cs))
235
+ return findings, notes
@@ -1,12 +1,42 @@
1
1
  import glob,re,os,sys
2
2
  from lxml import etree
3
+
4
+ # ── 종료코드 계약 (SKILL.md §쓰는 법) ────────────────────────────────────────
5
+ # 0 통과 · 1 발견 · 2 판정불가(계기오류/미측정 — 🟥 PASS 아님)
6
+ # 🟥 2026-09-21 수리: 이 게이트는 «판정불가»를 «발견»으로 렌더하고 있었다.
7
+ # 실사고 — 정본 v1.4 에 `docProps/app.xml` 이 없어(python-pptx 재저장이 떨어뜨린다)
8
+ # ④ 의 `open('docProps/app.xml')` 이 FileNotFoundError 로 죽으면서 **rc=1** 을 냈다.
9
+ # 읽는 쪽은 그것을 「결함을 찾았다」로 읽는다. 실제로는 **한 줄도 검사하지 못한 것**이다.
10
+ # ⇒ 부품 부재·계기 오류는 전부 **rc=2** 로 낸다. [[feedback_not_found_is_not_zero_family]]
11
+ def _unmeasured(*a):
12
+ print(' ⚠ UNMEASURED —',*a)
13
+ print('GATE UNMEASURED · 판정불가 (계기오류/부품부재 — 🟥 PASS 아님)')
14
+ sys.stdout.flush(); os._exit(2)
15
+
16
+ def _instrument_error(_t,_v,_tb):
17
+ import traceback
18
+ print(' ⚠ 계기 오류 —',''.join(traceback.format_exception_only(_t,_v)).strip())
19
+ print(' (게이트 자신이 죽은 것이지 덱의 결함이 아니다)')
20
+ print('GATE UNMEASURED · 판정불가 (계기오류 — 🟥 PASS 아님)')
21
+ sys.stdout.flush(); os._exit(2)
22
+ sys.excepthook = _instrument_error
23
+
3
24
  # 작업 트리: 인자 > 환경변수 OOXML_ROOT > 현재 디렉터리(v4 있으면 그쪽)
4
25
  _root = sys.argv[1] if len(sys.argv)>1 else os.environ.get('OOXML_ROOT')
5
26
  if not _root:
6
27
  _root = 'v4' if os.path.isdir('v4/ppt/slides') else '.'
7
28
  if not os.path.isdir(os.path.join(_root,'ppt','slides')):
8
- print('GATE FAIL · 작업 트리를 못 찾음:',_root); sys.exit(1)
29
+ # 🟥 「못 찾음」은 발견이 아니라 판정불가다 (예전에는 rc=1 이었다)
30
+ _unmeasured('작업 트리를 못 찾음:',_root)
9
31
  os.chdir(_root)
32
+
33
+ # 🟥 필수 부품 선검사 — 없으면 **한 줄도 검사하지 못한다**. 트레이스백 대신 이름으로 낸다.
34
+ _REQUIRED = ('[Content_Types].xml','ppt/presentation.xml',
35
+ 'ppt/_rels/presentation.xml.rels','docProps/app.xml')
36
+ _missing = [r for r in _REQUIRED if not os.path.exists(r)]
37
+ if _missing:
38
+ _unmeasured('pptx 필수 부품 없음:',_missing,
39
+ '· docProps/app.xml 이 없으면 python-pptx 재저장을 의심해라(통짜로 떨어뜨린다)')
10
40
  ok=True; P='http://schemas.openxmlformats.org/presentationml/2006/main'
11
41
  _A='http://schemas.openxmlformats.org/drawingml/2006/main'
12
42
  def fail(*a):
@@ -126,8 +156,18 @@ for _p in sorted(glob.glob('ppt/slides/slide*.xml')):
126
156
  # 그래서 «지금»을 기준선에 박고 **늘어날 때만** 막는다. 줄면 낮추라고 알린다.
127
157
  # 🟥 기준선은 «총합»이 아니라 «굵기별»이다 — 총합만 세면 어느 굵기가 새로 생겼는지
128
158
  # 못 짚어서, 판정은 맞고 처방은 틀린 게이트가 된다.
159
+ # 🟥 2026-09-21 수리: 기준선은 «덱별»이다. 전역 파일 하나로 판정하면 **다른 덱의 수치로
160
+ # 이 덱을 판정**한다 — 실사고: 외부 디자인 검수본을 스캔하니 「토큰 밖 8종」이 떴는데, 직전 판과
161
+ # `<a:ln w=…>` 히스토그램이 사실상 동일했다. 저쪽 탓이 아니라 기준선이 이 덱 것이 아니었다.
162
+ # ⇒ 교정된 기준선이 없으면 **UNCALIBRATED** 로 찍고 «발견»으로 세지 않는다(rc=2).
129
163
  _C1={12700:'구조 1pt',38100:'테두리 3pt',88900:'흐름 7pt',177800:'강조 14pt'}
130
- _BASE=os.path.join(os.path.dirname(os.path.abspath(__file__)),'c1_baseline.txt')
164
+ _BASE_ENV=os.environ.get('PREPREP_C1_BASELINE')
165
+ _BASE_LOCAL='c1_baseline.txt' # 작업 트리 안 (cwd 가 트리다)
166
+ _BASE_GLOBAL=os.path.join(os.path.dirname(os.path.abspath(__file__)),'c1_baseline.txt')
167
+ if _BASE_ENV: _BASE,_CALIBRATED = _BASE_ENV, True
168
+ elif os.path.exists(_BASE_LOCAL): _BASE,_CALIBRATED = _BASE_LOCAL, True
169
+ else: _BASE,_CALIBRATED = _BASE_GLOBAL,False
170
+ _c1_uncalibrated=False
131
171
  _seen={}
132
172
  for _p in sorted(glob.glob('ppt/slides/slide*.xml')):
133
173
  for _l in etree.parse(_p).iter('{%s}ln'%_A):
@@ -136,7 +176,20 @@ for _p in sorted(glob.glob('ppt/slides/slide*.xml')):
136
176
  _seen.setdefault(int(_w),[]).append(os.path.basename(_p))
137
177
  _now={k:len(v) for k,v in _seen.items()}
138
178
  _dump=lambda d:'\n'.join('%d %d'%(k,d[k]) for k in sorted(d))
139
- if os.path.exists(_BASE):
179
+ # 🟥 미교정이면 «늘었다»도 «줄었다»도 판정하지 않는다.
180
+ # 첫 수리는 거짓 «발견» 쪽만 막았는데, known-pair 가 **반대 방향**을 드러냈다:
181
+ # 남의 기준선이 이 덱보다 «크면» 게이트가 그냥 조용해진다(388 → 1 을 「줄었다 ✅」로 읽었다).
182
+ # 거짓 발견과 거짓 침묵은 같은 원인의 두 얼굴이고, 침묵 쪽이 더 위험하다(fail-open).
183
+ # ⇒ 미교정 + 토큰 밖이 하나라도 있으면 **측정만 하고 판정은 안 한다**(rc=2).
184
+ if _now and not _CALIBRATED:
185
+ _c1_uncalibrated=True
186
+ print(' ⚠ C1 UNCALIBRATED — 기준선이 **이 덱 것이 아니다**(전역 폴백: %s)'%os.path.relpath(_BASE))
187
+ print(' 🟥 이 축은 판정하지 않는다. 아래는 «측정»이지 «발견»이 아니다 — 어디에도 인용하지 마라.')
188
+ for _w in sorted(_now):
189
+ print(' w=%-7d (%.2fpt) 이 덱 %d곳 예: %s'%(_w,_w/12700,_now[_w],
190
+ ', '.join(sorted(set(_seen[_w]))[:3])))
191
+ print(' ↳ 이 덱의 기준선을 먼저 박아라: python3 %s <트리> --write-c1-baseline'%os.path.relpath(__file__))
192
+ elif os.path.exists(_BASE):
140
193
  _prev={}
141
194
  for _line in open(_BASE):
142
195
  _line=_line.split('#')[0].strip()
@@ -156,9 +209,18 @@ else:
156
209
  print(' ⚠ C1 기준선 없음 — 토큰 밖 %d곳(%d종). 박으려면:'%(sum(_now.values()),len(_now)))
157
210
  print(' python3 %s --write-c1-baseline'%os.path.relpath(__file__))
158
211
  if '--write-c1-baseline' in sys.argv:
212
+ # 🟥 전역 파일을 덮어쓰면 다음 덱이 또 남의 기준선을 물려받는다 — 기본은 **덱별 경로**다.
213
+ _BASE = _BASE_ENV or _BASE_LOCAL
159
214
  open(_BASE,'w').write('# C1 선 굵기 기준선 — «굵기 개수». gate.py ⑧ 이 읽는다.\n'+_dump(_now)+'\n')
160
215
  print(' ✍ 기준선 기록: %s (%d종 %d곳)'%(os.path.relpath(_BASE),len(_now),sum(_now.values())))
161
216
 
162
217
 
163
- print('GATE','PASS' if ok else 'FAIL','·',len(order),'장')
164
- sys.exit(0 if ok else 1)
218
+ # 🟥 우선순위: 진짜 발견(1) > 판정불가(2) > 통과(0).
219
+ # 발견이 있으면 그것을 낸다 — 미교정 축 하나 때문에 실재 결함을 2 뒤로 숨기지 않는다.
220
+ if not ok:
221
+ print('GATE FAIL ·',len(order),'장'); sys.exit(1)
222
+ if _c1_uncalibrated:
223
+ print('GATE UNMEASURED ·',len(order),'장 · 다른 축은 통과했으나 C1 이 미교정 (🟥 PASS 아님)')
224
+ sys.exit(2)
225
+ print('GATE PASS ·',len(order),'장')
226
+ sys.exit(0)
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env python3
2
+ """test_gate_exitcodes.py — gate.py 종료코드 계약의 known-pair.
3
+
4
+ 🟥 재는 것은 «결함을 찾나»가 아니라 **«판정불가를 발견으로 렌더하지 않나»**다.
5
+ 실사고(2026-09-21): 정본 v1.4 에 `docProps/app.xml` 이 없어 게이트가 FileNotFoundError 로
6
+ 죽으면서 **rc=1(발견)** 을 냈다. 한 줄도 검사하지 못한 상태가 「결함을 찾았다」로 읽혔다.
7
+
8
+ 양팔은 **한 변수만 다르다** — 같은 덱에서 `docProps/app.xml` 하나를 뺐나 넣었나.
9
+ 컨트롤이 «볼 게 없어서» 조용한 것이 아님을 P1 에서 확인한다(장 수가 같다).
10
+
11
+ python3 test_gate_exitcodes.py # 전 팔 실행. 종료코드 0 통과 / 1 실패
12
+
13
+ 의존: python-pptx (픽스처를 그때그때 굽는다 — 바이너리를 레포에 안 둔다,
14
+ `fixtures/mk_slide_fixtures.py` 와 같은 관례).
15
+ """
16
+ import os, sys, shutil, zipfile, subprocess, tempfile
17
+
18
+ HERE = os.path.dirname(os.path.abspath(__file__))
19
+ GATE = os.path.join(HERE, 'gate.py')
20
+
21
+ def build_tree(dest):
22
+ """python-pptx 로 빈 덱을 굽고 풀어서 «정상 트리»를 만든다."""
23
+ from pptx import Presentation
24
+ pptx = os.path.join(dest, 'probe.pptx')
25
+ prs = Presentation()
26
+ prs.slides.add_slide(prs.slide_layouts[6]) # 빈 레이아웃
27
+ prs.save(pptx)
28
+ tree = os.path.join(dest, 'tree')
29
+ with zipfile.ZipFile(pptx) as z: z.extractall(tree)
30
+ return tree
31
+
32
+ def ensure_app_xml(tree, n_slides=1):
33
+ """app.xml 을 **항상 다시 쓴다** — 컨트롤 팔이 깨끗해야 하기 때문이다.
34
+
35
+ 🟥 이 함수가 원래는 «없으면 만든다» 였는데, 그러면 컨트롤이 rc=1 로 떨어졌다.
36
+ 원인이 곧 체크리스트 §F5 다: **python-pptx 의 기본 템플릿이 자기 app.xml 을 통짜로
37
+ 물려준다** — 1장짜리 덱인데 `<Slides>` 는 템플릿 값이라 ④ 가 정확히 그걸 잡는다.
38
+ 즉 컨트롤의 실패는 게이트의 결함이 아니라 **참인 발견**이었다. 그래서 억누르는 대신
39
+ **팔을 제대로 굽는다** — 부재 축 하나만 남기려면 나머지가 참이어야 한다.
40
+ """
41
+ p = os.path.join(tree, 'docProps', 'app.xml')
42
+ os.makedirs(os.path.dirname(p), exist_ok=True)
43
+ open(p, 'w', encoding='utf-8').write(
44
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'
45
+ '<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"'
46
+ ' xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">'
47
+ '<Slides>%d</Slides><Notes>%d</Notes>'
48
+ '<TitlesOfParts><vt:vector size="%d" baseType="lpstr">%s</vt:vector></TitlesOfParts>'
49
+ '</Properties>' % (n_slides, n_slides, n_slides, '<vt:lpstr>p</vt:lpstr>' * n_slides))
50
+ return True
51
+
52
+ def run_gate(tree):
53
+ r = subprocess.run([sys.executable, GATE, tree], capture_output=True, text=True)
54
+ return r.returncode, (r.stdout + r.stderr)
55
+
56
+ def main():
57
+ tmp = tempfile.mkdtemp(prefix='gate_pair_')
58
+ try:
59
+ tree = build_tree(tmp)
60
+ n = len([f for f in os.listdir(os.path.join(tree, 'ppt', 'slides'))
61
+ if f.startswith('slide') and f.endswith('.xml')])
62
+ ensure_app_xml(tree, n)
63
+
64
+ # ── ARM B (known-negative / 컨트롤): 부품이 다 있다 → 0 이어야 한다
65
+ rc_b, out_b = run_gate(tree)
66
+
67
+ # ── ARM A (known-positive): app.xml 하나만 뺀다 → 2 여야 한다 (1 이면 회귀)
68
+ armA = tree + '_noapp'
69
+ shutil.copytree(tree, armA)
70
+ os.remove(os.path.join(armA, 'docProps', 'app.xml'))
71
+ n_a = len([f for f in os.listdir(os.path.join(armA, 'ppt', 'slides'))
72
+ if f.startswith('slide') and f.endswith('.xml')])
73
+ rc_a, out_a = run_gate(armA)
74
+
75
+ # ── ARM C: 트리 자체가 없다 → 2 (예전엔 1 이었다)
76
+ rc_c, out_c = run_gate(os.path.join(tmp, 'nope'))
77
+
78
+ # ── ARM D/E: C1 기준선 «덱별» 계약 ─────────────────────────────────
79
+ # 🟥 재는 것: 전역 기준선으로 «늘었다»를 판정하지 않나. 실사고 — 외부 디자인 검수본에서
80
+ # 「토큰 밖 8종」이 떴는데 직전 판과 선굵기 히스토그램이 사실상 같았다. 저쪽 탓이
81
+ # 아니라 기준선이 이 덱 것이 아니었다. 그 수치는 인용되면 안 되는 값이었다.
82
+ armD = tree + '_c1'
83
+ shutil.copytree(tree, armD)
84
+ sp = os.path.join(armD, 'ppt', 'slides', 'slide1.xml')
85
+ x = open(sp, encoding='utf-8').read()
86
+ # 토큰(12700/38100/88900/177800) 밖 굵기를 하나 심는다
87
+ NS = 'http://schemas.openxmlformats.org/drawingml/2006/main'
88
+ inj = ('<p:sp><p:nvSpPr><p:cNvPr id="99" name="c1probe"/><p:cNvSpPr/><p:nvPr/></p:nvSpPr>'
89
+ '<p:spPr><a:xfrm xmlns:a="%s"><a:off x="0" y="0"/><a:ext cx="100000" cy="100000"/></a:xfrm>'
90
+ '<a:prstGeom xmlns:a="%s" prst="rect"><a:avLst/></a:prstGeom>'
91
+ '<a:ln xmlns:a="%s" w="31750"/></p:spPr>'
92
+ '<p:txBody><a:bodyPr xmlns:a="%s"/><a:lstStyle xmlns:a="%s"/>'
93
+ '<a:p xmlns:a="%s"/></p:txBody></p:sp>' % ((NS,)*6))
94
+ x = x.replace('</p:spTree>', inj + '</p:spTree>', 1)
95
+ open(sp, 'w', encoding='utf-8').write(x)
96
+ env_nolocal = {k: v for k, v in os.environ.items() if k != 'PREPREP_C1_BASELINE'}
97
+ rd = subprocess.run([sys.executable, GATE, armD], capture_output=True, text=True, env=env_nolocal)
98
+ rc_d, out_d = rd.returncode, rd.stdout + rd.stderr
99
+ # E: 이 덱의 기준선을 박고 다시 → 0
100
+ subprocess.run([sys.executable, GATE, armD, '--write-c1-baseline'],
101
+ capture_output=True, text=True, env=env_nolocal)
102
+ re_ = subprocess.run([sys.executable, GATE, armD], capture_output=True, text=True, env=env_nolocal)
103
+ rc_e, out_e = re_.returncode, re_.stdout + re_.stderr
104
+
105
+ fails = []
106
+ def chk(name, got, want, out, extra=''):
107
+ good = (got == want)
108
+ print(' %s %-34s rc=%s (기대 %s) %s' % ('✅' if good else '❌', name, got, want, extra))
109
+ if not good:
110
+ fails.append(name)
111
+ print(' ↳ 출력:', ' / '.join(out.strip().splitlines()[-3:]))
112
+
113
+ print('gate.py 종료코드 known-pair')
114
+ print(' 컨트롤 생존 확인: 양팔 슬라이드 수 %d == %d' % (n, n_a))
115
+ if n != n_a: fails.append('control-parity')
116
+ chk('B 정상 덱 (부품 전부)', rc_b, 0, out_b)
117
+ chk('A app.xml 하나만 뺌', rc_a, 2, out_a, '← 1 이면 «판정불가가 발견으로» 회귀')
118
+ chk('C 작업 트리 자체가 없음', rc_c, 2, out_c, '← 1 이면 회귀')
119
+ chk('D 토큰밖 굵기 + 기준선 미교정', rc_d, 2, out_d, '← 1 이면 남의 기준선으로 «발견»을 낸 것')
120
+ chk('E 같은 덱, 기준선 박은 뒤', rc_e, 0, out_e, '← 컨트롤: 교정하면 조용해진다')
121
+ if 'UNCALIBRATED' not in out_d:
122
+ fails.append('D-wording'); print(' ❌ D 팔 출력에 UNCALIBRATED 가 없다')
123
+ else:
124
+ print(' ✅ D 팔이 UNCALIBRATED 로 말하고 «인용하지 마라»를 적는다')
125
+ if 'UNMEASURED' not in out_a:
126
+ fails.append('A-wording'); print(' ❌ A 팔 출력에 UNMEASURED 가 없다')
127
+ else:
128
+ print(' ✅ A 팔이 UNMEASURED 로 말한다')
129
+
130
+ print(('PASS' if not fails else 'FAIL · ' + ', '.join(fails)))
131
+ return 1 if fails else 0
132
+ finally:
133
+ shutil.rmtree(tmp, ignore_errors=True)
134
+
135
+ if __name__ == '__main__':
136
+ sys.exit(main())
@@ -11,6 +11,8 @@
11
11
  L4 getput — 왕복 no-op 컨트롤. **v0.1 미배선 → NOT_WIRED 로 말한다**(거짓 초록 금지)
12
12
  L12 diagram — 타입 JSON 도해가 «지금 JSON» 에서 validate 를 거쳐 구워졌나 (lane_diagram.py · 2026-09-05)
13
13
  L15 font — 서체가 그 덱의 **배포 템플릿**이 정한 집합을 벗어났나 (lane_font.py · 2026-09-11).
14
+ L15-b embed — **쓰는 서체를 덱이 들고 다니나** (lane_font_embed.py · 2026-09-21).
15
+ 임베드 0 = UNMEASURED 아니라 **FAIL** — 이 축은 부재가 곧 결함이다.
14
16
  🟥 마스터/레이아웃 상속분을 저자 이탈과 가르는 것이 이 레인의 본체다
15
17
 
16
18
  exit 0 = 전 레인 통과 · 1 = 발견 있음 · 2 = 계기 오류/미측정으로 판정 불가 (PASS 아님)
@@ -778,7 +780,7 @@ def main():
778
780
  _mods = sorted(m for m in ('lane_promise', 'lane_adjacent_dup', 'lane_progression',
779
781
  'lane_slide_relations', 'lane_geometry', 'lane_attr_consistency',
780
782
  'lane_screen_parity',
781
- 'lane_diagram', 'lane_slide_refs', 'lane_font')
783
+ 'lane_diagram', 'lane_slide_refs', 'lane_font', 'lane_font_embed')
782
784
  if os.path.exists(os.path.join(HERE, m + '.py')))
783
785
  # 🟥 2026-09-04 신설 — `--lane R1,R2,...` 로 **새 모듈 레인(R1-R5·P1/P3)만** 골라 끈다/켠다.
784
786
  # L1~L11 은 아직 이 필터를 안 탄다(usage 줄의 --lane 은 그쪽엔 미배선인 채 남아 있다 —
@@ -906,6 +908,19 @@ def main():
906
908
  findings += _f15; notes += _n15
907
909
  except Exception as _e:
908
910
  notes.append('L15 font : 계기 미실행 — NOT_WIRED (%s: %s) (0 아님)' % (type(_e).__name__, _e))
911
+ # L15-b font-embed — 쓰는 서체를 덱이 «들고 다니나»(2026-09-21 신설).
912
+ # 🟥 L15 와 다른 실패를 잡는다: L15 는 «템플릿 집합을 벗어났나», 여기는 «발표장 PC에
913
+ # 설치돼 있다고 가정하고 있나». SKILL §L15 가 «구조적으로 못 보는 것 셋» 중 하나로
914
+ # 적어 둔 «그 서체가 설치돼 있는지»의 **절반을 닫는다** — 설치 여부는 파일 밖이지만
915
+ # **임베드 여부는 파일 안**이다.
916
+ # 🟥 이 축은 «부재가 곧 결함»이라 임베드 0 은 UNMEASURED 가 아니라 FAIL 이다.
917
+ try:
918
+ import lane_font_embed
919
+ _f15b, _n15b = lane_font_embed.scan(cfg, root)
920
+ findings += _f15b; notes += _n15b
921
+ except Exception as _e:
922
+ notes.append('L15-b font-embed : 계기 미실행 — NOT_WIRED (%s: %s) (0 아님)'
923
+ % (type(_e).__name__, _e))
909
924
  # L12 diagram — 타입 JSON 도해가 «지금 JSON» 에서 validate 를 거쳐 구워졌나(2026-09-05 신설).
910
925
  # 차단: 선언된 diagram_source 표면에 한해 지문·validate·해상도·viewBox 폭·여백을 본다.
911
926
  # 영수증 없는 PNG(손그림)는 UNMEASURED 노트로만 — 0 이 아니다.