# 02: Tracer bullet: Autofill module with Direct Answers, Vital Farms moved onto it

**What to build:** The first version of the Autofill module (the Controller in ADR-0001), proven end to end by moving the Vital Farms Runnable onto it.

**The module**
- It is handed:
  - the Survey, as a dependency,
  - a Store Preset table keyed by Store Number,
  - an ordered list of Answer Preset sets.
- It returns a neverthrow `ResultAsync` of either a run outcome or a configuration error.
- This ticket supports Direct Answers only:
  - a returned value is written to the Survey,
  - `null` gives a Skipped Question,
  - a throw from the preset or from the Survey write gives a failed question.
- An unknown Store returns a configuration error, and nothing is written.

**Question types and answers**
- One question-type union (text, radio, checkbox) is shared by every Runnable.
- Checkbox answers are always a list of strings. Text and radio answers are always a single value, and the types enforce this.
- The module picks the Survey write method from the question type.

**Logging**
- A failed question goes to `console.error`, with its label and cause.
- A Skipped Question goes to `console.log`.
- A summary line with the counts goes at the end.

**Vital Farms**
- The Vital Farms questions and per-Store answers become a numeric-key preset set of Direct Answers, plus a Vital Farms Store Preset table keyed by Store Number.
- A value a Store deliberately leaves out returns `null`, which gives a Skipped Question.
- The Vital Farms Runnable throws when the module returns a configuration error or the outcome has any failed question.
- The old Vital Farms fill-engine is deleted.

Parent spec: `.scratch/autofill-module/spec.md`

**Blocked by:** None (can start immediately)

**Status:** resolved

- [x] neverthrow is added as a runtime dependency and used only inside the Autofill module and as its return type. Answer Presets don't return Results.
- [x] Tests drive the module through its interface with an in-memory Survey stand-in and fixed presets. No DOM environment is added.
- [x] Tested: Direct Answers are written with the Store's preset values.
- [x] Tested: `null` produces a Skipped Question.
- [x] Tested: a preset that throws produces a failed question.
- [x] Tested: a Survey write that throws produces a failed question.
- [x] Tested: unrelated questions are still written after a failure.
- [x] Tested: an unknown Store returns a configuration error with no writes.
- [x] Tested: a checkbox list is written as each choice.
- [x] A list answer on a text or radio question, or a single value on a checkbox question, is a type error.
- [x] The Vital Farms Runnable uses the module. The old Vital Farms fill-engine and its separate question-type list are deleted.
- [x] The Runnable-to-Floating-Action-Bar contract is unchanged. The Vital Farms Runnable throws on a configuration error or any failed question.
- [x] Typecheck and the full test suite pass.

## Comments

Resolved on `feat/autofill-module` in 3143baa (review fixes in 3878798).
