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

fix(formal): land Round-12 props and honest cover-hit parse

Promote lingering/gate-hold formal targets, parse SBY-prefixed cover summary
lines so PASS covers are not fail_evidence, and keep FAIL→PASS honesty tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
root преди 3 месеца
родител
ревизия
8403e02041

+ 3 - 7
config/prod2u_p4_verification_targets_v1.json

@@ -134,18 +134,14 @@
       {
         "name": "command_startup_commit",
         "tasks": ["bmc", "cover"]
-      }
-    ],
-    "formal_blocked": [
+      },
       {
         "name": "door_axis_source_limit_lingering",
-        "tasks": ["bmc", "cover"],
-        "blocked_reason": "awaiting door_axis_controller source-limit snap RTL (Round-12 RTL agent)"
+        "tasks": ["bmc", "cover"]
       },
       {
         "name": "runtime_step_gate_hold",
-        "tasks": ["bmc", "cover"],
-        "blocked_reason": "awaiting prod2u_runtime_step_limit_gate hold-until-engine-low RTL (Round-12 RTL agent)"
+        "tasks": ["bmc", "cover"]
       }
     ]
   }

+ 42 - 12
tests/formal/door_axis_request_limit_race_formal.v

@@ -1,4 +1,4 @@
-// DUT-connected: single-limit position snap precedes same-cycle host replan.
+// DUT-connected: accepted one-shot limit snap precedes same-cycle host replan.
 // Bounded BMC (scaled params). Not an unbounded proof.
 module door_axis_request_limit_race_formal (
     input wire clk,
@@ -11,6 +11,8 @@ module door_axis_request_limit_race_formal (
 );
     localparam integer MAX_CAL = 8;
     localparam [2:0] ST_WAIT_REPLAN = 3'd5;
+    localparam [2:0] ST_MOVE_OPEN = 3'd3;
+    localparam [2:0] ST_MOVE_CLOSE = 3'd4;
 
     wire dut_rst_n = rst_n;
     wire planner_req;
@@ -34,12 +36,30 @@ module door_axis_request_limit_race_formal (
     wire faulted;
     wire terminal;
 
-    // Hard-gate STEP on active single limit (matches runtime external gate).
     wire gated_step = step & ~open_limit & ~close_limit;
     reg prev_gated;
     wire gated_step_rise = gated_step & ~prev_gated;
 
     reg [1:0] reset_cycles;
+    // Mirror DUT one-shot arming (no hierarchical probes — Yosys formal).
+    reg open_limit_armed;
+    reg close_limit_armed;
+    wire moving = status_flags[3];
+    wire in_calibration = (status_state == 3'd0) || (status_state == 3'd1);
+    wire departing_close_source =
+        calibrated && !in_calibration &&
+        ((status_state == ST_MOVE_OPEN) || (moving && !dir_close));
+    wire departing_open_source =
+        calibrated && !in_calibration &&
+        ((status_state == ST_MOVE_CLOSE) || (moving && dir_close));
+    wire open_assert_event = open_limit && open_limit_armed;
+    wire close_assert_event = close_limit && close_limit_armed;
+    wire close_snap_accept =
+        calibrated && !in_calibration &&
+        close_assert_event && !departing_close_source;
+    wire open_snap_accept =
+        calibrated && !in_calibration &&
+        open_assert_event && !departing_open_source;
 
     door_axis_controller #(
         .AXIS_ID(0),
@@ -75,6 +95,8 @@ module door_axis_request_limit_race_formal (
     initial begin
         reset_cycles = 2'd0;
         prev_gated = 1'b0;
+        open_limit_armed = 1'b1;
+        close_limit_armed = 1'b1;
         planner_done = 1'b0;
         planner_done_axis = 2'd0;
         planner_done_percent = 8'd0;
@@ -108,22 +130,30 @@ module door_axis_request_limit_race_formal (
 
         if (!dut_rst_n) begin
             prev_gated <= 1'b0;
+            open_limit_armed <= 1'b1;
+            close_limit_armed <= 1'b1;
         end else begin
             prev_gated <= gated_step;
+            if (!open_limit)
+                open_limit_armed <= 1'b1;
+            else if (open_assert_event)
+                open_limit_armed <= 1'b0;
+            if (!close_limit)
+                close_limit_armed <= 1'b1;
+            else if (close_assert_event)
+                close_limit_armed <= 1'b0;
 
-            // NBA-safe: check one cycle after limit/request are observed.
+            // NBA-safe: one cycle after accepted snap event.
             if ($past(dut_rst_n) && $past(calibrated) && !$past(faulted) &&
-                $past(close_limit) && !$past(open_limit))
+                $past(close_snap_accept))
                 assert (status_current == status_travel);
 
             if ($past(dut_rst_n) && $past(calibrated) && !$past(faulted) &&
-                $past(open_limit) && !$past(close_limit))
+                $past(open_snap_accept))
                 assert (status_current == 13'd0);
 
-            // After same-cycle mid request + single limit: position snapped.
-            // State may already leave WAIT_REPLAN into planner/move next cycle.
             if ($past(dut_rst_n) && $past(calibrated) && !$past(faulted) &&
-                $past(request_valid) && $past(close_limit) && !$past(open_limit) &&
+                $past(request_valid) && $past(close_snap_accept) &&
                 ($past(requested_percent_in) > 8'd0) &&
                 ($past(requested_percent_in) < 8'd100)) begin
                 assert (status_current == status_travel);
@@ -133,7 +163,7 @@ module door_axis_request_limit_race_formal (
             end
 
             if ($past(dut_rst_n) && $past(calibrated) && !$past(faulted) &&
-                $past(request_valid) && $past(open_limit) && !$past(close_limit) &&
+                $past(request_valid) && $past(open_snap_accept) &&
                 ($past(requested_percent_in) > 8'd0) &&
                 ($past(requested_percent_in) < 8'd100)) begin
                 assert (status_current == 13'd0);
@@ -142,10 +172,10 @@ module door_axis_request_limit_race_formal (
                         (status_state == 3'd2));
             end
 
-            cover (calibrated && request_valid && close_limit && !open_limit);
-            cover (calibrated && request_valid && open_limit && !close_limit);
+            cover (calibrated && request_valid && close_snap_accept);
+            cover (calibrated && request_valid && open_snap_accept);
             cover (calibrated && (status_state == ST_WAIT_REPLAN) &&
-                   close_limit && (status_current == status_travel));
+                   close_snap_accept && (status_current == status_travel));
         end
     end
 endmodule

+ 13 - 4
tests/formal/door_axis_source_limit_lingering.sby

@@ -1,14 +1,23 @@
+[tasks]
+bmc
+cover
+
 [options]
-# BLOCKED: acceptance gate disabled until door_axis_controller snap-event RTL lands.
-mode bmc
-depth 32
+bmc: mode bmc
+bmc: depth 48
+cover: mode cover
+cover: depth 48
 
 [engines]
-smtbmc
+smtbmc z3
 
 [script]
+read_verilog -formal door_axis_controller.v
 read_verilog -formal door_axis_source_limit_lingering_formal.v
+proc
+setundef -zero
 prep -top door_axis_source_limit_lingering_formal
 
 [files]
+../../src/modules/door_axis_controller.v
 door_axis_source_limit_lingering_formal.v

+ 190 - 4
tests/formal/door_axis_source_limit_lingering_formal.v

@@ -1,9 +1,195 @@
-// BLOCKED Round-12 stub: requires door_axis_controller source-limit snap RTL.
-// Do not treat as acceptance evidence until RTL agent lands and this shell binds DUT.
+// DUT-connected: consumed source-limit must not overwrite gated_step_rise ±1.
+// Instantiates door_axis_controller. Bounded BMC — not an unbounded proof.
 `timescale 1ns/1ps
 
-module door_axis_source_limit_lingering_formal;
+module door_axis_source_limit_lingering_formal (
+    input wire clk,
+    input wire rst_n,
+    input wire tick_500us,
+    input wire request_valid,
+    input wire [7:0] requested_percent_in,
+    input wire open_limit,
+    input wire close_limit,
+    input wire force_rise
+);
+    localparam integer MAX_CAL = 8;
+    localparam [2:0] ST_MOVE_OPEN = 3'd3;
+    localparam [2:0] ST_MOVE_CLOSE = 3'd4;
+
+    wire dut_rst_n = rst_n;
+    wire planner_req;
+    wire [7:0] planner_percent;
+    wire [12:0] planner_travel;
+    reg planner_done;
+    reg [1:0] planner_done_axis;
+    reg [7:0] planner_done_percent;
+    reg [12:0] planner_result;
+
+    wire step;
+    wire dir_close;
+    wire [2:0] status_state;
+    wire [7:0] status_flags;
+    wire [7:0] status_requested_percent;
+    wire [12:0] status_current;
+    wire [12:0] status_target;
+    wire [12:0] status_travel;
+    wire [7:0] status_fault_code;
+    wire calibrated;
+    wire faulted;
+    wire terminal;
+
+    wire selected_limit = dir_close ? close_limit : open_limit;
+    wire gated_step = step & ~selected_limit;
+    reg prev_gated;
+    wire gated_step_rise = force_rise & gated_step & ~prev_gated;
+
+    reg [1:0] reset_cycles;
+    reg past_valid;
+    reg [2:0] linger_rises;
+    // Next-cycle checkers avoid same-edge combo/NBA sampling races on status_current.
+    reg pending_dec;
+    reg pending_inc;
+    reg [12:0] pos_before;
+
+    door_axis_controller #(
+        .AXIS_ID(0),
+        .MAX_CAL_STEPS(MAX_CAL),
+        .MIN_TRAVEL(2),
+        .ENDPOINT_GUARD_EXTRA(4),
+        .DIR_SETUP_TICKS(1),
+        .PERCENT_MAX(100)
+    ) dut (
+        .clk(clk), .rst_n(dut_rst_n),
+        .open_limit(open_limit), .close_limit(close_limit),
+        .limit_sync_valid(1'b1),
+        .gated_step(gated_step), .gated_step_rise(gated_step_rise),
+        .tick_500us(tick_500us),
+        .request_valid(request_valid),
+        .requested_percent_in(requested_percent_in),
+        .watchdog_stop(1'b0),
+        .planner_req(planner_req),
+        .planner_percent(planner_percent),
+        .planner_travel(planner_travel),
+        .planner_done(planner_done),
+        .planner_done_axis(planner_done_axis),
+        .planner_done_percent(planner_done_percent),
+        .planner_result(planner_result),
+        .step(step), .dir_close(dir_close),
+        .status_state(status_state), .status_flags(status_flags),
+        .status_requested_percent(status_requested_percent),
+        .status_current(status_current), .status_target(status_target),
+        .status_travel(status_travel), .status_fault_code(status_fault_code),
+        .calibrated(calibrated), .faulted(faulted), .terminal(terminal)
+    );
+
     initial begin
-        $fatal(1, "door_axis_source_limit_lingering_formal blocked until RTL");
+        reset_cycles = 2'd0;
+        prev_gated = 1'b0;
+        past_valid = 1'b0;
+        linger_rises = 3'd0;
+        pending_dec = 1'b0;
+        pending_inc = 1'b0;
+        pos_before = 13'd0;
+        planner_done = 1'b0;
+        planner_done_axis = 2'd0;
+        planner_done_percent = 8'd0;
+        planner_result = 13'd0;
+    end
+
+    always @(posedge clk) begin
+        assume (rst_n == 1'b0 || rst_n == 1'b1);
+        assume (tick_500us == 1'b0 || tick_500us == 1'b1);
+        assume (request_valid == 1'b0 || request_valid == 1'b1);
+        assume (open_limit == 1'b0 || open_limit == 1'b1);
+        assume (close_limit == 1'b0 || close_limit == 1'b1);
+        assume (force_rise == 1'b0 || force_rise == 1'b1);
+        assume (requested_percent_in <= 8'd100);
+        assume (!(tick_500us && $past(tick_500us)));
+        assume (!(open_limit && close_limit));
+
+        if ($initstate || reset_cycles < 2) begin
+            assume (!dut_rst_n);
+            reset_cycles <= reset_cycles + 1'b1;
+        end else begin
+            assume (dut_rst_n);
+        end
+
+        planner_done <= 1'b0;
+        if (planner_req) begin
+            planner_done <= 1'b1;
+            planner_done_axis <= 2'd0;
+            planner_done_percent <= planner_percent;
+            planner_result <= (planner_travel > 13'd2) ? (planner_travel >> 1) : 13'd1;
+        end
+
+        if (!dut_rst_n) begin
+            prev_gated <= 1'b0;
+            past_valid <= 1'b0;
+            linger_rises <= 3'd0;
+            pending_dec <= 1'b0;
+            pending_inc <= 1'b0;
+            pos_before <= 13'd0;
+        end else begin
+            prev_gated <= gated_step;
+            past_valid <= 1'b1;
+            pending_dec <= 1'b0;
+            pending_inc <= 1'b0;
+
+            // Arm next-cycle check when a consumed source-limit linger rise occurs.
+            if (past_valid && gated_step_rise && calibrated && !faulted &&
+                (status_state == ST_MOVE_OPEN) &&
+                ($past(status_state) == ST_MOVE_OPEN) &&
+                close_limit && $past(close_limit) &&
+                !open_limit && !$past(open_limit) &&
+                !dir_close && !$past(dir_close) &&
+                ($past(status_current) > 13'd0) &&
+                (status_travel >= 13'd2) &&
+                !request_valid && !$past(request_valid)) begin
+                pending_dec <= 1'b1;
+                pos_before <= $past(status_current);
+            end
+
+            if (past_valid && gated_step_rise && calibrated && !faulted &&
+                (status_state == ST_MOVE_CLOSE) &&
+                ($past(status_state) == ST_MOVE_CLOSE) &&
+                open_limit && $past(open_limit) &&
+                !close_limit && !$past(close_limit) &&
+                dir_close && $past(dir_close) &&
+                ($past(status_current) < status_travel) &&
+                (status_travel >= 13'd2) &&
+                !request_valid && !$past(request_valid)) begin
+                pending_inc <= 1'b1;
+                pos_before <= $past(status_current);
+            end
+
+            // After the rise edge settles, coordinate must have moved by exactly 1.
+            // Keep the linger context on the check cycle (source still high, no target).
+            if ($past(pending_dec) && !faulted &&
+                (status_state == ST_MOVE_OPEN) && close_limit && !open_limit)
+                assert (status_current == ($past(pos_before) - 13'd1));
+            if ($past(pending_inc) && !faulted &&
+                (status_state == ST_MOVE_CLOSE) && open_limit && !close_limit)
+                assert (status_current == ($past(pos_before) + 13'd1));
+
+            if ($past(pending_dec) && (status_state == ST_MOVE_OPEN) &&
+                close_limit && !open_limit &&
+                (status_current == ($past(pos_before) - 13'd1)) &&
+                (linger_rises < 3'd7))
+                linger_rises <= linger_rises + 1'b1;
+            if ($past(pending_inc) && (status_state == ST_MOVE_CLOSE) &&
+                open_limit && !close_limit &&
+                (status_current == ($past(pos_before) + 13'd1)) &&
+                (linger_rises < 3'd7))
+                linger_rises <= linger_rises + 1'b1;
+
+            cover ($past(pending_dec) && (status_state == ST_MOVE_OPEN) &&
+                   close_limit && !open_limit &&
+                   (status_current == ($past(pos_before) - 13'd1)));
+            cover ($past(pending_inc) && (status_state == ST_MOVE_CLOSE) &&
+                   open_limit && !close_limit &&
+                   (status_current == ($past(pos_before) + 13'd1)));
+            cover (calibrated && (linger_rises >= 3'd2) && !close_limit && !open_limit &&
+                   (status_current != 13'd0) && (status_current != status_travel));
+        end
     end
 endmodule

+ 5 - 2
tests/formal/door_motion_status_snapshot_formal.v

@@ -83,10 +83,12 @@ module door_motion_status_snapshot_formal (
         assume (status_capture == 1'b0 || status_capture == 1'b1);
         assume (tx_start == 1'b0 || tx_start == 1'b1);
         assume (byte_ready == 1'b0 || byte_ready == 1'b1);
+        // Allow OOB addr=31 for cover/assert; TX path still binds to payload_addr.
         assume (status_rd_addr <= 8'd31);
         assume (!(tx_busy && tx_start));
         assume (!(status_capture && tx_start));
-        if (tx_busy)
+        // Only force addr==payload while TX is actively streaming payload bytes.
+        if (tx_busy && (tx.state == 4'd7))
             assume (status_rd_addr == payload_addr);
 
         if ($initstate || reset_cycles < 2) begin
@@ -126,7 +128,8 @@ module door_motion_status_snapshot_formal (
 
             cover (settled && (status_rd_addr == 8'd0));
             cover (settled && (status_rd_addr == 8'd30));
-            cover (status_rd_addr >= 8'd31);
+            // OOB probe: require idle TX so payload_addr binding cannot exclude addr=31.
+            cover (dut_rst_n && !tx_busy && (status_rd_addr == 8'd31));
             // TX payload-phase cover is depth-expensive; BMC asserts byte_data match.
             cover (tx_busy);
         end

+ 13 - 4
tests/formal/runtime_step_gate_hold.sby

@@ -1,14 +1,23 @@
+[tasks]
+bmc
+cover
+
 [options]
-# BLOCKED: acceptance gate disabled until prod2u_runtime_step_limit_gate hold RTL lands.
-mode bmc
-depth 16
+bmc: mode bmc
+bmc: depth 32
+cover: mode cover
+cover: depth 24
 
 [engines]
-smtbmc
+smtbmc z3
 
 [script]
+read_verilog -formal prod2u_runtime_step_limit_gate.v
 read_verilog -formal runtime_step_gate_hold_formal.v
+proc
+setundef -zero
 prep -top runtime_step_gate_hold_formal
 
 [files]
+../../src/modules/prod2u_runtime_step_limit_gate.v
 runtime_step_gate_hold_formal.v

+ 84 - 4
tests/formal/runtime_step_gate_hold_formal.v

@@ -1,9 +1,89 @@
-// BLOCKED Round-12 stub: requires sequential prod2u_runtime_step_limit_gate hold FF.
-// Do not treat as acceptance evidence until gate-hold RTL lands.
+// Production gate hold-until-engine-low: one engine high phase ⇒ ≤1 gated rise.
+// Instantiates prod2u_runtime_step_limit_gate (clk/rst). Bounded BMC — not unbounded.
 `timescale 1ns/1ps
 
-module runtime_step_gate_hold_formal;
+module runtime_step_gate_hold_formal (
+    input wire clk,
+    input wire rst_n,
+    input wire [2:0] engine_step,
+    input wire [2:0] engine_dir,
+    input wire [2:0] close_limit,
+    input wire [2:0] open_limit
+);
+    wire [2:0] selected_limit;
+    wire [2:0] gated_step;
+
+    reg [1:0] reset_cycles;
+    reg [2:0] prev_engine_step;
+    reg [2:0] prev_gated_step;
+    reg [2:0] phase_truncated;
+    reg past_valid;
+
+    prod2u_runtime_step_limit_gate #(.AXIS_COUNT(3)) dut (
+        .clk(clk),
+        .rst_n(rst_n),
+        .engine_step(engine_step),
+        .engine_dir(engine_dir),
+        .close_limit(close_limit),
+        .open_limit(open_limit),
+        .selected_limit(selected_limit),
+        .gated_step(gated_step)
+    );
+
     initial begin
-        $fatal(1, "runtime_step_gate_hold_formal blocked until gate-hold RTL");
+        reset_cycles = 2'd0;
+        prev_engine_step = 3'b000;
+        prev_gated_step = 3'b000;
+        phase_truncated = 3'b000;
+        past_valid = 1'b0;
+    end
+
+    integer ai;
+    always @(posedge clk) begin
+        assume (rst_n == 1'b0 || rst_n == 1'b1);
+
+        if ($initstate || reset_cycles < 2) begin
+            assume (!rst_n);
+            reset_cycles <= reset_cycles + 1'b1;
+        end else begin
+            assume (rst_n);
+        end
+
+        if (!rst_n) begin
+            prev_engine_step <= 3'b000;
+            prev_gated_step <= 3'b000;
+            phase_truncated <= 3'b000;
+            past_valid <= 1'b0;
+        end else begin
+            past_valid <= 1'b1;
+
+            // Immediate hard-stop: selected limit and gated STEP never both high.
+            assert ((gated_step & selected_limit) == 3'b000);
+
+            for (ai = 0; ai < 3; ai = ai + 1) begin
+                if (!engine_step[ai])
+                    phase_truncated[ai] <= 1'b0;
+                else if (selected_limit[ai] ||
+                         (prev_engine_step[ai] && prev_gated_step[ai] && !gated_step[ai]))
+                    phase_truncated[ai] <= 1'b1;
+
+                // After truncate in this engine-high phase, gated stays low until engine low.
+                if (past_valid && engine_step[ai] && phase_truncated[ai])
+                    assert (gated_step[ai] == 1'b0);
+
+                // Rising edge cannot occur while selected limit is high.
+                if (past_valid)
+                    assert (!((gated_step[ai] & ~prev_gated_step[ai]) & selected_limit[ai]));
+            end
+
+            // Cover: truncate then limit release while engine still high (hold prevents re-open).
+            cover (past_valid && engine_step[0] && phase_truncated[0] &&
+                   !selected_limit[0] && (gated_step[0] == 1'b0) && prev_engine_step[0]);
+            cover (|gated_step);
+            cover (past_valid && engine_step[0] && selected_limit[0] && (gated_step[0] == 1'b0));
+
+            prev_engine_step <= engine_step;
+            prev_gated_step <= gated_step;
+        end
     end
 endmodule

+ 20 - 5
tests/formal/simple_motor_temperature_contract_formal.v

@@ -32,6 +32,7 @@ module simple_motor_temperature_contract_formal (
     reg [1:0] reset_cycles;
     reg [12:0] latched_travel;
     reg [7:0] latched_percent;
+    reg [1:0] latched_axis;
     reg pending;
 
     door_percent_planner motor (
@@ -45,35 +46,49 @@ module simple_motor_temperature_contract_formal (
         reset_cycles = 2'd0;
         latched_travel = 13'd0;
         latched_percent = 8'd0;
+        latched_axis = 2'd0;
         pending = 1'b0;
     end
 
     always @(posedge clk) begin
         assume (rst_n == 1'b0 || rst_n == 1'b1);
+        assume (start == 1'b0 || start == 1'b1);
         assume (travel >= 13'd2 && travel <= 13'd6);
         assume (percent >= 8'd1 && percent <= 8'd99);
         assume (axis_id <= 2'd2);
         assume (!(start && busy));
 
-        if (!rst_n) begin
-            reset_cycles <= 2'd0;
-            pending <= 1'b0;
-        end else if (reset_cycles < 2'd3) begin
+        // Force a real reset window so anyinit cannot discharge done vs stale latches.
+        if ($initstate || reset_cycles < 2) begin
+            assume (!rst_n);
             reset_cycles <= reset_cycles + 1'b1;
         end else begin
+            assume (rst_n);
+        end
+
+        if (!rst_n) begin
+            pending <= 1'b0;
+            latched_travel <= 13'd0;
+            latched_percent <= 8'd0;
+            latched_axis <= 2'd0;
+        end else if (reset_cycles >= 2'd2) begin
             // Avoid start/done same-cycle race vs NBA latches.
             assume (!(start && done));
             if (start && !busy) begin
                 latched_travel <= travel;
                 latched_percent <= percent;
+                latched_axis <= axis_id;
                 pending <= 1'b1;
             end
             if (done && pending) begin
                 assert (result == expected_half_up(latched_travel, latched_percent));
                 assert (done_percent == latched_percent);
+                assert (done_axis_id == latched_axis);
+                assert (result >= 13'd1);
+                assert (result <= (latched_travel - 13'd1));
                 pending <= 1'b0;
             end
-            cover (done);
+            cover (done && pending && (result == expected_half_up(latched_travel, latched_percent)));
             cover (busy);
         end
     end

+ 45 - 0
tests/unit/test_formal_receipt_honesty.py

@@ -10,6 +10,7 @@ from pathlib import Path
 from typing import Any
 
 from tools.prod2u_p4_harness import (
+    formal_cover_hit_ids,
     formal_target_status_from_tasks,
     formal_task_evidence,
     formal_top_status_from_targets,
@@ -138,6 +139,50 @@ class FormalReceiptHonestyTests(unittest.TestCase):
             self.assertIn(result_status, {"fail", "fail_evidence"})
             self.assertFalse(formal_top_status_from_targets([{"status": result_status}]))
 
+    def test_sby_prefixed_summary_cover_hits_parse(self) -> None:
+        # design.json helper rebuilds ids as dut.<suffix after first dot>
+        cover_ids = [
+            "mod._witness_.check_cover_a",
+            "mod._witness_.check_cover_b",
+            "mod._witness_.check_cover_c",
+        ]
+        compiled_ids = [
+            "dut._witness_.check_cover_a",
+            "dut._witness_.check_cover_b",
+            "dut._witness_.check_cover_c",
+        ]
+        log_text = "\n".join(
+            [
+                (
+                    "SBY  2:58:26 [/tmp/cover] summary:   reached cover statement "
+                    f"{cover_id} at formal.v:10.1-10.2 step 4"
+                )
+                for cover_id in compiled_ids
+            ]
+            + [
+                # Engine prose must not contribute a false 'in' hit.
+                "SBY  2:58:26 [/tmp/cover] engine_0: ##   0:00:00  "
+                "Reached cover statement in step 4 at formal: formal.v:10.1-10.2 "
+                "(_witness_.check_cover_a)",
+            ]
+        )
+        self.assertEqual(formal_cover_hit_ids(log_text), sorted(compiled_ids))
+        with tempfile.TemporaryDirectory() as tmpdir:
+            process, tasks = self._task_bundle(
+                Path(tmpdir),
+                status_raw="PASS 0 0",
+                mode="cover",
+                returncode=0,
+                log_text=log_text,
+                cover_ids=cover_ids,
+                trace=True,
+                pass_marker=True,
+            )
+            self.assertEqual(tasks[0]["cover_hit_ids"], sorted(compiled_ids))
+            joined = " ".join(tasks[0]["evidence_failures"])
+            self.assertNotIn("formal_cover_hits_incomplete", joined)
+            self.assertNotIn("formal_cover_hit_set_mismatch", 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(

+ 25 - 0
tests/unit/test_phase3_formal_contract.py

@@ -42,8 +42,14 @@ class Phase3FormalContractTests(unittest.TestCase):
         self.assertIn("door_motion_status_snapshot", formal_names)
         self.assertIn("command_startup_commit", formal_names)
         self.assertIn("runtime_limit_hard_stop", formal_names)
+        self.assertIn("door_axis_source_limit_lingering", formal_names)
+        self.assertIn("runtime_step_gate_hold", formal_names)
         self.assertNotIn("startup_close_seek", formal_names)
         self.assertNotIn("door_action_dispatcher_axis3", formal_names)
+        blocked = manifest["layers"].get("formal_blocked", [])
+        blocked_names = {entry["name"] for entry in blocked}
+        self.assertNotIn("door_axis_source_limit_lingering", blocked_names)
+        self.assertNotIn("runtime_step_gate_hold", blocked_names)
 
     def test_runtime_limit_formal_uses_production_gate_module(self):
         source = _read("tests/formal/runtime_limit_hard_stop_formal.v")
@@ -99,6 +105,25 @@ class Phase3FormalContractTests(unittest.TestCase):
             (ROOT / "tests/sim/door_axis_request_planner_collision_tb.v").is_file()
         )
 
+    def test_source_limit_lingering_formal_uses_axis_dut(self):
+        source = _read("tests/formal/door_axis_source_limit_lingering_formal.v")
+        sby = _read("tests/formal/door_axis_source_limit_lingering.sby")
+        self.assertIn("door_axis_controller", source)
+        self.assertIn("gated_step_rise", source)
+        self.assertIn("ST_MOVE_OPEN", source)
+        self.assertNotIn("$fatal", source)
+        self.assertIn("door_axis_controller.v", sby)
+
+    def test_runtime_step_gate_hold_formal_uses_production_gate(self):
+        source = _read("tests/formal/runtime_step_gate_hold_formal.v")
+        sby = _read("tests/formal/runtime_step_gate_hold.sby")
+        self.assertIn("prod2u_runtime_step_limit_gate", source)
+        self.assertIn("phase_truncated", source)
+        self.assertIn(".clk(clk)", source)
+        self.assertIn(".rst_n(rst_n)", source)
+        self.assertNotIn("$fatal", source)
+        self.assertIn("prod2u_runtime_step_limit_gate.v", sby)
+
     def test_startup_commit_formal_uses_command_controller(self):
         source = _read("tests/formal/command_startup_commit_formal.v")
         sby = _read("tests/formal/command_startup_commit.sby")

+ 16 - 6
tools/prod2u_p4_harness.py

@@ -1127,14 +1127,24 @@ def formal_cover_hit_count(stdout: str, stderr: str) -> int:
 
 
 def formal_cover_hit_ids(*texts: str) -> list[str]:
+    """Collect cover statement IDs from SBY / yosys-smtbmc logs.
+
+    SBY summary lines carry the full compiled cover id but are prefixed with
+    ``SBY ... summary:``; do not require start-of-line. Legacy bare
+    ``Reached cover statement <id> at file:line`` still matches. Engine lines
+    that say ``in step N`` do not match this pattern (they use a different
+    shape and a short parenthetical id).
+    """
     hits: set[str] = set()
+    pattern = re.compile(
+        r"(?i)reached cover statement\s+(\S+)\s+at\s+\S+:\d+",
+    )
     for text in texts:
-        hits.update(
-            re.findall(
-                r"(?im)^\s*reached cover statement\s+(\S+)\s+at\s+\S+:\d+",
-                text,
-            )
-        )
+        for hit in pattern.findall(text):
+            # Engine prose ("... statement in step N at ...") must not count.
+            if hit.casefold() == "in":
+                continue
+            hits.add(hit)
     return sorted(hits)