# 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]].