Skip to content

Let a rule read a named set from the test resources - #7

Open
dionmcm wants to merge 1 commit into
developfrom
ext/named-set-lookup
Open

Let a rule read a named set from the test resources#7
dionmcm wants to merge 1 commit into
developfrom
ext/named-set-lookup

Conversation

@dionmcm

@dionmcm dionmcm commented Aug 29, 2026

Copy link
Copy Markdown
Member

This change allows for more generalised configuration access for rules.

What

semantic-tag-hierarchies.txt is loaded as a generic key=value,value,value store, but isSemanticTagCompatibleWithinHierarchy is the only way a rule can read it. That method extracts a semantic tag from a term before looking it up, so the store is only reachable for values that happen to be semantic tags.

Change

DescriptionService.isInNamedSet(setKey, value) exposes the same store for values that are not semantic tags, so a rule can be driven by per-edition configuration.

Why

The case that prompted it is a set of module ids. An editorial policy that some editions have adopted and others have not cannot be expressed as a semantic tag, and hardcoding either the policy or its exceptions into a rule in common-authoring makes that rule wrong for somebody.

Defaulted to the current behaviour. The default answers false for every key, meaning "no configuration present". That obliges a rule using it to behave, on false, exactly as it did before the method existed. NamedSetLookupTest asserts this against TestDescriptionService, which does not override it; that the test compiles at all is half the point.

TestDescriptionService implements it as well. Otherwise RulesTestManual would always see the interface default, so a rule driven by a named set could only ever be tested in its unconfigured state. test-cases.json and the dummy test resources were written to populate this.

The rule in the companion PR is testable both ways, silent when its module is listed, firing when it is not.

Scope

No behaviour change on its own — no rule calls it yet. 8 new tests, existing suites unchanged, and the 109 rule directories in RulesTestManual still pass.

@dionmcm
dionmcm changed the base branch from master to develop August 29, 2026 05:41
@dionmcm
dionmcm force-pushed the ext/named-set-lookup branch from 5dc3066 to dde3d12 Compare August 29, 2026 05:41
semantic-tag-hierarchies.txt is loaded as a generic key=value,value,value store,
but isSemanticTagCompatibleWithinHierarchy is the only way a rule can read it -
and that method extracts a semantic tag from a term before looking it up, so the
store is only reachable for values that are semantic tags.

This exposes the same store for values that are not, so a rule can be driven by
per-edition configuration. The case that prompted it is a set of module ids: an
editorial policy that some editions have adopted and others have not cannot be
expressed as a semantic tag, and hardcoding either the policy or its exceptions
into a rule in common-authoring makes that rule wrong for somebody.

Defaulted rather than abstract, so implementations outside this project - the
authoring platform's, in particular - keep compiling untouched. The default
answers false for every key, meaning "no configuration present", which obliges a
rule using it to behave on false exactly as it did before the method existed.
NamedSetLookupTest asserts that against an implementation declaring only the
methods the interface required before this change.

TestDescriptionService implements it too. Without that the rules test rig would
always see the default, so a rule driven by a named set could only ever be
tested unconfigured - the set would look empty however test-cases.json and the
dummy test resources were written.

No behaviour change on its own: no rule calls it yet.
@dionmcm
dionmcm force-pushed the ext/named-set-lookup branch from dde3d12 to aa0f9a0 Compare August 29, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant