@@ -11,37 +11,54 @@ reviews:
1111 path_instructions :
1212 - path : " src/Domain/**"
1313 instructions : |
14- You are reviewing PHP domain-layer code. Enforce strict domain purity:
15- - ❌ Do not allow persistence or transaction side effects here.
16- - Flag ANY usage of Doctrine persistence APIs, especially:
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:
1718 - `$entityManager->flush(...)`, `$this->entityManager->flush(...)`
1819 - `$em->persist(...)`, `$em->remove(...)`
1920 - `$em->beginTransaction()`, `$em->commit()`, `$em->rollback()`
2021 - ✅ Accessing Doctrine *metadata*, *schema manager*, or *read-only schema info* is acceptable
2122 as long as it does not modify state or perform writes.
22- - ⚠️ If code is invoking actual table-creation, DDL execution, or schema synchronization,
23- then request moving that to the Infrastructure or Application layer (e.g. MessageHandler).
24- - Also flag repositories in Domain that invoke flush/transactional logic;
25- Domain repositories should be abstractions without side effects.
26- - Encourage using domain events or return-values to signal intent to write,
27- leaving persistence orchestration to Commands/Jobs.
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.
2840
2941 - path : " src/**/Command/**"
3042 instructions : |
3143 Application layer (Commands/Handlers) is the right place to coordinate persistence.
44+
3245 - ✅ It is acceptable to call $entityManager->flush() here.
3346 - Check that flush is used atomically (once per unit of work) after all domain operations.
34- - Ensure no domain entity or domain service is calling flush; only the handler orchestrates it.
35- - Prefer $em->transactional(...) or explicit try/catch with rollback on failure.
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.
3650
3751 - path : " src/**/MessageHandler/**"
3852 instructions : |
3953 Background jobs/workers may perform persistence and schema management.
54+
4055 - ✅ Allow `$entityManager->flush()` when the job is the orchestration boundary.
4156 - ✅ Allow table creation, migration, or schema synchronization (e.g. via Doctrine SchemaTool or SchemaManager),
4257 as this is considered infrastructure-level orchestration.
43- - Verify idempotency for schema operations — e.g., check if a table exists before creating.
44- - Ensure domain-layer code invoked by the job remains free of persistence calls.
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.
4562 - Batch flush operations where practical.
4663
4764 auto_review :
0 commit comments