Files
sql-server-query-ai/kb/Plan file encoding.md
T
ahmed mohammedandClaude Opus 4.7 8b42a0931c docs: karpathy-pattern wiki built from the spec, plan, design contract and decisions ledger
kb/ is its own wiki root: 34 pages across 7 categories, index.md catalog, log.md, AGENTS.md schema layer, and raw/ holding copies of README, the spec, the 13-task plan, the design master and the SDD ledger.

Every page cross-references 3 to 6 others and all 107 wikilinks resolve except two [["list"]] artefacts inside JSON snippets in the copied plan.

Kept separate from the repository root on purpose: its generated graph lands in kb/.ua/ instead of overwriting the code graph.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-22 12:14:05 +03:00

866 B

Plan file encoding

SSMS saves .sqlplan as UTF-16LE with a byte-order mark. File.text() assumes UTF-8, which turns such a plan into NUL-filled junk and makes the parser complain about the user's export. lib/plan-file.ts decodes by BOM first (UTF-32LE/BE, UTF-16LE/BE, UTF-8), then falls back to NUL density for BOM-less UTF-16: in ASCII XML roughly every other byte is 0x00.

The browser reads the dropped file into bytes and calls decodePlan; the server never sniffs encoding. That keeps ShowPlan digest independent of how the text arrived.

Four encodings are pinned by tests: UTF-8, UTF-8 with BOM, UTF-16LE with BOM, UTF-16BE with BOM, and both UTF-16 variants with no BOM. A browser test uploads a generated UTF-16LE file and asserts the textarea holds no NUL characters.

Related: ShowPlan digest, Unit suites, Playwright projects.