Answer prose round 1: 0 🔴, 5 🟡; count the audit's shares of all 196, say why the expected-values rule is repeated, and fix item 165's mutation claim

This commit is contained in:
2026-10-16 05:44:37 +02:00
parent 8ec835e36b
commit 5725baefab
5 changed files with 14 additions and 14 deletions
+5 -5
View File
@@ -40,15 +40,15 @@
- DTOs, enums, and value objects are pure data — no logic. They stand in for the structs/records a language lacks.
* Always use explicit state machines.
* Most, if not all, code should have automated tests, and each test earns its keep.
- A valuable test checks behaviour through the unit's interface, fails when that behaviour breaks, and passes through a refactor that keeps it.
- A valuable test checks behaviour through the unit's interface, fails when that behaviour breaks, and still passes after a refactor that keeps that behaviour.
- Write the test first and watch it fail on its assertion, not on an error, before implementing.
- Take expected values from the requirement — the item, ticket, spec or a hand-worked example — never from running the code or calling its helpers. A test that records today's output locks in today's bug. BANNED: `assert text.endswith(applications_text(applied))`. GOOD: the expected text written out for one small input.
- Assert the outcome — returned values, stored state, emitted output — not how the code reached it. Use real collaborators or fakes; mock only slow, nondeterministic or external edges. BANNED: asserting which internal function ran, or scanning the source with `ast` or a regex. GOOD: a fake clock, a fake HTTP transport.
- Take expected values from the requirement — the item, ticket, spec or a hand-worked example — never from running the code or calling its helpers. A test that records today's output locks in today's bug. BANNED: `assert text.endswith(applications_text(applied))`, where `applications_text` is the code's own helper. GOOD: the expected text written out for one small input.
- Assert the outcome — returned values, stored state, emitted output — not how the code reached it. Use real collaborators or fakes; mock only slow, nondeterministic or external edges. BANNED: asserting which internal function ran, or scanning the source with `ast` or a regex. GOOD: `assertEqual(saved_row, {...})` against a fake store; a fake clock.
- 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.
- Every escaped bug becomes a test that fails without its fix.
- Skip a test that no real bug could fail: a constant's value, a list's length, the framework's own behaviour.
- Tests take time, randomness and I/O through the same injected seams: no sleeps, no wall-clock asserts, seeded randomness, fixtures built per test.
- Write no test that no real bug could fail: a constant's value, a list's length, the framework's own behaviour.
- No sleeps or wall-clock asserts in a test, and seeded randomness.
- For pure logic over many inputs, prefer a property test: a round trip, an invariant.
- Changing tests and changing other code are two separate processes — be very careful about doing both at once.
- Use properly randomised UUID v7s — never `aaaa-0000`-style placeholders.