test_amt_diagnostic_transport.py 1.6 KB

123456789101112131415161718192021222324252627282930313233
  1. """Real AMT zero-algorithm BLOCK summaries must remain readable over native gRPC."""
  2. from pathlib import Path
  3. from google.protobuf.json_format import MessageToDict
  4. from stl_backend.diagnostics import DiagnosticConsole
  5. from stl_backend.generated import bench_pb2 as pb
  6. from stl_backend.parsers import IncrementalSolParser
  7. from stl_backend.service import message
  8. class ConsoleDescriptionOnly:
  9. def console_description(self):
  10. return "fixture"
  11. def test_real_amt_block_summary_roundtrips_diagnostic_grpc(tmp_path):
  12. raw = (Path(__file__).parent / "fixtures/live_amt_block_20261026.log").read_bytes()
  13. parser = IncrementalSolParser()
  14. events = parser.feed(raw) + parser.flush()
  15. summary = next(e for e in events if e["kind"] == "test_result" and e["details"].get("scope") == "summary")
  16. assert summary["details"]["outcome"] == "block"
  17. assert summary["details"]["algorithms_executed"] == 0
  18. assert summary["details"]["verdict_supported"] is False
  19. diag = DiagnosticConsole({"station_id":"S1","mode":"hardware","cpu_count":2,"channels_per_cpu":12},
  20. ConsoleDescriptionOnly(), tmp_path)
  21. diag.state["state"] = "online"
  22. for event in events:
  23. diag._parsed(event)
  24. wire = message(pb.DiagnosticSnapshot, diag.snapshot())
  25. restored = MessageToDict(wire, preserving_proto_field_name=True)
  26. summaries = [o for o in restored["observations"] if o.get("details",{}).get("scope") == "summary"]
  27. assert summaries
  28. assert summaries[-1]["details"]["algorithm_counts"] == {"0":0.0,"1":0.0}
  29. assert summaries[-1]["details"]["execution_blocked"] is True