Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(chunkers): escape NUL delimiters in symbol-resolver source (#5580)
garrytan5317f322c477
diff --git a/.gitattributes b/.gitattributesindex 13f81883ee..9f2abb9ed9 100644--- a/.gitattributes+++ b/.gitattributes@@ -35,7 +35,6 @@ native/locks/prebuilds/*.node binary# Preserve the vendored upstream license byte-for-byte, including indentation.native/locks/vendor/node-v22.15.0/LICENSE -whitespacescripts/native/** text eol=lf-src/core/chunkers/symbol-resolver.ts diff# Generated schema-migration registry: regenerate (bun run build:schema-migrations),# never hand-merge; collapsed in GitHub diffs.diff --git a/scripts/structural-suites.tsv b/scripts/structural-suites.tsvindex f2d9b874bc..2284fc9320 100644--- a/scripts/structural-suites.tsv+++ b/scripts/structural-suites.tsv@@ -58,6 +58,7 @@ test/check-bootstrap-guards.test.ts verify + workflow wiring 4 readFileSynctest/check-update.test.ts check-update CLI 3 source-surface-helpertest/child-worker-supervisor.test.ts issue #1801 — restartCurrentChild + killChild liveness fix 3 readFileSynctest/chronicle-extract.test.ts runChronicleExtract 9 readFileSync+test/chunkers/symbol-resolver.test.ts symbol-resolver source hygiene 1 readFileSynctest/ci-local-empty-mounts.test.ts (file-level) 2 readFileSynctest/claude-cli-recipe.test.ts claude-cli LanguageModel — CLI too old for the provider flags 2 readFileSynctest/claude-cli-recipe.test.ts claude-cli LanguageModel — abort + error envelopes 13 readFileSyncdiff --git a/src/core/chunkers/symbol-resolver.ts b/src/core/chunkers/symbol-resolver.tsindex 3a0e79d6b0..0a8eee3d62 100644--- a/src/core/chunkers/symbol-resolver.ts+++ b/src/core/chunkers/symbol-resolver.ts@@ -211,7 +211,7 @@ async function processChunkBatch(for (const e of edges) {const pageId = pageByChunkId.get(e.from_chunk_id);if (pageId === undefined) continue;- lookups.add(`${pageId} ${e.to_symbol_qualified}`);+ lookups.add(`${pageId}\0${e.to_symbol_qualified}`);}// One-shot per-page candidate map. We pre-load all qualified symbol names@@ -226,7 +226,7 @@ async function processChunkBatch([pagesToProbe],);for (const r of rows) {- const key = `${r.page_id} ${r.symbol_name_qualified}`;+ const key = `${r.page_id}\0${r.symbol_name_qualified}`;const list = candidatesByKey.get(key) ?? [];list.push({ id: r.id, page_id: r.page_id });candidatesByKey.set(key, list);@@ -243,7 +243,7 @@ async function processChunkBatch(stats.edges_unmatched += 1;continue;}- const key = `${pageId} ${e.to_symbol_qualified}`;+ const key = `${pageId}\0${e.to_symbol_qualified}`;const candidates = candidatesByKey.get(key) ?? [];if (candidates.length === 1) {toResolve.push({ edgeId: e.id, chunkId: candidates[0]!.id });diff --git a/test/chunkers/symbol-resolver.test.ts b/test/chunkers/symbol-resolver.test.tsnew file mode 100644index 0000000000..401614df88--- /dev/null+++ b/test/chunkers/symbol-resolver.test.ts@@ -0,0 +1,17 @@+import { describe, test, expect } from 'bun:test';+import { readFileSync } from 'node:fs';+import { join } from 'node:path';++describe('symbol-resolver source hygiene', () => {+ test('the module source carries no raw NUL bytes (lookup keys use the \\0 escape)', () => {+ // raw 0x00 makes file(1) classify the module as data and grep -I skip it; runtime keys unchanged.+ // test-reads-source-ok[raw-bytes]: asserts the module's on-disk bytes carry no NUL.+ const src = readFileSync(+ join(import.meta.dir, '..', '..', 'src', 'core', 'chunkers', 'symbol-resolver.ts'),+ 'utf-8',+ );+ expect(src.includes('\0')).toBe(false);+ expect(src).toContain('`${pageId}\\0${e.to_symbol_qualified}`');+ expect(src).toContain('`${r.page_id}\\0${r.symbol_name_qualified}`');+ });+});