Skip to content

log() hot-path control-byte pre-check (#621) was abandoned, not implemented -- board should not read it as fixed #629

Closed

Description

@fdaviddpt

#621 asked for a cheap in-shell pre-check ahead of log()'s printf | tr control-byte flatten, so the fork only runs on the rare message that actually needs it (an optional, low-severity cost optimization: "Fix (if judged worth it)").

PR #627 (which also carried #618 and #620) closed #621 via GitHub's Closes #621, but the optimization was never actually shipped. Three attempts at a portable pre-check were tried on that branch and none survived CI:

  1. An unconditional printf | tr gated by a POSIX [[:cntrl:]] bracket-class case pattern -- broke deterministically on every windows-latest leg (Git Bash/MSYS2 bash never matched a real embedded control byte through the pre-check, so the flatten silently never ran).
  2. An ANSI-C byte-literal range (case ... in *[$'\001'-$'\037']*...) instead of the bracket class -- fixed the Windows symptom, but macos-latest then failed the identical way: a real control byte (embedded newline, tab, CR, DEL, unit separator) did not trip the pre-check, so tr was never invoked and the raw message reached the log file, reopening the exact log() writes untrusted model reply text unsanitized, so an embedded newline forges a second log entry — sanitize once in scripts/log.sh, not per call site #599 log-forging bug log.sh control-byte flattening (#599) does not cover the four hook-errors.log writers #618 depends on log() closing. This was NOT reproducible locally -- tried Apple's system bash (3.2.57) and a fresh Homebrew bash (5.3.15), and every UTF-8 locale available locally, all matched correctly every time.
  3. A test-harness PATH-injection fix (export PATH="...:$PATH" inside the script rather than via subprocess.run's env=) -- did not touch the still-unexplained macOS mechanism; the macOS CI leg was still red afterward with the identical symptom.

Given three failed attempts and no way to reproduce or diagnose the macOS failure locally, the fix actually shipped by #627 was to drop the pre-check entirely and restore log()'s pre-#621 unconditional printf | tr flatten -- the correctness-safe, portable behaviour -- and delete the test file (tests/test_log_hot_path_tr_spawn_621.py) that existed solely to exercise the abandoned pre-check.

This issue is the record #621 itself no longer carries once GitHub auto-closed it: the hot-path cost optimization #621 asked for remains undone. log() still forks tr on every call, exactly as #621 originally described. Re-attempting it needs the actual macOS mechanism understood first -- see the companion issue this same finding filed for that.

Row: none of the existing rows fit (the same reason #621 itself was filed unranked) -- unranked, low severity, informational.

[AI-generated, filed by the maintainer loop correcting its own PR #627's board state per a maintainer ruling]

[AI-generated]

Activity

  1. added
    priority:low
    filed-by-loop
    lane-capture
    cohort-9
    on Sep 7, 2026
  2. self-assigned this
    on Sep 10, 2026
  3. added a commit that references this issue on Sep 10, 2026
  4. removed their assignment
    on Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cohort-9filed-by-looplane-capturepriority:low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions