@mrciphersmith/keryx 0.4.29 → 0.4.31
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.
- package/dist/cli.js +2446 -1391
- package/dist/core.js +90 -27
- package/dist/keryx-general-worker-entry.js +82 -25
- package/package.json +1 -1
- package/src/gdskills/bundled/install-manifest.json +2 -0
- package/src/gdskills/bundled/rules/core/api-contracts.mdc +21 -136
- package/src/gdskills/bundled/rules/core/async-patterns.mdc +18 -171
- package/src/gdskills/bundled/rules/core/clean-architecture.mdc +21 -3
- package/src/gdskills/bundled/rules/core/cli-interface-design.mdc +63 -194
- package/src/gdskills/bundled/rules/core/code-style-patterns.mdc +36 -49
- package/src/gdskills/bundled/rules/core/concurrency-patterns.mdc +32 -0
- package/src/gdskills/bundled/rules/core/database-patterns.mdc +26 -148
- package/src/gdskills/bundled/rules/core/error-handling.mdc +7 -8
- package/src/gdskills/bundled/rules/core/frontend-assistant.mdc +14 -29
- package/src/gdskills/bundled/rules/core/layout-rendering.mdc +51 -0
- package/src/gdskills/bundled/rules/core/mobx-store-template.mdc +69 -511
- package/src/gdskills/bundled/rules/core/nestjs-dto.mdc +18 -36
- package/src/gdskills/bundled/rules/core/playwright-testing.mdc +35 -308
- package/src/gdskills/bundled/rules/core/security-baseline.mdc +18 -140
- package/src/gdskills/bundled/rules/core/solid-principles.mdc +31 -7
- package/src/gdskills/bundled/rules/core/storybook-guidelines.mdc +20 -22
- package/src/gdskills/bundled/rules/core/tdd-workflow.mdc +37 -74
- package/src/gdskills/bundled/rules/core/ui-anti-slop.mdc +48 -37
- package/src/gdskills/bundled/skills/quality/deprecation-path/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-architecture/SKILL.md +24 -60
- package/src/gdskills/bundled/skills/review/review-backend/SKILL.md +13 -65
- package/src/gdskills/bundled/skills/review/review-clean-code/SKILL.md +22 -35
- package/src/gdskills/bundled/skills/review/review-frontend/SKILL.md +16 -309
- package/src/gdskills/bundled/skills/review/review-frontend-conventions/SKILL.md +7 -21
- package/src/gdskills/bundled/skills/review/review-highload/SKILL.md +83 -227
- package/src/gdskills/bundled/skills/review/review-layout/SKILL.md +22 -28
- package/src/gdskills/bundled/skills/review/review-logic/SKILL.md +8 -8
- package/src/gdskills/bundled/skills/review/review-performance/SKILL.md +15 -37
- package/src/gdskills/bundled/skills/review/review-security-code/SKILL.md +7 -7
- package/src/gdskills/bundled/skills/review/review-style/SKILL.md +31 -66
- package/src/gdskills/bundled/skills/review/review-testing-practices/SKILL.md +21 -39
- package/src/gdskills/bundled/skills/review/review-ui-ux/SKILL.md +42 -82
- package/src/gdskills/bundled/stacks/angular/rules/coding-style.mdc +15 -57
- package/src/gdskills/bundled/stacks/angular/rules/patterns.mdc +16 -60
- package/src/gdskills/bundled/stacks/angular/rules/security.mdc +11 -49
- package/src/gdskills/bundled/stacks/angular/rules/testing.mdc +13 -52
- package/src/gdskills/bundled/stacks/c-cpp/rules/coding-style.mdc +33 -57
- package/src/gdskills/bundled/stacks/c-cpp/rules/patterns.mdc +35 -62
- package/src/gdskills/bundled/stacks/c-cpp/rules/security.mdc +35 -62
- package/src/gdskills/bundled/stacks/c-cpp/rules/testing.mdc +34 -54
- package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/patterns.mdc +27 -56
- package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/security.mdc +51 -119
- package/src/gdskills/bundled/stacks/csharp-dotnet/rules/coding-style.mdc +42 -74
- package/src/gdskills/bundled/stacks/csharp-dotnet/rules/patterns.mdc +45 -84
- package/src/gdskills/bundled/stacks/csharp-dotnet/rules/security.mdc +34 -59
- package/src/gdskills/bundled/stacks/csharp-dotnet/rules/testing.mdc +33 -62
- package/src/gdskills/bundled/stacks/django/rules/coding-style.mdc +15 -56
- package/src/gdskills/bundled/stacks/django/rules/patterns.mdc +16 -68
- package/src/gdskills/bundled/stacks/django/rules/security.mdc +13 -71
- package/src/gdskills/bundled/stacks/django/rules/testing.mdc +16 -62
- package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/coding-style.mdc +30 -53
- package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/patterns.mdc +20 -56
- package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/security.mdc +52 -122
- package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/testing.mdc +23 -42
- package/src/gdskills/bundled/stacks/fastapi/rules/coding-style.mdc +13 -47
- package/src/gdskills/bundled/stacks/fastapi/rules/patterns.mdc +18 -81
- package/src/gdskills/bundled/stacks/fastapi/rules/security.mdc +13 -75
- package/src/gdskills/bundled/stacks/fastapi/rules/testing.mdc +14 -58
- package/src/gdskills/bundled/stacks/flutter-dart/rules/coding-style.mdc +36 -74
- package/src/gdskills/bundled/stacks/flutter-dart/rules/patterns.mdc +30 -66
- package/src/gdskills/bundled/stacks/flutter-dart/rules/security.mdc +33 -67
- package/src/gdskills/bundled/stacks/flutter-dart/rules/testing.mdc +41 -73
- package/src/gdskills/bundled/stacks/go/rules/coding-style.mdc +36 -57
- package/src/gdskills/bundled/stacks/go/rules/patterns.mdc +27 -42
- package/src/gdskills/bundled/stacks/go/rules/security.mdc +26 -43
- package/src/gdskills/bundled/stacks/go/rules/testing.mdc +23 -41
- package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/coding-style.mdc +18 -37
- package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/patterns.mdc +26 -43
- package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/security.mdc +25 -37
- package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/testing.mdc +34 -50
- package/src/gdskills/bundled/stacks/kotlin-android/rules/coding-style.mdc +28 -65
- package/src/gdskills/bundled/stacks/kotlin-android/rules/patterns.mdc +34 -78
- package/src/gdskills/bundled/stacks/kotlin-android/rules/security.mdc +35 -68
- package/src/gdskills/bundled/stacks/kotlin-android/rules/testing.mdc +34 -68
- package/src/gdskills/bundled/stacks/mobx/rules/coding-style.mdc +18 -64
- package/src/gdskills/bundled/stacks/mobx/rules/patterns.mdc +13 -66
- package/src/gdskills/bundled/stacks/mobx/rules/security.mdc +8 -35
- package/src/gdskills/bundled/stacks/mobx/rules/testing.mdc +10 -39
- package/src/gdskills/bundled/stacks/nestjs/rules/coding-style.mdc +32 -45
- package/src/gdskills/bundled/stacks/nestjs/rules/patterns.mdc +40 -60
- package/src/gdskills/bundled/stacks/nestjs/rules/security.mdc +30 -50
- package/src/gdskills/bundled/stacks/nestjs/rules/testing.mdc +27 -47
- package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/coding-style.mdc +14 -48
- package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/patterns.mdc +15 -67
- package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/security.mdc +12 -50
- package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/testing.mdc +11 -43
- package/src/gdskills/bundled/stacks/php-laravel/rules/coding-style.mdc +17 -58
- package/src/gdskills/bundled/stacks/php-laravel/rules/patterns.mdc +15 -56
- package/src/gdskills/bundled/stacks/php-laravel/rules/security.mdc +13 -50
- package/src/gdskills/bundled/stacks/php-laravel/rules/testing.mdc +14 -55
- package/src/gdskills/bundled/stacks/python/rules/coding-style.mdc +13 -41
- package/src/gdskills/bundled/stacks/python/rules/patterns.mdc +20 -61
- package/src/gdskills/bundled/stacks/python/rules/security.mdc +15 -57
- package/src/gdskills/bundled/stacks/python/rules/testing.mdc +16 -50
- package/src/gdskills/bundled/stacks/react/rules/coding-style.mdc +14 -40
- package/src/gdskills/bundled/stacks/react/rules/patterns.mdc +15 -55
- package/src/gdskills/bundled/stacks/react/rules/security.mdc +13 -49
- package/src/gdskills/bundled/stacks/react/rules/testing.mdc +10 -37
- package/src/gdskills/bundled/stacks/ruby-rails/rules/coding-style.mdc +12 -45
- package/src/gdskills/bundled/stacks/ruby-rails/rules/patterns.mdc +18 -67
- package/src/gdskills/bundled/stacks/ruby-rails/rules/security.mdc +11 -60
- package/src/gdskills/bundled/stacks/ruby-rails/rules/testing.mdc +14 -65
- package/src/gdskills/bundled/stacks/rust/rules/coding-style.mdc +39 -65
- package/src/gdskills/bundled/stacks/rust/rules/patterns.mdc +33 -60
- package/src/gdskills/bundled/stacks/rust/rules/security.mdc +35 -57
- package/src/gdskills/bundled/stacks/rust/rules/testing.mdc +29 -52
- package/src/gdskills/bundled/stacks/sql-db/rules/coding-style.mdc +12 -48
- package/src/gdskills/bundled/stacks/sql-db/rules/patterns.mdc +22 -113
- package/src/gdskills/bundled/stacks/sql-db/rules/security.mdc +11 -56
- package/src/gdskills/bundled/stacks/sql-db/rules/testing.mdc +14 -59
- package/src/gdskills/bundled/stacks/swift-ios/rules/coding-style.mdc +29 -65
- package/src/gdskills/bundled/stacks/swift-ios/rules/patterns.mdc +41 -88
- package/src/gdskills/bundled/stacks/swift-ios/rules/security.mdc +28 -53
- package/src/gdskills/bundled/stacks/swift-ios/rules/testing.mdc +32 -65
- package/src/gdskills/bundled/stacks/vue/rules/coding-style.mdc +17 -52
- package/src/gdskills/bundled/stacks/vue/rules/patterns.mdc +17 -63
- package/src/gdskills/bundled/stacks/vue/rules/security.mdc +11 -41
- package/src/gdskills/bundled/stacks/vue/rules/testing.mdc +16 -48
|
@@ -38,10 +38,9 @@ review-backend Progress:
|
|
|
38
38
|
- [ ] Step 2: Determine git scope (merge-base) — see .metaproject/skills/gdskills/shared/git-merge-base.md
|
|
39
39
|
- [ ] Step 3: Collect diff and changed file list
|
|
40
40
|
- [ ] Step 4: NestJS patterns check
|
|
41
|
-
- [ ] Step 5: API
|
|
42
|
-
- [ ] Step 6:
|
|
43
|
-
- [ ] Step 7:
|
|
44
|
-
- [ ] Step 8: Emit findings in unified format, sorted by severity
|
|
41
|
+
- [ ] Step 5: API, DTO and database rules check (section 2)
|
|
42
|
+
- [ ] Step 6: TypeScript correctness check
|
|
43
|
+
- [ ] Step 7: Emit findings in unified format, sorted by severity
|
|
45
44
|
```
|
|
46
45
|
|
|
47
46
|
---
|
|
@@ -87,13 +86,6 @@ git diff --name-status "${BASE_SHA}" && git diff "${BASE_SHA}" && git ls-files -
|
|
|
87
86
|
- `REQUEST`-scoped provider injected into a `Singleton` provider is a **blocker** (creates hidden state sharing)
|
|
88
87
|
- `TRANSIENT` scope used unnecessarily when singleton would suffice — flag as `minor`
|
|
89
88
|
|
|
90
|
-
**DTO validation**
|
|
91
|
-
- All controller methods accepting user input (body, query, param) have a DTO class decorated with `class-validator` decorators
|
|
92
|
-
- Required fields: `@IsString()`, `@IsNumber()`, `@IsEmail()`, etc. present and accurate
|
|
93
|
-
- `@IsOptional()` used only on truly optional fields; non-optional fields must not have `@IsOptional()`
|
|
94
|
-
- `ValidationPipe` applied globally (in `main.ts`) or explicitly via `@UsePipes(ValidationPipe)` — missing on an endpoint accepting user input is rated by the DTO row of the conditions table
|
|
95
|
-
- `@Transform()` used where input coercion is needed (e.g., string → number from query params)
|
|
96
|
-
|
|
97
89
|
**Guards and roles**
|
|
98
90
|
- Protected endpoints have `@UseGuards(...)` with appropriate guard(s)
|
|
99
91
|
- Role-based access uses `@Roles(...)` decorator with a roles guard — a missing guard on an endpoint that should be protected is rated by the auth-guard row of the conditions table
|
|
@@ -111,57 +103,20 @@ git diff --name-status "${BASE_SHA}" && git diff "${BASE_SHA}" && git ls-files -
|
|
|
111
103
|
|
|
112
104
|
---
|
|
113
105
|
|
|
114
|
-
### 2. API
|
|
115
|
-
|
|
116
|
-
**HTTP method conventions**
|
|
117
|
-
- `GET` requests carry no body (flag as `major` if present)
|
|
118
|
-
- `POST` used for resource creation
|
|
119
|
-
- `PUT` for full replacement, `PATCH` for partial update — mixed usage without clear reason flagged as `minor`
|
|
120
|
-
- `DELETE` on correct resource path
|
|
121
|
-
|
|
122
|
-
**Response shape consistency**
|
|
123
|
-
- All endpoints in a controller return the same envelope shape (e.g., `{ data, meta }`) — inconsistency (sometimes object, sometimes raw array) flagged as `major`
|
|
124
|
-
- HTTP status codes match semantics: `201` for create, `200` for read/update, `204` for no-content delete, `404` for not found, `422` for validation failure
|
|
125
|
-
|
|
126
|
-
**Pagination**
|
|
127
|
-
- List endpoints that could return unbounded datasets must have pagination (`limit`/`offset` or `cursor`)
|
|
128
|
-
- Missing pagination on a list endpoint flagged as `major` when no obvious bound exists
|
|
129
|
-
|
|
130
|
-
**Error handling**
|
|
131
|
-
- Unhandled promise rejections are rated by `.metaproject/rules/core/error-handling.mdc` (**Review severities**): a rejection Nest's exception layer answers with an error response is not a crash; rate that response
|
|
132
|
-
- Exception messages must not leak internal details (stack traces, ORM error strings) to the HTTP response — leaking is rated by the stack-trace row of the conditions table
|
|
133
|
-
- NestJS built-in exceptions (`NotFoundException`, `BadRequestException`, etc.) preferred over generic `Error`
|
|
134
|
-
|
|
135
|
-
---
|
|
136
|
-
|
|
137
|
-
### 3. Database Patterns (ORM)
|
|
138
|
-
|
|
139
|
-
**N+1 queries**
|
|
140
|
-
- Relation loaded inside a loop without eager loading (`relations`, `leftJoinAndSelect`) or a DataLoader — rated by the N+1 row of the conditions table
|
|
141
|
-
- Example: `for (const user of users) { user.orders = await orderRepo.find(...) }` — flag with concrete suggestion to use `relations: ['orders']` or batch query
|
|
142
|
-
|
|
143
|
-
**Transactions**
|
|
144
|
-
- Multi-step operations that must be atomic (e.g., create + update + delete across tables) must use a transaction
|
|
145
|
-
- Missing transaction on a multi-step mutation is a **major** finding
|
|
146
|
-
- NestJS TypeORM: use `dataSource.transaction(async (manager) => { ... })` or `@Transaction()` decorator pattern
|
|
106
|
+
### 2. API, DTOs and database: the standard
|
|
147
107
|
|
|
148
|
-
**
|
|
149
|
-
- String interpolation in raw queries: SQL injection risk, rated by the raw-SQL row of the conditions table
|
|
150
|
-
- Use parameterized queries: `query('SELECT * FROM users WHERE id = $1', [id])`
|
|
151
|
-
- Flag `createQueryBuilder().where('id = ' + id)` under that row
|
|
108
|
+
These project rules hold what to check and how to rate it. Read each one that applies to the change and rate by its **Review severities** table; this lens does not restate them.
|
|
152
109
|
|
|
153
|
-
|
|
154
|
-
-
|
|
155
|
-
-
|
|
110
|
+
- `.metaproject/rules/core/api-contracts.mdc`: spec first, versioning, error envelope (validation failure is `400`), idempotency keys, list envelopes and pagination.
|
|
111
|
+
- `.metaproject/rules/core/nestjs-dto.mdc`: DTO classes, validators, nested and query transforms, Swagger decorators.
|
|
112
|
+
- `.metaproject/rules/core/database-patterns.mdc`: queries in loops, indexes, migration safety, transactions, `SELECT *`, soft deletes.
|
|
113
|
+
- `.metaproject/rules/core/security-baseline.mdc`: parameterized queries (string interpolation in raw SQL).
|
|
156
114
|
|
|
157
|
-
|
|
158
|
-
- Column removed in migration — check that no application code still references it
|
|
159
|
-
- Dropping a column without a deprecation period in a live system flagged as `major`
|
|
160
|
-
- `NOT NULL` column added without a default value to a populated table — `major`; `blocker` only on shown truncation
|
|
115
|
+
Beyond them: a `GET` with a body is `major`; `PUT` for full replacement and `PATCH` for partial; NestJS built-in exceptions over a generic `Error`; unhandled rejections are rated by `.metaproject/rules/core/error-handling.mdc` (a rejection Nest's exception layer answers with an error response is not a crash: rate that response).
|
|
161
116
|
|
|
162
117
|
---
|
|
163
118
|
|
|
164
|
-
###
|
|
119
|
+
### 3. TypeScript Correctness
|
|
165
120
|
|
|
166
121
|
- No `any` in new code — suggest `unknown` with type guards, or correct typed return
|
|
167
122
|
- Public service methods must have explicit return types (`Promise<UserDto>`, not inferred)
|
|
@@ -203,16 +158,11 @@ is, and a condition that cannot name one is not a `blocker`.
|
|
|
203
158
|
|
|
204
159
|
| Condition | Severity | Shape |
|
|
205
160
|
|---|---|---|
|
|
206
|
-
| Missing DTO validation on an endpoint accepting user input | `blocker` with an attack vector stated (input, entry point, impact — `review-security-code` law); `major` with a named malformed input and wrong outcome; else `info` | Exploitable vulnerability only when the vector is shown |
|
|
207
|
-
| String interpolation in raw SQL query | `blocker` with an attack vector stated (input, entry point, impact); `major` with a named input and wrong outcome; else `info` | Exploitable vulnerability only when the vector is shown |
|
|
208
161
|
| Leaking stack trace / raw ORM error to API response | `blocker` with an attack vector stated (what is disclosed, to whom, through which entry point); `major` when the leak is shown reaching a response; else `info` | Exploitable vulnerability only when the vector is shown; a shown leak is a wrong outcome |
|
|
209
162
|
| Missing auth guard on an endpoint that should be protected | `blocker` with an attack vector stated (caller, entry point, impact); `major` with a named caller and the wrong outcome it gets; else `info` | Exploitable vulnerability only when the vector is shown |
|
|
210
163
|
| `REQUEST`-scoped provider injected into a `Singleton` | `blocker` | Data corruption — one request's state is served to another |
|
|
211
|
-
|
|
|
212
|
-
|
|
|
213
|
-
| Missing transaction on a multi-step atomic mutation | `major` — `blocker` where a partial write corrupts persisted state | The outcome decides |
|
|
214
|
-
| Business logic in a controller | `minor` — `major` only with a concrete defect it causes (trigger and outcome) or a stated project rule it breaks | Layer violation. Same rating as `review-architecture` |
|
|
215
|
-
| Missing pagination on an unbounded list endpoint | `major` — `blocker` where an attacker-reachable request exhausts memory | Degradation vs. crash/DoS |
|
|
164
|
+
| DTO, API contract, query, migration and transaction conditions | per the rule's **Review severities** table (section 2) | The rule's row names the shape |
|
|
165
|
+
| Business logic in a controller | `minor` — `major` only with a concrete defect it causes (trigger and outcome) | Layer violation. Same rating as `review-architecture` |
|
|
216
166
|
|
|
217
167
|
---
|
|
218
168
|
|
|
@@ -340,10 +290,8 @@ When dispatched by `review-orchestrator` or `job-orchestrator`, the prompt MAY c
|
|
|
340
290
|
| Rationalization | Why it is wrong |
|
|
341
291
|
|----------------|-----------------|
|
|
342
292
|
| "ValidationPipe is probably configured somewhere" | Always verify it is applied; assumption lets injection reach service layer |
|
|
343
|
-
| "The N+1 only runs on small datasets now" | Data grows; flag it now with a clear fix, not after the incident |
|
|
344
293
|
| "The controller has some logic but it's minor" | Logic in a controller is `minor` unless a defect is named; say which, do not rate by feeling |
|
|
345
294
|
| "Stack trace in response only shows in dev" | Config can be wrong in prod; report it per the stack-trace row; blocker needs a shown vector |
|
|
346
|
-
| "I'll skip the migration check — it's just a column rename" | Column renames without fallback break zero-downtime deploys |
|
|
347
295
|
|
|
348
296
|
<!-- keryx:layers-block:start -->
|
|
349
297
|
## Project layers: graph, tests, wiki, memory
|
|
@@ -3,12 +3,13 @@ name: review-clean-code
|
|
|
3
3
|
model_tier: standard
|
|
4
4
|
description: |
|
|
5
5
|
Use when: reviewing code against Clean Code principles (Uncle Bob) and SOLID at the
|
|
6
|
-
function/class level —
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
function/class level — small functions, single level of abstraction, argument count,
|
|
7
|
+
error handling, DRY, magic literals, comment quality, and SRP, OCP, LSP and ISP as applied
|
|
8
|
+
to individual classes and functions.
|
|
9
9
|
Dispatched by review-orchestrator.
|
|
10
|
-
NOT for:
|
|
11
|
-
(review-style), logic correctness bugs (review-logic), or security
|
|
10
|
+
NOT for: layer violations, dependency inversion and circular imports (review-architecture),
|
|
11
|
+
names and readability (review-style), logic correctness bugs (review-logic), or security
|
|
12
|
+
(review-security-code).
|
|
12
13
|
triggers:
|
|
13
14
|
- "clean code review"
|
|
14
15
|
- "functions do too much"
|
|
@@ -41,23 +42,23 @@ there the payload supplies the history).
|
|
|
41
42
|
|
|
42
43
|
Read both rules before the diff. They are what the code was written against.
|
|
43
44
|
|
|
44
|
-
- `.metaproject/rules/core/solid-principles.mdc` — the **Thresholds** table
|
|
45
|
+
- `.metaproject/rules/core/solid-principles.mdc` — the **Thresholds** table, the SOLID rules and **Review severities**, which rate every SRP, OCP, LSP, ISP, duplication, magic-literal and comment finding.
|
|
45
46
|
- `.metaproject/rules/core/error-handling.mdc` — how failure is signalled, what a message carries, `cause`, silent catches.
|
|
46
47
|
|
|
47
48
|
A threshold there is your threshold. Under it, report nothing; never apply a
|
|
48
49
|
stricter textbook number. Where this file and a rule disagree, the rule wins.
|
|
49
50
|
|
|
51
|
+
Ownership: this lens owns SRP, OCP, LSP and ISP at class and function level, plus
|
|
52
|
+
duplication, magic literals and comments. `review-architecture` owns DIP, layers,
|
|
53
|
+
module boundaries and circular imports; `review-style` owns names and readability.
|
|
54
|
+
|
|
50
55
|
## Scope
|
|
51
56
|
|
|
52
57
|
Only code introduced or modified in this change.
|
|
53
58
|
|
|
54
|
-
**Debt the change did not create
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
function already past the length threshold, another copy of a literal already
|
|
58
|
-
copied 3+ times, another parameter on a signature already at 4+. It is a finding
|
|
59
|
-
when the change crosses from under to over, or when the diff adds a
|
|
60
|
-
self-contained block that meets the threshold on its own — cite that block.
|
|
59
|
+
**Debt the change did not create** is not a finding (`solid-principles.mdc`):
|
|
60
|
+
check the before-state first. It is a finding when the change crosses a threshold,
|
|
61
|
+
or adds a self-contained block that meets it alone; cite that block.
|
|
61
62
|
|
|
62
63
|
**Supplied text first.** When the payload carries `slices`, `context_files`, `diff` or `file_contents`, review exactly that text and never rebuild the diff. A choice's history (law 4) is read with `git log`, `git blame` and `git show` only where the host gives a read-only child git; on keryx shell a read-only child has no shell and no git tool, so read the `git log -L`/`git blame` excerpts the payload supplies, or say the history was not read. Only with none supplied, collect it:
|
|
63
64
|
```bash
|
|
@@ -82,8 +83,8 @@ boundary is the trigger-and-outcome test.
|
|
|
82
83
|
### Clean Code laws
|
|
83
84
|
|
|
84
85
|
1. **Every finding cites a `file:line` in the diff.** No observations about the codebase in general.
|
|
85
|
-
2. **
|
|
86
|
-
3. **Duplication needs 3+ copies
|
|
86
|
+
2. **Names are `review-style`'s.** This lens reports no naming finding.
|
|
87
|
+
3. **Duplication needs 3+ copies**, reported once with every copy, rated by the `solid-principles.mdc` table.
|
|
87
88
|
4. **A SOLID finding names the principle, the two responsibilities or the broken contract, and the impact**, or it is `info`.
|
|
88
89
|
5. **Language idioms and framework conventions are not violations.**
|
|
89
90
|
|
|
@@ -96,22 +97,8 @@ a named site, a threshold crossed by this change, a cost someone will pay.
|
|
|
96
97
|
| Signal | A finding when | Default | Not a finding |
|
|
97
98
|
|---|---|---|---|
|
|
98
99
|
| Failure paths: a hiding `catch`, failure as a value, lost `cause`, log-and-rethrow | per `error-handling.mdc` **Review severities** | as there | as there |
|
|
99
|
-
|
|
|
100
|
-
|
|
|
101
|
-
| Function length | over 40 lines **and** two separable jobs or mixed abstraction levels | `minor` (name the jobs) | a long linear table, serializer, test or one-level sequence |
|
|
102
|
-
| I/O mixed with a transform | one function reads or writes (file, network, store) and transforms the data in between, at any length | `minor` (name the transform that should be a pure helper) | the transform already lives in a helper the I/O shell calls |
|
|
103
|
-
| Positional parameters | 4+, no options object, not a natural ordered set the codebase already uses | `minor` | — |
|
|
104
|
-
| Boolean flag parameter | it selects between two behaviours (`run(x, true)`) | `minor` | — |
|
|
105
|
-
| Output argument | a function fills a caller-supplied argument instead of returning | `minor` | — |
|
|
106
|
-
| Constructor dependencies | more than 5 | `minor` (name the two responsibilities) | — |
|
|
107
|
-
| Class or function with two change drivers | you can name both (e.g. validation + persistence) | `minor` | — |
|
|
108
|
-
| Branch chain over a type discriminant | 4+ branches, extended by the diff, and a map/strategy precedent exists (name it) | `minor` | no precedent in the codebase |
|
|
109
|
-
| Interface wider than its implementers | implementers leave methods as stubs/no-ops | `minor` | — |
|
|
110
|
-
| Business logic constructing its I/O, network or clock dependency | always | `minor` | a plain helper or value object built inside a module |
|
|
111
|
-
| Duplicated block | 3+ copies | `minor`, one finding listing every copy | 2 copies |
|
|
112
|
-
| Magic number / repeated string literal | business meaning, no named constant | `minor` | `0`, `1`, `100` and other neutral values |
|
|
113
|
-
| Name | needs a comment to be understood; generic (`data`, `result`, `temp`); two names for one concept in the diff; ambiguous boolean polarity | `minor` | loop counters; project-standard abbreviations |
|
|
114
|
-
| Comment | stale, contradicting the code; redundant; commented-out code; compensating for a bad name | `minor` | intent, a domain constraint, a warning, a TODO with an issue |
|
|
100
|
+
| SRP, OCP, LSP, ISP: override that breaks the base contract, constructor I/O, function length, I/O mixed with a transform, parameters, constructor dependencies, branch chain, two change drivers, wide interface | per `solid-principles.mdc` **Review severities** | as there (LSP `major`, `blocker` when the broken caller is in the diff) | as there |
|
|
101
|
+
| Duplicated block, magic literal, comment | per `solid-principles.mdc` **Review severities** | as there | as there |
|
|
115
102
|
| Stylistic opinion; a future issue with no current violation | — | `info` | — |
|
|
116
103
|
|
|
117
104
|
## Documentation drift — search for it
|
|
@@ -130,8 +117,8 @@ Where an issue or PR is cited, check it is the right one and still says what the
|
|
|
130
117
|
|
|
131
118
|
| Concern | Use instead |
|
|
132
119
|
|---------|-------------|
|
|
133
|
-
| Layer violations, module coupling, dependency direction | `review-architecture` |
|
|
134
|
-
|
|
|
120
|
+
| Layer violations, module coupling, dependency direction, DIP (`new X()` for I/O), circular imports | `review-architecture` |
|
|
121
|
+
| Names, naming conventions, readability | `review-style` |
|
|
135
122
|
| Logic bugs, off-by-one errors, null-safety | `review-logic` |
|
|
136
123
|
| Security vulnerabilities | `review-security-code` |
|
|
137
124
|
| Performance anti-patterns | `review-performance` |
|
|
@@ -163,7 +150,7 @@ class_scope:
|
|
|
163
150
|
|
|
164
151
|
- **Severity**: blocker | major | minor | info
|
|
165
152
|
- **File**: path/to/file.ts:line
|
|
166
|
-
- **Principle**: Clean Code —
|
|
153
|
+
- **Principle**: Clean Code — function design | comments | error handling | DRY | SOLID — SRP/OCP/LSP/ISP
|
|
167
154
|
- **Problem**: what is wrong and why it matters
|
|
168
155
|
- **Fix**: concrete actionable suggestion
|
|
169
156
|
```
|
|
@@ -193,7 +180,7 @@ STATUS: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED
|
|
|
193
180
|
- blocker: N | major: N | minor: N | info: N
|
|
194
181
|
|
|
195
182
|
### Findings
|
|
196
|
-
One `####` section per area (
|
|
183
|
+
One `####` section per area (Functions, Comments, Error Handling, DRY,
|
|
197
184
|
SOLID): its `[F-NNN]` findings, or "No <area> issues found."
|
|
198
185
|
|
|
199
186
|
### Clean Areas
|
|
@@ -67,8 +67,8 @@ boundary is the trigger-and-outcome test.
|
|
|
67
67
|
|
|
68
68
|
### Frontend / MobX laws
|
|
69
69
|
|
|
70
|
-
These say what is **always reported**. Its severity is the
|
|
71
|
-
|
|
70
|
+
These say what is **always reported**. Its severity is the matching rule's **Review severities** table (Parts A-C) —
|
|
71
|
+
the canonical rubric applied, not a second opinion.
|
|
72
72
|
|
|
73
73
|
1. **Every observable mutation outside an action or `runInAction` is reported.**
|
|
74
74
|
No exception for "small stores" or "simple assignments".
|
|
@@ -128,234 +128,16 @@ If no CLAUDE.md is found, proceed normally. CLAUDE.md is optional and non-blocki
|
|
|
128
128
|
|
|
129
129
|
## Review Checklist
|
|
130
130
|
|
|
131
|
-
###
|
|
131
|
+
### Parts A-C: the standard
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
Components, stores, TypeScript and stories are checked against the rules the code was written to. Read each that the change touches; each ends with a **Review severities** table, and a finding takes its level from that table's row:
|
|
134
134
|
|
|
135
|
-
-
|
|
136
|
-
-
|
|
137
|
-
-
|
|
138
|
-
-
|
|
135
|
+
- `.metaproject/rules/core/code-style-patterns.mdc`: `observer`, layers (no API/IO or business logic in components), where state lives (`useState` for UI-only state is correct), store created once, effect cleanup, keys, accessibility, TypeScript (`any`, `!`, `I` prefix, `src/` imports).
|
|
136
|
+
- `.metaproject/rules/core/mobx-store-template.mdc`: `makeObservable` and decorators, mutations in actions, thin public `@action.bound` over private arrow methods (`@action.bound` on a private method is a finding), async flags and the `disposed` guard, disposers and child stores, in-place collection updates, two-way sync guards, the `onMount()`/`onUnmount()` lifecycle bridge (correct, never flagged).
|
|
137
|
+
- `.metaproject/rules/core/storybook-guidelines.mdc`: which states each component's stories cover, `fn()` for actions.
|
|
138
|
+
- `.metaproject/rules/core/error-handling.mdc` for `catch` typing and swallowed errors.
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
- Component reads `store.*` or `useLocalObservable` result but is not wrapped in `observer` — **major** (stale UI; not one of the four merge-blocking shapes)
|
|
142
|
-
- `observer` applied inside another HOC wrapper instead of outside — **minor** (layer-violation rule; **major** only with a named defect it causes)
|
|
143
|
-
|
|
144
|
-
#### A2. MVVM Boundary (Business Logic in Store, Not Component)
|
|
145
|
-
|
|
146
|
-
- [ ] Business logic MUST live in Store/Service, not in component
|
|
147
|
-
- [ ] IO (API calls, file reads, WebSocket messages) MUST originate from private store methods
|
|
148
|
-
- [ ] Component event handlers must only call store action methods — no logic between the event and the store call
|
|
149
|
-
- [ ] Computed/derived values MUST be `@computed` getters in the store, not inline derivations in the component body
|
|
150
|
-
|
|
151
|
-
Flags:
|
|
152
|
-
- `fetch()` / `axios` / `httpClient` call directly in component (hook or handler) — **minor** (layer violation; **major** only with a named defect it causes or a stated project rule; same as `review-architecture`)
|
|
153
|
-
- Business logic (conditionals, transformations, validation) inside a component event handler instead of a store method — **minor** (layer violation, same condition)
|
|
154
|
-
- Derived value computed inline in component that could be a `@computed` getter — **minor**
|
|
155
|
-
|
|
156
|
-
#### A3. useEffect Misuse
|
|
157
|
-
|
|
158
|
-
- [ ] `useEffect` must not contain business logic
|
|
159
|
-
- [ ] `useEffect` must not fetch data or run business logic through the store: no `store.load()` / `store.loadX()`, and no `init()` of a child store that the parent store owns. The lifecycle bridge `useEffect(() => { store.onMount(); return () => store.onUnmount(); }, [store])` is correct and is not flagged (D6) — it hands the mount event to the store, which decides what to load
|
|
160
|
-
- [ ] `useEffect` must not contain API calls or IO
|
|
161
|
-
- [ ] `useEffect` used to synchronize component state with store state is a sign the component should be an `observer` instead
|
|
162
|
-
- [ ] Every `useEffect` that creates a subscription, timer, or listener MUST return a cleanup function
|
|
163
|
-
|
|
164
|
-
Flags:
|
|
165
|
-
- `useEffect` calls `store.loadX()`, or a child store's `init()` that the parent store owns — **minor** (layer-violation rule, as a direct fetch in a component; **major** only with a named defect; the `onMount()` / `onUnmount()` bridge form is not this)
|
|
166
|
-
- `useEffect` contains `fetch()` or IO — **minor** (API in component; layer-violation rule)
|
|
167
|
-
- `useEffect` contains business logic / state derivation — **minor** (layer-violation rule)
|
|
168
|
-
- `useEffect` creates a subscription/timer/listener with no cleanup return — **major** (memory leak)
|
|
169
|
-
|
|
170
|
-
#### A4. Key Props on Lists
|
|
171
|
-
|
|
172
|
-
- [ ] Every `.map()` rendering React elements MUST have a `key` prop on the root returned element
|
|
173
|
-
- [ ] Keys must be stable, unique identifiers — not array index when the list can reorder or filter
|
|
174
|
-
- [ ] Key must be on the element returned by `.map()`, not a child inside it
|
|
175
|
-
|
|
176
|
-
Flags:
|
|
177
|
-
- Missing `key` prop on list — **major** (causes reconciliation bugs)
|
|
178
|
-
- `key={index}` on a list that can reorder, filter, or paginate — **minor**
|
|
179
|
-
|
|
180
|
-
#### A5. Accessibility Basics
|
|
181
|
-
|
|
182
|
-
- [ ] `<img>` tags MUST have `alt` attribute (can be `alt=""` for decorative images, must be descriptive for content images)
|
|
183
|
-
- [ ] Interactive elements (`<button>`, `<a>`) with no visible text content MUST have `aria-label` or `aria-labelledby`
|
|
184
|
-
- [ ] Form inputs MUST have an associated `<label>` (via `htmlFor` + `id`, or `aria-label`)
|
|
185
|
-
- [ ] `role="button"` on a `<div>` or `<span>` without `tabIndex={0}` and keyboard handler — prefer a real `<button>`
|
|
186
|
-
- [ ] `onClick` on non-interactive elements without keyboard equivalent
|
|
187
|
-
|
|
188
|
-
Flags:
|
|
189
|
-
- `<img>` without `alt` — **major**
|
|
190
|
-
- Interactive element without accessible name — **major**
|
|
191
|
-
- Non-semantic interactive element without keyboard support — **minor**
|
|
192
|
-
|
|
193
|
-
---
|
|
194
|
-
|
|
195
|
-
### Part B: MobX Store Patterns
|
|
196
|
-
|
|
197
|
-
#### B1. Store Structure
|
|
198
|
-
|
|
199
|
-
- [ ] Store class MUST call `makeObservable(this)` in the constructor
|
|
200
|
-
- [ ] Observable state MUST use `@observable`, `@observable.shallow`, `@observable.ref`, or `@observable.struct` decorators
|
|
201
|
-
- [ ] Derived values MUST live in `@computed` getters, not recomputed in components or plain methods
|
|
202
|
-
- [ ] `@observable.ref` is preferred for large external objects or objects that manage their own reactivity
|
|
203
|
-
|
|
204
|
-
Flags:
|
|
205
|
-
- `makeObservable(this)` missing from constructor — **major** (nothing is reactive; stale UI, not corrupted state)
|
|
206
|
-
- Observable state missing `@observable` decorator — **major**
|
|
207
|
-
- Derived value in plain method instead of `@computed` — **minor**
|
|
208
|
-
|
|
209
|
-
#### B2. Member Ordering
|
|
210
|
-
|
|
211
|
-
The canonical class member order (flag deviations):
|
|
212
|
-
|
|
213
|
-
1. `private` fields (internal state, disposers, injected deps as `private readonly`)
|
|
214
|
-
2. Public fields (`@observable`, `readonly`, public plain props)
|
|
215
|
-
3. `constructor`
|
|
216
|
-
4. Public methods: `@computed` getters, lifecycle (`init`, `dispose`, `onMount`, `onUnmount`), public helpers/selectors, public `@action.bound` UI entrypoints
|
|
217
|
-
5. `private` methods
|
|
218
|
-
|
|
219
|
-
Flags:
|
|
220
|
-
- Constructor before field declarations — **minor**
|
|
221
|
-
- Private methods before public methods — **minor**
|
|
222
|
-
- `@action.bound` public method buried among private methods — **minor**
|
|
223
|
-
|
|
224
|
-
#### B3. Member Accessibility Modifiers
|
|
225
|
-
|
|
226
|
-
ESLint rule: `@typescript-eslint/explicit-member-accessibility: ["error", { accessibility: "no-public" }]` — the word `public` is **forbidden** on any class member.
|
|
227
|
-
|
|
228
|
-
Correct accessibility:
|
|
229
|
-
- *(no modifier)*: observable fields, computed getters, lifecycle methods, public helper methods, public `@action.bound` UI methods
|
|
230
|
-
- `private`: internal state (`disposed`, `initialized`, `_value`), helper methods, API-call methods (`fetchX`, `performX`), inter-store callbacks (`onChangeX`, `onFireX`, `handleX`, `syncX`)
|
|
231
|
-
- `private readonly`: constructor-injected dependencies, immutable configuration (`service`, `context`, `id`)
|
|
232
|
-
- `readonly`: immutable public identity fields (`pipelineType`, `contextActions`)
|
|
233
|
-
- `protected`: only in abstract base classes for extension points
|
|
234
|
-
|
|
235
|
-
Decision rule for inter-store callbacks: ask "Is this called from JSX or a React event handler?" If NO — it is `private`.
|
|
236
|
-
|
|
237
|
-
Flags:
|
|
238
|
-
- `public` keyword on any member — **minor** (ESLint `no-public` already fails CI; a reviewer restating a lint rule is not a merge gate)
|
|
239
|
-
- `onChangeX`, `onFireX`, `handleX`, `syncX` without `private` — **minor**
|
|
240
|
-
- Missing `private` on internal state or helper methods — **minor**
|
|
241
|
-
- Missing `private readonly` on a private field that is never reassigned (injected dependencies, immutable configuration) — **minor**
|
|
242
|
-
|
|
243
|
-
#### B4. Observable Collections
|
|
244
|
-
|
|
245
|
-
- [ ] `IObservableArray` MUST be mutated in place using MobX methods (`.replace()`, `.push()`, `.splice()`, etc.) inside `runInAction` — never reassigned
|
|
246
|
-
- [ ] `ObservableMap` MUST be mutated using `.set()`, `.delete()`, `.merge()`, `.replace()` — never reassigned
|
|
247
|
-
- [ ] Deep `@observable` on a large external object/instance should use `@observable.ref` instead
|
|
248
|
-
- [ ] A list of plain items that is replaced whole and never mutated per element uses `@observable.shallow` (or `.ref`), not deep `@observable`
|
|
249
|
-
|
|
250
|
-
Flags:
|
|
251
|
-
- `IObservableArray` field reassigned instead of using `.replace()` — **major**
|
|
252
|
-
- `ObservableMap` field reassigned instead of `.replace()` or `.merge()` — **major**
|
|
253
|
-
- Deep `@observable` on a list of plain items that is only ever replaced whole — **minor**
|
|
254
|
-
- Observable mutation outside `runInAction` in async context — **major**, or **blocker** where the interleaving can corrupt persisted state (frontend law 1)
|
|
255
|
-
|
|
256
|
-
#### B5. Reactions and Disposers
|
|
257
|
-
|
|
258
|
-
- [ ] Every `autorun`, `reaction`, or `when` created in the store MUST be disposed in `dispose()`
|
|
259
|
-
- [ ] Disposers MUST be stored in `private disposers: IReactionDisposer[]`
|
|
260
|
-
- [ ] `dispose()` MUST call `this.disposers.forEach(d => d())` (or equivalent)
|
|
261
|
-
- [ ] Stores with async operations MUST have a `disposed` guard: check `if (this.disposed) return` after each `await`
|
|
262
|
-
|
|
263
|
-
Flags:
|
|
264
|
-
- `autorun` / `reaction` / `when` without disposer in `dispose()` — **major**
|
|
265
|
-
- Missing `dispose()` in a store that creates reactions — **major**
|
|
266
|
-
- Missing `disposed` guard in async store methods — **major**
|
|
267
|
-
- `private disposers: IReactionDisposer[]` missing when reactions are used — **minor**
|
|
268
|
-
|
|
269
|
-
#### B6. Actions and Async
|
|
270
|
-
|
|
271
|
-
**Public methods (UI entrypoints):**
|
|
272
|
-
- [ ] Public mutating methods called from React components or route handlers MUST be `@action.bound`
|
|
273
|
-
- [ ] Public `@action.bound` methods MUST stay thin: optional guard → delegate to private method
|
|
274
|
-
- [ ] Public non-mutating helpers/selectors must NOT be `@action.bound` (unnecessary and misleading)
|
|
275
|
-
- [ ] Arrow method on a class used as an event handler alternative: acceptable when context must escape but generally prefer `@action.bound`
|
|
276
|
-
|
|
277
|
-
**Private async methods:**
|
|
278
|
-
- [ ] State mutations after `await` MUST be wrapped in `runInAction()`
|
|
279
|
-
- [ ] Private async methods that own loading/error flags MUST use `try/catch/finally`
|
|
280
|
-
- [ ] `catch (err: unknown)` MUST be used — NOT `catch (err: any)` or untyped `catch (err)`
|
|
281
|
-
- [ ] `finally` block MUST reset loading flags (e.g., `this.isLoading = false`) inside `runInAction`
|
|
282
|
-
|
|
283
|
-
Flags:
|
|
284
|
-
- Public UI method missing `@action.bound` — **major**
|
|
285
|
-
- Public helper method marked `@action.bound` but does not mutate state — **minor**
|
|
286
|
-
- Public async action doing API/IO directly instead of delegating to private — **minor** (layer-violation rule; **major** only with a named defect)
|
|
287
|
-
- State mutation after `await` outside `runInAction` — **major**, or **blocker** where the interleaving can corrupt persisted state (frontend law 1)
|
|
288
|
-
- Missing `try/catch/finally` on private async method owning loading flags — **major**
|
|
289
|
-
- `catch (err: any)` — rated by `.metaproject/rules/core/error-handling.mdc` (**Review severities**)
|
|
290
|
-
|
|
291
|
-
#### B7. Inter-Store Callbacks and Internal Handlers
|
|
292
|
-
|
|
293
|
-
Methods serving as callbacks between stores or internal event handlers MUST be `private`.
|
|
294
|
-
|
|
295
|
-
Patterns that MUST be `private` unless called from JSX:
|
|
296
|
-
- `onChangeEditorState(state)`
|
|
297
|
-
- `onFireExecutorChange()`
|
|
298
|
-
- `onChangeX(value)`
|
|
299
|
-
- `handleX()`
|
|
300
|
-
- `syncX()`
|
|
301
|
-
|
|
302
|
-
The test: "Is this method called from JSX or passed as a React event handler prop?" If NO — it is `private`, full stop.
|
|
303
|
-
|
|
304
|
-
Flags:
|
|
305
|
-
- Public method matching `onChangeX`, `onFireX`, `handleX`, `syncX` naming not called from components — **minor**
|
|
306
|
-
- Inter-store callback without `private` — **minor**
|
|
307
|
-
- `@action.bound` on a `private` method that is not passed as a callback reference — **minor**
|
|
308
|
-
|
|
309
|
-
#### B8. Bidirectional Sync Bounce Protection
|
|
310
|
-
|
|
311
|
-
When two stores synchronize state in both directions, at least one direction MUST have an equality guard (`if (newValue !== currentValue)`) before writing to the other store. Without this, changes bounce indefinitely.
|
|
312
|
-
|
|
313
|
-
Flags:
|
|
314
|
-
- Bidirectional store sync without equality guard — **blocker** only when a named trigger reaches the loop and it kills the render (crash); **major** for a reachable hang; **info** with no path shown
|
|
315
|
-
- Store A writes to Store B in a callback from Store B without `!==` check — same condition as the line above
|
|
316
|
-
- Truthy guard (`if (value)`) on optional/nullable field instead of equality check in sync logic — **major**
|
|
317
|
-
|
|
318
|
-
#### B9. API Calls Placement
|
|
319
|
-
|
|
320
|
-
- [ ] API/IO calls belong in `private` store methods only
|
|
321
|
-
- [ ] Public `@action.bound` methods are thin: guard-check → delegate to private method
|
|
322
|
-
- [ ] Components MUST NOT call APIs directly (fetch, axios, httpClient, service.callX) — even inside `useEffect`
|
|
323
|
-
|
|
324
|
-
Flags:
|
|
325
|
-
- API call inside a public `@action.bound` method body — **minor** (layer-violation rule; **major** only with a named defect)
|
|
326
|
-
- API call in a component (hook, handler, useEffect) — **minor** (frontend law 3; layer-violation rule)
|
|
327
|
-
|
|
328
|
-
#### B10. Lifecycle Initialization and Disposal
|
|
329
|
-
|
|
330
|
-
- [ ] `init()` / `onMount()` of a **child** store is called from the **parent store's** `init()` / `onMount()`, not from a component `useEffect`. The component's own store is different: its `onMount()` / `onUnmount()` are called from the component through the lifecycle bridge (D6), and that is correct
|
|
331
|
-
- [ ] Components must NOT trigger store data loading via `useEffect` (e.g., `useEffect(() => { store.load() }, [])`)
|
|
332
|
-
- [ ] Parent store's `onUnmount()` / `dispose()` MUST call `childStore.dispose()` to prevent stale-state updates
|
|
333
|
-
- [ ] Store `dispose()` MUST set `this.disposed = true` before canceling async work
|
|
334
|
-
|
|
335
|
-
Flags:
|
|
336
|
-
- Component `useEffect` calls `store.loadX()`, or a child store's `init()` / `onMount()` that the parent store owns — **minor** (as above). Do not flag the bridge `useEffect(() => { store.onMount(); return () => store.onUnmount(); }, [store])`
|
|
337
|
-
- Parent store does not call `child.dispose()` in `onUnmount()` / `dispose()` — **major**
|
|
338
|
-
- Missing `disposed` flag in store with async operations — **major**
|
|
339
|
-
|
|
340
|
-
---
|
|
341
|
-
|
|
342
|
-
### Part C: TypeScript Safety
|
|
343
|
-
|
|
344
|
-
- [ ] No `any` type in changed code — use `unknown` + type guards or specific types
|
|
345
|
-
- [ ] No `as any` or `as unknown as T` unsafe double-cast without a comment explaining why
|
|
346
|
-
- [ ] No `!` non-null assertion without a comment proving the value cannot be null/undefined at that point
|
|
347
|
-
- [ ] Props interface named without an `I` prefix: `interface MyComponentProps { ... }`
|
|
348
|
-
- [ ] Prefer optional chaining (`?.`) and nullish coalescing (`??`) over `!` assertions
|
|
349
|
-
- [ ] A store's state and its public API are typed with explicit interfaces/types, not inferred object literals or `any`
|
|
350
|
-
- [ ] `catch (err: unknown)` — typed error handling, not `catch (err)` or `catch (err: any)`
|
|
351
|
-
|
|
352
|
-
Flags:
|
|
353
|
-
- `any` type in new code — **minor** (**major** only with a named input and the wrong value it lets through)
|
|
354
|
-
- `!` non-null assertion without justification comment — **minor**
|
|
355
|
-
- Props interface with an `I` prefix introduced by the change — **minor**
|
|
356
|
-
- Store state or public API left to an inferred object-literal type — **minor**
|
|
357
|
-
|
|
358
|
-
---
|
|
140
|
+
A pattern listed under a row's **Not a finding** is not reported. A defect no row covers is rated by the canonical rubric.
|
|
359
141
|
|
|
360
142
|
### Part D: Project-Specific Patterns (populated from CLAUDE.md in Step 0)
|
|
361
143
|
|
|
@@ -399,69 +181,7 @@ class RootStore {
|
|
|
399
181
|
- Swappable stores MUST use `@observable.shallow`, not `@observable` — deep observation of child store internals causes double-tracking — **major** if using `@observable` on swappable stores
|
|
400
182
|
- Context interface (callbacks the child calls back into the parent) should be passed as arrow functions, not raw store references — flag raw store reference leak as **minor**
|
|
401
183
|
|
|
402
|
-
#### D3.
|
|
403
|
-
|
|
404
|
-
When a project CLAUDE.md defines which binding style to use for methods passed between stores:
|
|
405
|
-
|
|
406
|
-
```typescript
|
|
407
|
-
// Inter-store callback: arrow function property (auto-bound; no @action.bound needed)
|
|
408
|
-
handleChildChange = (value: string) => {
|
|
409
|
-
runInAction(() => { this.value = value; });
|
|
410
|
-
};
|
|
411
|
-
|
|
412
|
-
// UI entrypoint called from JSX: @action.bound
|
|
413
|
-
@action.bound
|
|
414
|
-
submit() { ... }
|
|
415
|
-
```
|
|
416
|
-
|
|
417
|
-
If the project follows this distinction:
|
|
418
|
-
- Arrow function for store-to-store methods: correct — do NOT flag
|
|
419
|
-
- `@action.bound` on an inter-store method: **minor** (stylistically wrong per project convention, functionally OK)
|
|
420
|
-
- Neither arrow nor `@action.bound` on a mutating method — **major** (Iron Laws still apply regardless of style choice)
|
|
421
|
-
|
|
422
|
-
#### D4. React Hooks to Avoid (MobX Equivalents)
|
|
423
|
-
|
|
424
|
-
When a project CLAUDE.md explicitly forbids certain hooks in favor of MobX equivalents:
|
|
425
|
-
|
|
426
|
-
| Forbidden Pattern | MobX Replacement | Severity if found |
|
|
427
|
-
|-------------------|-----------------|-------------------|
|
|
428
|
-
| `useState` for store-managed state | `@observable` in store | major |
|
|
429
|
-
| `useMemo` for derived store values | `@computed` getter | major |
|
|
430
|
-
| `useCallback` wrapping a store method | `@action.bound` or arrow method | minor |
|
|
431
|
-
|
|
432
|
-
Flag only when the hook manages state that belongs in a store. Local UI-only state (`useState` for a controlled input that never persists) is acceptable.
|
|
433
|
-
|
|
434
|
-
#### D5. Store Initialization in Components
|
|
435
|
-
|
|
436
|
-
When a project defines a canonical store initialization pattern:
|
|
437
|
-
|
|
438
|
-
```typescript
|
|
439
|
-
// Canonical: useLocalObservable with lazy initializer (store created once, not on every render)
|
|
440
|
-
const store = useLocalObservable(() => props.store ?? new ComponentStore(props.service));
|
|
441
|
-
```
|
|
442
|
-
|
|
443
|
-
- `new Store()` directly in the component body — **major** (store recreated on every render)
|
|
444
|
-
- Store created with `useMemo` instead of `useLocalObservable` — **minor** (not observable-aware; `useLocalObservable` is the correct primitive)
|
|
445
|
-
- `useLocalObservable(() => props.store)` when the store is always provided externally is acceptable
|
|
446
|
-
|
|
447
|
-
#### D6. Store Lifecycle Bridge via useEffect
|
|
448
|
-
|
|
449
|
-
The component tells its store that it mounted and unmounted; the store decides what that means:
|
|
450
|
-
|
|
451
|
-
```typescript
|
|
452
|
-
useEffect(() => {
|
|
453
|
-
store.onMount();
|
|
454
|
-
return () => store.onUnmount();
|
|
455
|
-
}, [store]);
|
|
456
|
-
```
|
|
457
|
-
|
|
458
|
-
This is the correct lifecycle bridge — do not flag it under A3 or B10. Those rules target a data fetch or business logic placed in the effect, and a component reaching into a child store the parent store owns; they do not target the lifecycle hooks themselves. What `onMount()` does (load, subscribe, initialise child stores) is store code and is reviewed as store code.
|
|
459
|
-
|
|
460
|
-
Distinction:
|
|
461
|
-
- `useEffect(() => { store.onMount(); return () => store.onUnmount(); }, [store])` — correct lifecycle bridge — **do not flag**
|
|
462
|
-
- `useEffect(() => { store.loadData(); }, [])` or `useEffect(() => { store.childStore.init(); }, [])` — data trigger, or a child store's lifecycle the parent store owns, run from the component — **minor** (A3 / B10, regardless of project conventions); **major** only with a named defect (trigger and wrong outcome)
|
|
463
|
-
|
|
464
|
-
#### D7. JSX and Naming Conventions
|
|
184
|
+
#### D3. JSX and Naming Conventions
|
|
465
185
|
|
|
466
186
|
When a project CLAUDE.md defines JSX and naming rules:
|
|
467
187
|
|
|
@@ -535,7 +255,7 @@ STATUS: DONE_WITH_CONCERNS
|
|
|
535
255
|
### [F-001] Title
|
|
536
256
|
- **Severity**: blocker | major | minor | info
|
|
537
257
|
- **File**: path/to/file.ts:line
|
|
538
|
-
- **Rule**:
|
|
258
|
+
- **Rule**: the rule and row, e.g. `code-style-patterns` Rule 5 | `mobx-store-template` Rule 2
|
|
539
259
|
- **Problem**: what is wrong in the code
|
|
540
260
|
- **Why it matters**: concrete impact (silent non-reactivity, stale state, memory leak, etc.)
|
|
541
261
|
- **Fix**: concrete suggestion
|
|
@@ -551,21 +271,8 @@ STATUS: DONE_WITH_CONCERNS
|
|
|
551
271
|
|
|
552
272
|
### Where frontend conditions land
|
|
553
273
|
|
|
554
|
-
Severity comes from **Severity (canonical)** in `review-orchestrator/SKILL.md
|
|
555
|
-
|
|
556
|
-
conditions land under that rubric, not a second rubric.
|
|
557
|
-
|
|
558
|
-
| Condition | Severity | Why, under the canonical rubric |
|
|
559
|
-
|---|---|---|
|
|
560
|
-
| A store mutation that corrupts or loses persisted state | `blocker` | Data corruption |
|
|
561
|
-
| A render path that throws on an input the change admits | `blocker` | Crash |
|
|
562
|
-
| Missing `observer()` on a component that reads observables | `major` | Named trigger (the observable changes) and named outcome (the UI does not update). Stale UI is not a crash, data loss, vulnerability, or missing acceptance criterion |
|
|
563
|
-
| Observable mutation outside an action or `runInAction` | `major` — `blocker` only where the interleaving can corrupt persisted state | Same wording as `review-logic` and `review-highload` for a race: the outcome decides |
|
|
564
|
-
| API/IO call in a component; business logic in a component | `minor` — `major` only with a named defect it causes (trigger and outcome) or a stated project rule | Layer violation: structural. Identical to `review-architecture`'s rule for the same condition |
|
|
565
|
-
| Bidirectional sync without an equality guard | `blocker` when a named trigger reaches the loop and the render dies; `major` for a reachable hang; `info` with no path | The outcome and its reachability decide, not the pattern |
|
|
566
|
-
| `useState` for store-managed state; `useMemo` for a derived store value; a store constructed in the component body | `major` | Named trigger (a re-render) and named outcome (state lost or recreated) |
|
|
567
|
-
| `public` on a class member; `useCallback` around a store method; a store created with `useMemo` instead of `useLocalObservable`; an unprivate inter-store callback | `minor` | The code behaves correctly. A lint rule that fails CI is caught by the machine, not by a reviewer, and the cost is to the next editor |
|
|
568
|
-
| Observation with no concrete bug | `info` | Shared laws 1 and 2 |
|
|
274
|
+
Severity comes from **Severity (canonical)** in `review-orchestrator/SKILL.md`; the rules' **Review severities** tables (Parts A-C) are that rubric applied to these patterns, and this reviewer keeps no table of its own. Outside those rows: a store mutation that corrupts or loses persisted state is `blocker`, a render path that throws on an input the change admits is `blocker`, and an observation with no concrete bug is `info` (shared laws 1 and 2).
|
|
275
|
+
|
|
569
276
|
|
|
570
277
|
---
|
|
571
278
|
|
|
@@ -576,13 +283,13 @@ Stop and re-read these rules if you are thinking:
|
|
|
576
283
|
| Rationalization | Why it's wrong |
|
|
577
284
|
|---|---|
|
|
578
285
|
| "The store is small, no need for full observer wrapping" | Missing `observer()` is reported regardless of store size — frontend law 2. It is `major`, not `blocker`: stale UI is not one of the four shapes |
|
|
579
|
-
| "The mutation happens in a non-async method, so runInAction isn't needed" | Mutations outside action/runInAction are always reported — frontend law 1; the
|
|
580
|
-
| "I'll skip the API call in component to avoid friction" | API in a component is always reported — frontend law 3; `minor` unless a named defect
|
|
286
|
+
| "The mutation happens in a non-async method, so runInAction isn't needed" | Mutations outside action/runInAction are always reported — frontend law 1; the rule's severity table sets the level |
|
|
287
|
+
| "I'll skip the API call in component to avoid friction" | API in a component is always reported — frontend law 3; `minor` unless a named defect makes it `major`, as in `review-architecture` |
|
|
581
288
|
| "The `public` keyword is just a style issue, I'll call it minor" | It is `minor` — but still reported. The linter fails CI on it, which is why a reviewer does not need to block merge on it too |
|
|
582
289
|
| "This inter-store callback works fine as public" | Frontend law 5: if it is not called from JSX, it must be `private` |
|
|
583
290
|
| "No spec compliance check needed for this skill" | Correct — this skill covers Stage 2 (code quality) only; spec compliance is handled by the orchestrator or review-logic |
|
|
584
291
|
| "I can suggest adding useCallback everywhere for safety" | With MobX+observer, useCallback is rarely needed and adds noise; only flag when concretely justified |
|
|
585
|
-
| "The bidirectional sync looks fine, no equality guard needed" | Bidirectional sync without an equality guard is always reported; its level follows the
|
|
292
|
+
| "The bidirectional sync looks fine, no equality guard needed" | Bidirectional sync without an equality guard is always reported; its level follows the `mobx-store-template` table (reachability decides) |
|
|
586
293
|
|
|
587
294
|
---
|
|
588
295
|
|