66import re
77import shlex
88import sys
9+ import unittest
910from pathlib import Path
1011
1112from generate_tool_inventory import ROOT , render_inventory , runtime_routes
1213
1314
1415README_FILES = sorted (ROOT .glob ("README*.md" ))
16+ VERIFICATION_DOC = ROOT / "docs" / "self-evolution.md"
1517STALE_TOOL_PATTERNS = (
1618 re .compile (r"\b26\b[^\n]*(?:tool|工具|ツール|도구)" , re .IGNORECASE ),
1719 re .compile (r"(?:Git|git)[^\n]{0,24}\b15\b[^\n]*(?:tool|工具|ツール|도구)" , re .IGNORECASE ),
1820 re .compile (r"\b15\b[^\n]*(?:Git|git)[^\n]*(?:tool|工具|ツール|도구)" , re .IGNORECASE ),
1921)
22+ STALE_VERIFICATION_CLAIMS = (
23+ "51d0bce" ,
24+ "58 tests" ,
25+ "119 tests" ,
26+ "359378b" ,
27+ )
28+ VERIFICATION_COMMANDS = (
29+ "make check" ,
30+ "make docs-check" ,
31+ "make shell-check" ,
32+ "make lint" ,
33+ "make test" ,
34+ "make benchmark" ,
35+ "git diff --check" ,
36+ )
37+ BENCHMARK_METADATA = (
38+ "benchmarks/multi_party_memory.jsonl" ,
39+ "openkyrozen-learning-benchmark-v1" ,
40+ "deterministic-fixture" ,
41+ "openkyrozen-memory-policy-v1" ,
42+ "fixture_verified" ,
43+ "paired_evidence_status: insufficient" ,
44+ "public_superiority_claim_supported: false" ,
45+ )
2046
2147
2248def _command_blocks (text : str ) -> list [str ]:
@@ -78,6 +104,44 @@ def _check_commands(path: Path, text: str, routes: set[str], targets: set[str])
78104 return errors
79105
80106
107+ def _discovered_test_count () -> int :
108+ suite = unittest .TestLoader ().discover (
109+ str (ROOT / "tests" ), pattern = "test_*.py"
110+ )
111+ return suite .countTestCases ()
112+
113+
114+ def _check_verification_record () -> list [str ]:
115+ if not VERIFICATION_DOC .exists ():
116+ return ["docs/self-evolution.md is missing" ]
117+ text = VERIFICATION_DOC .read_text (encoding = "utf-8" )
118+ errors : list [str ] = []
119+ for claim in STALE_VERIFICATION_CLAIMS :
120+ if claim in text :
121+ errors .append (f"self-evolution.md contains obsolete verification claim '{ claim } '" )
122+
123+ if "historical verification snapshot" not in text .lower ():
124+ errors .append ("self-evolution.md must label its verification as a historical snapshot" )
125+ if not re .search (r"Historical verification snapshot:\s*`[0-9a-f]{40}`" , text ):
126+ errors .append ("self-evolution.md must identify a full historical verification commit" )
127+
128+ test_count = _discovered_test_count ()
129+ expected_test_marker = f"Current repository test count at this snapshot: **{ test_count } unittest cases**"
130+ if expected_test_marker not in text :
131+ errors .append (f"self-evolution.md must record the discovered test count ({ test_count } )" )
132+
133+ for command in VERIFICATION_COMMANDS :
134+ if command not in text :
135+ errors .append (f"self-evolution.md is missing verification command '{ command } '" )
136+ for marker in BENCHMARK_METADATA :
137+ if marker not in text :
138+ errors .append (f"self-evolution.md is missing benchmark metadata '{ marker } '" )
139+ for marker in ("API health/scoping smoke" , "CLI command-loop smoke" ):
140+ if marker not in text :
141+ errors .append (f"self-evolution.md is missing verification evidence '{ marker } '" )
142+ return errors
143+
144+
81145def main () -> int :
82146 expected_inventory = render_inventory ()
83147 import main as agent_main
@@ -92,6 +156,7 @@ def main() -> int:
92156 routes = runtime_routes (__import__ ("server" ))
93157 route_paths = {path for _ , path in routes }
94158 targets = _make_targets ()
159+ errors .extend (_check_verification_record ())
95160 for readme in README_FILES :
96161 text = readme .read_text (encoding = "utf-8" )
97162 for pattern in STALE_TOOL_PATTERNS :
0 commit comments