From 828c69f7ec860d3eec09b8738f1d8fb0bc9c12e8 Mon Sep 17 00:00:00 2001 From: Dan Wolfson Date: Wed, 16 Sep 2026 22:29:37 -0500 Subject: [PATCH] RE: pin the diagram try/catch by structure, not a byte window test_a_render_failure_degrades_the_answer_not_the_whole_message asserted "catch" within a fixed byte distance of f.value.mermaid in _renderEnvelopeMarkdown (index.html) -- widened once already (2026-09-08) when the success branch grew a perspective note, and drifted past the new window again after this week's "found by" rename (RULING-WHAT-A-VERDICT- IS-ABOUT.md), which is unrelated to the guarantee the test exists to pin. The comment already said the guarantee is ordering, not a specific byte distance -- the assertion just didn't match it. Brace-match the try{} immediately after f.value.mermaid and check its own catch{} follows, which cannot drift as the surrounding success branch grows. Flagged by a peer session mid-dispatch: this failure blocks the full suite for every branch touching app.js-adjacent rendering, independent of PLAN-FINISH-REPOS.md's app.js split. Co-Authored-By: Claude Sonnet 5 Signed-off-by: Dan Wolfson --- .../tests/test_fact_answer_rendering.py | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/packages/resource-explorer/tests/test_fact_answer_rendering.py b/packages/resource-explorer/tests/test_fact_answer_rendering.py index da8e06ac..fdeed2a0 100644 --- a/packages/resource-explorer/tests/test_fact_answer_rendering.py +++ b/packages/resource-explorer/tests/test_fact_answer_rendering.py @@ -701,10 +701,24 @@ def test_a_render_failure_degrades_the_answer_not_the_whole_message(self): # The diagram block specifically, not just some other try/catch # elsewhere in this large function. diagram_start = fn.index("f.value.mermaid") - # 2026-09-08: the success branch grew a "shown: ... also on file: ..." - # perspective note (the detect/coupling split), pushing `catch` - # further from the window's start than before -- widened rather than - # tightened, since the guarantee this pins is about ordering, not a - # specific byte distance. - nearby = fn[diagram_start:diagram_start + 2200] - assert "catch" in nearby + # 2026-09-08, then 2026-09-17: a fixed byte window drifted twice as + # the success branch grew (the "shown: .../also on file:" perspective + # note, then the "found by" rename) -- each growth is legitimate and + # has nothing to do with the guarantee this pins, which is ORDERING: + # the try{} guarding the diagram fetch has its own catch{}, wherever + # that lands. Brace-match the try immediately after diagram_start + # rather than picking a byte count that the next unrelated edit will + # outgrow again. + try_start = fn.index("try {", diagram_start) + brace = fn.index("{", try_start) + depth = 1 + i = brace + 1 + while depth: + if fn[i] == "{": + depth += 1 + elif fn[i] == "}": + depth -= 1 + i += 1 + assert "catch" in fn[i:i + 200], ( + "the try{} guarding the diagram fetch has no catch{} immediately after it" + )