Skip to content

server: write a request line's control bytes as \xNN in the access log, as Python's log_message does - #2542

Merged
ashhart merged 3 commits into
ashhart:mainfrom
chadhurley25075-png:compass/log-control-chars
Nov 8, 2026
Merged

ashhart merged 3 commits into
ashhart:mainfrom
chadhurley25075-png:compass/log-control-chars

Conversation

@chadhurley25075-png

Copy link
Copy Markdown
Contributor

The Test.sink in log.zig lets the access line be checked byte for byte, and http_conn.latin1 keeps a request line's bytes rather than guessing at them. Those two choices are what made this change and its test small.

What this changes

Before: a request line's bytes went into the [tensorfold] access line as they arrived, so a request such as \x1b[2J\x1b]0;owned\x07GET /health wrote terminal controls into whatever the log is attached to. After: line() writes every C0, DEL and C1 control (the C1 as http_conn.latin1 carries it, 0xc2 then the byte) as \xNN, the way Python's log_message does, at the one place every [tensorfold] line passes through, so the access line, the refusal lines and the key label all get it. One deliberate difference from Python: backslashes are not doubled, so Windows paths in startup lines stay readable; happy to add that if you prefer the exact table. The ordinary line is byte-identical to before, and a line past the buffer still ends in exactly one newline.

  • Issue: n/a; no open issue. A log-injection fix in one function.
  • Stacked on: main (1a56448). One commit.
  • atc overlap --json (run 2026-11-08 03:2x CT against main): overlaps: [], no open pull request shares the file; one local worktree shares it, conflict: clean. complete: false with pullFilesLimit, pullFilesUnavailable, timeLimit, so the open-PR coverage was partial.

Checks on this head

  • Head commit: 640de35
  • Lean checker, python3 tools/zig/lean_check.py, on the base and on this head: 116 and 116, 0 new (python3 tools/pr_check.py --base main: 0 errors, 1 advisory warning about the Unreleased line).
  • Tests run, with the command and pass, fail and skip counts: on an x86_64 Linux host with Zig 0.17.0, zig build -Dfixed-cpu test --test-timeout 10m exit 0, zig build -Dfixed-cpu test-server-security exit 0, zig build -Dfixed-cpu test-golden exit 0 (the runner prints no pass/fail/skip summary on a green build; the new test's name begins with security: so the security step reaches it). zig fmt --check build.zig zig and git diff --check clean. All of these were run on this head, 640de35, after the rebase onto 1a56448 (test 211 s, security 2 s, golden 81 s).
  • CI: not run yet on this head; I will read it once it runs and label anything that is not mine.
  • Not run, and why: Metal and CUDA device checks; the host is a Linux box without a GPU and this change does not reach a kernel.

Receipt

n/a: the change is in the server's log line formatting and cannot reach inference, tokens or speed.

  • Main against branch: n/a, see above.
  • Boxes it reaches: every server build; the log line only.
  • New switch? none.
  • Environment, with the TensorFold commit, Zig and backend toolchain, machine and GPU, checkpoint and revision: n/a for a receipt; host checks above ran on x86_64 Linux, Zig 0.17.0.
  • Paths and platforms the change reaches, which I ran and which I could not: every [tensorfold] line on every platform; host tests on Linux; Metal, CUDA and HIP builds not run.
  • Exactness: n/a.
  • Main against this branch, same machine and checkpoint: n/a.
  • Decode speed before and after: n/a.
  • Prompt speed before and after: n/a, the change cannot reach prompt processing.
  • Licence of any new weights or drafter: n/a.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (The test alone on main: zig build -Dfixed-cpu test-server-security fails, the sink receives the raw ESC bytes, Build Summary 21/22 tests passed (1 failed); with the change it passes. No dependency to skip on.)
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

From Chad Hurley and Compass — Compass is our family's assistant; this change was found, fixed and tested on Claude Mythos 5.1.

@ashhart

ashhart commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Thanks @chadhurley25075-png. Putting this in line() (zig/src/server/log.zig:72-76) means every [tensorfold] line gets it, and the test pins both the escaped access line and the unchanged ordinary one. The C1 check against latin1's 0xc2 pairs is exact, and leaving backslashes alone is fine with us. We'll add the CHANGELOG line when it lands; nothing more is needed from you.

@ashhart
ashhart force-pushed the compass/log-control-chars branch from 640de35 to 2dfd087 Compare November 8, 2026 17:49
@ashhart
ashhart merged commit e54fe0d into ashhart:main Nov 8, 2026
3 of 9 checks passed
@ashhart

ashhart commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Thank you @chadhurley25075-png. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

ashhart added a commit to jschmied/TensorFold that referenced this pull request Nov 8, 2026
ashhart added a commit that referenced this pull request Nov 8, 2026
ashhart added a commit that referenced this pull request Nov 8, 2026
@ashhart

ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants