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

requirements.cli.skill_structure.habeas

Requirements index · View definition

evidence Valid

Requirement

Under cite requirements.cli.skill_structure, the habeas skill MUST be the home of routing tasks to skills, habeas status and habeas info, directive and reference syntax, distributed requirements, and gotchas common to every task.

Rationale

The subject has one obligation: the habeas skill must be the home of five topics. They are routing tasks to skills, habeas status and habeas info, directive and reference syntax, distributed requirements, and gotchas common to every task. The parent requirements.cli.skill_structure adds that each topic is stated in full in exactly one skill.

The only marked test is tests/authoring_cli.rs#fn[the_habeas_skill_is_home_of_routing_inspection_syntax_and_shared_gotchas]. It covers each topic as follows.

  • Routing: assert_text checks that the ## Workflow section of the habeas SKILL.md contains the | Task | Skill | table header.
  • Status and info: it checks that ## Inspecting mentions habeas status [<selection>] and habeas info <selection>.
  • Syntax: it checks that ## Requirements, examples, and definitions covers {req}, {example} and {definition}. It also checks that ## References covers writing a reference with a full name in a comment and fencing a reference.
  • Gotchas: it checks that ## Gotchas states the Git-index limitation.
  • Distributed requirements: it checks that references/distributed-requirements.md has its heading. references/syntax-details.md is checked for the nested-chapter full-name and anchors sections.
  • Exactly one home: assert_home("habeas") does two things. It uses the home_markers list for habeas to assert that the whole habeas skill, SKILL.md plus references, contains each marker. It then asserts that none of the other four skills contains any of those markers. The markers include the routing table, the selection definition, fencing a reference to attach commentary, :::{violations}, site-query matches making a site, silently defines nothing, the longer outer fence, and the target-directory artifacts and install-prerequisites gotchas.

The assertions are real. section extracts the body of a given heading and fails if the heading is missing. assert_text and assert_home fail with messages when a phrase is absent or when another skill restates a marker. A skill that moved or dropped any of these topics, or let another skill restate a marker, would fail.

The check is phrase-based, so it cannot prove a topic is stated “in full”. That is the same level of verification the sibling home tests use, and bundled_skills_refer_to_a_topic_home_instead_of_restating_it supports it for the parent requirement. I found no input class, boundary or failure case in the subject’s text that the test leaves unexercised. No acknowledgments apply.

Inputs

Tests

Input 3: outline tests/authoring_cli.rs fn[the_habeas_skill_is_home_of_routing_inspection_syntax_and_shared_gotchas]
// {test}`requirements.cli.skill_structure.habeas`
#[test]
fn the_habeas_skill_is_home_of_routing_inspection_syntax_and_shared_gotchas() {
    let raw = skill_md("habeas");
    assert_text(
        "routing",
        &section(raw, "## Workflow"),
        &["| Task | Skill |"],
    );
    assert_text(
        "inspecting",
        &section(raw, "## Inspecting"),
        &["`habeas status [<selection>]`", "`habeas info <selection>`"],
    );
    assert_text(
        "syntax",
        &section(raw, "## Requirements, examples, and definitions"),
        &[
            "fenced `{req}` directive",
            "An `{example}`",
            "A `{definition}`",
        ],
    );
    assert_text(
        "references",
        &section(raw, "## References"),
        &[
            "Write a reference with a full name in a comment on the relevant source line",
            "Fence a reference",
        ],
    );
    assert_text(
        "gotchas",
        &section(raw, "## Gotchas"),
        &["Reference discovery and authoring read only files in the Git index"],
    );
    assert_text(
        "distributed requirements",
        skill_file("habeas", "references/distributed-requirements.md"),
        &["# Distributed requirements"],
    );
    assert_text(
        "syntax details",
        skill_file("habeas", "references/syntax-details.md"),
        &["## Full names in nested chapters", "## Anchors"],
    );
    assert_home("habeas");
}

Referenced definitions

Input 2: requirements selection requirements.cli.skill_structure
:::{req} skill_structure
Habeas's bundled agent skills MUST jointly give the direction that the requirements on them specify. A skill consists of its `SKILL.md` and the files under its `references/` directory. Each topic MUST be stated in full in exactly one skill, its home.
:::

Other sources

Input 1: requirements selection requirements.cli.skill_structure.habeas
:::{req} skill_structure.habeas
Under {cite}`requirements.cli.skill_structure`, the `habeas` skill MUST be the home of routing tasks to skills, `habeas status` and `habeas info`, directive and reference syntax, distributed requirements, and gotchas common to every task.
:::
Input 4: outline tests/authoring_cli.rs fn[assert_home]
/// Asserts that `home` states each of its markers and no other skill does.
// {cite}`habeas:util`
fn assert_home(home: &str) {
    assert_phrases(home, home_markers(home));
    for other in SKILLS.into_iter().filter(|other| *other != home) {
        let text = bundled_skill(other);
        for marker in home_markers(home) {
            assert!(
                !text.contains(marker),
                "{other} restates {home}'s {marker:?}"
            );
        }
    }
}
Input 5: outline tests/authoring_cli.rs fn[assert_text]
// {cite}`habeas:util`
fn assert_text(label: &str, text: &str, phrases: &[&str]) {
    for phrase in phrases {
        assert!(text.contains(phrase), "{label} lacks {phrase:?}");
    }
}
Input 6: outline tests/authoring_cli.rs fn[section]
/// 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"))
}
Input 7: outline tests/authoring_cli.rs fn[home_markers]
/// Phrases that state part of a topic in full, by the skill that is its home.
// {cite}`habeas:util`
fn home_markers(home: &str) -> &'static [&'static str] {
    match home {
        "habeas" => &[
            "| Task | Skill |",
            "A selection is a full name or a glob in which `*` matches any characters",
            "Its full name is the chapter path relative to that directory",
            "Fence a reference to attach commentary",
            "`:::{violations} <name>` selects constructs likely to break it",
            "Each site-query match makes a site",
            "omit a leading `reqs/` and a trailing `/index` or `/README`",
            "silently defines nothing",
            "needs a longer outer fence such as `::::{req}`",
            "Profiles, reports, and captured source under the Cargo target directory",
            "Install prerequisites",
        ],
        "habeas-requirements" => &[
            "Write drafts from the request straight into the chapter",
            "For each group, start a read-only subagent",
            "**Gate:** no implementation or test code",
            "A *root* is an item that carries out part of a requirement",
            "## What the review checks",
            "# Requirement group review",
            "**Compound:** a requirement that lists several independent forms",
        ],
        "habeas-evidence" => &[
            "A judgment is one of three outcomes",
            "`habeas author --all` assesses every definition whose evidence is missing, stale, or invalid",
            "## Fixing findings",
            "An item has recent coverage when it has its own reference, or when a recent version of an existing evidence record or review read it",
            "A FIXME judgment, such as",
            "gets a citation review. For project requirements and examples it checks that",
            "For built-ins it checks their permitted forms and stated criteria",
            "A site the requirement does not apply to is judged true",
            "The goal is that independent assessments of the same subject reach the same determination",
            "describing the change relative to the prior commit rather than the drafts that led to it",
        ],
        "habeas-bootstrap-requirements" => &[
            "every first-party runnable test or test case",
            "## Proposing requirements",
            "Independent recount:",
        ],
        "habeas-refactor" => &[
            "habeas refactor --dry-run",
            "`--map 'src/config.rs#fn[load]=src/config/load.rs#fn[load]'`",
            "\"Would leave ... unchanged\" lists records a mapping affects that fail a check",
        ],
        _ => panic!("unknown skill {home}"),
    }
}
Input 8: outline tests/authoring_cli.rs fn[assert_phrases]
// {cite}`habeas:util`
fn assert_phrases(name: &str, phrases: &[&str]) {
    assert_text(name, &bundled_skill(name), phrases);
}
Input 9: outline tests/authoring_cli.rs fn[bundled_skill]
/// A bundled skill: its `SKILL.md` together with its reference files,
/// collapsed.
// {cite}`habeas:util`
fn bundled_skill(name: &str) -> String {
    let files = skill_files(name)
        .iter()
        .map(|(_, text)| *text)
        .collect::<Vec<_>>();
    collapse(&files.join("\n"))
}