@chrono-meta/fh-gate 3.39.1 → 3.41.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 (65) hide show
  1. package/.claude/regression/probes_live.yaml +9 -2
  2. package/.claude-plugin/marketplace.json +4 -4
  3. package/CLAUDE.md +2 -2
  4. package/README.ja.md +20 -18
  5. package/README.zh.md +20 -18
  6. package/knowledge/shared/harness-core/claude_md_full_reference.md +8 -1
  7. package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +9 -0
  8. package/knowledge/shared/harness-core/fh_module_contract.md +55 -1
  9. package/knowledge/shared/harness-core/lease_record_channel.md +26 -2
  10. package/knowledge/shared/harness-core/onboarding_acceleration_autopilot.md +7 -0
  11. package/knowledge/shared/learnings/subagent_invocations_log.yaml +36 -0
  12. package/knowledge/shared/rules/operations.md +1 -0
  13. package/package.json +14 -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 +52 -0
  17. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  18. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  19. package/scripts/adapters/gstack_content_safety.sh +2 -2
  20. package/scripts/adapters/mate_agent_boundary.sh +2 -2
  21. package/scripts/adapters/qasp_new_code_anchor.sh +2 -2
  22. package/scripts/adapters/qasp_web_rules.sh +2 -2
  23. package/scripts/agent_tools_pin.txt +16 -0
  24. package/scripts/catch_tally.py +216 -0
  25. package/scripts/claim_precision_report.py +138 -0
  26. package/scripts/fh_module_check.py +182 -1
  27. package/scripts/fh_session_load.sh +3 -1
  28. package/scripts/fixture_guard_lib.sh +38 -0
  29. package/scripts/generated_harness_check.py +4 -0
  30. package/scripts/lane_identity_tripwire.sh +35 -0
  31. package/scripts/package_coverage_check.sh +6 -2
  32. package/scripts/post_squash_verify.sh +53 -1
  33. package/scripts/pr_merge_verified.sh +57 -1
  34. package/scripts/probe_live_eval.sh +61 -0
  35. package/scripts/probe_live_eval_lib.py +47 -4
  36. package/scripts/selfcheck.sh +17 -0
  37. package/scripts/selfdev_merge_tier.sh +153 -0
  38. package/scripts/session_checklist.py +38 -1
  39. package/scripts/session_close_check.sh +79 -1
  40. package/scripts/shell_name_boundary_scan.sh +11 -3
  41. package/scripts/sim_isolated_run.sh +62 -1
  42. package/scripts/test_adapter_lanes.sh +3 -3
  43. package/scripts/test_agent_tools_pin_lanes.sh +73 -0
  44. package/scripts/test_catch_tally_lanes.sh +10 -0
  45. package/scripts/test_claim_precision_report_lanes.sh +77 -0
  46. package/scripts/test_doc_claims_1113_lanes.sh +36 -0
  47. package/scripts/test_fh_module_check_lanes.sh +106 -1
  48. package/scripts/test_fh_run_resolver_lanes.sh +1 -1
  49. package/scripts/test_fixture_git_env_lanes.sh +87 -0
  50. package/scripts/test_generated_harness_check_lanes.sh +8 -0
  51. package/scripts/test_lane_gap_hint_lanes.sh +2 -2
  52. package/scripts/test_locale_invariance_lanes.sh +3 -3
  53. package/scripts/test_name_boundary_locale_lanes.sh +66 -0
  54. package/scripts/test_package_coverage_lanes.sh +10 -0
  55. package/scripts/test_post_squash_verify_lanes.sh +23 -2
  56. package/scripts/test_pr_merge_verified_lanes.sh +62 -3
  57. package/scripts/test_probe_live_eval_lanes.sh +160 -5
  58. package/scripts/test_selfdev_merge_tier_lanes.sh +128 -0
  59. package/scripts/test_session_checklist_lanes.sh +57 -0
  60. package/scripts/test_session_close_chain_lanes.sh +93 -0
  61. package/scripts/test_session_close_lanes.sh +11 -0
  62. package/scripts/test_sim_isolated_run_lanes.sh +67 -0
  63. package/scripts/test_temper_check_lanes.sh +1 -1
  64. package/scripts/test_verdict_watermark_lanes.sh +1 -1
  65. package/templates/harness_birth_core.md +57 -0
@@ -12,7 +12,7 @@ Exit codes: 0 OK . 1 BLOCK . 2 UNMEASURED (unreadable / tooling down / empty cor
12
12
  3 OK-but-UNCALIBRATED (valid, no verdict entry points, calibration declared UNCALIBRATED; never a clean pass).
13
13
  Fail closed: nothing unreadable, unknown or empty ever exits 0.
14
14
  """
15
- import argparse, glob, hashlib, json, os, re, shutil, subprocess, sys
15
+ import argparse, ast, glob, hashlib, json, os, re, shutil, subprocess, sys, sysconfig
16
16
 
17
17
  OK, BLOCK, UNMEASURED, UNCAL = 0, 1, 2, 3
18
18
 
@@ -384,6 +384,185 @@ def validate(m, vd, repo_core, repo):
384
384
  vd.block("files: %s resolves outside the repo" % f)
385
385
 
386
386
 
387
+ def _is_stdlib(name):
388
+ """True when `name` is a standard-library module of the interpreter running this check (3.9 has no
389
+ sys.stdlib_module_names: fall back to where the module lives)."""
390
+ names = getattr(sys, "stdlib_module_names", None)
391
+ if names is not None:
392
+ return name in names
393
+ if name in sys.builtin_module_names:
394
+ return True
395
+ import importlib.util
396
+ try:
397
+ spec = importlib.util.find_spec(name)
398
+ except (ImportError, ValueError):
399
+ return False
400
+ if spec is None or not spec.origin:
401
+ return False
402
+ if spec.origin in ("built-in", "frozen"):
403
+ return True
404
+ std = os.path.realpath(sysconfig.get_paths()["stdlib"])
405
+ org = os.path.realpath(spec.origin)
406
+ return org.startswith(std + os.sep) and "site-packages" not in org
407
+
408
+
409
+ _CATCH = ("ImportError", "ModuleNotFoundError", "Exception", "BaseException")
410
+
411
+
412
+ def _bound_names(tree):
413
+ """Every name the file binds anywhere (assignment, parameter, `except … as`, def/class, import alias), except a plain
414
+ `import builtins`. Over-approximate on purpose: a rebound name stops counting as a guard -> fail closed."""
415
+ out = set()
416
+ for n in ast.walk(tree):
417
+ if isinstance(n, ast.Name) and isinstance(n.ctx, (ast.Store, ast.Del)):
418
+ out.add(n.id)
419
+ elif isinstance(n, ast.arg):
420
+ out.add(n.arg)
421
+ elif isinstance(n, ast.ExceptHandler) and n.name:
422
+ out.add(n.name)
423
+ elif isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
424
+ out.add(n.name)
425
+ elif isinstance(n, (ast.Global, ast.Nonlocal)):
426
+ out.update(n.names)
427
+ elif isinstance(n, (ast.Import, ast.ImportFrom)):
428
+ for a in n.names:
429
+ if isinstance(n, ast.Import) and a.name == "builtins" and not a.asname:
430
+ continue
431
+ out.add((a.asname or a.name).split(".")[0])
432
+ return out
433
+
434
+
435
+ def _bare_import_module(tree):
436
+ """True when the file binds `import_module` from importlib (so a bare `import_module("x")` call is that one)."""
437
+ return any(isinstance(n, ast.ImportFrom) and n.module == "importlib" and n.level == 0
438
+ and any(a.name == "import_module" and not a.asname for a in n.names) for n in ast.walk(tree))
439
+
440
+
441
+ def _dynamic_import(n, bare_ok=False):
442
+ """`importlib.import_module("x")` / `__import__("x")` (and a bare `import_module("x")` when the file imported it
443
+ from importlib), name given positionally or as `name=`, literal -> "x", else None. A computed name is not read
444
+ (named residual, contract 2b)."""
445
+ if not isinstance(n, ast.Call):
446
+ return None
447
+ f = n.func
448
+ if not ((isinstance(f, ast.Name) and (f.id == "__import__" or (bare_ok and f.id == "import_module"))) or
449
+ (isinstance(f, ast.Attribute) and f.attr == "import_module" and isinstance(f.value, ast.Name)
450
+ and f.value.id == "importlib")):
451
+ return None
452
+ arg = n.args[0] if n.args else next((k.value for k in n.keywords if k.arg == "name"), None)
453
+ if isinstance(arg, ast.Constant) and isinstance(arg.value, str):
454
+ return arg.value
455
+ return None
456
+
457
+
458
+ def _guarded_lines(tree):
459
+ """Line numbers of imports that run inside a `try:` body whose handlers catch ImportError / ModuleNotFoundError /
460
+ Exception / BaseException (or everything), by a name the file does not rebind."""
461
+ bound = _bound_names(tree)
462
+ bare = _bare_import_module(tree)
463
+
464
+ def _catches(x):
465
+ if isinstance(x, ast.Name):
466
+ return x.id in _CATCH and x.id not in bound
467
+ return (isinstance(x, ast.Attribute) and isinstance(x.value, ast.Name) and x.value.id == "builtins"
468
+ and "builtins" not in bound and x.attr in _CATCH)
469
+
470
+ def _imports_run_now(st):
471
+ # A def / lambda body inside the try runs later, outside the try: its imports are not guarded by it.
472
+ # (Named residual: default arguments and decorators do run at definition time; skipping them errs toward BLOCK.)
473
+ stack = [st]
474
+ while stack:
475
+ n = stack.pop()
476
+ if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef, ast.Lambda)):
477
+ continue
478
+ if isinstance(n, ast.GeneratorExp):
479
+ # A generator runs on next(), outside the try; only its first iterable is evaluated here.
480
+ stack.append(n.generators[0].iter)
481
+ continue
482
+ if isinstance(n, (ast.Import, ast.ImportFrom)) or _dynamic_import(n, bare):
483
+ yield n.lineno
484
+ stack.extend(ast.iter_child_nodes(n))
485
+
486
+ out = set()
487
+ for node in ast.walk(tree):
488
+ if not isinstance(node, ast.Try):
489
+ continue
490
+ catches = False
491
+ for h in node.handlers:
492
+ t = h.type
493
+ names = [t] if t is not None and not isinstance(t, ast.Tuple) else (t.elts if t is not None else [])
494
+ if t is None or any(_catches(x) for x in names):
495
+ catches = True
496
+ if catches:
497
+ for st in node.body:
498
+ out.update(_imports_run_now(st))
499
+ return out
500
+
501
+
502
+ def runtime_deps(m, repo, vd):
503
+ """Spec section 2b: a module's python is stdlib-only, or each non-stdlib import is guarded so its absence can be
504
+ reported as UNMEASURED (exit 2, naming it). Unguarded non-stdlib import -> BLOCK; guarded -> NOTE (the floor run
505
+ environment may not have it). Unparsable python -> UNMEASURED. Only .py files are read (named residual: shell
506
+ scripts calling jq / yq / node are not checked)."""
507
+ paths, _prob = module_paths(m, repo)
508
+ files = []
509
+ for rel in paths:
510
+ full = os.path.join(repo, rel)
511
+ if os.path.isdir(full):
512
+ for dp, dn, fns in os.walk(full):
513
+ dn[:] = sorted(d for d in dn if d not in (".git", "__pycache__"))
514
+ files += [os.path.join(dp, f) for f in sorted(fns) if f.endswith(".py")]
515
+ elif full.endswith(".py") and os.path.isfile(full):
516
+ files.append(full)
517
+ shipped = {os.path.realpath(f) for f in files}
518
+
519
+ def _is_local(mod, importer):
520
+ # Python puts the running script's folder first on sys.path; a module inside a shipped package resolves from an
521
+ # ancestor folder. So a name is local when <dir>/<mod>.py or <dir>/<mod>/__init__.py is shipped in the
522
+ # importer's folder or one of its ancestors -- not anywhere in the module.
523
+ d = os.path.dirname(os.path.realpath(importer))
524
+ while True:
525
+ if os.path.join(d, mod + ".py") in shipped or os.path.join(d, mod, "__init__.py") in shipped:
526
+ return True
527
+ up = os.path.dirname(d)
528
+ if up == d or not up.startswith(os.path.realpath(repo)):
529
+ return False
530
+ d = up
531
+
532
+ import tokenize
533
+ for f in sorted(set(files)):
534
+ rel = os.path.relpath(f, repo)
535
+ try:
536
+ with tokenize.open(f) as fh: # honours a PEP 263 coding cookie, as Python does
537
+ tree = ast.parse(fh.read(), filename=rel)
538
+ except (OSError, UnicodeDecodeError, SyntaxError, ValueError) as e:
539
+ vd.unm("runtime dependencies of %s cannot be read: %s" % (rel, e))
540
+ continue
541
+ guarded = _guarded_lines(tree)
542
+ bare = _bare_import_module(tree)
543
+ seen = set()
544
+ for node in ast.walk(tree):
545
+ if isinstance(node, ast.Import):
546
+ mods = [a.name.split(".")[0] for a in node.names]
547
+ elif isinstance(node, ast.ImportFrom) and node.level == 0 and node.module:
548
+ mods = [node.module.split(".")[0]]
549
+ elif _dynamic_import(node, bare):
550
+ mods = [_dynamic_import(node, bare).split(".")[0]]
551
+ else:
552
+ continue
553
+ for mod in mods:
554
+ if (mod, node.lineno) in seen or not mod or mod == "__future__" or _is_stdlib(mod) or _is_local(mod, f):
555
+ continue
556
+ seen.add((mod, node.lineno))
557
+ if node.lineno in guarded:
558
+ vd.notes.append("runtime dependency %s (%s:%d) is not stdlib; guarded — allowed only when a stdlib route is not feasible (contract 2b); its absence must exit 2 "
559
+ "(UNMEASURED) naming it, and the floor run environment may not have it" % (mod, rel, node.lineno))
560
+ else:
561
+ vd.block("runtime dependency %s (%s:%d) is not stdlib and not guarded — in an environment without it "
562
+ "the module crashes instead of answering UNMEASURED; make it stdlib-only, or guard the import "
563
+ "and exit 2 naming the missing module" % (mod, rel, node.lineno))
564
+
565
+
387
566
  def load_installed(d):
388
567
  mods, errs, dups = {}, [], []
389
568
  if not os.path.isdir(d):
@@ -416,6 +595,8 @@ def cmd_check(a):
416
595
  if cerr:
417
596
  vd.unm(cerr)
418
597
  validate(m, vd, core, repo)
598
+ if isinstance(m, dict):
599
+ runtime_deps(m, repo, vd)
419
600
  if a.installed:
420
601
  inst, errs, dups = load_installed(a.installed)
421
602
  for e in errs: vd.unm("installed registry unreadable: " + e)
@@ -405,7 +405,7 @@ if [ -d "$FH/tracks" ]; then
405
405
  UNRESOLVED) continue ;;
406
406
  # 🟥 ARGS = 전제 파손(빈 이름·경로 탈출·알 수 없는 술어)이지 «못 찾음» 이 아니다.
407
407
  # 미해소로 접으면 그것도 미측정을 0 으로 렌더하는 형태다 — 따로 말한다.
408
- ARGS:*) printf '%s' "⚠️ [track-resolve] 트랙 이름 «$_n» 이 거부됐다(${_note#ARGS:}) — 이건 «레포 없음» 이 아니라 **전제 파손**이다.
408
+ ARGS:*) printf '%s' "⚠️ [track-resolve] 트랙 이름 «${_n}» 이 거부됐다(${_note#ARGS:}) — 이건 «레포 없음» 이 아니라 **전제 파손**이다.
409
409
  "; continue ;;
410
410
  esac
411
411
  _resolved=$((_resolved + 1))
@@ -588,6 +588,8 @@ fi
588
588
  # So: no new hook, no new line, no nag — the node name is appended to a banner that already
589
589
  # prints every single session. `hostname -s`, the same source fh_node_check.sh uses.
590
590
  echo "🔄 [FH SessionStart] companion-store freshness — $PULL_NOTE. · node: $(hostname -s 2>/dev/null || echo unknown)"
591
+ # lane-identity tripwire (record-only): fixture commits that leaked into the hub repo
592
+ [ -f "$FH/scripts/lane_identity_tripwire.sh" ] && bash "$FH/scripts/lane_identity_tripwire.sh" "$FH" 2>/dev/null | grep -v '^LANE-TRIPWIRE ok' || true
591
593
  # §Diverged banner. Loud, counted, and it names the ONE command — see the §Diverged comment at the
592
594
  # fetch site for the 2026-08-28 measurement that made this necessary. The magnitude line and the
593
595
  # "everything below is stale" line are separate on purpose: the first says the tree is behind, the
@@ -34,6 +34,19 @@
34
34
  # 거부**했고, `scripts/` 밑에 두면 통과했다. 방향은 **fail-closed(과차단)** 라 안전하지만,
35
35
  # 벤더링하면 모든 소비처가 시끄럽게 죽는다 — 옮길 거면 레포 루트 계산을 인자로 받게 바꿔라.
36
36
 
37
+ # 🟥 상속된 git 환경을 끊는다 (2026-11-13). `git -C <fixture>` 는 GIT_DIR / GIT_INDEX_FILE /
38
+ # GIT_COMMON_DIR 를 **못 이긴다** — 경로 가드가 통과해도 커밋·인덱스·객체는 export 된 레포로 간다.
39
+ # 실측(미끼 레포, test_script_caller_ratchet_lanes.sh): GIT_DIR → «base» 커밋 7개 + 브랜치 이동 +
40
+ # 인덱스 교체 · GIT_INDEX_FILE → 미끼의 스테이징 인덱스 덮어씀 · GIT_COMMON_DIR → 객체 39개 기록.
41
+ # 목록 = `git rev-parse --local-env-vars` (git 2.50) + GIT_NAMESPACE, **설정 3종(GIT_CONFIG ·
42
+ # GIT_CONFIG_PARAMETERS · GIT_CONFIG_COUNT)은 뺐다** — 어느 레포에 쓰는지를 안 바꾸고, CI 가 `-c safe.directory`
43
+ # 같은 걸 거기 싣는다(cross-family codex R1). GIT_CEILING_DIRECTORIES 도 그대로 둔다.
44
+ # 🟥 알려진 과차단(의도): TMPDIR 가 어떤 레포의 작업트리 안이면 아직 init 전인 픽스처도 아래 git 확인에서
45
+ # 거부된다. init 을 빼먹은 레인이 그 레포에 커밋하는 길이 바로 그것이라 fail-closed 쪽을 택했다.
46
+ # 🟥 source 시점에 끊는다: fh_fixture_root 는 `$(…)` 서브셸에서 돌아서 거기서 unset 해도 호출 레인엔 안 남는다.
47
+ FH_FIXTURE_GIT_ENV="GIT_ALTERNATE_OBJECT_DIRECTORIES GIT_OBJECT_DIRECTORY GIT_DIR GIT_WORK_TREE GIT_IMPLICIT_WORK_TREE GIT_GRAFT_FILE GIT_INDEX_FILE GIT_NO_REPLACE_OBJECTS GIT_REPLACE_REF_BASE GIT_PREFIX GIT_SHALLOW_FILE GIT_COMMON_DIR GIT_NAMESPACE"
48
+ for _fg_v in $FH_FIXTURE_GIT_ENV; do unset "$_fg_v"; done; unset _fg_v
49
+
37
50
  fh_fixture_root() { # $1 = 후보 픽스처 루트 → stdout: 해석된 절대경로. 위반이면 exit 1.
38
51
  [ -n "${1:-}" ] || { echo "FIXTURE-GUARD: empty root — refusing (git -C \"\" would target cwd)" >&2; exit 1; }
39
52
  [ -d "$1" ] || { echo "FIXTURE-GUARD: root does not exist: $1" >&2; exit 1; }
@@ -51,5 +64,30 @@ fh_fixture_root() { # $1 = 후보 픽스처 루트 → stdout: 해석된 절
51
64
  "$_fg_repo"/*) echo "FIXTURE-GUARD: root is inside the live repo ($_fg_real) — refusing" >&2; exit 1 ;;
52
65
  esac
53
66
  fi
67
+ # 🟥 fail-closed 확인: source 시점 scrub 이 되돌려졌거나 뒤에서 다시 export 됐으면 커밋하지 않는다.
68
+ for _fg_v in $FH_FIXTURE_GIT_ENV; do
69
+ if [ -n "$(eval "printf '%s' \"\${$_fg_v+x}\"")" ]; then
70
+ echo "FIXTURE-GUARD: HARNESS-ERROR inherited $_fg_v is set — git -C would write to that repo, not the fixture; refusing" >&2; exit 1
71
+ fi
72
+ done
73
+ # 🟥 git 자신의 답으로 확인: 루트가 이미 git 안이면 그 git dir 은 루트 안에 있어야 한다
74
+ # (mktemp 디렉터리가 어떤 레포의 작업트리 밑에 있으면 `git -C` 는 그 레포로 간다).
75
+ if _fg_gd="$(git -C "$_fg_real" rev-parse --absolute-git-dir 2>/dev/null)"; then
76
+ _fg_gdr="$(cd "$_fg_gd" 2>/dev/null && pwd -P)" || _fg_gdr="$_fg_gd"
77
+ case "$_fg_gdr" in
78
+ "$_fg_real"/*) ;;
79
+ *) echo "FIXTURE-GUARD: HARNESS-ERROR git resolves $_fg_real to repo $_fg_gdr outside the fixture — refusing" >&2; exit 1 ;;
80
+ esac
81
+ fi
54
82
  printf '%s\n' "$_fg_real"
55
83
  }
84
+
85
+ # fh_fixture_git_check <dir> — 커밋 직전 확인용. git 이 <dir> 을 어느 레포로 보는지 묻고,
86
+ # 그 git dir 이 <dir> 안이 아니면 HARNESS-ERROR(exit 1). 이미 init 된 픽스처에서 쓴다.
87
+ fh_fixture_git_check() {
88
+ _fc_real="$(cd "${1:?}" 2>/dev/null && pwd -P)" || { echo "FIXTURE-GUARD: cannot resolve $1" >&2; exit 1; }
89
+ _fc_gd="$(git -C "$_fc_real" rev-parse --absolute-git-dir 2>/dev/null)" || { echo "FIXTURE-GUARD: HARNESS-ERROR $1 is not a git repo" >&2; exit 1; }
90
+ _fc_gdr="$(cd "$_fc_gd" && pwd -P)"
91
+ case "$_fc_gdr" in "$_fc_real"/*) return 0 ;; esac
92
+ echo "FIXTURE-GUARD: HARNESS-ERROR git resolves $1 to $_fc_gdr — not inside the fixture; refusing" >&2; exit 1
93
+ }
@@ -18,6 +18,7 @@
18
18
  # «확인 없이/알아서» 류와 같은(또는 바로 다음) 문장에서 허용.
19
19
  # 경고(rc 무영향): W1 읽기 전용 주장 vs 쓰기·Bash 도구(tools 없음=전부 상속 포함) · W2 tools 줄 없음(전부 상속) · W7 스킬 파일명이 SKILL.md 아님 ·
20
20
  # W4 죽은 참조 · W6 스킬 description 비어 있음.
21
+ # 정보 W8: 스킬 description 에 질문 모양 예시(«…?») 없음 — 질문으로 오는 요청에서 스스로 불리지 않을 수 있다.
21
22
  # 정보: W3 Bash 범위 제한 서술 없음 · W5 Done When 없음(FH 기준, 생성기 결함 아님) ·
22
23
  # 아직 없는 입출력 경로(자리표시자·디렉터리·_workspace·런타임 산출 파일명).
23
24
  #
@@ -589,6 +590,9 @@ def check(target, exclude_skills=()):
589
590
  continue
590
591
  if not fm.get("description", "").strip():
591
592
  rep.add("warn", "W6", path, where.get("description", 1), "(description 비어 있음)", "")
593
+ elif not re.search(r"[??]", fm.get("description", "")):
594
+ rep.add("info", "W8", path, where.get("description", 1), "description 에 질문 모양 예시 없음",
595
+ "활동 이름만 적은 description 은 «머지해도 돼?» · «몇 파일?» 류 질문에서 스스로 불리지 않았다 (A/B C7–C12: 활동 요청 9/9 · 예/아니오 질문 0–1/9)")
592
596
  if not DONE_WHEN_RE.search(text):
593
597
  rep.add("info", "W5", path, 1, "Done When 절 없음", "FH 기준이다 — 생성기의 결함이 아니다")
594
598
 
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env bash
2
+ # lane_identity_tripwire.sh — report commits authored by the lane fixture identity that are reachable
3
+ # in a real repository.
4
+ #
5
+ # tenet: FH-T02 (machinery at the irreversible edge: a fixture commit in a real repo is the edge)
6
+ #
7
+ # WHY: test lanes commit inside throwaway repos as `lane <lane@example.invalid>`. When the caller's shell
8
+ # exports GIT_DIR / GIT_INDEX_FILE, `git -C <fixture> commit` writes into the exported repo instead
9
+ # (measured 2026-11-13 on a decoy repo). A downstream harness found such «base» commits in its own repo
10
+ # three times, the last one swallowing a staged intake. The env scrub in fixture_guard_lib.sh /
11
+ # selfcheck.sh closes the cause; this is the detector for anything that slips past it.
12
+ #
13
+ # Usage: lane_identity_tripwire.sh [repo-dir] [--strict]
14
+ # default: record-only — prints a WARN line per hit, exit 0 (also when nothing is found).
15
+ # --strict: exit 1 when any hit is found.
16
+ # exit 2 = could not read the repo (HARNESS-ERROR — not «no hits»).
17
+ set -u
18
+ # same repo-targeting list as fixture_guard_lib.sh — GIT_SHALLOW_FILE / GIT_GRAFT_FILE / GIT_REPLACE_REF_BASE
19
+ # would otherwise hide reachable lane commits and print «ok» (cross-family codex R1)
20
+ for v in GIT_ALTERNATE_OBJECT_DIRECTORIES GIT_OBJECT_DIRECTORY GIT_DIR GIT_WORK_TREE GIT_IMPLICIT_WORK_TREE GIT_GRAFT_FILE GIT_INDEX_FILE GIT_NO_REPLACE_OBJECTS GIT_REPLACE_REF_BASE GIT_PREFIX GIT_SHALLOW_FILE GIT_COMMON_DIR GIT_NAMESPACE; do unset "$v"; done
21
+ REPO="."; STRICT=0
22
+ for a in "$@"; do case "$a" in --strict) STRICT=1 ;; *) REPO="$a" ;; esac; done
23
+ IDENT="lane@example.invalid"
24
+ if ! git -C "$REPO" rev-parse --git-dir >/dev/null 2>&1; then
25
+ echo "LANE-TRIPWIRE HARNESS-ERROR: $REPO is not a readable git repo (not «no hits»)"; exit 2
26
+ fi
27
+ hits="$(git -C "$REPO" log --all --format='%h %ad %s' --date=short --author="$IDENT" 2>/dev/null)"; rc=$?
28
+ [ "$rc" -eq 0 ] || { echo "LANE-TRIPWIRE HARNESS-ERROR: git log failed (rc=$rc)"; exit 2; }
29
+ if [ -z "$hits" ]; then echo "LANE-TRIPWIRE ok: 0 commits by $IDENT reachable from any ref"; exit 0; fi
30
+ n="$(printf '%s\n' "$hits" | wc -l | tr -d ' ')"
31
+ echo "LANE-TRIPWIRE WARN: $n commit(s) by the test-lane identity $IDENT are reachable in $(cd "$REPO" && pwd -P):"
32
+ printf '%s\n' "$hits" | sed 's/^/ /'
33
+ echo " → a lane committed into this repo (inherited GIT_DIR / GIT_INDEX_FILE?). Check the branch and index before anything else."
34
+ [ "$STRICT" = 1 ] && exit 1
35
+ exit 0
@@ -46,10 +46,9 @@ ACCEPTED_ABSENT=(
46
46
  # (CLAUDE.local.md §FH 자체개발 자율화: «일반 사용자는 이슈/PR 제안»): shipping it would put an
47
47
  # auto-merging loop into every consumer install. self_evolution_routine.md §3b names these files to
48
48
  # say exactly that; selfcheck resolves their rows as SKIP on a consumer tree.
49
+ # (selfdev_merge_tier.sh and its lane DO ship since #1068 — pr_merge_verified.sh --lease reads the tier.)
49
50
  "scripts/selfdev_loop.sh"
50
- "scripts/selfdev_merge_tier.sh"
51
51
  "scripts/selfdev_queue.py"
52
- "scripts/test_selfdev_merge_tier_lanes.sh"
53
52
  "scripts/test_selfdev_queue_lanes.sh"
54
53
  "scripts/test_selfdev_loop_lanes.sh"
55
54
  # 2026-11-07 — the self-dev loop's ablation nominator and its lanes. Same loop, same scope as above; whether the
@@ -61,6 +60,11 @@ ACCEPTED_ABSENT=(
61
60
  # has no such file and no such convention, so shipping it would ship a tool with nothing to act on.
62
61
  "scripts/lease_line_apply.sh"
63
62
  "scripts/test_lease_line_apply_lanes.sh"
63
+ # 2026-11-11 — shared session ledger (root/child sessions of this hub). Pilot for this hub's thin-root operation;
64
+ # whether consumers get it is an operator decision after the pilot, so not shipped yet.
65
+ "scripts/session_ledger_write.sh"
66
+ "scripts/session_ledger_read.py"
67
+ "scripts/test_session_ledger_lanes.sh"
64
68
  # 2026-11-07 — context-continuity read half (AQ-20261107-10/-12). Governor tools for this hub: the hook reads the
65
69
  # hub's lease-file convention (CLAUDE.local.md «utterance» lines) and its snippet is not shipped either, so
66
70
  # shipping the script alone would hand consumers a hook nothing calls. Ship both together, or neither.
@@ -26,7 +26,8 @@
26
26
  # --rerun run with `bash -c` inside a throwaway detached worktree at --merge. Cwd = that worktree.
27
27
  #
28
28
  # EXIT 0 both halves pass · 1 content mismatch or ② failed · 2 usage (incl. missing --rerun)
29
- # 3 trivial ② refused · 4 instrument/harness error (② silent, worktree not creatable, bad sha)
29
+ # 3 trivial or statically quiet ② refused (`grep -q …` alone — add `&& echo …`) · 4 instrument/harness
30
+ # error (② silent at run time, worktree not creatable, bad sha)
30
31
  #
31
32
  # Labels for ①, per path the branch changed (merge-base(tip, merge^) .. tip, machine-listed):
32
33
  # SAME blob on --merge == blob on --tip (incl. both absent = deletion carried)
@@ -83,6 +84,57 @@ if [ "$_noop" -eq 1 ]; then
83
84
  echo "🟥 --rerun '$RERUN' only echoes / no-ops — refused. Printing is not exercising the change." >&2
84
85
  exit 3
85
86
  fi
87
+ # 🟥 2026-11-09 (verify-incomplete root cause, tracks/_meta/verify_incomplete_root_cause_2026-11-09.md):
88
+ # 7 of 7 non-verified merges in the receipts carried a QUIET ② (`grep -q`, `>/dev/null`, a python -c
89
+ # with no print). Content was intact every time; the silence guard below (rc=0 + no output → rc=4)
90
+ # fired AFTER the merge, so each ended verify-incomplete. Refuse before merging instead, when every
91
+ # segment is statically a silent check. The silence guard stays as it is for what this cannot see.
92
+ # Quoted text is blanked before splitting so a `;` inside `python3 -c "…"` does not split it.
93
+ # 🟥 cross-family R1 (codex, 11 findings): over-refusal is the costly direction (a printing command
94
+ # refused before merging). Fixed: quote blanking is one left-to-right pass (a `"` inside '…' no longer
95
+ # pairs with a later quote) · a lone `&` separates · `>&2` anywhere in a segment means output reaches
96
+ # ② (captured 2>&1) · only fd-less/1/& redirects to /dev/null count · grep options stop at `--` ·
97
+ # python -c is quiet only with no print/stdout/write anywhere. Named residual (fail-open → rc=4 after
98
+ # the merge, guard unchanged): a quoted option (`grep '-q'`), a comment containing «print», a quiet
99
+ # check piped into a printer of nothing (`… | cat`), and any wrapper (`bash -c '…'`).
100
+ _quiet_seg() { # $1 = one segment; rc 0 = prints nothing on success
101
+ local s="$1" w1 w
102
+ case "$s" in *'>&2'*) return 1 ;; esac # stdout sent to stderr — ② captures both
103
+ s="${s##*|}" # judge the last element of a pipeline
104
+ printf '%s' "$s" | grep -Eq '(^|[[:space:]])(1|&)?>[[:space:]]*/dev/null' && return 0
105
+ set -f; set -- $s; set +f; w1="${1:-}"
106
+ case "$w1" in
107
+ :|true|/bin/true|/usr/bin/true|exit|return|test|'['|'[[') return 0 ;;
108
+ grep|egrep|fgrep|rg)
109
+ for w in "$@"; do case "$w" in --) break ;; --quiet|--silent) return 0 ;; --*) : ;; -*q*) return 0 ;; esac; done ;;
110
+ git) for w in "$@"; do case "$w" in --) break ;; -q|--quiet|--is-ancestor) return 0 ;; esac; done
111
+ case " $s " in *" cat-file "*" -e "*) return 0 ;; esac ;; # bare -e only for cat-file (git grep -e prints)
112
+ cmp) for w in "$@"; do [ "$w" = -s ] && return 0; done ;;
113
+ python|python3) for w in "$@"; do [ "$w" = -c ] && { case "$RERUN" in *print*|*stdout*|*write*) return 1 ;; esac; return 0; }; done ;;
114
+ esac
115
+ return 1
116
+ }
117
+ _bl=""; _q=""; _esc=0; _i=0
118
+ while [ "$_i" -lt "${#RERUN}" ]; do
119
+ _c="${RERUN:$_i:1}"; _i=$((_i+1))
120
+ if [ "$_q" = "'" ]; then [ "$_c" = "'" ] && { _q=""; _bl="$_bl'"; }; continue; fi
121
+ if [ "$_q" = '"' ]; then
122
+ if [ "$_esc" -eq 1 ]; then _esc=0; elif [ "$_c" = '\' ]; then _esc=1; elif [ "$_c" = '"' ]; then _q=""; _bl="$_bl\""; fi
123
+ continue; fi
124
+ if [ "$_esc" -eq 1 ]; then _esc=0; _bl="$_bl$_c"; continue; fi
125
+ case "$_c" in '\') _esc=1; _bl="$_bl$_c" ;; "'"|'"') _q="$_c"; _bl="$_bl$_c" ;; *) _bl="$_bl$_c" ;; esac
126
+ done
127
+ _quiet=1; _nseg=0
128
+ while IFS= read -r _seg; do
129
+ _t=$(printf '%s' "$_seg" | tr -d '[:space:]'); [ -z "$_t" ] && continue
130
+ _nseg=$((_nseg+1)); _quiet_seg "$_seg" || { _quiet=0; break; }
131
+ done <<< "$(printf '%s' "$_bl" | sed -E -e 's/&&/;/g' -e 's/[|][|]/;/g' -e 's/([^>&<0-9])&([^>&]|$)/\1;\2/g' | tr ';' '\n')"
132
+ if [ "$_quiet" -eq 1 ] && [ "$_nseg" -gt 0 ]; then
133
+ echo "🟥 --rerun '$RERUN' prints nothing when it passes (every segment is a quiet check) — refused before merging." >&2
134
+ echo " A silent ② reads as an instrument failure (rc=4), so the merge would end verify-incomplete." >&2
135
+ echo " Make it say what passed, e.g. <your check> && echo '<what passed>'" >&2
136
+ exit 3
137
+ fi
86
138
 
87
139
  [ "$PRECHECK" -eq 0 ] || { echo "✅ --rerun accepted (precheck)"; exit 0; }
88
140
 
@@ -21,13 +21,15 @@
21
21
  # merged from another head · not fetchable — never for a refusal or a merge GitHub did not take) one JSON line goes to
22
22
  # ${PMV_RECEIPTS:-<git common dir>/fh-merge-receipts.jsonl} — local, never pushed: pr · head · merge · outcome ·
23
23
  # actor (agent-session:claude-code when CLAUDECODE is set, else human-or-unknown — a human cannot be proven) ·
24
- # lease (the --lease label of the standing approval the caller merges under, else NONE — recorded, not enforced) · rerun.
24
+ # lease (the --lease label of the standing approval the caller merges under, else NONE — recorded; any label other than NONE or a case-insensitive «operator…» prefix is also enforced: the merge needs selfdev_merge_tier.sh TIER=AUTO, see EXIT 7) · rerun.
25
25
  # Why: arXiv:2610.28683 — 27% of merges that passed a «non-author review» gate rested on an agent approving under a
26
26
  # human account; who decided must be on the record, not inferred later (frontier digest 2026-10-23).
27
27
  # EXIT 0 merged + verified · 1 merged but verify FAILED (the merge stands — act on it)
28
28
  # 2 usage (nothing merged) · 3 trivial --rerun refused (nothing merged)
29
29
  # 4 harness error (see message: before or after the merge)
30
30
  # 6 merge accepted but not completed (queue/lag) — NOT verified, nothing claimed
31
+ # 7 lease merge refused: a --lease other than «operator…» and selfdev_merge_tier.sh did not say AUTO, or the tier
32
+ # could not be read (nothing merged)
31
33
  # 5 merge NOT observed (gh failed and GitHub still reports OPEN/CLOSED after bounded re-reads —
32
34
  # an observation, not proof: stale state can outlast the re-reads)
33
35
  # (gh non-zero but GitHub says MERGED → continue to verify; state unreadable → 4, outcome UNKNOWN)
@@ -104,6 +106,60 @@ if [ -n "$EXPECT_HEAD" ] && [ "$HEAD_OID" != "$EXPECT_HEAD" ]; then
104
106
  echo "🟥 PR #$PR head is $HEAD_OID, not the checked $EXPECT_HEAD — not merging" >&2; exit 2
105
107
  fi
106
108
  echo "── PR #$PR head recorded: $HEAD_OID"
109
+ # 1a. no --lease → say so, before the merge (AQ-20261109-5). The receipt still records NONE and the merge still runs:
110
+ # most merges rest on the operator's per-PR answer, which is fine to leave unnamed. What must not stay silent is a merge
111
+ # that rested on a STANDING approval and recorded none — #1063 was merged on the self-dev lease with lease=NONE and the
112
+ # receipt said nothing. Advisory only; never changes rc.
113
+ if [ "$LEASE" = "NONE" ]; then
114
+ echo "⚠️ no --lease: the receipt will record lease=NONE. If this merge rests on a standing approval (the self-dev" >&2
115
+ echo " lease, a session lease), stop and rerun with --lease '<its label>'; if it rests on the operator's answer for" >&2
116
+ echo " THIS PR, NONE is right. Advisory only; merging continues." >&2
117
+ fi
118
+
119
+ # 1c. a lease only covers what the merge tier allows (AQ-20261109-4). The self-dev lease (CLAUDE.local.md 2026-11-04) is
120
+ # grade (가): reversible changes merge on their own, anything gate-shaped waits for the operator. selfdev_loop.sh asks
121
+ # selfdev_merge_tier.sh before calling here; an interactive session merging «under the lease» did not (#1063: TIER=HOLD,
122
+ # merged as (가)). So every --lease is checked against the tier here, before the merge, EXCEPT a label that starts with
123
+ # «operator» — the operator's answer for THIS PR, which is what a HOLD asks for. Default-on, not a list of standing-lease
124
+ # spellings (codex R1: «STANDING», «self-dev», «session lease» each slipped a substring list).
125
+ # The tier reads the RECORDED head through local git (merge-base with origin/main .. $HEAD_OID), not the live PR, so what
126
+ # it judged is what --match-head-commit merges (codex R1: a head swapped during the check). Unreadable → refuse (rc 7).
127
+ # only the literal default skips («--lease none» is a label someone typed — codex R2); «operator…» in any case
128
+ _lease_lc=$(printf '%s' "$LEASE" | tr '[:upper:]' '[:lower:]')
129
+ [ "$LEASE" = "NONE" ] && _lease_lc="__default_none__"
130
+ case "$_lease_lc" in
131
+ __default_none__|operator*) ;;
132
+ *)
133
+ _tier="$(dirname "$PSV")/selfdev_merge_tier.sh"
134
+ _tw=$(mktemp -d "${TMPDIR:-/tmp}/pmv-tier-XXXXXX") || _tw=""
135
+ _tok=0
136
+ # the diff must not depend on the caller's git config (codex R2: diff.ignoreSubmodules · diff.relative hid changes;
137
+ # noprefix / color would break the tier's parser), and the base is the live main, fetched now
138
+ _gd() { git -c core.quotepath=off -c diff.noprefix=false -c diff.mnemonicPrefix=false -c diff.relative=false \
139
+ -c diff.ignoreSubmodules=none diff --no-color --no-ext-diff --no-textconv --no-renames --ignore-submodules=none "$@"; }
140
+ if [ -f "$_tier" ] && [ -n "$_tw" ] && git fetch -q origin main < /dev/null 2>/dev/null \
141
+ && _mb=$(git merge-base origin/main "$HEAD_OID" < /dev/null 2>/dev/null) && [ -n "$_mb" ] \
142
+ && _gd --name-status "$_mb" "$HEAD_OID" < /dev/null > "$_tw/ns" 2>/dev/null \
143
+ && _gd --numstat "$_mb" "$HEAD_OID" < /dev/null > "$_tw/num" 2>/dev/null \
144
+ && _gd "$_mb" "$HEAD_OID" < /dev/null > "$_tw/diff" 2>/dev/null \
145
+ && awk -F'\t' 'NR==FNR { st[$2]=$1; next } { print st[$3] "\t" $3 "\t" $1 "\t" $2 }' "$_tw/ns" "$_tw/num" > "$_tw/files" 2>/dev/null; then
146
+ _tok=1
147
+ fi
148
+ if [ "$_tok" -ne 1 ]; then
149
+ [ -n "$_tw" ] && rm -rf "$_tw"
150
+ echo "🟥 lease «${LEASE}»: the merge tier could not be read for head $HEAD_OID (tier script, merge-base or diff) — not merging" >&2
151
+ exit 7
152
+ fi
153
+ _tout=$(bash "$_tier" --files "$_tw/files" --diff "$_tw/diff" < /dev/null 2>&1); _trc=$?
154
+ rm -rf "$_tw"
155
+ if [ "$_trc" -ne 0 ] || [ "$(printf '%s\n' "$_tout" | tail -1)" != "TIER=AUTO" ]; then
156
+ printf '%s\n' "$_tout" | sed 's/^/ /' >&2
157
+ echo "🟥 lease «${LEASE}» is not the operator's answer for this PR, and selfdev_merge_tier.sh did not say AUTO (rc=$_trc) — not merging." >&2
158
+ echo " Ask the operator for THIS PR, then merge with --lease 'operator: «<their words>» <date>'." >&2
159
+ exit 7
160
+ fi
161
+ echo "── lease «${LEASE}»: selfdev_merge_tier.sh says TIER=AUTO for head $HEAD_OID" ;;
162
+ esac
107
163
 
108
164
  # 1b. coverage advisory — WARNING ONLY (never changes rc, never merges or refuses). post_squash_verify's precheck rejects a
109
165
  # command that is trivially empty; it cannot see a command that is real but never touches this PR's files. Static, pre-merge,
@@ -375,6 +375,67 @@ python3 "$LIB" score ${SCORE_EXTRA[@]+"${SCORE_EXTRA[@]}"} \
375
375
  --reps "$REPS"
376
376
  score_rc=$?
377
377
 
378
+ # State fingerprint (2026-11-11, arXiv:2611.11216 — record only, never read by the scorer above).
379
+ # Two arms can print the same output while leaving their isolated clones in different states. The
380
+ # runner already writes `<arm>_r<n>.treediff.txt` (porcelain lines the arm added); this appends, in
381
+ # the same execution as the verdict, one line per rep: changed-path count + a hash over the treediff
382
+ # and the current bytes of every path it lists. A rep with no treediff file says MISSING — not 0.
383
+ # Appended AFTER score so no verdict row can move; score_rc is untouched.
384
+ {
385
+ echo ""
386
+ echo "## State fingerprint (record only — not scored)"
387
+ echo ""
388
+ while IFS= read -r id; do
389
+ [ -z "$id" ] && continue
390
+ for arm in primary control control_b; do
391
+ [ "$arm" = control_b ] && [ ! -f "$SPEC_DIR/$id.control_b.txt" ] && continue
392
+ r=1
393
+ while [ "$r" -le "$REPS" ]; do
394
+ td="$OUTDIR/$id/${arm}_r${r}.treediff.txt"
395
+ if [ ! -f "$td" ]; then
396
+ echo "state-fingerprint: $id $arm r$r treediff=MISSING"
397
+ elif [ ! -r "$td" ]; then
398
+ echo "state-fingerprint: $id $arm r$r treediff=UNREADABLE"
399
+ else
400
+ n=$(grep -c . "$td" 2>/dev/null); n=${n:-0}
401
+ # A listed path we cannot read as bytes is counted as unhashed and the line says how many,
402
+ # so «same hash» never silently covers it: git-quoted paths (spaces, non-ASCII — not decoded
403
+ # here), rename records («a -> b»), unreadable files, directories holding unreadable files.
404
+ # Directories (?? dir/) are otherwise hashed over their files in sorted order.
405
+ uh=0; body="$(mktemp "${TMPDIR:-/tmp}/fh-sfp.XXXXXX")"; cat "$td" > "$body"
406
+ while IFS= read -r p; do
407
+ f="$OUTDIR/$id/w_${arm}_r${r}/repo/$p"
408
+ case "$p" in
409
+ (\"*|*" -> "*) uh=$((uh + 1)); echo "<unhashed:$p>" >> "$body" ;;
410
+ (*)
411
+ if [ -d "$f" ]; then
412
+ # find output and rc captured apart: a failing find counts the path as unhashed,
413
+ # never as «no unreadable files» (pipefail class-lock lane L12c).
414
+ _bad="$(find "$f" -type f ! -perm -u=r 2>/dev/null)"; _brc=$?
415
+ _all="$(find "$f" -type f 2>/dev/null)"; _arc=$?
416
+ if [ "$_brc" -ne 0 ] || [ "$_arc" -ne 0 ] || [ -n "$_bad" ]; then uh=$((uh + 1)); echo "<unhashed:$p>" >> "$body"
417
+ else
418
+ _sorted="$(printf '%s\n' "$_all" | LC_ALL=C sort)"
419
+ while IFS= read -r g; do
420
+ [ -n "$g" ] || continue
421
+ echo "<f:${g#"$f"}>" >> "$body"
422
+ cat "$g" >> "$body" || { uh=$((uh + 1)); echo "<unhashed:$g>" >> "$body"; }
423
+ done <<< "$_sorted"
424
+ fi
425
+ elif [ -e "$f" ] && [ ! -r "$f" ]; then uh=$((uh + 1)); echo "<unhashed:$p>" >> "$body"
426
+ elif [ -f "$f" ]; then cat "$f" >> "$body"
427
+ else echo "<absent:$p>" >> "$body"; fi ;;
428
+ esac
429
+ done < <(cut -c4- "$td")
430
+ h=$(shasum -a 256 < "$body" | cut -c1-16); rm -f "$body"
431
+ echo "state-fingerprint: $id $arm r$r changed=$n unhashed=$uh sha256=$h"
432
+ fi
433
+ r=$((r + 1))
434
+ done
435
+ done
436
+ done < "$SPEC_DIR/selected_ids.txt"
437
+ } >> "$REPORT_PATH"
438
+
378
439
  if [ -n "$EVIDENCE_DIR" ]; then
379
440
  # The report is part of the evidence: a preserved body set with no verdict beside it forces the
380
441
  # next reader to re-derive what the run concluded.