Fix the claim gate for a public incident update

Review the AI's codeEasy10 min

Your task

After a partial outage, leadership wants a short explanation for the public status page. An AI drafted it from the incident timeline and wrote "no data was lost or exposed", which nobody has confirmed. Your team now checks every claim against the incident record before anything is published.

An assistant wrote review_public_claims(claims, confirmed_fact_ids). It is in the editor. It has a bug. Find it and fix it.

Input and output:

  • claims: the draft's claims, each written <text>|<fact id>. The fact id points to an entry in the incident record. It can be empty, and a claim can have no | at all.
  • confirmed_fact_ids: the ids of the facts someone has confirmed.
  • Return one verdict per claim, in order: "publish", "hedge" or "remove".

Rules the tests check:

  • Split a claim at its first |. The text is before it. The fact id is after it, with whitespace trimmed from both ends. With no |, the fact id is empty.
  • A claim is confirmed when its fact id is not empty and is in confirmed_fact_ids exactly. The ids in that list are used as given. A confirmed claim gets "publish", whatever its text says.
  • An unconfirmed claim gets "remove" when its text contains an absolute word: no, none, never, nothing, zero, all or every. Otherwise it gets "hedge".
  • To find the words, lowercase the text and take each run of the letters a to z. Every other character separates words: spaces, digits, hyphens and punctuation. So nothing. and zero-downtime contain absolute words, and November does not.

Examples

review_public_claims(claims: list[str], confirmed_fact_ids: list[str]) -> list[str]
Example 1
Inputreview_public_claims(["A brief networking issue caused some requests to slow down|f1", "No data was lost or exposed|f2"], ["f1"])
Output["publish", "remove"]
Example 2
Inputreview_public_claims(["Requests were slower than usual|"], [])
Output["hedge"]
Example 3
Inputreview_public_claims(["All customer data is safe|f3"], ["f3"])
Output["publish"]