nev docs generated-functions.md
19 kB · 270 lines
Markdown
at main

# Generated functions A **generated function** is one layout rule pulled out of the hand-written engine into a plain-data function: typed inputs in, typed outputs out, no access to the DOM or Stylo. The hand-written code around it (`crates/layout/src/fragment.rs`) decides *when* the rule applies and hands it inputs already reduced to one decision; the generated function decides *what the answer is*. Because the function is that small, a model can write it, and the harness can score it alone with every other generated function held fixed. How one is generated and admitted is in [`generation-loop.md`](generation-loop.md); how its output is checked is in [`geometry-verification.md`](geometry-verification.md). ```mermaid flowchart LR fragment["fragment.rs<br/>(hand-written walk)"] -- "plain inputs" --> gen["generated function"] gen -- "plain outputs" --> fragment fragment --> tree["fragment tree"] ``` ## The twelve generated functions Scores are on each function's own corpus, as recorded in the committed candidate's provenance record under `crates/layout/src/generated/`. The recipe corpus is 227 cases; the other corpora are per-function. | function | rule (CSS 2.1 unless noted) | committed candidate | score | how it was built | | --- | --- | --- | --- | --- | | width | 10.3.3 width equation, 10.4 min/max | `qwen3.8-flash-next` | 140/227 | hand fixture first | | margin | 8.3.1 margin collapsing | `qwen3.8-27b` | 156/227 | hand fixture first | | percentage | 10.2 / 10.5 / 8.4 percentages | `qwen3.8-27b` | 116/227 | hand fixture first | | absolute | 9.3, 10.3.7, 10.6.4 absolute positioning | `qwen3.8-flash-next` | 82/108 | model-first | | float | 9.5, 9.5.1, 9.5.2 floats and clearance | `claude-code:default` | 109/109 | model-first | | relpos | 9.4.3 relative positioning | `claude-code:default` | 104/104 | model-first | | stacking | 9.9.1, Appendix E.2, CSS Color 3 opacity | `claude-code:default` | 105/105 | model-first | | height | 10.6.3 / 10.6.7 auto height | hand-written | 105/105 | extracted from working…