@chrono-meta/fh-gate 3.38.1 → 3.39.1

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 (41) hide show
  1. package/.claude/regression/probes_live.yaml +36 -0
  2. package/.claude/rules/fh_4axis_gate.md +6 -1
  3. package/.claude-plugin/marketplace.json +4 -4
  4. package/AGENTS.md +1 -1
  5. package/README.ja.md +2 -2
  6. package/README.ko.md +2 -2
  7. package/README.md +5 -4
  8. package/README.zh.md +2 -2
  9. package/docs/ETHOS.md +3 -1
  10. package/docs/codex-compat.md +2 -2
  11. package/knowledge/shared/harness-core/agents_md_runtime_details.md +1 -1
  12. package/knowledge/shared/harness-core/fh_module_contract.md +15 -2
  13. package/knowledge/shared/harness-core/fh_three_layer_canon.md +7 -0
  14. package/knowledge/shared/harness-core/governance_engineering_definition.md +55 -0
  15. package/knowledge/shared/harness-core/governor_landing_before_compact.md +57 -0
  16. package/knowledge/shared/harness-core/lease_record_channel.md +32 -0
  17. package/knowledge/shared/learnings/subagent_invocations_log.yaml +36 -0
  18. package/knowledge/shared/rules/operations.md +16 -0
  19. package/package.json +9 -1
  20. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  21. package/plugins/fh-commons/skills/convergence-loop/SKILL.md +8 -0
  22. package/plugins/fh-commons/skills/convergence-loop/fh-module.yaml +22 -0
  23. package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +5 -0
  24. package/plugins/fh-commons/skills/persona-cast/SKILL.md +20 -4
  25. package/plugins/fh-commons/skills/persona-cast/fh-module.yaml +20 -0
  26. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  27. package/plugins/fh-meta/CHANGELOG.md +28 -0
  28. package/plugins/fh-meta/skills/steel-quench/SKILL.md +8 -3
  29. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  30. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  31. package/scripts/convergence_verdict.py +177 -0
  32. package/scripts/lane_gap_hint.py +166 -0
  33. package/scripts/lane_gap_hint.sh +7 -0
  34. package/scripts/package_coverage_check.sh +19 -0
  35. package/scripts/persona_cast_merge.py +235 -0
  36. package/scripts/probe_live_eval_lib.py +41 -0
  37. package/scripts/selfcheck.sh +12 -1
  38. package/scripts/test_convergence_verdict_lanes.sh +67 -0
  39. package/scripts/test_lane_gap_hint_lanes.sh +91 -0
  40. package/scripts/test_live_eval_construct_lanes.sh +70 -0
  41. package/scripts/test_persona_cast_merge_lanes.sh +108 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrono-meta/fh-gate",
3
- "version": "3.38.1",
3
+ "version": "3.39.1",
4
4
  "description": "FH runtime adapters — run FH governance, skills, and agents via Claude or Codex with machine-parseable gates.",
5
5
  "homepage": "https://github.com/chrono-meta/forge-harness#readme",
6
6
  "bugs": {
@@ -189,6 +189,8 @@
189
189
  "scripts/fh_session_load.sh",
190
190
  "scripts/fh_track_resolve.sh",
191
191
  "scripts/field_canon_preload.sh",
192
+ "scripts/lane_gap_hint.py",
193
+ "scripts/lane_gap_hint.sh",
192
194
  "scripts/files_manifest_shipping_check.sh",
193
195
  "scripts/finding_fleet.sh",
194
196
  "scripts/finding_pipeline.sh",
@@ -231,6 +233,7 @@
231
233
  "scripts/test_abstract_consult_check_lanes.sh",
232
234
  "scripts/outbound_query_hook.sh",
233
235
  "scripts/package_coverage_check.sh",
236
+ "scripts/persona_cast_merge.py",
234
237
  "scripts/pipe_verdict_guard.sh",
235
238
  "scripts/portability_lint.sh",
236
239
  "scripts/postinstall_notice.js",
@@ -258,6 +261,7 @@
258
261
  "scripts/selfcheck_shard_weights.txt",
259
262
  "scripts/session_checklist.py",
260
263
  "scripts/checklist_unblocked_hook.sh",
264
+ "scripts/convergence_verdict.py",
261
265
  "scripts/session_close_check.sh",
262
266
  "scripts/shell_name_boundary_scan.sh",
263
267
  "scripts/sidecar_calibrate.sh",
@@ -346,6 +350,7 @@
346
350
  "scripts/test_package_coverage_lanes.sh",
347
351
  "scripts/test_paper_integrity_lanes.sh",
348
352
  "scripts/test_peer_worktree_detect_lanes.sh",
353
+ "scripts/test_persona_cast_merge_lanes.sh",
349
354
  "scripts/test_pipe_verdict_guard_lanes.sh",
350
355
  "scripts/test_precommit_gitlink_lanes.sh",
351
356
  "scripts/test_precommit_pointer_index_lanes.sh",
@@ -364,6 +369,7 @@
364
369
  "scripts/test_prepush_stdin_integrity.sh",
365
370
  "scripts/test_prior_art_prompt_lanes.sh",
366
371
  "scripts/test_probe_live_eval_lanes.sh",
372
+ "scripts/test_live_eval_construct_lanes.sh",
367
373
  "scripts/test_proposal_hook_lanes.sh",
368
374
  "scripts/test_psa_singlefile_lanes.sh",
369
375
  "scripts/test_push_zone_lanes.sh",
@@ -401,6 +407,7 @@
401
407
  "scripts/test_verdict_watermark_lanes.sh",
402
408
  "scripts/test_version_lockstep_lanes.sh",
403
409
  "scripts/test_wizard_snippet_merge_lanes.sh",
410
+ "scripts/test_lane_gap_hint_lanes.sh",
404
411
  "scripts/test_worktree_reclaim_lanes.sh",
405
412
  "scripts/tier_census_grep.sh",
406
413
  "scripts/transcript_utterances.py",
@@ -442,6 +449,7 @@
442
449
  "templates/temper_check.sh",
443
450
  "tests/seam_absence_probes.md",
444
451
  "scripts/marker_diff_sha.sh",
452
+ "scripts/test_convergence_verdict_lanes.sh",
445
453
  "scripts/test_marker_diff_sha_lanes.sh",
446
454
  "scripts/test_preprep_speech_coach_lanes.sh"
447
455
  ]
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fh-commons",
3
- "version": "3.38.1",
3
+ "version": "3.39.1",
4
4
  "engines": {
5
5
  "claudeCode": ">=1.0.0"
6
6
  },
@@ -102,6 +102,14 @@ Escalation: [who to escalate to / how, if not converged within N rounds]
102
102
 
103
103
  ### Convergence Judgment
104
104
 
105
+ **Judge with the engine, not by eye** (2026-11-06): write the round vector as
106
+ `R1 [new=<n>, fixed=<n>] → R2 [new=<n>, fixed=<n>] …` (every round both counts) and run
107
+ `python3 scripts/convergence_verdict.py --rounds "<vector>"` — exit 0 CONVERGED · 1 NOT-CONVERGED or
108
+ PROVISIONAL (one clean round) · 2 UNMEASURED (a shape it cannot read, or a round missing a count — never
109
+ guessed). `--scan-markers tracks/_meta` audits every marker's `axis2-rounds:` line for «converged» written
110
+ where the vector says otherwise (first run: 6 markers wrote «R1 [new=0, fixed=0] → converged» — one round).
111
+ Calibration: `bash scripts/test_convergence_verdict_lanes.sh`. The rule it applies:
112
+
105
113
  ```
106
114
  Convergence = a round returns 0 new FAILs AND no FIX was applied in response to it
107
115
  Conditions to declare truly passed:
@@ -0,0 +1,22 @@
1
+ # FH module manifest (contract v0). Spec: knowledge/shared/harness-core/fh_module_contract.md
2
+ # A cartridge: the convergence-loop skill and its verdict engine — the first module with a verdict entry point.
3
+ id: convergence-loop
4
+ version: 0.1.0
5
+ provides:
6
+ skills: [convergence-loop]
7
+ agents: []
8
+ hooks: []
9
+ verdicts:
10
+ - entry: convergence-verdict
11
+ command: python3 scripts/convergence_verdict.py
12
+ exit_codes: {pass: 0, block: 1, unmeasured: 2}
13
+ adds_constraints: []
14
+ touches_irreversible: none
15
+ data_class: public
16
+ requires:
17
+ modules: []
18
+ core_min: 3.0.0
19
+ calibration:
20
+ command: bash scripts/test_convergence_verdict_lanes.sh
21
+ files:
22
+ - scripts/convergence_verdict.py
@@ -20,6 +20,11 @@ model: sonnet
20
20
  > 이 문서의 유지 규칙이다. 이 SKILL.md 자체는 독자 대면 문서가 아니라 하네스 자산이므로
21
21
  > 이 파이프라인의 적용 대상이 아니다(FH 하우스 스타일을 따른다).
22
22
 
23
+ > **정본 위치 (2026-11-07, 단계적 이전)**: 다음 메이저까지는 FH 저장소의 `plugins/fh-commons/skills/ko-tech-writer/` 가 정본이다.
24
+ > 별도 테크라이터 하네스에 있는 같은 파일들은 FH 에서 `scripts/fh_module_check.py export` 로 뽑은 사본이다.
25
+ > 수정은 FH 저장소에서 하고, FH 에서 다시 export 한다. 다음 메이저에서 문체 부분(번역투 부류 · 매체 보정)을
26
+ > 그쪽으로 옮기고, 숫자 · 주장 게이트와 `--check-rewrite` 는 FH 에 남긴다. 두 벌 대조는 그 하네스 쪽 검사가 맡는다.
27
+
23
28
  ## Step 0 — 대상 판별 (레지스터 분기)
24
29
 
25
30
  같은 내용도 매체에 따라 규율이 다르다. 먼저 셋 중 무엇인지 정한다:
@@ -19,9 +19,9 @@ doorway, the same shape as `harness-pr-reviewer` (a standalone way in to one FH
19
19
 
20
20
  ## Casts (shipped in `plugins/fh-commons/agents/*-lens.md`)
21
21
 
22
- | cast | lenses | for |
23
- |---|---|---|
24
- | `web-review` (default) | designer-lens · ux-writer-lens · fe-dev-lens · be-dev-lens · qa-lens · a11y-lens | a screen, a flow, a web/mobile spec, a page (review mode) **or a live app (explore mode)** |
22
+ | cast | lenses | for | status |
23
+ |---|---|---|---|
24
+ | `web-review` (default) | designer-lens · ux-writer-lens · fe-dev-lens · be-dev-lens · qa-lens · a11y-lens | a screen, a flow, a web/mobile spec, a page (review mode) **or a live app (explore mode)** | **validated** (review mode, 2026-11-07 — first field run on a desktop app's approval-card UI, 6 source files: every lens `unique ≥ 1`, 0 decorative; one finding dropped after a source check). Explore mode: still `synthesized` |
25
25
 
26
26
  A cast is a list, not a promise: every run measures which lenses earned their seat (Step 4).
27
27
 
@@ -71,6 +71,16 @@ artifact paths + the stance + *nothing else*. Lenses run in parallel; none sees
71
71
  Each returns the parallax block including its `Unique-to-this-seat` self-tag.
72
72
 
73
73
  ### Step 4 — Merge with the marginal-coverage stop (anti-decorative)
74
+ **Run the engine — do not count by hand** (2026-11-06): save each lens's reply to a file, then
75
+ ```
76
+ python3 scripts/persona_cast_merge.py --artifact <path> --lens designer=<file> --lens qa=<file> … [--stance neutral]
77
+ ```
78
+ It prints the Step 5 table and the merged Concerns. Exit 0 = every lens measured; **exit 2 = a lens
79
+ could not be read (no `### Concerns` section, missing file) or no artifact was given — that lens is
80
+ UNMEASURED, never «decorative» and never «earned»**. It keys Concerns by the normalized `[location]`
81
+ alone (stricter than «location + first noun phrase»: it can only under-count unique, never pad a lens
82
+ into «earned»). Calibration: `bash scripts/test_persona_cast_merge_lanes.sh`. The rules it applies:
83
+
74
84
  First drop every Concern that carries no `[location]` — the lens files promise this («A concern
75
85
  without a location is dropped by the dispatcher»), and this step is where it happens. Count what you
76
86
  drop per lens and print it (`no-loc` column below); a dropped concern is never silently lost, and a
@@ -159,7 +169,13 @@ explore mode adds:
159
169
  ```
160
170
  **First-use gate (graduation)**: a cast graduates from *synthesized* to *validated* only when, on a
161
171
  real artifact, every lens has `unique ≥ 1` at least once across runs. Until then the cast row above
162
- says `synthesized`. Measured, not asserted.
172
+ says `synthesized`. Measured, not asserted. The graduation is per mode: a review-mode run does not
173
+ validate explore mode (it never drove a live app). On the first field run `scripts/persona_cast_merge.py`
174
+ read all six reports (exit 0) but keyed on exact location strings, so it found **0** concerns shared
175
+ by two seats where a hand merge by location + noun phrase found **9** groups — each lens names the same
176
+ spot differently (the engine's named residual, now measured on real output: it over-counts `unique`).
177
+ Its self-tag column read 0/0 because the lenses' «Unique-to-this-seat» bullets carry no `[location]`.
178
+ The `earned` verdicts held either way; cross-seat convergence needs the hand pass until the key is fixed.
163
179
 
164
180
  ## Constraints
165
181
  - Review-shaped only. A lens that starts redesigning or rewriting has left its cap — drop that part.
@@ -0,0 +1,20 @@
1
+ # FH module manifest (contract v0). Spec: knowledge/shared/harness-core/fh_module_contract.md
2
+ # A cartridge: the persona-cast doorway, its six review lenses, and the Step 4 merge engine (marginal-coverage stop).
3
+ id: persona-cast
4
+ version: 0.1.0
5
+ provides:
6
+ skills: [persona-cast]
7
+ agents: [designer-lens, ux-writer-lens, fe-dev-lens, be-dev-lens, qa-lens, a11y-lens]
8
+ hooks: []
9
+ verdicts: []
10
+ adds_constraints: []
11
+ touches_irreversible: none
12
+ data_class: public
13
+ requires:
14
+ modules: []
15
+ core_min: 3.0.0
16
+ calibration:
17
+ command: bash scripts/test_persona_cast_merge_lanes.sh
18
+ # what export copies besides the skill/agent files and the command file: the merge engine the lane runs
19
+ files:
20
+ - scripts/persona_cast_merge.py
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fh-meta",
3
- "version": "3.38.1",
3
+ "version": "3.39.1",
4
4
  "engines": {
5
5
  "claudeCode": ">=1.0.0"
6
6
  },
@@ -2,6 +2,34 @@
2
2
 
3
3
  ### [Unreleased]
4
4
 
5
+ ### [3.39.1] — 2026-11-08
6
+
7
+ Documentation-only patch.
8
+
9
+ ### Changed
10
+ - `knowledge/shared/harness-core/fh_module_contract.md`: a short glossary (module = cartridge, the unit with a manifest; skill/agent = what a module provides; plugin = the distribution unit; one spelling `UNMEASURED`), a rule that a command which exits 0 on a negative finding is a measurement engine and not a `provides.verdicts` entry, and a note that exit code 3 means different things in different scripts (#1054).
11
+ - `knowledge/shared/harness-core/governor_landing_before_compact.md`: internal pointers an outside reader cannot follow were removed (#1054).
12
+ - README (en/ko/ja/zh): the sentence between «You get three things:» and the table moved below the table; «the author» now reads «the author of FH» (#1054).
13
+ - `.claude/regression/ablation_verdicts.md`: the §Autonomous Initiative Layer KEEP verdict is now a table row, re-measured (#1053).
14
+
15
+ ### [3.39.0] — 2026-11-07
16
+
17
+ New scripts and lanes ship, so this is a minor by the version policy. No existing gate tightens. The new hook is not wired by default. The `persona-cast` and `convergence-loop` skills now tell the agent to run their engines instead of counting by hand, so a session that uses those skills runs the scripts.
18
+
19
+ ### Added
20
+ - Two skills get an FH module manifest (`fh-module.yaml`, manifest v0.1.0) under `fh_module_contract.md` v0. A module (FH also says cartridge) is a skill or agent packaged with a manifest that says what it provides and promises not to weaken the core floor (`adds_constraints: []`, `touches_irreversible: none`). v0 is a manifest and a checker; it does not install anything (contract §7 «Not in v0»).
21
+ - `persona-cast` with its Step 4 merge as a program, `scripts/persona_cast_merge.py`: drops concerns without a location, counts them per lens, and names a lens with no unique concern «decorative on this artifact». It is a **measurement, not a verdict entry point**: it exits 0 when the artifact and every lens were read — a decorative lens included — and 2 when something could not be read (a missing artifact, a missing or malformed lens). Do not gate on its exit code (#1033).
22
+ - `convergence-loop` with a verdict entry point, `scripts/convergence_verdict.py` (exit 0 pass · 1 block · 2 unmeasured, as the contract requires). With `--rounds`: CONVERGED (0) only when the last round found nothing new, fixed nothing, and at least two rounds ran. Exit 1 covers both NOT-CONVERGED and PROVISIONAL — PROVISIONAL is one clean round, «run one more», not a rejected change. An unreadable round is UNMEASURED (2). `--scan-markers` audits recorded vectors instead: 1 when a marker claims convergence its vector contradicts, 2 when a line could not be read, else 0 (#1034).
23
+ - `scripts/lane_gap_hint.py` / `.sh`: a UserPromptSubmit hook that adds one line to the next prompt when the last turn changed code files and ran no test. It never blocks. Opt-in: the install wizard adds it from the hub clone's settings snippet (clone installs only); `FH_LANE_GAP_HINT=0` turns it off (#1039).
24
+ - live-eval probes declare what they claim and what their pattern cannot see (`construct` · `claims` · `unseen` in `.claude/regression/probes_live.yaml`). Record only — no verdict, selection or score changes (#1036).
25
+ - `knowledge/shared/harness-core/governor_landing_before_compact.md`: «land, then compact» — when a governed session nears auto-compact, the governor asks it to write down its state first, and that session then asks the operator whether to compact now. Its 90% threshold is UNCALIBRATED (one observation) and its measurement plan has not run; reading context usage needs the desktop app's session tools, and its checker (`scripts/governor_landing_check.py`) ships in the hub clone only, not in the npm package (#1047).
26
+
27
+ ### Changed
28
+ - `steel-quench`: the axis-2 convergence vector gets a readable shape (`R1 [new=, fixed=] → R2 …`) in the marker guidance. Guidance only; the commit hook's verdict is unchanged (#1038).
29
+ - persona-cast is listed as M2 in every Codex runtime tier table (`AGENTS.md`, `docs/codex-compat.md`, `agents_md_runtime_details.md`) (#1037). Its web-review cast is marked validated in review mode after its first field run (#1040).
30
+ - README (all four languages): the «the gates catch you, not only your agent» line moves from the slogan spot into «Who it is for», with its evidence (one day of gate blocks, `docs/GATE_DAY.md`) (#1046).
31
+ - Sub-agent invocation log entries for 2026-11-06 and 2026-11-07 (#1035, #1043).
32
+
5
33
  ### [3.38.1] — 2026-11-06
6
34
 
7
35
  Documentation-only patch.
@@ -523,10 +523,15 @@ over **unchanged** code:
523
523
  this round") while the invariant it certifies — the shipped artifact is the audited one — is
524
524
  false. Either ship the τ-FAIL as a **named** τ-FAIL (the pipeline table's own alternative, and
525
525
  terminal) or run one more round over the trimmed artifact before declaring Done.
526
- 2. **Record the per-round yield vector** in the Axis-2 marker — `axis2-rounds: 4A / 3A+1B / 2A /
527
- 0A+3B / 1A+2B`. It is what makes the stop decision auditable afterwards, and a flat or rising
526
+ 2. **Record the per-round yield vector** in the Axis-2 marker, every round with BOTH counts —
527
+ `axis2-rounds: R1 [new=4, fixed=4] → R2 [new=3 (A3 B1), fixed=3] → R3 [new=0, fixed=0]`
528
+ (`new` = new S/A findings that round; `fixed` = repairs made in response to it, B included; a note
529
+ goes in parentheses). It is what makes the stop decision auditable afterwards, and a flat or rising
528
530
  vector is the input to criterion 4's reduce-the-design branch (its premise-attack branch fires on
529
- shared assumptions, whatever the vector).
531
+ shared assumptions, whatever the vector). Check it before writing «converged»:
532
+ `python3 scripts/convergence_verdict.py --rounds "<vector>"` (0 CONVERGED · 1 not yet — one clean
533
+ round is PROVISIONAL · 2 unreadable). The older `4A / 3A+1B / …` shape has no repair count, so no
534
+ tool can tell «clean» from «clean but repaired» in it (2026-11-06: 290 of 314 markers unreadable).
530
535
 
531
536
  **PIN THE TARGET — mandatory on every dispatched Wave, and the reason criterion 1 can be trusted
532
537
  at all.** The dispatch prompt carries a measured fingerprint and orders the agent to report
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fh-preprep",
3
- "version": "3.38.1",
3
+ "version": "3.39.1",
4
4
  "engines": {
5
5
  "claudeCode": ">=1.0.0"
6
6
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fh-qp",
3
- "version": "3.38.1",
3
+ "version": "3.39.1",
4
4
  "engines": {
5
5
  "claudeCode": ">=1.0.0"
6
6
  },
@@ -0,0 +1,177 @@
1
+ #!/usr/bin/env python3
2
+ """convergence_verdict.py — the convergence-loop verdict, by program (convergence-loop SKILL.md §Convergence Judgment ·
3
+ steel-quench §Convergence Criteria).
4
+
5
+ Converged = the LAST round found no new S/A (or no new FAIL) AND nothing was fixed in response to it,
6
+ AND at least two rounds ran (one clean round is only «provisionally passed»).
7
+
8
+ Why a program: a marker's `axis2-rounds:` line is «recorded-by-convention, validated by nothing» (fh_4axis_gate.md),
9
+ and the rule says to mechanize on the first recurrence of a false convergence claim. The 2026-11-06 corpus scan found
10
+ markers that wrote «R1 [new=0, fixed=0] → converged» — one round, claimed converged — more than once.
11
+
12
+ Modes
13
+ --rounds "<vector>" judge one vector (exit 0 CONVERGED · 1 NOT-CONVERGED or PROVISIONAL · 2 UNMEASURED/unparsed)
14
+ --scan-markers <dir> audit every `axis2-rounds:` line in <dir>/.axes_23_passed_*.marker: the vector's verdict
15
+ vs what the line CLAIMS («converged» written when the vector does not support it).
16
+ exit 0 no false claim · 1 at least one false claim · 2 nothing readable.
17
+ [--since YYYY-MM-DD] limits by the date in the marker file name.
18
+
19
+ Vector shapes read (anything else is UNPARSED — never guessed):
20
+ R1 [new=3, fixed=3] → R2 [new=0, fixed=0] (fixed is the count of repairs made in response to that round)
21
+ R1 S1A2B3 → R2 S0A0B0 (counts of new S/A/B[/C] findings; repairs unknown, so a round with
22
+ any finding and no explicit «fixed» is UNMEASURED for repairs —
23
+ only an all-zero round is clean-with-no-repairs by construction)
24
+ Advisory audit only: it never edits a marker and is not wired into the commit hook (that hook is a gate path).
25
+ """
26
+ import argparse
27
+ import glob
28
+ import os
29
+ import re
30
+ import sys
31
+
32
+ ROUND = re.compile(r"\bR(\d+)\b")
33
+ # a round segment must START with exactly one shape; a note after a count is only «(…)» (so «0.5» is not «0»)
34
+ SEG_NEWFIX = re.compile(r"^\s*\[\s*new\s*=\s*(\d+)(?:\s*\([^)]*\))?\s*,\s*fixed\s*=\s*(\d+)(?:\s*\([^)]*\))?\s*\]")
35
+ SEG_SAB = re.compile(r"^\s+((?:[SABC]\d+){2,4})(?![\w.])")
36
+ REPAIR_WORDS = re.compile(r"fix|repair|수리|반영|고침|고쳤", re.I)
37
+ CLAIM_EN = re.compile(r"(?<![A-Za-z])converged(?![A-Za-z])", re.I)
38
+ NEG_EN = re.compile(r"(?:\bnot|n't|\bnever|\bun|\bnon)[\s-]*(?:yet[\s-]*)?$", re.I)
39
+ CLAIM_KO = re.compile(r"(?:→|=>|->)\s*(?:완전\s*)?수렴(?!\s*(?:안|못|실패|하지|아님|불가))|수렴\s*(?:했|함\b|됨|완료|판정\s*[:=]?\s*(?:통과|OK))")
40
+ CONVERGED, NOT_CONVERGED, PROVISIONAL, UNMEASURED = "CONVERGED", "NOT-CONVERGED", "PROVISIONAL", "UNMEASURED"
41
+ RC = {CONVERGED: 0, NOT_CONVERGED: 1, PROVISIONAL: 1, UNMEASURED: 2} # the module contract allows 0/1/2 only; one clean round is not yet a pass
42
+
43
+
44
+ def parse(vector):
45
+ """→ list of rounds [{n, new, fixed (None = unknown)}], "partial" when a round is present but in no known shape
46
+ (or the shapes are mixed), or None when the vector names no round at all. A round that does not parse is never
47
+ skipped — skipping it would let the rounds before it decide the verdict (codex R1)."""
48
+ marks = list(ROUND.finditer(vector))
49
+ if not marks:
50
+ return None
51
+ rounds, shapes = [], set()
52
+ for i, m in enumerate(marks):
53
+ seg = vector[m.end(): marks[i + 1].start() if i + 1 < len(marks) else len(vector)]
54
+ nf = SEG_NEWFIX.match(seg)
55
+ if nf:
56
+ rest = seg[nf.end():]
57
+ # codex R2: a second shape in the same round, or repairs written outside the counts, is not «one shape»
58
+ if SEG_NEWFIX.search(rest.lstrip()) or re.search(r"\[\s*new\s*=|(?:^|\s)(?:[SABC]\d+){2,4}\b", rest) or REPAIR_WORDS.search(rest):
59
+ return "partial"
60
+ shapes.add("newfix")
61
+ rounds.append({"n": int(m.group(1)), "new": int(nf.group(1)), "fixed": int(nf.group(2))})
62
+ continue
63
+ sab = SEG_SAB.match(seg)
64
+ if sab:
65
+ keys = re.findall(r"([SABC])(\d+)", sab.group(1))
66
+ if len({k for k, _ in keys}) != len(keys):
67
+ return "partial" # «S1S0A0» — a repeated key would overwrite a count
68
+ c = {k: int(v) for k, v in keys}
69
+ if not {"S", "A"} <= set(c):
70
+ return "partial" # codex R2: «B0C0» says nothing about S/A — absent is not zero
71
+ if re.search(r"\[\s*new\s*=|(?:^|\s)(?:[SABC]\d+){2,4}\b", seg[sab.end():]):
72
+ return "partial"
73
+ total = sum(c.values())
74
+ if REPAIR_WORDS.search(seg[sab.end():]):
75
+ fixed = None # repairs mentioned but not as a count this tool can read
76
+ else:
77
+ fixed = 0 if total == 0 else None
78
+ shapes.add("sab")
79
+ rounds.append({"n": int(m.group(1)), "new": c.get("S", 0) + c.get("A", 0), "all": total, "fixed": fixed})
80
+ continue
81
+ return "partial"
82
+ if len(shapes) > 1:
83
+ return "partial"
84
+ return rounds
85
+
86
+
87
+ def judge(vector):
88
+ """→ (verdict, reason)"""
89
+ rounds = parse(vector)
90
+ if rounds == "partial":
91
+ return UNMEASURED, "a round is not in one known shape (each R<n> needs [new=, fixed=] or S#A#B#, one shape for all)"
92
+ if not rounds:
93
+ return UNMEASURED, "no round vector in a known shape (R<n> [new=, fixed=] or R<n> S#A#B#)"
94
+ nums = [r["n"] for r in rounds]
95
+ if nums != sorted(nums) or len(set(nums)) != len(nums):
96
+ return UNMEASURED, f"round numbers out of order or repeated: {nums}"
97
+ last = rounds[-1]
98
+ if last["new"] > 0:
99
+ return NOT_CONVERGED, f"last round R{last['n']} found {last['new']} new"
100
+ if last["fixed"] is None:
101
+ return UNMEASURED, f"last round R{last['n']}: findings {last.get('all')} or repairs mentioned, and no fixed= count to read"
102
+ if last["fixed"] > 0:
103
+ return NOT_CONVERGED, f"last round R{last['n']} triggered {last['fixed']} fix(es) — the fixes are unverified"
104
+ if len(rounds) < 2:
105
+ return PROVISIONAL, "one clean round — «provisionally passed» only (convergence-loop condition 3: at least 2 rounds)"
106
+ return CONVERGED, f"R{last['n']} clean with no repairs after {len(rounds)} rounds"
107
+
108
+
109
+ def claims_converged(text):
110
+ """True when the line says «converged» anywhere not negated («not yet converged», «unconverged»), or says it in
111
+ Korean («→ 수렴», «수렴 완료/했/됨») without «안/못/하지 않/아님»."""
112
+ for m in CLAIM_EN.finditer(text):
113
+ if not NEG_EN.search(text[max(0, m.start() - 12):m.start()]):
114
+ return True
115
+ return bool(CLAIM_KO.search(text))
116
+
117
+
118
+ def scan(directory, since=None):
119
+ rows, unreadable = [], 0
120
+ for path in sorted(glob.glob(os.path.join(directory, ".axes_23_passed_*.marker"))):
121
+ m = re.search(r"_(\d{4}-\d{2}-\d{2})\.marker$", path)
122
+ if since and (not m or m.group(1) < since):
123
+ continue
124
+ try:
125
+ with open(path, encoding="utf-8") as f:
126
+ lines = [l for l in f if l.startswith("axis2-rounds:")]
127
+ except (OSError, UnicodeDecodeError):
128
+ unreadable += 1
129
+ continue
130
+ for line in lines[:1]: # the hook reads the first line only; so do we
131
+ vec = line.split(":", 1)[1].strip()
132
+ v, why = judge(vec)
133
+ rows.append({"marker": os.path.basename(path), "verdict": v, "why": why,
134
+ "claimed": claims_converged(vec), "vector": vec})
135
+ return rows, unreadable
136
+
137
+
138
+ def main(argv):
139
+ ap = argparse.ArgumentParser(description="convergence verdict from a round vector")
140
+ g = ap.add_mutually_exclusive_group(required=True)
141
+ g.add_argument("--rounds")
142
+ g.add_argument("--scan-markers")
143
+ ap.add_argument("--since")
144
+ try:
145
+ a = ap.parse_args(argv)
146
+ except SystemExit:
147
+ return 2
148
+ if a.rounds is not None:
149
+ v, why = judge(a.rounds)
150
+ print(f"{v}: {why}")
151
+ return RC[v]
152
+ if not os.path.isdir(a.scan_markers):
153
+ print(f"UNMEASURED: {a.scan_markers} is not a directory")
154
+ return 2
155
+ rows, unreadable = scan(a.scan_markers, a.since)
156
+ if not rows:
157
+ print(f"UNMEASURED: no readable axis2-rounds line in {a.scan_markers}" + (f" since {a.since}" if a.since else ""))
158
+ return 2
159
+ tally = {}
160
+ for r in rows:
161
+ tally[r["verdict"]] = tally.get(r["verdict"], 0) + 1
162
+ # a claim the vector contradicts (not converged / one round) is false; a claim on an unreadable vector is unauditable
163
+ false_claims = [r for r in rows if r["claimed"] and r["verdict"] in (NOT_CONVERGED, PROVISIONAL)]
164
+ unauditable = [r for r in rows if r["claimed"] and r["verdict"] == UNMEASURED]
165
+ print(f"convergence audit · {len(rows)} markers with axis2-rounds · " + " · ".join(f"{k} {v}" for k, v in sorted(tally.items()))
166
+ + (f" · unreadable {unreadable}" if unreadable else ""))
167
+ print(f"claimed «converged» but the vector contradicts it: {len(false_claims)} · claimed on a vector this tool cannot read: {len(unauditable)}")
168
+ for r in false_claims:
169
+ print(f" - {r['marker']}: {r['verdict']} — {r['why']}\n «{r['vector'][:160]}»")
170
+ # an audit that could not read some lines is not a clean audit (codex R1): false claim → 1, else anything unread → 2
171
+ if false_claims:
172
+ return 1
173
+ return 2 if (unauditable or unreadable) else 0
174
+
175
+
176
+ if __name__ == "__main__":
177
+ sys.exit(main(sys.argv[1:]))
@@ -0,0 +1,166 @@
1
+ #!/usr/bin/env python3
2
+ """lane_gap_hint.py — UserPromptSubmit hook: «last turn changed code but ran no test/lane» → one line of context.
3
+
4
+ Operator 2026-11-06 («추천대로», from the stop-hook video review `tracks/_meta/video_stophook_review_2026-11-06.md`):
5
+ FH does NOT block at Stop. Blocking stays at the irreversible edge (pre-push / session close). This hook only RECORDS:
6
+ when the previous assistant turn edited code files and ran no test or lane command, the next prompt gets one line saying so.
7
+ It is a property of the record (edits seen · runs seen), never a verdict on whether the change is correct.
8
+
9
+ What counts (deliberately simple — named, not hidden):
10
+ edit = an Edit / Write / MultiEdit / NotebookEdit tool call on a code path (*.sh *.py *.js *.mjs *.cjs *.ts *.tsx *.go *.rs *.rb *.java)
11
+ run = a Bash command naming a test/lane: test_* · *_lanes.sh · selfcheck · pytest · «node --test» · «npm test» · «go test» ·
12
+ «cargo test» · «make test» · unittest
13
+ the previous turn = tool calls after the last real user prompt in the transcript (the current prompt is not in it yet).
14
+ Silent when: nothing edited · something ran · the transcript is unreadable (an unreadable transcript is not «no gap» — it
15
+ is no statement at all, and saying nothing is the honest output for an advisory hook). Never blocks: exit 0 on every path.
16
+ Opt out: FH_LANE_GAP_HINT=0.
17
+ """
18
+ import json
19
+ import os
20
+ import re
21
+ import sys
22
+
23
+ CODE = re.compile(r"\.(sh|py|js|mjs|cjs|ts|tsx|go|rs|rb|java|ipynb)$")
24
+ # a statement that RUNS a test/lane — anchored at the statement's start (after env assignments and an interpreter), so that
25
+ # «git diff scripts/test_x_lanes.sh» · «echo pytest» · «rg test_x» do not count (codex R1: mentions silenced the hint)
26
+ RUN_STMT = re.compile(r"^(?:\w+=\S*\s+)*(?:(?:bash|sh|zsh|python3?|node|timeout\s+\S+)\s+(?:-\S+\s+)*)?"
27
+ r"(?:\S*/)?(?:test_[\w.-]+|[\w.-]*_lanes\.sh|selfcheck(?:\.sh)?)\b"
28
+ r"|^(?:\w+=\S*\s+)*(?:python3?\s+-m\s+)?(?:pytest|unittest)\b"
29
+ r"|^(?:\w+=\S*\s+)*(?:node\s+--test|npm\s+(?:run\s+)?test|go\s+test|cargo\s+test|make\s+test)\b")
30
+
31
+
32
+ def _strip_noise(cmd):
33
+ """drop heredoc bodies and «# …» comments outside quotes — text, not commands (codex R2). Named residual: conditional
34
+ execution («false && pytest») still counts as a run; this is an advisory hook and shell semantics do not converge."""
35
+ lines, out, end = cmd.split("\n"), [], None
36
+ for ln in lines:
37
+ if end is not None:
38
+ if ln.strip() == end:
39
+ end = None
40
+ continue
41
+ m = re.search(r"<<-?\s*['\"]?(\w+)['\"]?", ln)
42
+ q, keep = None, ""
43
+ for ch in ln:
44
+ if q:
45
+ q = None if ch == q else q
46
+ elif ch in "'\"":
47
+ q = ch
48
+ elif ch == "#" and (not keep or keep[-1].isspace()):
49
+ break
50
+ keep += ch
51
+ out.append(keep)
52
+ if m:
53
+ end = m.group(1)
54
+ return "\n".join(out)
55
+
56
+
57
+ def _statements(cmd):
58
+ cmd = _strip_noise(cmd)
59
+ out, cur, q = [], "", None
60
+ i = 0
61
+ while i < len(cmd):
62
+ c = cmd[i]
63
+ if q:
64
+ cur += c
65
+ q = None if c == q else q
66
+ elif c in "'\"":
67
+ q = c; cur += c
68
+ elif cmd.startswith("&&", i) or cmd.startswith("||", i):
69
+ out.append(cur); cur = ""; i += 1
70
+ elif c in ";|\n":
71
+ out.append(cur); cur = ""
72
+ else:
73
+ cur += c
74
+ i += 1
75
+ out.append(cur)
76
+ # quotes around the program name do not hide a run («"pytest" -q»)
77
+ return [" ".join(x.replace('"', "").replace("'", "").split()) for x in out if x.strip()]
78
+
79
+
80
+ def _runs_tests(cmd):
81
+ return any(RUN_STMT.search(st) for st in _statements(cmd))
82
+ EDIT_TOOLS = {"Edit", "Write", "MultiEdit", "NotebookEdit"}
83
+ TAIL = 4 * 1024 * 1024
84
+
85
+
86
+ def _is_real_prompt(d):
87
+ """a user line typed by the person — not a tool_result, not a meta/hook line"""
88
+ if d.get("type") != "user" or d.get("isMeta") or d.get("isSidechain"):
89
+ return False
90
+ c = (d.get("message") or {}).get("content")
91
+ if isinstance(c, str):
92
+ return bool(c.strip())
93
+ if isinstance(c, list): # text or image typed by the person; a line carrying a tool_result is the tool talking back
94
+ return any(isinstance(x, dict) and x.get("type") in ("text", "image") for x in c) and not any(
95
+ isinstance(x, dict) and x.get("type") == "tool_result" for x in c)
96
+ return False
97
+
98
+
99
+ def last_turn(path):
100
+ """→ (edited code paths, test/lane commands) of the tool calls after the last real user prompt, or None if unreadable."""
101
+ try:
102
+ with open(path, "rb") as f:
103
+ f.seek(0, 2)
104
+ n = f.tell()
105
+ f.seek(max(0, n - TAIL))
106
+ lines = f.read().decode("utf-8", "replace").splitlines()
107
+ except OSError:
108
+ return None
109
+ rows = []
110
+ for l in lines:
111
+ try:
112
+ rows.append(json.loads(l))
113
+ except ValueError:
114
+ continue
115
+ start = max((i for i, d in enumerate(rows) if isinstance(d, dict) and _is_real_prompt(d)), default=None)
116
+ if start is None:
117
+ return None # the tail cut off the turn's start — a partial turn is no statement (codex R1)
118
+ edits, runs, pending = [], [], {}
119
+ for d in rows[start + 1:]:
120
+ if not isinstance(d, dict) or d.get("isSidechain"):
121
+ continue # a subagent's prompts and tools are not this session's turn
122
+ c = (d.get("message") or {}).get("content")
123
+ if not isinstance(c, list):
124
+ continue
125
+ for x in c:
126
+ if not isinstance(x, dict):
127
+ continue
128
+ if x.get("type") == "tool_use":
129
+ inp = x.get("input") or {}
130
+ if x.get("name") in EDIT_TOOLS:
131
+ p = inp.get("file_path") or inp.get("notebook_path") or ""
132
+ if isinstance(p, str) and CODE.search(p):
133
+ pending[x.get("id")] = p
134
+ elif x.get("name") == "Bash" and isinstance(inp.get("command"), str) and _runs_tests(inp["command"]):
135
+ runs.append(inp["command"])
136
+ elif x.get("type") == "tool_result" and x.get("tool_use_id") in pending:
137
+ p = pending.pop(x.get("tool_use_id"))
138
+ if x.get("is_error") is not True:
139
+ edits.append(p) # only an edit that went through counts (a failed Edit changed nothing)
140
+ return edits, runs
141
+
142
+
143
+ def main():
144
+ try:
145
+ if os.environ.get("FH_LANE_GAP_HINT") == "0":
146
+ return 0
147
+ ev = json.load(sys.stdin)
148
+ tp = ev.get("transcript_path")
149
+ if not (isinstance(tp, str) and os.path.isabs(tp)):
150
+ return 0
151
+ r = last_turn(tp)
152
+ if r is None:
153
+ return 0
154
+ edits, runs = r
155
+ if edits and not runs:
156
+ uniq = sorted(set(os.path.basename(p) for p in edits))
157
+ shown = ", ".join(uniq[:4]) + (f" 외 {len(uniq) - 4}" if len(uniq) > 4 else "")
158
+ print(f"[lane-gap] 지난 턴에 코드 파일 {len(uniq)}개({shown})를 바꿨는데 테스트·레인 실행 기록이 0이다 — "
159
+ f"확인을 안 했으면 이번 턴에 돌려라. (기록일 뿐 판정·차단 아님 · 끄기 FH_LANE_GAP_HINT=0)")
160
+ except Exception:
161
+ pass
162
+ return 0
163
+
164
+
165
+ if __name__ == "__main__":
166
+ sys.exit(main())
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ # lane_gap_hint.sh — UserPromptSubmit wrapper for scripts/lane_gap_hint.py (advisory; see its header).
3
+ # A .sh entry point because install-wizard recognises a snippet's FH script by its `scripts/<name>.sh` path form.
4
+ # Never blocks: exit 0 on every path. Opt out with FH_LANE_GAP_HINT=0.
5
+ [ "${FH_LANE_GAP_HINT:-1}" = 0 ] && exit 0
6
+ python3 "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lane_gap_hint.py" 2>/dev/null
7
+ exit 0