From 23c4e34b753ae40e2c2c4af8a49b9ceb7df3fe91 Mon Sep 17 00:00:00 2001 From: Vito Sansevero Date: Mon, 19 Oct 2026 14:43:41 -0700 Subject: [PATCH] test(inspect): cover batch copies past the role budget and orphan widgets --- tests/test_inspection_legacy_ports.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/test_inspection_legacy_ports.py b/tests/test_inspection_legacy_ports.py index 143026e..d300a4a 100644 --- a/tests/test_inspection_legacy_ports.py +++ b/tests/test_inspection_legacy_ports.py @@ -133,7 +133,10 @@ class TestOverwrittenPromptManagerText(unittest.TestCase): node["type"] = node["type"].replace("PromptManager", "PromptManagerPair") self.assertEqual(_inspect(metadata)["state"], "resolved") # No workflow, or a malformed one, cannot show the signature. - for workflow in (None, "nodes", {"nodes": "x"}, {"nodes": [1, None]}): + orphans = { + "nodes": [{"id": 5, "type": "PromptManager", "widgets_values": ["a"]}] + } + for workflow in (None, "nodes", {"nodes": "x"}, {"nodes": [1, None]}, orphans): with self.subTest(workflow=workflow): metadata = _overwritten() metadata["workflow"] = workflow @@ -448,6 +451,24 @@ class TestBatchIndexDuplicates(unittest.TestCase): path = self.png(chunks) with self.assertRaisesRegex(MetadataReadError, "exceeds inspection limits"): read_inspection_file(path) + # The kept copy still fits the role budget when a later one is longer. + from utils.prompt_inspector import ROLE_METADATA_BYTES + + first = _batch(9) + first += "," + " " * (ROLE_METADATA_BYTES - len(first) - 1) + later = first.replace("index: 9", "index: 10") + for copy in (later, later + " " * ROLE_METADATA_BYTES): + with self.subTest(size=len(copy)): + path = self.png( + [ + _chunk("parameters", first, b"zTXt"), + _chunk("parameters", copy, b"zTXt"), + ] + ) + with self.assertRaisesRegex( + MetadataReadError, "exceeds inspection limits" + ): + read_inspection_file(path) def _f02(**changes) -> dict: