Fix the coverage check for generated setup docs

Review the AI's codeEasy10 min

Your task

An AI agent wrote setup docs for your TypeScript monorepo. On a clean machine, pnpm build failed, because nothing said to copy .env.example to .env and set two keys first. The agent could not see that in the code. Your team now runs the setup in a clean container, writes down every step it really needed, and checks the docs against that list.

An assistant wrote missing_setup_steps(documented_steps, required_steps). It is in the editor. It has a bug. Find it and fix it.

Input and output:

  • documented_steps: the steps the docs give, as written.
  • required_steps: the steps a clean machine really needs.
  • Return the required steps the docs do not cover, in their original order and wording.

Rules the tests check:

  • Normalize a step before comparing: lowercase it, trim it, and turn every run of whitespace inside it into one space.
  • A required step is covered when its normalized text appears inside the normalized text of some documented step. A documented step may wrap the required step in more words.
  • Covering part of a step is not covering it: pnpm build does not cover pnpm build --filter web.
  • Required steps that normalize to the same text are one step. Report it at most once, with its first wording.

Examples

missing_setup_steps(documented_steps: list[str], required_steps: list[str]) -> list[str]
Example 1
Inputmissing_setup_steps(["Clone the repo", "Run pnpm install", "Run pnpm build"], ["clone the repo", "copy .env.example to .env", "set the two required API keys", "run pnpm install"])
Output["copy .env.example to .env", "set the two required API keys"]
Example 2
Inputmissing_setup_steps([], ["install node 20"])
Output["install node 20"]
Example 3
Inputmissing_setup_steps(["Set the TWO required API keys before building"], ["set the two required api keys"])
Output[]