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.references.anchors.guidance

Requirements index · View definition

evidence Valid

Requirement

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.

Rationale

Obligations. requirements.references.anchors.guidance has two clauses.

  • Agents SHOULD NOT anchor a file when a more precise reference is available. This is a behavioral norm for agents, and the bundled skills are the only way the product can enforce it. The MUST clause is what carries it.
  • Habeas’s bundled agent skills MUST give this direction. The skill text must tell agents not to anchor a file whose items can carry a reference themselves.

Test mapping. tests/authoring_cli.rs#fn[bundled_skills_limit_anchors_to_files_whose_items_cannot_carry_references] is marked {test} for the subject.

  • It loads the bundled habeas skill’s references/syntax-details.md through skill_file, which uses include_str! on the shipped asset.
  • It extracts the ## Anchors section with section.
  • Through assert_text, it asserts that the section contains two phrases:
    • “When a file that implements or tests a requirement cannot carry a reference”. This is the positive condition under which anchoring is allowed.
    • “Don’t anchor a file whose items can carry a reference themselves”. This is the prohibition and the direction the requirement demands.
  • assert_text panics if either phrase is missing, so the assertions are real.

I read the asset section assets/skills/habeas/references/syntax-details.md#section[Syntax details]/section[Anchors]. It contains both phrases, so the test matches the shipped text.

Remaining questions.

  • The requirement says “skills” in the plural, but the other bundled skills (habeas-refactor, habeas-requirements) only mention anchors in passing. They don’t author declarations, and the requirement doesn’t say which skill must carry the direction. The habeas skill’s syntax reference is the natural home, and the test covers it.
  • The skill’s wording is slightly more general than “such as a reference attached to the Rust item”. The requirement’s “such as” is only illustrative, so this is not a gap.

The SHOULD NOT clause is agent behavior and can’t be tested directly. The MUST clause is the testable obligation, and it is covered with an adequate assertion. I found no gap.

Inputs

Implementation

Input 8: outline assets/skills/habeas/references/syntax-details.md section[Syntax%20details]/section[Anchors]
## Anchors

When a file that implements or tests a requirement cannot carry a reference,
such as a shipped skill or a stylesheet copied into other projects, anchor it
from the declaration with `:impl: <path>` or `:test: <path>` option lines
directly after the opening fence (examples accept only `:test:`). Use
`:impl: <path>#<selector>` for one outline node, an item such as a function or
a Markdown section that a selector names, such as
`:impl: skills/foo/SKILL.md#section[Workflow]`; `habeas info` shows each input's
selector. Don't anchor a file whose items can carry a reference themselves.

Tests

Input 3: outline tests/authoring_cli.rs fn[bundled_skills_limit_anchors_to_files_whose_items_cannot_carry_references]
// {test}`requirements.references.anchors.guidance`
#[test]
fn bundled_skills_limit_anchors_to_files_whose_items_cannot_carry_references() {
    assert_text(
        "syntax details",
        &section(
            skill_file("habeas", "references/syntax-details.md"),
            "## Anchors",
        ),
        &[
            "When a file that implements or tests a requirement cannot carry a reference",
            "Don't anchor a file whose items can carry a reference themselves",
        ],
    );
}

Referenced definitions

Input 2: requirements selection requirements.references.anchors
:::{req} 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.
:::

Other sources

Input 1: requirements selection requirements.references.anchors.guidance
:::{req} 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.
:::
Input 4: outline tests/authoring_cli.rs fn[skill_files]
/// The files of a bundled skill, by path relative to its directory: its
/// `SKILL.md` first, then every file under its `references/` directory.
// {cite}`habeas:util`
fn skill_files(name: &str) -> &'static [(&'static str, &'static str)] {
    match name {
        "habeas" => &[
            ("SKILL.md", include_str!("../assets/skills/habeas/SKILL.md")),
            (
                "references/ci.md",
                include_str!("../assets/skills/habeas/references/ci.md"),
            ),
            (
                "references/distributed-requirements.md",
                include_str!("../assets/skills/habeas/references/distributed-requirements.md"),
            ),
            (
                "references/syntax-details.md",
                include_str!("../assets/skills/habeas/references/syntax-details.md"),
            ),
        ],
        "habeas-requirements" => &[
            (
                "SKILL.md",
                include_str!("../assets/skills/habeas-requirements/SKILL.md"),
            ),
            (
                "references/review-prompt.md",
                include_str!("../assets/skills/habeas-requirements/references/review-prompt.md"),
            ),
        ],
        "habeas-evidence" => &[
            (
                "SKILL.md",
                include_str!("../assets/skills/habeas-evidence/SKILL.md"),
            ),
            (
                "references/authoring-failures.md",
                include_str!("../assets/skills/habeas-evidence/references/authoring-failures.md"),
            ),
            (
                "references/fixme.md",
                include_str!("../assets/skills/habeas-evidence/references/fixme.md"),
            ),
            (
                "references/reviews.md",
                include_str!("../assets/skills/habeas-evidence/references/reviews.md"),
            ),
        ],
        "habeas-bootstrap-requirements" => &[(
            "SKILL.md",
            include_str!("../assets/skills/habeas-bootstrap-requirements/SKILL.md"),
        )],
        "habeas-refactor" => &[(
            "SKILL.md",
            include_str!("../assets/skills/habeas-refactor/SKILL.md"),
        )],
        _ => panic!("unknown skill {name}"),
    }
}
Input 5: outline tests/authoring_cli.rs fn[skill_file]
/// One file of a bundled skill, raw.
// {cite}`habeas:util`
fn skill_file(name: &str, path: &str) -> &'static str {
    skill_files(name)
        .iter()
        .find(|(file, _)| *file == path)
        .unwrap_or_else(|| panic!("{name} has no {path}"))
        .1
}
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[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:?}");
    }
}