Repository navigation
chore: spell control characters as escapes in tracked sources - #1784
openwong2kim merged 2 commits into
Conversation
Ten source files and docs/phone-client-contract.md held raw NUL bytes inside string literals, a comment and inline code. With default settings ripgrep treats such a file as binary and stops searching it: on main, a directory search does not find even `export class WebTerminalServer` (line 1317). In deviceAudit.ts the NUL sits within git's first 8000 bytes, so `git diff` and GitHub's PR view show "Binary files differ" for it. Raw ESC, BEL and US bytes in nine more files are respelled the same way. In source files every rewrite respells a literal, regex or comment: esbuild output is byte-identical for 18 of the 19 changed sources, and the remaining one differs only in how a regex spells ESC. The contract doc now writes its NUL marker as \u0000 and says what it denotes. A tracked-tree test rejects raw C0 control bytes (other than tab, LF and CR) in allowlisted text files. It skips symlinks and submodules recorded in the index, exempts patches/, decodes paths as strict UTF-8, and fails on any read error other than a missing file.
Git treated both files as binary while they held a raw NUL, so their CRLF endings were never normalized like the rest of the repository. This commit changes line endings only.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (21)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe changes replace literal control characters with escaped notation in code, tests, and documentation. A new test scans eligible tracked files for raw C0 control bytes and checks file classification, Git index parsing, reported positions, and read errors. ChangesControl-byte hygiene
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Other Suggested reviewers: Merge Risk: ⚪ Minimal · up to The control-character cleanup appears ready to merge after normal checks; no behavior-changing issue was identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 70.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 16 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks, this is a great find. Three reviewers checked it token by token: every runtime string, template and regex value is unchanged, and the CRLF→LF files are value-identical too. Merging. One optional nit for whenever: |
Summary
Ten source files and
docs/phone-client-contract.mdcontain raw NUL bytes, written straight into string literals, one comment and one piece of inline code. With default tool settings that has three effects:main, a default directory search (rg "export class WebTerminalServer" src/daemon/web) returns nothing. The same is true forprivate advertisedHosts((line 9020) and forUNKNOWN_SUBJECT_KEYindeviceAudit.ts.grep -rprints "Binary file matches" instead of the line. A person or agent who searches with plainrgorgrep -rwill not find the 9,819-lineWebTerminalServer.ts, the phone client contract, or the rest of the files below. Tools that pass--textare not affected.deviceAudit.tsthe NUL is within git's first 8000 bytes, so git's binary heuristic applies.git diff,git log -pand GitHub's PR view all show "Binary files differ". For example, the GitHub API returns no patch for that file in 74b876c..gitattributes, so binary detection keptparseEntry.tsand its test out of line-ending normalization. They are stored with CRLF; the rest of the repository is LF.This PR spells those characters as escapes and adds a test that keeps raw control bytes out.
Changes
\u0000, the spellinghostSearch.tsandturnEvents.tsalready use for the same code-block marker. This covers 10 sources: cache keys, separators, test fixtures and a comment. In the phone client contract, the inline-code marker now reads, with a note that\u0000code:<n>\u0000\u0000is a NUL character.\x1b,\x07and\x1f. Most are test fixtures for terminal sanitizers; one is a NIC key inSettingsPanel.tsx.scripts/__tests__/sourceControlBytes.test.mjs. Every tracked regular file on an extension/name allowlist must be free of C0 control bytes other than tab, LF and CR. The allowlist covers source, docs, config,.patch/.diff, and dotfiles such as.gitignore.patches/is exempt, because package patches carry upstream bytes verbatim.file:line:columnand the byte, for examplesrc/daemon/web/deviceAudit.ts:80:30 raw \x00.git ls-filespattern ofinternalDocGuard.test.mjs.parseEntry.tsandparseEntry.test.tswith LF, like the rest of the repository. It changes line endings only (git diff --ignore-cr-at-eolis empty), so you can review the first commit alone or use "Hide whitespace". Left as CRLF, both files would failgit diff --checkwith default whitespace settings on every future edit, because git now treats them as text.Behavior
Code behavior is unchanged: every rewrite in a source file respells a string literal, a regex or a comment. To check, I ran each of the 19 changed sources through
esbuild.transformSync(comments dropped,charset: 'ascii') before and after:scripts/hooks-daemon-dynamic.mjsdiffers only because esbuild keeps regex source verbatim. With ESC spelled\x1b, its output is identical too, and the old and new regexes give the same result on four sample strings.The documented wire value is also unchanged; only how the doc writes the NUL is different.
CHANGELOG entry
n/a: repository hygiene with no user-facing change.
Stability tier impact
internalsurface (no contract impact).docs/phone-client-contract.mdchanges only in how one marker is written. The marker on the wire is unchanged.Substrate contract impact (Substrate 3.0)
n/a.
Test plan
Verified on Windows with Node 22.12.0, on upstream
f31eb506, then rebased onto94c49222without conflicts.deviceAudit.tsrestored, it fails and namesdeviceAudit.ts:80:30.f31eb506a default directory search finds none of the three symbols above; on this branch it finds all three.WebTerminalServer.ts, the phone contract,ClaudePtyBrainAdapter.test.ts). After rebasing, the guard passes and the esbuild comparison against94c49222gives the same result.mainon this machine: symlinkEPERMwithout Developer Mode, the Node 22.12file-changedpreview case, and a skill-discovery test that reads the developer's real~/.claude. Two more werefetch failedsocket timeouts under load and passed 3 of 3 times when rerun alone.node scripts/typecheck.mjspasses. ESLint on the new test is clean.git diff --checkpasses.Related issues / PRs
n/a.
Reviewer checklist
.env, or unrelated large binaries.Summary by CodeRabbit