Repository navigation
Ruleset modularity: one family of rulesets, many environments, standards and versions #41
Description
Three people described the same missing feature on the 28 August office hours (#40), from two different directions, and neither of them was asking for a tool — both were asking for modularity in the ruleset format itself.
What was said
A consultant, from a live customer engagement:
Right now I'm with a customer that has around 160 custom rules, which is already a lot. So it sometimes gets difficult to handle so many rules… They need different rulesets for different environments. They need something different in prod, in staging, in the IDE — and then there's a pipeline that does several things, all the API operations aspects and so on. Right now, usually you have one ruleset. But people need more than one. And that's very difficult right now to really handle: either you duplicate the rules, or you try to import them, but then it gets pretty messy.
A public-sector platform team, immediately after:
We have exactly the same challenge. We have different standards, different versions of standards — and for every version of every standard, we have different rulesets. We have now created an additional layer on top of Spectral to coordinate this all. But it would be even better if the ruleset specification already provides some sort of modularity in rulesets to manage this.
Why this is its own issue
Two things in there are worth separating from #30.
1. It is the specification that is missing something, not the tooling. #30 covers how rulesets are named, found and composed — the referencing mechanics. This is a level above: how a family of related rulesets is expressed as one thing with variants, so that the same rule does not have to exist in four files.
2. Someone has already built the missing layer privately. That is the exact pattern that produced this fork: a capable user hits a hole in the format, builds a private layer over it, and the format never learns. Every organisation running this at scale is currently writing the same coordination layer, and none of those layers interoperate. The private layer is the evidence, not an anecdote.
The two axes people are actually asking for
They are not the same axis, and a design that only handles one will not land.
| Axis | Example | What varies |
|---|---|---|
| Environment / stage | IDE, pre-commit, CI gate, staging, production | Usually the severity and the subset: the same rule is a hint in the editor and an error in the gate. Rules are largely shared; enforcement is not. |
| Standard and version | OAS 3.0 vs 3.1; FHIR R4 vs R5; a house standard v2 vs v3 | Usually which rules apply at all, plus per-version given expressions. This is where aliases (#20) do real work, since aliases are already registered per format version. |
Questions this needs to answer
- Is a variant a first-class construct in the ruleset document (profiles, layers, overlays) or is it composition of separate documents that the format only has to make possible?
- Can a variant change severity only, or also add and remove rules and change
given? The IDE-vs-gate case is mostly severity; the standard-version case is not. - How does this interact with
extends— today the only composition primitive, and the one that already leaks (aliases stop working when you extend, see Elevate aliases out of the core ruleset into their own namespace, and get rules off JSONPath #20). - How does it interact with the industry layer model in Where do industry rulesets sit in the layer model? #21? An organisation extending a FHIR ruleset and then varying it per environment is stacking two different kinds of modularity, and the model has to say how they compose.
- Does selecting a variant belong in the document, the invocation, or the environment? A CI gate that has to pass
--profile productionis a different design from a ruleset that knows what a production run is. - What does a conformance suite (Build the conformance suite — and no blessed implementation #9) assert about variant resolution? Two implementations that resolve profiles differently are worse than no profiles at all.
Prior art worth reading before designing anything
- ESLint flat config
overrides/ config arrays — the closest analogue, including the failure modes. tsconfig.jsonextendsplus per-project overrides — an example of the "one axis only" design and its limits.- OPA/Rego bundles and package scoping — how a policy engine handles the same problem, relevant to Rule portability across policy engines (OPA/Rego) without a second rule language #13.
- OpenAPI Overlay — arguably the version of this that already exists and might be borrowed rather than reinvented, given Overlay 1.3 is starting (Ruleset modularity: one family of rulesets, many environments, standards and versions #41).
What would settle it
Two ruleset families, written out longhand, from the people who actually have them: the ~160-rule customer set with its IDE/pipeline/staging/prod variants, and the multi-standard multi-version set with its coordination layer. Sanitised is fine. Design against real ones or this gets a mechanism nobody's real case fits.
Related: #30 (referencing and composition) · #21 (industry layers) · #20 (aliases, including per-format-version registration) · #9 (whatever this becomes has to be conformance-testable).
Raised in the office hours of 28 August 2026 — notes in #40.
Activity