Introduce rule applicability framework (validation profile + agenda filter) (TEDEFO-5035)#77
Merged
Merged
Conversation
…ilter) (TEDEFO-5035)
rouschr
approved these changes
Apr 29, 2026
Contributor
rouschr
left a comment
There was a problem hiding this comment.
There are a lot of changes, I think I will understand this better on the side of the MDM analyse-emd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second analyser-side step of TEDEFO-5029 (epic: run the SDK Analyzer against the live MDD), addressing TEDEFO-5035.
The analyser becomes aware of the context in which a validation run is happening (which SDK major version, what kind of source backs the content), and individual Drools rules can declare which contexts they apply to via DRL metadata annotations. Rules without annotations apply to every context — so existing rules continue to fire for every run with no DRL change required, and the file-backed CI gate stays exactly as it was.
New types and behaviour
SourceKind(enum:FILE,DATABASE).ValidationProfile(immutable value:int sdkMajor,SourceKind sourceKind).SdkContentSourcegainsSourceKind getSourceKind()(non-default by design — forces every implementation to be explicit).SdkValidator.validate()builds aValidationProfilelazily from the loadedSdkMetadata(major) andsource.getSourceKind(), and threads it through toRulesRunner.execute(unit, profile, rules...).ApplicabilityFilterreads@sdkMajor(...)and@source(...)metadata on each rule and AND's it against the active profile. A rule applies iff every annotated axis matches — annotation-absent on an axis means "any value on that axis."Triage of obvious file-only rules
Four existing rules now carry
@source(FILE):Document types use existing schemaLocation,Codelist indicated in codelists index exists,Codelist files are indicated in codelists index, andCodelist filenames are as expected. They fire under FILE and are skipped under DATABASE. Broader rule triage is intentionally deferred to a follow-up.Defensive null guard on
DocumentTypeFact.schemaLocationExistsThe framework's premise that "FILE source = always has a path" doesn't hold if a custom source declares
SourceKind.FILEwithout backing the content with a real path (e.g. an in-memory or archive-backed reader). The null guard is restored with a comment explaining why; a regression test (fileSourceWithDocumentTypeAndNoSdkRootDoesNotThrow) covers the case end-to-end.Verification
mvn test: 176 tests green (148 Cucumber + 28 JUnit, 0 failures, 0 errors).DroolsApplicabilityIntegrationTest(11 tests) compiles a small DRL through the real Drools engine and locks in the metadata-shape assumption underpinningApplicabilityFilter— runtime guard against future Drools upgrades.ApplicabilityFilterTest(7 tests) covers the four-corner profile matrix.SdkValidatorProfileFilteringTest(3 tests) drives the fullvalidate()pipeline: a@source(FILE)rule fires under FILE, is skipped under DATABASE, and a custom FILE source with a document type but nosdkRootdoes not NPE.Intentional API breaks (no external Java consumers)
SdkContentSourceadds a non-default methodgetSourceKind(). Per the design, every implementation must declare its kind explicitly. Both in-tree implementations (SdkLoader,EmptySdkContentSourcetest stub) declareFILE. Phase 3a'sEmdSdkContentSourceinmdm-cliwill declareDATABASE.RulesRunner.execute(unit, String...)becomesRulesRunner.execute(unit, ValidationProfile, String...). There is exactly one production call site (SdkValidator.fireRules).The analyser has no known external Java consumers and a major version bump is on the horizon.
mdm-cli(the only known internal consumer) doesn't implementSdkContentSourcetoday and isn't affected by the break.Test-mode caveat
When
SdkValidator.fireRules(String...)is called without first callingvalidate(), the active profile is null andRulesRunnerbypasses the applicability filter entirely. This preserves the behaviour of legacy step-by-step Cucumber tests inSdkValidationSteps. The bypass is documented onSdkValidator.fireRulesand on theSdkValidator.profilefield, and aWARNlog line is emitted whenever it triggers — a non-test caller doing this would be loud.Follow-ups (separate PRs)
mdm-cli-side):EmdSdkContentSourcedeclaringSourceKind.DATABASEconsumes this framework and naturally inherits clean rule selection.@sdkMajorannotations).