requirements.authoring.testing_bar
Requirements index · View definition
Requirement
The requirement task MUST continue with these criteria, which set when a requirement’s obligations need tests:
Testing criteria: - Every obligation assessed here, and every boundary or failure case the text names for that obligation, needs a test that exercises the required behavior and asserts its outcome. - Distinct modes and scenarios the text governs, such as verbose and default modes, each need a relevant test. Implementation branches for cases the text does not distinguish need no test of their own. - An untested obligation is a gap unless the code carrying it out has no conditional and no transformation of its own, such as passing a value through unchanged, or running it would need network services, real elapsed time, or process-wide state such as environment variables or the current directory, and no test in the project sets that up; say which, and why. Request source if needed to establish a claimed exemption. Files and directories a test can create do not qualify. - That exemption does not cover an obligation that itself states that a value stays unchanged, distinct, or present; such an obligation needs a test.
Rationale
Obligation. requirements.authoring.testing_bar has one obligation. For a requirement subject, the requirement task must continue with the quoted Testing criteria: text.
Implementation. src/authoring/mod.rs#fn[subject_task] builds the requirement-subject task as requirement_task + “\n” + testing_bar. Both come from approved_text, which reads the text blocks of the approved requirements in md/requirements/authoring.md. Example subjects get only example_task.
Test coverage. src/authoring/mod.rs#mod[tests]/fn[initial_prompt_carries_the_review_criteria] is marked {test} for this requirement. It does the following:
- It builds the initial prompt for the requirement subject
requirements.ready. - It asserts the prompt contains
approved_text("testing_bar", 0)and the literal “Testing criteria:”. - It asserts the prompt contains the exact concatenation
requirement_task+ “\n” +testing_bar. This enforces that the criteria continue the requirement task, not merely appear somewhere in the prompt. - It switches to an example subject (
requirements.case) and asserts the testing bar and “Testing criteria:” are absent. This checks the boundary where the criteria must not apply.
approved_text reads the text from the book chapter, which is the same source the requirement text comes from. The expected value therefore matches the requirement’s quoted block. A wrong, truncated or reordered criteria text would fail these assertions.
Other test. a_distributed_requirement_task_continues_with_the_filled_distributed_task also asserts that the system prompt contains requirement_task, testing_bar and “# How to judge” in sequence. It has no {test} reference to testing_bar. The requirement text does not distinguish distributed requirements, so that case is the same branch (DefinitionKind::Requirement) the marked test already covers. This is not an adequacy gap, and the unmarked incidental assertion does not change the judgment.
Exemptions and acknowledgments. No exemption was needed, and no acknowledgments apply.
Inputs
Implementation
Input 4: outline src/authoring/mod.rs fn[subject_task]
- File:
src/authoring/mod.rs - Selector:
fn[subject_task] - Kind:
fn src/authoring/mod.rs:802–819
/// The task text of a requirement or example review.
// {impl}`requirements.authoring.initial_prompt`
// {impl}`requirements.authoring.requirement_task`
// {impl}`requirements.authoring.testing_bar`
// {impl}`requirements.authoring.example_task`
fn subject_task(kind: &DefinitionKind) -> String {
match kind {
DefinitionKind::Requirement => format!(
"{}\n{}",
approved_text("requirement_task", 0),
approved_text("testing_bar", 0)
),
// Terms are never assessment subjects.
DefinitionKind::Example | DefinitionKind::Term => {
approved_text("example_task", 0).to_owned()
}
}
}
Tests
Input 2: outline src/authoring/mod.rs mod[tests]/fn[initial_prompt_carries_the_review_criteria]
- File:
src/authoring/mod.rs - Selector:
mod[tests]/fn[initial_prompt_carries_the_review_criteria] - Kind:
fn src/authoring/mod.rs:2138–2210
// {test}`requirements.ci.review_criteria`
// {test}`requirements.authoring.requirement_task`
// {test}`requirements.authoring.testing_bar`
// {test}`requirements.authoring.example_task`
// {test}`requirements.authoring.judgment_rules`
// {test}`requirements.authoring.habeas_background`
// {test}`requirements.examples.evidence`
// {test}`requirements.examples.definition`
#[test]
fn initial_prompt_carries_the_review_criteria() {
let project = inputs::tests::project();
let sources = AssessmentSources::prepare(project.path(), "requirements.ready").unwrap();
let prompt = initial_prompt(&sources).unwrap().joined();
for criterion in [
"Subject: requirement requirements.ready\nJudge against: the subject's text.",
approved_text("habeas_background", 0),
approved_text("habeas_background", 1),
approved_text("judgment_rules", 0),
approved_text("requirement_task", 0),
approved_text("testing_bar", 0),
"Derive testable obligations and expected outcomes from each MUST, MUST NOT,",
"Testing criteria:",
"The project MUST be ready.",
] {
assert!(
prompt.contains(criterion),
"missing {criterion:?} in:\n{prompt}"
);
}
// The testing criteria follow the requirement task.
assert!(prompt.contains(&format!(
"{}\n{}",
approved_text("requirement_task", 0),
approved_text("testing_bar", 0)
)));
assert!(!prompt.contains(approved_text("example_task", 0)));
assert!(!prompt.contains("This subject is a distributed requirement."));
assert!(!prompt.contains(distributed_background()));
assert!(!prompt.contains("{{"), "{prompt}");
// An example's task replaces the requirement task.
let requirements = project.path().join("md/requirements.md");
let mut book = fs::read_to_string(&requirements).unwrap();
let cite = "{cite}`requirements.ready`";
book.push_str(&format!(
"\n:::{{example}} case\nA ready case. {cite}\n:::\n"
));
fs::write(&requirements, book).unwrap();
let sources = AssessmentSources::prepare(project.path(), "requirements.case").unwrap();
let prompt = initial_prompt(&sources).unwrap().joined();
assert!(
prompt.contains("Subject: example requirements.case"),
"{prompt}"
);
assert!(
prompt.contains(approved_text("example_task", 0)),
"{prompt}"
);
assert!(
prompt.contains("First check that it describes a concrete case\nwith expected behavior; a missing concrete case or expected behavior is a gap."),
"{prompt}"
);
assert!(
!prompt.contains(approved_text("requirement_task", 0)),
"{prompt}"
);
assert!(
!prompt.contains(approved_text("testing_bar", 0)),
"{prompt}"
);
assert!(!prompt.contains("Testing criteria:"), "{prompt}");
assert!(!prompt.contains("{{"), "{prompt}");
}
Other sources
Input 1: requirements selection requirements.authoring.testing_bar
requirements.authoring.testing_bar:md/requirements/authoring.md:1485–1507
:::{req} testing_bar
The requirement task MUST continue with these criteria, which set when a
requirement's obligations need tests:
```text
Testing criteria:
- Every obligation assessed here, and every boundary or failure case the text
names for that obligation, needs
a test that exercises the required behavior and asserts its outcome.
- Distinct modes and scenarios the text governs, such as verbose and
default modes, each need a relevant test. Implementation branches for
cases the text does not distinguish need no test of their own.
- An untested obligation is a gap unless the code carrying it out has no
conditional and no transformation of its own, such as passing a value
through unchanged, or running it would need network services, real elapsed
time, or process-wide state such as environment variables or the current
directory, and no test in the project sets that up; say which, and why.
Request source if needed to establish a claimed exemption. Files and
directories a test can create do not qualify.
- That exemption does not cover an obligation that itself states that a value
stays unchanged, distinct, or present; such an obligation needs a test.
```
:::
Input 3: 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 5: requirements selection requirements.authoring.requirement_task
requirements.authoring.requirement_task:md/requirements/authoring.md:1441–1483
:::{req} requirement_task
The requirement task of {cite}`requirements.authoring.initial_prompt` MUST be
this text, the steps a requirement's review follows to assess test adequacy:
```text
1. Derive testable obligations and expected outcomes from each MUST, MUST NOT,
and SHOULD clause. Separate independent conditions and properties while
preserving alternatives the text permits. Identify ambiguities separately.
2. Identify relevant input classes, boundaries, condition combinations, and
state transitions from the requirement. Use only distinctions that affect
an obligation; do not invent required behavior for unspecified inputs.
3. Read the supplied tests and request helpers or fixtures needed to understand
their inputs and assertions. Use targeted discovery to look for relevant
tests before reporting a missing scenario.
4. Map each obligation assessed here to concrete test scenarios and assertions
in your rationale. Identify obligations delegated to a refining requirement
or a distributed site's review, and any established testing exemptions,
separately. Check both whether the expected result is correct under the
requirement and whether the assertions enforce it. Execution without a
relevant assertion does not establish adequacy; assertions in helpers,
snapshots, and parameterized or property tests can do so.
5. For each proposed adequacy gap, describe plausible requirement-violating
behavior that the reviewed tests would accept. Cite the requirement clause
and explain why the tested inputs or assertions would miss it. A wrong
expected result is a gap too: explain how the assertion contradicts the
requirement rather than claiming it proves a missing scenario.
Explain the requirement-relevant distinction the counterexample exposes.
Another untested value in an already represented input class is not a gap
without explaining why it could expose different required behavior.
6. Check whether another reviewed test or helper already rules out that
behavior. Report unresolved questions separately from established gaps.
If information needed to decide adequacy remains unavailable, choose false
and explain what is missing without inventing a behavioral gap.
A relevant test without a {test} reference to the subject is a marking gap;
a helper reached from a marked test needs no reference of its own. Do not
confuse marking gaps with inadequate assertions.
7. Request implementation source only to resolve a specific question, stating
that question in your rationale. Derive expected behavior from the
requirement, not the implementation. Do not assess implementation
correctness, implementation reachability, or unspecified implementation
behavior as additional tasks.
```
:::