Answer stability round 1: 0 🔴, 1 🟡 (0 misread); keep a blanked row

This commit is contained in:
2026-11-26 10:22:54 +01:00
parent 4b51675596
commit a929e2ccc0
+2 -2
View File
@@ -30,7 +30,7 @@
* Make invalid states unrepresentable.
- Example: using a time-only type in the database when we actually want to store a time of day introduces risk for errors.
- A function's inputs too: take only inputs that cannot disagree, instead of checking that they agree. BANNED: a test helper that takes a token and a message, and checks that the message holds the token. GOOD: the helper makes the token and builds the message. When a review finds a second edge case in a check, change the signature so the input can't occur.
- A data importer's filter on a field reads the value after the importer's fixups for that field, or exempts the rows they fix. BANNED: dropping source rows with an empty `population` before a fixup fills in `population` for one of them. GOOD: apply the fixups, then filter.
- A data importer's filter on a field never drops a row the importer's own fixups complete. A fixup is a hand-written correction to one source row. Filter after applying the fixups, and exempt a row whose fixup leaves the field empty on purpose. BANNED: dropping source rows with an empty `population` before a fixup fills in `population` for one of them. GOOD: apply the fixups, then filter.
* Always store timestamps as full ISO datetime in UTC.
- Always communicate timestamps as full ISO datetime in UTC from APIs with database access.
* Always grant explicit access to data, both read and write.
@@ -56,7 +56,7 @@
- Pin wording only where the wording is the contract: a message a consumer parses, a published format. For prompts, help and error text, assert the facts the text must carry — an item ID, a model argument, an error code — not the sentence. BANNED: `assertIn("<a 600-character prompt sentence>", prompt)`. GOOD: `assertIn("model opus, effort high", prompt)`.
- One behaviour per test, named for it, tested once, at the lowest level that reproduces it. No loops or branches in a test body; parametrize the cases.
- A test doesn't decide at run time whether to check anything: no conditional skip, early return, or catch around its assertions. A test that needs a state creates it, or fails and names what is missing. BANNED: `test.skip(created.every((count) => count === 0))` after the payroll run under test, since a broken payroll also creates zero rows. GOOD: before running the payroll, check each precondition and fail naming the one that is missing; after it, `expect(created).toEqual([1, 2, 1])`.
- A test that scans rows for an exception also asserts that the exception exists, or it passes when the exception is missing. BANNED: looping over every row and asserting that only the row named `X` has an empty cell, which passes when the table has no row `X`. GOOD: collect the rows with an empty cell, then `assertEqual(["X"], collected)`.
- A test that scans rows for the one row that breaks a pattern also asserts that the row exists, or it passes when the row is missing. BANNED: looping over every row and asserting that only the row named `X` has an empty cell. GOOD: collect the names of the rows with an empty cell, then `assertEqual(["X"], names)`.
- Every escaped bug becomes a test that fails without its fix.
- Write no test that no real bug could fail: a constant's value, a list's length, the framework's own behaviour.
- A test neither sleeps nor asserts on the wall clock, and seeds any randomness.