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
@@ -2,43 +2,53 @@
2
2
 
3
3
  What breaks when there is more of everything? Gate: a queue, worker, or background jobs were detected.
4
4
 
5
- `Performance` asks how fast one operation is. This module asks what happens at ten times the load, ten times the data, and two instances instead of one.
5
+ `Performance` asks how fast one operation is. This module asks what happens at ten times the load, ten times the data, and two instances instead of one. Most checks below are `read` once you find the file and `inferred` on the actual future volume — state which.
6
6
 
7
7
  ## Horizontal readiness
8
8
 
9
- - [ ] No state lives only in one process's memory. In-memory caches, counters, session maps, and rate-limit buckets all diverge across instances.
10
- - [ ] Nothing depends on being the only instance. `search_code` for in-process locks, singletons holding mutable state, and interval timers — each one runs N times with N instances.
11
- - [ ] Scheduled work has a leader election or a distributed lock. Otherwise every instance runs the cron.
12
- - [ ] Local filesystem writes are either ephemeral or explicitly shared storage. A file written on one instance and read on another silently fails behind a load balancer.
9
+ - [ ] No state lives only in one process's memory: `search_code` for a module-level `Map`/`Set`/object literal used as a cache, counter, or session store, then `find_callers` to confirm it is written on the request path rather than populated once from static config.
10
+ - [ ] Nothing depends on being the only instance: `search_code` for in-process locks, singletons holding mutable state, and interval timers — each one runs N times with N instances.
11
+ - [ ] Scheduled work has a leader election or a distributed lock: `search_code` for `setInterval`/a cron import/a scheduler registration, then read the surrounding code for a lock/leader check (`SETNX`, an advisory lock, an "only run on leader" guard). Rule out a genuinely single-replica deployment — read the deploy manifest or Dockerfile replica count — before flagging.
12
+ - [ ] Local filesystem writes are either ephemeral or explicit shared storage: `search_code` for `fs.writeFile`/`createWriteStream` and check the target path against a shared-storage prefix (S3, a mounted volume) versus a local `/tmp`-style path. A file written on one instance and read on another silently fails behind a load balancer.
13
13
 
14
14
  ## Queues and workers
15
15
 
16
- - [ ] Every queue has a consumer, and every consumer has a producer. Cross-reference the half-wired pairs table in `flow-integrity.md` — an unconsumed queue grows forever.
17
- - [ ] Jobs are idempotent. At-least-once delivery is the norm, so a job that runs twice must be safe.
18
- - [ ] Failed jobs go somewhere — a dead-letter queue, a retry with backoff, or an alert. Silent drop is the default failure mode and it is `High`.
19
- - [ ] Retries are bounded. An infinite retry on a poison message blocks the queue.
20
- - [ ] Job payloads carry identifiers, not whole objects. Fat payloads make the queue the database.
21
- - [ ] Concurrency per consumer is bounded and configurable.
16
+ - [ ] Every queue has a consumer, and every consumer has a producer: `search_code` the queue/topic name literal and confirm it appears at both a publish call (`.publish`/`.send`/`.enqueue`) and a consume call (`.consume`/`on('message'`). Cross-reference the half-wired pairs table in `flow-integrity.md` — an unconsumed queue grows forever.
17
+ - [ ] Jobs are idempotent: `find_symbol` the job handler and read its write path. An `INSERT` with no unique constraint or dedup key, run under at-least-once delivery, double-writes on redelivery. Rule out that the transport itself guarantees exactly-once (name it) before flagging — but check the guarantee's actual scope first: Kafka's exactly-once semantics (idempotent producer + transactions) covers Kafka-to-Kafka only — offsets, state stores, output topics — not a database write or HTTP call the handler makes as a side effect; SQS FIFO's deduplication is a 5-minute window on the *send* path (`MessageDeduplicationId` or a content hash), not a guarantee the handler itself won't run twice after redelivery; RabbitMQ makes no exactly-once claim at all — its own docs say to make consumers idempotent. A rule-out that doesn't name which of these applies, and confirm the side effect stays inside that boundary, is not a rule-out.
18
+ - [ ] Failed jobs go somewhere: `search_code` for the queue library's failure hook (`on('failed'`, a dead-letter binding, a `.catch(` around job processing). Silent drop is the default failure mode in most libraries and it is `High`.
19
+ - [ ] The dead-letter destination is actually drained by something: `search_code` for a redrive/replay path (SQS's `StartMessageMoveTask`, a scheduled job reading the DLQ, an alert wired to DLQ depth) versus a DLQ that exists only as a naming convention. Replay tooling varies by platform — SQS supports redrive natively; Kafka Connect's dead-letter topic (sink connectors only — source connectors have no DLQ mechanism at all) is a plain topic with no built-in replay; Azure Service Bus has no built-in redrive either. A DLQ nothing reads is a slower version of silent drop.
20
+ - [ ] Retries are bounded: `search_code` for the retry/backoff config (`attempts:`, `backoff:`, `maxRetries`) on the job/queue definition. Read the library's default when no config is present — several default to infinite.
21
+ - [ ] Job payloads carry identifiers, not whole objects: read a handful of `.enqueue`/`.publish` call sites — a full domain object in the payload instead of an id is the finding. Fat payloads make the queue the database.
22
+ - [ ] Concurrency per consumer is bounded and configurable: `search_code` for the consumer's concurrency/prefetch setting; its absence means the library's own default applies, which is worth stating explicitly.
22
23
 
23
24
  ## Data growth
24
25
 
25
- - [ ] Every table, collection, log, and index has an answer to "what bounds this?" Unbounded growth with no retention policy is a finding even when it is slow.
26
- - [ ] Queries that work today at current row counts — state the count at which each becomes a problem.
27
- - [ ] Batch jobs that process everything rather than only what changed. These get slower every day by construction.
28
- - [ ] Pagination is cursor-based where the dataset is large; offset pagination degrades linearly.
26
+ - [ ] Every table, collection, log, and index has an answer to "what bounds this?": `search_code` for a retention/TTL/cleanup job referencing each table name. Report the ones with no hit once, as a single finding with the full list — not one finding per table.
27
+ - [ ] Queries that work today at current row counts: read the query (`find_symbol`/`expand_context`) and state the row count at which an unindexed filter or full scan degrades. This is `inferred` without a real count from the schema or a migration comment — cap it at `Medium` accordingly.
28
+ - [ ] Batch jobs that process everything rather than only what changed: `search_code` the batch job's query for a narrowing clause (`WHERE updated_at >`, `WHERE processed = false`) versus an unfiltered `.findAll()`/`SELECT *`. A job that reprocesses the whole table gets slower every day by construction.
29
+ - [ ] Pagination is cursor-based where the dataset is large: `search_code` the listing route/query for `OFFSET`/`.skip(` versus a cursor or keyset parameter (`after:`, `WHERE id >`). Offset pagination degrades linearly as the table grows.
29
30
 
30
31
  ## Backpressure
31
32
 
32
- - [ ] Producers slow down or shed load when consumers fall behind. Unbounded buffering between them just moves the failure.
33
- - [ ] Bounded pools exist for connections, workers, and concurrent outbound calls.
34
- - [ ] Rate limits protect downstream dependencies, not only inbound callers.
35
- - [ ] Timeouts are shorter than the caller's timeout, so failures surface at the right layer.
33
+ - [ ] Producers slow down or shed load when consumers fall behind: `search_code` for a queue-depth check, an ack wait, or a `pause()`/`resume()` hook (Node stream `highWaterMark`, a Kafka consumer's `pause()`) before the next publish. The absence signature is concrete: unbounded array/queue growth with no size cap, a fan-out that spawns one promise or goroutine per item with no semaphore or worker-pool limit, or a publish loop with no await/ack-wait between sends. Unbounded fire-and-forget publishing just moves the failure downstream.
34
+ - [ ] A reactive/streaming operator that claims to handle backpressure is actually bounded: `search_code` for the operator call and check whether a capacity argument is present — Project Reactor's `onBackpressureBuffer()` is unbounded by default unless given an explicit max size. An unconfigured "backpressure-handling" operator can still exhaust memory under sustained overload.
35
+ - [ ] Bounded pools exist for connections, workers, and concurrent outbound calls: `search_code` for the pool config (`maxConnections`, `pool: { max: }`, an HTTP agent's `maxSockets`). Its absence means the client library's own unbounded default applies. This is the bulkhead pattern — a slow or saturated dependency should exhaust only its own pool, not one shared with every other dependency; a single HTTP client or connection pool reused across multiple downstream services is the common way this fails. Cross-reference `Failure`'s circuit-breaker check — the two patterns are usually paired.
36
+ - [ ] Rate limits protect downstream dependencies, not only inbound callers: `search_code` for a throttle wrapper around outbound calls to a third-party dependency, separate from the inbound API gate.
37
+ - [ ] Timeouts are shorter than the caller's timeout, so failures surface at the right layer: read the timeout set on each outbound client (`find_symbol`/read the client construction) and compare it against the framework's own request timeout.
36
38
 
37
39
  ## Degradation
38
40
 
39
- - [ ] Under load the system degrades rather than collapsing — sheds optional work, serves stale cache, returns a clear 503.
40
- - [ ] Non-critical work is genuinely non-blocking. A failing analytics call must not fail the request.
41
- - [ ] Health checks reflect real capacity, not just process liveness.
41
+ - [ ] Under load the system degrades rather than collapsing: read the failure path of the top-ranked handler from `repo_map` for a stale-cache fallback or an explicit `503`, versus an unhandled exception that takes the whole request down.
42
+ - [ ] Non-critical work is genuinely non-blocking: `search_code` for an `await` on an analytics/telemetry call inside a request handler with no surrounding try/catch or fire-and-forget wrapper — a failing optional call must not fail the request.
43
+ - [ ] Health checks reflect real capacity, not just process liveness: `find_symbol` the health-check handler and read it — a handler that returns `200` unconditionally is a liveness check wearing a readiness check's name.
44
+
45
+ ## Out of static reach
46
+
47
+ - Actual behaviour under N concurrent instances — nothing here is run.
48
+ - Whether observed traffic ever approaches the stated bound, or the crossover row count named above.
49
+ - True queue throughput versus producer rate under real load.
50
+ - Real failover or leader-election behaviour during an actual node loss.
51
+ - Whether a rate limit or bounded pool is sized correctly for real downstream capacity, versus merely present.
42
52
 
43
53
  ## Severity guidance
44
54
 
@@ -49,7 +59,10 @@ What breaks when there is more of everything? Gate: a queue, worker, or backgrou
49
59
  | Unbounded retry on a poison message | High |
50
60
  | Scheduled job with no leader election | High |
51
61
  | Non-idempotent job under at-least-once delivery | High |
62
+ | Exactly-once guarantee assumed for a side effect outside the transport's actual transactional boundary | High |
52
63
  | No backpressure between producer and consumer | Medium |
53
64
  | Unbounded data growth with no retention policy | Medium |
54
65
  | Batch job that reprocesses everything | Medium |
66
+ | Dead-letter queue with no redrive or replay path — failures accumulate unread | Medium |
67
+ | Reactive backpressure operator used with no bounded capacity (default-unbounded buffer) | Medium |
55
68
  | Offset pagination over a large dataset | Low |
@@ -4,60 +4,76 @@ Gate: auth, external input, or a network boundary was detected.
4
4
 
5
5
  **Scope discipline.** This module finds and reports defects in the audited codebase. It does not write exploits, and it does not produce working attack payloads. A finding names the vulnerable line, the class of attack, and the fix.
6
6
 
7
+ **This is the module where an invented finding does the most damage.** A false Critical here does not sit quietly in a backlog — it sends someone onto an emergency rotation for nothing, and the second cost is worse than the first: it trains that team to discount the next alert this skill raises, including the real one. Every rule-out below is not optional colour, it is the difference between a finding and an incident. If a check cannot be traced to its origin, it is not reported at this severity — see the Evidence Contract in `SKILL.md`.
8
+
7
9
  Trace every input from where it enters to where it is used. `find_callees` from the entry point, or `trace_path` from the handler to the sink. An input that reaches a sink without passing validation is the finding.
8
10
 
9
11
  ## Injection sinks
10
12
 
11
- Enumerate the sinks, then check what reaches each one:
13
+ Enumerate the sinks, then check what reaches each one. For every hit, the rule-out is the same shape: `trace_path` (or `find_callers` walked backward one hop at a time) from the sink to the value's origin. A value that terminates at a literal, an internal config object, or a value already validated upstream is not a finding — an invented finding at Critical is a full incident response for nothing, so confirm the traced origin is unvalidated external input before reporting anything.
12
14
 
13
- - [ ] **Query** — any query built by concatenation or interpolation from external input. Parameterised or nothing. `Critical`.
14
- - [ ] **Shell** — `exec`, `spawn` with a shell, or a command string built from input. Prefer argument arrays with no shell.
15
- - [ ] **Filesystem** — a path built from input. Check for `..` traversal and absolute-path override; the fix is resolve-then-verify-inside-root, not string filtering.
16
- - [ ] **Code** — `eval`, `new Function`, dynamic `require`/`import` of an input-derived name, deserialisation of untrusted data.
17
- - [ ] **Template/markup** — unescaped interpolation into HTML, `innerHTML`, `dangerouslySetInnerHTML`.
18
- - [ ] **Model prompt** — untrusted text concatenated into instructions; see `abuse.md` and `ai.md`.
15
+ - [ ] **Query** — `search_code` for string concatenation or template interpolation feeding a query call (`+ req.`, `` `${...}` `` next to a query function, `.raw(`, `f"SELECT`). Trace the interpolated value back with `trace_path`; parameterised or nothing. CWE-89, #2 in the 2025 CWE Top 25. `Critical`.
16
+ - [ ] **Shell** — `search_code` for `exec(`, `spawn(` with `shell: true`, `os.system(`, `subprocess.` with `shell=True`, or backtick/string command construction. Trace the command string's origin; prefer argument arrays with no shell. CWE-78/CWE-77 (OS command injection, #9/#23 in the 2025 CWE Top 25).
17
+ - [ ] **Filesystem** — `search_code` for `path.join(`/`os.path.join(` fed by a request parameter, or raw string path building. Read the resolved-path handling for `..` traversal and absolute-path override; the fix is resolve-then-verify-inside-root, not string filtering. CWE-22 Path Traversal, #6 in the 2025 CWE Top 25.
18
+ - [ ] **Code** — `search_code` for `eval(`, `new Function(`, dynamic `require(`/`import(` of a computed name, `pickle.loads`, `yaml.load` without `SafeLoader`, or other deserialisation of untrusted data. Trace the argument to its source. CWE-94 Code Injection (#10) or CWE-502 Deserialization of Untrusted Data (#15) in the 2025 CWE Top 25 — cite whichever fits the sink.
19
+ - [ ] **Template/markup** — `search_code` for `innerHTML`, `dangerouslySetInnerHTML`, `v-html`, or a template engine's raw/unescaped filter. Trace the value; a hit rendering only static or already-sanitised content is not the finding.
20
+ - [ ] **Model prompt** — `search_code` for string concatenation into a prompt or messages array. Trace the concatenated text to confirm it is untrusted user content, not a fixed system instruction; see `abuse.md` and `ai.md`.
19
21
 
20
22
  ## AuthN
21
23
 
22
- - [ ] Credential comparison is constant-time. `search_code` for `===` against a token or secret.
23
- - [ ] Passwords are hashed with a slow, salted algorithm — never a plain digest, never encrypted, never stored raw.
24
- - [ ] Sessions and tokens expire, and expiry is checked with the correct comparison. An off-by-one on `<` vs `<=` at an expiry boundary is a real defect.
25
- - [ ] Tokens are validated for signature, issuer, audience, and expiry — not merely decoded.
26
- - [ ] Logout invalidates server-side, not only client-side.
24
+ ASVS 5.0 §V6 (Authentication) and §V7 (Session Management) cover this section.
25
+
26
+ - [ ] Credential comparison is constant-time. `search_code` for `===`, `==`, or `.equals(` comparing a token, secret, or hash — read the call site; a comparison against a non-secret value (a public id, a CSRF token already bound to session) does not qualify.
27
+ - [ ] Passwords are hashed with a slow, salted algorithm. `find_symbol`/`search_code` the registration or password-set handler and read what it calls before persisting — `bcrypt`/`argon2`/`scrypt` is correct, `md5`/`sha256`/plain storage is the finding.
28
+ - [ ] Sessions and tokens expire, and expiry is checked with the correct comparison. `find_symbol` the verify function and read the comparison operator literally — an off-by-one on `<` vs `<=` at the expiry boundary is a real defect, not a style nit.
29
+ - [ ] Tokens are validated for signature, issuer, audience, and expiry. Read the verify call's options argument directly — a call that only decodes (`jwt.decode` with verification disabled, or no `verify()` at all) is the finding regardless of what happens after.
30
+ - [ ] Logout invalidates server-side. `find_symbol` the logout handler, then `find_callees` — a handler that only clears a client-side cookie or local storage entry, with no server-side session/token revocation call, is the finding.
27
31
 
28
32
  ## AuthZ
29
33
 
30
- - [ ] Every protected operation checks authorisation, and the check is on the server. `find_callers` on the authorisation helper, then compare against the full list of protected handlers — the gap is the finding.
31
- - [ ] Authorisation is checked against the *resource*, not only the *route*. Being logged in is not permission to read record 42.
32
- - [ ] No object reference from the client is trusted as ownership proof.
33
- - [ ] Privilege escalation paths: can a user set their own role, quota, or flags through a mass-assigned update?
34
- - [ ] Default is deny. A new endpoint added tomorrow should be closed unless opened.
34
+ ASVS 5.0 §V8 (Authorization) covers this section. The specific defect below — a handler trusting a client-supplied resource id as ownership proof — is **Broken Object Level Authorization**, OWASP API Security Top 10:2023 API1 (BOLA), CWE-639 Authorization Bypass Through User-Controlled Key, #24 in the 2025 CWE Top 25.
35
+
36
+ - [ ] Every protected operation checks authorisation, and the check is on the server. `find_callers` on the authorisation helper, then compare against the full list of protected handlers from `get_architecture`/route discovery — the gap between the two lists is the finding. CWE-862 Missing Authorization, #4 in the 2025 CWE Top 25.
37
+ - [ ] Authorisation is checked against the *resource*, not only the *route*. `trace_path` from the handler to the query that loads the record and confirm the caller's identity is compared against an ownership or ACL field before the read/write executes — a handler that only checks "is authenticated" and then loads by the id in the URL is the finding (BOLA, see above).
38
+ - [ ] No object reference from the client is trusted as ownership proof — same trace as above; the id in the request is data, not a credential.
39
+ - [ ] A caught exception or an unmatched branch in an authorisation check does not fail open. Read the authorisation helper's error handling directly — a `try/catch` around the permission check that falls through to "allow" on any exception, or a `switch`/`if` chain with no explicit deny in the default branch, is the finding. This is OWASP Top 10:2025 A10 (Mishandling of Exceptional Conditions), new for the 2025 edition.
40
+ - [ ] Mass assignment: `search_code` for `...req.body` spread into an update call, or an ORM `.update(req.body)`/`.save(req.body)` with no field allowlist. A hit with an explicit `pick`/DTO/schema validation between the request and the update is not the finding. OWASP API Security Top 10:2023 API3 (Broken Object Property Level Authorization / BOPLA).
41
+ - [ ] Default is deny. Check the router/framework's default for an unmatched or newly added route — a default-allow framework configuration is itself a finding even with no missing check found yet.
35
42
 
36
43
  ## Secrets
37
44
 
38
- - [ ] No secret in source, config committed to the repo, test fixture, or log line. `search_code` for `secret`, `password`, `token`, `api_key`, `private_key`, `Bearer`.
39
- - [ ] No secret in an error message, stack trace, or debug output.
40
- - [ ] Secrets come from the environment or a secret manager, and absence fails loudly at startup.
41
- - [ ] Check git history if a secret is found in the working tree — removal from HEAD does not remove it from history. Report the need for rotation.
45
+ - [ ] `search_code` for `secret`, `password`, `token`, `api_key`, `private_key`, `Bearer` as literal string assignments. This is the highest false-positive check in the whole skill — read every hit before reporting. A hit assigning a hardcoded literal (`"sk-...")`, `"changeme"` used as a real default, a real-looking key in a fixture reused outside tests) is the finding; a hit reading from `process.env`, a config object backed by env, or a secret-manager client call is not.
46
+ - [ ] No secret in an error message, stack trace, or debug output — read the logging/error-serialisation call sites found under Information disclosure below for a secret-bearing field, don't infer it.
47
+ - [ ] Secrets come from the environment or a secret manager, and absence fails loudly at startup. `search_code` the config-loading module for a fallback default on a secret-shaped key — a silent fallback (`|| 'default-secret'`) is the finding, not the absence of one. Application/service secrets should also carry an expiry or rotation mechanism, not just a source — read the secret-manager client call for a TTL/rotation parameter; its total absence on a long-lived service credential is `read`-tier evidence for a finding (this does not apply to user passwords, where mandatory periodic rotation is now considered outdated guidance per current NIST practice — do not flag its absence).
48
+ - [ ] If a secret is found in the working tree, check git history — removal from `HEAD` does not remove it from history. **Rotation is required regardless of whether the check-in was reverted or the history was later rewritten** — per OWASP's Secrets Management Cheat Sheet, squashing/rewriting history addresses the commit trail, not the exposure: the secret was retrievable, so it is compromised, full stop. Proactive, exhaustive history scanning is owned by `repo-history.md`; this line stays reactive — do not expand history work here.
42
49
 
43
50
  ## Transport and headers
44
51
 
45
- - [ ] TLS enforced; no plaintext transport for credentials or user data. No disabled certificate verification — `search_code` for `rejectUnauthorized: false` and equivalents.
46
- - [ ] CORS is not permissive-with-credentials. A wildcard origin plus credentials is `High`.
47
- - [ ] Cookies are `HttpOnly`, `Secure`, and have an appropriate `SameSite`.
48
- - [ ] State-changing requests are protected against cross-site forgery where cookie auth is used.
52
+ - [ ] TLS enforced; no plaintext transport for credentials or user data. `search_code` for `rejectUnauthorized: false`, `NODE_TLS_REJECT_UNAUTHORIZED=0`, `verify=False` (requests/httpx), or `InsecureSkipVerify: true` (Go) — each disables certificate verification outright and needs no further rule-out.
53
+ - [ ] CORS is not permissive-with-credentials. `search_code` for the CORS configuration and read it as one object — a wildcard origin (`*`) and `credentials: true` must be set on the *same* middleware instance to qualify; a wildcard on a public, unauthenticated endpoint with `credentials: false` elsewhere is not the finding.
54
+ - [ ] Cookies are `HttpOnly`, `Secure`, and have an appropriate `SameSite`. `search_code` for the cookie-setting call (`res.cookie(`, `Set-Cookie`, `set_cookie(`) and read the options object directly rather than assuming defaults.
55
+ - [ ] State-changing requests are protected against cross-site forgery where cookie auth is used. First confirm the auth mechanism: `search_code` for how the session is authenticated — a pure Bearer-token API with no cookie in the auth path does not need CSRF protection, and flagging its absence there is the false positive. Where cookie auth is confirmed, `search_code` for CSRF middleware/token verification and check it is wired into the state-changing routes, not just imported.
49
56
 
50
57
  ## Information disclosure
51
58
 
52
- - [ ] No stack trace, internal path, dependency version, or query text reaches a client. Cross-reference `failure.md`.
53
- - [ ] Error messages do not distinguish "no such user" from "wrong password".
54
- - [ ] Directory listing, source maps, and debug endpoints are disabled in production.
55
- - [ ] Logs do not contain credentials, tokens, or personal data — cross-reference `privacy.md`.
59
+ - [ ] No stack trace, internal path, dependency version, or query text reaches a client. `search_code` the central error handler for `err.stack`, `err.message`, or a caught error object serialised directly into the response body. Cross-reference `failure.md`.
60
+ - [ ] Error messages do not distinguish "no such user" from "wrong password". Read the login and password-reset handlers directly and literally compare the status code and message text returned on each branch — they must be identical, not merely similar.
61
+ - [ ] Directory listing, source maps, and debug endpoints are disabled in production. `search_code` the production build/deploy config for `sourceMap: true`, `devtool:` set to a non-hidden value, or a static-file server with listing enabled.
62
+ - [ ] Logs do not contain credentials, tokens, or personal data. Read what is passed to the logger at the request-boundary middleware — a logged `req` or `req.headers` object without redaction is the finding; cross-reference `privacy.md`.
56
63
 
57
64
  ## Dependencies
58
65
 
59
- - [ ] Known-vulnerable dependencies. Report the advisory, not a guess. Cross-reference `dependencies-licensing.md`.
60
- - [ ] Lockfile present and committed, so builds are reproducible.
66
+ - [ ] Known-vulnerable dependencies: cross-reference `dependencies-licensing.md` rather than duplicating that inventory here. Do not maintain a CVE list in this module — it goes stale the day it's written; live vulnerability status is unverifiable from source and belongs in Out of static reach.
67
+ - [ ] Lockfile present and committed, so builds are reproducible — `get_architecture` reports the package manager and manifest directly.
68
+
69
+ ## Out of static reach
70
+
71
+ - Whether a flagged dependency vulnerability is actually exploitable in this codebase's usage of it — that needs the vulnerable code path exercised, not just present.
72
+ - Live CVE/advisory status for any dependency — the manifest is a point-in-time read; advisories are published continuously.
73
+ - Whether network-layer controls (WAF rules, firewall policy, a reverse proxy's own header stripping) already mitigate a code-level finding.
74
+ - Actual production TLS/certificate configuration, as opposed to what the code declares — the deployed reality can diverge from the repo.
75
+ - Whether a secret found in git history has actually been rotated — this module can only prove exposure, not remediation; the reactive line above stays here, proactive scanning is `repo-history.md`'s job.
76
+ - Whether a rate limit, lockout policy, or auth control holds up under real concurrent traffic — cross-reference `abuse.md` and `concurrency.md` for the structural checks; effectiveness under load is not something source can show.
61
77
 
62
78
  ## Severity guidance
63
79
 
@@ -65,10 +81,11 @@ Enumerate the sinks, then check what reaches each one:
65
81
  |---|---|
66
82
  | Injection sink reachable from unvalidated external input | Critical |
67
83
  | Missing authorisation on a protected operation | Critical |
68
- | Secret committed to the repository | Critical |
84
+ | Secret committed to the repository (regardless of later history rewrite) | Critical |
69
85
  | Password stored unhashed or reversibly | Critical |
86
+ | Authorisation check fails open on an unhandled exception | High |
70
87
  | Certificate verification disabled | High |
71
- | Authorisation checked on route but not on resource | High |
88
+ | Authorisation checked on route but not on resource (BOLA) | High |
72
89
  | Wildcard CORS with credentials | High |
73
90
  | Non-constant-time secret comparison | Medium |
74
91
  | Missing cookie security attributes | Medium |
@@ -0,0 +1,73 @@
1
+ # State Model
2
+
3
+ Does every declared state get reached, and does everything that reads it agree on what it means? Gate: enumerated states, a status column, or a state library was detected.
4
+
5
+ This module audits explicit state machines and status fields — the enum, the `status` column, the state chart — as data. It does **not** own how a flow gets wired to UI events or navigation; that is `flow-integrity.md`. It does **not** own where a React component's or a store's state lives, or whether it is over- or under-lifted; that is `frontend.md`. If a check here starts asking "who calls `setState`", it belongs in one of those two instead.
6
+
7
+ A formal state model — a statechart, in Harel's original sense, standardised by the W3C as SCXML (a Recommendation since September 2015) and popularised in the JS ecosystem by XState — gives a codebase something a flat enum plus `switch` cannot express on its own: hierarchical (nested) states for sub-states that only carry meaning inside a parent, orthogonal/parallel regions for independent facets of status varying at once without a combinatorial cross-product enum, and a transition table where an edge must exist for a move to be legal at all, rather than any state being reachable from any other just because a write path didn't check. Every check below is, in effect, asking whether the codebase's enum-plus-switch is honouring guarantees a real state machine would have enforced structurally.
8
+
9
+ ## Enumerate the state set
10
+
11
+ - [ ] Find every declaration of the state set: an enum, a union type, a database column's `CHECK` constraint or comment listing valid values, a state-machine library's chart definition (XState, a `transitions` table). `find_symbol` on the type/enum name to get the canonical list.
12
+ - [ ] Find every place that switches on it: `find_callers` on the enum/type, then read each `switch`/`match`/if-chain for completeness against the list above.
13
+ - [ ] Note the state set's shape once, in prose, so every later check has a fixed reference — this is the yardstick, same discipline as establishing the token vocabulary in `design-system.md`.
14
+
15
+ ## Declared but unreachable
16
+
17
+ - [ ] A state present in the enum that no code path ever assigns. `search_code` the state's literal value as an assignment target (`status = 'archived'`, `.setState(Status.Archived)`); if nothing assigns it, it is dead data, not dead code — cross-reference `reachability.md` for the mechanics but report the finding here since the enum is the artefact.
18
+ - [ ] A state assigned only in a test fixture or seed script, never by application logic — the same shape, one layer removed.
19
+
20
+ ## Assigned but unhandled
21
+
22
+ - [ ] The inverse and more dangerous gap: a state that gets assigned somewhere but that a `switch`/`match` elsewhere doesn't handle. Read each switch site found via `find_callers` above for a **missing `default`/`else` arm** — code that silently falls through and does nothing is worse than a crash, because nothing signals the gap ever fired.
23
+ - [ ] `search_code` for the exhaustiveness marker itself (`: never`, `assertNever(`, `@Exhaustive`, a sealed-class `when` in Kotlin). Its absence at a switch site is exactly what let the current gaps exist, and adding it is the fix that prevents the next one. Cross-reference `type-safety.md` if the exhaustiveness gap is hidden behind an `any`/suppressed cast.
24
+ - [ ] Among the switch sites read above, a `default`/`else` arm that maps every unrecognised state to some fallback value rather than erroring or logging — a milder form of the same gap: it hides a genuinely unhandled state behind output that looks intentional, so nobody notices the switch was incomplete.
25
+ - [ ] Every creation path (constructor, insert, factory function) assigns one of the declared states explicitly. `search_code` the record's construction sites; a field left `null`/undefined at insert time behaves as a phantom extra state that no switch was written to handle.
26
+
27
+ ## Transitions
28
+
29
+ - [ ] Every transition path is deliberate: `trace_path` (or a straightforward read of the transition table) from each state to the states it's allowed to reach. A transition with no guard — any state can jump to any other by just setting the field — is not a state machine, it's a label.
30
+ - [ ] Transitions that skip a declared intermediate state. If the model says `draft → review → published`, `search_code` every write site setting `published` directly (`status = 'published'`, `.setState(Status.Published)`) and check its originating state — confirm any direct `draft → published` write is intentional (an admin override) rather than a bypass nobody meant to allow.
31
+ - [ ] Terminal states with a way out that shouldn't exist — `search_code` for a write to the state field inside any code path reachable after a `cancelled`/`refunded`/terminal check, e.g. `if (status === 'cancelled') { ... status = ... }`.
32
+ - [ ] Non-terminal states with no path forward at all: cross-check the transition table built above — any state that appears as a **target** of some transition but never as a **source** of one. Records land there and stay forever. Rule out first: a manual/support-only transition that's real but undocumented in code (an admin panel, a direct DB fix) — state which you checked.
33
+
34
+ ## Duplicated state sets
35
+
36
+ - [ ] The same conceptual state set declared twice — a backend enum and a frontend union, a database `CHECK` constraint and a client-side type — and already out of sync. Diff the literal member lists; a backend value with no frontend counterpart renders as `undefined`/a blank label, not an error. **Cross-reference `cross-surface-parity.md`**, which owns diverged behavioural rules between surfaces; this module reports the divergence, that module tracks the general pattern.
37
+ - [ ] Where a shared type is meant to be the single source, `search_code` the second surface's directory for a local re-declaration of the same enum/union name rather than an import from the shared location — a local copy that happens to match today is the drift waiting to happen.
38
+
39
+ ## Persisted values the code no longer knows about
40
+
41
+ - [ ] Values existing in stored data (a `status` column, a serialized state field) that don't appear in the current enum at all — the fingerprint of a state renamed or removed without a data migration. `search_code` for the old name in migration history or a comment; if the current switch has no case for it, every row carrying that value falls through the unhandled-state gap above, silently, in production, for real records.
42
+ - [ ] `search_code` migration files for an `ALTER`/`CHECK`-constraint change to the state column with no accompanying `UPDATE` statement backfilling the old values to a valid new one.
43
+
44
+ ## Concurrency on transitions
45
+
46
+ - [ ] `search_code` each transition function found above for a read-then-write shape (fetch the record, check its current state, then write the new one) with no atomic guard — optimistic lock, unique constraint, or conditional `UPDATE ... WHERE status = ...`. Two concurrent requests (a double-submit, a webhook retry) racing this gap will both pass the check and both write. Cross-reference `concurrency.md`'s read-modify-write section; report the state-specific instance here.
47
+ - [ ] A self-transition (a record transitioning back into the state it's already in) unintentionally re-firing side effects — a confirmation email, a webhook, a billing event — that were meant to fire once on entry. `find_callees` on the transition handler to see what it triggers, then check whether it guards on "value actually changed" before triggering them.
48
+
49
+ ## Display and downstream consumers
50
+
51
+ - [ ] `search_code` the label/badge/translation lookup that renders the state to a user and diff its case list against the canonical enum from the first section. A state with no display case renders a blank, the raw enum key, or throws, depending on the language's default behaviour for an unmatched case.
52
+ - [ ] `search_code` filter and sort UI (a dashboard's status filter, a report's grouping control) for a hardcoded local list of state values, and diff it against the canonical enum — a state added later silently never appears as a filter option, and records in it become invisible to anyone filtering.
53
+
54
+ ## Out of static reach
55
+
56
+ - Whether an admin-only or support-tooling transition is intentional versus a bypass — usually needs a person to confirm.
57
+ - The actual frequency a given transition fires in production, which decides how urgent an unguarded race really is.
58
+ - Whether a "stuck" non-terminal state is a real dead end or one only reachable through an out-of-repo system (a support queue, a manual ops runbook).
59
+
60
+ ## Severity guidance
61
+
62
+ | Situation | Severity |
63
+ |---|---|
64
+ | Persisted value with no current code path that handles it | Critical |
65
+ | Assigned state with no handling branch (silent no-op) | High |
66
+ | Transition with no guard, reachable from any state | High |
67
+ | Non-terminal state with zero outgoing transitions | High |
68
+ | Same state set duplicated across surfaces and diverged | High |
69
+ | Transition skipping a declared intermediate state | Medium |
70
+ | Terminal state with an unintended exit path | Medium |
71
+ | Missing exhaustiveness check on a state switch | Medium |
72
+ | Declared state never assigned by any code path | Medium |
73
+ | Race on a transition with no atomic guard | Medium (High if it double-charges/double-ships) |
@@ -0,0 +1,64 @@
1
+ # Supply Chain
2
+
3
+ Can the artefact you ship be trusted, and can the build that produced it be reproduced? Gate: a lockfile or dependency manifest is present.
4
+
5
+ `dependencies-licensing.md` owns *which* dependencies exist — their weight, health, and licences. This module does not repeat that inventory; it owns a different question: how each dependency **arrives**, whether the version that lands on a machine is the version anyone reviewed, and whether the build pipeline itself is a trusted, reproducible thing. A project can have perfectly healthy, permissively-licensed dependencies and still be compromised at the point where they are fetched, installed, or published — that gap is this module's entire scope, and it is no longer a specialist corner: OWASP's Top 10:2025 ranks it **A03:2025 — Software Supply Chain Failures**, a top-three category, widened from 2021's narrower A06 "Vulnerable and Outdated Components" (which only covered *using* a component with a known vulnerability) to the whole chain of how a dependency arrives. That 2021→2025 widening is exactly the line this module draws against `dependencies-licensing.md`.
6
+
7
+ ## Install-time execution
8
+
9
+ - [ ] `search_code` the project's own manifest for `postinstall`, `preinstall`, and `prepare` scripts, and — for any package with native bindings — a `binding.gyp` file. Lifecycle scripts are not the only install-time execution vector: 2026 npm worm campaigns shipped a weaponised `binding.gyp` that triggers `node-gyp` to run attacker code during `install`, specifically because scanners that only watch the `scripts` field miss it.
10
+ - [ ] Whether the install pipeline disables or audits scripts from dependencies — `search_code` CI config and root config files for `--ignore-scripts` (npm/pnpm), `enable-scripts` (yarn), or `trustedDependencies` (bun). **Falsify before flagging as missing**: some package managers ship this off by default and rely on an allowlist file instead — confirm the allowlist exists rather than assuming no gate at all.
11
+ - [ ] If scripts are not disabled, whether any allowlist restricts which packages may run them — `search_code` for `trustedDependencies`, an `.npmrc` scripts setting, or the package manager's equivalent — rather than trusting the entire dependency tree by default.
12
+
13
+ ## Lockfile integrity
14
+
15
+ - [ ] Lockfile present and committed — `get_architecture` packageManager, then confirm the lockfile file itself is tracked (`search_code` or a direct path check), not merely present on disk and gitignored.
16
+ - [ ] Manifest ranges the lockfile actually satisfies. Read a sample of `dependencies` entries against their resolved lockfile versions — a range the lockfile does not satisfy means a fresh `install` on CI resolves something nobody tested locally. This is the single most common source of "works on my machine, breaks in CI."
17
+ - [ ] In a monorepo, every workspace has its dependencies covered by the root lockfile — `search_code` for a `workspaces` / `packages` field, then confirm no workspace manifest references a dependency absent from the lockfile.
18
+ - [ ] Integrity hashes present for every lockfile entry (`integrity`, `resolved` + checksum, or the package manager's equivalent). An entry with a version but no hash trusts the registry's word at every future install, not just this one.
19
+ - [ ] Only one package manager's lockfile is present. Two lockfiles from different tools (`package-lock.json` alongside `pnpm-lock.yaml`) means whichever one CI happens to read is the one actually enforced, and a developer using the other tool silently resolves a different tree.
20
+ - [ ] What "locked" means for this ecosystem, checked rather than assumed. `Cargo.lock`, `package-lock.json`/`pnpm-lock.yaml`/`bun.lock`, and `uv.lock` each pin the full resolved dependency graph with a per-entry hash — `go.sum` does not: it is an append-only checksum ledger for modules already downloaded, not a resolved-graph lock, so read it alongside `go.mod` under `-mod=readonly` rather than treating it as equivalent. A Python project's `requirements.txt` with exact `==` pins looks locked but carries no hash unless generated with `--require-hashes` (e.g. via `pip-compile --generate-hashes`) — `search_code` for the flag before assuming pinned means verified.
21
+
22
+ ## Provenance and pinning
23
+
24
+ - [ ] A minimum-release-age (cooldown) is configured so a freshly-published version cannot resolve immediately — `search_code` for npm's `min-release-age`, pnpm's `minimumReleaseAge` (paired with `trustPolicy: no-downgrade`, pnpm ≥10.21), or Bun's `install.minimumReleaseAge` in `bunfig.toml` (Bun ≥1.3). Most compromised releases are pulled within hours; its absence means every install races the takedown.
25
+ - [ ] Dependency sources beyond the default registry — `search_code` the lockfile for `git+`, `github:`, direct tarball URLs, or `file:`/`link:` local paths. Each is a supply-chain path the registry's own integrity checks do not cover.
26
+ - [ ] Any git-sourced dependency pinned to a branch or tag rather than a commit SHA — read the lockfile's `git+` entries for a `#<sha>` suffix versus a branch or tag name. A branch ref is mutable — the maintainer can push different code to it tomorrow and every future install silently picks it up.
27
+ - [ ] CI action versions pinned by a full 40-character commit SHA, not a moving tag — the only form GitHub treats as immutable (`uses: actions/checkout@11bd719… # v4.2.2` vs `@v4`) — `search_code` workflow files for `uses:` lines. GitHub's actions-policy can enforce this org-wide (SHA-pinning policy, GA since August 2025); a repo relying on that alone, rather than the pin itself, is still unproven from source.
28
+ - [ ] Container base images pinned by digest (`FROM image@sha256:…`) rather than a tag that can be repointed (`:latest`, `:20`) — `search_code` Dockerfiles for `FROM`.
29
+
30
+ ## Release and publish trust
31
+
32
+ - [ ] SBOM generation as part of the release process — `search_code` release workflows for an SBOM tool invocation (`cyclonedx`/`cdxgen` for CycloneDX (spec 1.7, Mar 2026 — the final release in the 1.x line, backward compatible with 1.4–1.6; 2.0 is expected later in 2026, so a reader re-checking this later should confirm 1.7 is still current), `syft` for SPDX (spec 3.0.1, current since the 3.0 line shipped Apr 2024; a 3.1 release candidate is underway), `npm sbom`, or equivalent) and confirm the output is actually published as a release artefact, not just generated and discarded.
33
+ - [ ] Provenance or attestation on published artefacts — `search_code` for `npm publish --provenance`, PyPI Trusted Publishing, a `cosign sign`/`cosign attest` step, or GitHub's `actions/attest-build-provenance` action. All four now produce a DSSE-wrapped in-toto statement verifiable with a single tool (cosign v3 reads npm provenance, GitHub Attestations, and Homebrew provenance alike) — confirm the step exists, not that anyone has ever run verification against it.
34
+ - [ ] Who can publish the artefact — `search_code` the publish workflow for the trigger condition (tag push, manual approval, protected branch) and whether the publishing token is scoped to this package alone or holds broader org access.
35
+ - [ ] Whether publishing requires a review gate — `search_code` the publish workflow for a required-approval step or a branch-protection prerequisite before the tag that triggers release — rather than firing on any push to a default branch.
36
+
37
+ ## Impersonation and unvetted origin
38
+
39
+ - [ ] Internal-looking package names resolved from a public registry rather than a private one — read the manifest for names that look like internal tooling (`@company/*`, `internal-*`) and confirm they resolve from a scoped/private registry, not the public one, where a typosquat could sit under the same unscoped name.
40
+ - [ ] Vendored or copied third-party code with no recorded origin — `search_code` for a directory of third-party-looking code with no corresponding manifest entry, no `LICENSE`, and no comment naming its source or version. This is the one class of risk no dependency tool will ever surface, because it was never declared a dependency at all.
41
+
42
+ ## Out of static reach
43
+
44
+ - Whether a registry package's published tarball actually matches its public source repository at that version — requires fetching and diffing both, not reading the manifest.
45
+ - Runtime behaviour of any postinstall script or `binding.gyp`-triggered native build — this module can enumerate that scripts (or build files) exist, not what they do without executing them.
46
+ - Whether `--ignore-scripts` (or its equivalent) is actually honoured at install time in CI, versus merely configured somewhere and silently overridden.
47
+ - Registry-level compromise of a dependency between the version pinned in the lockfile and what a fresh resolve would fetch today.
48
+ - Whether the SBOM checked into the release matches the artefact that was actually built and shipped, rather than one generated from a different commit.
49
+
50
+ ## Severity guidance
51
+
52
+ | Situation | Severity |
53
+ |---|---|
54
+ | Git dependency pinned to a mutable branch, not a commit | High |
55
+ | Postinstall scripts enabled with no allowlist across the full dependency tree | High |
56
+ | Lockfile absent, uncommitted, or not satisfying the manifest range | High |
57
+ | Publish token unscoped or publish requires no review gate | High |
58
+ | Internal-looking package name resolving from the public registry | High |
59
+ | CI action or base image pinned by moving tag, not digest/SHA | Medium |
60
+ | No SBOM or provenance attestation in the release process | Medium |
61
+ | Vendored code with no recorded origin or version | Medium |
62
+ | Lockfile entry missing an integrity hash | Medium |
63
+ | Monorepo workspace not covered by the root lockfile | Medium |
64
+ | No minimum-release-age / cooldown configured on the package manager | Medium |
@@ -0,0 +1,66 @@
1
+ # Temporal
2
+
3
+ Does the code agree with itself about what time it is? Gate: dates, schedules, expiry, or scheduling logic present.
4
+
5
+ `database.md` notes, in one line, whether timestamp columns are timezone-aware. `testing.md` notes, in one line, whether tests depend on wall-clock time. Neither goes further than that. This module owns everything else about temporal correctness: the instant-versus-civil-time distinction that causes most date bugs, DST arithmetic, serialisation at every boundary, and the clock as a dependency nobody injected. If a finding is about the *storage type* of a column, it belongs in `database.md`; if it is about *what the code does* with the value once read, it belongs here.
6
+
7
+ The instant/civil distinction this module probes for by hand is, as of ECMAScript 2026, a distinction the language itself now names: TC39's Temporal proposal reached Stage 4 in March 2026 and ships unflagged in Firefox 139+, Chrome/Edge 144+, and Node.js 26+ (not yet in Safari as of this writing) — `Temporal.Instant` for a fixed point in time, `Temporal.PlainDateTime`/`Temporal.PlainDate` for a genuinely civil value with no zone attached, and `Temporal.ZonedDateTime` for a value that carries both. A codebase still on a modern runtime but exclusively using legacy `Date` for a "deliver at 9am local" feature had, until recently, no first-party type to reach for instead — that gap is closing, and its presence is useful context, not itself a defect.
8
+
9
+ ## Storage and representation
10
+
11
+ - [ ] Every timestamp column's declared type: `search_code` the schema/migrations for date fields, then `find_symbol` the column type. `TIMESTAMP WITHOUT TIME ZONE` (or a driver default that behaves like it) storing a value the application treats as an instant is a defect — the offset is silently lost, and every read is a guess about what zone it was written in.
12
+ - [ ] The inverse: a genuinely civil datetime — "9am local, wherever local is" — stored in a timezone-aware column. This double-converts on every read, because the column assumes a single instant and civil time by definition is not one.
13
+ - [ ] Naive local time (`new Date()`, `datetime.now()`, `time.Now()` with no explicit zone) used at a boundary that is supposed to represent a fixed instant — a token expiry, an audit log entry, a scheduled-at field. Rule out first: a value that is genuinely display-only and never compared or persisted is not a defect.
14
+ - [ ] The instant/civil conflation itself: a "deliver at 9am" feature that stores a single UTC instant instead of a wall-clock time plus a zone. This is correct in the sender's zone and wrong in every other zone, and DST will additionally shift it twice a year.
15
+
16
+ ## DST and calendar arithmetic
17
+
18
+ - [ ] Any `addDays`/`addHours`-style call used to mean "the same wall-clock time tomorrow" rather than "24 hours from now" — `search_code` for day-arithmetic helpers and read what they add. Adding 24 hours across a DST transition lands one hour off the intended wall-clock time.
19
+ - [ ] Recurring schedules (`search_code` for cron-like fields, `RRULE`, or a "repeat every" config) evaluated in a fixed offset rather than a named zone. A schedule anchored to `UTC-5` drifts by an hour relative to local time twice a year; one anchored to `America/Bogota` does not, because Bogota has no DST — the distinction matters exactly where DST exists.
20
+ - [ ] Time ranges spanning a "spring forward" gap (a wall-clock hour that never occurs) or a "fall back" overlap (an hour that occurs twice). A range built from raw wall-clock start/end without zone-aware arithmetic can silently normalise a nonexistent time to something else, or double-count the ambiguous hour.
21
+ - [ ] Whether ambiguous/nonexistent-hour disambiguation is explicit at each construction site rather than left to whatever the library defaults to — `search_code` for tz-aware datetime construction (Python's `fold` attribute or `is_dst=`, JS's `Temporal.ZonedDateTime.from(..., { disambiguation })`) with no argument supplied. Defaults genuinely differ by library and this is a common false assumption: Python's `zoneinfo` (PEP 495) and `pytz` both silently pick a side (the earlier occurrence, or `is_dst=False`) with no error, while `pandas.Series.dt.tz_localize` raises by default (`ambiguous='raise'`, `nonexistent='raise'`) — a codebase mixing both in one pipeline can have one path fail loudly and the adjacent one fail silently on the same kind of input.
22
+ - [ ] Month-end and leap-year arithmetic: adding a month to 31 January, or a year to 29 February. `search_code` for manual `setMonth`/`setDate`/`setFullYear` chains rather than a date library's calendar-aware add.
23
+ - [ ] Week-numbering assumptions (ISO week vs. US week, week start on Sunday vs. Monday) applied inconsistently between a report and the UI that renders it.
24
+ - [ ] A container/base-image build (`Dockerfile`, base-image manifest) with no mechanism to keep its bundled tz database current — `search_code` the Dockerfile for a `tzdata` package install with no update step, or a base image pinned by digest with no rebuild trigger. The IANA tz database releases several times a year whenever a government changes DST/offset rules (real 2026 examples: Alberta moving to permanent UTC-6, Morocco moving to permanent UTC+0); an image built once and never rebuilt computes the *old* rule for that zone until it is, which reproduces as "the time is right most of the year, then off by an hour around the transition." This is a `read` finding on the Dockerfile itself, not a claim about the deployed environment's actual tzdata version — that stays under Out of static reach.
25
+
26
+ ## Serialisation and boundaries
27
+
28
+ - [ ] Every wire boundary — API response, queue payload, log line, cache key — for date fields: does serialisation preserve the offset (ISO 8601 with `Z`/offset, or an explicit epoch) or silently drop it (a bare `YYYY-MM-DD HH:mm:ss`)? `search_code` the serializer/formatter used at each boundary. A numeric offset alone (`-04:00`) doesn't say which named zone/DST rule produced it — RFC 9557's Internet Extended Date/Time Format (IXDTF, the format `Temporal.ZonedDateTime.toString()` emits) adds a bracketed zone-name suffix (`-04:00[America/New_York]`) precisely to keep that disambiguated across a wire boundary; its absence isn't a defect on its own, but a codebase reinventing the same suffix ad hoc is a signal to check the two ends actually agree on the convention.
29
+ - [ ] A queue payload or webhook body carrying a naive timestamp string with no documented zone contract between producer and consumer — `trace_path` from producer to consumer to confirm both sides agree, rather than assuming they do.
30
+ - [ ] Comparisons between values of different kinds — an instant compared to a civil datetime, or a stored UTC value compared to a freshly-constructed local `Date` without normalising both sides first.
31
+ - [ ] `now()` (or its language equivalent) called more than once within a single logical operation — `search_code` for repeated `Date.now()`/`time.Now()` calls inside one function or one request. Two calls milliseconds apart can straddle a rounding boundary and disagree, and a "created before it expired" check built from two separate `now()` reads is not atomic.
32
+
33
+ ## Clock as a dependency
34
+
35
+ - [ ] `Date.now()`, `new Date()`, or the platform equivalent called directly deep inside business logic rather than through an injected clock/`now` parameter. `find_callers` on the logic function — if none of its callers can supply a fixed time, the logic is untestable for anything time-dependent and every "what happens near midnight / near expiry" case is unverifiable without wall-clock waiting.
36
+ - [ ] Expiry and TTL arithmetic: off-by-one at the boundary (`<` vs `<=` against the expiry instant), and which clock performs the check — client-supplied time versus server time. A client clock that is wrong, or deliberately manipulated, must never be the authority for an expiry decision.
37
+ - [ ] Cron/schedule expressions read against their documented intent — `search_code` the expression and compare it to what the surrounding comment or config name claims it does. A drifted expression (`0 0 * * 1` labelled "daily") is a silent scope change.
38
+ - [ ] What happens to a missed scheduled run (process was down, deploy in progress): does the job catch up, skip, or run every missed occurrence at once on restart? `find_callees` from the scheduler entry point to see if a catch-up path exists at all.
39
+
40
+ ## Presentation
41
+
42
+ - [ ] User-facing date/time formatting rendered in the server's zone rather than the user's — `search_code` for a formatter call with no zone argument on a value ultimately shown to a user. Cross-reference `i18n.md` for locale-specific format conventions (12h/24h, date order); this module owns whether the *zone* is right, `i18n.md` owns whether the *format* is right.
43
+
44
+ ## Out of static reach
45
+
46
+ - Whether a DST transition actually reproduces the bug in the deployed environment's real timezone database version.
47
+ - Clock skew between distributed nodes at runtime.
48
+ - Whether a cron scheduler's actual trigger times match the expression under real load (delayed execution, overlapping runs).
49
+ - User-perceived correctness of "relative time" displays ("3 hours ago") as real time elapses.
50
+
51
+ ## Severity guidance
52
+
53
+ | Situation | Severity |
54
+ |---|---|
55
+ | Instant stored as naive local time at a security-relevant boundary (token/session expiry) | Critical |
56
+ | Expiry checked against client-supplied clock | High |
57
+ | Timestamp column type disagrees with what the application treats it as | High |
58
+ | Serialisation drops offset at a cross-service boundary | High |
59
+ | `addDays`-style arithmetic used across a DST boundary for wall-clock intent | Medium |
60
+ | Ambiguous/nonexistent-hour disambiguation left to an unstated library default | Medium |
61
+ | `now()` called multiple times in one operation with no single source of truth | Medium |
62
+ | Hardcoded clock access preventing time-dependent logic from being tested | Medium |
63
+ | Missed-schedule catch-up behaviour undefined | Medium |
64
+ | User-facing time rendered in server zone instead of user zone | Medium |
65
+ | Base image with no tzdata update mechanism | Low |
66
+ | Week-numbering or month-end drift between two surfaces | Low |