# The feature loop: pick, define, route Status: pick, define and route are built (see "Build order" for what is and is not). Goal: a feature job runs from "which feature next" to a landed generated function with no model call for coordination and none for writing the job definition (`AGENTS.md` → "Decisions that never wait on a person"). The landing end exists (`jobs/scripts/submit.sh`, `jobs/scripts/poll-and-land.sh`); this plan adds the front. Four architectural choices are settled below ("Settled decisions"); every step is built without asking. A new architectural choice found while building stops the work for an answer. ## What exists and is reused | Piece | Anchor | Used for | |---|---|---| | Triage | `crates/generation/src/bin/feature_triage.rs` `main`; record `corpus/-triage.json` (`summary`, `unattributed`, `keys`, `pages`, `engine_commit`) | per-feature pass, fail, which function is implicated, which failures are unattributed | | Feature files | `oracle/suites/features/*.json` (`source`, `pages`, `deny`, `specification`), read by `oracle/suites/feature-pages.mjs` | which WPT pages a feature admits | | Map | `docs/web-features-map.json`, `docs/web-features-map.md` → "Inputs" (pages reach features through `WEB_FEATURES.yml`) | the universe of features and per-key status | | Triage credit | `jobs/src/feature_rules.rs` `triage_verifies`, `evidence_resolves`; `oracle/suites/feature-map-rules.mjs` `triageVerifies` | verification-only credit | | Landing | `jobs/scripts/submit.sh`, `jobs/scripts/poll-and-land.sh`, `bench/land.sh` | send and land a job | | Definitions | `specs/aspect-ratio.md` + `.job.json` (WPT-sourced, the template); `specs/display-contents.*` (generated pages, hand-written case module); `specs/viewport-units.*` (small, no generated function) | template sources | | Score | `docs/wpt-checklayout.md` (`docs/wpt-checklayout-results.json`) | per-directory pass share, as a tie-break | Reading `specs/aspect-ratio.job.json`: apart from the name, every stage is the same for any function that has the four function-specific files below; the per-function values are the `feature_rules` patterns and evidence, the `--resolver` path, `--module`, `--rule`, `--baseline`, the `*_types.rs`/`*_engine.rs`/`*_call_site.txt` paths, the models line, and `limits`. That is why the definition can be filled from a template. ## Piece 1: pick - **Inputs:** `docs/web-features-map.json` features with status `none` or `partial`; the feature's WPT pages (via `WEB_FEATURES.yml`); `corpus/*-triage.json`; `docs/wpt-checklayout-results.json`. - **Output:** `docs/feature-queue.json`, a ranked list: feature, failing pages, attributed pages, unattributed pages, implicated functions, `ready` (every implicated function is job-able, below), reason. - **Rule.** For feature f with triage record t: `score(f) = attributed_failing_pages(f) = fail(t) - unattributed(t)`, counting only pages whose implicated functions are all job-able; ties go to the lower `unattributed / fail`, then to the feature name (the `checkLayout` share of the page's directory is not used yet: a record names pages, not directories). Before that score comes the number of engines shipping the feature (`engines`, 0 to 3, "Engine count and the feature states" below): features all three of Chrome, Firefox and Safari ship rank first, then those two ship, then one. A feature with `unattributed / fail > 0.5` is not ranked; it goes to the hand-written list (piece 3). This is the `AGENTS.md` rule "failing pages most numerous and not blocked on missing hand-written layout" made a formula. The 0.5 threshold is from the measured records: `box-sizing` 3 of 5 and `fit-content` 10 of 10 unattributed. - **Triage must exist before ranking.** For a feature without a record the script builds one: feature file -> `feature-pages.mjs` -> `pages_ground_truth_cache` -> `feature_triage` (the reproduction steps in `docs/feature-to-function-design.md` → "The first piece"). The feature file is derived (settled decision 1) unless one is hand-written. - **A landed feature gets its next job on another function.** A feature's job is open until its current definition has a landing tag; after that the feature is eligible again once its triage record is measured at or after the landing (the scheduled step measures such a record again on a build lane before any untriaged feature, `jobs/scripts/scheduled-triage.sh`; by hand, `feature-loop-step.sh --retriage ` re-measures the records that predate it), and the new job takes the best function other than the landed one and replaces `specs/.md` and `.job.json`. The failing pages of a feature span several generated functions, and rerunning the landed function would replay its cached stages. - **Where it runs:** `bench/on-lane.sh` on a build lane (browser runs and layouts of hundreds of pages), by cron on the development box that calls it, or by hand. No Dagu; it is not a job, it writes a file. **build** for the ranking script given existing records; feature-file derivation is a second **build** step. - **Fails safe:** a feature whose triage cannot run (no usable pages, tree not clean, unmeasured pages) is listed as `skipped` with the reason and never ranked. A stale record (`engine_commit` not an ancestor-or-equal of `main` since a layout change) is rerun, not trusted. Output is rewritten whole; a crash leaves the previous file. ## Piece 2: write the job definition - **Inputs:** the queue's top ready entry; its feature file; the function's `*_types.rs`, `*_engine.rs`, `*_call_site.txt`, runner (`crates/generation/src/*_runner.rs`). - **Output:** `specs/.md` and `specs/.job.json`, the manifest being the short form and the prose filled from the feature file and triage summary, written by a `job-check` subcommand (`new-feature-job`). The manifest must pass `job-check manifest --spec` (`jobs/src/manifest.rs` `validate`) and `crates/harness/tests/spec_lint.rs`; the script runs both and writes nothing if either fails. - **Types stages:** when `crates/layout/src/generated/.inputs.json` exists, the types file is the `types_from_list` tool's output and stays as it is, so the expansion leaves out `types-prompt`, `types-candidates`, `types-keep` and `types-use`, their `corpus/-types-*` folders, and the types file from the prose's `touches` line (`jobs/src/feature_job.rs` `generate_with`; `job-check new-feature-job` looks for the list under its workdir). A model-written types file would replace it and fail to build against the list's `String` and `Vec` fields. The coverage-pages and findings-pages stages stay. `specs/padding.*` and `specs/fit-content.*` (function `height`) have this shape. - **Inputs-list stages:** a single function with no list gets, where the types stages stood, the four stages that design one (`jobs/src/feature_job.rs` `design_stages`): `inputs-prompt` (`jobs/scripts/inputs-prompt.sh`: the prompt's sections are the function's own, from `oracle/suites/input-designer-sections.json`, not the feature's), `inputs-request` (three replies from the candidate model), `inputs-keep` (the replies the validator passes) and `inputs-use` (`jobs/scripts/inputs-use.sh`: the first kept list the call site reads, that builds, and whose inputs check over the job's ground truth has no conflict, written in place with the types, engine values, sources and starting candidate `types_from_list` makes of it). `store` and `admit` carry the list (`--inputs-list`), so a landing commits the list beside the function. Designing a list is feature work, so it runs inside the job on folknet rather than as a structure task: the validator, `types_from_list` and the inputs check judge a list, not a person. A group job keeps its types stages. A list that needs a source the format cannot name or the engine cannot read fails `inputs-keep` or `inputs-use` with `inputs-list gap:` lines, which become a structure task ("Build order" 7). - **Refresh:** each pass of `feature-loop-step.sh --apply` runs `job-check refresh-feature-job` on every definition. One whose function has a list now but whose stages still write types or design a list is written again without them (`jobs/src/feature_job.rs` `refresh`), because a model's types file or a second list would replace the landed list's files. Its short form is read back from the manifest (`short_form_of`), and the definition is rewritten only when that short form expands to exactly the files on disk, so a definition edited by hand or written by an earlier template is left alone. A definition whose function has no list keeps its types stages: rewriting it would change a definition that still runs as written and send it again. The one exception is a designing definition whose `inputs-prompt` still calls `input_designer` on the feature's folder (the template before `inputs-prompt.sh`): it fails at that stage whenever the function's sections are not the feature's, so it is written again with the current command and a paragraph in the prose saying so (`is_earlier_prompt_template`). The prose changes the blob, so the schedule sends the job afresh ("its definition changed since the run"), and `failure-tasks.py` writes no task for a failed run whose recorded `spec_sha` is no longer the definition's blob. - **Findings rounds:** a review `fail` names the inputs the candidate answers wrongly; the findings stages turn them into pages and browser-measured train cases. `findings-pages-keep` measures the model's pages in the three browsers first and records the calls with that geometry pinned (`generation::findings_pages::keep_with`), because the engine lays an unmeasured page out with the function's deliberately wrong starting candidate in its place and every definite height then measures 0. Run `034o7OF9RJ9aTruWFAL52x` of `padding` showed the cost: the pages giving the review's child-height inputs were rejected for 0-tall children, rounds 2 and 3 named the same wrong inputs, and the run used its whole round budget on them and landed on the score bar alone. The keep stage therefore needs the browser oracle, which every lane running a feature job has for the ground-truth stage that follows it; `--no-measure` is only for a run without one. A page's step for a `NaN` value is left out of the prompt altogether: `NaN` is how the engine records `auto`, and `height: NaNpx` is not CSS. - **Triage attribution:** the engine calls `containing_block` before every in-flow box's `width` call only to give `width` an input. The call is recorded as input-only (`crates/layout/src/generated_calls.rs` `InputOnly`), and `feature_triage.rs` `box_calls` leaves such calls out, so a failing in-flow box implicates `width` and not `containing_block`, whose answer the failing measurement does not come from. A call the engine reads its answer from (the one for an out-of-flow box) still counts. A record keeps the functions a page implicates but not the kind of each call, so an earlier record cannot be corrected from what it stores. The tool writes `attribution` (`feature_triage.rs` `ATTRIBUTION`, 2 now; a record without it is 1), and the queue (`feature-queue.mjs` `INPUT_ONLY_SINCE`, `staleImplications`) treats a record of an earlier version that implicates such a function as stale: it routes as skipped, so no job is written or ranked from it, and it is listed in `needs_triage` so the scheduled triage measures it again. A record that never implicated the function is unaffected. A job definition on that function whose record is stale is removed (the loop writes a new one on the function the fresh record picks); a definition on another function stays, because the change only drops `containing_block` from the lists. - **Candidate mode:** the short form may carry `candidate_mode`, `"single-request"` (the default, and byte-identical to a short form without the field) or `"agent"`, with `agent_count` (sessions per round, default 4) and `agent_session_seconds` (default 3600), both only in agent mode. In agent mode the stage names, order, outputs and `on_fail` stay as they are; only the commands of `candidates` and `repair` change, to `jobs/scripts/agent-candidates.sh`. Each session (`jobs/scripts/pi-session.sh`) works in its own folder outside the repository, holding `TASK.md` (the prompt), the specification, types, engine values, call site and current function as files, a copy of the train cases, and a `score.sh` (`jobs/scripts/agent-score.sh`) that compiles its one candidate and scores it over those train cases only. The folder also has `bin/` with the lookup tools (`jobs/agent-tools/`: `spec`, `bcd`, `feature`, `cases`, `engine`), first on the session's `PATH` and named in `TASK.md`, so the session reads the share's webref, browser-compat-data, web-features build and its train cases instead of the job's repository. It leaves its candidate in `candidate/.rs`; the script gathers these into `sources/`, `replies/` and `requests.json`, the layout `bench/repair-loop.sh` and `store-candidate.sh` read. `repair` runs the loop with `--rounds 0`, so the landing bar, held-out scoring and survivors are the pipeline's own. In a rework round each survivor gets a session first. Held-out cases are never copied into a session folder, and the session's shell runs with `corpus/` and the lane archive masked (`bwrap --tmpfs`, else `unshare --user --map-current-user --mount`); the script exits 2 when neither works, rather than run sessions unmasked (`--isolation none` is for tests). The stand-in agent (`jobs/scripts/stand-in-pi`) runs it in `jobs/tests/agent_candidates.rs`. Single-request stays the default. Agent mode on `padding` with `qwen3.8-27b-fast-2` (run `034kvI0G0FYliA8DRGqEvI`, 16 sessions, 8 at a time, 3600 s each) was stopped in its first wave: all 8 sessions ran out their hour, 5 of them with no candidate written, each spending its turns reading the job's repository (`crates/generation/`, `crates/layout/`) rather than its own folder. The `candidates` stage alone needs two such waves, past the 1.5 times allowed against the single-request run `034ksqJPFXPA2SNAfIQBII` (`candidates` 152 s plus `repair` 3377 s), so no score could have made agent mode the default. - **Where it runs:** the development box; it only writes two files and commits them to a track (`track/`) that `bench/land.sh` lands. **build**, once the template is extracted from `aspect-ratio`. - **Fails safe:** refuses (writes nothing, exit 1) when the function is not job-able, a `specs/.*` file exists, the checks fail, or `submit.sh` would refuse (a tag `spec//` exists). Submitting stays `jobs/scripts/submit.sh`, whose refusals are the rest of the guard. Spec text that a person would write (why the feature, scope) is produced from the feature file's `specification` and the triage summary, as plain templated sentences; see "Where a model is still called". - The manifest gains a short form (settled decision 2), so the 540-line stage list is not copied per feature. ## Prompts fit the model's window No model request is sent for being larger than the model's context window. What is left out is whole failing or measured cases, never part of a case, and each stage says so in its log. - **`prompt`** (`model_prompt`, and `types_prompt` for the types prompt): the window is the smallest among the job's models (`model::configured_window`: what the gateway reports for each, else `WEBENGINE_MODEL_WINDOW`, else 131072 tokens). A request may hold `model::prompt_byte_budget(window)` bytes: the window less 32768 tokens for the reply (a third of a window too small for that) and a 2048-token margin, at 3 bytes per token. The `prompt` stage's prompt takes three quarters of that (`model::first_prompt_byte_budget`), because every repair request carries it plus a source and failing cases; the types prompt, which no repair carries, takes all of it. Over its share, cases are left out, spread evenly over the list; the specification, engine description, types and task are always whole. When even one case does not fit, the stage fails naming the sizes. - **`candidates`** (`request_candidates`): sends the stored prompt whole. A prompt over a model's window is reported before the first request, naming the sizes (`prompt_fit::check_whole_prompt`); rebuild it with `prompt`. - **`repair`** (`repair_candidates`): a failing-case request is the prompt, the candidate's source and the failing cases. It is fitted per candidate to the window of the model the candidate is sent to (`prompt_fit::fit_repair_message`): failing cases are kept one of each kind of failure in turn (a panic, a wrong answer, a box off), earliest first, until no more fit, and the message ends its list with how many are not shown. The candidate's source, the prompt and the closing instruction are never left out. The request's record in `requests.json` says in `shown` how many were left out. A candidate whose request cannot fit even with one case is not repaired that round, with the sizes in the log. - **The opening is reused, so it never varies.** Every request of a job opens with the `prompt` stage's file byte for byte: that file is sent unchanged, and nothing per request (a date, an id, a case count) goes before its end (`crates/generation/tests/model_prompt_command.rs` `repair_requests_for_one_job_open_with_the_stored_prompt`). Every rig server a job draws from keeps the computed state of a repeated opening — `PREFIX_CACHE=1` on the Qwen workers, prefix caching in the DeepSeek pair's recipe (`docs/rig-capacity.md` → "Prompt reuse") — so after the first request on a worker, prefill costs only the part after the stored prompt: measured at 56k tokens, 91.3-92.7 s to first token cold and 5.5-5.6 s reused, and at today's 6.6k-token prompts 5.6-5.9 s against 1.5-1.7 s (`docs/model-first-cost.md` → "Prefill reuse across a job's requests"). Two limits a job cannot fix from the client: an alias spread over several workers keeps the opening once per worker, so each worker pays it on its first request after the prompt changed; and a request that reaches a worker while the same opening is still being prefilled there pays for it again rather than reusing it. ## Piece 3: route the triage result Input: `corpus/-triage.json`. Output: one of three, written to `docs/feature-queue.json`. 1. **Every page passes** (`summary.failed == 0`, `unmeasured == 0`): verification-only. The script points the feature's rules in `docs/feature-map.json` at `corpus/-triage.json#` (`triage_verifies` decides; no model, no job). Needs a rule change per key and the `schemaVersion` bump noted in `docs/web-features-map.md`. The credit lands unattended (settled decision 3). 2. **Failures attributed to a generated function** (`summary.by_function`): a function job, piece 2, one per implicated function (a failing page names several, so the order is the function with the most pages first, and the rest are re-triaged after it lands because the first admit can fix the others). Job-able functions only; a feature whose failing pages all implicate functions that cannot take a job yet is `blocked` in the queue, and `readiness` ranks those functions by the pages waiting for each. 3. **Unattributed failures** (`unattributed`): a record in the hand-written list. The list is `docs/hand-written-layout.md`, generated by the same script, one block per feature: failing pages grouped by the record's reason: a value the engine cannot represent reached named functions, or no function decides what fails. A person sees it by opening the file; the queue also counts it. The hand-written file that decides a group is not derived; the group names the functions that were handed the lost value. Fails safe: a page with outcome `unmeasured` is neither pass nor fail and blocks route 1. ## Which functions can take a job A function can take a job when it has an `*_engine.rs`, `*_types.rs`, `*_call_site.txt` and a runner, and its inputs can determine the answer the browsers measured (next subsection). `oracle/suites/feature-queue.mjs` `jobAble` reads both; a function with no inputs-check record is not job-able. The paragraph that follows lists the functions that have the four files (`docs/feature-to-function-design.md` → "Review (2026-10-19)"): `absolute`, `aspect_ratio`, `box_generation`, `containing_block`, `height`, `margin_classify`, `margin_combine`, `width`. The others in `crates/layout/src/generated/` (`float`, `inline_atomic`, `overflow`, `percentage`, `relpos`, `stacking`, `table`, `transform`) are not; `relpos` took about 570 lines on the `physical-properties-job` branch and `height` about 600 (below). Order to make ready: the `readiness` list of `docs/feature-queue.json`, which counts the failing pages waiting for each function. On the records at the intrinsic-size commit and the first derived feature (`padding`) it is `height` and `margin_classify` (21 pages each), `width` (19), `margin_combine` (17), `absolute` and `containing_block` (9 each), `percentage` (2); the earlier guess of `absolute` first is replaced by this list. `height` and `margin_classify` are decided together, so they are likely one track. The cost per function is one engine-values file, one types file, one call-site file and one runner: **build**, one track per function, each landing independently. There is no per-function lock (settled decision 4): the queue holds at most one open job per function, and its `ready` filter keeps every other function off the pipeline. With `height`, `margin_classify`, `margin_combine` and `width` job-able the list started `absolute` and `containing_block` (9 each), and `padding` was the queue's `next`, on `width` (18 pages). With those two job-able as well the list holds `percentage` (2) alone, and `fit-content` (on `absolute`, 5 pages) and `box-sizing` (on `containing_block`, 2 pages) are in `next`. ### The inputs check A function's inputs are drawn from the specification sections that define its answer (for `height`, CSS 2.1 10.6.3, 10.6.7 and 9.4.1: the children's boxes and margins, floats and computed style, all of which a browser exposes). A function whose inputs include another function's answer, or a value no browser measures (the static position, a content height the engine fills from deliberately wrong neighbours), cannot be recovered by any candidate: the same inputs occur with different browser answers. Jobs on `height` and `absolute` ran for hours and closed `no-gain` for this reason. The stage that makes a function job-able therefore reads those sections to choose the inputs, and then runs the check: `cargo run -p generation --bin inputs_check -- --function --cases ...` (`crates/generation/src/inputs_check.rs`) takes the calls the function's page runner shows a model (`function_calls`: every call the engine makes for a box that the prompt lists, the call before a box's children included, each with the inputs the engine passed and the answer the browsers measured), groups them by inputs on the 1/64px grid, and writes `crates/layout/src/generated/.inputs-check.json`: - `conflicts`: the input groups with more than one browser answer (count, calls, and up to five examples with the node, the inputs and the differing answers). Any conflict means the inputs do not determine the answer; the examples are the evidence a redefinition of the function's inputs starts from. Only a call whose answer a browser measures by itself counts: a call with no expected output (the call before a box's children) is listed in `calls` and left out of `answered_calls`. A box the engine asks about more than once shows as separate calls with their own inputs, so calls whose inputs differ fall in separate groups. - Pinned boxes. `height`, `width` and `aspect_ratio` record their calls with every box's width, height and offset held to the browsers' measurement (`layout::pins`, `Free::NOTHING`), the children's pins in place before the parent's call, so a measured input (a parent's width, a child's height) is the browsers' and not a neighbouring function's deliberately wrong answer. Their candidates are scored the same way, call by call (`page_scoring::wrong_call_answers`): each call's answer is compared with the browsers' value for that box (`height`: the content height; `width`: the border-box width less padding and border, and the computed `margin-left` and `margin-right`; `aspect_ratio`: the content width and height). A call with no browser counterpart is skipped, and shows in `calls` but not in `answered_calls`. For `width`: a box whose margins a browser does not report in px or the browsers disagree on, or whose width the vote splits on. Never recorded at all: a float, a box with an `aspect-ratio` (its width is the ratio's), a table whose columns decide its width, and the second `width` call a ratio box makes. For `aspect_ratio`: a box whose width or height the vote splits on, and the call before a box's children. For `width` the records over `corpus/ground-truth` have 1195 calls, all answered. - `answered_calls`, `checkable`: calls with a browser answer, and whether there are any. A function with none (`containing_block`, `margin_classify`, `margin_combine`: a browser measures where boxes end up, not the function's answer; `absolute`, whose runner's answer is the landed function's own) has nothing to compare and is recorded as not checkable. `jobAble` requires the four files and no conflicts. A record with calls but no browser answer (`absolute`, `containing_block`) does not block: such a function is job-able on the four files, as it was before the check. A record with 0 calls (`margin_classify`, `margin_combine`, `table_auto_columns`, `table_grid_rows`) is not job-able: the engine never calls the function on those cases, so no candidate can change a score. The check holds no web rule: it compares recorded inputs with recorded browser answers. There is no lookup-table score: a table keyed on the inputs of one recording and replayed in a layout that changes those inputs is not an upper bound, and replaying under the recording's exact conditions would repeat the conflict count. A function that fails is redefined without a person: before its commit, the scheduled step (`feature-loop-schedule.sh`) runs `jobs/scripts/inputs-redraw-tasks.py`, which writes `jobs/generated-tasks/-inputs.md` for every record with conflicts that has no such file. The spec-watch tick runs it on a remote lane. The task names the function and the specification sections the job definitions crediting it give, lists the record's conflict examples, and tells the writer to hold a measured input to the browser's value in scoring, or to replace another function's answer with the values the sections build it from. It forbids any part of the rule, and it is done when `inputs_check` reports 0 conflicts. A function that needs a value neither computed style nor measured is left to be split, which waits on a person. A task file that exists is never rewritten, so deleting it asks again. This and the stall task ("Build order" 7) are structure tasks generated rather than written by `/spec` (`AGENTS.md` "Two job systems"). The check reports the inputs as the runner records them, so it answers whether the model is shown inputs that determine the answer. Where a runner leaves a neighbour's answer to a deliberately wrong function, the conflict is that function's: `width` frees every box's width (`layout::pins::Free::WIDTH`), so each box's `containing_block_width` is the stand-in's answer for its parent, 0 from the root down, whatever the browsers measured for the parent; `aspect_ratio` shows `content_height_from_children` as laid out by the landed `height` function, 0 for a box whose child has a `height: 100px`. These are the same defect as `height`'s. The redraw is meant to be done by the input designer (`docs/input-designer.md`): a step that writes the function's inputs as data, each from a computed style property or a browser-measured value, checked against a list of known sources. Its list is to feed the types-file step (the types file and the starting candidate are written from it, in a later slice) and then replace the part of `types_prompt` where a model picks inputs from the engine's fixed list of values; until then the two run side by side and `height.inputs.json` is not read by anything else. The record is measured over the cases it was run on; rerun it when the function's types file or the cases change. The check ran over the caches present on the development box: `padding` pages for `height`, the generated corpus for `width`, `box_generation`, `margin_classify` and `margin_combine` (which have no calls there), the `aspect-ratio` pages, `containing-block` and `absolute` corpora. `table_auto_columns` and `table_grid_rows` have no record because no cache with their calls was available, so they are not job-able until one is run. ### What making a function job-able took (`height`) The recipe, in the order the files depend on each other; `relpos` (`git show 34c286ee`) and `aspect_ratio` are the other worked examples. 1. **`_engine.rs`**: `EngineValues`, every value the engine has at the call under one name and type, with a `Needed:` paragraph on the values the specification's rules read (`jobs/src/types_file.rs` `check_needs`) and a `EngineAnswer` with the fields the engine reads from the answer. For `height` these are the six fields every call site has (`layout_box`, the table cell loop, `layout_absolute_box`) plus `min_height` and `max_height` for CSS 2.1 10.7 clamping. Only `layout_box` reads a style, so only it fills the two limits (a percentage resolved against the containing block's height, `None` when there is no definite one, which 10.7 reads as `0` and `none`); the other two sites pass `None`. The limits clamp a definite and an `auto` height alike, and `layout_box` clamps the height it hands its children as their percentage basis. A positive `min-height` stops an `auto` box collapsing its margins through (8.3.1). 2. **`_types.rs`**: the types file the committed function is written against, `Inputs`, `Outputs`, `Resolver`, as the first model-written file would be. `job-check types --engine ` must pass. 3. **`_call_site.txt`**: where the engine calls the function and what it does with the answer, one paragraph per call site. 4. **`.rs`**: re-exports the types, `include!`s the `_inputs_from.rs` that `crates/layout/build.rs` writes (add the function to its `FUNCTIONS`), `call()`, and a baseline that reads the engine's values through a thread-local the way `aspect_ratio::resolve_baseline` does, because a model's types file may not hold what the baseline needs. The committed `generated/.rs` stays as it is when it is written against the types file in place. 5. **`fragment.rs`**: each call site builds the engine values and calls `::call`; the site whose answer is the box's own records a `Call` through `call_recording::record`. Layout does not change (`generated_score_check` and `bench/checklayout-diff.sh`). 6. **`generation/src/_page_runner.rs`**: scores a candidate over measured pages with every other function as landed, and records each call with the browsers' value for the box (`height`: the border box they measured less `edge_tb`). The function's own corpus scorer (`height_runner`) stays for `generated_score_check`. In `candidate_crate.rs` `Seam::` gets a `function_name`, the page runner as its runner and its `function_calls` as `recorder`; `model_prompt.rs` `calls_heading` gets the text that introduces the cases. 7. **The inputs check**: run `inputs_check` for the function (previous subsection) and commit its record. A function whose record has conflicts goes back to step 1 with its inputs redrawn from the specification sections. A function with no per-call browser answer is recorded as not checkable and goes on to step 8. 8. **The queue**: `oracle/suites/feature-queue.mjs` `jobAble` needs the four files (`*_runner.rs` is the corpus runner `height` already had) and the record from step 7. Rerun it and commit `docs/feature-queue.json`. `job-check new-feature-job` for `padding` on `height` first refused, because `feature-queue.mjs` `shortForm` put the specification address in the manifest's `--rule` and a manifest holds no address; `sectionName` writes it as `css-box-4 #paddings`. The generated pair then passes `job-check manifest --spec`. No job was submitted. Not checked by this change: a job's model rewriting `height` against a new types file (the stand-in baseline and the `inputs_from` copy are exercised only against the committed types file), and the cases a job would show (`height_page_runner` has been run on synthetic pages, not on measured `padding` pages). ### What `margin_classify` added to the recipe `margin_classify` followed the steps above (`margin_classify_engine.rs`, `_types.rs`, `_call_site.txt`, `margin_classify.rs`, the `build.rs` entry, `fragment.rs` calling `margin_classify::call` at its three sites through `classify_box`, which also records a `MarginClassifyCall`, and `generation/src/margin_classify_runner.rs` as the page runner with `Seam::MarginClassify` named `margin-classify`). Four things differed. - **The function shared a generated file and a score corpus with `margin_combine`.** One module held `classify` and `combine`, a job writes `generated/.rs` with one `resolve`, and `Resolvers::generated()` has to point at that file or an admitted function would never run. So `classify` moved to `generated/margin_classify.rs` (`resolve`, with its own copy of the provenance record and score floor, 156 of 227) and `generated/margin.rs` keeps `combine`. `generated_score_check` scores `margin_classify` and `margin_combine` (then still `margin`) on the same cache with the same runner, each with the other half as landed, so the two floors hold independently. `margin_combine` was made job-able the same way (next section) and `generated/margin.rs` renamed to `generated/margin_combine.rs`. - **The old names went with the first loop's move.** The generation loop's candidates, fixtures, prompt and runners import `MarginClassifyInputs`/`MarginClassifyOutputs` and `classify_baseline` (all false: nothing collapses) from `margin_classify`; the baseline reads no input, so it needs no engine values. `fragment.rs` imports them from `margin_classify` too; the module `layout::margin` is gone. - **A browser measures no collapsing decision.** `height` has the browsers' box height to compare with; here the browsers give only where boxes end up. `margin_classify_runner` records every box's call with `margin_classify::resolve_reference` (the 8.3.1 rule over the engine's values, through the same thread-local as `height`'s stand-in) and gives a call an expected output only when the page laid out with that rule matches the browsers at every box. A page that does not match shows no expected output and is left out of a prompt, and still scores a candidate through the geometry. - **The call has no single owning site.** Three sites call it for every box with children, so a box is recorded up to once per layout; `record_calls` keeps the last. Checked: `job-check types` on the types file against the engine file; `new-feature-job` for `padding` on `margin-classify` in a scratch directory, then `job-check manifest --spec` on the pair; `cargo test --workspace`. Not checked by this change: a job's model rewriting `margin_classify` against a new types file (the stand-in and the `inputs_from` copy are exercised only against the committed types file); the cases a job would show on measured `padding` pages (the page runner has run on synthetic pages); `job-check types --specification` on the margin-collapsing text (the phrases in the engine file's `Needed:` paragraphs were read off the text, not run against it). ### What `margin_combine` added to the recipe `margin_combine` followed the same steps (`margin_combine_engine.rs`, `_types.rs`, `_call_site.txt`, `margin_combine.rs`, the `build.rs` entry, `fragment.rs` calling `margin_combine::call` through `combine_margins`, which `call_block_flow` in `fragment.rs` hands to `block_flow` as a plain function (at the time, five sites in `stack_children`), `generation/src/margin_combine_runner.rs` as the page runner, `Seam::MarginCombine` named `margin-combine`). Four things differed. - **The input is a list.** One group of adjoining margins has any length, so the engine's struct and the types file's inputs struct borrow it: `MarginCombineEngineValues<'a>` and `MarginCombineInputs<'a>` hold `margins: &'a [f64]`, both with the lifetime named `'a` (`type_text` compares the type as written, so a types file with another lifetime name is refused by `check_names`). `build.rs` writes `inputs_from<'a>` when the inputs struct has a lifetime. Nothing is copied: the call costs one indirect call as before, plus the one check `call_recording::record_with` makes for a running recording. - **The stand-ins read the inputs.** `height`'s and `margin_classify`'s stand-ins read the engine's values through a thread-local because a types file may not hold what they need. Here the one value is the whole job, so `resolve_reference` and `resolve_baseline` read `inputs.margins`, and a types file without it does not build; `job-check types --specification` refuses one while the text says "adjoining margins". - **The old pair stays scorable.** `generation::margin_runner` scores a `classify` and a `combine` together over the recipe corpus (the first generation loop, `generated_score_check`). Both take the job functions' own types (`fn(&MarginCombineInputs) -> MarginCombineOutputs` for `combine`, the engine's `MarginCombineResolver`), so a candidate's `combine` goes into the engine's table of resolvers as it is. The slice-function adapter (`MarginCombineFn`, `with_combine`, `resolve_installed`, `combine_baseline`, `combine_generated`) is gone; the baseline is `margin_combine::resolve_baseline` and the committed function `layout::generated_margin_combine_resolve`. The loop's prompt shows the two types files (`margin_classify_types.rs`, `margin_combine_types.rs`) as the signatures. `generated/margin.rs` (with its provenance record and floor, `generated_score_check`'s `margin` entry) became `generated/margin_combine.rs`. `candidate_crate::Seam::MarginCollapse` keys on `layout::margin_collapse::MarginClassifyResolver` (a label, no such module) as its resolver path so it stays distinct from `Seam::MarginClassify`'s. - **The caption of an expected output follows the function.** `prompt_parts::FunctionCall` has `expected_from`: `Browsers` (the default every function had: "from the box the majority of the browsers measure") or `HandRule` (`margin_classify` and `margin_combine`: "from the engine's hand rule, on a page the browsers lay out the same way"), because no browser measures either answer by itself. `margin_combine_runner` records every group a box asks about, in call order, one call per distinct group of a box; a group of zeros decides nothing and is left out, as `generated_calls` leaves it out. The expected output is the hand rule's answer when the page laid out with the hand rule matches the browsers at every box, as for `margin_classify`. Checked: `job-check types` on the types file against the engine file; `new-feature-job` for `padding` on `margin-combine` in a scratch directory, then `job-check manifest --spec` on the pair; `cargo test --workspace`; `generated_score_check --score margin_combine` and `--score margin_classify` (156 of 227 each, the floors); `bench/checklayout-diff.sh` (no change in any of the 872 pages). Not checked by this change: a job's model rewriting `margin_combine` against a new types file; the cases a job would show on measured `padding` pages (the page runner has run on synthetic pages); `job-check types --specification` on the margin-collapsing text; the layout time of `rendering.html` (the call is no longer than before by construction, not by measurement). ### What `width` added to the recipe `width` followed the same steps (`width_engine.rs`, `_types.rs`, `_call_site.txt`, `width.rs`, the `build.rs` entry, `fragment.rs` calling `width::call` at its two sites in `layout_box_styled`, `generation/src/width_runner.rs` as the page runner, `Seam::Width` named `width`). Four things differed. - **The engine's values are the inputs it already had.** `layout_box_styled` resolved an intrinsic-size keyword on `width`, `min-width` and `max-width` to a length before the call, so `WidthEngineValues` holds the twelve fields `WidthInputs` always had, and the call-site file says a keyword never reaches the function. `Direction` stays in `width.rs` (the absolute and relative-positioning functions import it from there); the engine and types files import it from `crate::width`, and the call-site file shows it beside `LengthPercentageOrAuto`. - **The old name stays, but it needs a call.** `width::resolve_block_width_baseline` is still the baseline resolver the generation loop, `Resolvers::baselines` and the tests pass around, but it now reads the engine's values for the call in progress, as `height`'s does, and panics when called any way but through `width::call`. - **`Seam::Width` changed runner.** The first generation loop's `candidate_crate::write` (`generation_loop`, `real_model_run`) writes `Seam::Width`, so its candidates now run under `width_runner::main`, which lays a page out with every other function as landed; the corpus scorer `generation::runner` still scores `generated_score_check`'s `width` entry with the others at their baselines. The two runners read the same environment (`page_scoring::main`). - **The expected output has three values and one comes from a style.** The browsers' dumps measure a box's width (the vote's `Width`, less the call's padding and border) but no margin; `width_runner` takes `used_margin_left` and `used_margin_right` from the computed `margin-left` and `margin-right` all three dumps give, when each is in px and they agree to within the harness's tolerance. A box with any of the three unsettled shows no expected output. Only the call that decides the box's own width is recorded: not a float's (the engine does not ask), not a table whose columns decide its width, not a box with an `aspect-ratio`, and not the second call a ratio box makes for its margins. Checked: `job-check types` on the types file against the engine file; `new-feature-job` for `padding` on `width` in a scratch directory (it also runs `job-check manifest --spec` on the pair); `cargo test --workspace`-level tests of `layout`, `generation`, `jobs` and `harness`; `generated_score_check --score width` (151 of 227, the floor) and the other three recipe-corpus functions at their floors; `bench/checklayout-diff.sh` (no change in any of the 872 pages). Layout time on `crates/webengine/examples/bench.rs`, release build, fastest of 100 rounds, `main` at `229bb228` against the branch, alternating runs, on a generated page of 10155 nested block elements with auto, fixed, `auto`-margin, border-box and `max-width` boxes: page 7.29 to 7.48 ms on `main`, 7.30 to 7.56 ms on the branch (about +0.5%); the 227-case recipe corpus 1.30 to 1.32 ms on `main`, 1.31 to 1.35 ms on the branch. Not checked by this change: a job's model rewriting `width` against a new types file (the `inputs_from` copy is exercised only against the committed types file); the cases a job would show on measured `padding` pages (the page runner has run on synthetic pages, and the margin values the browsers report for an over-constrained box have not been compared across the three engines); `job-check types --specification` on the 10.3.3 text (the phrases in the engine file's `Needed:` paragraphs were read off `provenance::css21_width::SPEC_TEXT`, not run against it). ### `width` after its input list `width` now takes its inputs from `crates/layout/src/generated/width.inputs.json` (`docs/input-designer.md`, "Wiring: `width`"). Its types, engine values and sources are the `types_from_list` tool's output, and its function is the tool's deliberately wrong starting candidate (every output zero) with a placeholder floor of 0 over the 227 cases, so any candidate that passes one case beats it. A width job reruns this way: - **The definition is rewritten first.** The width job on `main` is `specs/stretch.*` (feature `stretch`, function `width`), written before the list, so it still has the `types-prompt`, `types-candidates`, `types-keep` and `types-use` stages. `types-use` would put a model-written `width_types.rs` over the tool's and fail to build, as the `padding` run did on `height` before `generate_with` left those stages out. Before any resend, the definition is written again from its short form with the list in place: `node oracle/suites/feature-queue.mjs --print short-form stretch width` into a file, then `job-check new-feature-job --workdir `, as `specs/padding.*` and `specs/fit-content.*` were. The change is committed on `main`, since `bench/land.sh` refuses a diff inside `specs/`; the scheduled step (`feature-loop-step.sh`) writes the same shape when it next picks a width feature. - **Nothing restores from the old run.** Every stage that builds the engine lists `crates/layout/src/**` as an input, so the types change invalidates their stage cache, and `inputs-changed.sh` sees a changed stage input: a `no-gain` run or a score-bar landing of the width job is resent by the scheduled step on its own, and a plain `submit.sh stretch` counts as free. - **The prompt and cases change.** The cases show the list's inputs (computed forms, the containing block's width and `direction` from `containing_block`'s answer), recorded with every box pinned to the browsers' geometry; a box with a percentage padding shows no expected output. The repair stage starts from the zero candidate. ### What `absolute` and `containing_block` added to the recipe Both followed the same steps (`absolute_engine.rs`, `containing_block_engine.rs`, the two `_types.rs`, `_call_site.txt` and `.rs` files, two `build.rs` entries, `fragment.rs` calling `absolute::call` at both calls of `layout_absolute_box` and `containing_block::call` in `containing_block_for`, `generation/src/absolute_page_runner.rs` and `containing_block_page_runner.rs` as page runners, `Seam::AbsolutePositioning` named `absolute` and `Seam::ContainingBlock` named `containing-block`). They are two functions, not one: the containing block is chosen once per box at the tree root with the whole ancestor chain, and `absolute` then solves the box against the chosen rect, so the engine's values for `absolute` already hold the containing block's size. Five things differed. - **`absolute`'s engine values are the inputs it already had.** `AbsoluteEngineValues` holds the 25 fields `AbsoluteInputs` always had, under the same names, because `layout_absolute_box` resolves every percentage and every intrinsic-sizing keyword before the call. `Direction` stays in `width.rs`. - **`containing_block`'s input is a borrowed chain.** `ContainingBlockInputs<'a>` holds `ancestors: &'a [AncestorBox]` instead of the `Vec` the first generation loop used, so the call copies nothing (as for `margin_combine`'s list). `Rect`, `AncestorBox` and `ContainingBlockRule` stay in `containing_block.rs`, as `Direction` stays in `width.rs`: `check_names` refuses a struct or enum in a types file, so a type the inputs and outputs name has to live outside it. The call records its box's owned chain through `call_recording::record_with`, which builds the copy only while a recording runs. - **`containing_block` has a hand rule; `absolute` has none.** `containing_block::reference` is CSS 2.1 10.1's four rules (`resolve_reference` as the resolver); its baseline stays the deliberately wrong one (a `fixed` box treated as `static`, no initial containing block fallback) and reads its three inputs directly, so each is marked `Needed:` in the engine file. `absolute` has no correct hand implementation by design (`absolute.rs` module doc), so its baseline reads the engine's values through a thread-local as `height`'s does, and its page runner shows as the expected output the answer of the function as landed, on a page it lays out where the browsers put every box. An expected output for `absolute` therefore changes when a candidate is admitted; `containing_block`'s does not. - **A browser measures neither answer.** `getClientRects` gives a border box, never the offset and margin that add up to its position (nor an `auto` margin), and no containing block at all. Both runners follow `margin_classify_runner`: a call has an expected output only when the page laid out with the stand-in matches the browsers at every box, and `prompt_parts::ExpectedFrom::HandRule` words the caption. For `absolute` the caption is loose, because the stand-in is the landed function, not a hand rule. - **`Seam::AbsolutePositioning` and `Seam::ContainingBlock` changed runner.** The first generation loops (`absolute_generation_loop`, `containing_block_generation_loop` and the `*_real_model_run` binaries) write these two functions' variants, so their candidates now run under the page runners, which lay a page out with every other function as landed; `generated_score_check` still scores the `absolute` and `containing_block` entries through `absolute_runner` and `containing_block_runner` with the others at their baselines. The call-site files describe the two calls per box that `absolute` gets (the first gives the width the children are laid out against, the second, with the content height, is authoritative) and the single call per out-of-flow box that `containing_block` gets. Checked: `cargo test --workspace`; `generated_score_check --score absolute` (100 of 108, the floor) and `--score containing_block` (106 of 106, the floor); `bench/checklayout-diff.sh` (no change in any of the 872 pages). Layout time on `crates/webengine/examples/bench.rs`, release build, 100 rounds, `main` at `376198ac` against the branch, alternating runs, on a generated page of 7204 elements (900 relatively positioned boxes each holding absolute and fixed boxes, auto margins, percentage widths and border-box sizing): page 61.1, 61.9 and 65.2 ms on `main`, 63.5, 60.3 and 61.9 ms on the branch, so the difference is inside the run-to-run spread; the 227-case recipe corpus 1.31 to 1.34 ms on `main`, 1.34 to 1.47 ms on the branch (three runs each; the spread on the branch is wider than a two-call change explains, and it was not re-run on a quiet machine). Not checked by this change: a job's model rewriting either function against a new types file (the `inputs_from` copy is exercised only against the committed types files); the cases a job would show on measured pages (the page runners have run on synthetic pages); `job-check types --specification` on the CSS 2.1 10.1, 10.3.7 and 10.6.4 text (the phrases in the engine files' `Needed:` paragraphs were read off the text, not run against it); no job was submitted for `fit-content` or `box-sizing`. ### What `table_auto_columns` added to the recipe `table_auto_columns` is the first function made job-able that had no admitted function to start from, and the first whose feature pages are not block-only. The files are the recipe's (`table_auto_columns_engine.rs`, `_types.rs`, `_call_site.txt`, `table_auto_columns.rs`, the `build.rs` entry, `fragment.rs` calling `table_auto_columns::call` in `layout_table_children` for every table that does not use the fixed algorithm, `generation/src/table_auto_columns_runner.rs`, `Seam::TableAutoColumns` named `table-auto-columns`). Differences: - **The starting file is a stand-in with no record.** `generated/table_auto_columns.rs` answers with the function's starting candidate and has no provenance record or floor, so `generated_score_check` lists its entry and holds it to nothing until a job's `admit` stage replaces the file (the way `box_generation` was). `Resolvers::generated()` points at the file, which is how an admitted function runs. Without that file `admit` would write one nothing calls. - **The inputs hold lists of the engine's own structs.** `cells: &'a [TableAutoCell]` and `declared_widths: &'a [LengthPercentageOrAuto]` borrow, as `containing_block`'s chain does; `TableAutoCell` lives in `table_auto_columns.rs` because a types file declares no struct but its inputs and outputs. The stand-in reads the engine's values through a thread-local that holds an owned copy (`OwnedValues`), so it works whatever the types file holds; the copy costs one allocation per table. - **A browser measures cells, not columns.** The runner reads a column's width and x off a cell that sits in that column alone, in every cached engine, and shows an expected output only when the engines agree and every column has such a cell. - **The feature's pages are tables.** `oracle/suites/features/table-auto-columns.json` is hand-written (a derived file would have no `allow_elements`): `feature-pages.mjs` takes `allow_elements` (body elements allowed besides the default ones) and `strip_elements` (elements removed with their content, for the `checkLayout` script and the paragraphs that describe a test), and `/css/css-tables/` is in `suites.json` `wpt.sparse`. Of the twelve pages the file names, seven pass the selector today; the rest hold text. Checked: `job-check types` on the types file against the engine file; `job-check new-feature-job` for `table-auto-columns` (it also runs `manifest --spec`); the layout, generation, jobs and dom tests; `node --test oracle/suites/feature-pages.test.mjs`; checkLayout unchanged on all 872 pages. Not checked: any stage of the job past `new-feature-job` (no job was submitted, and `feature-rules`/`feature-map` have not seen the feature name, which is not a web-features id); `job-check types --specification` on the CSS 2.1 17.5.2.2 text (no `Needed:` phrase was read against it); the page runner on measured pages (it has run on synthetic ones); a model rewriting the function against a new types file. ### What `table_grid_rows` added to the recipe `table_grid_rows` followed `table_auto_columns` (`table_grid_rows_engine.rs`, `_types.rs`, `_call_site.txt`, `table_grid_rows.rs`, a stand-in `generated/table_grid_rows.rs` with no record, `generation/src/table_grid_rows_runner.rs`, `Seam::TableGridRows` named `table-grid-rows`, `oracle/suites/features/table-grid-rows.json` of nine selected pages). It is called second, after every cell is laid out at its columns' width, so a call's cell heights depend on the columns function as landed; the runner records with that function as it ships and the rows stand-in. The browsers' answer is read off the `tr` boxes, so a table with a generated row or a caption shows no expected output. Checked and not checked as for `table_auto_columns`. ## Shipped features only The loop writes or sends a feature job only for a feature at least one of Chrome, Firefox or Safari ships. Browsers measure the cases a job scores against, so a feature no browser ships has nothing to measure; and a draft feature's text moves too much to implement. **Where the data comes from.** `oracle/suites/shipped.mjs` reads web-features data through `oracle/suites/web-features-data.mjs`, the one reader the web-features map shares: the share's fresh build (`/web-features/data.json`, built from the head of the web-features repository's forge mirror by `bench/nas-refresh.sh web-features`, `docs/infrastructure.md` -> "web-features data") when `WEBENGINE_LANE_SHARED` has one, else the `web-features` npm package pinned in `oracle/package-lock.json`. Fresh data matters here: a feature a browser has just released must not wait for a lockfile bump. The per-feature `status.support`, and `status.by_compat_key[].support`, are derived from MDN's browser-compat-data and name a browser only for a released version, never `false`, `null`, a preview or a flag; browser-compat-data is therefore read through web-features, with no checkout of its own. The feature ids of the queue are web-features ids, so no mapping through specification addresses is needed. Each pass logs which source and version it used (`feature-queue.mjs` writes `shipping data web-features