requirements.cli.internal_detail_guidance
Requirements index · View definition
Requirement
Habeas’s bundled agent skills MUST direct agents to choose references by the procedure in
. For internal code, they MUST direct agents to state any invariant worth checking as an ordinary requirement and implement it, to cite the built-in
habeas:utilunderon an item that only serves other code, and to report to the user an item that does neither. They MUST NOT suggest grouping requirements, such as
internal.config_parsing, that state no checkable obligation.
Rationale
The reviewed tests adequately check every obligation in requirements.cli.internal_detail_guidance. The requirement’s subject is the text of the bundled skills, so the tests check it by asserting on that text. The helpers behind them (assert_text, assert_text_in_order, assert_phrases, section, bundled_skill, skill_md) do real contains or ordered find checks and panic when a phrase is missing. SKILLS lists all five skills.
Obligations and the tests that cover them:
- Choose references by the procedure.
tests/authoring_cli.rs#fn[bundled_skills_direct_the_reference_procedure_and_report_items_without_one]asserts, in order, the## Choosing referencessection ofhabeas-requirements. That section covers:- what carries out part of a requirement;
{test}first;{impl}for a root;{cite}for code to re-check. The same test asserts thathabeas-evidenceandhabeas-bootstrap-requirementsrefer to “Choosing references” in thehabeas-requirementsskill. It also asserts that no other skill restates the procedure text.fn[bundled_skills_mark_roots_and_handle_uncovered_items]adds the root and reach rules. It also asserts thathabeas-evidence’s “Uncovered Rust items” section routes items still uncovered afterhabeas author --allthrough that procedure.
- State an invariant worth checking as an ordinary requirement and implement it. The first test asserts “propose a requirement stating the invariant and
{impl}it” in the procedure section. It asserts “write a requirement for the invariant they check” inhabeas-bootstrap-requirements. - Cite
habeas:utilon an item that only serves other code. The first test asserts the{cite}habeas:util`` step, including the “code a library calls, such as a trait implementation it requires” clause. It also asserts the matchinghabeas-evidencetable row. The second test asserts thehabeas-evidencetable rows for a root and for an item that only serves other code. - Report an item that does neither. The first test asserts the sentence “needs a requirement or is not needed: report it to the user…” in the procedure section. It asserts the gap-list phrase in
habeas-bootstrap-requirements. The second test asserts thehabeas-evidencehandling of dead code: “report it to the user as dead code; don’t delete it unasked”. - MUST NOT suggest grouping requirements. The first test asserts “Don’t propose grouping requirements that state no checkable obligation” in the procedure section. For every skill in
SKILLS, it asserts the absence ofinternal.config_parsing,catch-allandinternal-detail requirement. It also asserts that no skill offers a waiver.
The absence check names specific strings, so a differently worded grouping suggestion would not trip it. The requirement text names only the internal.config_parsing form, and the positive “Don’t propose grouping…” assertion backs the check up. I don’t count this as a gap.
Both tests carry {test} references to the subject, so there is no marking gap. No {fixme} acknowledgments apply.
Inputs
Tests
Input 4: outline tests/authoring_cli.rs fn[bundled_skills_direct_the_reference_procedure_and_report_items_without_one]
- File:
tests/authoring_cli.rs - Selector:
fn[bundled_skills_direct_the_reference_procedure_and_report_items_without_one] - Kind:
fn tests/authoring_cli.rs:4557–4621
// {test}`requirements.cli.internal_detail_guidance`
// {test}`requirements.cli.behavior_review_guidance`
#[test]
fn bundled_skills_direct_the_reference_procedure_and_report_items_without_one() {
// habeas-requirements is the home of the reference procedure; its steps
// come in order.
assert_text_in_order(
"choosing references",
§ion(skill_md("habeas-requirements"), "## Choosing references"),
&[
"a type does when the requirement constrains its fields, variants, serialized form, or validation",
"For each requirement or example an item could reference",
"1. A test designed to verify it gets `{test}`",
"2. Otherwise a root gets `{impl}`",
"3. Otherwise, code that should be re-checked when the requirement changes gets `{cite}`",
"and it serves other code and carries out no requirement itself, it gets `` // {cite}`habeas:util` ``",
"That includes code a library calls, such as a trait implementation it requires",
"propose a requirement stating the invariant and `{impl}` it",
"Don't propose grouping requirements that state no checkable obligation",
"An item that neither carries out a requirement nor serves other code needs a requirement or is not needed: report it to the user with a proposed requirement, or as dead code if nothing reaches it. Don't delete it unasked",
],
);
// The other skills refer to the procedure rather than restate it.
assert_phrases(
"habeas-evidence",
&[
"choose references by \"Choosing references\" in the habeas-requirements skill",
"| the item only serves other code | add `` // {cite}`habeas:util` `` |",
],
);
assert_phrases(
"habeas-bootstrap-requirements",
&[
"\"Choosing references\" in the habeas-requirements skill",
"write a requirement for the invariant they check",
"An item that neither carries out a requirement nor serves other code goes on the gap list: it needs a requirement or is not needed",
],
);
for name in SKILLS
.into_iter()
.filter(|name| *name != "habeas-requirements")
{
assert!(
!bundled_skill(name).contains("fields, variants, serialized form, or validation"),
"{name} restates the reference procedure"
);
}
for name in SKILLS {
let text = bundled_skill(name);
for grouping in [
"internal.config_parsing",
"catch-all",
"internal-detail requirement",
] {
assert!(!text.contains(grouping), "{name} suggests {grouping:?}");
}
let reference_guidance = text.replace("no explanation can waive them", "");
for waiver in ["may waive", "can waive", "waiver applies", "is exempt"] {
assert!(
!reference_guidance.to_lowercase().contains(waiver),
"{name} offers a waiver"
);
}
}
}
Input 5: outline tests/authoring_cli.rs fn[bundled_skills_mark_roots_and_handle_uncovered_items]
- File:
tests/authoring_cli.rs - Selector:
fn[bundled_skills_mark_roots_and_handle_uncovered_items] - Kind:
fn tests/authoring_cli.rs:4722–4784
// {test}`requirements.cli.behavior_review_guidance`
// {test}`requirements.cli.internal_detail_guidance`
#[test]
fn bundled_skills_mark_roots_and_handle_uncovered_items() {
const ROOT: &str = "A *root* is an item that carries out part of a requirement and that no other `{impl}` item for it reaches";
// habeas-requirements is the home of roots: reach goes downward only.
assert_text_in_order(
"choosing references",
§ion(skill_md("habeas-requirements"), "## Choosing references"),
&[
"what an item calls, the types it uses, and the trait methods it calls, transitively",
"Callers don't count",
ROOT,
"Roots are per requirement",
"Helpers the test calls need nothing",
"Leave what it reaches unmarked",
"Don't remove an existing `{impl}` from code a root reaches unless the user asks",
],
);
// Coverage comes from a reference or a current read, never a search, and
// reads exist only after authoring.
assert_text(
"requirements gotchas",
§ion(skill_md("habeas-requirements"), "## Gotchas"),
&[
"by its own reference, or by a current assessment that read it or an enclosing item",
"Search results only locate code; they cover nothing",
"Reads exist only after `habeas author`, so author before treating an item as uncovered",
],
);
// habeas-evidence handles items still warned about after authoring by the
// reference procedure.
assert_text_in_order(
"uncovered Rust items",
§ion(skill_md("habeas-evidence"), "### Uncovered Rust items"),
&[
"For each item still warned about after `habeas author --all`, choose references by \"Choosing references\" in the habeas-requirements skill",
"Before changing an uncovered item, determine whether it is a requirement root, an entry point, an item that serves other code, or dead code",
"Report dead code to the user without editing it",
"| the item is a root of a requirement's implementation | add `{impl}` of that requirement to the item |",
"| the item only serves other code | add `` // {cite}`habeas:util` `` |",
"| nothing reaches the item | report it to the user as dead code; don't delete it unasked |",
],
);
assert_phrases(
"habeas-evidence",
&[
"except uncovered Rust items: leave those until after step 3, because an assessment that reads an item covers it",
"| rationale identifies an unmarked standalone test | add `{test}` for the requirement or example it verifies",
],
);
assert_phrases(
"habeas-bootstrap-requirements",
&["Leave uncovered items for now"],
);
// The other skills refer to the definition of a root rather than restate it.
for name in SKILLS
.into_iter()
.filter(|name| *name != "habeas-requirements")
{
assert!(!bundled_skill(name).contains(ROOT), "{name} restates roots");
}
}
Referenced definitions
Input 2: requirements selection requirements.references.procedure
requirements.references.procedure:md/requirements/references.md:68–97
:::{req} 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`.
:::
Input 3: requirements selection requirements.references.util
requirements.references.util:md/requirements/references.md:51–66
:::{req} 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`.
:::
Other sources
Input 1: requirements selection requirements.cli.internal_detail_guidance
requirements.cli.internal_detail_guidance:md/requirements/cli.md:339–351
:::{req} internal_detail_guidance
Habeas's bundled agent skills MUST direct agents to choose references by the
procedure in {cite}`requirements.references.procedure`. For internal code, they
MUST direct agents to state any invariant worth checking as an ordinary
requirement and implement it, to cite the built-in `habeas:util` under
{cite}`requirements.references.util` on an item that only serves other code, and
to report to the user an item that does neither. They MUST
NOT suggest grouping requirements, such as `internal.config_parsing`, that state
no checkable obligation.
:::
Input 6: outline tests/authoring_cli.rs const[SKILLS]
- File:
tests/authoring_cli.rs - Selector:
const[SKILLS] - Kind:
const tests/authoring_cli.rs:2817–2825
/// The bundled skills, by name.
// {cite}`habeas:util`
const SKILLS: [&str; 5] = [
"habeas",
"habeas-requirements",
"habeas-evidence",
"habeas-bootstrap-requirements",
"habeas-refactor",
];
Input 7: outline tests/authoring_cli.rs fn[assert_text]
- File:
tests/authoring_cli.rs - Selector:
fn[assert_text] - Kind:
fn tests/authoring_cli.rs:3011–3016
// {cite}`habeas:util`
fn assert_text(label: &str, text: &str, phrases: &[&str]) {
for phrase in phrases {
assert!(text.contains(phrase), "{label} lacks {phrase:?}");
}
}
Input 8: outline tests/authoring_cli.rs fn[assert_text_in_order]
- File:
tests/authoring_cli.rs - Selector:
fn[assert_text_in_order] - Kind:
fn tests/authoring_cli.rs:3018–3028
/// Asserts that the text contains each phrase, each after the previous one.
// {cite}`habeas:util`
fn assert_text_in_order(label: &str, text: &str, phrases: &[&str]) {
let mut from = 0;
for phrase in phrases {
let at = text[from..]
.find(phrase)
.unwrap_or_else(|| panic!("{label} lacks {phrase:?} after byte {from}"));
from += at + phrase.len();
}
}
Input 9: outline tests/authoring_cli.rs fn[assert_phrases]
- File:
tests/authoring_cli.rs - Selector:
fn[assert_phrases] - Kind:
fn tests/authoring_cli.rs:3030–3033
// {cite}`habeas:util`
fn assert_phrases(name: &str, phrases: &[&str]) {
assert_text(name, &bundled_skill(name), phrases);
}
Input 10: outline tests/authoring_cli.rs fn[section]
- File:
tests/authoring_cli.rs - Selector:
fn[section] - Kind:
fn tests/authoring_cli.rs:2929–2954
/// The collapsed body of a Markdown section, from the line after `heading` to
/// the next heading of the same or a higher level outside a code fence.
// {cite}`habeas:util`
fn section(raw: &str, heading: &str) -> String {
let level = heading.chars().take_while(|c| *c == '#').count();
let mut lines = raw.lines().skip_while(|line| *line != heading);
assert!(lines.next().is_some(), "no section {heading:?}");
let mut fence: Option<usize> = None;
let mut body = Vec::new();
for line in lines {
let ticks = line.trim_start().chars().take_while(|c| *c == '`').count();
match fence {
Some(open) if ticks >= open && line.trim().chars().all(|c| c == '`') => fence = None,
Some(_) => {}
None if ticks >= 3 => fence = Some(ticks),
None => {
let hashes = line.chars().take_while(|c| *c == '#').count();
if hashes > 0 && hashes <= level && line[hashes..].starts_with(' ') {
break;
}
}
}
body.push(line);
}
collapse(&body.join("\n"))
}