Преглед на файлове

fix(formal): read SBY PASS marker for complete cover-hit evidence

logfile.txt truncates after six covers ('and N further traces'); include PASS so dispatcher 10/10 cover hits are fail-closed honest.

Co-authored-by: Cursor <cursoragent@cursor.com>
root преди 3 месеца
родител
ревизия
84b2c28f74
променени са 2 файла, в които са добавени 47 реда и са изтрити 0 реда
  1. 42 0
      tests/unit/test_formal_receipt_honesty.py
  2. 5 0
      tools/prod2u_p4_harness.py

+ 42 - 0
tests/unit/test_formal_receipt_honesty.py

@@ -183,6 +183,48 @@ class FormalReceiptHonestyTests(unittest.TestCase):
             self.assertNotIn("formal_cover_hits_incomplete", joined)
             self.assertNotIn("formal_cover_hit_set_mismatch", joined)
 
+    def test_pass_marker_supplies_covers_truncated_from_logfile(self) -> None:
+        """SBY logfile may say 'and N further traces'; PASS holds the full set."""
+        compiled_ids = [
+            f"dut._witness_.check_cover_{index}" for index in range(10)
+        ]
+        # Truncated logfile summary (first 6 only), matching real SBY behavior.
+        truncated_log = "\n".join(
+            [
+                (
+                    "SBY summary:   reached cover statement "
+                    f"{cover_id} at formal.v:10.1-10.2 step 4"
+                )
+                for cover_id in compiled_ids[:6]
+            ]
+            + ["SBY summary: and 4 further traces"]
+        )
+        pass_body = "\n".join(
+            f"  reached cover statement {cover_id} at formal.v:10.1-10.2 step 4"
+            for cover_id in compiled_ids
+        )
+        with tempfile.TemporaryDirectory() as tmpdir:
+            workdir = _minimal_workdir(
+                Path(tmpdir),
+                status_raw="PASS 0 0",
+                log_text=truncated_log,
+                cover_ids=[f"cover_{i}" for i in range(10)],
+                trace=True,
+                pass_marker=True,
+            )
+            (workdir / "PASS").write_text(pass_body + "\n", encoding="utf-8")
+            task = formal_task_evidence(
+                name="cover",
+                mode="cover",
+                workdir=workdir,
+                configured_engines=["smtbmc boolector"],
+                returncode=0,
+            )
+            self.assertEqual(task["cover_hit_ids"], sorted(compiled_ids))
+            self.assertEqual(len(task["cover_hit_ids"]), 10)
+            joined = " ".join(task["evidence_failures"])
+            self.assertNotIn("formal_cover_hits_incomplete", joined)
+
     def test_fail_2_1_cover_incomplete_fails(self) -> None:
         cover_ids = [f"dut.cover_{index}" for index in range(4)]
         log_text = "\n".join(

+ 5 - 0
tools/prod2u_p4_harness.py

@@ -1158,6 +1158,11 @@ def formal_workdir_log_texts(workdir: Path) -> list[str]:
     logfile = workdir / "logfile.txt"
     if logfile.is_file():
         texts.append(logfile.read_text(encoding="utf-8", errors="replace"))
+    # SBY truncates cover hits in logfile.txt ("and N further traces");
+    # the PASS marker holds the complete cover-statement summary.
+    pass_marker = workdir / "PASS"
+    if pass_marker.is_file():
+        texts.append(pass_marker.read_text(encoding="utf-8", errors="replace"))
     if workdir.is_dir():
         for engine_log in sorted(workdir.glob("engine_*/logfile.txt")):
             texts.append(engine_log.read_text(encoding="utf-8", errors="replace"))