project-brain 0.15.0 → 0.16.1

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 (37) hide show
  1. package/README.md +52 -1
  2. package/package.json +7 -6
  3. package/templates/skills/brain-audit/SKILL.md +134 -0
  4. package/templates/skills/brain-audit/references/abuse.md +59 -0
  5. package/templates/skills/brain-audit/references/accessibility.md +55 -0
  6. package/templates/skills/brain-audit/references/ai.md +51 -0
  7. package/templates/skills/brain-audit/references/api.md +47 -0
  8. package/templates/skills/brain-audit/references/backend.md +48 -0
  9. package/templates/skills/brain-audit/references/complexity.md +52 -0
  10. package/templates/skills/brain-audit/references/concurrency.md +60 -0
  11. package/templates/skills/brain-audit/references/consistency.md +59 -0
  12. package/templates/skills/brain-audit/references/contract-drift.md +58 -0
  13. package/templates/skills/brain-audit/references/cost.md +60 -0
  14. package/templates/skills/brain-audit/references/database.md +59 -0
  15. package/templates/skills/brain-audit/references/dependencies-licensing.md +59 -0
  16. package/templates/skills/brain-audit/references/devops.md +61 -0
  17. package/templates/skills/brain-audit/references/documentation.md +56 -0
  18. package/templates/skills/brain-audit/references/failure.md +58 -0
  19. package/templates/skills/brain-audit/references/flow-integrity.md +61 -0
  20. package/templates/skills/brain-audit/references/frontend.md +51 -0
  21. package/templates/skills/brain-audit/references/functional.md +39 -0
  22. package/templates/skills/brain-audit/references/future.md +31 -0
  23. package/templates/skills/brain-audit/references/goal.md +38 -0
  24. package/templates/skills/brain-audit/references/i18n.md +61 -0
  25. package/templates/skills/brain-audit/references/infrastructure.md +62 -0
  26. package/templates/skills/brain-audit/references/mobile.md +58 -0
  27. package/templates/skills/brain-audit/references/observability.md +55 -0
  28. package/templates/skills/brain-audit/references/packaging.md +52 -0
  29. package/templates/skills/brain-audit/references/performance.md +58 -0
  30. package/templates/skills/brain-audit/references/privacy.md +63 -0
  31. package/templates/skills/brain-audit/references/product.md +34 -0
  32. package/templates/skills/brain-audit/references/prompt-spec-gap.md +41 -0
  33. package/templates/skills/brain-audit/references/reachability.md +58 -0
  34. package/templates/skills/brain-audit/references/scalability.md +55 -0
  35. package/templates/skills/brain-audit/references/security.md +75 -0
  36. package/templates/skills/brain-audit/references/testing.md +58 -0
  37. package/templates/skills/brain-audit/references/versioning-compatibility.md +59 -0
@@ -0,0 +1,55 @@
1
+ # Scalability
2
+
3
+ What breaks when there is more of everything? Gate: a queue, worker, or background jobs were detected.
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.
6
+
7
+ ## Horizontal readiness
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.
13
+
14
+ ## Queues and workers
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.
22
+
23
+ ## Data growth
24
+
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.
29
+
30
+ ## Backpressure
31
+
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.
36
+
37
+ ## Degradation
38
+
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.
42
+
43
+ ## Severity guidance
44
+
45
+ | Situation | Severity |
46
+ |---|---|
47
+ | Failed jobs silently dropped | High |
48
+ | In-memory state that breaks with a second instance | High |
49
+ | Unbounded retry on a poison message | High |
50
+ | Scheduled job with no leader election | High |
51
+ | Non-idempotent job under at-least-once delivery | High |
52
+ | No backpressure between producer and consumer | Medium |
53
+ | Unbounded data growth with no retention policy | Medium |
54
+ | Batch job that reprocesses everything | Medium |
55
+ | Offset pagination over a large dataset | Low |
@@ -0,0 +1,75 @@
1
+ # Security
2
+
3
+ Gate: auth, external input, or a network boundary was detected.
4
+
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
+
7
+ 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
+
9
+ ## Injection sinks
10
+
11
+ Enumerate the sinks, then check what reaches each one:
12
+
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`.
19
+
20
+ ## AuthN
21
+
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.
27
+
28
+ ## AuthZ
29
+
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.
35
+
36
+ ## Secrets
37
+
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.
42
+
43
+ ## Transport and headers
44
+
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.
49
+
50
+ ## Information disclosure
51
+
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`.
56
+
57
+ ## Dependencies
58
+
59
+ - [ ] Known-vulnerable dependencies. Report the advisory, not a guess. Cross-reference `dependencies-licensing.md`.
60
+ - [ ] Lockfile present and committed, so builds are reproducible.
61
+
62
+ ## Severity guidance
63
+
64
+ | Situation | Severity |
65
+ |---|---|
66
+ | Injection sink reachable from unvalidated external input | Critical |
67
+ | Missing authorisation on a protected operation | Critical |
68
+ | Secret committed to the repository | Critical |
69
+ | Password stored unhashed or reversibly | Critical |
70
+ | Certificate verification disabled | High |
71
+ | Authorisation checked on route but not on resource | High |
72
+ | Wildcard CORS with credentials | High |
73
+ | Non-constant-time secret comparison | Medium |
74
+ | Missing cookie security attributes | Medium |
75
+ | Internal detail disclosed in an error | Medium |
@@ -0,0 +1,58 @@
1
+ # Testing
2
+
3
+ Gate: test files are present **or conspicuously absent**. The absence case is the point — "this project has no tests" is a finding, not a reason to skip the module.
4
+
5
+ Coverage percentage is not the question. The question is: **which defects would this suite have caught?** Take the findings from the other modules and ask, for each, why no test failed.
6
+
7
+ ## Does the suite prove anything
8
+
9
+ - [ ] For each confirmed finding elsewhere in this audit, identify the missing test. That list is the most valuable output of this module.
10
+ - [ ] Tests assert behaviour, not implementation. A test that breaks on every refactor and passes through every real bug is negative value.
11
+ - [ ] Tests would fail if the feature broke. Try it mentally on the most important test: mutate the logic and ask whether an assertion catches it.
12
+ - [ ] No test asserts only that a function was called. Call-count assertions on a mock prove the test's own wiring.
13
+ - [ ] Assertions are specific — `toEqual` on a shape rather than `toBeDefined`, expected values rather than `expect.anything()`.
14
+
15
+ ## What is not covered
16
+
17
+ - [ ] Error paths. Most suites test only the happy path; cross-reference `failure.md` and check each error branch has a test.
18
+ - [ ] Boundaries: empty, one, many, maximum, negative, zero, unicode, very long.
19
+ - [ ] Concurrency. Tests run operations one at a time, which is why the defects in `concurrency.md` survive green suites. Note explicitly which are untestable as written.
20
+ - [ ] Idempotency and re-run paths.
21
+ - [ ] Migration and upgrade paths — reading state written by the previous version.
22
+ - [ ] The packaged artefact, as a consumer would use it. Cross-reference `packaging.md`: the suite runs from the repository where every file exists, which is exactly why it misses packaging bugs.
23
+
24
+ ## Test isolation
25
+
26
+ - [ ] **No test writes outside its own temporary directory.** Check for writes derived from the home directory, a global config path, or a shared data directory. A test that pollutes the developer's real environment is `High` — and it is easy to introduce accidentally when production code resolves paths from `homedir()`.
27
+ - [ ] Injection seams exist for anything that resolves a real path, spawns a process, or reaches the network — and the tests actually use them.
28
+ - [ ] Tests do not depend on execution order or on each other's leftovers.
29
+ - [ ] Each test cleans up on both the pass and the fail path.
30
+ - [ ] Nothing hits a real paid or external endpoint. Cross-reference `cost.md`.
31
+
32
+ ## Determinism
33
+
34
+ - [ ] No dependence on wall-clock time, current date, timezone, or locale without control.
35
+ - [ ] No dependence on unseeded randomness.
36
+ - [ ] No fixed sleeps standing in for synchronisation — that is a flake with a timer.
37
+ - [ ] No dependence on a fixed port, or ports are allocated dynamically. Fixed ports collide under parallel runs and in CI.
38
+ - [ ] **Known flaky tests are tracked, not tolerated.** A test that fails one run in ten is a real signal being discarded. Report each one with its observed failure rate.
39
+
40
+ ## Guard tests
41
+
42
+ - [ ] Where the codebase depends on two things agreeing — a manifest and a directory, a schema and a model, a gate table and a file set — a test asserts the agreement. Hand-maintained lists are fine; unguarded hand-maintained lists are not.
43
+ - [ ] **A guard nobody has watched fail is not a guard.** Verify each one by mutation: break the invariant deliberately, confirm the test fails, revert. Report guards that pass unconditionally.
44
+
45
+ ## Severity guidance
46
+
47
+ | Situation | Severity |
48
+ |---|---|
49
+ | No tests at all for correctness-critical logic | High |
50
+ | Test writes outside its temp directory into a real user path | High |
51
+ | Tests hitting real paid or external endpoints | High |
52
+ | A confirmed defect that the suite could have caught but does not | High |
53
+ | Guard test that cannot fail | Medium |
54
+ | Flaky test tolerated and untracked | Medium |
55
+ | No test for any error path | Medium |
56
+ | Fixed sleep standing in for synchronisation | Medium |
57
+ | Fixed port causing collisions under parallel runs | Medium |
58
+ | Tests asserting implementation rather than behaviour | Low |
@@ -0,0 +1,59 @@
1
+ # Versioning & Compatibility
2
+
3
+ Gate: a published package manifest or a release workflow was detected.
4
+
5
+ Every published thing has consumers you cannot see. This module asks whether a consumer who upgrades will survive it.
6
+
7
+ ## Public surface
8
+
9
+ - [ ] What is public is stated. Without a declared boundary, everything exported is public by accident and every internal rename is a breaking change.
10
+ - [ ] Internal-only exports are marked internal, or not exported. `find_callers` on each export — one with only in-repo callers is a candidate to unexport.
11
+ - [ ] Types and schemas that appear in public signatures are part of the contract, including their optional fields.
12
+ - [ ] Configuration keys, CLI flags, environment variables, and on-disk formats are public surface too. These are the ones teams forget.
13
+
14
+ ## Breaking-change discipline
15
+
16
+ - [ ] Version numbers follow a stated scheme, and breaking changes actually bump the breaking component. A major-version-zero project should say what its stability promise is.
17
+ - [ ] For each recent change to public surface, classify it: added (minor), fixed (patch), removed or narrowed (major). Report any misclassification.
18
+ - [ ] These are breaking even when they look small: narrowing an accepted input, adding a required parameter, changing a default, changing an error type, changing a return shape, renaming a config key, tightening validation.
19
+ - [ ] Behavioural breaks count, not only signature breaks. Same types, different meaning is worse — it compiles and misbehaves.
20
+
21
+ ## Deprecation
22
+
23
+ - [ ] Removals are preceded by a deprecation with a runtime warning and a stated replacement.
24
+ - [ ] Deprecations have a removal version, not just a label. Cross-reference `future.md`: an undated deprecation is kept forever.
25
+ - [ ] Both paths work during the overlap, and the old one is genuinely equivalent.
26
+ - [ ] Deprecation warnings are emitted once per process, not once per call.
27
+
28
+ ## Data and state compatibility
29
+
30
+ - [ ] Persisted formats carry a version field. Without one, the next reader must guess.
31
+ - [ ] The new version reads state written by the previous version. Test it, do not assume it.
32
+ - [ ] Forward compatibility is decided deliberately: does an older version encountering newer state fail loudly or corrupt quietly? Loudly is the only acceptable answer.
33
+ - [ ] Migrations of on-disk or cached state are idempotent and recoverable if interrupted.
34
+
35
+ ## Runtime and platform
36
+
37
+ - [ ] Declared engine and platform support matches what the code and dependencies actually require.
38
+ - [ ] Minimum supported versions are tested, not just declared. A CI matrix of one version supports one version.
39
+ - [ ] Newly used runtime APIs do not silently raise the real minimum below the declared one.
40
+
41
+ ## Communication
42
+
43
+ - [ ] Changes are recorded somewhere a consumer will find — changelog, release notes, or migration guide.
44
+ - [ ] Breaking changes state the migration, not just the fact.
45
+ - [ ] Entries correspond to real commits; a changelog nobody maintains is worse than none because it is trusted.
46
+
47
+ ## Severity guidance
48
+
49
+ | Situation | Severity |
50
+ |---|---|
51
+ | Breaking change shipped without a breaking version bump | High |
52
+ | Behavioural break with an unchanged signature | High |
53
+ | New version cannot read the previous version's persisted state | High |
54
+ | Persisted format with no version field | High |
55
+ | Removal with no prior deprecation | Medium |
56
+ | Deprecation with no removal version | Medium |
57
+ | Declared engine support wider than what the code requires | Medium |
58
+ | No declared public-surface boundary | Medium |
59
+ | Breaking change documented without a migration path | Low |