Browse Source
Investigation record only - no fix yet (goal remains proposed). Root cause: the Tcl core delivers the transform 'clear' op before every write (output-buffer flush-down; tclsh 8.7 and 9.0.3), and ::punkboot::ansistrip's transchan handles 'clear' with 'dict unset carry' - discarding a split sequence's held tail at every chunk boundary. The tail's remainder (e.g. 0;1m) passes through unstripped while the held ESC[ bytes are never emitted, so the zero-ESC pin (maketclcolour.test) stays green while fragments leak. Evidence: pre-transform stream captured via NO_COLOR+PUNK_FORCE_COLOR is fully well-formed (textblock/punk::ansi exonerated; G-056 not the mechanism); the verbatim strip proc is correct for every possible 2-chunk split and 512..8192 block sizes; an identity logging transform under ansistrip captured the boundary byte-exactly; minimal isolated repro on a bare file channel reproduces both the per-write 'clear' op sequence and a fragment. Deterministic per table geometry, matching the observed intermittency. Upstream (TEMP_REFERENCE/tcl9 survey): per-write 'clear' is intentional, test-pinned core behavior (ioTrans.test iortrans-7.1 "chan write, write clears read buffers") but transchan.n and TIP 230 document it as seek-only and read-side-scoped - an upstream documentation gap, not an implementation bug; no existing Tcl ticket found. A write-only transform's contract-conformant 'clear' is a no-op; fix layer recorded in the goal file (drop 'clear' from the supported-methods list or make it a no-op; 'finalize' keeps dropping the carry). - goals/G-145-piped-usage-ansi-remnants.md: root cause, evidence chain, upstream documentation status, fix layer, encoding note, repro recipes - shellfilter: G-145 warning comment over the commented-out 'clear' method so future refactors don't discard o_encbuf/stream state there goals_lint clean (83 active-index goals, 62 archived). Assisted-by: harness=opencode; primary-model=opencode/kimi-k3; api-location=unknownmaster
2 changed files with 19 additions and 1 deletions
Loading…
Reference in new issue