requirements.authoring.distributed_task
Requirements index · View definition
Requirement
For a distributed requirement under
, the subject message of
MUST include this text, which continues the requirement task to assess the requirement’s queries:
{{distributed_background}} Each query is an ast-grep rule with match and no_match snippets. This subject is a distributed requirement. Its sites need no {impl} reference and each has its own review, so do not vet them. Also assess the requirement and its queries: 8. Each obligation must be either one that each site upholds on its own, or one that particular code carries out, whose tests you assess under 1 to 7 and the testing criteria. An obligation that neither covers is a gap. 9. The site queries must select every place the text's description of a site covers, and no place outside the requirement's stated scope. Run each site query once with ast_grep by its name, <subject>/<query>, scan its matches, and search briefly for the construct the text describes to find places the queries miss. Obligations that decide which places are sites, such as how a variable is named, are checked by this search. 10. Judge whether each query's conditions are adequately tested by its snippets, as you would judge tests of code: its match snippets should show what it selects, and its no_match snippets nearby code it must not select. A condition without a snippet of its own is not by itself a gap. This applies to violation queries too. Queries are heuristics, so judge them by a preponderance of the evidence: is it more likely than not that the site queries find the places the requirement applies? A specific place in the sources that a site query misses, or selects outside the requirement's scope, is a gap; a form that does not occur in the sources is not. A violation query that misses constructs is not a gap; note what it misses.
Rationale
Obligation. requirements.authoring.distributed_task has one obligation. For a distributed requirement, the subject message of requirements.authoring.initial_prompt MUST include the distributed-task text, with {{distributed_background}} filled in. The subject is not itself a distributed requirement, since it has no sites or violations queries. Items 8–10 of the quoted prompt text are therefore instructions for a future assessor. They are not obligations on this requirement’s tests.
Test. src/authoring/mod.rs#mod[tests]/fn[a_distributed_requirement_task_continues_with_the_filled_distributed_task] is marked {test} for the subject.
- It builds a project whose requirement
requirements.ruleis distributed, usingcrate::sites::tests::RULEandSOURCE. It then callsinitial_prompton that project. - It computes the expected text independently.
approved_text("distributed_task", 0)reads the first text block of the requirement frommd/requirements/authoring.md, andfillsubstitutesdistributed_background()for the placeholder. I read these helpers.approved_textlocates the{req}block in the book andfillreplaces placeholders in a single pass. - It asserts that the filled task starts with the distributed background. This shows the placeholder was substituted.
- It asserts that
prompt.subjectcontains the filled task at the exact position the book prescribes. That position is after the “Judge against” line and before “# Acknowledgments” and “# Mandatory inputs”. - It asserts that
prompt.systemdoes not contain the task. The system prompt instead ends with the requirement task, the testing bar and “# How to judge”. - It asserts that the joined prompt has no leftover
{{placeholders. - It also checks that the verification prompt’s subject carries the task.
A wrong text, a missing background substitution, or placement in the system prompt would each fail an assertion. The test covers the requirement’s case.
Gaps. I found none. The “nothing for a non-distributed requirement” case belongs to requirements.authoring.initial_prompt and not to this requirement’s text.
Inputs
Tests
Input 4: outline src/authoring/mod.rs mod[tests]/fn[a_distributed_requirement_task_continues_with_the_filled_distributed_task]
- File:
src/authoring/mod.rs - Selector:
mod[tests]/fn[a_distributed_requirement_task_continues_with_the_filled_distributed_task] - Kind:
fn src/authoring/mod.rs:4418–4462
// {test}`requirements.authoring.distributed_task`
// {test}`requirements.authoring.habeas_background`
// {test}`requirements.authoring.initial_prompt`
// {test}`requirements.ci.review_criteria`
#[test]
fn a_distributed_requirement_task_continues_with_the_filled_distributed_task() {
let project =
crate::sites::tests::project(crate::sites::tests::RULE, crate::sites::tests::SOURCE);
let sources = AssessmentSources::prepare(project.path(), "requirements.rule").unwrap();
let prompt = initial_prompt(&sources).unwrap();
let task = fill(
approved_text("distributed_task", 0),
&[("distributed_background", distributed_background())],
);
assert!(task.starts_with(distributed_background()), "{task}");
// The requirement task stays in the system prompt; the distributed
// task follows the subject line in the subject message.
assert!(
prompt.system.contains(&format!(
"{}\n{}\n\n# How to judge",
approved_text("requirement_task", 0),
approved_text("testing_bar", 0)
)),
"{}",
prompt.system
);
assert!(!prompt.system.contains(&task), "{}", prompt.system);
assert!(
prompt.subject.contains(&format!(
"Judge against: the subject's text.\n\n{task}\n\n# Acknowledgments\n\n[]\n\n# Mandatory inputs"
)),
"{}",
prompt.subject
);
assert!(
prompt
.system
.contains(approved_text("habeas_background", 1))
);
assert!(!prompt.joined().contains("{{"), "{}", prompt.joined());
// The verifier's criteria carry the distributed task too.
let verifier = verification_prompt(&sources, &Judgment::False, "A gap.").unwrap();
assert!(verifier.subject.contains(&task), "{}", verifier.subject);
assert!(!verifier.system.contains(&task), "{}", verifier.system);
}
Referenced definitions
Input 2: requirements selection requirements.references.distributed
requirements.references.distributed:md/requirements/references.md:472–519
:::{req} 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.
:::
Input 3: requirements selection requirements.authoring.initial_prompt
requirements.authoring.initial_prompt:md/requirements/authoring.md:1349–1439
:::{req} initial_prompt
The initial request MUST provide the ten tool definitions above and the
following prompt, the first block as its system prompt and the second as its
subject message under {cite}`requirements.authoring.prompt_parts`. The harness MUST replace `{{subject_kind}}` with `requirement`
or `example`, `{{subject_name}}` with the full subject name,
`{{habeas_background}}`, `{{reference_roles}}`, and `{{distributed_background}}`
under {cite}`requirements.authoring.habeas_background`, `{{judgment_rules}}` under
{cite}`requirements.authoring.judgment_rules`, `{{acknowledgments}}` with the JSON
array of {cite}`requirements.authoring.fixme_inputs`, and `{{mandatory_inputs}}` with the
complete mandatory inputs as a JSON array using
the existing evidence-input formats. It MUST replace `{{subject_task}}`, for a requirement, with the text of
{cite}`requirements.authoring.requirement_task` followed by that of
{cite}`requirements.authoring.testing_bar`, and for an example, with the text of
{cite}`requirements.authoring.example_task`. It MUST replace
`{{distributed_task}}` with the filled text of
{cite}`requirements.authoring.distributed_task` for a distributed requirement,
and with nothing otherwise. The template MUST otherwise
be used as written. Their review guidance MUST follow
{impl}`requirements.ci.review_criteria`, {cite}`requirements.examples.evidence`,
and {cite}`requirements.ci.outcomes`.
```text
# Task
Assess whether a project's tests adequately check one {{subject_kind}}.
Your determination should be the one any careful reviewer would reach from the
same text and sources.
# Background: Habeas terms
{{habeas_background}}
{{reference_roles}}
# Your task
The mandatory inputs at the end contain the subject, the requirements and
examples it cites, the vocabulary definitions it uses, and the source text of
its {test} items and :test: anchors. Requirement and example declarations that
refine the subject through {impl} are also included. Implementation source is
not included merely because it carries an {impl} reference or :impl: anchor.
You can locate it with references and request it with habeas when needed.
Each {fixme} acknowledgment includes the state of the issues it names.
Cited requirements and examples are context: when the subject requires behavior
under or following a cited requirement, check that the subject's tests cover
applying it in the subject's case. Do not reassess the cited requirement's
implementation or tests.
When another requirement's text carries an {impl} reference to the subject,
assess only whether that text carries out the obligations it covers; do not
reassess its implementation or tests, and those obligations need no test here.
Judge test adequacy, rather than whether the current implementation is correct.
Derive expected behavior from the requirement and examples, even if you request
implementation source. A true judgment means the reviewed tests adequately
check the subject under the criteria below. You do not need to find a defect
when those criteria are met.
{{subject_task}}
# How to judge
{{judgment_rules}}
# Submitting
Choose true when your task finds no gap, {"FIXME": ["..."]} when every gap is
acknowledged, and false otherwise. You MUST end by calling submit_judgment
with determination and rationale until one submission is accepted.
A rejected submission does not complete the assessment. A judgment written in your
reply text is not accepted.
```
```text
# Subject
Subject: {{subject_kind}} {{subject_name}}
Judge against: the subject's text.
{{distributed_task}}
# Acknowledgments
{{acknowledgments}}
# Mandatory inputs
{{mandatory_inputs}}
```
:::
Other sources
Input 1: requirements selection requirements.authoring.distributed_task
requirements.authoring.distributed_task:md/requirements/authoring.md:1509–1546
:::{req} distributed_task
For a distributed requirement under {cite}`requirements.references.distributed`,
the subject message of {cite}`requirements.authoring.initial_prompt` MUST
include this text, which continues the requirement task to assess the
requirement's queries:
```text
{{distributed_background}} Each query is an ast-grep rule with match and
no_match snippets.
This subject is a distributed requirement. Its sites need no {impl} reference
and each has its own review, so do not vet them. Also assess the requirement and
its queries:
8. Each obligation must be either one that each site upholds on its own, or one
that particular code carries out, whose tests you assess under 1 to 7 and the
testing criteria. An obligation that
neither covers is a gap.
9. The site queries must select every place the text's description of a site
covers, and no place outside the requirement's stated scope. Run each site
query once with ast_grep by its name, <subject>/<query>, scan its matches,
and search briefly for the construct the text describes to find places the
queries miss. Obligations that decide which places are sites, such as how a
variable is named, are checked by this search.
10. Judge whether each query's conditions are adequately tested by its
snippets, as you would judge tests of code: its match snippets should show
what it selects, and its no_match snippets nearby code it must not select.
A condition without a snippet of its own is not by itself a gap. This
applies to violation queries too.
Queries are heuristics, so judge them by a preponderance of the evidence: is it
more likely than not that the site queries find the places the requirement
applies? A specific place in the sources that a site query misses, or selects
outside the requirement's scope, is a gap; a form that does not occur in the
sources is not. A violation query that misses constructs is not a gap; note what
it misses.
```
:::
Input 5: outline src/authoring/mod.rs fn[approved_text]
- File:
src/authoring/mod.rs - Selector:
fn[approved_text] - Kind:
fn src/authoring/mod.rs:729–744
/// The `index`th text block of approved requirement `name` in the authoring
/// chapter, which is the sole source of these instructions.
// {impl}`requirements.authoring.initial_prompt`
// {impl}`requirements.authoring.habeas_background`
// {impl}`requirements.authoring.judgment_rules`
fn approved_text(name: &str, index: usize) -> &'static str {
let chapter = include_str!("../../md/requirements/authoring.md");
let opening = format!(":::{{req}} {name}\n");
let start = chapter.find(&opening).expect("approved requirement") + opening.len();
let body = &chapter[start..];
let body = &body[..body.find("\n:::\n").expect("requirement closing fence")];
body.split("```text\n")
.nth(index + 1)
.and_then(|block| block.split("\n```").next())
.expect("approved text block")
}
Input 6: outline src/authoring/mod.rs fn[distributed_background]
- File:
src/authoring/mod.rs - Selector:
fn[distributed_background] - Kind:
fn src/authoring/mod.rs:770–775
/// The account of distributed requirements that the site prompt, the
/// distributed task, and a site review's verifier receive.
// {impl}`requirements.authoring.habeas_background`
fn distributed_background() -> &'static str {
approved_text("habeas_background", 2)
}
Input 7: outline src/authoring/mod.rs fn[fill]
- File:
src/authoring/mod.rs - Selector:
fn[fill] - Kind:
fn src/authoring/mod.rs:777–800
/// Replaces `{{name}}` placeholders in one pass, so substituted text that
/// itself contains a placeholder, such as a requirement quoting a template,
/// is left as written.
// {impl}`requirements.authoring.initial_prompt`
fn fill(template: &str, values: &[(&str, &str)]) -> String {
let mut result = String::with_capacity(template.len());
let mut rest = template;
'scan: while let Some(position) = rest.find("{{") {
result.push_str(&rest[..position]);
rest = &rest[position..];
for (name, value) in values {
let placeholder = format!("{{{{{name}}}}}");
if let Some(after) = rest.strip_prefix(placeholder.as_str()) {
result.push_str(value);
rest = after;
continue 'scan;
}
}
result.push_str("{{");
rest = &rest[2..];
}
result.push_str(rest);
result
}