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>
This commit is contained in:
ahmed mohammed
2026-09-22 12:14:05 +03:00
co-authored by Claude Opus 4.7
parent 735a57bfd6
commit 8b42a0931c
42 changed files with 3534 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
# ShowPlan digest
`lib/digest.ts` converts a SQL Server ShowPlan XML document into a bounded JSON summary before any model is
consulted. The point is that the models judge facts, not guess them: [[Plan file encoding]] hands it clean text,
then it walks the parsed document for operators, tables, missing-index groups, waits and warnings.
Each operator keeps `NodeId`, the logical or physical op name, `EstimateIO`, `EstimateCPU`,
`EstimatedTotalSubtreeCost`, estimated rows, and actual rows where the plan carries
`RunTimeCountersPerThread`. Attribute spellings differ across SQL Server builds, so every cost field falls
through the known variants rather than trusting one.
`digestForModel` is the budget gate: 4 000 characters of statement text, 20 tables, 12 operators, 5 missing
index groups, 20 warnings. It also sets `sql_truncated` when the statement was cut, which stops [[Analyst model]]
from offering a rewrite of a query it never received.
Measured on a 2 694 090-byte production plan (UTF-16LE, 1 352 044 characters, 2 729 tags deep): 2 ms to decode,
56 ms to digest, 37 distinct tables, and `StatementOptmEarlyAbortReason = TimeOut` surfaced as the headline finding.
Related: [[Jev scoring]], [[Max nested tags for real plans]], [[Table names live on Object]].