|
|
@@ -1,9 +1,9 @@
|
|
|
#!/usr/bin/env python3
|
|
|
-"""Fail-closed consistency gates for active status docs vs final closure truth.
|
|
|
+"""Fail-closed consistency gates for active status docs vs current 3-axis truth.
|
|
|
|
|
|
-Activity docs must agree on FINAL_COMMIT, matrix (incl. cocotb), TD built commit,
|
|
|
-bitstream SHA-256, hardware not_run, and physical blockers. Stale tip / fail-matrix
|
|
|
-/ old-bitstream claims must not reappear as current truth.
|
|
|
+Activity docs must assert X/Y/Z, six limits, 450/5000/500, permanent EN, hard
|
|
|
+truncate, and unbound tip-TD/bitstream placeholders. Stale 2-axis/solenoid IO,
|
|
|
+runtime-limit-inert policy, and old bit/commit-as-current claims must not reappear.
|
|
|
"""
|
|
|
|
|
|
from __future__ import annotations
|
|
|
@@ -17,14 +17,11 @@ from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
-FINAL_COMMIT = "da7b05a340a096ccfb4ccf4f656eb3efe6a957e2"
|
|
|
-FINAL_COMMIT_SHORT = "da7b05a"
|
|
|
-TD_BUILT_COMMIT = "8f28660f176e18e97a015e66bdae0ff747e0fc63"
|
|
|
-TD_BUILT_SHORT = "8f28660"
|
|
|
-BITSTREAM_SHA256 = "ce3157c593858c33c36e9805fe477a3955ba6f380b4a04f5f9236d3fbddb376d"
|
|
|
-BITSTREAM_SHORT = "ce3157c5"
|
|
|
-CLOSURE_RUN_ID = "grok45-final-20260805T013238Z"
|
|
|
-MATRIX_RUN_ID = "c43c4201f74517c50bd349fce87f9e0b"
|
|
|
+PENDING_MARKER = "pending final tip TD"
|
|
|
+TRUNCATE_SEMANTICS = "truncate_current_high_pulse_immediately_after_synchronized_limit"
|
|
|
+PRIOR_BIT_SHORT = "45f548ab"
|
|
|
+PRIOR_BIT_COMMIT = "bb515af"
|
|
|
+BASELINE_TIP_SHORT = "cdf9f76"
|
|
|
|
|
|
ACTIVITY_DOCS = (
|
|
|
"README.zh-CN.md",
|
|
|
@@ -33,57 +30,94 @@ ACTIVITY_DOCS = (
|
|
|
"OPEN_QUESTIONS.md",
|
|
|
"PLAN.md",
|
|
|
"docs/TD_USAGE.zh-CN.md",
|
|
|
+ "docs/HARDWARE_TEST_ORDER_WAVEFORMS.zh-CN.md",
|
|
|
)
|
|
|
|
|
|
-# Must appear in every activity doc (full or unambiguous short form).
|
|
|
+# Must appear in every activity doc.
|
|
|
PER_DOC_MARKERS = (
|
|
|
- FINAL_COMMIT_SHORT,
|
|
|
- TD_BUILT_SHORT,
|
|
|
- BITSTREAM_SHORT,
|
|
|
+ PENDING_MARKER,
|
|
|
+ PRIOR_BIT_SHORT,
|
|
|
+ PRIOR_BIT_COMMIT,
|
|
|
)
|
|
|
|
|
|
# Must appear somewhere in the activity-doc corpus.
|
|
|
CORPUS_REQUIRED = (
|
|
|
- FINAL_COMMIT,
|
|
|
- TD_BUILT_COMMIT,
|
|
|
- BITSTREAM_SHA256,
|
|
|
- CLOSURE_RUN_ID,
|
|
|
- MATRIX_RUN_ID,
|
|
|
- "cocotb",
|
|
|
- "intake",
|
|
|
- "A11",
|
|
|
- "CON124",
|
|
|
+ PENDING_MARKER,
|
|
|
+ TRUNCATE_SEMANTICS,
|
|
|
+ "permanent_high",
|
|
|
+ "450",
|
|
|
+ "5000",
|
|
|
+ "500",
|
|
|
+ "CON104",
|
|
|
+ "CON105",
|
|
|
+ "CON106",
|
|
|
+ "CON120",
|
|
|
+ "CON12",
|
|
|
+ "CON129",
|
|
|
+ BASELINE_TIP_SHORT,
|
|
|
+ PRIOR_BIT_SHORT,
|
|
|
+ PRIOR_BIT_COMMIT,
|
|
|
)
|
|
|
|
|
|
-# Superseded identifiers that must not be presented as current FINAL/tip truth.
|
|
|
+# Superseded identifiers / policies that must not be presented as current tip truth.
|
|
|
STALE_AS_CURRENT = (
|
|
|
(
|
|
|
re.compile(
|
|
|
- r"(?i)(?:FINAL_COMMIT|文档对齐 tip|worktree 起点 tip|Full matrix @ tip)\s*[|::]*\s*`?f82c41e"
|
|
|
+ r"(?i)FINAL_COMMIT\s*[|::=]*\s*`?da7b05a[0-9a-f]*`?"
|
|
|
),
|
|
|
- "stale tip f82c41e presented as current FINAL/tip",
|
|
|
+ "stale 2-axis FINAL_COMMIT da7b05a presented as current",
|
|
|
),
|
|
|
(
|
|
|
- re.compile(r"(?i)最近矩阵绑定 commit\s*[|::]*\s*`?6f32493"),
|
|
|
- "stale fail-matrix 6f32493 presented as current bind",
|
|
|
+ re.compile(
|
|
|
+ r"(?i)Bitstream SHA-256\s*[|::=]*\s*`?ce3157c5[0-9a-f]*`?"
|
|
|
+ ),
|
|
|
+ "stale bitstream ce3157c5 presented as current",
|
|
|
),
|
|
|
(
|
|
|
re.compile(
|
|
|
- r"(?i)(?:TD built commit|最近 TD pass|TD \+ bitstream)[^\n]{0,80}`?ead5a3e"
|
|
|
+ r"(?i)TD built commit\s*[|::=]*\s*`?8f28660[0-9a-f]*`?"
|
|
|
),
|
|
|
- "stale TD ead5a3e presented as current TD evidence",
|
|
|
+ "stale TD 8f28660 presented as current",
|
|
|
),
|
|
|
(
|
|
|
- re.compile(r"(?i)bitstream SHA-256\s*`?a7b5c119"),
|
|
|
- "stale bitstream a7b5c119 presented as current",
|
|
|
+ re.compile(
|
|
|
+ r"(?i)(?:(?:as|@)\s*tip|tip\s+(?:bitstream|bit|TD|证据)|"
|
|
|
+ r"当前\s*(?:tip\s*)?(?:bitstream|位流|闭包证据))\s*[`:]?\s*45f548ab"
|
|
|
+ ),
|
|
|
+ "prior bit 45f548ab presented as tip/current",
|
|
|
),
|
|
|
(
|
|
|
- re.compile(r"(?i)cocotb[^\n]{0,40}\*\*fail\*\*"),
|
|
|
- "cocotb still marked fail in activity docs",
|
|
|
+ re.compile(
|
|
|
+ r"(?i)(?:runtime\s+limits?\s+are\s+inert|"
|
|
|
+ r"(?<!not\s)(?<!non-)runtime\s+limit\s+inert|"
|
|
|
+ r"限位对普通\s*jog\s*\*?惰性\*?|"
|
|
|
+ r"完成后限位对普通 jog\s*\*?惰性\*?)"
|
|
|
+ ),
|
|
|
+ "runtime limit inert presented as current policy",
|
|
|
),
|
|
|
(
|
|
|
- re.compile(r"(?i)Full matrix @ `?6f32493`?[^\n]{0,40}\*\*fail\*\*"),
|
|
|
- "full matrix still marked fail at stale commit",
|
|
|
+ re.compile(
|
|
|
+ r"(?i)(?:进风(?:门)?默认\*?电磁铁\*?|intake_solenoid_out\s*[::].*\bP2\b|"
|
|
|
+ r"偏移\s*8\s*进风门\s*\|\s*默认\*\*电磁铁\*\*)"
|
|
|
+ ),
|
|
|
+ "solenoid intake presented as active product path",
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ re.compile(
|
|
|
+ r"(?i)(?:X\s*限位[^\n]{0,40}CON68|Y\s*限位[^\n]{0,40}CON34|"
|
|
|
+ r"CON68\.3\s*/\s*M6|CON34\.3\s*/\s*F9|"
|
|
|
+ r"X\s*电机[^\n]{0,20}CON139|Y\s*电机[^\n]{0,20}CON138|"
|
|
|
+ r"进风电磁铁[^\n]{0,20}CON141)"
|
|
|
+ ),
|
|
|
+ "obsolete CON68/CON34/CON138-141 mapping presented as active probe",
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ re.compile(r"(?i)(?:FINAL_COMMIT|文档对齐 tip|worktree 起点 tip|Full matrix @ tip)\s*[|::]*\s*`?f82c41e"),
|
|
|
+ "stale tip f82c41e presented as current FINAL/tip",
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ re.compile(r"(?i)bitstream SHA-256\s*`?a7b5c119"),
|
|
|
+ "stale bitstream a7b5c119 presented as current",
|
|
|
),
|
|
|
)
|
|
|
|
|
|
@@ -103,7 +137,7 @@ class ActivityDocsTruthTests(unittest.TestCase):
|
|
|
missing = [rel for rel in ACTIVITY_DOCS if not (ROOT / rel).is_file()]
|
|
|
self.assertEqual(missing, [], f"missing activity docs: {missing}")
|
|
|
|
|
|
- def test_each_activity_doc_carries_final_td_bitstream_markers(self) -> None:
|
|
|
+ def test_each_activity_doc_carries_pending_and_prior_bit_markers(self) -> None:
|
|
|
for rel in ACTIVITY_DOCS:
|
|
|
text = _read(rel)
|
|
|
for marker in PER_DOC_MARKERS:
|
|
|
@@ -113,32 +147,25 @@ class ActivityDocsTruthTests(unittest.TestCase):
|
|
|
f"{rel} missing required marker {marker!r}",
|
|
|
)
|
|
|
|
|
|
- def test_activity_docs_agree_on_closure_corpus_fields(self) -> None:
|
|
|
+ def test_activity_docs_agree_on_three_axis_corpus(self) -> None:
|
|
|
corpus = "\n".join(_read(rel) for rel in ACTIVITY_DOCS)
|
|
|
for marker in CORPUS_REQUIRED:
|
|
|
self.assertIn(marker, corpus, f"activity corpus missing {marker!r}")
|
|
|
|
|
|
- # Matrix / cocotb / hardware / blockers
|
|
|
- self.assertRegex(corpus, r"(?i)cocotb[^\n]{0,80}pass")
|
|
|
- self.assertRegex(corpus, r"(?i)(?:Full matrix|全矩阵)[^\n]{0,80}pass")
|
|
|
+ self.assertRegex(corpus, r"(?i)(?:X\s*/\s*Y\s*/\s*Z|三轴)")
|
|
|
+ self.assertRegex(corpus, r"(?i)(?:六限位|six limits)")
|
|
|
+ self.assertRegex(corpus, r"(?i)(?:硬截断|立即截断|hard truncate)")
|
|
|
self.assertRegex(corpus, r"(?i)(?:Hardware|硬件)[^\n]{0,80}(?:NOT RUN|not_run)")
|
|
|
- self.assertRegex(corpus, r"(?i)solenoid")
|
|
|
- self.assertRegex(corpus, r"(?i)(?:silkscreen|丝印)")
|
|
|
- self.assertRegex(corpus, r"A11")
|
|
|
- self.assertRegex(corpus, r"CON124")
|
|
|
-
|
|
|
- # Cross-doc agreement: every doc that mentions FINAL_COMMIT uses the same hash.
|
|
|
- for rel in ACTIVITY_DOCS:
|
|
|
- text = _read(rel)
|
|
|
- if "FINAL_COMMIT" in text or "da7b05a" in text:
|
|
|
- self.assertIn(FINAL_COMMIT_SHORT, text)
|
|
|
- if re.search(r"da7b05a[0-9a-f]*", text):
|
|
|
- matches = set(re.findall(r"da7b05a[0-9a-f]*", text))
|
|
|
- for match in matches:
|
|
|
- self.assertTrue(
|
|
|
- FINAL_COMMIT.startswith(match),
|
|
|
- f"{rel} has unexpected commit token {match!r}",
|
|
|
- )
|
|
|
+ self.assertRegex(
|
|
|
+ corpus,
|
|
|
+ r"(?i)45f548ab[^\n]{0,80}bb515af|bb515af[^\n]{0,80}45f548ab",
|
|
|
+ )
|
|
|
+ # Active mapping must include 3-axis connectors somewhere.
|
|
|
+ self.assertRegex(corpus, r"CON104")
|
|
|
+ self.assertRegex(corpus, r"CON105")
|
|
|
+ self.assertRegex(corpus, r"CON106")
|
|
|
+ self.assertRegex(corpus, r"CON120")
|
|
|
+ self.assertRegex(corpus, r"CON129")
|
|
|
|
|
|
def test_activity_docs_reject_stale_current_claims(self) -> None:
|
|
|
for rel in ACTIVITY_DOCS:
|
|
|
@@ -149,6 +176,27 @@ class ActivityDocsTruthTests(unittest.TestCase):
|
|
|
f"{rel}: {message}",
|
|
|
)
|
|
|
|
|
|
+ def test_obsolete_io_mentions_are_negated(self) -> None:
|
|
|
+ """If obsolete connectors appear, they must be clearly non-active."""
|
|
|
+ obsolete = ("CON68", "CON34", "CON138", "CON139", "CON140", "CON141", "solenoid", "电磁铁")
|
|
|
+ negate = re.compile(
|
|
|
+ r"(?i)(?:不是|禁止|无|not\b|historical|归档|退役|obsolete|非活动|not\s+active|"
|
|
|
+ r"已迁|作废|superseded|forbid)"
|
|
|
+ )
|
|
|
+ for rel in ACTIVITY_DOCS:
|
|
|
+ text = _read(rel)
|
|
|
+ for token in obsolete:
|
|
|
+ if token.lower() not in text.lower() and token not in text:
|
|
|
+ continue
|
|
|
+ # Allow token only in sentences/lines that negate active use.
|
|
|
+ for line in text.splitlines():
|
|
|
+ if token.lower() not in line.lower() and token not in line:
|
|
|
+ continue
|
|
|
+ self.assertIsNotNone(
|
|
|
+ negate.search(line),
|
|
|
+ f"{rel}: obsolete token {token!r} on non-negated line: {line!r}",
|
|
|
+ )
|
|
|
+
|
|
|
def test_root_runtime_residue_not_tracked_or_present(self) -> None:
|
|
|
for name in ROOT_RESIDUE:
|
|
|
path = ROOT / name
|
|
|
@@ -163,10 +211,14 @@ class ActivityDocsTruthTests(unittest.TestCase):
|
|
|
):
|
|
|
self.assertIn(token, ignored, f".gitignore missing {token!r}")
|
|
|
|
|
|
- # Migrated historical probe must exist; active root copy must not.
|
|
|
hist = ROOT / "docs/historical/evidence-batch-summary-linux-continue-20260804T155114Z.txt"
|
|
|
self.assertTrue(hist.is_file(), "expected migrated evidence-batch summary")
|
|
|
|
|
|
+ hist_readme = _read("docs/historical/README.md")
|
|
|
+ self.assertIn("pending final tip TD", hist_readme)
|
|
|
+ self.assertIn("2-axis", hist_readme.lower() + hist_readme)
|
|
|
+ self.assertRegex(hist_readme, r"(?i)not.*old solenoid|not.*solenoid/2-axis|不是.*solenoid|不是.*电磁铁|Root activity docs are \*\*not\*\*")
|
|
|
+
|
|
|
def test_cleanup_runtime_residue_helper_removes_root_probes(self) -> None:
|
|
|
script = ROOT / "tools/cleanup_runtime_residue.py"
|
|
|
self.assertTrue(script.is_file())
|
|
|
@@ -180,7 +232,6 @@ class ActivityDocsTruthTests(unittest.TestCase):
|
|
|
(fake_root / ".run_id_linux").write_text("run\n", encoding="utf-8")
|
|
|
(fake_root / "evidence-batch-summary.txt").write_text("old\n", encoding="utf-8")
|
|
|
(fake_root / "td_20260804_probe.log").write_text("log\n", encoding="utf-8")
|
|
|
- # Nested path must not be deleted.
|
|
|
nested = fake_root / "runs" / "td_20260804_probe.log"
|
|
|
nested.parent.mkdir()
|
|
|
nested.write_text("keep\n", encoding="utf-8")
|