requirements.references.anchors.guidance
Requirements index · View definition
Requirement
Agents SHOULD NOT anchor a file under
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
habeasskill’sreferences/syntax-details.mdthroughskill_file, which usesinclude_str!on the shipped asset. - It extracts the
## Anchorssection withsection. - 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_textpanics 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. Thehabeasskill’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]
- File:
assets/skills/habeas/references/syntax-details.md - Selector:
section[Syntax%20details]/section[Anchors] - Kind:
section assets/skills/habeas/references/syntax-details.md:9–18
## 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]
- File:
tests/authoring_cli.rs - Selector:
fn[bundled_skills_limit_anchors_to_files_whose_items_cannot_carry_references] - Kind:
fn tests/authoring_cli.rs:4541–4555
// {test}`requirements.references.anchors.guidance`
#[test]
fn bundled_skills_limit_anchors_to_files_whose_items_cannot_carry_references() {
assert_text(
"syntax details",
§ion(
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
requirements.references.anchors:md/requirements/references.md:176–197
:::{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
requirements.references.anchors.guidance:md/requirements/references.md:199–203
:::{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]
- File:
tests/authoring_cli.rs - Selector:
fn[skill_files] - Kind:
fn tests/authoring_cli.rs:2827–2885
/// 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]
- File:
tests/authoring_cli.rs - Selector:
fn[skill_file] - Kind:
fn tests/authoring_cli.rs:2899–2907
/// 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]
- 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"))
}
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:?}");
}
}