[object Object]

← back to Terminal Status

TK-11826 (TK-11779 Finding 2): pin ticket_update=None in T1-c preserve block + coherence regression test

546375811b892c50416b2d5bcbe649e68d0d2940 · 2026-09-16 09:35:06 -0700 · Steve Abrams

The T1-c lightblue preserve branch already cannot mismatch (old label + new
ticket) today — its 'not caller_gave_reason' guard (e0a025a) guarantees
ticket_update is None on that path. Land the credential-desk memo's fix
defensively: pin ticket_update=None inside the block so the preserved reason
stays coherent as a whole (colour+label+ticket) even if a future edit loosens
the branch guard. Add test_lightblue_never_mismatches_old_label_with_new_ticket
to lock the invariant permanently.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Files touched

Diff

commit 546375811b892c50416b2d5bcbe649e68d0d2940
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed Sep 16 09:35:06 2026 -0700

    TK-11826 (TK-11779 Finding 2): pin ticket_update=None in T1-c preserve block + coherence regression test
    
    The T1-c lightblue preserve branch already cannot mismatch (old label + new
    ticket) today — its 'not caller_gave_reason' guard (e0a025a) guarantees
    ticket_update is None on that path. Land the credential-desk memo's fix
    defensively: pin ticket_update=None inside the block so the preserved reason
    stays coherent as a whole (colour+label+ticket) even if a future edit loosens
    the branch guard. Add test_lightblue_never_mismatches_old_label_with_new_ticket
    to lock the invariant permanently.
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
 terminal_status.py      |  8 ++++++++
 test_terminal_status.py | 26 ++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/terminal_status.py b/terminal_status.py
index 280d374..634c233 100644
--- a/terminal_status.py
+++ b/terminal_status.py
@@ -797,6 +797,14 @@ class Store:
                 color = previous["state"]
                 variant = "stopped"
                 label = label_ticket(previous.get("label", ""))[0]
+                # Defensive coherence (TK-11826 / TK-11779 Finding 2): the branch guard
+                # `not caller_gave_reason` already guarantees ticket_update is None here
+                # (caller_gave_reason is True whenever ticket_update is not None), so the
+                # overwrite below cannot fire on this path today. Pin it to None anyway so
+                # the preserved reason stays coherent as a WHOLE — colour + label + ticket —
+                # even if a future edit ever loosens the branch condition; never the
+                # mismatch of an OLD preserved label carrying a NEW caller ticket.
+                ticket_update = None
             # TK-11378 (DTD verdict A) — an AUTOMATIC paint must never erase a pending
             # request for Steve's attention. PRIORITY already encodes the ordering
             # (orange > purple > yellow > green > pink > none) but until now was only
diff --git a/test_terminal_status.py b/test_terminal_status.py
index c0744f7..e097ff5 100644
--- a/test_terminal_status.py
+++ b/test_terminal_status.py
@@ -142,6 +142,32 @@ class StatusTests(unittest.TestCase):
                 self.assertNotIn("OLD", r["title"], "no leak of the preserved base's reason")
                 self.store.set(self.owner, "none")
 
+    def test_lightblue_never_mismatches_old_label_with_new_ticket(self):
+        # TK-11826 / TK-11779 Finding 2: guard the coherence invariant permanently — a
+        # lightblue paint on a purple/orange/yellow base must never produce the mismatch of
+        # an OLD preserved label carrying a NEW caller ticket. Every lightblue result must
+        # take its label and ticket from the SAME source: both preserved (bare set) or both
+        # the caller's explicit reason. The T1-c block pins ticket_update=None defensively.
+        for base in ("purple", "orange", "yellow"):
+            with self.subTest(base=base, path="bare-preserve"):
+                self.store.set(self.owner, base, "TK-11779 · reason A")
+                r = self.store.set(self.owner, "lightblue")  # no reason -> preserve whole
+                self.assertEqual(r["state"], base, "base colour preserved")
+                self.assertEqual(r["variant"], "stopped")
+                self.assertEqual(r["label"], "reason A", "preserved label")
+                self.assertEqual(r["ticket"], "TK-11779",
+                                 "preserved ticket must stay with the preserved label")
+                self.store.set(self.owner, "none")
+            with self.subTest(base=base, path="explicit-ticket-only"):
+                # An explicit ticket_update with NO label must not staple the new ticket onto
+                # the preserved base's old label — it paints a coherent solid lightblue.
+                self.store.set(self.owner, base, "TK-11779 · reason A")
+                r = self.store.set(self.owner, "lightblue", ticket_update="TK-11780")
+                self.assertEqual(r["state"], "lightblue", "explicit ticket paints solid lightblue")
+                self.assertEqual(r["ticket"], "TK-11780", "new ticket taken")
+                self.assertNotIn("reason A", r["title"], "no old label paired with the new ticket")
+                self.store.set(self.owner, "none")
+
     def test_ledger_discovery_rejects_reused_pid_and_nested_agent(self):
         self.rows[124] = ts.Process(124, 123, "??", self.process.started, "/bin/node")
         self.rows[125] = ts.Process(125, 123, "??", self.process.started, "/bin/codex")

← a1139e9 dot.sh: forward all set args so --tty/--force reach the engi  ·  back to Terminal Status  ·  dot.sh: check-for-color — hard timeout + report result, neve 06cd6c5 →