.loreconfig
A .loreconfig file holds settings for the directory it is in and
every directory below it, except those below a Lore root that cuts off
the lookup (see Lore root). It MAY sit in any directory
of the governed repo or of a given folder's repository, except inside a
Lore folder: a file
there is not a Lore file, and a tool ignores it (see
Files and folders).
A .loreconfig is UTF-8 text, read as a Lore file is (see
Files and folders). Its whole content is one
structured block (see Structured blocks). It is
not an element, so no indentation is removed from it. Its value MUST be
a mapping whose keys are all optional:
| Key | Value | Meaning |
|---|---|---|
lore | 1 | The version of this specification that the files follow. Without it, the version is 1. |
root | true or false | true makes this directory a Lore root (see Lore root). Without it, false. |
repo | <host>/<path> | Marks this directory as standing for the root of the repository it names (see External folders). |
loose | true or false | true in the .loreconfig at the root of a loose folder says the folder is meant to be loose (see External folders). Without it, false. |
categories | A list of categories | Categories declared for this directory and below (see Categories). |
disable | A list of ids | Entries switched off for changed files in this directory and below (see Disable). |
audit | A mapping | The age limit and finding levels that audits use for this directory and below (see Audit settings). |
An empty .loreconfig, or one that holds only comments, is an empty
mapping and sets nothing. The shape is also given as
loreconfig.schema.json.
Every problem with the content of a .loreconfig is
invalid-loreconfig: each problem that
Structured blocks names, a byte that is not
valid UTF-8, and any value the table does not allow, such as a key it
does not name, lore: 2, or root: yes (which the core schema reads
as a string). A tool ignores a .loreconfig with a problem as a whole,
as if it did not exist, and reports the error once, with a null
entry. Entries that relied on it then fail on their own: an entry
whose category it declared is unknown-category.
A tool checks a .loreconfig in this order, and reports the first
problem it finds, at this line:
- a byte that is not valid UTF-8: that byte's line;
- the problems of Structured blocks, in the order that section gives: the line it gives, counted in the file. A document that ends before it is complete is reported at the file's last line, the line that holds the file's last character (for a file that ends with a line feed, the line that the line feed ends);
- a value that is not a mapping: line 1;
- each key, in the order of the file: the line of the first key that the table does not name, or whose value it does not allow.
The first .loreconfig has a disable that is not a list, the second
repeats a key, and the third has a root that is not a boolean. All
three are ignored: the categories they declare are unknown, and
currency-from-settings is not switched off:
Example 127 (eligibility)
categories: [data_provenance]
disable: currency-from-settings
lore: 1
categories: [api_contracts]
categories: [api_latency]
root: yes
categories: [web_vitals]
<rule id="order-schema-versioned" category="api_contracts">
Every change to the order schema bumps its version.
</rule>
<rule id="price-source-recorded" category="data_provenance">
Every stored price records the quote it came from.
</rule>
<rule id="currency-from-settings" category="functional_correctness">
Display text never hard-codes a currency code.
</rule>
<rule id="checkout-render-budget" category="web_vitals">
The checkout page shows its first price within the page's time budget.
</rule>
M apps/web/src/checkout/Price.tsx
+12 const label = 'USD'
{
"eligible": ["currency-from-settings"],
"hits": [],
"excluded": [
{ "name": "unknown-category", "file": ".lore/provenance.lore", "entry": "price-source-recorded", "line": 1 },
{ "name": "invalid-loreconfig", "file": ".loreconfig", "entry": null, "line": 2 },
{ "name": "unknown-category", "file": "apps/api/.lore/api.lore", "entry": "order-schema-versioned", "line": 1 },
{ "name": "invalid-loreconfig", "file": "apps/api/.loreconfig", "entry": null, "line": 3 },
{ "name": "unknown-category", "file": "apps/web/.lore/web.lore", "entry": "checkout-render-budget", "line": 1 },
{ "name": "invalid-loreconfig", "file": "apps/web/.loreconfig", "entry": null, "line": 1 }
],
"warnings": []
}
Lore root
.loreconfig files cascade: the settings that hold for a directory come
from the .loreconfig in it and those above it. The Lore root of a
directory is where that lookup stops, so that the result never depends
on where a tool was pointed. A .loreconfig applies to a directory
when it is in that directory or in one above it, up to and including the
directory's Lore root, and is not ignored.
- In the governed repo, the Lore root of a directory is the nearest
directory, at or above it, whose
.loreconfighasroot: true. When there is none, it is the repository's root. Lookup never goes above the repository's root. - In an external folder, the Lore root is defined in External folders.
- A Lore file's Lore root is the Lore root of the directory that holds
it. A file-relative
srcMUST NOT leave it (see Context).
apps/web/.loreconfig has root: true, so lookup from apps/web/
stops there: data_provenance, declared at the repository root, is not
known in apps/web/.lore/, and ./../../README.md leaves the Lore root.
At the repository root, with no root: true anywhere above, the Lore
root is the repository's root, and ./../../handbook/review.md leaves
it:
Example 128 (eligibility)
categories: [data_provenance]
root: true
categories: [web_vitals]
<rule id="price-source-recorded" category="data_provenance">
Every stored price records the quote it came from.
</rule>
<context id="org-handbook" src="./../../handbook/review.md">
Read for the organization's review conventions.
</context>
<rule id="checkout-render-budget" category="web_vitals">
The checkout page shows its first price within the page's time budget.
</rule>
<rule id="web-prices-recorded" category="data_provenance">
Every price the web app stores records the quote it came from.
</rule>
<context id="web-readme" src="./../README.md">
Read for how the web app is built.
</context>
<context id="shop-readme" src="./../../README.md">
Read for how the shop is built and deployed.
</context>
# Web app
M apps/web/src/checkout/Price.tsx
{
"eligible": ["checkout-render-budget", "price-source-recorded", "web-readme"],
"hits": [],
"excluded": [
{ "name": "src-escapes-root", "file": ".lore/shop.lore", "entry": "org-handbook", "line": 5 },
{ "name": "unknown-category", "file": "apps/web/.lore/web.lore", "entry": "web-prices-recorded", "line": 5 },
{ "name": "src-escapes-root", "file": "apps/web/.lore/web.lore", "entry": "shop-readme", "line": 13 }
],
"warnings": []
}
Categories
The categories known for a Lore file are the fixed ones and those that
the categories lists of the .loreconfig files that apply to its
directory declare (see Categories and severity).
- Lists add down the tree. A
.loreconfigcannot take away a category that one above it declares, and an empty list declares nothing. - A category declared in a directory below a Lore file's directory, or beside it, is not known for that file.
- Declaring a fixed category, or one already declared above, changes nothing.
apps/web/ adds web_vitals to data_provenance from the root, and
apps/api/'s empty list takes nothing away. At the root, web_vitals
is unknown:
Example 129 (eligibility)
categories: [data_provenance]
categories: [web_vitals]
categories: []
<rule id="price-source-recorded" category="data_provenance">
Every stored price records the quote it came from.
</rule>
<rule id="render-budgets-kept" category="web_vitals">
Every page shows its first content within its time budget.
</rule>
<rule id="checkout-render-budget" category="web_vitals">
The checkout page shows its first price within the page's time budget.
</rule>
<rule id="web-prices-recorded" category="data_provenance">
Every price the web app stores records the quote it came from.
</rule>
<rule id="api-prices-recorded" category="data_provenance">
Every price the API stores records the quote it came from.
</rule>
M apps/web/src/checkout/Price.tsx
M apps/api/src/orders.ts
{
"eligible": ["api-prices-recorded", "checkout-render-budget", "price-source-recorded", "web-prices-recorded"],
"hits": [],
"excluded": [
{ "name": "unknown-category", "file": ".lore/shop.lore", "entry": "render-budgets-kept", "line": 5 }
],
"warnings": []
}
Disable
disable lists the ids of entries that a .loreconfig switches off for
changed files in its directory and below. It is the consumer's switch,
where disabled is the author's (see Attributes): a team
switches an entry off for part of a repository without editing the file
that holds it.
- An entry is switched off for a path when its id is in the
disablelist of a.loreconfigthat applies to the directory that holds the path. Lists add down the tree, ascategorieslists do, so a.loreconfigbelow cannot switch the entry back on. An id MAY name a context as well as a rule. - An entry is switched off for a changed file when it is switched off
for each of the file's paths that is in its scope. Such a file is not
one of the entry's counted files: it does not make the entry eligible,
its added and removed lines do not count for the added-line,
removed-line and dropped-line conditions, and checks do not search it.
changedandunchangedstill see it (see Conditions). - An entry switched off for every changed file in its scope is not eligible. A counted file elsewhere keeps it eligible.
- A
disablelist in the governed repo also switches off entries from external folders. External folders says which lists apply to those entries.
An id in a disable list that names no entry the list can switch off
is the warning unknown-disabled-id, once for each such item, with a
null entry. Its line is the line where the item starts: in a block
sequence, the line of the item's -; in a flow sequence, the line of
the item's first character. The entries a list can
switch off are those whose ids count in Ids: for a list
in the governed repo, every such entry collected from anywhere; for a
list in a given folder's repository, see
External folders.
The warning is part of the document model.
legacy/ switches off three rules. currency-from-settings stays
eligible through Total.tsx. currency-codes-from-settings counts only
Total.tsx, where no 'USD' was added. legacy-prices-from-quote has
no counted file:
Example 130 (eligibility)
disable: [currency-from-settings, currency-codes-from-settings, legacy-prices-from-quote]
<rule id="currency-from-settings" category="functional_correctness">
Display text never hard-codes a currency code; it uses the shop's
`currency` setting.
</rule>
<rule id="currency-codes-from-settings" category="functional_correctness">
<when>
addedContains: ["'USD'"]
</when>
Display text never spells out a currency code.
</rule>
<rule id="legacy-prices-from-quote" category="functional_correctness">
Legacy pages take their prices from the quote too.
</rule>
M apps/web/src/legacy/Price.tsx
+4 const label = 'USD'
M apps/web/src/checkout/Total.tsx
+9 return <span>{total}</span>
{ "eligible": ["currency-from-settings"], "hits": [], "excluded": [], "warnings": [] }
A disable list may switch off a context. curency-from-settings names
no entry, while dates-from-locale names an entry that is excluded by
an error and still counts:
Example 131 (eligibility)
disable:
- checkout-architecture
- curency-from-settings
- dates-from-locale
<rule id="currency-from-settings" category="functional_correctness">
Display text never hard-codes a currency code.
</rule>
<rule id="dates-from-locale" category="functional_correctness" severity="high">
Displayed dates are formatted with the shop's locale.
</rule>
<context id="checkout-architecture" src="ARCHITECTURE.md">
Read before judging any change to how a price is computed.
</context>
# Checkout architecture
M apps/web/src/checkout/Price.tsx
{
"eligible": ["currency-from-settings"],
"hits": [],
"excluded": [
{ "name": "invalid-attribute-value", "file": ".lore/checkout.lore", "entry": "dates-from-locale", "line": 5 }
],
"warnings": [
{ "name": "unknown-disabled-id", "file": ".loreconfig", "entry": null, "line": 3 }
]
}
Audit settings
audit sets how a tool that audits sources reports its findings for a
directory and below. It is a mapping with two optional keys:
maxAgeDays: a positive integer, the number of days after which a review is overdue. Without it, no age limit is set.levels: a mapping from a finding name to a level. A level iserror,warnoroff. The finding names, and the level each has when nothing sets it, are:
| Finding | Default level |
|---|---|
source-missing | error |
source-unchecked | error |
ambiguous-heading | warn |
source-changed | warn |
never-reviewed | warn |
review-overdue | warn |
orphan-review | warn |
meta-source | off |
Anything else under audit is invalid-loreconfig: a key other than
those two, a maxAgeDays that is not a positive integer, a levels
that is not a mapping, a finding name not in the table, or a level not
named above. The problem is reported at the line of the audit key.
Each setting is looked up on its own. maxAgeDays, and the level of
each finding, takes its value from the nearest .loreconfig that sets
it, on the way up from a directory to its Lore root (see
Lore root); a setting that none sets has its default. A
.loreconfig above the Lore root is not consulted. A finding that
belongs to no rule takes the settings of the directory that holds its
lock file (see The lock file).
The root .loreconfig sets an age limit and turns one finding off.
apps/web/ raises one finding to an error and leaves the rest as the
root set them:
Example 132 (parse)
audit:
maxAgeDays: 180
levels:
never-reviewed: off
audit:
levels:
source-changed: error
<rule id="price-from-quote" category="functional_correctness">
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": 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": [],
"warnings": []
}
A level that is not error, warn or off makes the whole
.loreconfig invalid. It is ignored and reported at the audit line:
Example 133 (parse)
lore: 1
audit:
levels:
source-changed: fatal
<rule id="price-from-quote" category="functional_correctness">
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": 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": "invalid-loreconfig", "file": ".loreconfig", "entry": null, "line": 2 }
],
"warnings": []
}