@chrono-meta/fh-gate 3.10.0 → 3.12.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 (34) hide show
  1. package/.claude/regression/probes_live.yaml +13 -5
  2. package/.claude-plugin/marketplace.json +4 -4
  3. package/AGENTS.md +1 -1
  4. package/CHEATSHEET.md +1 -1
  5. package/CLAUDE.md +8 -4
  6. package/bin/fh-codex-doctor.js +223 -25
  7. package/docs/codex-compat.md +1 -1
  8. package/knowledge/shared/harness-core/claude_md_gate_details.md +8 -4
  9. package/knowledge/shared/harness-core/governance_engineering_definition.md +403 -7
  10. package/knowledge/shared/harness-core/harness_terminal_correlation_and_recommendations.md +22 -6
  11. package/knowledge/shared/learnings/subagent_invocations_log.yaml +107 -0
  12. package/package.json +11 -2
  13. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  14. package/plugins/fh-commons/README.md +1 -1
  15. package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +269 -26
  16. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  17. package/plugins/fh-meta/CHANGELOG.md +44 -0
  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/citation_key_check.py +357 -0
  21. package/scripts/claim_propagation_scan.py +499 -0
  22. package/scripts/ko_tech_writer_calibrate.py +13 -4
  23. package/scripts/numeric_token_diff.py +389 -0
  24. package/scripts/probe_live_eval_lib.py +19 -1
  25. package/scripts/section_ref_check.py +591 -0
  26. package/scripts/selfcheck.sh +72 -0
  27. package/scripts/session_checklist.py +704 -0
  28. package/scripts/test_claim_propagation_lanes.sh +573 -0
  29. package/scripts/test_codex_doctor_root_lanes.sh +384 -0
  30. package/scripts/test_ko_tech_writer_lanes.sh +5 -1
  31. package/scripts/test_paper_integrity_lanes.sh +1473 -0
  32. package/scripts/test_probe_live_eval_lanes.sh +25 -4
  33. package/scripts/test_session_checklist_lanes.sh +746 -0
  34. package/templates/predelete_check.sh +28 -4
@@ -0,0 +1,746 @@
1
+ #!/bin/bash
2
+ # test_session_checklist_lanes.sh — known-pair lanes for session_checklist.py
3
+ # bash 3.2 compatible: no mapfile, no ${var,,}, no associative arrays.
4
+ set -u
5
+
6
+ SUBJ="${SUBJ:-scripts/session_checklist.py}"
7
+
8
+ PASS_COUNT=0
9
+ FAIL_COUNT=0
10
+
11
+ pass() { echo "✅ PASS $1"; PASS_COUNT=$((PASS_COUNT+1)); }
12
+ fail() { echo "❌ FAIL $1"; FAIL_COUNT=$((FAIL_COUNT+1)); }
13
+
14
+ run() {
15
+ local out="$1"
16
+ shift
17
+ python3 "$SUBJ" "$@" >"$out" 2>&1
18
+ RC=$?
19
+ }
20
+
21
+ TMPDIR_ROOT=$(mktemp -d 2>/dev/null || mktemp -d -t schk)
22
+ trap 'rm -rf "$TMPDIR_ROOT"' EXIT
23
+
24
+ # ---------------------------------------------------------------------------
25
+ # L1 — syntax + --help names the rc contract
26
+ # ---------------------------------------------------------------------------
27
+ L1_SYN_OUT="$TMPDIR_ROOT/l1_syn.out"
28
+ python3 -c "import ast; ast.parse(open('$SUBJ').read())" >"$L1_SYN_OUT" 2>&1
29
+ L1_SYN_RC=$?
30
+
31
+ run "$TMPDIR_ROOT/l1_help.out" --help
32
+ L1_HELP_RC=$RC
33
+
34
+ if [ "$L1_SYN_RC" -eq 0 ] && [ "$L1_HELP_RC" -eq 0 ] \
35
+ && grep -q "rc=4" "$TMPDIR_ROOT/l1_help.out" \
36
+ && grep -q "rc=10" "$TMPDIR_ROOT/l1_help.out" \
37
+ && grep -qi "DEAD CONTROL" "$TMPDIR_ROOT/l1_help.out"; then
38
+ pass "L1 syntax clean + --help names rc contract"
39
+ else
40
+ fail "L1 syntax_rc=$L1_SYN_RC help_rc=$L1_HELP_RC (see $TMPDIR_ROOT/l1_help.out)"
41
+ fi
42
+
43
+ # ---------------------------------------------------------------------------
44
+ # fixture builder for L2 / L2b — 3 raw + 4 excluded-class entries + 1 compaction
45
+ # summary carrying 3 quotes (1 duplicate of a raw utterance)
46
+ # ---------------------------------------------------------------------------
47
+ build_l2_fixture() {
48
+ # $1 = out path, $2 = "with_summary" | "no_summary"
49
+ python3 - "$1" "$2" <<'PYEOF'
50
+ import json, sys
51
+ out_path, mode = sys.argv[1], sys.argv[2]
52
+
53
+ RAW1 = "체크리스트 인스트루먼트 만들어줘 스크래치패드에 파이썬으로"
54
+ RAW2 = "L2 레인 통과하는지 확인해줘"
55
+ RAW3 = "야간자율주행 계속해도 좋아"
56
+
57
+ rows = [
58
+ {"type": "user", "timestamp": "2026-09-17T05:56:00.000Z",
59
+ "message": {"role": "user", "content": RAW1}},
60
+ {"type": "user",
61
+ "message": {"role": "user", "content": [
62
+ {"type": "tool_result", "tool_use_id": "t1", "content": "some tool output"}
63
+ ]}},
64
+ {"type": "user",
65
+ "message": {"role": "user",
66
+ "content": "<system-reminder>\nreminder body\n</system-reminder>"}},
67
+ {"type": "user",
68
+ "message": {"role": "user",
69
+ "content": "<task-notification>agent finished</task-notification>"}}, # v11: the real shape ends with the closing tag
70
+ {"type": "user",
71
+ "message": {"role": "user",
72
+ "content": "Another Claude session sent a message:\n<agent-message from=\"peer\">\n[Subagent hand-back] hello there\n</agent-message>"}}, # v9: the REAL envelope shape (sentence + tag)
73
+ {"type": "user", "timestamp": "2026-09-17T06:01:00.000Z",
74
+ "message": {"role": "user", "content": RAW2}},
75
+ {"type": "user", "timestamp": "2026-09-17T06:05:00.000Z",
76
+ "message": {"role": "user", "content": RAW3}},
77
+ ]
78
+
79
+ if mode == "with_summary":
80
+ summary_text = (
81
+ "This session is being continued from a previous conversation "
82
+ "that ran out of context.\n\n"
83
+ "Summary:\n"
84
+ "1. Primary Request and Intent:\n"
85
+ " - placeholder narrative text, not a quote list.\n\n"
86
+ "6. All user messages:\n"
87
+ ' - "' + RAW1 + '"\n'
88
+ ' - "새로운 이월 항목 검토해줘"\n'
89
+ ' - "체크리스트 스펙 문서 확인해봐"\n\n'
90
+ "7. Pending Tasks:\n"
91
+ " - something not in the quote list\n"
92
+ )
93
+ rows.append({"type": "user", "message": {"role": "user", "content": summary_text}})
94
+
95
+ with open(out_path, "w", encoding="utf-8") as f:
96
+ for r in rows:
97
+ f.write(json.dumps(r, ensure_ascii=False) + "\n")
98
+ PYEOF
99
+ }
100
+
101
+ L2_JSONL="$TMPDIR_ROOT/l2.jsonl"
102
+ build_l2_fixture "$L2_JSONL" "with_summary"
103
+
104
+ run "$TMPDIR_ROOT/l2.out" extract --transcript "$L2_JSONL"
105
+ L2_ROWCOUNT=$(grep -c '^| ' "$TMPDIR_ROOT/l2.out")
106
+ # subtract the header row (which also starts with '| ') to get data rows
107
+ L2_DATAROWS=$((L2_ROWCOUNT - 1))
108
+
109
+ if [ "$RC" -eq 0 ] \
110
+ && grep -q "채널 2/2" "$TMPDIR_ROOT/l2.out" \
111
+ && grep -q "raw 3건" "$TMPDIR_ROOT/l2.out" \
112
+ && grep -q "압축 요약 3건(중복 제거 후 2건 추가)" "$TMPDIR_ROOT/l2.out" \
113
+ && [ "$L2_DATAROWS" -eq 5 ]; then
114
+ pass "L2 extract: 3 raw + 2/3 summary added, 5 data rows, channel 2/2"
115
+ else
116
+ fail "L2 rc=$RC datarows=$L2_DATAROWS (see $TMPDIR_ROOT/l2.out)"
117
+ fi
118
+
119
+ L2B_JSONL="$TMPDIR_ROOT/l2b.jsonl"
120
+ build_l2_fixture "$L2B_JSONL" "no_summary"
121
+
122
+ run "$TMPDIR_ROOT/l2b.out" extract --transcript "$L2B_JSONL"
123
+ L2B_ROWCOUNT=$(grep -c '^| ' "$TMPDIR_ROOT/l2b.out")
124
+ L2B_DATAROWS=$((L2B_ROWCOUNT - 1))
125
+
126
+ if [ "$RC" -eq 0 ] \
127
+ && grep -q "채널 2/2" "$TMPDIR_ROOT/l2b.out" \
128
+ && grep -q "압축 요약 0건(중복 제거 후 0건 추가)" "$TMPDIR_ROOT/l2b.out" \
129
+ && [ "$L2B_DATAROWS" -eq 3 ]; then
130
+ pass "L2b extract without summary entry: channel still 2/2, 0/0, 3 rows"
131
+ else
132
+ fail "L2b rc=$RC datarows=$L2B_DATAROWS (see $TMPDIR_ROOT/l2b.out)"
133
+ fi
134
+
135
+ # ---------------------------------------------------------------------------
136
+ # L3 — check on a fully filled fixture -> rc=0
137
+ # ---------------------------------------------------------------------------
138
+ L3_MD="$TMPDIR_ROOT/l3_clean.md"
139
+ {
140
+ echo "# clean checklist"
141
+ echo ""
142
+ echo "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
143
+ echo "|---|---|---|---|---|---|---|"
144
+ echo "| 1 | 09-17 05:56 | greeting | n/a | — | — | — |"
145
+ echo "| 2 | 09-17 06:01 | did the thing | ✅ | fixture.md:1 | — | — |"
146
+ echo "| 3 | 09-17 06:05 | still going | ⏳ | wip.md | 팔이 도는 중 | 다음 세션 |"
147
+ echo "| 4 | 09-17 06:10 | half done | 🟡 | partial.md:9 | 일부만 착지 | 이번 세션 |"
148
+ echo "| 5 | 09-17 06:15 | held by operator | ⏸ | — | 운영자 보류 지시 | 이월 |"
149
+ echo "| 6 | 09-17 06:20 | cannot confirm | 🔎 | — | 기록에서 증거 못 찾음 | 다음 세션 재구성 |"
150
+ echo "| 7 | 09-17 06:25 | dropped | ❌ | — | 우선순위 밀림 | 이월 |"
151
+ } > "$L3_MD"
152
+
153
+ run "$TMPDIR_ROOT/l3.out" check --file "$L3_MD"
154
+ if [ "$RC" -eq 0 ] && grep -q "rows=7 ok=7 violations=0 rc=0" "$TMPDIR_ROOT/l3.out"; then
155
+ pass "L3 check on fully filled fixture -> rc=0"
156
+ else
157
+ fail "L3 rc=$RC (see $TMPDIR_ROOT/l3.out)"
158
+ fi
159
+
160
+ # ---------------------------------------------------------------------------
161
+ # L4 — three known violations -> rc=1, three violations naming right rows
162
+ # ---------------------------------------------------------------------------
163
+ L4_MD="$TMPDIR_ROOT/l4_violations.md"
164
+ {
165
+ echo "# violating checklist"
166
+ echo ""
167
+ echo "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
168
+ echo "|---|---|---|---|---|---|---|"
169
+ echo "| 1 | 09-17 05:56 | clean done row | ✅ | fixture.md:1 | — | — |"
170
+ echo "| 2 | 09-17 06:01 | enum violation | ✔ done | ev | reason | proposal |"
171
+ echo "| 3 | 09-17 06:05 | not-done missing reason | ❌ | — | | some proposal |"
172
+ echo "| 4 | 09-17 06:10 | done missing evidence | ✅ | — | — | — |"
173
+ } > "$L4_MD"
174
+
175
+ run "$TMPDIR_ROOT/l4.out" check --file "$L4_MD"
176
+ if [ "$RC" -eq 1 ] \
177
+ && grep -q "^row 2 invalid" "$TMPDIR_ROOT/l4.out" \
178
+ && grep -q "^row 3 missing 사유" "$TMPDIR_ROOT/l4.out" \
179
+ && grep -q "^row 4 DONE missing 증거" "$TMPDIR_ROOT/l4.out" \
180
+ && grep -q "violations=3" "$TMPDIR_ROOT/l4.out"; then
181
+ pass "L4 check: 3 known violations, right rows named, rc=1"
182
+ else
183
+ fail "L4 rc=$RC (see $TMPDIR_ROOT/l4.out)"
184
+ fi
185
+
186
+ # ---------------------------------------------------------------------------
187
+ # L5 — header + zero data rows -> rc=4 (DEAD CONTROL)
188
+ # ---------------------------------------------------------------------------
189
+ L5_MD="$TMPDIR_ROOT/l5_empty.md"
190
+ {
191
+ echo "# empty table"
192
+ echo ""
193
+ echo "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
194
+ echo "|---|---|---|---|---|---|---|"
195
+ } > "$L5_MD"
196
+
197
+ run "$TMPDIR_ROOT/l5.out" check --file "$L5_MD"
198
+ if [ "$RC" -eq 4 ] && grep -q "rows=0 ok=0 violations=0 rc=4" "$TMPDIR_ROOT/l5.out"; then
199
+ pass "L5 check on header-only table -> rc=4 DEAD CONTROL"
200
+ else
201
+ fail "L5 rc=$RC (see $TMPDIR_ROOT/l5.out)"
202
+ fi
203
+
204
+ # ---------------------------------------------------------------------------
205
+ # L6 — missing path -> rc=10
206
+ # ---------------------------------------------------------------------------
207
+ run "$TMPDIR_ROOT/l6.out" check --file "$TMPDIR_ROOT/does_not_exist_$$.md"
208
+ if [ "$RC" -eq 10 ] && grep -q "rc=10" "$TMPDIR_ROOT/l6.out"; then
209
+ pass "L6 check on missing path -> rc=10"
210
+ else
211
+ fail "L6 rc=$RC (see $TMPDIR_ROOT/l6.out)"
212
+ fi
213
+
214
+ # ---------------------------------------------------------------------------
215
+ # L7 — revert probe: patch enum-membership fallthrough to always pass,
216
+ # show L4(a) violation goes GREEN on the copy while original stays RED.
217
+ # ---------------------------------------------------------------------------
218
+ L7_COPY="$TMPDIR_ROOT/session_checklist_patched.py"
219
+ cp "$SUBJ" "$L7_COPY"
220
+
221
+ L7_PATCH_OUT="$TMPDIR_ROOT/l7_patch.out"
222
+ python3 - "$L7_COPY" >"$L7_PATCH_OUT" 2>&1 <<'PYEOF'
223
+ import sys
224
+ path = sys.argv[1]
225
+ with open(path, encoding="utf-8") as f:
226
+ lines = f.readlines()
227
+ target = " return None # ENUM-MEMBERSHIP-FALLTHROUGH\n"
228
+ count = sum(1 for l in lines if l == target)
229
+ print("ANCHOR-COUNT", count)
230
+ if count != 1:
231
+ sys.exit(2)
232
+ for i, l in enumerate(lines):
233
+ if l == target:
234
+ lines[i] = " return 'DONE' # PATCHED-FOR-REVERT-PROBE\n"
235
+ break
236
+ with open(path, "w", encoding="utf-8") as f:
237
+ f.writelines(lines)
238
+ PYEOF
239
+ L7_PATCH_RC=$?
240
+
241
+ L7_MD="$TMPDIR_ROOT/l7_single_violation.md"
242
+ {
243
+ echo "# single enum violation"
244
+ echo ""
245
+ echo "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
246
+ echo "|---|---|---|---|---|---|---|"
247
+ echo "| 1 | 09-17 06:01 | enum violation | ✔ done | ev | reason | proposal |"
248
+ } > "$L7_MD"
249
+
250
+ python3 "$SUBJ" check --file "$L7_MD" >"$TMPDIR_ROOT/l7_orig.out" 2>&1
251
+ L7_ORIG_RC=$?
252
+ python3 "$L7_COPY" check --file "$L7_MD" >"$TMPDIR_ROOT/l7_patched.out" 2>&1
253
+ L7_PATCHED_RC=$?
254
+
255
+ if [ "$L7_PATCH_RC" -eq 0 ] && grep -q "ANCHOR-COUNT 1" "$L7_PATCH_OUT" \
256
+ && [ "$L7_ORIG_RC" -eq 1 ] && grep -q "^row 1 invalid" "$TMPDIR_ROOT/l7_orig.out" \
257
+ && [ "$L7_PATCHED_RC" -eq 0 ] && ! grep -q "invalid" "$TMPDIR_ROOT/l7_patched.out"; then
258
+ pass "L7 revert probe: exactly 1 anchor line, original RED / patched GREEN"
259
+ else
260
+ fail "L7 patch_rc=$L7_PATCH_RC orig_rc=$L7_ORIG_RC patched_rc=$L7_PATCHED_RC (see $TMPDIR_ROOT/l7_*.out)"
261
+ fi
262
+
263
+ # ---------------------------------------------------------------------------
264
+ # L8 — real transcript, env-gated
265
+ # ---------------------------------------------------------------------------
266
+ if [ -z "${CHECKLIST_REAL_TRANSCRIPT:-}" ]; then
267
+ echo "⏭ SKIP L8 (SKIP ≠ PASS)"
268
+ else
269
+ run "$TMPDIR_ROOT/l8.out" extract --transcript "$CHECKLIST_REAL_TRANSCRIPT"
270
+ L8_ROWCOUNT=$(grep -c '^| ' "$TMPDIR_ROOT/l8.out")
271
+ L8_DATAROWS=$((L8_ROWCOUNT - 1))
272
+ # 🟥 known-positive of the SUMMARY channel: a string that exists only in the compaction summaries of the
273
+ # real transcript (default = the night-drive delegation phrase of this author's session). v6 first cut
274
+ # dropped 3 of 4 real summaries (heading `6. **All user messages:**` did not match) and only this
275
+ # assertion would have said so — «rows ≥ 1» was green.
276
+ L8_KP="${CHECKLIST_REAL_KNOWN_POSITIVE:-야간자율주행}"
277
+ if [ "$RC" -eq 0 ] && [ "$L8_DATAROWS" -ge 1 ] && grep -q "채널 2/2" "$TMPDIR_ROOT/l8.out" \
278
+ && grep '^| S' "$TMPDIR_ROOT/l8.out" | grep -q -- "$L8_KP"; then
279
+ pass "L8 real-transcript extract: rows=$L8_DATAROWS, channel 2/2, summary known-positive «${L8_KP}» present"
280
+ else
281
+ fail "L8 rc=$RC datarows=$L8_DATAROWS known-positive «${L8_KP}» in S-rows: $(grep '^| S' "$TMPDIR_ROOT/l8.out" | grep -c -- "$L8_KP") (see $TMPDIR_ROOT/l8.out)"
282
+ fi
283
+ fi
284
+
285
+ # ---------------------------------------------------------------------------
286
+ # L9–L14 — 🟥 cross-family round 1 (codex, 2026-09-18): 4 MAJOR + 3 MINOR, every one silent.
287
+ # L9 a summary quote wrapped across two lines was dropped with no header signal
288
+ # L10 two DISTINCT requests sharing their first 40 chars collapsed into one (dedupe on a prefix)
289
+ # L11 a fenced example table was picked as THE checklist and masked the real one (rc=0)
290
+ # L12 a clean earlier table masked a malformed later one (only the first table was checked)
291
+ # L13 a row shorter than the header passed
292
+ # L14 an escaped inner quote split one utterance into two rows (header over-counted)
293
+ # ---------------------------------------------------------------------------
294
+ build_jsonl() { # build_jsonl <out> <python expr producing list of dicts>
295
+ python3 - "$1" "$2" <<'PYEOF'
296
+ import json, sys
297
+ out, expr = sys.argv[1], sys.argv[2]
298
+ rows = eval(expr)
299
+ with open(out, "w", encoding="utf-8") as f:
300
+ for r in rows:
301
+ f.write(json.dumps(r, ensure_ascii=False) + "\n")
302
+ PYEOF
303
+ }
304
+ SUMHEAD='This session is being continued from a previous conversation that ran out of context.\n\nSummary:\n1. Primary Request and Intent:\n - setup\n\n6. All user messages:\n'
305
+ SUMTAIL='\n7. Pending Tasks:\n - keep going\n'
306
+
307
+ # L9
308
+ build_jsonl "$TMPDIR_ROOT/l9.jsonl" "[{'type':'user','message':{'role':'user','content':'$SUMHEAD - \"Please update the rollout checklist,\n then verify every unchecked item\"$SUMTAIL'}}]"
309
+ run "$TMPDIR_ROOT/l9.out" extract --transcript "$TMPDIR_ROOT/l9.jsonl"
310
+ if [ "$RC" -eq 0 ] && grep -q "압축 요약 1건(중복 제거 후 1건 추가)" "$TMPDIR_ROOT/l9.out" \
311
+ && grep -q "rollout checklist, then verify every unchecked item" "$TMPDIR_ROOT/l9.out"; then
312
+ pass "L9 extract: a summary quote wrapped over two lines is one row (was dropped silently)"
313
+ else
314
+ fail "L9 rc=$RC (see $TMPDIR_ROOT/l9.out)"
315
+ fi
316
+
317
+ # L10
318
+ build_jsonl "$TMPDIR_ROOT/l10.jsonl" "[{'type':'user','timestamp':'2026-09-18T01:00:00.000Z','message':{'role':'user','content':'Please investigate the deployment checklist alpha path and record evidence for it.'}},{'type':'user','message':{'role':'user','content':'$SUMHEAD - \"Please investigate the deployment checklist beta path and record a separate proposal.\"\n - \"Please investigate the deployment checklist alpha path and record evidence for it.\"$SUMTAIL'}}]"
319
+ run "$TMPDIR_ROOT/l10.out" extract --transcript "$TMPDIR_ROOT/l10.jsonl"
320
+ if [ "$RC" -eq 0 ] && grep -q "압축 요약 2건(중복 제거 후 1건 추가)" "$TMPDIR_ROOT/l10.out" \
321
+ && grep -q "^| S1 | (요약) | Please investigate the deployment checklist beta path" "$TMPDIR_ROOT/l10.out"; then
322
+ pass "L10 extract: distinct request sharing the first 40 chars is ADDED; the true duplicate is dropped"
323
+ else
324
+ fail "L10 rc=$RC (see $TMPDIR_ROOT/l10.out)"
325
+ fi
326
+
327
+ # L11
328
+ {
329
+ echo "# code fence masks bad table"; echo
330
+ echo '```md'
331
+ echo "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
332
+ echo "|---|---|---|---|---|---|---|"
333
+ echo "| 1 | 09-18 01:00 | fenced clean row | ✅ | fx/evidence.md:1 | — | — |"
334
+ echo '```'; echo
335
+ echo "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
336
+ echo "|---|---|---|---|---|---|---|"
337
+ echo "| 1 | 09-18 01:05 | actual bad row | ❌ | — | | |"
338
+ } > "$TMPDIR_ROOT/l11.md"
339
+ run "$TMPDIR_ROOT/l11.out" check --file "$TMPDIR_ROOT/l11.md"
340
+ if [ "$RC" -eq 1 ] && grep -q "^row 1 missing 사유" "$TMPDIR_ROOT/l11.out" && grep -q "rows=1 " "$TMPDIR_ROOT/l11.out"; then
341
+ pass "L11 check: a fenced example table is ignored; the real table's bad row is RED"
342
+ else
343
+ fail "L11 rc=$RC (see $TMPDIR_ROOT/l11.out)"
344
+ fi
345
+
346
+ # L12
347
+ {
348
+ echo "# earlier table masks bad table"; echo
349
+ echo "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
350
+ echo "|---|---|---|---|---|---|---|"
351
+ echo "| 1 | 09-18 01:00 | stale completed row | ✅ | old.md:1 | — | — |"; echo
352
+ echo "Some later checklist is the one a reviewer would inspect."; echo
353
+ echo "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
354
+ echo "|---|---|---|---|---|---|---|"
355
+ echo "| 1 | 09-18 01:05 | actual bad row | ❌ | — | | |"
356
+ } > "$TMPDIR_ROOT/l12.md"
357
+ run "$TMPDIR_ROOT/l12.out" check --file "$TMPDIR_ROOT/l12.md"
358
+ if [ "$RC" -eq 1 ] && grep -q "^row table 2 1 missing 사유" "$TMPDIR_ROOT/l12.out" && grep -q "rows=2 .*tables=2" "$TMPDIR_ROOT/l12.out"; then
359
+ pass "L12 check: every 상태 table is checked — the later bad table is RED (table 2 named)"
360
+ else
361
+ fail "L12 rc=$RC (see $TMPDIR_ROOT/l12.out)"
362
+ fi
363
+
364
+ # L13
365
+ {
366
+ echo "# short row"; echo
367
+ echo "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
368
+ echo "|---|---|---|---|---|---|---|"
369
+ echo "| 1 | 09-18 01:00 | truncated but accepted | n/a |"
370
+ echo "| 2 | 09-18 01:01 | compact spelling is fine | ✅DONE | ev.md:1 | — | — |"
371
+ } > "$TMPDIR_ROOT/l13.md"
372
+ run "$TMPDIR_ROOT/l13.out" check --file "$TMPDIR_ROOT/l13.md"
373
+ if [ "$RC" -eq 1 ] && grep -q "^row 1 short (4 cells < header 7)" "$TMPDIR_ROOT/l13.out" && grep -q "violations=1" "$TMPDIR_ROOT/l13.out"; then
374
+ pass "L13 check: a row shorter than the header is a violation; compact ✅DONE stays accepted (documented)"
375
+ else
376
+ fail "L13 rc=$RC (see $TMPDIR_ROOT/l13.out)"
377
+ fi
378
+
379
+ # L14
380
+ build_jsonl "$TMPDIR_ROOT/l14.jsonl" "[{'type':'user','message':{'role':'user','content':'$SUMHEAD - \"Please preserve the literal \"quoted\" word and finish the task\"$SUMTAIL'}}]"
381
+ run "$TMPDIR_ROOT/l14.out" extract --transcript "$TMPDIR_ROOT/l14.jsonl"
382
+ if [ "$RC" -eq 0 ] && grep -q "압축 요약 1건(중복 제거 후 1건 추가)" "$TMPDIR_ROOT/l14.out" \
383
+ && grep -q 'preserve the literal "quoted" word and finish the task' "$TMPDIR_ROOT/l14.out"; then
384
+ pass "L14 extract: an escaped inner quote stays inside one row (was split in two, header over-counted)"
385
+ else
386
+ fail "L14 rc=$RC (see $TMPDIR_ROOT/l14.out)"
387
+ fi
388
+
389
+ # ---------------------------------------------------------------------------
390
+ # L15–L16 — 🟥 cross-family round 2 (codex): a 4-space-indented table (CommonMark code block) was read as THE
391
+ # checklist (rc=0 with no real table — silent); a quote inside a trailing annotation became a phantom row.
392
+ # ---------------------------------------------------------------------------
393
+ {
394
+ echo "# indented example only"; echo
395
+ echo " | # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
396
+ echo " |---|---|---|---|---|---|---|"
397
+ echo " | 1 | 09-18 01:00 | indented clean row | ✅ | ev.md:1 | — | — |"
398
+ } > "$TMPDIR_ROOT/l15a.md"
399
+ run "$TMPDIR_ROOT/l15a.out" check --file "$TMPDIR_ROOT/l15a.md"
400
+ L15A_RC=$RC
401
+ {
402
+ cat "$TMPDIR_ROOT/l15a.md"; echo
403
+ echo "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
404
+ echo "|---|---|---|---|---|---|---|"
405
+ echo "| 1 | 09-18 01:05 | real bad row | ❌ | — | | |"
406
+ } > "$TMPDIR_ROOT/l15b.md"
407
+ run "$TMPDIR_ROOT/l15b.out" check --file "$TMPDIR_ROOT/l15b.md"
408
+ if [ "$L15A_RC" -eq 10 ] && [ "$RC" -eq 1 ] && grep -q "rows=1 " "$TMPDIR_ROOT/l15b.out" && grep -q "^row 1 missing 사유" "$TMPDIR_ROOT/l15b.out"; then
409
+ pass "L15 check: a 4-space-indented table is code, not a checklist (rc=10 alone; the real table below it is the one checked)"
410
+ else
411
+ fail "L15 alone_rc=$L15A_RC with_real_rc=$RC (see $TMPDIR_ROOT/l15*.out)"
412
+ fi
413
+
414
+ build_jsonl "$TMPDIR_ROOT/l16.jsonl" "[{'type':'user','message':{'role':'user','content':'$SUMHEAD - \"Deploy the release notes\" (already \"summarized\" above)\n - Two inline quotes in prose: \"first ask\" and then \"second ask\"$SUMTAIL'}}]"
415
+ run "$TMPDIR_ROOT/l16.out" extract --transcript "$TMPDIR_ROOT/l16.jsonl"
416
+ if [ "$RC" -eq 0 ] && grep -q "압축 요약 3건(중복 제거 후 3건 추가)" "$TMPDIR_ROOT/l16.out" \
417
+ && grep -q "^| S1 | (요약) | Deploy the release notes |" "$TMPDIR_ROOT/l16.out" && ! grep -q "summarized" "$TMPDIR_ROOT/l16.out" \
418
+ && grep -q "^| S2 | (요약) | first ask |" "$TMPDIR_ROOT/l16.out" && grep -q "^| S3 | (요약) | second ask |" "$TMPDIR_ROOT/l16.out"; then
419
+ pass "L16 extract: a quote inside a trailing annotation is not a row; a prose item still yields every quote"
420
+ else
421
+ fail "L16 rc=$RC (see $TMPDIR_ROOT/l16.out)"
422
+ fi
423
+
424
+ # ---------------------------------------------------------------------------
425
+ # L17–L19 — 🟥 cross-family round 3 (codex): an item opening with a quote that never closes was dropped
426
+ # (silent); a Korean compaction heading «모든 사용자 메시지» disabled the summary channel (silent);
427
+ # zero-width spacing around an emoji made a valid status invalid (loud); `n.a.` stays rejected by contract.
428
+ # ---------------------------------------------------------------------------
429
+ build_jsonl "$TMPDIR_ROOT/l17.jsonl" "[{'type':'user','message':{'role':'user','content':'$SUMHEAD - \"Carry the unclosed request over to the next session$SUMTAIL'}}]"
430
+ run "$TMPDIR_ROOT/l17.out" extract --transcript "$TMPDIR_ROOT/l17.jsonl"
431
+ if [ "$RC" -eq 0 ] && grep -q "압축 요약 1건(중복 제거 후 1건 추가)" "$TMPDIR_ROOT/l17.out" \
432
+ && grep -q "^| S1 | (요약) | Carry the unclosed request over to the next session |" "$TMPDIR_ROOT/l17.out"; then
433
+ pass "L17 extract: an item that opens with a quote and never closes it is still one row"
434
+ else
435
+ fail "L17 rc=$RC (see $TMPDIR_ROOT/l17.out)"
436
+ fi
437
+
438
+ build_jsonl "$TMPDIR_ROOT/l18.jsonl" "[{'type':'user','message':{'role':'user','content':'This session is being continued from a previous conversation that ran out of context.\n\n요약:\n1. 주요 요청:\n - 준비\n\n6. 모든 사용자 메시지:\n - \"한국어 헤딩 아래의 발화\"\n\n7. 남은 작업:\n - 계속\n'}}]"
439
+ run "$TMPDIR_ROOT/l18.out" extract --transcript "$TMPDIR_ROOT/l18.jsonl"
440
+ if [ "$RC" -eq 0 ] && grep -q "압축 요약 1건(중복 제거 후 1건 추가)" "$TMPDIR_ROOT/l18.out" \
441
+ && grep -q "^| S1 | (요약) | 한국어 헤딩 아래의 발화 |" "$TMPDIR_ROOT/l18.out"; then
442
+ pass "L18 extract: a Korean compaction heading (모든 사용자 메시지) still opens the summary channel"
443
+ else
444
+ fail "L18 rc=$RC (see $TMPDIR_ROOT/l18.out)"
445
+ fi
446
+
447
+ python3 - "$TMPDIR_ROOT/l19.md" <<'PYEOF'
448
+ import sys
449
+ zw = "​"; nb = " "
450
+ rows = [
451
+ "# invisible spacing",
452
+ "",
453
+ "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |",
454
+ "|---|---|---|---|---|---|---|",
455
+ "| 1 | 09-18 01:00 | zero-width around emoji | " + zw + "✅" + zw + " | ev.md:1 | — | — |",
456
+ "| 2 | 09-18 01:01 | nbsp around emoji | " + nb + "✅" + nb + " | ev.md:2 | — | — |",
457
+ "| 3 | 09-18 01:02 | n.a. is not an alias | n.a. | — | — | — |",
458
+ ]
459
+ open(sys.argv[1], "w", encoding="utf-8").write("\n".join(rows) + "\n")
460
+ PYEOF
461
+ run "$TMPDIR_ROOT/l19.out" check --file "$TMPDIR_ROOT/l19.md"
462
+ if [ "$RC" -eq 1 ] && grep -q "^row 3 invalid" "$TMPDIR_ROOT/l19.out" && grep -q "rows=3 ok=2 violations=1" "$TMPDIR_ROOT/l19.out"; then
463
+ pass "L19 check: zero-width / NBSP around a status is stripped (rows 1–2 ok); n.a. stays invalid by contract (row 3)"
464
+ else
465
+ fail "L19 rc=$RC (see $TMPDIR_ROOT/l19.out)"
466
+ fi
467
+
468
+ # ---------------------------------------------------------------------------
469
+ # L20–L27 — 🟥 cross-family round 4 (codex): six silent MAJORs at the Markdown-table / JSONL boundary.
470
+ # L20 `\|` inside the utterance cell shifted every later column (status read from the wrong cell)
471
+ # L21 a header `이전 상태 메모` before `상태` stole the status column
472
+ # L22 a 4-backtick fence "closed" by a 3-backtick line — the table stayed fenced code
473
+ # L23 an indented delimiter row (code) still made a header a table
474
+ # L24 an unparsable JSONL line silently dropped a user utterance (rc stayed 0)
475
+ # L25 an ordinary utterance that starts with the compaction phrase was routed to the summary channel
476
+ # L26 a BOM before the compaction prefix hid the summary channel
477
+ # L27 a table with only `#` and `상태` passed as a checklist (schema)
478
+ # ---------------------------------------------------------------------------
479
+ {
480
+ echo "# escaped pipe"; echo
481
+ echo "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
482
+ echo "|---|---|---|---|---|---|---|"
483
+ echo "| 1 | 09-18 01:00 | run a \\| b | ✅ | ev.md:1 | — | — |"
484
+ echo "| 2 | 09-18 01:01 | run c \\| d | | ev.md:2 | — | — |"
485
+ } > "$TMPDIR_ROOT/l20.md"
486
+ run "$TMPDIR_ROOT/l20.out" check --file "$TMPDIR_ROOT/l20.md"
487
+ if [ "$RC" -eq 1 ] && grep -q "^row 2 missing 상태" "$TMPDIR_ROOT/l20.out" && grep -q "rows=2 ok=1 violations=1" "$TMPDIR_ROOT/l20.out"; then
488
+ pass "L20 check: an escaped pipe inside a cell is not a column boundary (row 1 ok, row 2's empty 상태 is caught)"
489
+ else
490
+ fail "L20 rc=$RC (see $TMPDIR_ROOT/l20.out)"
491
+ fi
492
+
493
+ {
494
+ echo "# ambiguous header"; echo
495
+ echo "| # | 이전 상태 메모 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
496
+ echo "|---|---|---|---|---|---|---|"
497
+ echo "| 1 | ✅ | the real status is bogus | bogus | ev.md:1 | — | — |"
498
+ } > "$TMPDIR_ROOT/l21.md"
499
+ run "$TMPDIR_ROOT/l21.out" check --file "$TMPDIR_ROOT/l21.md"
500
+ if [ "$RC" -eq 1 ] && grep -q "^row 1 invalid 상태 (got 'bogus')" "$TMPDIR_ROOT/l21.out"; then
501
+ pass "L21 check: the exact 상태 header wins over a contains-match (bogus is caught)"
502
+ else
503
+ fail "L21 rc=$RC (see $TMPDIR_ROOT/l21.out)"
504
+ fi
505
+
506
+ {
507
+ echo "# long fence, short closer"; echo
508
+ echo '````'
509
+ echo '```'
510
+ echo "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
511
+ echo "|---|---|---|---|---|---|---|"
512
+ echo "| 1 | 09-18 01:00 | still fenced | ✅ | ev.md:1 | — | — |"
513
+ echo '````'
514
+ } > "$TMPDIR_ROOT/l22.md"
515
+ run "$TMPDIR_ROOT/l22.out" check --file "$TMPDIR_ROOT/l22.md"
516
+ L22_RC=$RC
517
+ {
518
+ echo "# indented delimiter"; echo
519
+ echo "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
520
+ echo " |---|---|---|---|---|---|---|"
521
+ echo "| 1 | 09-18 01:00 | not a table | ✅ | ev.md:1 | — | — |"
522
+ } > "$TMPDIR_ROOT/l23.md"
523
+ run "$TMPDIR_ROOT/l23.out" check --file "$TMPDIR_ROOT/l23.md"
524
+ if [ "$L22_RC" -eq 10 ] && [ "$RC" -eq 10 ]; then
525
+ pass "L22/L23 check: a 4-backtick fence is not closed by 3 backticks; an indented delimiter row is not a table (both rc=10)"
526
+ else
527
+ fail "L22 rc=$L22_RC L23 rc=$RC (see $TMPDIR_ROOT/l22.out $TMPDIR_ROOT/l23.out)"
528
+ fi
529
+
530
+ {
531
+ echo '{"type":"user","timestamp":"2026-09-18T01:00:00.000Z","message":{"role":"user","content":"first request"}}'
532
+ echo '{"type":"user","timestamp":"2026-09-18T01:01:00.000Z","message":{"role":"user","content":"broken line'
533
+ echo '{"type":"user","timestamp":"2026-09-18T01:02:00.000Z","message":{"role":"user","content":"third request"}}'
534
+ } > "$TMPDIR_ROOT/l24.jsonl"
535
+ run "$TMPDIR_ROOT/l24.out" extract --transcript "$TMPDIR_ROOT/l24.jsonl"
536
+ if [ "$RC" -eq 2 ] && grep -q "JSONL 파싱 실패 1줄" "$TMPDIR_ROOT/l24.out" && grep -q "raw 2건" "$TMPDIR_ROOT/l24.out"; then
537
+ pass "L24 extract: an unparsable JSONL line is loud (rc=2, header names the count) instead of a silent drop"
538
+ else
539
+ fail "L24 rc=$RC (see $TMPDIR_ROOT/l24.out)"
540
+ fi
541
+
542
+ build_jsonl "$TMPDIR_ROOT/l25.jsonl" "[{'type':'user','timestamp':'2026-09-18T01:00:00.000Z','message':{'role':'user','content':'This session is being continued from a previous conversation? no — I am just quoting that phrase; please treat this as my request'}}]"
543
+ run "$TMPDIR_ROOT/l25.out" extract --transcript "$TMPDIR_ROOT/l25.jsonl"
544
+ if [ "$RC" -eq 0 ] && grep -q "raw 1건" "$TMPDIR_ROOT/l25.out" && grep -q "^| 1 | " "$TMPDIR_ROOT/l25.out"; then
545
+ pass "L25 extract: an utterance that merely starts with the compaction phrase stays a raw row"
546
+ else
547
+ fail "L25 rc=$RC (see $TMPDIR_ROOT/l25.out)"
548
+ fi
549
+
550
+ build_jsonl "$TMPDIR_ROOT/l26.jsonl" "[{'type':'user','message':{'role':'user','content':'$SUMHEAD - \"carried over behind a BOM\"$SUMTAIL'}}]"
551
+ run "$TMPDIR_ROOT/l26.out" extract --transcript "$TMPDIR_ROOT/l26.jsonl"
552
+ if [ "$RC" -eq 0 ] && grep -q "압축 요약 1건(중복 제거 후 1건 추가)" "$TMPDIR_ROOT/l26.out" && grep -q "carried over behind a BOM" "$TMPDIR_ROOT/l26.out"; then
553
+ pass "L26 extract: a BOM before the compaction prefix does not hide the summary channel"
554
+ else
555
+ fail "L26 rc=$RC (see $TMPDIR_ROOT/l26.out)"
556
+ fi
557
+
558
+ {
559
+ echo "# status-only table"; echo
560
+ echo "| # | 상태 |"
561
+ echo "|---|---|"
562
+ echo "| 1 | n/a |"
563
+ } > "$TMPDIR_ROOT/l27.md"
564
+ run "$TMPDIR_ROOT/l27.out" check --file "$TMPDIR_ROOT/l27.md"
565
+ if [ "$RC" -eq 10 ] && grep -q "schema" "$TMPDIR_ROOT/l27.out"; then
566
+ pass "L27 check: a table without 증거/사유/제안 columns is not a checklist (schema, rc=10)"
567
+ else
568
+ fail "L27 rc=$RC (see $TMPDIR_ROOT/l27.out)"
569
+ fi
570
+
571
+ # ---------------------------------------------------------------------------
572
+ # L28–L31 — 🟥 cross-family round 5 (codex): four silent MAJORs.
573
+ # L28 an utterance containing the phrase «user messages» (no heading line) was routed to the summary channel
574
+ # L29 a distinct follow-up sharing a long opening with an earlier summary quote was folded as a duplicate
575
+ # L30 a GFM row without the outer pipes was not collected (its bad status went unchecked)
576
+ # L31 a real utterance starting with «Caveat:» was excluded as if it were the synthetic local-command caveat
577
+ # ---------------------------------------------------------------------------
578
+ build_jsonl "$TMPDIR_ROOT/l28.jsonl" "[{'type':'user','timestamp':'2026-09-18T01:00:00.000Z','message':{'role':'user','content':'This session is being continued from a previous conversation is a phrase; the old user messages are gone, so re-derive the plan from the card'}}]"
579
+ run "$TMPDIR_ROOT/l28.out" extract --transcript "$TMPDIR_ROOT/l28.jsonl"
580
+ if [ "$RC" -eq 0 ] && grep -q "raw 1건 · 압축 요약 0건" "$TMPDIR_ROOT/l28.out"; then
581
+ pass "L28 extract: the phrase «user messages» without a heading line does not make a compaction summary"
582
+ else
583
+ fail "L28 rc=$RC (see $TMPDIR_ROOT/l28.out)"
584
+ fi
585
+
586
+ build_jsonl "$TMPDIR_ROOT/l29.jsonl" "[{'type':'user','message':{'role':'user','content':'$SUMHEAD - \"Please investigate the deployment checklist and record evidence for the alpha path\"$SUMTAIL'}},{'type':'user','message':{'role':'user','content':'$SUMHEAD - \"Please investigate the deployment checklist and record evidence for the alpha path, then open a PR\"\n - \"Please investigate the deployment checklist and record evidence for the alpha…\"$SUMTAIL'}}]"
587
+ run "$TMPDIR_ROOT/l29.out" extract --transcript "$TMPDIR_ROOT/l29.jsonl"
588
+ if [ "$RC" -eq 0 ] && grep -q "압축 요약 3건(중복 제거 후 2건 추가)" "$TMPDIR_ROOT/l29.out" && grep -q "then open a PR" "$TMPDIR_ROOT/l29.out"; then
589
+ pass "L29 extract: a distinct follow-up sharing a long opening is its own row; only a quote ending in «…» folds"
590
+ else
591
+ fail "L29 rc=$RC (see $TMPDIR_ROOT/l29.out)"
592
+ fi
593
+
594
+ {
595
+ echo "# outer pipes optional"; echo
596
+ echo "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
597
+ echo "|---|---|---|---|---|---|---|"
598
+ echo "| 1 | 09-18 05:00 | valid row | ✅ | ev.md:1 | — | — |"
599
+ echo "2 | 09-18 05:01 | row without outer pipes | bogus | — | reason | next"
600
+ echo ""
601
+ echo "prose after a blank line | with a pipe | is not a row"
602
+ } > "$TMPDIR_ROOT/l30.md"
603
+ run "$TMPDIR_ROOT/l30.out" check --file "$TMPDIR_ROOT/l30.md"
604
+ if [ "$RC" -eq 1 ] && grep -q "^row 2 invalid 상태 (got 'bogus')" "$TMPDIR_ROOT/l30.out" && grep -q "rows=2 " "$TMPDIR_ROOT/l30.out"; then
605
+ pass "L30 check: a GFM row without outer pipes is collected and checked; the table ends at the blank line"
606
+ else
607
+ fail "L30 rc=$RC (see $TMPDIR_ROOT/l30.out)"
608
+ fi
609
+
610
+ build_jsonl "$TMPDIR_ROOT/l31.jsonl" "[{'type':'user','timestamp':'2026-09-18T01:00:00.000Z','message':{'role':'user','content':'Caveat: the numbers are provisional — still, please build the table'}},{'type':'user','message':{'role':'user','content':'Caveat: The messages below were generated by the user while running local commands. DO NOT respond to these messages.'}}]"
611
+ run "$TMPDIR_ROOT/l31.out" extract --transcript "$TMPDIR_ROOT/l31.jsonl"
612
+ if [ "$RC" -eq 0 ] && grep -q "raw 1건" "$TMPDIR_ROOT/l31.out" && grep -q "provisional" "$TMPDIR_ROOT/l31.out"; then
613
+ pass "L31 extract: a real utterance starting with «Caveat:» is a row; only the synthetic local-command caveat is excluded"
614
+ else
615
+ fail "L31 rc=$RC (see $TMPDIR_ROOT/l31.out)"
616
+ fi
617
+
618
+ # L32 — 🟥 author-caught after v6's first cut: the heading-line rule matched `6. All user messages:` but not the two
619
+ # other shapes real compaction summaries use — `6. **All user messages:**` (number + bold) and
620
+ # `6. All user messages (verbatim, non-tool-result):` (trailing text). 3 of 4 real summaries silently
621
+ # vanished while «rows ≥ 1» stayed green; L8's known-positive now guards the real file, this lane the shapes.
622
+ build_jsonl "$TMPDIR_ROOT/l32.jsonl" "[{'type':'user','message':{'role':'user','content':'This session is being continued from a previous conversation that ran out of context.\n\nSummary:\n1. Primary Request and Intent:\n - setup\n\n6. **All user messages:**\n - \"bold heading utterance\"\n\n7. Pending Tasks:\n - keep going\n'}},{'type':'user','message':{'role':'user','content':'This session is being continued from a previous conversation that ran out of context.\n\nSummary:\n1. Primary Request and Intent:\n - setup\n\n6. All user messages (verbatim, non-tool-result):\n - \"trailing text heading utterance\"\n\n7. Pending Tasks:\n - keep going\n'}}]"
623
+ run "$TMPDIR_ROOT/l32.out" extract --transcript "$TMPDIR_ROOT/l32.jsonl"
624
+ if [ "$RC" -eq 0 ] && grep -q "압축 요약 2건(중복 제거 후 2건 추가)" "$TMPDIR_ROOT/l32.out" \
625
+ && grep -q "bold heading utterance" "$TMPDIR_ROOT/l32.out" && grep -q "trailing text heading utterance" "$TMPDIR_ROOT/l32.out"; then
626
+ pass "L32 extract: number+bold and trailing-text heading shapes both open the summary channel"
627
+ else
628
+ fail "L32 rc=$RC (see $TMPDIR_ROOT/l32.out)"
629
+ fi
630
+
631
+ # ---------------------------------------------------------------------------
632
+ # L33–L34 — 🟥 cross-family round 6 (codex, first round with the contract boundaries stated): two silent, in-contract.
633
+ # L33 a later table whose header AND delimiter omit the outer pipes was never found (its bad row unchecked)
634
+ # L34 a user DRAFTING a compaction template (boilerplate + heading line, no quoted items) was routed to the summary channel
635
+ # ---------------------------------------------------------------------------
636
+ {
637
+ echo "# outerless later table"; echo
638
+ echo "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안 |"
639
+ echo "|---|---|---|---|---|---|---|"
640
+ echo "| 1 | 09-18 05:00 | first table ok | ✅ | ev.md:1 | — | — |"
641
+ echo
642
+ echo "# | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안"
643
+ echo "---|---|---|---|---|---|---"
644
+ echo "1 | 09-18 05:01 | outerless table bad row | bogus | — | reason | next"
645
+ } > "$TMPDIR_ROOT/l33.md"
646
+ run "$TMPDIR_ROOT/l33.out" check --file "$TMPDIR_ROOT/l33.md"
647
+ if [ "$RC" -eq 1 ] && grep -q "^row table 2 1 invalid 상태 (got 'bogus')" "$TMPDIR_ROOT/l33.out" && grep -q "tables=2" "$TMPDIR_ROOT/l33.out"; then
648
+ pass "L33 check: a table whose header and delimiter omit the outer pipes is found and checked (table 2 named)"
649
+ else
650
+ fail "L33 rc=$RC (see $TMPDIR_ROOT/l33.out)"
651
+ fi
652
+
653
+ build_jsonl "$TMPDIR_ROOT/l34.jsonl" "[{'type':'user','timestamp':'2026-09-18T01:00:00.000Z','message':{'role':'user','content':'This session is being continued from a previous conversation that ran out of context. — let us use that as our template:\n\n1. Primary Request and Intent:\n - (fill in)\n\n6. All user messages:\n - (list them here)\n\n7. Pending Tasks:\n - (fill in)\n'}}]"
654
+ run "$TMPDIR_ROOT/l34.out" extract --transcript "$TMPDIR_ROOT/l34.jsonl"
655
+ if [ "$RC" -eq 0 ] && grep -q "raw 1건 · 압축 요약 0건" "$TMPDIR_ROOT/l34.out"; then
656
+ pass "L34 extract: a compaction-shaped utterance with no quoted items stays a raw row"
657
+ else
658
+ fail "L34 rc=$RC (see $TMPDIR_ROOT/l34.out)"
659
+ fi
660
+
661
+ # L35 — 🟥 cross-family round 7 (codex): flush-left numbered quoted items (`1. "…"`) ended the «All user messages»
662
+ # section (silent — the whole summary collapsed into one truncated raw row); a `7) Pending Tasks:` heading did
663
+ # not end it (loud phantom row). v8: the section ends at the next flush-left numbered line WITHOUT a quote.
664
+ build_jsonl "$TMPDIR_ROOT/l35.jsonl" "[{'type':'user','message':{'role':'user','content':'This session is being continued from a previous conversation that ran out of context.\n\nSummary:\n1) Primary Request and Intent:\n - setup\n\n6) All user messages:\n1. \"first flush-left numbered quote\"\n2. \"second flush-left numbered quote\"\n7) Pending Tasks:\n - \"a quoted pending task is not a user message\"\n'}}]"
665
+ run "$TMPDIR_ROOT/l35.out" extract --transcript "$TMPDIR_ROOT/l35.jsonl"
666
+ if [ "$RC" -eq 0 ] && grep -q "raw 0건 · 압축 요약 2건(중복 제거 후 2건 추가)" "$TMPDIR_ROOT/l35.out" \
667
+ && grep -q "second flush-left numbered quote" "$TMPDIR_ROOT/l35.out" && ! grep -q "pending task" "$TMPDIR_ROOT/l35.out"; then
668
+ pass "L35 extract: flush-left numbered quoted items stay inside the section; a \`7)\` heading ends it"
669
+ else
670
+ fail "L35 rc=$RC (see $TMPDIR_ROOT/l35.out)"
671
+ fi
672
+
673
+ # L36–L37 — 🟥 cross-family round 8 (codex): exclusions matched marker LITERALS inside ordinary utterances (three silent
674
+ # drops — `<task-notification>` · `[Subagent hand-back]` · the peer-message sentence); a one-character quote was
675
+ # mangled (loud). v9: exclusions are envelope-shaped (line start + tag); one-character quotes are quotes.
676
+ build_jsonl "$TMPDIR_ROOT/l36.jsonl" "[
677
+ {'type':'user','timestamp':'2026-09-18T01:00:00.000Z','message':{'role':'user','content':'please grep the transcript for the literal <task-notification> marker and count it'}},
678
+ {'type':'user','timestamp':'2026-09-18T01:01:00.000Z','message':{'role':'user','content':'the [Subagent hand-back] frame should be neutralized in our extractor — add a lane'}},
679
+ {'type':'user','timestamp':'2026-09-18T01:02:00.000Z','message':{'role':'user','content':'Another Claude session sent a message: is the exact envelope sentence — use it as fixture text'}},
680
+ {'type':'user','message':{'role':'user','content':'<task-notification>\n<task-id>x</task-id>\n</task-notification>'}},
681
+ {'type':'user','message':{'role':'user','content':'Another Claude session sent a message:\n<agent-message from=\"abc\">\n[Subagent hand-back] report body\n</agent-message>'}}
682
+ ]"
683
+ run "$TMPDIR_ROOT/l36.out" extract --transcript "$TMPDIR_ROOT/l36.jsonl"
684
+ if [ "$RC" -eq 0 ] && grep -q "raw 3건" "$TMPDIR_ROOT/l36.out" && grep -q "count it" "$TMPDIR_ROOT/l36.out" && grep -q "add a lane" "$TMPDIR_ROOT/l36.out" && grep -q "fixture text" "$TMPDIR_ROOT/l36.out" \
685
+ && ! grep -q "report body" "$TMPDIR_ROOT/l36.out" && ! grep -q "task-id" "$TMPDIR_ROOT/l36.out"; then
686
+ pass "L36 extract: marker literals inside utterances are rows; the real task-notification and agent-message envelopes are excluded"
687
+ else
688
+ fail "L36 rc=$RC (see $TMPDIR_ROOT/l36.out)"
689
+ fi
690
+
691
+ build_jsonl "$TMPDIR_ROOT/l37.jsonl" "[{'type':'user','message':{'role':'user','content':'$SUMHEAD - \"y\"\n - \"ok go\"$SUMTAIL'}}]"
692
+ run "$TMPDIR_ROOT/l37.out" extract --transcript "$TMPDIR_ROOT/l37.jsonl"
693
+ if [ "$RC" -eq 0 ] && grep -q "압축 요약 2건(중복 제거 후 2건 추가)" "$TMPDIR_ROOT/l37.out" && grep -q "^| S1 | (요약) | y |" "$TMPDIR_ROOT/l37.out"; then
694
+ pass "L37 extract: a one-character quoted item is one clean row"
695
+ else
696
+ fail "L37 rc=$RC (see $TMPDIR_ROOT/l37.out)"
697
+ fi
698
+
699
+ # L38 — 🟥 cross-family round 9 (codex): prefix-only exclusions dropped ordinary utterances that START with an envelope
700
+ # literal (`<system-reminder>` · `[SYSTEM NOTIFICATION` · `<local-command…>` · `<command-name>`) — silent.
701
+ # v10: every exclusion is an envelope VALIDATOR (opening marker at line start + the closing/companion mark the
702
+ # real Claude Code envelope always carries); a look-alike without the companion is a row.
703
+ build_jsonl "$TMPDIR_ROOT/l38.jsonl" "[
704
+ {'type':'user','timestamp':'2026-09-18T01:00:00.000Z','message':{'role':'user','content':'<system-reminder> is the tag I want counted — look-alike, no closing tag'}},
705
+ {'type':'user','timestamp':'2026-09-18T01:01:00.000Z','message':{'role':'user','content':'[SYSTEM NOTIFICATION style banners must be neutralized — write that lane'}},
706
+ {'type':'user','timestamp':'2026-09-18T01:02:00.000Z','message':{'role':'user','content':'<local-command-stdout> lines are noise; strip them in the extractor'}},
707
+ {'type':'user','timestamp':'2026-09-18T01:03:00.000Z','message':{'role':'user','content':'<command-name>deploy</command-name> is sample text for the parser docs — treat as my request'}},
708
+ {'type':'user','message':{'role':'user','content':'<system-reminder>\nreminder body\n</system-reminder>'}},
709
+ {'type':'user','message':{'role':'user','content':'[SYSTEM NOTIFICATION - NOT USER INPUT]\nThis is an automated background-task event\n\n<task-notification>\n<task-id>x</task-id>\n</task-notification>'}},
710
+ {'type':'user','message':{'role':'user','content':'<local-command-stdout>hi</local-command-stdout>'}},
711
+ {'type':'user','message':{'role':'user','content':'<command-name>/compact</command-name>\n<command-message>compact</command-message>'}}
712
+ ]"
713
+ run "$TMPDIR_ROOT/l38.out" extract --transcript "$TMPDIR_ROOT/l38.jsonl"
714
+ if [ "$RC" -eq 0 ] && grep -q "raw 4건" "$TMPDIR_ROOT/l38.out" && grep -q "look-alike" "$TMPDIR_ROOT/l38.out" && grep -q "treat as my request" "$TMPDIR_ROOT/l38.out" \
715
+ && ! grep -q "reminder body" "$TMPDIR_ROOT/l38.out" && ! grep -q "task-id" "$TMPDIR_ROOT/l38.out" && ! grep -q "compact" "$TMPDIR_ROOT/l38.out"; then
716
+ pass "L38 extract: four envelope look-alikes are rows; the four real envelopes (with their closing marks) are excluded"
717
+ else
718
+ fail "L38 rc=$RC (see $TMPDIR_ROOT/l38.out)"
719
+ fi
720
+
721
+ # L39 — 🟥 cross-family round 10 (codex): a user-authored FULL envelope literal (byte-identical text) was excluded by text
722
+ # shape. Measured on the real transcript: Claude Code marks entries — origin.kind=human (48/48 typed utterances),
723
+ # origin.kind=task-notification / peer (+isMeta), isCompactSummary. v11: METADATA FIRST — a human-origin entry is
724
+ # never excluded by its text; flagged entries are excluded/routed by the flag; text validators only when NO metadata.
725
+ build_jsonl "$TMPDIR_ROOT/l39.jsonl" "[
726
+ {'type':'user','timestamp':'2026-09-18T01:00:00.000Z','origin':{'kind':'human'},'promptSource':'typed','message':{'role':'user','content':'<system-reminder>\nthis whole envelope is what I pasted as my request\n</system-reminder>'}},
727
+ {'type':'user','origin':{'kind':'task-notification'},'promptSource':'system','message':{'role':'user','content':'plain looking text that is actually a notification'}},
728
+ {'type':'user','isMeta':True,'origin':{'kind':'peer'},'promptSource':'system','message':{'role':'user','content':'peer text without the sentence prefix'}},
729
+ {'type':'user','isCompactSummary':True,'message':{'role':'user','content':'Summary (no boilerplate prefix):\n\n6. All user messages:\n - \"flagged compaction quote\"\n\n7. Pending Tasks:\n - x\n'}},
730
+ {'type':'user','message':{'role':'user','content':'<system-reminder>\nno metadata at all — text fallback treats a full envelope as synthetic\n</system-reminder>'}}
731
+ ]"
732
+ run "$TMPDIR_ROOT/l39.out" extract --transcript "$TMPDIR_ROOT/l39.jsonl"
733
+ if [ "$RC" -eq 0 ] && grep -q "raw 1건 · 압축 요약 1건(중복 제거 후 1건 추가)" "$TMPDIR_ROOT/l39.out" \
734
+ && grep -q "what I pasted as my request" "$TMPDIR_ROOT/l39.out" && grep -q "flagged compaction quote" "$TMPDIR_ROOT/l39.out" \
735
+ && ! grep -q "actually a notification" "$TMPDIR_ROOT/l39.out" && ! grep -q "peer text" "$TMPDIR_ROOT/l39.out" && ! grep -q "no metadata at all" "$TMPDIR_ROOT/l39.out"; then
736
+ pass "L39 extract: metadata first — human-origin envelope text is a row; flagged notification/peer are excluded; isCompactSummary opens the summary channel; no-metadata envelope falls back to the text validator"
737
+ else
738
+ fail "L39 rc=$RC (see $TMPDIR_ROOT/l39.out)"
739
+ fi
740
+
741
+ echo "── $PASS_COUNT passed, $FAIL_COUNT failed ──"
742
+
743
+ if [ "$FAIL_COUNT" -gt 0 ]; then
744
+ exit 1
745
+ fi
746
+ exit 0