Skip to main content

Document model

A tool that parses Lore files builds a document model: the entries it read from every collected Lore file, and the errors and warnings it found in them and in every .loreconfig it read. A tool that computes eligibility builds an eligibility result. Both are JSON values, and the conformance examples compare against them (see Conformance examples). A tool MAY emit either one in this form. Their shapes are also given as document-model.schema.json and eligibility.schema.json.

A document model is an object with three members:

MemberValue
entriesEvery entry that no error excludes, rules and contexts alike, disabled entries included (see Error reach).
errorsA diagnostic for each error that Parsing and Error reach say the model lists, in a Lore file or in a .loreconfig.
warningsA diagnostic for each missing-category, empty-scope and unknown-disabled-id found outside an excluded file, entry or .loreconfig. The other warnings are found when computing eligibility, and only an eligibility result carries them.

Each array is in the order that Conformance examples gives under Order, and every file field follows Paths there.

Paths. A file is a path from the root of the repository that holds the file. A file of the governed repo has its plain path, except that a file read from a rules revision has rules: before it. A file of a given folder's repository has external: before its path, so that it is never mistaken for a file of the governed repo, and a file of a loose folder has loose: before its path from that folder (see External folders). The prefix does not say which repository the file is in, so a tool given folders of two repositories can list two different files with the same file. This version of the format does not tell them apart. Every other path in either output (globs in scopes, plain src values, each file in sources, and hits) names a path in the governed repo, apart from a file-relative src in an external folder (see Context) and a sources file that has the external: or loose: prefix (see File paths).

Entry fields​

FieldValue
kind"rule" or "context".
idThe entry's id (see Attributes).
fileThe path of the Lore file that holds the entry.
categoryA rule's category, found as Categories and severity says, or null when it has none. Always null for a context.
severityA rule's severity, "blocking" or "advisory", never null. Always null for a context.
disabledtrue when the entry has the disabled attribute, otherwise false. A disable list does not change it.
scopesThe file's scope, then the entry's own <scope> when it has one, each as an object with files and ignores, defaults filled in and globs resolved (see Scope and globs). A path is in the entry's scope when it is in every item.
whenThe <when> mapping as parsed, with its globs as written, or null when the entry has none (see Conditions).
checksEach <check> as an object with lang and body, in the order they appear (see Checks). Always [] for a context.
metaThe <meta> mapping as parsed, or null when the entry has none (see Children).
summaryThe first paragraph of the prose (see Entries).
proseThe entry's prose, which for a context is its body (see Entries).
srcA context's resolved src, or null when it has none (see Context). Always null for a rule.
sourcesEach item of a rule's <source>, in the order written, as an object with file, heading and phrase: file resolved, and heading and phrase as written or null when absent (see Sources). [] for a rule without <source>, and always [] for a context.

Diagnostics​

Every error and warning is reported as a diagnostic:

FieldValue
nameThe problem's name (see Errors and warnings).
fileThe path of the Lore file or .loreconfig the problem is in. For ast-grep-no-language, the changed file the check skipped.
entryThe id of the entry the problem is in, or null, as Diagnostic entry in Conformance examples says. For ast-grep-no-language, the rule's id.
lineThe line, counted from 1, as Diagnostic lines in Conformance examples says.

Eligibility result​

An eligibility result is an object with four members (see Eligibility):

MemberValue
eligibleThe id of every eligible entry, in ascending order.
hitsEach hit as an object with rule, file, line and text: the rule's id, the changed file's new path (for a hit on a removed line, its old path), the line's number counted from 1, and that line's text (see Running checks); a hit on a removed line also has side set to "old".
excludedThe document model's errors.
warningsThe document model's warnings, with missing-src-target, unsupported-check-language and ast-grep-no-language added as Eligibility says.