External folders
A team MAY keep Lore outside the repository it governs, for example in its own repository, so that one set of rules serves several repositories:
team-repo/lore/
.loreconfig root: true
categories: [data_provenance]
shop/
.loreconfig repo: github.com/acme/shop
.lore/
checkout.lore base: the shop repo's root
apps/web/.lore/
web.lore base: apps/web/ in the shop repo
- A given folder is a directory in a working copy of another
repository that the tool's user hands to the tool, for example with a
command-line option or a setting. A loose folder, below, is the one
kind of given folder that is in no working copy. A tool MAY be given
any number of folders, and treats each one the same way. In a
conformance example, the tool is given one folder: the root of the
repository that holds the
external:input files. - A
.loreconfigwith arepokey marks its directory: the directory stands for the root of the repository thatreponames. A tool looks for marked directories in each given folder and below it. - A marked directory whose
reponames the governed repo (see Matching the governed repo), with everything below it, is an external folder. The tool collects the Lore files at or below it (see Collecting files). No other Lore file of a given folder's repository is collected, including one below a directory marked for another repository. - A
.loreconfigwith arepokey that is above a given folder, and in no given folder, still marks its directory fornested-repo(see Where repo may appear). That directory is never an external folder, even when itsreponames the governed repo. To use the Lore below a marked directory, give a folder that holds the marked directory, not one inside it. - A file that more than one given folder reaches, such as when one given folder holds another, is collected and read once.
- A tool MAY collect a given folder that is in no working copy (a
loose folder), such as a downloaded copy of a team repository,
counting every file under it except those inside a directory whose
name starts with
.other than.lore. A loose folder is a repository of its own whose root is the folder, so a Lore root found in it is at or below the folder, and a file-relativesrcthat would climb above that Lore root issrc-escapes-root. Its files carryloose:and their path from the folder. When a tool collects a loose folder, it MUST reportuntracked-given-folderonce for that folder, withfileloose:.,entrynullandline1, unless the.loreconfigat the top of the folder (loose:.loreconfig) setsloose: true. Theloosekey has no effect in any other.loreconfig, and a.loreconfigwith a problem is ignored as a whole, so the tool then reports the folder. A tool MAY instead refuse such a folder and collect nothing from it. The team, not version control, decides what is in such a folder, so a stray copy of a Lore folder in it can add rules. - Below a marked directory, directories mirror the governed repo: the
directory
<marked>/<path>stands for<path>in the governed repo. The base of a Lore file below a marked directory is found as Files and folders says, counting from the marked directory instead of the repository root, and is the directory it stands for. Its globs, its plainsrcpaths and itschangedandunchangedglobs resolve from there, as in the governed repo, and a leading/means the governed repo's root. - A file-relative
src(one that starts with./or../) resolves in the external folder's own repository, as Context describes.
The Lore root of a directory at or below a marked directory is the
nearest directory, at or above it, whose .loreconfig has root: true, looking as far up as the root of the marked directory's
repository. When there is none, it is the marked directory. So a
.loreconfig above the marked directory applies only when a
root: true at or above it makes the Lore root higher than the marked
directory. An organization that wants shared categories puts them, with
root: true, in a .loreconfig above all its marked directories.
The shop's Lore is kept in a team repository. checkout.lore has the
shop repo's root as its base, and web.lore has apps/web/. The
organization's .loreconfig makes data_provenance known in both, and
its directory is the Lore root, so the context can point at the
organization's handbook beside it:
Example 134 (eligibility)
root: true
categories: [data_provenance]
# Review handbook
repo: github.com/acme/shop
<scope>
files: ["apps/web/src/checkout/**"]
</scope>
<rule id="price-source-recorded" category="data_provenance">
Every price the checkout stores records the quote it came from.
</rule>
<context id="review-handbook" src="./../../handbook.md">
Read for the organization's review conventions.
</context>
<rule id="web-prices-from-quote" category="functional_correctness">
<scope>
files: ["src/**/*.tsx"]
</scope>
A price the web app displays comes from the quote that produced it.
</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
+12 const total = quote.total
{
"eligible": ["price-source-recorded", "review-handbook", "web-prices-from-quote"],
"hits": [],
"excluded": [],
"warnings": []
}
A given folder in no working copy, such as a plain download, is
collected whole. The stray copy under .cache/ is not read, and the
tool reports the folder:
Example 135 (eligibility, requires loose-given-folder)
repo: github.com/acme/shop
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
<rule id="stale-copy" category="documentation">
A copy a tool left behind.
</rule>
M apps/web/src/checkout/Price.tsx
+12 const total = quote.total
{
"eligible": ["price-from-quote"],
"hits": [],
"excluded": [],
"warnings": [{ "name": "untracked-given-folder", "file": "loose:.", "entry": null, "line": 1 }]
}
A folder that is meant to be loose, such as rules installed with a
tool, says so in its root .loreconfig, and the tool does not report
it:
Example 136 (eligibility, requires loose-given-folder)
repo: github.com/acme/shop
loose: true
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
M apps/web/src/checkout/Price.tsx
+12 const total = quote.total
{
"eligible": ["price-from-quote"],
"hits": [],
"excluded": [],
"warnings": []
}
Here loose: true is in the marked directory's .loreconfig, which is
not at the folder's root, so it has no effect and the tool reports the
folder:
Example 137 (eligibility, requires loose-given-folder)
repo: github.com/acme/shop
loose: true
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
M apps/web/src/checkout/Price.tsx
+12 const total = quote.total
{
"eligible": ["price-from-quote"],
"hits": [],
"excluded": [],
"warnings": [{ "name": "untracked-given-folder", "file": "loose:.", "entry": null, "line": 1 }]
}
The root .loreconfig has a loose that is not a boolean, so it is
ignored, and the tool reports the folder:
Example 138 (eligibility, requires loose-given-folder)
loose: yes
repo: github.com/acme/shop
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
M apps/web/src/checkout/Price.tsx
+12 const total = quote.total
{
"eligible": ["price-from-quote"],
"hits": [],
"excluded": [
{ "name": "invalid-loreconfig", "file": "loose:.loreconfig", "entry": null, "line": 1 }
],
"warnings": [{ "name": "untracked-given-folder", "file": "loose:.", "entry": null, "line": 1 }]
}
In the document model, an external file's file keeps its external:
path. Its globs and its plain src resolve to paths in the governed
repo, from apps/web/. The file-relative src stays in the team
repository: its four .. segments lead from lore/shop/apps/web/.lore/
up to the Lore root, lore/:
Example 139 (parse)
root: true
repo: github.com/acme/shop
<scope>
files: ["src/**/*.tsx"]
</scope>
<rule id="checkout-prices-from-quote" category="functional_correctness">
<scope>
files: ["src/checkout/**"]
</scope>
A price the checkout displays comes from the quote that produced it.
</rule>
<context id="web-architecture" src="docs/architecture.md">
</context>
<context id="review-handbook" src="../../../../handbook.md">
</context>
{
"entries": [
{
"kind": "rule", "id": "checkout-prices-from-quote", "file": "external:lore/shop/apps/web/.lore/web.lore",
"category": "functional_correctness", "severity": "advisory", "disabled": false,
"scopes": [{ "files": ["apps/web/src/**/*.tsx"], "ignores": [] }, { "files": ["apps/web/src/checkout/**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "A price the checkout displays comes from the quote that produced it.",
"prose": "A price the checkout displays comes from the quote that produced it.",
"src": null,
"sources": []
},
{
"kind": "context", "id": "web-architecture", "file": "external:lore/shop/apps/web/.lore/web.lore",
"category": null, "severity": null, "disabled": false,
"scopes": [{ "files": ["apps/web/src/**/*.tsx"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "",
"prose": "",
"src": "apps/web/docs/architecture.md",
"sources": []
},
{
"kind": "context", "id": "review-handbook", "file": "external:lore/shop/apps/web/.lore/web.lore",
"category": null, "severity": null, "disabled": false,
"scopes": [{ "files": ["apps/web/src/**/*.tsx"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "",
"prose": "",
"src": "external:lore/handbook.md",
"sources": []
}
],
"errors": [],
"warnings": []
}
Matching the governed repo
A repo value names a repository as <host>/<path>: a host of
lowercase ASCII letters, digits, . and -, optionally followed by
: and a port, then / and a path with no whitespace,
ending in neither / nor .git. Any other value is
invalid-loreconfig.
The governed repo is named by its remotes: the URLs of the
repositories it is fetched from or pushed to. In a conformance example,
it has one, the === remote line. A tool normalizes a remote in
these steps:
- If it holds
://, remove everything up to and including the first://, then any user information: everything up to and including the last@before the next/. - Otherwise, if it holds a
:before any/, it has the form[user@]host:path: remove everything up to and including the last@before that:, and replace that:with/. - Remove every
/at the end, then a.gitat the end, if there is one.
A marked directory's repo names the governed repo when it equals
any of the governed repo's normalized remotes, with ASCII letters
compared regardless of case.
So https://github.com/acme/shop.git, git@github.com:Acme/shop.git
and ssh://git@github.com/acme/shop all match github.com/acme/shop,
while ssh://git@github.com:22/acme/shop keeps its port and does not.
A governed repo without a remote matches no repo. A tool MAY also let
its user map a repo value to the governed repo explicitly.
The remote is written in the scp-like form, with a different case and
.git at the end, and still names github.com/acme/shop. The
directory marked for another repository is not collected:
Example 140 (eligibility)
git@github.com:Acme/shop.git
repo: github.com/acme/shop
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
repo: github.com/acme/payments
<rule id="refunds-logged" category="observability">
Every refund is logged with the order it refunds.
</rule>
M apps/web/src/checkout/Price.tsx
{ "eligible": ["price-from-quote"], "hits": [], "excluded": [], "warnings": [] }
With a remote for another repository, the folder marked for
github.com/acme/shop is not collected, and only the governed repo's
own Lore applies:
Example 141 (eligibility)
https://github.com/acme/other
<rule id="orders-logged" category="observability">
Every order is logged with its quote.
</rule>
repo: github.com/acme/shop
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
M apps/web/src/checkout/Price.tsx
{ "eligible": ["orders-logged"], "hits": [], "excluded": [], "warnings": [] }
Trees
The governed repo's files form one tree. Each marked directory that
names the governed repo forms another: the files at or below it, and
the .loreconfig files above it that apply to it. Trees resolve their
.loreconfig files separately:
- Categories. A Lore file knows the categories of its own tree only. Categories declared in the governed repo are unknown in an external folder's files, and the other way round.
- Disable. An entry of an external folder is switched off for a path
when a
.loreconfigof the governed repo switches it off, as Disable says, or when a.loreconfigof its own tree applies to the directory that stands for the path's directory and lists its id. Adisablelist in a given folder's repository, whether inside an external folder or in a.loreconfigabove one, never switches off the governed repo's entries, nor those of a tree it does not belong to. Forunknown-disabled-id, the entries it can switch off are those of the trees it belongs to. A list in a given folder's repository that belongs to no tree switches nothing off and is not checked forunknown-disabled-id. - Ids. Ids MUST be unique across every tree, as Ids
says. An id used in two trees is
duplicate-idin both: neither entry overrides the other.
Each tree knows only its own category, so one rule in each is excluded:
Example 142 (eligibility)
categories: [web_vitals]
<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>
root: true
categories: [data_provenance]
repo: github.com/acme/shop
<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>
M apps/web/src/checkout/Price.tsx
{
"eligible": ["checkout-render-budget", "price-source-recorded"],
"hits": [],
"excluded": [
{ "name": "unknown-category", "file": ".lore/web.lore", "entry": "web-prices-recorded", "line": 5 },
{ "name": "unknown-category", "file": "external:lore/shop/.lore/shop.lore", "entry": "render-budgets-kept", "line": 5 }
],
"warnings": []
}
The shop switches off a shared rule for apps/web/ without editing the
team's file. The team's own disable list cannot switch off the shop's
rule, so the id it names is unknown to it:
Example 143 (eligibility)
disable: [shared-currency-from-settings]
<rule id="currency-from-settings" category="functional_correctness">
Display text never hard-codes a currency code.
</rule>
repo: github.com/acme/shop
disable: [currency-from-settings]
<rule id="shared-currency-from-settings" category="functional_correctness">
Display text never hard-codes a currency code; it uses the shop's
`currency` setting.
</rule>
<rule id="shared-dates-from-locale" category="functional_correctness">
Displayed dates are formatted with the shop's locale.
</rule>
M apps/web/src/checkout/Price.tsx
{
"eligible": ["currency-from-settings", "shared-dates-from-locale"],
"hits": [],
"excluded": [],
"warnings": [
{ "name": "unknown-disabled-id", "file": "external:shop/.loreconfig", "entry": null, "line": 2 }
]
}
The same id in the governed repo and in an external folder is an error in both files, not an override:
Example 144 (eligibility)
<rule id="price-from-quote" category="functional_correctness" severity="blocking">
The checkout page shows the price from the quote, never a recomputed one.
</rule>
repo: github.com/acme/shop
<rule id="price-from-quote" category="functional_correctness">
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>
M apps/web/src/checkout/Price.tsx
{
"eligible": ["dates-from-locale"],
"hits": [],
"excluded": [
{ "name": "duplicate-id", "file": ".lore/checkout.lore", "entry": "price-from-quote", "line": 1 },
{ "name": "duplicate-id", "file": "external:shop/.lore/shared.lore", "entry": "price-from-quote", "line": 1 }
],
"warnings": []
}
Where repo may appear
- A
.loreconfigin the governed repo MUST NOT have arepokey. One that does isrepo-inside-repo: Lore in the governed repo already governs it. - A marked directory MUST NOT be below another marked directory of the
same repository, whichever repositories they name. The lower one is
nested-repo.
A tool checks for these errors only in a .loreconfig that has no
other problem; an invalid-loreconfig marks nothing. The offending
.loreconfig is read, and either error is reported at the line of its
repo key, with a null entry. The error excludes that .loreconfig
and every Lore file and .loreconfig in its directory or below it:
none of those below is collected or read, and nothing in them is
reported. An excluded .loreconfig is as if it did not exist, so its
root: true, if it has one, does not cut off any lookup. A tool reads
.loreconfig files from the top of the tree down, so when such errors
nest, only the highest is reported.
apps/web/.loreconfig has a repo key, so nothing under apps/web/ is
read: not web.lore, and not the broken .loreconfig below it. In the
team repository, apps/web/ is marked below the shop's marked
directory, so its rules are excluded too:
Example 145 (eligibility)
repo: github.com/acme/shop
categories: [web_vitals]
<rule id="checkout-render-budget" category="web_vitals">
The checkout page shows its first price within the page's time budget.
</rule>
categories: [checkout_flow
<rule id="price-from-quote" category="functional_correctness">
A displayed price must come from the quote that produced it.
</rule>
repo: github.com/acme/shop
<rule id="dates-from-locale" category="functional_correctness">
Displayed dates are formatted with the shop's locale.
</rule>
lore: 1
repo: github.com/acme/web
<rule id="web-dates-from-locale" category="functional_correctness">
Dates the web app displays are formatted with the shop's locale.
</rule>
M apps/web/src/checkout/Price.tsx
{
"eligible": ["dates-from-locale", "price-from-quote"],
"hits": [],
"excluded": [
{ "name": "repo-inside-repo", "file": "apps/web/.loreconfig", "entry": null, "line": 1 },
{ "name": "nested-repo", "file": "external:lore/shop/apps/web/.loreconfig", "entry": null, "line": 2 }
],
"warnings": []
}