test(core): unit-test the shared Unicode sanitizer - #3692
Conversation
bd118a1 to
d139db7
Compare
Cover each pipeline stage (NFC, control/bidi replacement, zero-width removal, whitespace collapse) plus surrogate-safe code-point capping, silent caps, and inputs that sanitize to empty. The module is the single source of truth shared by session names and foreign-session names and had no direct tests. Generated-By: opencode
d139db7 to
69c03b6
Compare
|
Two questions before this lands, both about scope rather than correctness — the assertions themselves are accurate. What drove this? There's no issue, no reported bug, and no regression this pins. #1404 establishes that Some of it is already covered, and more so as of an hour ago. #3846 landed The parts that genuinely aren't reachable from either caller are narrower and, I think, the real argument for this PR:
Those three are worth having as a direct contract. The plain-passthrough, control-character, zero-width, and whitespace-collapse cases mostly restate what the two callers' suites already assert from the other side. Would you narrow this to the properties the callers can't reach, and say in the body what prompted it? If you think the full-pipeline coverage is worth it as a whole, that's a fine answer too — I'd just like the reasoning on the record rather than inferred. AI-assisted review: I checked both callers' invocations and their existing suites against head |
Astro-Han
left a comment
There was a problem hiding this comment.
Thanks for adding focused coverage at the shared Unicode-sanitization authority. I reviewed exact head 69c03b6708e7c240130e7eefff4d96f72d3f090f.
This has a concrete contract to protect: sanitizeUnicodeText() is the single pipeline shared by session names and foreign-session text at trust-adjacent boundaries. The tests distinguish the behavior of each stage—NFC normalization, control/bidi replacement, zero-width removal, whitespace collapse, code-point capping, and empty output—so a future drift fails at the owner instead of surfacing only through distant callers.
The 98-line scope is proportionate: one test file, no production change, no new helper or parallel authority, and no repeated full matrix across wrapper APIs. I found no P0-P3 issue. The reported exact-head test and windows_recovery checks are green.
中文对照
感谢在共享 Unicode sanitizer 的权威边界补上聚焦测试。我复核了最新提交 69c03b6708e7c240130e7eefff4d96f72d3f090f。
这里有明确需要保护的 contract:sanitizeUnicodeText() 是 session name 与 foreign-session text 共用的唯一处理流水线,位于接近信任边界的位置。测试分别锁定 NFC normalization、control/bidi 替换、zero-width 删除、空白收敛、code-point 截断和空结果,因此未来某个阶段发生漂移时,会在 owner 处直接失败,而不是只靠较远的调用方间接暴露。
98 行范围是成比例的:只有一个测试文件,不改生产代码,不新增 helper 或并行权威,也没有把完整矩阵重复套在多个 wrapper API 上。没有发现 P0-P3。GitHub 报告的 exact-head test 和 windows_recovery 均为绿色。
AI-assisted review: Codex compared the direct suite with existing caller coverage; I independently verified the problem value, scope, exact head, and severity.
* refactor(runtime): remove unvalidated Auto tool guidance Remove the prompt fragment, composition wiring, export, and feature-specific tests added by #3705. Maka has no demonstrated retry-loop reproduction or A/B evidence for this guidance, and the implemented best-fit wording does not match the issue’s CLI-first premise. Generated-by: OpenAI Codex * test(core): remove speculative sanitizer coverage Remove the direct sanitizer matrix added by #3692. It was not tied to a reported regression, planned behavior change, or failing contract, while existing session-name and foreign-session tests continue to cover the real trust-adjacent behavior. Generated-by: OpenAI Codex
Summary
packages/core/src/text-sanitize.tsis the single source of truth (#1404) for the Unicode sanitize pipeline shared by session names (session-name.ts) and foreign-session names (foreign-session.ts) — explicitly documented as security-adjacent (bidi-spoofing defense) shared infrastructure — but it had no direct unit tests; only callers exercised it transitively.This adds direct coverage of each pipeline stage and edge:
Character classes are asserted via
\uXXXXescapes in both source and test, per the note intext-sanitize.tsabout keeping files text-safe for git.No production code is touched.
Verification
node --test packages/core/dist/__tests__/text-sanitize.test.js).@maka/coresuite: 660 tests, 660 pass.npx biome check packages/core/srcclean; ASF header check passes.AI use
Select exactly one:
Tool(s) and scope: opencode — identified the coverage gap, wrote the tests against the documented pipeline, hand-checked expectations against the implementation. Commit carries the
Generated-By: opencodetrailer.Checklist
Does this PR entail a change in behavior?