Context
A context is a <context> entry. It points a reviewer at a prose
document to read when the context is eligible, such as an architecture
note. A context gets no verdict, and has no category and no severity.
Context documents stay where they already live; Lore only points at
them.
- A context's attributes are
id(required),srcanddisabled, read as Attributes describes for a rule. Any other attribute,categoryandseverityincluded, isunknown-attribute. - Its children are
<meta>,<scope>and<when>, as for a rule (see Children).<check>,<source>, or any other child, isunknown-child. - Its prose is its body, found as Entries defines. With
src, the body is an optional note on when or why to read the document. Withoutsrc, the body is the context itself. - In the document model, a context has
category: null,severity: nullandchecks: [].missing-categorynever applies to a context.
src names one file, not a glob. Its value MUST be a relative path:
one or more segments separated by /, none of them empty (so no
leading, trailing or doubled /), with . and .. segments only at its
start, and a last segment that is neither . nor ... Any other value,
bare src included, is invalid-attribute-value.
- A
srcwhose first segment is.or..is relative to the Lore file. It resolves from the directory that holds the Lore file:.stays in the directory,..moves up one. Such a path lets a context point at a document kept beside its rules, and MUST NOT leave the Lore root (see .loreconfig). A..that would move up from the Lore root issrc-escapes-root. - Any other
srcresolves against the governed repo: from the base, or for a file in an external folder through itsrepomapping (see External folders). - Both
srcerrors are entry-level, at the context's opening tag line. Among the attribute checks of Attributes, a tool checkssrcforinvalid-attribute-valuefirst, then forsrc-escapes-root.
In the document model, src is the resolved path, from the governed
repo's root, or null when the context has no src. A file-relative
src in a file of an external folder names a file in that folder's
repository, not in the governed repo. Its src in the document model is
external:<path>, where <path> is from that repository's root, as in
a file field. In a loose folder (see
External folders) it is loose:<path>, where
<path> is from the loose folder.
A context with a plain src, one with a src beside the Lore file and
no body, and one with no src, whose body is the context:
Example 51 (parse)
<context id="checkout-architecture" src="ARCHITECTURE.md">
Read before judging any change to how a price is computed.
</context>
<context id="pricing-glossary" src="./glossary.md">
</context>
<context id="quote-lifecycle">
<scope>
files: ["quotes/**"]
</scope>
A quote is created when the cart is priced and expires after 30 minutes.
Any price shown after that comes from a new quote.
</context>
{
"entries": [
{
"kind": "context", "id": "checkout-architecture", "file": "apps/web/src/checkout/.lore/context.lore",
"category": null, "severity": null, "disabled": false,
"scopes": [{ "files": ["apps/web/src/checkout/**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "Read before judging any change to how a price is computed.",
"prose": "Read before judging any change to how a price is computed.",
"src": "apps/web/src/checkout/ARCHITECTURE.md",
"sources": []
},
{
"kind": "context", "id": "pricing-glossary", "file": "apps/web/src/checkout/.lore/context.lore",
"category": null, "severity": null, "disabled": false,
"scopes": [{ "files": ["apps/web/src/checkout/**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "",
"prose": "",
"src": "apps/web/src/checkout/.lore/glossary.md",
"sources": []
},
{
"kind": "context", "id": "quote-lifecycle", "file": "apps/web/src/checkout/.lore/context.lore",
"category": null, "severity": null, "disabled": false,
"scopes": [{ "files": ["apps/web/src/checkout/**"], "ignores": [] }, { "files": ["apps/web/src/checkout/quotes/**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "A quote is created when the cart is priced and expires after 30 minutes. Any price shown after that comes from a new quote.",
"prose": "A quote is created when the cart is priced and expires after 30 minutes.\nAny price shown after that comes from a new quote.",
"src": null,
"sources": []
}
],
"errors": [],
"warnings": []
}
With no .loreconfig, the Lore root is the repository root. From
.lore/, ./../README.md reaches the root's README.md, while one more
.. leaves the Lore root. A .. after the first named segment is not
allowed at all, and a path that ends in .. names a directory, not a
file:
Example 52 (parse)
<context id="shop-readme" src="./../README.md">
Read for how the shop is built and deployed.
</context>
<context id="org-handbook" src="./../../handbook/review.md">
Read for the organization's review conventions.
</context>
<context id="shop-readme-roundabout" src="docs/../README.md">
Read for how the shop is built and deployed.
</context>
<context id="shop-root" src="./..">
Read the repository's top-level files.
</context>
{
"entries": [
{
"kind": "context", "id": "shop-readme", "file": ".lore/context.lore",
"category": null, "severity": null, "disabled": false,
"scopes": [{ "files": ["**"], "ignores": [] }],
"when": null, "checks": [], "meta": null,
"summary": "Read for how the shop is built and deployed.",
"prose": "Read for how the shop is built and deployed.",
"src": "README.md",
"sources": []
}
],
"errors": [
{ "name": "src-escapes-root", "file": ".lore/context.lore", "entry": "org-handbook", "line": 5 },
{ "name": "invalid-attribute-value", "file": ".lore/context.lore", "entry": "shop-readme-roundabout", "line": 9 },
{ "name": "invalid-attribute-value", "file": ".lore/context.lore", "entry": "shop-root", "line": 13 }
],
"warnings": []
}
A missing target. When the resolved src names no tracked file, the context
gets the warning missing-src-target, at its opening tag line, and stays
eligible as usual. Parsing reads Lore files and .loreconfig files,
never the governed repo's other files, so the document model does not
report this warning. A tool reports it when it computes eligibility,
where the governed repo's files are known, for every context in the
document model whose target is missing, eligible or not. A target named
external:<path> is looked for among the tracked files of that external
folder's repository, and one named loose:<path> among the files of
that loose folder.
docs/payments-architecture.md and docs/refunds-architecture.md are
not in the governed repo. The first two contexts are eligible, and the
second carries a warning. The third is not eligible, since its scope
misses the change, and still carries one:
Example 53 (eligibility)
<context id="checkout-architecture" src="docs/checkout-architecture.md">
Read before judging any change to how a price is computed.
</context>
<context id="payments-architecture" src="docs/payments-architecture.md">
Read before judging any change to how a payment is taken.
</context>
<context id="refunds-architecture" src="docs/refunds-architecture.md">
<scope>
files: ["apps/web/src/refunds/**"]
</scope>
Read before judging any change to how a refund is issued.
</context>
# Checkout architecture
Prices come from quotes.
M apps/web/src/checkout/Price.tsx
+12 const total = quote.total
{
"eligible": ["checkout-architecture", "payments-architecture"],
"hits": [],
"excluded": [],
"warnings": [
{ "name": "missing-src-target", "file": ".lore/context.lore", "entry": "payments-architecture", "line": 5 },
{ "name": "missing-src-target", "file": ".lore/context.lore", "entry": "refunds-architecture", "line": 9 }
]
}