project-brain 0.22.4 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +1 -1
  2. package/package.json +6 -6
  3. package/templates/skills/brain-audit/SKILL.md +191 -8
  4. package/templates/skills/brain-audit/references/abuse.md +34 -24
  5. package/templates/skills/brain-audit/references/accessibility.md +41 -21
  6. package/templates/skills/brain-audit/references/ai.md +28 -18
  7. package/templates/skills/brain-audit/references/analytics.md +73 -0
  8. package/templates/skills/brain-audit/references/api.md +27 -17
  9. package/templates/skills/brain-audit/references/backend.md +24 -16
  10. package/templates/skills/brain-audit/references/complexity.md +30 -17
  11. package/templates/skills/brain-audit/references/concurrency.md +28 -19
  12. package/templates/skills/brain-audit/references/consistency.md +32 -24
  13. package/templates/skills/brain-audit/references/contract-drift.md +30 -19
  14. package/templates/skills/brain-audit/references/cost.md +35 -24
  15. package/templates/skills/brain-audit/references/cross-surface-parity.md +70 -0
  16. package/templates/skills/brain-audit/references/database.md +42 -24
  17. package/templates/skills/brain-audit/references/dependencies-licensing.md +34 -23
  18. package/templates/skills/brain-audit/references/design-system.md +99 -0
  19. package/templates/skills/brain-audit/references/devops.md +38 -24
  20. package/templates/skills/brain-audit/references/documentation.md +35 -23
  21. package/templates/skills/brain-audit/references/failure.md +33 -21
  22. package/templates/skills/brain-audit/references/feature-flags.md +87 -0
  23. package/templates/skills/brain-audit/references/flow-integrity.md +58 -33
  24. package/templates/skills/brain-audit/references/frontend.md +36 -19
  25. package/templates/skills/brain-audit/references/functional.md +38 -17
  26. package/templates/skills/brain-audit/references/future.md +32 -12
  27. package/templates/skills/brain-audit/references/goal.md +19 -12
  28. package/templates/skills/brain-audit/references/i18n.md +37 -23
  29. package/templates/skills/brain-audit/references/idempotency.md +76 -0
  30. package/templates/skills/brain-audit/references/infrastructure.md +31 -22
  31. package/templates/skills/brain-audit/references/mobile.md +32 -23
  32. package/templates/skills/brain-audit/references/multi-tenancy.md +74 -0
  33. package/templates/skills/brain-audit/references/numeric.md +70 -0
  34. package/templates/skills/brain-audit/references/observability.md +36 -21
  35. package/templates/skills/brain-audit/references/packaging.md +27 -19
  36. package/templates/skills/brain-audit/references/performance.md +48 -21
  37. package/templates/skills/brain-audit/references/privacy.md +39 -25
  38. package/templates/skills/brain-audit/references/product.md +31 -12
  39. package/templates/skills/brain-audit/references/prompt-spec-gap.md +25 -18
  40. package/templates/skills/brain-audit/references/reachability.md +28 -20
  41. package/templates/skills/brain-audit/references/repo-history.md +65 -0
  42. package/templates/skills/brain-audit/references/runtime.md +83 -0
  43. package/templates/skills/brain-audit/references/scalability.md +35 -22
  44. package/templates/skills/brain-audit/references/security.md +50 -33
  45. package/templates/skills/brain-audit/references/state-model.md +73 -0
  46. package/templates/skills/brain-audit/references/supply-chain.md +64 -0
  47. package/templates/skills/brain-audit/references/temporal.md +66 -0
  48. package/templates/skills/brain-audit/references/testing.md +49 -24
  49. package/templates/skills/brain-audit/references/tooling-baseline.md +77 -0
  50. package/templates/skills/brain-audit/references/type-safety.md +68 -0
  51. package/templates/skills/brain-audit/references/versioning-compatibility.md +33 -22
  52. package/templates/skills/brain-audit/references/visual-design.md +89 -0
  53. package/templates/skills/brain-audit/references/web-metadata.md +72 -0
@@ -4,41 +4,58 @@ Client-side structure and correctness. Gate: a UI framework was detected.
4
4
 
5
5
  Family B does the wiring work — orphan handlers and the loading/empty/error triad live in `flow-integrity.md`. Do not duplicate them here; cross-reference.
6
6
 
7
+ Three modules split the UI between them, and the boundary is what each one is asking about a component:
8
+
9
+ | Question | Module |
10
+ |---|---|
11
+ | Is it built correctly? — state ownership, effects, fetching, keys, bundle | `frontend.md` (here) |
12
+ | Do its values come from one vocabulary? — tokens, scales, variants, theming | `design-system.md` |
13
+ | Does it read correctly? — hierarchy, rhythm, state treatment, responsive behaviour | `visual-design.md` |
14
+
15
+ Duplicated component *structure* is a finding here. The *values that have diverged* between those duplicates belong to `design-system.md`. Report each once, in its own module, and cross-reference.
16
+
7
17
  ## Component structure
8
18
 
9
- - [ ] Components separate what they show from where the data comes from. A component that fetches, transforms, and renders has three reasons to change.
10
- - [ ] No component is large enough that its responsibilities cannot be named in one sentence. Find the biggest ones via `repo_map`.
11
- - [ ] Shared UI is shared, not copy-pasted. `search_code` a distinctive class name or string from a component to find its duplicates.
12
- - [ ] Props are typed, and optional props have defaults at one place rather than at each call site.
19
+ - [ ] Components separate what they show from where the data comes from. Read the component: does it call `fetch`/a query hook, transform the result, *and* render markup, all in one file? That is three reasons to change. Rule out: a container component whose only job is composing children is not a violation — the smell is business logic mixed with render, not composition itself.
20
+ - [ ] No component is large enough that its responsibilities cannot be named in one sentence. `repo_map` ranks files by centrality; open the top-ranked component files and check their size and hook count — read the file to confirm the smell before reporting, since size alone is a signal, not proof.
21
+ - [ ] Shared UI is shared, not copy-pasted. `search_code` a distinctive class string or markup shape from a button, card, or modal — duplicate hits are the finding. Rule out a repeated utility-class combination that Tailwind encourages; the finding is duplicated *structure*, not a repeated class string alone.
22
+ - [ ] Props are typed, and optional props default in one place. `find_symbol` the component to read its prop type, then `search_code` the prop name at its call sites — a default repeated at each call site instead of declared once in the component means every call site can drift from the others.
13
23
 
14
24
  ## State
15
25
 
16
- - [ ] Each piece of state has one owner. State duplicated in two places will diverge.
17
- - [ ] Server data and UI state are distinguishable. Caching server data in the same store as ephemeral UI flags makes invalidation guesswork.
18
- - [ ] Derived values are derived, not stored alongside their source.
19
- - [ ] Global state holds only what genuinely needs to be global. Check `find_callers` on each store selector — a global read by one component is local state in the wrong place.
26
+ - [ ] Each piece of state has one owner. `search_code` the state's field name across the codebase — the same data held in a local `useState` and in a global store at once will diverge the moment one updates without the other.
27
+ - [ ] Server data and UI state are distinguishable. `search_code` the data-fetching hook (`useQuery`, `useSWR`, or the project's own) and check whether its result is copied into the same store slice as ephemeral flags (`isOpen`, `activeTab`) — mixing them makes invalidation guesswork.
28
+ - [ ] Derived values are derived, not stored alongside their source. Read the store/reducer for a field whose value is always some function of another field in the same store (a count, a filtered list, a total) — if it is set explicitly rather than computed, it goes stale the moment one update path forgets it.
29
+ - [ ] Global state holds only what genuinely needs to be global. `find_callers` on each store selector — a selector read by exactly one component is local state living in the wrong place. Rule out a selector called from multiple sibling instances of the same component; that is legitimately shared.
20
30
 
21
31
  ## Data fetching
22
32
 
23
- - [ ] Requests are cancelled or ignored when the component unmounts. Otherwise a late response writes to a dead component.
24
- - [ ] Nothing fetches in a render path.
25
- - [ ] Refetch and invalidation rules are explicit. "It updates on reload" is a defect if the user expects it sooner.
26
- - [ ] Waterfall requests — a fetch whose input comes from a previous fetch's output — are intentional, not accidental.
33
+ - [ ] Requests are cancelled or ignored on unmount. `search_code` for the fetching effect and check for an `AbortController`/cleanup return, or confirm the query library (React Query, SWR) handles this by default — a raw `fetch` inside `useEffect` with neither is a late response writing to a dead component.
34
+ - [ ] Nothing fetches in a render path. `search_code` for the HTTP client call (`fetch(`, `axios.`) and read the call site — one sitting directly in a component body, outside any effect, handler, or loader, re-fires on every render.
35
+ - [ ] Refetch and invalidation rules are explicit. `search_code` the mutation hooks and check each one either calls the cache's invalidate/refetch or documents why it does not — a mutation with neither leaves stale data on screen until the next full reload.
36
+ - [ ] Waterfall requests — a fetch whose input comes from a previous fetch's output — are intentional, not accidental. `search_code` for nested `await` calls inside one async function or effect; two independent fetches sequenced only by code order, with no real data dependency between them, is wasted latency.
27
37
 
28
38
  ## Rendering correctness
29
39
 
30
- - [ ] List keys are stable identities, not array indices.
31
- - [ ] Effects declare every dependency they read, and none they do not.
32
- - [ ] No layout shift from content that arrives late — reserved space or a skeleton.
33
- - [ ] Forms are controlled consistently; a mix of controlled and uncontrolled inputs in one form is a bug waiting for a reset.
40
+ - [ ] List keys are stable identities, not array indices. `search_code` for `key={index}` or `.map((item, index)` feeding `index` into `key` — stable only if the list is never reordered, filtered, or spliced; confirm that before excusing it.
41
+ - [ ] Effects declare every dependency they read, and none they do not. `search_code` for `eslint-disable-next-line react-hooks/exhaustive-deps` — each suppression is a self-admitted gap; read what the effect references against its dependency array.
42
+ - [ ] No layout shift from content that arrives late. Read the component's loading branch against its loaded branch — a loading branch that does not reserve the same space (a skeleton, a fixed `min-height`/`aspect-ratio`) as the loaded content is a confirmed CLS defect, not a guess.
43
+ - [ ] Forms are controlled consistently. `search_code` the form component for a mix of `value={}`/`onChange` on some fields and `defaultValue`/an uncontrolled ref on others in the same form — the mix is the defect, not either style alone.
34
44
 
35
45
  ## Assets and bundle
36
46
 
37
- - [ ] Images have dimensions and a modern format; nothing ships a 4 MB PNG as a thumbnail.
38
- - [ ] Large dependencies are justified. Check the manifest against what is actually imported — cross-reference `Dependencies & Licensing`.
39
- - [ ] Code splitting exists at route boundaries if the app has routes.
47
+ - [ ] Images declare dimensions and use a modern format. `search_code` for `<img`/`<Image` tags with neither `width`/`height` attributes nor a CSS aspect-ratio, and check the served file extensions against `.webp`/`.avif` availability.
48
+ - [ ] Large dependencies are justified. Read the manifest from `get_architecture`, then `search_code` each heavy package's import sites — a dependency pulled in for one helper in one file is a candidate for inlining; cross-reference `Dependencies & Licensing` for the licensing angle.
49
+ - [ ] Code splitting exists at route boundaries if the app has routes. `search_code` for `lazy(`, `dynamic(`, or the framework's route-level split convention — a route table importing every page eagerly ships the whole app on first load.
40
50
  - [ ] Unused assets are reported under `Reachability`, not here.
41
51
 
52
+ ## Out of static reach
53
+
54
+ - Actual re-render counts and effect firing order at runtime — a dependency array can look correct in source and still over-fire in practice.
55
+ - Real bundle size and per-chunk output — the manifest and import graph show what is *possible* to split, not what a bundler analysis would measure.
56
+ - Whether an unmounted-component write actually happens — the race depends on response timing, not just the presence or absence of cleanup.
57
+ - Actual network waterfall duration and perceived loading performance.
58
+
42
59
  ## Severity guidance
43
60
 
44
61
  | Situation | Severity |
@@ -4,36 +4,57 @@ Does the software actually do what it claims to do? This module audits behaviour
4
4
 
5
5
  ## Claimed vs. real behaviour
6
6
 
7
- - [ ] Every capability the README/docs advertise exists in code. Confirm with `search_code` on the feature's name, then `find_symbol` on what it points at. A documented feature with no implementation is `High`.
7
+ - [ ] Every capability the README/docs advertise exists in code. `search_code` the feature's name or the exact phrase used in the doc, then `find_symbol` on what it points at. A documented feature with no implementation is `High`.
8
8
  - [ ] Every CLI command, flag, subcommand, or public entry point listed in docs is reachable from the real dispatcher. Confirm with `trace_path` from the entry point to the handler.
9
- - [ ] The inverse: capabilities that exist in code but appear in no doc. Undocumented ⇒ nobody uses it ⇒ candidate for the Reachability module.
10
- - [ ] Names do not lie. A function called `validateUser` that only checks non-null, a `cache` that never evicts, a `retry` with one attempt. Naming drift is `Medium` — it misleads every future reader.
9
+ - [ ] The inverse: capabilities that exist in code but appear in no doc. `search_code` the exported symbol or command string across the docs directory — zero hits confirms it. Rule out: deliberately unlisted internal/admin command, or a feature shipped behind a flag pending announcement. Undocumented and unruled-out ⇒ candidate for the `Reachability` module.
10
+ - [ ] Names do not lie. `find_symbol` the function, then read its body against its name: a `validateUser` that only checks non-null, a `cache` that never evicts, a `retry` with one attempt. Naming drift is `Medium` — it misleads every future reader.
11
11
 
12
12
  ## Input handling
13
13
 
14
- - [ ] Each public entry point states what it accepts and rejects the rest. Missing validation at a trust boundary escalates to the Security module.
15
- - [ ] Boundary values are handled: empty string, empty collection, zero, negative, max int, unicode, very long input.
16
- - [ ] Optional parameters have a defined default, and the default is the safe one.
17
- - [ ] Malformed input produces an actionable error, not a stack trace and not silence.
14
+ - [ ] Each public entry point states what it accepts and rejects the rest. `find_symbol` the entry point and read its parameter validation. Missing validation at a trust boundary escalates to the `Security` module.
15
+ - [ ] Boundary values are handled: empty string, empty collection, zero, negative, max int, unicode, very long input. Read the validation function's guard clauses — an entry point with none of these is the finding, not each missing case individually.
16
+ - [ ] Optional parameters have a defined default, and the default is the safe one. `find_symbol` the signature; a parameter typed optional with no explicit default is the finding.
17
+ - [ ] Malformed input produces an actionable error, not a stack trace and not silence. `search_code` the entry point's error path (try/catch, `Result`, error return). Rule out a global error-handler/middleware that catches upstream of this function before reporting silence — check its behaviour too, not just the local absence. Whether the resulting message reads as actionable to a real user is out of static reach.
18
18
 
19
19
  ## Output correctness
20
20
 
21
- - [ ] Return shapes are consistent across the success paths of the same function. A function returning `T | null | undefined | []` for "nothing" has three ways to be wrong at every call site.
22
- - [ ] Errors are distinguishable from valid empty results. `find_callers` returning `[]` must not mean the same thing as "lookup failed".
23
- - [ ] Side effects match the name: a function named as a query does not mutate.
21
+ - [ ] Return shapes are consistent across the success paths of the same function. `find_symbol` the function and read every `return`. A function returning `T | null | undefined | []` for "nothing" has three ways to be wrong at every call site.
22
+ - [ ] Errors are distinguishable from valid empty results. `find_callers` the function, then read one call site: can it tell "empty" from "failed" without inspecting an exception?
23
+ - [ ] Side effects match the name: `find_symbol` a function named as a query (`get`, `list`, `find`, `is`) and read its body for writes. Rule out an internal memoisation/cache write that has no externally observable effect — that is not the side effect this check targets. A query that mutates externally visible state is `Medium`.
24
24
 
25
25
  ## State and idempotency
26
26
 
27
- - [ ] Operations advertised as idempotent actually are — running twice produces the same end state. Test it, do not assume it.
28
- - [ ] Re-entrant / re-run paths (setup, init, sync, migrate) preserve existing user data rather than clobbering it, unless overwrite is the documented contract.
29
- - [ ] Partial failure leaves recoverable state — no half-written config, no orphaned rows, no lock left held.
27
+ - [ ] Operations advertised as idempotent have a static marker that would make them so: an upsert instead of an insert, a check-before-write, an idempotency key threaded through the call. `find_symbol` the operation and read for one of these. Rule out dedup enforced by a caller outside this function (a queue consumer, an API gateway) before reporting its absence as a gap. Its absence with no such caller-side guarantee, on an operation the docs call idempotent, is the finding — whether it actually converges under a real re-run is execution, and belongs to `Out of static reach`.
28
+ - [ ] Re-entrant / re-run paths (setup, init, sync, migrate) preserve existing user data rather than clobbering it, unless overwrite is the documented contract. `find_symbol` the entry point and read for an existence check before the write.
29
+ - [ ] Partial failure leaves recoverable state — no half-written config, no orphaned rows, no lock left held. `search_code` a lock/file acquire in the same function and confirm every return path releases it. Rule out a release in a `finally`/`defer` before reporting a leak.
30
30
 
31
31
  ## Behavioural gaps
32
32
 
33
- - [ ] For each core feature, list what a user would reasonably expect that is absent. Missing cancel, missing undo, missing dry-run, missing list/inspect for something the tool creates.
34
- - [ ] Every "create" has a matching way to see and remove what was created — or the omission is documented as deliberate.
35
- - [ ] Configuration that can be set can also be read back and reset.
33
+ - [ ] For each core feature, list what a user would reasonably expect that is absent — missing cancel, undo, dry-run, list/inspect for something the tool creates. Anchor each to the entry-point file that would need to grow it; cross-reference `product.md`'s onboarding path.
34
+ - [ ] Every "create" has a matching way to see and remove what was created, or the omission is documented as deliberate. `search_code` the resource name alongside `create`/`delete`/`list` verbs — a verb with no counterpart is the finding.
35
+ - [ ] Configuration that can be set can also be read back and reset. `find_callers` the config setter and confirm a getter and a reset/clear path exist in the same module.
36
36
 
37
37
  ## Evidence discipline
38
38
 
39
- Every finding here cites `file:line`. "This feature seems incomplete" without a line reference is not a finding — it is a hypothesis. Downgrade its confidence and say what you would need to confirm it.
39
+ Follow the Evidence Contract in `SKILL.md` — every finding here declares its tier and cites `file:line`. "This feature seems incomplete" with no probe run against it is `inferred` at best, and caps at `Medium` regardless of how serious it looks.
40
+
41
+ ## Out of static reach
42
+
43
+ - Whether an idempotent-looking operation actually converges when re-run concurrently, or only when re-run serially.
44
+ - Whether an "actionable" error message reads as actionable to an actual user, versus merely present in the return type.
45
+ - Runtime boundary-value behaviour — does the empty-string path really take the branch the code implies.
46
+ - Partial-failure recovery under a real crash mid-write, as opposed to the presence of a release path in source.
47
+
48
+ ## Severity guidance
49
+
50
+ | Situation | Severity |
51
+ |---|---|
52
+ | Documented capability with no implementation | High |
53
+ | Entry point in docs unreachable from the real dispatcher | High |
54
+ | Missing validation at a trust boundary | High (escalate to Security) |
55
+ | Naming drift — behaviour contradicts the name | Medium |
56
+ | Query function with externally visible side effects | Medium |
57
+ | No idempotency marker on an operation documented as idempotent, and no caller-side dedup | Medium |
58
+ | Lock/resource with an unreleased path on some return | Medium |
59
+ | Undocumented capability, exclusions ruled out | Low |
60
+ | Missing read/remove counterpart to a create | Low |
@@ -4,28 +4,48 @@ What will hurt six months from now? This module is forward-looking, which makes
4
4
 
5
5
  ## Extension points
6
6
 
7
- - [ ] Where the project clearly expects to grow (new providers, new commands, new file types), is adding one a single-file change or a shotgun edit? Use `find_callers` on the dispatcher to count the places a new case must be registered.
8
- - [ ] Hardcoded lists that will need an entry per future addition — a switch, a `Set` of names, a manual manifest. Not automatically wrong; a hand-maintained list guarded by a parity test is often better than codegen. Flag the ones with no guard.
9
- - [ ] Interfaces with exactly one implementation. Either the abstraction is speculative, or a second implementation is coming and the seam is real. Say which you think it is.
7
+ - [ ] Where the project clearly expects to grow (new providers, new commands, new file types), is adding one a single-file change or a shotgun edit? `find_callers` on the dispatcher/registry to count the places a new case must be registered.
8
+ - [ ] Hardcoded lists that will need an entry per future addition — a switch, a `Set` of names, a manual manifest. `search_code` the list/switch, then `find_callers` it to check whether a parity test asserts it stays in sync with any sibling list. Not automatically wrong; flag the ones with no guard.
9
+ - [ ] Interfaces with exactly one implementation. `search_code`/`find_callers` the interface name for implementing classes. Rule out a test-only mock or stub before counting it as the second implementation. Exactly one real implementation means either the abstraction is speculative or a second is coming — say which you think it is, and why.
10
10
 
11
11
  ## Scaling assumptions
12
12
 
13
- - [ ] Loops and data structures that assume small N. Find them, then check what actually bounds N — a config value, user input, or nothing.
14
- - [ ] Anything loaded fully into memory: whole files, whole tables, whole directories. State the input size at which it breaks.
15
- - [ ] Synchronous work on a path that will eventually be called in a loop.
13
+ - [ ] Loops and data structures that assume small N. `search_code` for an unbounded loop over a collection loaded in full — no pagination, no cursor, no `LIMIT`. Read what actually bounds N: a config value, user input, or nothing.
14
+ - [ ] Anything loaded fully into memory: whole files, whole tables, whole directories. `search_code` for `readFile`/`SELECT *`/`readdir` with no streaming or pagination counterpart. State the input size at which it breaks.
15
+ - [ ] Synchronous work on a path that will eventually be called in a loop. `find_callers` the synchronous function. Rule out a caller whose own loop bound is small and fixed (an enum, a constant-size config) before flagging it — that is present-tense, not future.
16
16
 
17
17
  ## Lock-in
18
18
 
19
- - [ ] Dependencies on a specific vendor, model, API version, or file format, with no adapter layer. Note the switching cost.
20
- - [ ] Data formats written to disk with no version field. Migrating them later means guessing.
21
- - [ ] Persisted state whose schema has no migration path.
19
+ - [ ] Dependencies on a specific vendor, model, API version, or file format, with no adapter layer. `search_code` the vendor SDK import, then `find_callers` it to check whether call sites route through one seam or are scattered directly through the codebase. Note the switching cost either way.
20
+ - [ ] Data formats written to disk with no version field. `find_symbol` the serialisation function and read the written shape for a `version`/`schema` key. Migrating them later means guessing.
21
+ - [ ] Persisted state whose schema has no migration path. `search_code` a migrations directory or schema-versioning table; its absence next to a persisted, evolving shape is the finding.
22
22
 
23
23
  ## Deprecation debt
24
24
 
25
- - [ ] APIs, flags, or config keys kept for backwards compatibility with no removal date and no deprecation warning. They will be kept forever by default.
26
- - [ ] Duplicated code paths where one is "the old way" — check with `find_callers` whether the old way still has callers. If not, it is dead (report under `Reachability`); if yes, the migration is unfinished.
27
- - [ ] Pinned dependency versions with a comment explaining a workaround. Verify the workaround is still needed.
25
+ - [ ] APIs, flags, or config keys kept for backwards compatibility with no removal date and no deprecation warning. `search_code` for `deprecated` in comments/docstrings and check each for a stated removal version or date. Absence means it will be kept forever by default.
26
+ - [ ] Duplicated code paths where one is "the old way" — `find_callers` the old path. If it still has callers, the migration is unfinished; if not, it is dead and belongs to `Reachability`, not here.
27
+ - [ ] Pinned dependency versions with a comment explaining a workaround. `search_code` the pin in the manifest and read the adjacent comment. Verify, where a linked issue exists, whether it is still open before assuming the workaround is stale.
28
28
 
29
29
  ## What NOT to report here
30
30
 
31
31
  Speculative refactors, "this could be more generic", and architecture preferences with no concrete future cost. If you cannot name the change that will be painful and the code that makes it painful, it is not a finding — it is taste.
32
+
33
+ ## Out of static reach
34
+
35
+ - Whether an extension point will actually be exercised again, versus built once and never revisited.
36
+ - Whether a switching cost for a locked-in vendor is tolerable to the team — that is a business judgement, not a structural one.
37
+ - The actual size N a scaling assumption breaks at under production traffic, as opposed to the shape of the code.
38
+ - Whether a pinned dependency's linked workaround issue has since been fixed upstream, when the repo carries no link to check.
39
+
40
+ ## Severity guidance
41
+
42
+ | Situation | Severity |
43
+ |---|---|
44
+ | Extension requires a shotgun edit across many files with no registry | Medium |
45
+ | Unbounded loop or full-memory load with no stated bound | Medium |
46
+ | Vendor/format lock-in with no adapter seam | Medium |
47
+ | Persisted format with no version field or migration path | Medium |
48
+ | Deprecated API/flag with no removal date | Low |
49
+ | Duplicated "old way" path confirmed dead | Low (report under Reachability) |
50
+ | Hardcoded list with no parity guard | Low |
51
+ | Pinned dependency workaround unverified as still needed | Low |
@@ -5,33 +5,40 @@ Does the code still serve the goal it was written for? Codebases drift: the goal
5
5
  ## Stated goal
6
6
 
7
7
  - [ ] Locate the goal as written — README opening, package description, ADRs, design docs. `search_code` the project name; `search_context` for "purpose" or "why".
8
- - [ ] If two sources state different goals, that contradiction is a `Medium` finding on its own. Pick neither; report both.
9
- - [ ] If no source states a goal, say so plainly. A project whose purpose exists only in someone's head cannot be onboarded onto.
8
+ - [ ] If two sources state different goals, `search_code` each source's exact goal phrase to confirm both are current — rule out one being superseded by a changelog, deprecation note, or newer doc before calling it a live contradiction. A genuine contradiction is a `Medium` finding on its own. Pick neither; report both.
9
+ - [ ] If no source states a goal, `search_code` "purpose", "goal", "mission" across the repo root and docs directory to confirm the absence rather than assume it. A project whose purpose exists only in someone's head cannot be onboarded onto.
10
10
 
11
11
  ## Goal vs. architecture
12
12
 
13
- - [ ] The architecture serves the stated goal. A local-first tool with a hard cloud dependency, a "simple" tool with a plugin system, a "fast" tool with a synchronous network call on the hot path — each is a goal/structure mismatch.
14
- - [ ] The highest-PageRank symbols from `repo_map` sit on the goal's critical path. If the center of the call graph is infrastructure rather than the core job, the project may have drifted into building a framework.
15
- - [ ] Constraints implied by the goal are actually enforced. "Offline-capable" ⇒ find the network calls and check each has a degraded path. "Zero-config" ⇒ count required config keys.
13
+ - [ ] The architecture serves the stated goal. `get_architecture` for the dependency list: a local-first tool with a hard cloud SDK dependency, a "simple" tool with a plugin system, a "fast" tool with a synchronous network call on the hot path — `find_callers` the hot-path function to confirm it is actually on a called-often path before flagging it. Each confirmed mismatch is a goal/structure defect.
14
+ - [ ] The highest-PageRank symbols from `repo_map` sit on the goal's critical path. If the centre of the call graph is infrastructure rather than the core job, the project may have drifted into building a framework.
15
+ - [ ] Constraints implied by the goal are actually enforced. "Offline-capable" ⇒ `search_code` the network-client import and check each call site has a degraded/cached path. "Zero-config" ⇒ `search_code` required config reads and count the keys with no default.
16
16
 
17
17
  ## Goal vs. scope
18
18
 
19
- - [ ] Features that serve no stated goal. Not automatically wrong, but each needs a reason — otherwise it is scope that will need maintenance forever.
20
- - [ ] Goals with no supporting feature. The stated ambition nothing implements. This is usually the more expensive direction.
21
- - [ ] Abandoned directions: half-built subsystems, feature flags never turned on, TODOs older than the last major refactor. Cross-check with `Reachability`.
19
+ - [ ] Features that serve no stated goal. `find_callers` each major feature's entry point and check whether its purpose traces back to the stated goal. Not automatically wrong — but each needs a reason, or it is scope that will need maintenance forever.
20
+ - [ ] Goals with no supporting feature. Read the stated goal's claims one by one and `search_code` each for a corresponding entry point. The stated ambition nothing implements is usually the more expensive direction.
21
+ - [ ] Abandoned directions: half-built subsystems, feature flags never turned on, TODOs older than the last major refactor. `search_code` for `TODO`/`FIXME` and, where `Repo History` is in the confirmed module set, cross-check the comment's age against recent activity in that file. Cross-check flags with `Reachability`.
22
22
 
23
23
  ## Decision record
24
24
 
25
- - [ ] Significant architectural choices have a recorded why — ADR, design doc, or at minimum a comment. An unexplained choice cannot be revisited safely because nobody knows what it was trading against.
26
- - [ ] Decisions that were reversed are recorded as reversed, not silently overwritten. Otherwise the next person re-litigates a settled question.
27
- - [ ] Where a decision's rationale has expired (the constraint it optimised for is gone), flag it. That is the highest-value finding in this module.
25
+ - [ ] Significant architectural choices have a recorded why — ADR, design doc, or at minimum a comment. `search_code` the decision's keyword (the technology or pattern name) across `docs/adr`, `docs/`, and the comments near its `find_symbol` location. An unexplained choice cannot be revisited safely because nobody knows what it was trading against.
26
+ - [ ] Decisions that were reversed are recorded as reversed, not silently overwritten. `search_code` for an ADR or doc marked superseded; a reversal with no trace at all means the next person re-litigates a settled question.
27
+ - [ ] Where a decision's rationale has expired (the constraint it optimised for is gone), flag it. Read the ADR/comment's stated constraint and check via `find_symbol`/`find_callers` whether the code that constraint drove is still present unchanged. That is the highest-value finding in this module.
28
+
29
+ ## Out of static reach
30
+
31
+ - Whether the goal as stated is the *right* goal — that is a product judgement, not a static one.
32
+ - Whether an architectural mismatch actually causes pain in practice, versus being theoretically inconsistent.
33
+ - Team intent behind an undocumented decision, when no comment, ADR, or commit message records it.
34
+ - Whether a decision's original constraint has genuinely expired, when nothing in the repo dates the constraint itself.
28
35
 
29
36
  ## Severity guidance
30
37
 
31
38
  | Situation | Severity |
32
39
  |---|---|
33
40
  | Architecture actively prevents a stated goal | High |
34
- | Two sources state contradictory goals | Medium |
41
+ | Two sources state contradictory goals, both confirmed current | Medium |
35
42
  | No goal recorded anywhere | Medium |
36
43
  | Decision whose rationale has expired | Medium |
37
44
  | Feature serving no stated goal | Low |
@@ -6,44 +6,55 @@ The core of this module is the two-directional key sweep from `reachability.md`,
6
6
 
7
7
  ## Key integrity
8
8
 
9
- - [ ] **Keys used in code but missing from a locale file.** The user sees a raw key, or a crash. `search_code` the translation function, extract the keys, diff against each locale. This is `High`.
10
- - [ ] Keys present in locale files that no call site uses. Dead translation weight, and translators are paying to maintain it.
11
- - [ ] Every locale has the same key set. A key present in the default locale and missing in another means that locale degrades in production only.
12
- - [ ] Dynamically constructed keys — `t('errors.' + code)` — cannot be statically verified. Enumerate the possible values and confirm each exists, or flag the construction as unverifiable.
13
- - [ ] Keys are namespaced consistently, and the namespace scheme is one scheme.
9
+ - [ ] **Keys used in code but missing from a locale file.** `search_code` for the translation call (`t(`, `i18n.t(`, `formatMessage(`) and extract the literal key arguments; diff that set against each locale file's keys. Any key present in code and absent from a shipped locale is `High` — the user sees the raw key, or a crash.
10
+ - [ ] Keys present in locale files that no call site uses. Take each locale's key list and `search_code` it back against the codebase — a key with zero call-site hits is dead translation weight, and translators still pay to maintain it.
11
+ - [ ] Every locale has the same key set. Read each locale file (`en.json`, `es.json`, …) and diff their key sets directly — a key present in the default locale and absent from another means that locale degrades in production only, and a manual spot-check in the default locale would never catch it.
12
+ - [ ] Dynamically constructed keys — `t('errors.' + code)` — cannot be statically verified by a direct diff. `search_code` for template-literal or concatenation inside a translation call, then read the type/enum backing the interpolated variable and check each possible resulting key exists in every locale; where the value set is unbounded (raw user input), flag the construction itself as unverifiable rather than guessing.
13
+ - [ ] Keys are namespaced consistently, and the namespace scheme is one scheme. Read locale files from two or three different feature areas and compare their nesting convention (`feature.section.key` vs a flat key with a prefix) — a second scheme introduced partway through is drift, visible directly in the file structure.
14
14
 
15
15
  ## Untranslated strings
16
16
 
17
- - [ ] User-visible strings hardcoded in components instead of going through the translation function. These are invisible until someone switches locale.
18
- - [ ] Strings in the less-obvious places: error messages, validation text, email templates, notifications, page titles, `aria-label` values, placeholder text, document metadata.
19
- - [ ] Server-generated user-facing text — it needs the user's locale, not the server's.
17
+ - [ ] User-visible strings hardcoded in components instead of going through the translation function. `search_code` component files for JSX text content or string literals in render output not wrapped in `t(`/`<Trans>`/the project's translation component — invisible until someone switches locale, and by then it has shipped.
18
+ - [ ] Strings in the less-obvious places: error messages, validation text, email templates, notifications, page titles, `aria-label` values, placeholder text, document metadata. `search_code` specifically for literal strings in thrown/caught error messages, validation-schema `message:` fields, `document.title` assignments, and `aria-label=`/`placeholder=` attributes — these are the sites hardcoding survives longest, because they never appear in a design review.
19
+ - [ ] Server-generated user-facing text — it needs the user's locale, not the server's. `search_code` the server-side handler or notification sender that builds user-facing copy and check whether it accepts or reads a locale parameter — one that always renders in a single hardcoded language regardless of the recipient's preference is the finding.
20
20
 
21
21
  ## Formatting
22
22
 
23
- - [ ] Dates, times, numbers, currencies, and percentages go through locale-aware formatting rather than manual concatenation. `search_code` for hand-built date strings.
24
- - [ ] Timezone handling is explicit for anything displayed to a user.
25
- - [ ] Currency carries an explicit currency code, never an assumed one.
26
- - [ ] Sorting uses locale-aware collation where the list is user-visible.
23
+ - [ ] Dates, times, numbers, currencies, and percentages go through locale-aware formatting rather than manual concatenation. `search_code` for hand-built date strings (`${year}-${month}-${day}`, `.toLocaleDateString()` called with no locale argument) instead of the project's formatting library used with an explicit locale.
24
+ - [ ] Timezone handling is explicit for anything displayed to a user. `search_code` the date-display paths for a threaded-through timezone (`Intl.DateTimeFormat` with `timeZone`, or an explicit UTC conversion) — a bare `new Date().toString()` rendered to the user takes on the server's timezone, not theirs.
25
+ - [ ] Currency carries an explicit currency code, never an assumed one. `search_code` for a hardcoded `$`/`€` prefix concatenated onto a number, versus `Intl.NumberFormat(locale, { style: 'currency', currency })` — the concatenated symbol assumes both the currency and its position, which differ across locales.
26
+ - [ ] Sorting uses locale-aware collation where the list is user-visible. `search_code` for `.sort(` on user-visible string arrays and check whether the comparator uses `localeCompare` — a default `.sort()` on strings orders by UTF-16 code unit, wrong for accented and non-Latin scripts.
27
+ - [ ] The runtime formatting non-English locales actually has that locale's data installed, not just the code path to request it. `search_code` the deployment config, `Dockerfile`, or `package.json` for `full-icu`/`--with-intl=full-icu`, or confirm the runtime version bundles full ICU by default — a Node process built against `small-icu` silently formats every locale as `en-US` instead of throwing, so `Intl.NumberFormat('de-DE', ...)` can be correct on a developer's machine and silently wrong in a minimal production container with no error to catch it.
27
28
 
28
29
  ## Grammar
29
30
 
30
- - [ ] Pluralisation uses the framework's plural rules, not `count === 1 ? x : y`. Many languages have more than two plural forms; a binary check is wrong in them by construction.
31
- - [ ] No sentences assembled from concatenated fragments — word order differs across languages, so the fragments cannot be reordered.
32
- - [ ] Interpolated values are named placeholders, not positional ones, so translators can reorder them.
33
- - [ ] Gendered or context-dependent strings have the context available to the translator.
31
+ - [ ] Pluralisation uses the framework's plural rules, not `count === 1 ? x : y`. `search_code` for that exact ternary shape gated on a count variable — each hit is provably wrong for any language with more than two plural forms, independent of which languages currently ship. CLDR defines up to six plural categories (`zero`, `one`, `two`, `few`, `many`, `other`); Arabic and Welsh use all six, Russian and Polish use four — a binary ternary collapses all of them to two.
32
+ - [ ] No sentences assembled from concatenated fragments — word order differs across languages, so the fragments cannot be reordered. `search_code` for adjacent translation calls joined by string concatenation or interpolated into one template literal.
33
+ - [ ] Interpolated values are named placeholders, not positional ones, so translators can reorder them. `search_code` translation call sites for a positional arguments array (`t('key', [name, date])`) versus a named object (`t('key', { name, date })`) — positional arguments force every locale to keep the source language's argument order.
34
+ - [ ] Gendered or context-dependent strings have the context available to the translator. `search_code` for `select`/`gender` ICU MessageFormat blocks, or their absence around a string known to vary by subject ("He/She updated the profile") — gendered content with no ICU block hardcodes one gender into the key. ICU MessageFormat's `plural`/`select` constructs are the baseline to check for — MessageFormat 2 (the successor spec) reached its stable Final Candidate in 2025, but tooling adoption is still early as of 2026, so its absence by name is not itself a finding.
34
35
 
35
36
  ## Layout
36
37
 
37
- - [ ] Text expansion is tolerated — translations commonly run 30–50% longer. Fixed-width containers and single-line assumptions break.
38
- - [ ] Right-to-left layout is handled if any supported locale requires it: logical CSS properties, mirrored icons, correct text direction.
39
- - [ ] Fonts cover the character sets of every supported locale.
40
- - [ ] Truncation is by grapheme, not by byte or code unit.
38
+ - [ ] Text expansion is tolerated — translations commonly run 30–50% longer. `search_code` for a fixed pixel/rem width or `white-space: nowrap` on a container wrapping translated text (a button label, a nav item) — a fixed-width label sized to the English string truncates or overflows once a longer locale renders.
39
+ - [ ] Right-to-left layout is handled if any supported locale requires it: logical CSS properties, mirrored icons, correct text direction. `search_code` the locale config for an RTL language (`ar`, `he`, `fa`, `ur`); if one is present, `search_code` the stylesheet for physical properties (`margin-left`, `left:`, `text-align: left`) instead of logical ones (`margin-inline-start`, `inset-inline-start`) — physical properties do not flip under `dir="rtl"`.
40
+ - [ ] Direction is set via the `dir` attribute, not left to CSS alone, and lives at the document root. Where an RTL locale is present, `search_code` the root layout, `_document`, or SSR template for `dir=` bound to the active locale on the `<html>` element — W3C's own i18n guidance treats markup, not a `direction:` stylesheet rule, as the authoritative source, since the Unicode bidi algorithm and assistive technology both key off the attribute. A hardcoded `dir="ltr"` on the root with RTL handled only in CSS is the finding.
41
+ - [ ] Opposite-direction fragments embedded inside RTL prose — a username, a product code, a foreign proper noun — are wrapped, not left to automatic direction detection. `search_code` for `<bdi` or an explicit `dir=` span around interpolated values in components that render user-generated or mixed-script content next to translated RTL text; unwrapped interpolation is where individual characters or whole substrings visibly reorder.
42
+ - [ ] Fonts cover the character sets of every supported locale. `search_code` the `@font-face`/font-family declarations and cross-reference the typeface against the declared locale list — a Latin-only webfont with no fallback stack shipped alongside a CJK or Cyrillic locale is readable from the declaration; whether the glyphs actually render correctly still needs a rendered check.
43
+ - [ ] Truncation is by grapheme, not by byte or code unit. `search_code` for `.slice(`/`.substring(`/`.substr(` applied to a string headed for display and check whether it precedes a grapheme-aware truncation utility (`Intl.Segmenter`, or a surrogate-pair-aware library) — plain index slicing on a string containing emoji or combining characters splits a visible character in half.
41
44
 
42
45
  ## Process
43
46
 
44
- - [ ] Locale detection has a defined precedence and a fallback, and the fallback is complete.
45
- - [ ] Missing translations fall back to a readable string, never to the raw key or an empty string.
46
- - [ ] Something keeps locales in sync — a CI check on key parity. Without it, drift is guaranteed. This is the same anti-drift pattern as a manifest parity test.
47
+ - [ ] Locale detection has a defined precedence and a fallback, and the fallback is complete. `find_symbol` the locale-resolution function and read its order of sources — a resolver that falls through several sources with no final default can return `undefined`, and the app renders with no locale loaded at all.
48
+ - [ ] Missing translations fall back to a readable string, never to the raw key or an empty string. `search_code` the i18n library's initialization config for `fallbackLng` and its missing-key behaviour (`returnEmptyString: false`, a `parseMissingKeyHandler`) — most i18n frameworks default to rendering the raw key, exactly the failure this check exists to catch.
49
+ - [ ] Something keeps locales in sync — a CI check on key parity. `search_code` the CI workflow files for a step that diffs locale key sets (an i18n lint action, a custom script) — its absence means the drift found under Key Integrity will recur on every PR with nothing to catch it. This is the same anti-drift pattern as a manifest parity test.
50
+
51
+ ## Out of static reach
52
+
53
+ - Native-speaker grammatical correctness and naturalness — a string can pass every structural check here and still read wrong to a native speaker.
54
+ - Whether pluralisation and gender rules are *correctly* filled in per language, versus merely present as valid ICU syntax.
55
+ - Actual rendered text expansion and truncation at real container widths.
56
+ - Whether RTL mirroring (icons, directional imagery) is visually correct, beyond which CSS property class was used.
57
+ - Translation quality and tone consistency across a locale.
47
58
 
48
59
  ## Severity guidance
49
60
 
@@ -51,11 +62,14 @@ The core of this module is the two-directional key sweep from `reachability.md`,
51
62
  |---|---|
52
63
  | Key used in code but missing from a shipped locale | High |
53
64
  | Missing translation renders the raw key to the user | High |
65
+ | Runtime missing full ICU/locale data — silently formats every locale as `en-US` in production | High |
54
66
  | Sentences assembled from concatenated fragments | Medium |
55
67
  | Binary pluralisation instead of plural rules | Medium |
56
68
  | Hardcoded user-visible string bypassing translation | Medium |
57
69
  | Manually formatted dates, numbers, or currency | Medium |
58
70
  | Locale key sets out of sync with no CI check | Medium |
71
+ | RTL locale present with `dir` controlled only by CSS, not the `<html>` attribute | Medium |
72
+ | Unwrapped opposite-direction fragment embedded in RTL prose | Low |
59
73
  | Positional instead of named placeholders | Low |
60
74
  | Layout that breaks on text expansion | Low |
61
75
  | Unused keys in locale files | Low |
@@ -0,0 +1,76 @@
1
+ # Idempotency
2
+
3
+ Is repetition safe? Gate: retries, webhooks, queues, or externally-triggered writes present.
4
+
5
+ `functional.md` checks whether an operation the code or docs *advertise* as idempotent actually is, once. `concurrency.md` owns interleavings between simultaneous actors. This module owns the narrower mechanical question underneath both: what actually makes a repeated call safe — a key, a constraint, a check — and whether every retryable path has one. A finding about two requests racing belongs in `concurrency.md`; a finding about the same request arriving twice belongs here.
6
+
7
+ ## Reachable retry surface
8
+
9
+ - [ ] Every write reachable from a retryable entry point — `trace_path` from each retry helper, queue consumer, or webhook route to the write(s) it performs. A retry wrapper that only retries a read is not a finding here; one that retries a write is the starting point for everything below.
10
+ - [ ] For each such write: does an idempotency key exist on the request, and where does it come from? A client-generated key survives a client-side retry (the client resends the same key); a server-generated key does not — the server assigns a new one on retry and the write happens again. `find_symbol` the key generation to see which side owns it. There is no ratified standard to check this against — `draft-ietf-httpapi-idempotency-key-header` expired 2026-04-18 with no successor draft — so judge it against the convention Stripe and AWS both implement (client-generated), not a spec.
11
+ - [ ] The key is enforced by a uniqueness constraint (DB unique index, `INSERT ... ON CONFLICT`, a dedupe table with a unique key) rather than only a read-then-write existence check. A "look up by key, if not found insert" without a constraint is itself a race — cross-reference `concurrency.md` for the read-modify-write pattern, but report the missing-constraint instance here since the *mechanism* is this module's concern.
12
+ - [ ] A key reused with a *different* request body is rejected, not silently replayed or silently reprocessed — `search_code` the key-lookup site for a stored-payload comparison (a hash or field-by-field check) before treating the request as a duplicate. Stripe and AWS both make this a hard error (AWS EC2's `IdempotentParameterMismatch`); a handler that only keys on the identifier and ignores the body lets a retried-with-different-arguments call silently do the wrong thing.
13
+ - [ ] A duplicate key with the *same* payload replays the original stored response rather than recomputing a fresh one — read the key-hit branch for a stored-response return versus falling through to re-execute business logic. Recomputing breaks the caller's assumption that a retry is a no-op if downstream state moved between the two attempts (a price, an inventory count).
14
+ - [ ] The idempotency key's scope — is it unique per operation type and per actor, or global? A key that is unique only by value (not scoped to the endpoint or the account) lets one caller's retry key collide with an unrelated operation from another caller, silently short-circuiting a legitimate second write as a "duplicate."
15
+
16
+ ## Webhooks
17
+
18
+ - [ ] Signature verification present on every webhook route before the payload is trusted — `search_code` the webhook handler for a signature/HMAC check (Stripe's `Stripe-Signature`, HMAC-SHA256 over `timestamp.payload`; GitHub's `X-Hub-Signature-256`; or the cross-vendor Standard Webhooks spec — `webhook-signature`/`svix-signature`, HMAC-SHA256 over `msg_id.timestamp.payload`, now adopted by 40+ providers including OpenAI, Anthropic, and Twilio). Its absence means anyone who finds the URL can trigger the write, not just a genuine retry.
19
+ - [ ] The comparison is constant-time, not `==`/`===`/string equality — `search_code` for the signature-compare line and confirm it calls a constant-time primitive (`crypto.timingSafeEqual` in Node, `hmac.compare_digest` in Python, `hash_equals` in PHP, `Rack::Utils.secure_compare` in Ruby). GitHub's and Stripe's own docs both call out plain `==` explicitly: it short-circuits on the first mismatched byte and leaks the correct prefix through response timing.
20
+ - [ ] The signature is computed over the raw request body, not a re-serialised copy — `search_code` for a body-parsing middleware (Express's `express.json()` mounted globally is the canonical case) that runs before the webhook route and reparses the payload. Re-serialising JSON changes key order, whitespace, and number formatting, which changes the bytes the HMAC covers and breaks verification — the raw body must be captured before any parsing, scoped to the webhook route specifically.
21
+ - [ ] A replay window — is a signed-but-stale payload (timestamp far in the past) still accepted? Stripe's default tolerance is 5 minutes, and its own docs warn against setting tolerance to 0 (that disables the check entirely). Without a window, a captured valid payload can be replayed indefinitely.
22
+ - [ ] The provider's event ID is stored and checked before processing, not just the payload's business data — `find_callees` from the handler to confirm a lookup against previously-seen event IDs happens before the side-effecting write, not after.
23
+ - [ ] Fields inside the payload (an `event_type`, a `customer_id`) are not used to route or act on the request before the signature is verified — verification must gate every use of the body, not just the parts a developer remembered to protect.
24
+ - [ ] Out-of-order delivery: a handler that assumes events arrive in the order they were sent (e.g. `payment.created` before `payment.refunded`) — most providers guarantee at-least-once, not ordered, delivery. `search_code` for sequencing assumptions (a state transition that would break if the "later" event arrived first).
25
+ - [ ] Duplicate webhook deliveries from provider-side retries (the provider itself retries on a non-2xx or a timeout) versus the handler's own idempotency check — confirm the handler returns success only after the write is durably committed, not before, or the provider will interpret a slow success as a failure and retry a request that already landed.
26
+
27
+ ## Queue and retry semantics
28
+
29
+ - [ ] At-least-once delivery acknowledged in the consumer's code (idempotency key, or the write itself is naturally idempotent — e.g. a `SET`, not an `INCREMENT`) versus silently assumed to be exactly-once. `search_code` the consumer's ack/commit point relative to where the write happens, concretely: Kafka's `enable.auto.commit` defaults to `true` on a 5-second interval and commits the offset once `poll()` returns — before the handler body has run — so a crash mid-processing is silent loss unless the commit is manual and placed after the write; SQS deletes the message explicitly, and a delete issued before processing has the same effect, while a delete issued after processing but with too short a visibility timeout (SQS's default is 30 seconds) causes duplicate redelivery instead of loss; RabbitMQ's manual ack before processing is discarded on crash, ack after is safe by default (auto-requeue on channel/connection close) provided the write itself is idempotent. An ack after a failed write, or a write before the ack, both reopen the redelivery case.
30
+ - [ ] Consumer-side dedupe is implemented as an inbox / idempotent-consumer table (a `processed_message(id)` record inserted in the same transaction as the handling), not just an in-memory guard — `search_code` for a processed-messages/seen-ids table and confirm the insert and the business write share a transaction. An in-memory-only guard resets on every deploy and duplicates on every restart.
31
+ - [ ] Retries that are unbounded (no max attempt count) or unjittered (fixed-interval retry against a struggling downstream, amplifying the load that caused the failure in the first place). Named jitter strategies exist for a reason — Full Jitter (`random(0, min(cap, base*2^attempt))`) is the primary-source recommendation over Equal Jitter or no jitter at all, since it does the least total work against a recovering backend for comparable completion time (AWS Architecture Blog, "Exponential Backoff and Jitter").
32
+ - [ ] A retry wrapper applied to an operation that is not idempotent by construction — `find_callers` on the retry helper and check each wrapped call against the checks above; wrapping a bare `INSERT` with no key is a retry mechanism actively making things worse.
33
+ - [ ] Retry-on-timeout specifically: a timeout means the first attempt's outcome is unknown, not that it failed. `search_code` for a catch-and-retry around a timeout error with no idempotency key — this is the mechanism behind duplicate charges and duplicate emails, because the first attempt may have already succeeded server-side.
34
+ - [ ] A poison message (one that will never succeed, e.g. malformed payload) has a dead-letter path rather than being retried indefinitely — `find_callees` from the consumer's error handler to confirm a max-attempts-then-park path exists, distinct from a message that fails only transiently.
35
+
36
+ ## Client-side half
37
+
38
+ - [ ] A submit action (payment, form post, "create") whose button is not disabled after the first click, and no client-side dedupe (request-in-flight guard, disabled state, single-flight promise) — `search_code` the submit handler for a guard. Cross-reference `flow-integrity.md`, which owns the broader UI-flow-correctness question; report the specific double-submit-with-no-guard instance here since the mechanism is a missing idempotency key on the client side of the same problem.
39
+
40
+ ## Compensation and cleanup
41
+
42
+ - [ ] Multi-step operations that can fail partway (charge then provision, reserve then confirm) have a compensating action for the already-completed steps — `find_callees` from the orchestrating function to see if a rollback/compensate path exists for each step, not just a try/catch that logs and gives up.
43
+ - [ ] A partial failure leaves state that is reversible by a human or a retry, rather than requiring manual database surgery — read the error path to confirm which state the record is left in.
44
+ - [ ] Dedupe/idempotency-key records are stored but never expired — `search_code` for the dedupe table's write path and check for a corresponding TTL or cleanup job. An unbounded dedupe store is a slow leak, and once it is large enough that lookups degrade, the protection it provides degrades with it.
45
+
46
+ ## Out of static reach
47
+
48
+ - Actual delivery ordering and duplication behaviour of the specific queue/webhook provider in production.
49
+ - Whether a race window is wide enough to matter at real traffic volumes.
50
+ - Whether a compensating action is triggered promptly enough in practice, versus existing in code but rarely exercised.
51
+ - Idempotency-key storage capacity under sustained load.
52
+
53
+ ## Severity guidance
54
+
55
+ | Situation | Severity |
56
+ |---|---|
57
+ | Retryable write with no idempotency key and no unique constraint | Critical |
58
+ | Webhook route with no signature verification | Critical |
59
+ | Retry-on-timeout wrapping a non-idempotent write (duplicate charge shape) | High |
60
+ | Idempotency key server-generated instead of client-supplied on a client-retried path | High |
61
+ | Idempotency enforced only by read-then-write check, no DB constraint | High |
62
+ | Multi-step operation with no compensating action on partial failure | High |
63
+ | Idempotency key reused with a different request body is silently accepted, not rejected | High |
64
+ | Consumer dedupe implemented only as an in-memory guard, not a durable inbox record | High |
65
+ | Signature verified over a re-serialised body instead of the raw bytes | High |
66
+ | Payload fields trusted or routed on before signature verification | High |
67
+ | Webhook handler with no replay-window check | Medium |
68
+ | Consumer assumes ordered delivery from an at-least-once queue | Medium |
69
+ | Unbounded or unjittered retry against a downstream dependency | Medium |
70
+ | Idempotency key not scoped per operation/actor, allowing cross-operation collision | Medium |
71
+ | Handler acknowledges before the write is durably committed | Medium |
72
+ | Poison message retried indefinitely with no dead-letter path | Medium |
73
+ | Submit action with no client-side dedupe guard | Medium |
74
+ | Duplicate key + same payload recomputes a fresh response instead of replaying the stored one | Medium |
75
+ | Signature compared with non-constant-time equality | Medium |
76
+ | Dedupe/idempotency records stored with no expiry | Low |
@@ -6,44 +6,53 @@ Runtime environment and its definition. Gate: CI/CD, a Dockerfile, or IaC was de
6
6
 
7
7
  ## Declared vs. actual
8
8
 
9
- - [ ] Infrastructure is in code. Resources created by hand are undocumented, unreviewable, and unreproducible — that gap is the first finding.
10
- - [ ] State files are remote and locked, not local. A local state file means one machine holds the only truth.
11
- - [ ] Drift is detectable — something compares declared to actual. Without it, IaC describes intentions rather than reality.
12
- - [ ] Every environment comes from the same definition with different inputs. Divergent per-environment definitions guarantee "works in staging".
9
+ - [ ] `search_code` for `.tf`, `Pulumi.*`, `*.bicep`, or a CloudFormation template, and cross-reference the resources they declare against the cloud SDK usage `get_architecture` reports for the application. A resource the app clearly talks to but no IaC declares is the candidate — **rule-out**: it may live in a separate, un-indexed infrastructure repo, so when no IaC directory exists in this repo at all, report the signal as `undetermined`, not as a confirmed hand-created resource.
10
+ - [ ] State is remote and locked, not local. `search_code` the Terraform `backend` block or the Pulumi state/backend config for a remote target (S3, GCS, Terraform Cloud) with locking (DynamoDB table, native lock) rather than a local `.tfstate`.
11
+ - [ ] Drift detection exists. `search_code` CI workflows for a scheduled `terraform plan` / `pulumi preview` job distinct from the apply-on-merge job, or a TACOS platform config that runs it for you — `atlantis.yaml`, a Spacelift/env0 stack definition, or an HCP Terraform workspace with drift detection enabled. A plan that only ever runs right before an apply never catches drift that accumulates between deploys.
12
+ - [ ] Every environment comes from the same definition with different inputs. Read the IaC directory structure: one module parameterised by `*.tfvars`/env-specific variables is the intended shape; separate copy-pasted per-environment directories (`envs/staging/main.tf`, `envs/prod/main.tf` diverging beyond their variables) is the finding — diff them.
13
13
 
14
14
  ## Configuration
15
15
 
16
- - [ ] Every environment variable the application reads is declared in the deployment definition. Cross-reference the used-but-never-declared sweep in `reachability.md` — this is where that check pays off most.
17
- - [ ] Required config with no value fails at startup, not at first use in production.
18
- - [ ] Defaults in the definition are safe for production, not convenient for development.
19
- - [ ] Nothing environment-specific is compiled into the artefact.
16
+ - [ ] Every environment variable the application reads is declared in the deployment definition. Reuse `reachability.md`'s used-but-never-declared probe directly: `search_code` for `process.env.` / `os.environ` / the language's equivalent, then check each name against the deployment manifest's env list — this is where that check pays off most, because the failure mode is a variable that is `undefined` only in production.
17
+ - [ ] Required config with no value fails at startup, not at first use. `find_symbol` the config-loading module and read it: a schema-validated load that throws before the server binds its port is the standard; a lazy read that returns `undefined` and gets used three requests later is the finding.
18
+ - [ ] Defaults in the definition are safe for production. Read the deployment definition's default values for anything security-relevant — `debug: true`, a wildcard CORS origin, a verbose log level — a convenient development default is `High` if nothing overrides it in the production environment file.
19
+ - [ ] Nothing environment-specific is compiled into the artefact. `search_code` the build step for values injected at build time (webpack `DefinePlugin`, a baked-in API base URL, an embedded feature flag) rather than read at runtime — these force a rebuild per environment and silently defeat "one artefact, many environments".
20
20
 
21
21
  ## Resource limits
22
22
 
23
- - [ ] CPU and memory limits are set. No limit means one process can starve its neighbours; a limit far above observed use wastes money — cross-reference `cost.md`.
24
- - [ ] Disk is bounded and monitored, especially wherever logs or uploads land.
25
- - [ ] Connection and file-descriptor limits accommodate the configured pool sizes. A pool larger than the descriptor limit fails under load only.
26
- - [ ] Autoscaling bounds exist at both ends, and the scale-up signal is the resource that actually saturates.
23
+ - [ ] CPU and memory limits are set. `search_code` Kubernetes manifests or compose files for `resources.limits` / `mem_limit`; absence is the finding — cross-reference `cost.md` where a limit is present but sits far above observed use.
24
+ - [ ] Disk is bounded and monitored wherever logs or uploads land. `search_code` volume mounts for a log or upload directory and check for a size cap or rotation config (`logrotate`, a max-size setting) alongside it.
25
+ - [ ] Connection and file-descriptor limits accommodate the configured pool sizes. Read the application's DB/connection pool size setting and compare it against the container's declared `ulimit` or fd limit where one is set — a pool ceiling above the fd ceiling only fails under load, never in development.
26
+ - [ ] Autoscaling bounds exist at both ends, and the scale-up signal is the resource that actually saturates. `search_code` the autoscaler config (HPA, ASG launch config) for `min`/`max` replicas and the triggering metric; cross-reference `performance.md` for whether that metric is the one that actually saturates first.
27
27
 
28
28
  ## Network and access
29
29
 
30
- - [ ] Nothing is publicly reachable that does not need to be — databases, caches, admin ports, metrics endpoints.
30
+ - [ ] Nothing is publicly reachable that does not need to be. `search_code` IaC or compose files for datastore ports (`5432:5432`, `6379:6379`, `27017:27017`) bound to a public interface rather than `127.0.0.1:` or a private subnet — a datastore port with no interface prefix in a compose file defaults to all interfaces.
31
31
  - [ ] Ingress rules are specific rather than open ranges. `search_code` the IaC for `0.0.0.0/0`.
32
- - [ ] Service-to-service access is least-privilege, not a shared broad role.
33
- - [ ] Credentials are workload identities where available, rather than long-lived static keys.
32
+ - [ ] Service-to-service access is least-privilege. Read the IAM role or policy document attached to each service in IaC — a wildcard `*` action or `*` resource on a role that only needs to read one bucket is the finding.
33
+ - [ ] Credentials are workload identities where available, rather than long-lived static keys. `search_code` the deployment definition for static key literals or key references (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`) versus an instance-profile or workload-identity binding — presence of the former where the platform offers the latter is the finding.
34
34
 
35
35
  ## Durability
36
36
 
37
- - [ ] Backups exist for every stateful resource, and a restore has been performed. An untested backup is not a backup.
38
- - [ ] Restore time and acceptable data loss are stated, not assumed.
39
- - [ ] Deletion protection on resources whose loss would be unrecoverable.
40
- - [ ] Stateful data is not on ephemeral storage.
37
+ - [ ] Backups exist for every stateful resource the inventory names. `search_code` IaC or the managed-service config for a backup/snapshot-schedule attribute on each one — a resource with no such attribute has no backup, full stop.
38
+ - [ ] Restore time and acceptable data loss are stated somewhere findable — a runbook, a README, an ADR. **Whether a restore has actually been performed and succeeded is not establishable from source**; report the runbook's existence (or absence) as the static half of this check and push the "actually tested" half to Out of static reach.
39
+ - [ ] Deletion protection on resources whose loss would be unrecoverable. `search_code` IaC for `deletion_protection` / `prevent_destroy` on the datastore and storage resources the inventory lists.
40
+ - [ ] Stateful data is not on ephemeral storage. Read the container or pod spec for the path the application writes state to — mounted on `emptyDir` or no volume at all is the finding; a persistent volume claim or managed volume is the pass.
41
41
 
42
42
  ## Operability
43
43
 
44
- - [ ] Someone can reach logs, metrics, and a shell for a running instance without a bespoke procedure. Cross-reference `observability.md`.
45
- - [ ] Restart, scale, and redeploy are single documented commands.
46
- - [ ] The definition names an owner. Unowned infrastructure is what still runs three years after the team forgot it.
44
+ - [ ] Someone can reach logs, metrics, and a shell for a running instance without a bespoke procedure. Cross-reference `observability.md`; `search_code` for a centralised logging/metrics sink configured in the deployment definition versus container-stdout-only, which is unreachable once the container recycles.
45
+ - [ ] Restart, scale, and redeploy are single documented commands. Read the deployment docs or `Makefile`/scripts directory for these — their absence, when the app clearly does deploy somehow, is itself the finding: the knowledge exists only in one person's shell history.
46
+ - [ ] The definition names an owner. `search_code` IaC or manifest metadata (tags, labels, annotations) for an owner or team field — treat this as a soft signal: missing metadata implies but does not prove the resource is unowned, since ownership may be tracked outside the repo.
47
+
48
+ ## Out of static reach
49
+
50
+ - Whether a backup restore actually succeeds — only executing one proves it; the runbook's existence is the ceiling of what source can show.
51
+ - Real autoscaling behaviour under load — the declared bounds and metric are checkable, whether they trigger correctly at the right threshold is not.
52
+ - Whether live cloud-console configuration matches declared IaC — drift detection can be configured and still be broken or unrun; the actual comparison happens outside this audit.
53
+ - Real network reachability from the public internet — a port scan or external probe would confirm it, IaC only states intent.
54
+ - Hand-created resources that exist entirely outside any indexed repo — invisible to `search_code` by definition; only a live account inventory would surface them.
55
+ - Actual on-call ownership and response readiness — an owner tag is a label, not a guarantee someone answers a page.
47
56
 
48
57
  ## Severity guidance
49
58