The rulebook holds the shared standards every data product must meet. It is a versioned set of policy rules. The same rules run on a laptop (wam validate), in the editor (SARIF) and in every CI pipeline, so a product that breaks a blocking rule cannot be merged or released. This page covers the types of rules, every built-in rule, how an organisation tunes the rulebook with a policy pack, how exceptions work, and how to write your own rules.
How a rule works
A rule is a small Python class with an ID, a title, a scope and a default severity. It receives a context and returns findings:
- The context holds the parsed
product.yaml, the SQL files and their analysis (columns, tables read, lineage, expression fingerprints), the previous version frommainwhen there is one, the repository files, today's date, and optional workspace facts such as groups, the dependency graph, row counts and upstream classifications. - A finding has the rule ID, a severity, a message, a file, a line and a remediation hint.
The engine runs every rule whose scope belongs to the requested gates, applies the policy pack, then applies waivers. The product is blocked if any block finding is left unwaived.
Types of rules
By scope: when the rule runs
| Scope | Gate | Runs | Typical checks |
|---|---|---|---|
static | 1 | Locally and in CI, from the files alone, in milliseconds | Names, owner, descriptions, classifications, secrets, SQL hygiene, regulatory mappings |
build | 2 | In CI on the pull request, compared with main | Contract changes, keys, required tests, PII lineage, declared inputs, cycles, consumer expectations |
deploy | 4 | Before a release is promoted to production | Deploy identity, human approval of AI changes, external sharing profile |
runtime | 5 | On every run in the workspace | Quality checks, freshness and grant drift (Enterprise) |
continuous | 6 | Scheduled scans of the whole mesh | Retention, unused ports, duplicates (Enterprise) |
Gate 3 is the test deploy: the bundle deploys to the test workspace and runs on sample data. It is a CI step, not a set of rules.
By severity: what a finding does
| Severity | Effect |
|---|---|
block | Fails wam validate (exit 1) and the CI gate. |
warn | Reported, annotated on the pull request, never fails. |
info | Reported only. |
Some rules choose their severity by tier: DP011 blocks at P1–P2 and warns at P3–P4, and DP055 blocks only at P1. A policy pack can change any rule's severity.
Offline and online rules
Most rules need only the files, so they give the same answer everywhere. Online rules also need facts from the workspace, such as row counts (DP045) or registered consumer expectations (DP063). Offline, they are listed as skipped and do not fail. CI collects the facts and runs them.
Core and Enterprise rules
Core rules ship with the CLI. Enterprise rules come with the Enterprise package and are loaded automatically when it is installed: DP110 to DP112 (the Regulated pack), plus the runtime and continuous services. Your own rules are a third source, loaded the same way.
Catalogue
| ID | Scope · gate | Default | Rule | Fix |
|---|---|---|---|---|
| DP001 | static · 1 | block | Product and port names are snake_case, 2–63 characters | Rename |
| DP002 | static · 1 | block | owner is an existing group with at least two members (membership checked online) | Use a team group |
| DP005 | static · 1 | block | No secrets in product.yaml or SQL: password, token or API-key assignments, Databricks tokens, storage account keys, private keys | Use a secret scope |
| DP007 | build · 2 | block | A breaking change (port or column removed, type or keys changed) needs a new port version | Publish <port>_v<N+1> |
| DP010 | static · 1 | block | Product and port descriptions have at least 40 characters | Describe purpose and use |
| DP011 | build · 2 | block at P1–P2, warn otherwise | Every published column is described | wam describe |
| DP020 | static · 1 | block | Every column of a source product has a classification | Add classification |
| DP021 | build · 2 | block | A column that inherits PII through lineage is classified, or marked x-deidentified with a justification | Add pii or de-identify |
| DP030 | static · 1 | block | No physical catalog or environment names in SQL | Use {{ ref() }} |
| DP031 | static · 1 | warn | No more than five template variables in one SQL file | Simplify |
| DP033 | static · 1 | block | No SELECT * in port SQL | List the columns |
| DP040 | build · 2 | block | merge, scd2 and window ports have keys; window has a watermark | Add keys, load.watermark |
| DP045 | build · 2, online | warn | snapshot on a table above 50 million rows | Use merge or window |
| DP050 | build · 2 | block | No dependency cycles between products | Extract the shared logic |
| DP055 | build · 2 | block at P1, warn otherwise | SQL reads only declared inputs | Declare the input |
| DP060 | build · 2 | block | The tests required for the tier are present | Add the listed checks |
| DP061 | build · 2 | block | At most two live versions per port | Retire the oldest |
| DP062 | build · 2 | warn | Semantic change: a column's SQL expression changed | Declare a bugfix or bump the version |
| DP063 | build · 2, online | block | The change keeps every registered consumer expectation | Agree with the consumer |
| DP075 | deploy · 4 | block | Externally shared ports are P1 or P2 and expose no restricted columns | De-identify, raise the tier |
| DP090 | deploy · 4 | block | Production deploys run as a service principal | Deploy from CI |
| DP095 | deploy · 4 | block | AI-generated changes have a human approver | Get a review |
| DP110 | build · 2 | block for high-risk AI | High-risk AI training data represents the reference population (Enterprise) | Rebalance or document |
| DP111 | static · 1 | block | Regulatory ports map or waive every mandatory data point of their template (Enterprise) | Complete mapping |
| DP112 | build · 2 | block | Ports that implements: a group contract conform to it (Enterprise) | Align the port |
Enterprise services enforce more standards outside the gates: grant drift (DP070, manual grants outside the access workflow are reverted) and duplicate-port candidates (DP085). Retention enforcement (DP076) and retiring unused ports (DP080) are on the roadmap and not yet enforced.
Each run also blocks on SQL that does not parse. These findings are reported under the rule ID SQL.
Policy packs
An organisation does not edit the rules. It publishes a policy pack: a versioned YAML file that picks which rules run and how strictly. Every repository pins one pack, and CI passes it to wam validate --pack.
name: acme-standards
version: "1.4"
disabled: [DP031] # rules that do not run at all
severity: # override a rule's severity: block | warn | info
DP011: block # undescribed columns block at every tier
DP062: block
grace: # a newly blocking rule only warns until this date
DP021: 2027-02-01
defaults: # configuration defaults, a layer below domain wam.yaml
tier: P2
compute: {performance_target: STANDARD}
| Key | Type | Effect |
|---|---|---|
name, version | string | Identify the pack. Reports show it as name@version, and products can record it in policy_pack:. |
disabled | list of rule IDs | These rules are not run. |
severity | map: rule ID → block | warn | info | Replaces the rule's default severity, including tier-dependent ones. |
grace | map: rule ID → date | Until that date, block findings of the rule are shown as warnings with (blocking from <date>). This lets you tighten a standard without breaking every team the same day. |
defaults | map | Configuration defaults for every product, merged between the platform defaults and the domain wam.yaml. |
Packs can extend each other. A group pack sets the baseline and a business-unit pack adds to it: disabled rules are combined, while severities and defaults from the child win. Changing the pack version is itself a pull request. The upgrade impact check (whatamesh.policy.engine.upgrade_impact) compares the old and new pack across the mesh and lists every product that would newly block, with a 30-day grace date by default.
Waivers
When a product cannot meet a rule yet, the owner adds a waiver to product.yaml and the steward approves it in the pull request:
waivers:
- rule: DP060
reason: Reconciliation against the actuarial system arrives with release 2027.1
approved_by: steward-risk
expires: 2027-06-30
A waived finding is still reported, marked (waived), and stops blocking. SARIF output leaves it out, so code scanning stays clean. Once expires passes, the finding blocks again with (waiver expired <date>). A waiver covers every finding of that rule in the product, so keep the reason specific.
Adding your own rules
Custom rules are ordinary Python classes in a package your organisation owns. They are registered through an entry point, so the CLI and CI load them without a fork.
1. Write the rule. Subclass Rule, set id, title, scope, severity and remediation, and yield findings from evaluate. Use your own ID prefix so you never collide with built-in IDs; the registry refuses duplicates.
# acme_rules/rules.py
from collections.abc import Iterable
from whatamesh.policy.base import Context, Finding, Rule, Scope, Severity
from whatamesh.spec.models import Tier
class ACME001CostCentre(Rule):
"""Every P1 or P2 product carries a cost centre for chargeback."""
id, title, scope = "ACME001", "P1 and P2 products declare a cost centre", Scope.static
severity = Severity.block
remediation = "Add `x-cost-centre: <code>` to product.yaml."
def applies(self, ctx: Context) -> bool:
return ctx.spec.tier in (Tier.P1, Tier.P2)
def evaluate(self, ctx: Context) -> Iterable[Finding]:
if "x-cost-centre" not in ctx.spec.extensions:
yield self.finding("product has no x-cost-centre")
class ACME002NoTimestampKeys(Rule):
"""Keys on timestamps make merges non-deterministic."""
id, title, scope = "ACME002", "Keys are not timestamps", Scope.build
severity = Severity.warn
def evaluate(self, ctx: Context) -> Iterable[Finding]:
for port in ctx.spec.outputs:
for key in port.keys:
col = port.columns.get(key)
if col and col.type and col.type.startswith("timestamp"):
yield self.finding(f"port '{port.name}' uses timestamp column '{key}' as a key")
RULES = [ACME001CostCentre, ACME002NoTimestampKeys]
Useful parts of the context:
| Attribute | Content |
|---|---|
ctx.spec | The validated product.yaml (ProductSpec): outputs, inputs / input_ports, tier, kind, extensions (the x- keys) and so on |
ctx.sql / ctx.sql_info | SQL text per file, and its analysis: columns, refs, lineage, expressions, select_star, hardcoded |
ctx.previous | The version on main, for build rules that compare (None for a new product) |
ctx.repo_files | Repository files the rule may scan |
ctx.today | The evaluation date, so time-based rules stay testable |
ctx.online, ctx.facts, ctx.groups, ctx.graph | Workspace facts. Set online = True on the rule if it needs them, and it is skipped offline |
ctx.deploy | For deploy rules: target environment, identity, approvers |
2. Register the package. Point the whatamesh.rules entry point at the class or the list:
# pyproject.toml of acme-rules
[project.entry-points."whatamesh.rules"]
acme = "acme_rules.rules:RULES"
3. Install it wherever validation runs. Install it next to whatamesh in developer environments and in the CI image (pip install acme-rules). The engine loads every entry point once per process. A plugin that fails to import prints whatamesh: skipped rule plugins: ... and never breaks validation. Pin the package version in CI, so you know exactly which rules ran.
4. Control it with the pack. New rules run at their default severity. Use the policy pack to roll them out safely: start them as warn, set a grace date, then let them block.
5. Test it. Rules are plain classes, so test them by building a context from a fixture product:
from whatamesh.policy.engine import PolicyEngine
from whatamesh.project import Product
def test_p1_without_cost_centre_blocks():
report = PolicyEngine().evaluate(Product.load("tests/fixtures/claims").context(), {1})
assert [f.rule for f in report.findings if f.rule == "ACME001"] == ["ACME001"]
assert report.blocked
Good rules check one thing, explain the fix in remediation, point at a file and line where they can, and give the same answer on a laptop and in CI.