Package com.aim2be.platform.archunit
Class EntityVersionParity
java.lang.Object
com.aim2be.platform.archunit.EntityVersionParity
ArchUnit rule enforcing the
@Entity → @Version parity
invariant from ADR-0001 §1.4.
Every JPA entity in the aim2be services must carry an optimistic-lock version field — without it, concurrent writes silently overwrite each other and the outbox + dedup machinery cannot detect lost updates. The rule covers production code; deliberate exceptions are encoded as annotation-based or package-based exclusions:
- Classes annotated with
Immutableare excluded — by contract, the row is append-only (seeProcessedKafkaEvent). - Classes in
**.audit.**are excluded — audit rows are append-only by convention; lost updates are impossible. - Classes in
**.replica.**are excluded — replica rows are sourced from another authority and don't carry their own lock.
Consumers wire this rule into their own JUnit5 suite via
@AnalyzeClasses; see EntityVersionParityArchTest for the
canonical sample.
v1.0 scaffold: the rule body lands in PR-PLATFORM-5 with both a
positive fixture (entities that DO carry @Version) and a negative
fixture (a deliberately broken entity that the rule MUST flag).
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.tngtech.archunit.lang.ArchRuleBuilds the ArchRule.
-
Method Details
-
entitiesMustCarryVersion
public static com.tngtech.archunit.lang.ArchRule entitiesMustCarryVersion()Builds the ArchRule. Consumers evaluate it against their own classpath via the standard ArchUnit JUnit5 API:@AnalyzeClasses(packagesOf = ApplicationMainClass.class) class EntityVersionParityArchTest { @ArchTest static final ArchRule rule = EntityVersionParity.entitiesMustCarryVersion(); }- Returns:
- the ArchRule (instance is reusable across test classes)
-