Import CBB refresh verify r4 stability baseline
Preserve tested Verify source, authoritative READY checks, bounded bridge retries, diagnostics and failure-only reporting. Include 336-test suite and packaging assets; exclude live Mentor samples, field logs, backups and distributions.
This commit is contained in:
commit
11a2b2e46e
130 files changed
+19267
No files matched your search
@@ -0,0 +1,86 @@
|
||||
import json
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
from cbb_refresh_verify.batch_status import BatchStatusSession, fingerprint_library
|
||||
from cbb_refresh_verify.status_bridge import StatusBridgeServer
|
||||
|
||||
|
||||
def make_bridge_script(tmp_path, body):
|
||||
script = tmp_path / "fault_bridge.py"
|
||||
script.write_text(textwrap.dedent(body), encoding="utf-8")
|
||||
return script
|
||||
|
||||
|
||||
def test_malformed_response_does_not_stop_later_item(tmp_path):
|
||||
script = make_bridge_script(tmp_path, '''
|
||||
import json, sys
|
||||
for line in sys.stdin:
|
||||
item = json.loads(line)
|
||||
if item["block_name"] == "BAD":
|
||||
print("not-json", flush=True)
|
||||
else:
|
||||
print(json.dumps({"ok": True, "request_id": item["request_id"],
|
||||
"block_name": item["block_name"], "lmc_file": item["lmc_file"],
|
||||
"status": "PENDING", "source": "fake"}), flush=True)
|
||||
''')
|
||||
lmc = tmp_path / "x.lmc"; lmc.write_bytes(b"x")
|
||||
bridge = StatusBridgeServer(script)
|
||||
records = BatchStatusSession(bridge).scan(["BAD", "GOOD"], lmc, tmp_path / "scan.jsonl")
|
||||
assert records[0].status == "ERROR"
|
||||
assert records[1].status == "PENDING"
|
||||
|
||||
|
||||
def test_bridge_exit_does_not_stop_later_item(tmp_path):
|
||||
script = make_bridge_script(tmp_path, '''
|
||||
import json, sys
|
||||
for line in sys.stdin:
|
||||
item = json.loads(line)
|
||||
if item["block_name"] == "EXIT":
|
||||
sys.exit(7)
|
||||
print(json.dumps({"ok": True, "request_id": item["request_id"],
|
||||
"block_name": item["block_name"], "lmc_file": item["lmc_file"],
|
||||
"status": "READY", "source": "fake"}), flush=True)
|
||||
''')
|
||||
lmc = tmp_path / "x.lmc"; lmc.write_bytes(b"x")
|
||||
records = BatchStatusSession(StatusBridgeServer(script)).scan(
|
||||
["EXIT", "GOOD"], lmc, tmp_path / "scan.jsonl")
|
||||
assert records[0].status == "ERROR"
|
||||
assert records[1].status == "READY"
|
||||
|
||||
|
||||
def test_timeout_on_item_seventeen_continues(tmp_path):
|
||||
script = make_bridge_script(tmp_path, '''
|
||||
import json, sys, time
|
||||
for line in sys.stdin:
|
||||
item = json.loads(line)
|
||||
if item["block_name"] == "N17":
|
||||
time.sleep(0.5)
|
||||
print(json.dumps({"ok": True, "request_id": item["request_id"],
|
||||
"block_name": item["block_name"], "lmc_file": item["lmc_file"],
|
||||
"status": "PENDING", "source": "fake"}), flush=True)
|
||||
''')
|
||||
lmc = tmp_path / "x.lmc"; lmc.write_bytes(b"x")
|
||||
names = [f"N{i}" for i in range(1, 18)] + ["N18"]
|
||||
records = BatchStatusSession(StatusBridgeServer(script), timeout_seconds=0.1).scan(
|
||||
names, lmc, tmp_path / "scan.jsonl")
|
||||
assert records[16].status == "TIMEOUT"
|
||||
assert records[17].status == "PENDING"
|
||||
|
||||
|
||||
def test_fingerprint_change_does_not_reuse_checkpoint(tmp_path):
|
||||
lmc = tmp_path / "x.lmc"; lmc.write_bytes(b"one")
|
||||
checkpoint = tmp_path / "scan.jsonl"
|
||||
first = fingerprint_library(lmc).sha256
|
||||
checkpoint.write_text(json.dumps({"block_name": "A", "status": "READY",
|
||||
"fingerprint": first}) + "\n", encoding="utf-8")
|
||||
lmc.write_bytes(b"two")
|
||||
class Bridge:
|
||||
def __init__(self): self.requests = []
|
||||
def query(self, lmc_file, block_name, **kwargs):
|
||||
self.requests.append(block_name)
|
||||
from cbb_refresh_verify.status_bridge import BridgeResult
|
||||
return BridgeResult("PENDING", "fake")
|
||||
bridge = Bridge()
|
||||
BatchStatusSession(bridge).scan(["A"], lmc, checkpoint)
|
||||
assert bridge.requests == ["A"]
|
||||
Reference in new issue
Block a user