@@ -9,32 +9,57 @@ reviews:
99 high_level_summary_in_walkthrough : false
1010 poem : false
1111 path_instructions :
12- - path : " src/Domain/**"
13- instructions : |
14- You are reviewing PHP domain-layer code. Enforce strict domain purity:
15- - ❌ Do not allow infrastructure persistence side effects here.
16- - Flag ANY usage of Doctrine persistence APIs, especially:
17- - $entityManager->flush(...), $this->entityManager->flush(...)
18- - $em->persist(...), $em->remove(...)
19- - direct transaction control ($em->beginTransaction(), commit(), rollback())
20- - If found, request moving these calls to application-layer Command handlers or background Jobs.
21- - Also flag repositories in Domain that invoke flush/transactional logic; Domain repositories should be abstractions without side effects.
22- - Encourage domain events/outbox or return-values to signal write-intent, leaving orchestration to Commands/Jobs.
23-
24- - path : " src/**/Command/**"
25- instructions : |
26- Application layer (Commands/Handlers) is the right place to coordinate persistence.
27- - ✅ It is acceptable to call $entityManager->flush() here.
28- - Check that flush is used atomically (once per unit of work) after all domain operations.
29- - Ensure no domain entity or domain service is calling flush; only the handler orchestrates it.
30- - Prefer $em->transactional(...) or explicit try/catch with rollback on failure.
31-
32- - path : " src/**/MessageHandler/**"
33- instructions : |
34- Background jobs/workers may perform persistence.
35- - ✅ Allow $entityManager->flush() here when the job is the orchestration boundary.
36- - Verify idempotency and that flush frequency is appropriate (batching where practical).
37- - Ensure no domain-layer code invoked by the job performs flush/transaction control.
12+ - path : " src/Domain/**"
13+ instructions : |
14+ You are reviewing PHP domain-layer code. Enforce domain purity, with a relaxed policy for DynamicListAttr:
15+
16+ - ❌ Do not allow persistence or transaction side effects here for *normal* domain models.
17+ - Flag ANY usage of Doctrine persistence APIs on regular domain entities, especially:
18+ - `$entityManager->flush(...)`, `$this->entityManager->flush(...)`
19+ - `$em->persist(...)`, `$em->remove(...)`
20+ - `$em->beginTransaction()`, `$em->commit()`, `$em->rollback()`
21+ - ✅ Accessing Doctrine *metadata*, *schema manager*, or *read-only schema info* is acceptable
22+ as long as it does not modify state or perform writes.
23+
24+ - ✅ **Relaxed rule for DynamicListAttr-related code**:
25+ - DynamicListAttr is a special case dealing with dynamic tables/attrs.
26+ - It is acceptable for DynamicListAttr repositories/services to:
27+ - Create/update/drop DynamicListAttr tables/columns.
28+ - Use Doctrine persistence APIs (`persist`, `remove`, `flush`, etc.)
29+ as part of managing DynamicListAttr data and schema.
30+ - Do *not* flag persistence or schema-creation calls that are clearly scoped
31+ to DynamicListAttr tables or their management.
32+ - Still prefer keeping this logic well-encapsulated (e.g. in dedicated services/repos),
33+ not scattered across unrelated domain objects.
34+
35+ - ⚠️ For non-DynamicListAttr code:
36+ - If code is invoking actual table-creation, DDL execution, or schema synchronization,
37+ then request moving that to the Infrastructure or Application layer (e.g. MessageHandler).
38+ - Repositories in Domain should be abstractions without side effects; they should express *intent*,
39+ not perform flush/transactional logic.
40+
41+ - path : " src/**/Command/**"
42+ instructions : |
43+ Application layer (Commands/Handlers) is the right place to coordinate persistence.
44+
45+ - ✅ It is acceptable to call $entityManager->flush() here.
46+ - Check that flush is used atomically (once per unit of work) after all domain operations.
47+ - Ensure no domain entity or domain service is calling flush; only the handler orchestrates it,
48+ except for the explicitly allowed DynamicListAttr management logic in Domain.
49+ - Prefer $em->transactional(...) or explicit try/catch with rollback on failure when multiple writes are involved.
50+
51+ - path : " src/**/MessageHandler/**"
52+ instructions : |
53+ Background jobs/workers may perform persistence and schema management.
54+
55+ - ✅ Allow `$entityManager->flush()` when the job is the orchestration boundary.
56+ - ✅ Allow table creation, migration, or schema synchronization (e.g. via Doctrine SchemaTool or SchemaManager),
57+ as this is considered infrastructure-level orchestration.
58+ - For DynamicListAttr-related jobs, it is fine to orchestrate both data and schema changes here,
59+ as long as responsibilities remain clear and behavior is predictable.
60+ - Verify idempotency for schema operations where practical — e.g., check if a table exists before creating.
61+ - Ensure domain-layer code invoked by the job (outside the DynamicListAttr exception) remains free of persistence calls.
62+ - Batch flush operations where practical.
3863
3964 auto_review :
4065 enabled : true
0 commit comments