bi-03 — Analysis
Required invariants
- Every byte sequence produces a DOM. There is no parse-failure path. "Parse error" is a diagnostic annotation, not control flow.
- Two conforming implementations produce the same DOM for broken markup. This is the entire reason error recovery is specified, and the largest interop win in the platform's history.
- Insertion location is decided separately from insertion mode. Foster parenting is a property of where, not of which mode — the lab's Case A turns on exactly this.
- The tokenizer's state depends on the tree builder. Content models (
RCDATA,RAWTEXT, script data) mean the two machines cannot be decoupled. - Speculation may be wrong; it may never be observable. Preload and background scanners create no nodes, run no script, and change no parser state.
- Author code never observes a half-built tree. The construction site queues tasks rather than mutating directly.
The measurable shape of the problem
| Quantity | Value | What it tells you |
|---|---|---|
| Tokenizer states | 76 | content models and legacy escaping, not core parsing |
| Insertion modes | 21 | 7 are tables; 3 are framesets |
| Parser directory files | ~95 | you need about six of them |
Seven of twenty-one insertion modes are table-related. That ratio is the honest measure of what table markup cost the platform, and it is a better argument than any anecdote.
Failure modes
| Break | Consequence | First test to fail |
|---|---|---|
| Remove foster parenting | legacy table markup renders inside-out | html5lib table cases |
| Remove character batching | whitespace handling in tables becomes wrong | in-table-text cases |
| Decouple tokenizer from tree builder | <title>/<textarea> content parsed as markup | RCDATA cases |
Remove the <input type=hidden> exception | hidden form fields leave their <form> on submit | compat, not conformance |
| Sanitiser disagrees with the parser | mutation XSS | none — this is a security bug, not a test failure |
Classification exercise
For each of the following, decide: essential architecture, production hardening, or accretion?
- insertion modes — essential (the tree shape must be recovered from arbitrary input)
kScriptDataDoubleEscaped*— accretion (1990s comment-wrapped scripts)- the fragment-parsing fast path — hardening (it bails out to the general algorithm; that is the tell)
- foster parenting — essential, but only given the compatibility requirement
<input type=hidden>in tables — accretion, and the answer key argues the case
Getting these right, with evidence, is the skill fw-11 formalises.