Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

References and Rust items

req requirements.references.roles

Project text files MAY use the {impl}, {cite}, and {test} roles with a backtick-delimited full requirement or example name, or with a built-in name under cite requirements.references.builtin_definitions, and MAY use the {fixme} role in fenced form. A reference MAY instead be written in fenced form, :::{role} name on one line, a body, and a closing fence, following the fence rules of cite requirements.ci.span and cite requirements.ci.fence_lengths; the fenced form is the same edge with attached commentary, and the inline form carries none. In a source comment, fence lines MUST be recognized after removing each line’s comment delimiters within one comment run under cite requirements.references.outline_comments, and a fence that does not close within its comment run MUST be a validation error. Each reference is a directed edge between its source and the named definition. A source is a project source item or a requirement or example declaration. The roles MUST mean:

  • {cite}: the source relies on, supports, or refers to the definition. It is an edge from the source to the definition.
  • {impl}: the source implements part of the definition: it makes a decision, performs a check, produces an output, or handles a case that the definition specifies. A requirement MAY implement part of another requirement by refining one of its obligations. Calling code that implements a definition, or producing a result a caller uses to meet it, MUST NOT by itself count as implementing it. A check MUST count only if the definition states it, or the source could not meet one of the definition’s obligations without it; source that checks it is consistent with a definition, such as recognizing a form the definition specifies in order to decide whether to run other behavior, relies on that definition and calls for {cite}. A requirement stating a convention for every output of a kind, such as every validation error, is implemented by the source that carries out the convention as a whole, such as the step that collects and reports those outputs.
  • {test}: the source is designed to verify behavior the definition specifies: a test through its scenario and the assertions about that scenario’s outcome, or a named example through the concrete case it describes.
  • {fixme}: the source acknowledges a known gap in fulfilling the definition. It MUST use the fenced form, and its body MUST describe the gap. The body MAY begin with option lines naming issues that track the gap, one per line, in the form :github: <owner>/<repo>#<number>, such as :github: rust-lang/rust#123. github MUST be the only recognized option. A named {fixme} MAY appear only in sources outside the book. Validation MUST report any other option line, a :github: value not in that form, an inline {fixme}, a {fixme} in a requirement or example declaration, and a {fixme} whose body, without option lines and comment delimiters, is empty. An unnamed {fixme}, a fence of :::{fixme} with no name, MAY appear in any project text, including a requirement or example body, to tie that place to the issues it names. It MUST have at least one :github: option line and MAY have a description; it is not a reference edge, acknowledges no gap, needs no coverage, and does not count as a reference for Rust item coverage. Its issues are checked under cite requirements.cli.fixme_issues.

{impl}, {test}, and {fixme} are edges from the definition to the source. Only requirements and examples are assessed; code is reviewed as part of the definitions it implements or tests.

{impl}`requirements.references.roles`
{cite}`requirements.references.roles`
{test}`requirements.references.roles`

req requirements.references.util

Habeas MUST provide the built-in habeas:util under cite requirements.references.builtin_definitions, with this text:

Cite this on an item that serves other code, including code outside the project such as a library calling a trait implementation it requires, and carries out no requirement or example itself: it has no obligations and no end-user-observable behavior of its own. A review that reaches it from a root judges what it does as part of that root.

Only {cite} MAY reference it, inline or fenced, with or without commentary. An item whose only citations are of habeas:util MUST NOT need a citation review under cite requirements.references.citation_review. A citation of habeas:util MUST cover its item under cite requirements.references.rust_item_coverage.

req requirements.references.procedure

A source item MUST choose its references under cite requirements.references.roles for each candidate definition by this procedure, and MAY carry several:

  1. If the item is a test designed to verify the definition, it MUST use {test}. A test helper a reviewer reaches by following such a test needs no reference to the definition.
  2. Otherwise, if the item is a root of the definition’s implementation, it MUST use {impl}. Code or a type carries out part of a definition when it makes a decision, performs a check, produces an output, or handles a case the definition specifies, or when the definition constrains its shape: fields, variants, serialized form, or validation. A root is such an item that no other item marked {impl} for the definition reaches, where an item reaches what it calls, the types it uses, and the implementations of trait methods it calls, and what those reach in turn. An item reached from a root needs no reference to the definition. An item that is a site of a distributed definition under cite requirements.references.distributed needs no reference to it; its site review covers it.
  3. Otherwise, if the item should be re-checked or kept in sync when the definition changes, it MUST use {cite}.
  4. If the item carries no reference after applying steps 1 to 3 to every definition and no assessment reads it under cite requirements.references.rust_item_coverage, it MUST cite the built-in habeas:util under cite requirements.references.util when it serves other code. An item that does neither carries out behavior that needs a requirement, or is not needed.

A {fixme} reference is added independently of this procedure, and MUST NOT count as an item’s reference for cite requirements.references.rust_item_coverage.

req requirements.references.discovery

Habeas MUST find the references of cite requirements.references.roles in project source files, where cite requirements.references.reference_contexts says they count, and MUST fail with the source file and line if a name has no matching {req} or {example} definition. In Markdown, escaped roles and roles in code examples MUST remain literal. Reference discovery MUST consider exactly the project sources that source-access policy permits under cite requirements.authoring.source_tools: in a Git worktree, files present in the Git index, including staged new files; outside Git, all project files; in both cases excluding the project-root book and evidence directories, .git and target directories at any depth, and paths disallowed by cite requirements.configuration.evidence_paths. Evidence snapshots and generated build output MUST therefore not be counted as source references.

req requirements.references.reference_contexts

Each supported language profile MUST define where in its files roles count as references, and SHOULD exclude places that hold code or data rather than prose, such as string literals. In a file with a language outline under cite requirements.references.outlines, inline and fenced roles MUST count only within comments as its profile defines them, including doc comments; a role anywhere else, including in a string literal, MUST remain literal. In Markdown, escaped roles and roles in code examples remain literal under cite requirements.references.discovery. In a plain-text file, roles MUST count anywhere.

req requirements.references.builtin_definitions

Habeas MUST provide built-in definitions named habeas:<name>, available in every project without a declaration. Each built-in MUST have fixed text, which states its obligations and is documented in Habeas’s reference documentation, and MUST state which reference roles may use it. References MUST resolve built-in names alongside project definitions. So that every book stands alone, the book MUST render a reference to a built-in as a badge without a link whose hover text gives the built-in’s full text. Built-ins themselves MUST NOT require or permit definition evidence files and MUST NOT appear as definitions in the requirements index, habeas status, or the missing-evidence check of cite requirements.ci.coverage. Per-source citation reviews under cite requirements.references.citation_review MAY be required for references to a built-in. A project definition MUST NOT use a full name beginning with habeas:; validation MUST report one, and the : character already makes such names invalid under cite requirements.ci.identifiers. Validation MUST report a reference to a built-in in a role the built-in does not permit, or that breaks the built-in’s stated form.

req requirements.references.citation_review

Every source item outside the book that carries at least one {cite} reference other than a citation of habeas:util under cite requirements.references.util MUST have a citation review: an assessment of that item’s citations, recorded at evidence/citations/<file>/<selector>.json, where <file> is the item’s project-relative path, <selector> is its outline selector with every / and % percent-encoded, and the root node uses _root. The review MUST use the prompt defined by cite requirements.authoring.citation_prompt. For citations of project requirements and examples, the reviewer MUST assess whether the item should be re-checked or kept in sync when the cited definition changes, and whether the reference procedure of cite requirements.references.procedure calls for {impl} or {test} instead. For citations of built-ins, the reviewer MUST check the permitted reference roles and forms and any citation-review criteria stated in the built-in’s fixed text, using the item’s source and commentary. A permitted citation role alone MUST NOT suffice when the fixed text states additional criteria. Mandatory inputs, under cite requirements.authoring.mandatory_inputs, MUST be the item’s outline node, each cited declaration or built-in text, and the citations’ commentary. The record MUST contain the item’s file and selector, its citations by role, name, and commentary, determination, rationale, and inputs, with determinations under cite requirements.ci.outcomes. Validation MUST require a current, accepted review for every such item and report stale, missing, or orphaned reviews; a review MUST become stale when the item’s hash, a cited declaration, or its citations or their commentary change. Authoring with --all MUST include citation reviews, and habeas author citations:<file>#<selector> MUST author the review of the one item it names, under cite requirements.authoring.refresh, where omitting #<selector> names the file’s root node. A citation in a requirement or example declaration is reviewed as part of that definition’s own assessment instead.

req requirements.references.anchors

A {req} declaration MAY list :impl: and :test: options, and an {example} declaration MAY list :test: options, immediately after its opening fence and before its body, one per option line, naming a project file path or path#selector for one outline node under cite requirements.references.outline_selectors. Each anchor MUST be an {impl} or {test} edge, under cite requirements.references.roles, from the definition to the anchored file or node, for files that cannot or should not carry a reference themselves. Paths MUST follow the path rules in cite requirements.ci.schema. Option lines MUST NOT form part of the definition’s text for evidence comparison or for requirements inputs, and MUST NOT render as body text.

For each :test: anchor, the harness MUST include the selected file or node’s source text in the initial model request under cite requirements.authoring.mandatory_inputs and MUST record that selection as an evidence input under cite requirements.references.evidence_coverage, so changing that source makes the evidence stale. A :impl: anchor alone MUST NOT require an input selecting its source. A path or selector that does not resolve to a readable, permitted file or node MUST be a validation error naming the definition and the path; authoring MUST report it before inference. Any other option line in a {req} or {example} declaration MUST be a validation error.

req requirements.references.anchors.guidance

Agents SHOULD NOT anchor a file under cite requirements.references.anchors when a more precise reference is available, such as a reference attached to the Rust item that implements or tests the definition. Habeas’s bundled agent skills MUST give this direction.

req requirements.references.book_badges

In a book chapter, each valid {impl}, {cite}, or {test} reference, inline or fenced, MUST render as a Shields.io static badge image with meaningful alt text that displays its role and full name and links to the badge at the corresponding {req} or {example} definition. Links MUST work across chapters, including nested chapters. A fenced reference MUST render its badge followed by its body as Markdown. Each fenced {req} or {example} directive MUST render as a Shields.io definition badge image identifying its kind; text outside a directive MUST remain literal. Badge text MUST remain legible regardless of whether its link has been visited. A badge link MUST show a visible indicator when it has keyboard focus and MAY brighten on hover. Badges MAY be laid out inline with the surrounding text, a fenced reference’s badge and body MAY be visually set apart from the surrounding text as one block, and a built-in’s unlinked badge MAY show a help cursor to signal its hover text. These badges use the syntax defined by cite requirements.references.roles.

req requirements.references.evidence_coverage

For every {test} reference in a project source file, including one in a requirement or example declaration, the evidence file for the referenced requirement or example MUST contain an input whose resolved source ranges cover the reference’s file and line. An {impl}, {cite}, or {fixme} reference alone MUST NOT require an input selecting its source. {impl} and {cite} sources remain discoverable through cite requirements.authoring.reference_index; {fixme} acknowledgments are supplied under cite requirements.authoring.fixme_inputs and tracked by cite requirements.ci.reference_set. Habeas MUST report every uncovered reference requiring coverage with its role, full name, source file, and line number.

req requirements.references.rust_item_coverage

During repository validation, Habeas MUST parse every first-party Rust source file: every .rs file among the sources reference discovery considers under cite requirements.references.discovery, except those under the project-root vendor directory. Each explicitly declared function or method, including trait methods and test helpers, and each struct, enum, and union is an item that can be covered. An item is covered when it has a valid {impl}, {cite}, or {test} reference to a defined requirement or named example, or a valid citation of the built-in habeas:util under cite requirements.references.util, in a Rust comment attached to it or within its body; or when its outline node, or an outline node containing it, is recorded with its current hash as an outline input of an evidence record, a citation review, or a site review. Outline inputs recorded from selected search snippets under cite requirements.authoring.finish_search.inputs MUST count alongside mandatory inputs and additional reads. Comments belong to items under cite requirements.references.outline_comments; a comment before a field, variant, or attribute inside an item belongs to that item. A named example MUST reference a requirement under cite requirements.examples.definition. A reference in a string literal, on an enclosing module or impl block, or only in an evidence input MUST NOT count for the items it encloses. Habeas MUST report a Rust parse failure instead of silently skipping the file. Only cite requirements.references.coverage.tests and cite requirements.references.coverage.examples make an uncovered item a validation error; other items without recent coverage are warned about under cite requirements.references.coverage.report.

req requirements.references.coverage.tests

Every Rust function carrying a test attribute, #[test] or an attribute whose path ends in test such as #[tokio::test], including those in Cargo integration-test targets, MUST carry a {test} reference to a requirement or named example under cite requirements.references.roles, in a comment attached to it or within its body. A test function without one MUST be a validation error naming its file, line, and name.

req requirements.references.coverage.examples

Every Cargo example target, each .rs file directly under the package’s examples/ directory, each examples/<name>/main.rs, and each [[example]] path in Cargo.toml, MUST {cite} a named example of the book under cite requirements.examples.definition in a comment in that file. An example target without one MUST be a validation error naming the file.

req requirements.references.coverage.history

impl requirements.configuration.feature_sections An item has recent coverage when it has a reference that covers it under cite requirements.references.rust_item_coverage, or when its outline node, or an outline node containing it, is named by file and selector in the inputs of any version of an existing evidence record, citation review, or site review in its coverage window. A file’s coverage window MUST be its current contents on disk, committed or not, together with its contents in each of the last N commits in its Git history that changed it, read through a Git library rather than by running git. A recorded hash MUST NOT matter here: an earlier version names the node, whatever its code was then. N MUST be the workspace [coverage] setting reauthorings, a positive integer, and 3 when it is not set. When the history is unavailable, such as outside Git or in a shallow clone missing those commits, the window MUST be the commits that are available, and habeas status --coverage MUST say that coverage history is incomplete.

req requirements.references.coverage.report

habeas status, and habeas author after it finishes, MUST report the number of nodes without recent coverage under cite requirements.references.coverage.history, except items inside a module named tests, using the following summary:

N nodes have coverage warnings. Use `status --coverage` to see them.

The summary MUST report zero when no nodes have warnings. Default output MUST NOT list individual coverage warnings or coverage-history details, including with status --all or status --verbose. habeas status --coverage MUST list every warning, naming its file, line, kind, and name, and report incomplete coverage history when applicable. A warning MUST NOT fail validation, and repository validation MUST NOT read Git history.

example requirements.references.coverage.reauthored

Function parse has no reference, and the evidence of requirements.cli.check read it. The requirement is re-authored and committed twice, and neither new record reads parse. With the default window of 3, the record’s third most recent version still names parse, so habeas status --coverage does not warn. After a third such commit, no version in the window names it, and habeas status --coverage warns about parse. test requirements.references.coverage.history test requirements.references.coverage.report

example requirements.references.coverage.deleted_requirement

Function render is read only by the evidence of requirements.cli.render. The requirement and its evidence file are deleted. Deleted files have no coverage window, so habeas status --coverage warns about render at once, before any further commit. test requirements.references.coverage.history

example requirements.references.coverage.new_function

A new function helper has no reference, and no evidence record has ever read it. habeas status --coverage warns about it at once; nothing in any window names it. test requirements.references.coverage.report

example requirements.references.coverage.uncommitted

The evidence of requirements.cli.check read parse. The requirement is re-authored but not yet committed, and the new record does not read parse. The committed versions in the window still name it, so habeas status --coverage does not warn. If the new record had read parse, its contents on disk would cover it even before the commit. test requirements.references.coverage.history

example requirements.references.coverage.shallow_clone

In a shallow clone with no history beyond the last commit, each window holds only the files’ contents on disk and in that commit. habeas status --coverage says that coverage history is incomplete and warns about items those contents do not cover. test requirements.references.coverage.history

example requirements.references.coverage.test_module

A helper function inside mod tests has no reference and is read by no record. habeas status --coverage does not warn about it. A #[test] function in the same module without a {test} reference is still a validation error. test requirements.references.coverage.report test requirements.references.coverage.tests

req requirements.references.definition_globs

A definition glob MUST match a complete full name. * MUST match zero or more characters, including dots; all other valid name characters MUST match literally. An empty glob MUST be invalid. Every definition selection MUST use this matching rule, including requirements evidence inputs, CLI definition filters, and the authoring references tool, and MUST match against both requirements and named examples.

definition selection

A full requirement or example name, or a definition glob, identifying the requirements and named examples it matches under cite requirements.references.definition_globs. A name without * selects exactly that definition.

req requirements.references.rust_item_selectors

The Rust outline profile under cite requirements.references.outlines MUST identify items by segments describing their syntactic ancestry within the file, such as fn[run], struct[Packet], and mod[local]/fn[run], and MUST NOT resolve Rust modules across files. Functions, methods, structs, enums, unions, traits, impls, modules, macros, constants, statics, type aliases, and extern blocks MUST be outline nodes. Impl segments MUST be named by their syntactic self type and optional trait path, as impl[Thing] and impl[Thing/Trait]. use declarations and other items without a suitable name MUST be anonymous. Selector spelling MUST be documented.

Outlines

req requirements.references.outlines

Habeas MUST parse Rust, Python, TypeScript, CSS, Markdown, TOML, and YAML sources with pinned tree-sitter grammars, selected by file extension compared case-insensitively. A source with any syntax error MUST fail to parse, reporting the line of its first error. Every other text file MUST use a plain-text profile in which each line that is not blank is an anonymous outline node of kind line. Each supported language MUST have an outline profile that maps grammar node kinds to short outline kind names and, for each mapped kind, states whether a node is named, and by which fields or children, or anonymous. Only mapped kinds MUST appear in the outline; other nodes MUST be transparent, so their outline descendants appear under the nearest outline ancestor. A profile MAY attach grammar siblings to an outline node, such as Rust attributes and doc comments preceding an item, so the outline tree need not match the grammar tree exactly; attached siblings are part of that node for its line range and hash. Every file’s outline MUST have a root node for the whole file, independent of language. Source in no other outline node, such as top-level statements no profile maps, MUST belong to the root node; profiles MUST NOT invent fallback kinds for it. Comments MUST NOT be outline nodes. Profiles MUST be documented. Upgrading a grammar or profile MAY change outlines and MUST be treated as a deliberate change.

req requirements.references.outline_selectors

An outline selector MUST be a /-separated path of segments from the file’s root node to an outline node; the empty selector MUST select the root node. A named node’s segment MUST be kind[name]. An anonymous node’s segment MUST be kind@hash, where hash is the first twelve hexadecimal digits of its identity hash under cite requirements.references.structural_hash. Siblings whose segments would otherwise be identical MUST be disambiguated by #N, their one-based position among those siblings in source order, except line nodes: identical lines are interchangeable, so a line selector MUST resolve when any line with that content exists in the file. In names, %, [, ], /, #, @, and whitespace MUST be percent-encoded as UTF-8 bytes, so selectors are reversible. Line numbers MUST NOT form part of a selector.

req requirements.references.structural_hash

A node’s structural hash MUST be the SHA-256 digest of an unambiguous encoding of its outline-relevant structure, including siblings its profile attaches to it: the kinds of its named grammar nodes and, in source order, its text pieces. A text piece MUST be the text of a leaf token, or text inside a node that no child token covers. Each text piece MUST be hashed as its ordered list of words, where words are separated by whitespace, the whitespace itself, including leading and trailing whitespace, is never hashed, and each word is encoded separately, so ab cd and abcd differ. The same rule MUST apply in every language. Comments MUST be excluded, except comment kinds the profile includes; the Rust profile MUST include doc comments. For an included comment, only its text and its profile’s comment group MUST be hashed, not its delimiter tokens such as //, ///, //!, /*, */, or a leading *; the Rust profile’s groups are inner and outer doc comments. The words of consecutive included comments of one group MUST be hashed as one ordered list, so reflowing them across more or fewer lines or comments does not change the hash, while moving text between groups does. A line node’s hash MUST be computed by the same word rule over the line’s text. A node’s identity hash MUST be computed the same way but MUST also exclude its outline descendants and their attached siblings, so editing a descendant does not change its ancestors’ selectors.

req requirements.references.outline_comments

Each documented profile defines which grammar nodes are comments; the Markdown profile’s comments are HTML comment blocks, so an inline HTML comment within a paragraph is text of its section. In every supported language, comments on consecutive lines with no other source between them MUST form one comment run. A comment that follows other source on the same line, including another comment, MUST form a run by itself and MUST belong to the innermost outline node containing that line. Any other run MUST belong to the next outline node that starts after it within the smallest node containing it; when that container has no such node, the run MUST belong to the container, which is the root node at top level. A profile MAY bind a comment kind to its container instead: such a run MUST belong to the smallest node containing it. The Rust profile MUST bind inner doc comments (//!, /*!) to their container, so a file-level inner doc comment belongs to the root node. A reference in a comment MUST count for the node its run belongs to under cite requirements.references.rust_item_coverage and cite requirements.references.authoring_inputs.

req requirements.references.markdown_literals

In Markdown, escaped roles and role-looking text in inline code, fenced code, or raw HTML MUST remain literal and MUST NOT count as references. Raw HTML means an HTML block, an HTML comment, or an inline HTML tag including its attributes; text between inline tags is ordinary Markdown. A {req} directive inside a fenced code example and a legacy inline {req} role MUST NOT define a requirement.

req requirements.references.safe_badges

The book preprocessor MUST escape requirement names and link targets when inserting badge HTML. It MUST encode badge label and message text in Shields.io URL path components so punctuation cannot change the badge URL structure.

example requirements.references.selector_nested

In src/lib.rs, fn outer() { fn inner() {} } gives the selectors fn[outer] and fn[outer]/fn[inner]. cite requirements.references.rust_item_selectors

example requirements.references.selector_impl_and_trait

In src/lib.rs, a method run in impl Thing has selector impl[Thing]/fn[run]; a method run in impl Trait for Thing has selector impl[Thing/Trait]/fn[run]; and a method read declared in trait Read has selector trait[Read]/fn[read]. cite requirements.references.rust_item_selectors

example requirements.references.selector_inline_and_foreign

A function run inside an inline mod local { ... } in src/lib.rs has selector mod[local]/fn[run]. A function defined in a separate src/local.rs file has a selector within that file, without reconstructing the path of a mod local; declaration elsewhere. A foreign function puts in an extern "C" block has selector extern[C]/fn[puts]. cite requirements.references.rust_item_selectors

example requirements.references.selector_duplicate_names

Two sibling declarations named run in one file, guarded by different #[cfg] attributes, have selectors fn[run]#1 and fn[run]#2 in source order. Their source line numbers are not part of either selector. cite requirements.references.rust_item_selectors

example requirements.references.selector_use

For consecutive sibling declarations use alpha::A; and use beta::B;, each selector is an anonymous use@<hash> segment derived from that declaration’s structure. Inserting a declaration before them leaves both selectors unchanged; changing an import target gives that declaration a new selector. A named declaration such as struct Packet; instead has selector struct[Packet]. cite requirements.references.rust_item_selectors cite requirements.references.outline_selectors

example requirements.references.selector_raw_lines

For a function preceded by a doc comment, an attribute, and an attached citation comment, an outline input’s displayed range starts at the earliest attached line and ends at the function’s final line. Inserting lines before the function changes the displayed range without changing the input. Editing the citation comment leaves its hash unchanged; editing the doc comment changes it. cite requirements.ci.outline_inputs cite requirements.references.structural_hash

example requirements.references.definition_glob_cases

Given a requirement foo.a.bar and a named example foo.a.b.bar, foo.*.bar matches both, in full-name order: foo.a.b.bar before foo.a.bar. A requirements input stores both full names and their complete raw fenced declarations. Adding another matching definition invalidates the existing input. cite requirements.references.definition_globs cite requirements.ci.requirements_inputs

Distributed requirements

req requirements.references.distributed

A requirement MAY be distributed: it states obligations that each of many sites in the sources must uphold on its own, such as a convention every validation function follows, and MAY also state obligations that particular code carries out, which that code implements with {impl}. A {req} body declares a distributed requirement by containing one or more nested query directives: :::{sites} <name> for a site query, which finds the places the obligation applies, or :::{violations} <name> for a violation query, which finds constructs likely to break it. A requirement with a violation query MUST also have a site query. Query names MUST be single identifier segments under cite requirements.ci.identifiers, unique within the requirement. A query directive outside a {req} body MUST be a validation error. Each query body MUST be one fenced yaml code block containing a mapping with only these keys:

  • language, required: the name of an outline profile with a grammar under cite requirements.references.outlines: rust, python, typescript, tsx, css, markdown, toml, or yaml.
  • paths, optional: project-relative files or directories. Only sources at or under one of them are searched; without it, every source of the language is.
  • exclude, optional: project-relative files or directories whose sources are not searched, even under paths.
  • rule, required, with optional utils and constraints: an ast-grep rule core in the syntax of Habeas’s pinned ast-grep-config version, matched against the language’s pinned grammar.
  • within, required for violation queries and not allowed for site queries: the name of a site query in the same requirement.
  • match and no_match, required: nonempty lists of source snippets in the query’s language. Each match snippet MUST contain at least one match of the query, and each no_match snippet none, where a violation query counts only matches inside a site of its within query in the same snippet.

Validation MUST report a query whose body is not such a mapping, whose rule does not compile, whose within names no site query of the requirement, a violation query without within, or one of whose snippets fails to parse or has the wrong match result, and a site query that matches nothing in the project. Queries MUST search exactly the sources reference discovery considers under cite requirements.references.discovery, in their original text.

A match’s site MUST be the innermost outline node, under cite requirements.references.outlines, whose range contains the match; for a violation query, it MUST instead be the innermost site of its within query that contains the match, and a match inside none of that query’s sites MUST be discarded. A requirement’s sites MUST be the distinct sites of all its queries’ matches. Each site MUST have a site review under cite requirements.references.site_review, and needs no reference to the requirement; being a site MUST NOT count as a reference for cite requirements.references.rust_item_coverage, because a distributed requirement concerns a cross-cutting obligation, not why the item exists. Upgrading ast-grep-config MAY change matches and MUST be treated as a deliberate change. The book MUST render each query directive as a badge naming its kind and name, followed by its code block.

req requirements.references.site_review

Every site of a distributed requirement under cite requirements.references.distributed MUST have a site review: an assessment of whether that site upholds the requirement, recorded at evidence/sites/<full-name>/<file>/<selector>.json, where <file> and <selector> are encoded as under cite requirements.references.citation_review. The review MUST use the prompt defined by cite requirements.authoring.site_prompt. Mandatory inputs, under cite requirements.authoring.mandatory_inputs, MUST be the site’s outline node, the requirement’s complete declaration, and each declaration the requirement cites. The record MUST contain the requirement’s full name, the site’s file and selector, queries, the sorted names of the queries with a match at the site, applies, determination, rationale, and inputs, with determinations under cite requirements.ci.outcomes. applies MUST be a Boolean recording whether the requirement applies to the site. A site to which the requirement does not apply MUST be judged true, and the rationale MUST explain why it does not apply. habeas info MUST report, for each selected distributed requirement, how many of its sites the requirement does not apply to.

Validation MUST require a current, accepted review for every site, MUST report a false review with its rationale, and MUST report stale, missing, or orphaned reviews; a review is orphaned when its file and selector no longer name a site of the requirement. A {fixme} naming the requirement inside a site acknowledges a gap at that site only: it MUST be an input to that site’s review and MUST NOT contribute to the requirement’s own review, coverage, or reference set. A review MUST become stale when the site’s hash, the requirement’s declaration, a cited declaration, its queries, or the {fixme} references naming the requirement inside the site, with the words of their bodies, change. Each site review’s determination MUST be checked on its own, independently of the requirement’s evidence. Authoring with --all MUST include site reviews, habeas author sites:<full-name> MUST author the site reviews of the named requirement, and habeas author sites:<full-name>/<file>#<selector> MUST author the review of the one site it names, under cite requirements.authoring.refresh, where omitting #<selector> names the file’s root node. habeas status MUST report missing, stale, invalid, and false site reviews with their requirement, file, and selector, and habeas info MUST list each selected requirement’s sites with their determinations.

References as authoring inputs

req requirements.references.authoring_inputs

When authoring evidence, the edges defined by cite requirements.references.roles MUST determine the reference contributions to the mandatory input set defined by cite requirements.authoring.mandatory_inputs. A {cite} made by the subject MUST contribute the cited definition’s complete fenced declaration. A requirement or example declaration that references the subject with {impl} or {test} MUST contribute that complete declaration. For sources outside such declarations, an {impl} reference or :impl: anchor alone MUST NOT contribute source text; those sources MUST remain discoverable under cite requirements.authoring.reference_index and MAY be requested under cite requirements.authoring.source_tools. Sources with only edges into the subject MUST NOT contribute and remain discoverable under cite requirements.authoring.reference_index. A :test: anchor under cite requirements.references.anchors MUST contribute the complete anchored file, or for a path#selector anchor the anchored node. An in-source {test} reference to the subject MUST contribute the source containing it: for a reference in a supported language, the smallest enclosing outline node under cite requirements.references.outline_comments; for a reference in a Markdown requirement, example, or terminology declaration, that complete declaration; for other references, the complete containing source file. Literal references, evidence copies, and generated output MUST remain excluded under the existing reference-discovery rules.

An in-source {fixme} reference alone MUST NOT contribute the containing source to the mandatory input set. Its acknowledgment MUST instead be supplied under cite requirements.authoring.fixme_inputs.

These contribution rules MUST apply only to the assessed subject’s direct references. Including another declaration or source MUST NOT by itself recursively expand that source’s own edges. Reference links MUST NOT be described as proof that all substantively relevant sources have been found.