Fix the behavior checklist for a script migration

Review the AI's codeEasy12 minAnthropic and OpenAI style

Your task

An agent is migrating your Bash deploy script to a Python CLI. Twice its rewrite ran the happy path but quietly dropped the rollback on failure and the skip if already deployed guard. Now you list every behavior the old script has, the agent reports what its rewrite does, and a check compares the two.

An assistant wrote missing_behaviors(required, implemented). It is in the editor. It has a bug. Find it and fix it.

Input and output:

  • required: the behaviors the old script has, by name.
  • implemented: what the rewrite reports, one entry per behavior: a name, or a name, = and a status, such as exit-codes=covered.
  • Return one name=dropped or name=untested string per required behavior that is not covered, sorted by name.

Rules the tests check:

  • Read each required name with whitespace trimmed from both ends, in lowercase. Skip empty names and names already seen.
  • Split each implemented entry at its first =. Trim both parts and lowercase both. Skip an entry whose name is empty.
  • A behavior is covered only when some entry has its name and the status covered. Any other status, or no status at all, means the behavior is present but not covered.
  • A required behavior that is not covered is name=untested when present and name=dropped when no entry has its name. Use the lowercase name.
  • Sort by the name alone, as plain strings.

Examples

missing_behaviors(required: list[str], implemented: list[str]) -> list[str]
Example 1
Inputmissing_behaviors(["rollback-on-failure", "skip-if-deployed", "exit-codes"], ["exit-codes=covered", "skip-if-deployed"])
Output["rollback-on-failure=dropped", "skip-if-deployed=untested"]
Example 2
Inputmissing_behaviors(["rollback-on-failure", "skip-if-deployed"], ["Skip-If-Deployed=COVERED", " rollback-on-failure = covered "])
Output[]
Example 3
Inputmissing_behaviors(["deploy", "rollback", "deploy"], [])
Output["deploy=dropped", "rollback=dropped"]