Rules
A rule is a <rule> entry: one thing a team expects every change to
follow. Its opening tag carries its attributes. Its contents are its
children and then its prose, read as Entries describes.
Attributes
| Attribute | Required | Value |
|---|---|---|
id | yes | The entry's id, in kebab-case: it matches ^[a-z][a-z0-9-]*$. |
category | no | A category that matches ^[a-z][a-z0-9_]*$ and is known for the file (see Categories and severity). |
severity | no | blocking or advisory (see Categories and severity). |
disabled | no | Bare, with no value. |
A tool reads the attributes of an entry's opening tag from left to right, and the first problem it meets is the entry's error:
-
An attribute whose name already appeared on the tag is
duplicate-attribute. -
An attribute the element does not define is
unknown-attribute. A rule defines only the four above, sosrcon a rule isunknown-attributetoo. -
A value the attribute does not allow is
invalid-attribute-value, except where a more specific name applies:- an
idvalue that does not match the id pattern isinvalid-id; - a
categoryvalue that matches the category pattern but is not a known category isunknown-category; disabledwith any value, evendisabled="false"ordisabled="", isdisabled-has-value.
So
id,categoryandseveritywritten bare areinvalid-attribute-value, and so are acategorythat does not match the category pattern and aseverityother thanblockingoradvisory. - an
-
A tag that ends with no
idattribute ismissing-id.
A malformed attribute list (see Lines and tags) is
met at the first character where it stops being valid, in the same
left-to-right reading. So on <rule id="x" owner="y" category=z>,
owner is met first, and the error is unknown-attribute.
Every error in this section is entry-level, and its line is the entry's
opening tag line. An entry's readable id is the value of the first
id attribute on its opening tag, when that value matches the id
pattern; it is the entry of the entry's diagnostics. (Lines and
tags narrows this for a malformed opening tag.) An
entry with invalid-id or missing-id has no readable id.
The first rule has no id, the second's id is not kebab-case, and the third repeats an attribute. The fourth has no id either, but its unknown attribute is met first. Only the last rule is read:
Example 40 (parse)
<rule category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
<rule id="currencyFromSettings" category="functional_correctness">
Display text never hard-codes a currency code.
</rule>
<rule id="dates-from-locale" category="functional_correctness" category="accessibility">
Displayed dates are formatted with the shop's locale.
</rule>
<rule owner="pricing">
Quoted prices are rounded once, when the quote is made.
</rule>
<rule id="quote-expiry-shown" category="functional_correctness">
A checkout page that shows a quoted price also shows when the quote expires.
</rule>
{
"entries": [
{
"kind": "rule", "id": "quote-expiry-shown", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "A checkout page that shows a quoted price also shows when the quote expires.",
"prose": "A checkout page that shows a quoted price also shows when the quote expires.",
"src": null,
"sources": []
}
],
"errors": [
{ "name": "missing-id", "file": ".lore/checkout.lore", "entry": null, "line": 1 },
{ "name": "invalid-id", "file": ".lore/checkout.lore", "entry": null, "line": 5 },
{ "name": "duplicate-attribute", "file": ".lore/checkout.lore", "entry": "dates-from-locale", "line": 9 },
{ "name": "unknown-attribute", "file": ".lore/checkout.lore", "entry": null, "line": 13 }
],
"warnings": []
}
An attribute the element does not define is an error, on a rule and on a
context alike: a context has no category. A severity the format does not
define is an invalid value. In refunds-logged, the unknown attribute
comes before the malformed one, so it is met first:
Example 41 (parse)
<rule id="price-from-quote" category="functional_correctness" owner="pricing">
A displayed price must come from the quote that produced it.
</rule>
<rule id="currency-from-settings" category="functional_correctness" severity="high">
Display text never hard-codes a currency code.
</rule>
<context id="checkout-architecture" src="ARCHITECTURE.md" category="documentation">
Read before judging any change to how a price is computed.
</context>
<rule id="refunds-logged" owner="payments" category=observability>
Every refund is logged with the order it refunds.
</rule>
<rule id="dates-from-locale" category="functional_correctness">
Displayed dates are formatted with the shop's locale.
</rule>
{
"entries": [
{
"kind": "rule", "id": "dates-from-locale", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "Displayed dates are formatted with the shop's locale.",
"prose": "Displayed dates are formatted with the shop's locale.",
"src": null,
"sources": []
}
],
"errors": [
{ "name": "unknown-attribute", "file": ".lore/checkout.lore", "entry": "price-from-quote", "line": 1 },
{ "name": "invalid-attribute-value", "file": ".lore/checkout.lore", "entry": "currency-from-settings", "line": 5 },
{ "name": "unknown-attribute", "file": ".lore/checkout.lore", "entry": "checkout-architecture", "line": 9 },
{ "name": "unknown-attribute", "file": ".lore/checkout.lore", "entry": "refunds-logged", "line": 13 }
],
"warnings": []
}
Disabled entries. disabled is the author's switch for turning an
entry off without deleting it; .loreconfig gives the
consumer's switch. A disabled entry is never eligible. It is still read
and checked like any other entry, and the document model lists it with
disabled: true. disabled takes no value:
Example 42 (parse)
<rule id="price-from-quote" category="functional_correctness" disabled>
A displayed price must come from the quote that produced it.
</rule>
<rule id="currency-from-settings" category="functional_correctness" disabled="false">
Display text never hard-codes a currency code.
</rule>
{
"entries": [
{
"kind": "rule", "id": "price-from-quote", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": true,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "A displayed price must come from the quote that produced it.",
"prose": "A displayed price must come from the quote that produced it.",
"src": null,
"sources": []
}
],
"errors": [
{ "name": "disabled-has-value", "file": ".lore/checkout.lore", "entry": "currency-from-settings", "line": 5 }
],
"warnings": []
}
The disabled rule's scope covers the change, but it is not eligible:
Example 43 (eligibility)
<rule id="price-from-quote" category="functional_correctness" disabled>
A displayed price must come from the quote that produced it.
</rule>
<rule id="quote-expiry-shown" category="functional_correctness">
A checkout page that shows a quoted price also shows when the quote expires.
</rule>
M apps/web/src/checkout/Price.tsx
+12 const total = quote.total
{ "eligible": ["quote-expiry-shown"], "hits": [], "excluded": [], "warnings": [] }
Ids. Rules and contexts share one namespace of ids. Ids MUST be
unique across every Lore file collected for the governed repo, including
the files of external folders (see External folders).
An id used by more than one entry is duplicate-id, an entry-level error
that excludes every entry using it. No entry overrides another.
- A tool checks ids after it has read every file. Every entry with a readable id counts, including a disabled entry and one excluded by another error. Entries in a file excluded by a file-level error do not count.
- Each entry that shares an id and has no other error gets
duplicate-id, at its opening tag line. An entry that already has an error keeps that error, as Parsing requires, and is not listed twice.
Each id below is used in both of the first two files, by two rules or
by a rule and a context. The first quote-expiry-shown already has an
error, and the second is still excluded. The disabled
totals-from-quote counts too. The third file is excluded by a
file-level error, so its dates-from-locale does not count, and the
other one is read:
Example 44 (parse)
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
<rule id="currency-from-settings" category="functional_correctness">
Display text never hard-codes a currency code.
</rule>
<rule id="quote-expiry-shown" category="functional_correctness" severity="high">
A checkout page that shows a quoted price also shows when the quote expires.
</rule>
<rule id="totals-from-quote" category="functional_correctness" disabled>
Cart totals come from the quote, never from summing line items.
</rule>
<rule id="price-from-quote" category="functional_correctness" severity="blocking">
The checkout page shows the price from the quote, never a recomputed one.
</rule>
<context id="currency-from-settings" src="docs/currency.md">
Read before changing how a price is formatted.
</context>
<rule id="quote-expiry-shown" category="functional_correctness">
The quote's expiry time is shown next to the quoted price.
</rule>
<rule id="totals-from-quote" category="functional_correctness">
The order total comes from the quote.
</rule>
<rule id="dates-from-locale" category="functional_correctness">
Displayed dates are formatted with the shop's locale.
</rule>
Draft rules, not reviewed yet.
<rule id="dates-from-locale" category="functional_correctness">
Displayed dates use the shop's locale.
</rule>
{
"entries": [
{
"kind": "rule", "id": "dates-from-locale", "file": "apps/web/src/checkout/.lore/rules.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["apps/web/src/checkout/**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "Displayed dates are formatted with the shop's locale.",
"prose": "Displayed dates are formatted with the shop's locale.",
"src": null,
"sources": []
}
],
"errors": [
{ "name": "duplicate-id", "file": ".lore/checkout.lore", "entry": "price-from-quote", "line": 1 },
{ "name": "duplicate-id", "file": ".lore/checkout.lore", "entry": "currency-from-settings", "line": 5 },
{ "name": "invalid-attribute-value", "file": ".lore/checkout.lore", "entry": "quote-expiry-shown", "line": 9 },
{ "name": "duplicate-id", "file": ".lore/checkout.lore", "entry": "totals-from-quote", "line": 13 },
{ "name": "top-level-text", "file": ".lore/drafts.lore", "entry": null, "line": 1 },
{ "name": "duplicate-id", "file": "apps/web/src/checkout/.lore/rules.lore", "entry": "price-from-quote", "line": 1 },
{ "name": "duplicate-id", "file": "apps/web/src/checkout/.lore/rules.lore", "entry": "currency-from-settings", "line": 5 },
{ "name": "duplicate-id", "file": "apps/web/src/checkout/.lore/rules.lore", "entry": "quote-expiry-shown", "line": 9 },
{ "name": "duplicate-id", "file": "apps/web/src/checkout/.lore/rules.lore", "entry": "totals-from-quote", "line": 13 }
],
"warnings": []
}
Children
A rule's children come before its prose, in any order:
| Child | Count | Contents |
|---|---|---|
<meta> | 0 or 1 | A free-form YAML mapping, described below. |
<scope> | 0 or 1 | The rule's own scope, which narrows the file's (see Scope and globs). |
<when> | 0 or 1 | Conditions on the change (see Conditions). |
<source> | 0 or 1 | The files the rule was written from (see Sources). |
<check> | any number | A search whose hits go to the reviewer (see Checks). |
- The order of the children carries no meaning, except among
<check>elements: the document model keeps checks in the order they appear. - A child whose name its entry does not allow is
unknown-child. - A second
<meta>,<scope>,<when>or<source>in one entry isduplicate-child. <meta>,<scope>,<when>and<source>take no attributes: an attribute on one isunknown-attribute.<check>takes the attributes Checks defines. A child's attributes are read from left to right, as an entry's are.- A tool reads each child in this order, and reports the first problem it
finds: its name (
unknown-child), then whether it repeats an earlier child (duplicate-child), then its attributes, then its indentation, then its contents. - Every error this section defines is entry-level. Apart from a YAML problem, its line is the child's opening tag line.
<meta> holds what a team wants to record about an entry: where the
rule came from, an owner, links. It is a structured block, and its value
MUST be a mapping; anything else, such as a scalar, a list or null, is
invalid-meta. This specification gives no key a meaning, and tools MAY
define their own keys. A tool MUST NOT let the keys and values of a
valid <meta> change whether an entry is eligible. The document model
keeps the mapping as parsed, in meta; an entry without <meta> has
meta: null.
<meta> is kept as parsed, whatever its keys. Under the core schema,
2026-03-01 is a string, not a date:
Example 45 (parse)
<rule id="price-from-quote" category="functional_correctness">
<meta>
source: docs/pricing-review.md#prices
owner: checkout
reviewed: 2026-03-01
reviewers: [pricing, web]
links:
decision: docs/decisions/0042-quote-prices.md
</meta>
A displayed price must come from the quote that produced it.
</rule>
{
"entries": [
{
"kind": "rule", "id": "price-from-quote", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [],
"meta": {
"source": "docs/pricing-review.md#prices",
"owner": "checkout",
"reviewed": "2026-03-01",
"reviewers": ["pricing", "web"],
"links": { "decision": "docs/decisions/0042-quote-prices.md" }
},
"summary": "A displayed price must come from the quote that produced it.",
"prose": "A displayed price must come from the quote that produced it.",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
<meta> holding a scalar or a list is an error:
Example 46 (parse)
<rule id="price-from-quote" category="functional_correctness">
<meta>
checkout team
</meta>
A displayed price must come from the quote that produced it.
</rule>
<rule id="currency-from-settings" category="functional_correctness">
<meta>
- checkout
- pricing
</meta>
Display text never hard-codes a currency code.
</rule>
{
"entries": [],
"errors": [
{ "name": "invalid-meta", "file": ".lore/checkout.lore", "entry": "price-from-quote", "line": 2 },
{ "name": "invalid-meta", "file": ".lore/checkout.lore", "entry": "currency-from-settings", "line": 9 }
],
"warnings": []
}
The same children in the opposite order give the same model, apart from the id:
Example 47 (parse)
<rule id="currency-children-first" category="functional_correctness">
<meta>
owner: checkout
</meta>
<scope>
files: ["apps/web/**/*.tsx"]
</scope>
<when>
addedContains: ["'USD'"]
</when>
<check>
'USD'
</check>
Display text never hard-codes a currency code.
</rule>
<rule id="currency-children-reversed" category="functional_correctness">
<check>
'USD'
</check>
<when>
addedContains: ["'USD'"]
</when>
<scope>
files: ["apps/web/**/*.tsx"]
</scope>
<meta>
owner: checkout
</meta>
Display text never hard-codes a currency code.
</rule>
{
"entries": [
{
"kind": "rule", "id": "currency-children-first", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }, { "files": ["apps/web/**/*.tsx"], "ignores": [] }],
"when": { "addedContains": ["'USD'"] },
"checks": [{ "lang": "regex", "body": "'USD'" }],
"meta": { "owner": "checkout" },
"summary": "Display text never hard-codes a currency code.",
"prose": "Display text never hard-codes a currency code.",
"src": null,
"sources": []
},
{
"kind": "rule", "id": "currency-children-reversed", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }, { "files": ["apps/web/**/*.tsx"], "ignores": [] }],
"when": { "addedContains": ["'USD'"] },
"checks": [{ "lang": "regex", "body": "'USD'" }],
"meta": { "owner": "checkout" },
"summary": "Display text never hard-codes a currency code.",
"prose": "Display text never hard-codes a currency code.",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
A rule may have several checks, and they keep their order:
Example 48 (parse)
<rule id="currency-codes-from-settings" category="functional_correctness">
<check>
'USD'
</check>
<check lang="regex">
'EUR'
</check>
Display text never hard-codes a currency code.
</rule>
{
"entries": [
{
"kind": "rule", "id": "currency-codes-from-settings", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null,
"checks": [{ "lang": "regex", "body": "'USD'" }, { "lang": "regex", "body": "'EUR'" }],
"meta": null,
"summary": "Display text never hard-codes a currency code.",
"prose": "Display text never hard-codes a currency code.",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
A second <when> is an error, and so is a child the entry does not
allow: <check> in a context, or an element the format does not define
in a rule:
Example 49 (parse)
<rule id="currency-from-settings" category="functional_correctness">
<when>
addedContains: ["'USD'"]
</when>
<when>
changed: ["apps/web/src/checkout/**"]
</when>
Display text never hard-codes a currency code.
</rule>
<context id="checkout-architecture" src="ARCHITECTURE.md">
<check>
quote
</check>
Read before judging any change to how a price is computed.
</context>
<rule id="price-from-quote" category="functional_correctness">
<example>
const price = quote.total
</example>
A displayed price must come from the quote that produced it.
</rule>
<rule id="dates-from-locale" category="functional_correctness">
Displayed dates are formatted with the shop's locale.
</rule>
{
"entries": [
{
"kind": "rule", "id": "dates-from-locale", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "Displayed dates are formatted with the shop's locale.",
"prose": "Displayed dates are formatted with the shop's locale.",
"src": null,
"sources": []
}
],
"errors": [
{ "name": "duplicate-child", "file": ".lore/checkout.lore", "entry": "currency-from-settings", "line": 5 },
{ "name": "unknown-child", "file": ".lore/checkout.lore", "entry": "checkout-architecture", "line": 12 },
{ "name": "unknown-child", "file": ".lore/checkout.lore", "entry": "price-from-quote", "line": 19 }
],
"warnings": []
}
Prose and summary
Everything after a rule's children, up to </rule>, is the rule's
prose, in CommonMark Markdown. Entries defines exactly which
lines it holds and how its summary is found.
- The prose MUST state the rule completely on its own. A reader who
skips
<when>and<check>still knows exactly what the rule asks. Conditions and checks select a rule and point at lines; they never add to its meaning. - The prose's first paragraph is the rule's summary, which tools use in listings and short reports. Authors SHOULD keep it to one or two sentences.
The summary is found by lines, not by Markdown structure, so a list directly under the first sentence is part of the summary. A blank line before the list would keep it out:
Example 50 (parse)
<rule id="checkout-prices-from-quote" category="functional_correctness">
Every price the checkout page shows comes from the quote:
- each line item's price;
- the order total.
A helper that recomputes a price from its inputs drops quote-level
discounts.
</rule>
{
"entries": [
{
"kind": "rule", "id": "checkout-prices-from-quote", "file": ".lore/checkout.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "Every price the checkout page shows comes from the quote: - each line item's price; - the order total.",
"prose": "Every price the checkout page shows comes from the quote:\n- each line item's price;\n- the order total.\n\nA helper that recomputes a price from its inputs drops quote-level\ndiscounts.",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}