requirements.cli.behavior_review_guidance
Requirements index · View definition
Requirement
Habeas’s bundled agent skills MUST direct agents reviewing code against requirements to inspect every end-user-observable result and branch, including errors and input handling, and verify both that the code fulfills each applicable requirement and that it introduces no additional end-user-observable behavior without an agreed requirement. They MUST explain the requirement and example review criteria in
, including test adequacy and justified absence of tests for requirements, and the three outcomes and documented-gap convention in
. Agents MUST mark the roots of a requirement’s implementation with
{impl}and the tests that verify it with{test}, leaving code reached from those items unmarked, and use{cite}only for related code that does neither, under. When Habeas warns that an item has no recent coverage under
, they MUST choose its references by that procedure, and for an item no other code reaches, determine whether it is dead code before changing anything. Where requirements interact, agents MUST mark every requirement implemented at the relevant point and explain how their texts jointly account for the behavior. A citation alone MUST NOT count as that explanation.
Rationale
The three tests in tests/authoring_cli.rs that carry {test} references to requirements.cli.behavior_review_guidance adequately check its obligations. They are bundled_skills_direct_behavior_review_against_requirements, bundled_skills_mark_roots_and_handle_uncovered_items and bundled_skills_direct_the_reference_procedure_and_report_items_without_one. The requirement governs the text of the bundled skills, so I judged the tests as phrase-presence checks on that text. I did not need implementation source.
The helpers assert_phrases, assert_text and assert_text_in_order really assert. assert_text panics unless the text contains each phrase. assert_text_in_order also enforces order. section panics if a heading is missing and bounds the text to that section. assert_phrases runs over the whole bundled skill, so the checks bind to real skill content.
How each obligation maps to a test:
-
Inspect every end-user-observable result and branch, including errors and input handling, and verify no unagreed behavior.
bundled_skills_direct_behavior_review_against_requirementsasserts:- the
habeas-requirementsphrase “Every end-user-observable result of the code, including errors and input handling, must follow from a requirement the user agreed to”; - the
habeas-bootstrap-requirementsphrases “distinct observable branches” and “every observable branch has been reviewed”; - the
habeas-evidencephrase “Behavior with no requirement needs one agreed with the user”.
- the
-
Verify the code fulfills each applicable requirement. The same test asserts “The supervising agent must still check that the code fulfills each applicable requirement” in the “What the review checks” section.
-
Explain the review criteria, including test adequacy and justified absence of tests. The same test asserts the following in the “What the review checks” section:
- wrong expected results;
- an unmarked standalone test (a marking gap);
- untested obligations, boundaries and failure cases;
- the omission exemptions (no logic, network, real time, process-wide state);
- the rule that “stays unchanged, distinct, or present” always needs a test;
- the criteria for examples;
- “One acknowledged gap does not excuse others”.
It also asserts that a
falserationale names a listed gap. -
Explain the three outcomes and the documented-gap convention. The same test asserts the three outcome phrases, the FIXME object form,
// :github:, “A plainFIXMEorTODOcomment does not count”, and “To defer a requirement gap the user agrees to, use{fixme}”. -
Mark roots with
{impl}, tests with{test}, leave reached code unmarked, and use{cite}only for related code. Three tests cover this:- The behavior test asserts the ordered procedure steps and “Leave what it reaches unmarked”.
bundled_skills_mark_roots_and_handle_uncovered_itemsasserts the root definition and the downward-only reach, and checks that other skills refer to the root definition rather than restate it.bundled_skills_direct_the_reference_procedure_and_report_items_without_oneasserts the ordered procedure and that other skills defer to it.
-
Handle no-recent-coverage warnings and decide dead code before changing anything.
bundled_skills_mark_roots_and_handle_uncovered_itemsasserts that the “Uncovered Rust items” section tells the agent to:- choose references by “Choosing references”;
- determine “whether it is a requirement root, an entry point, an item that serves other code, or dead code” before changing the item;
- report dead code without editing it.
The reference-procedure test also asserts the dead-code reporting text.
-
Interacting requirements, and a citation alone is not an explanation. The behavior test asserts that the skill says to mark each requirement with
{impl}where it applies and add fenced commentary on how they combine. It also asserts “a reference alone would not say why^Cis accepted” and the bootstrap-skill counterpart.
Unresolved question: the requirement asks the skills to explain the criteria in requirements.ci.review_criteria generally. The tests do not assert every sub-criterion, such as ambiguity treated as a gap, counterexample requirements, or delegation to refining requirements and site reviews. The requirement names test adequacy and justified absence of tests explicitly, and both are asserted. I treat the unasserted sub-criteria as unnamed edge cases rather than gaps.
I found no marking gap, no wrong expected result and no weak assertion. The tests are marked {test} for the subject.
Inputs
Tests
Input 6: 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 7: outline tests/authoring_cli.rs fn[bundled_skills_direct_behavior_review_against_requirements]
- File:
tests/authoring_cli.rs - Selector:
fn[bundled_skills_direct_behavior_review_against_requirements] - Kind:
fn tests/authoring_cli.rs:4623–4720
// {test}`requirements.cli.behavior_review_guidance`
#[test]
fn bundled_skills_direct_behavior_review_against_requirements() {
// The three outcomes.
assert_phrases(
"habeas-evidence",
&[
"A judgment is one of three outcomes",
"`true`: the reviewed tests adequately check the definition, with no gap under",
"`false`: there is a gap that no `{fixme}` reference acknowledges",
"FIXME: `{fixme}` references acknowledge every remaining gap",
],
);
// Every observable branch, and no unspecified behavior.
assert_phrases(
"habeas-requirements",
&[
"Every end-user-observable result of the code, including errors and input handling, must follow from a requirement the user agreed to",
],
);
assert_phrases(
"habeas-bootstrap-requirements",
&[
"distinct observable branches",
"every observable branch has been reviewed",
],
);
assert_phrases(
"habeas-evidence",
&["Behavior with no requirement needs one agreed with the user"],
);
// The requirement and example review criteria, including test adequacy and
// justified absence of tests; habeas-requirements is their home.
assert_text(
"what the review checks",
§ion(skill_md("habeas-requirements"), "## What the review checks"),
&[
"assertions whose expected results contradict the requirement",
"a standalone test designed to verify the subject without `{test}`",
"The supervising agent must still check that the code fulfills each applicable requirement",
"obligations, boundaries, and failure cases no test runs and asserts",
"A test may be omitted only for code with no logic of its own, or code that needs network services, real time, or process-wide state no project test sets up",
"an obligation that a value stays unchanged, distinct, or present always needs a test",
"An example's review checks that tests' setup and assertions cover its scenario and each expected outcome",
"One acknowledged gap does not excuse others",
],
);
assert_phrases(
"habeas-evidence",
&[
"A false rationale names one of the gaps listed in \"What the review checks\" in the habeas-requirements skill",
],
);
// The three outcomes and the documented-gap convention; habeas-evidence is
// the home of FIXME judgments.
assert_phrases(
"habeas-evidence",
&[
"| false judgment | read the rationale",
"A FIXME judgment, such as `{\"FIXME\": [\"rust-lang/rust#123\"]}`, means `{fixme}` references to the definition acknowledge every remaining gap",
"Validation accepts it like `true` when all other checks pass",
"// :github: rust-lang/rust#123",
"A plain `FIXME` or `TODO` comment does not count",
],
);
assert_phrases(
"habeas-requirements",
&["To defer a requirement gap the user agrees to, use `{fixme}`"],
);
// Roots get `{impl}`, tests `{test}`, and `{cite}` only for related code.
assert_text(
"choosing references",
§ion(skill_md("habeas-requirements"), "## Choosing references"),
&[
"1. A test designed to verify it gets `{test}`",
"2. Otherwise a root gets `{impl}`. Leave what it reaches unmarked",
"`{cite}` implements nothing; a citation review checks project citations' roles and built-ins' stated criteria",
],
);
assert_phrases(
"habeas-bootstrap-requirements",
&["`{test}` on tests and `{impl}` on roots; code a root or test reaches needs none"],
);
// Interacting requirements, and a citation alone is not an explanation.
assert_phrases(
"habeas-requirements",
&[
"If a behavior follows only from several requirements together, mark each with `{impl}` where it applies and add fenced commentary saying how they combine",
"a reference alone would not say why `^C` is accepted",
],
);
assert_phrases(
"habeas-bootstrap-requirements",
&[
"Where one behavior follows from several requirements, mark each with `{impl}` where it applies and explain how they combine",
],
);
}
Input 8: 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.ci.review_criteria
requirements.ci.review_criteria:md/requirements/ci.md:23–110
:::{req} review_criteria
The reviewer MUST assess the named subject using its text, referenced requirements,
and terminology definitions. For a requirement, the reviewer MUST assess whether
the reviewed tests adequately check its stated obligations, including relevant
input classes, boundaries, condition combinations, state transitions, and failure
cases. These cases MUST follow from the requirement's obligations; the reviewer
MUST NOT require behavior for inputs the text leaves unspecified. The reviewer
MUST derive expected outcomes from the text, inspect the tests and relevant
helpers or fixtures, and map each obligation assessed here to concrete test
inputs and assertions in the rationale. It MUST separately identify obligations
delegated to a refining requirement or a distributed site's review and any
established testing exemptions. It MUST assess both whether expected results conform
to the text and whether the assertions enforce those results.
For every proposed adequacy gap, the reviewer MUST describe plausible behavior
that violates a stated obligation but would be accepted by the reviewed tests,
and explain which missing scenarios or weak assertions allow it. For an incorrect
expected result, it MUST instead identify the assertion and explain its conflict
with the text. A counterexample MUST identify a requirement-relevant distinction
that the tests miss; another untested value in an already represented input class
MUST NOT by itself establish a gap without explaining why it could expose
different required behavior. It MUST check other relevant tests and helpers before reporting a
gap and distinguish missing information from an established inadequacy. A marking
gap or an ambiguity MUST be identified as such, without requiring a behavioral
counterexample. A judgment of `true` MUST mean the reviewed tests adequately check
the subject under these criteria, including the testing exemptions of
{cite}`requirements.authoring.testing_bar`; it MUST NOT assert implementation
correctness. The reviewer MAY request implementation source to resolve a
specific question and MUST state that question in its rationale. It MUST NOT
derive expected behavior from the implementation or assess implementation
correctness, implementation reachability, or unspecified implementation behavior
as additional tasks.
When another requirement implements part of the subject, the
reviewer MUST assess whether its text carries out that part, and MUST NOT
reassess its implementation, tests, or evidence; that requirement is assessed
separately. When there are no tests, the reviewer MUST apply the testing
exemptions of {cite}`requirements.authoring.testing_bar` and explain any
exemption it establishes.
The reviewer MUST apply these rules in every assessment. MUST and MUST NOT state
obligations; a SHOULD MUST impose an obligation unless the subject's text or a
source comment gives a reason it does not apply, and the reviewer MUST apply the
testing criteria to every applicable SHOULD in a test-adequacy assessment and
explain each exception in the rationale; MAY imposes nothing to
check; examples and sample output in the text illustrate the obligations its
prose states and bind their exact form only where the text says so. When the subject's
text admits two readings its wording supports equally and they lead to different conclusions, such as whether code conforms or which role a citation calls for, the ambiguity MUST be treated as a gap and the rationale MUST name
the readings. A test that verifies the subject without a `{test}` reference to it
MUST be treated as a marking gap; a helper reached from a marked test MUST NOT
need a reference of its own. A gap MUST be
reported only for a specific obligation with relevant sources the reviewer
has read. Before reporting a missing test, the reviewer MUST perform targeted
discovery of relevant tests and identify the missing scenario; an absent test
MUST NOT require an invented source location. Style, performance, logging, how
helpers are factored, robustness the text does not require, and silently ignoring input the text does not mention MUST NOT be treated as gaps, and the reviewer MUST NOT report bugs or issues outside the
subject's text.
For a distributed requirement under {cite}`requirements.references.distributed`,
the reviewer MUST also assess the requirement and its queries. Each obligation
MUST be either one that each site upholds on its own, checked by its review under
{cite}`requirements.references.site_review`, or one that particular code carries
out, assessed as above through its `{impl}` and `{test}` references; an
obligation neither covers MUST be treated as a gap. The reviewer MUST judge whether
each query's conditions are adequate and adequately tested: the site queries
MUST select every place the text's description of a site covers and no place
outside the requirement's stated scope, and each query's `match` and `no_match`
snippets MUST test its conditions as tests of code would, judged as such; a
condition without a snippet of its own MUST NOT by itself be treated as a gap. Because queries are heuristics, the reviewer MUST
judge them by a preponderance of the evidence, asking whether it is more likely
than not that the site queries find the places the requirement applies: a
specific place in the sources that a site query misses or wrongly selects MUST be
treated as a gap, and a form that does not occur in the sources MUST NOT.
Obligations that decide which places are sites, such as a naming rule, MUST be
checked by the reviewer's search of the sources. Violation queries direct site
reviews to likely problems; the reviewer SHOULD note constructs they miss, but
their incompleteness MUST NOT by itself make the determination false. Any other
gap in the queries or snippets MUST be treated as a gap under
{cite}`requirements.ci.outcomes`, even when the code is correct. The reviewer SHOULD run each site query once, scan its matches,
and search briefly for the construct the text describes, and MUST NOT review each
site or treat a site without an `{impl}` reference as a gap.
For an example, the reviewer MUST assess whether tests exist whose setup and
assertions cover its scenario and expected outcomes. The rationale MUST identify
the relevant sources and explain the testing judgment for a
requirement, or the test coverage for an example. Referenced requirements provide
context; they MUST NOT become additional subjects to assess in full.
:::
Input 3: requirements selection requirements.ci.outcomes
requirements.ci.outcomes:md/requirements/ci.md:112–149
:::{req} outcomes
Every assessment judgment MUST use one of these outcomes, applying
{cite}`requirements.ci.review_criteria`:
- `true`: the reviewed tests adequately check a requirement or example under
{cite}`requirements.ci.review_criteria`, including applicable testing
exemptions and obligations assessed by a refining requirement or a site's
own review. For a citation or site review, the review finds no gap under its
own task.
- `false`: the sources do not support the subject, or information is missing,
and the gaps are not all acknowledged by `{fixme}` references to it.
- `FIXME`: some aspects remain unmet or untested, and `{fixme}` references to
the subject acknowledge every one of those gaps. The reviewer MUST explain the
gaps and their source locations in the rationale and record their issue
references or other identifying content from the supplied acknowledgments or
inputs.
The JSON `determination` MUST be `true`, `false`, or an object containing exactly
`"FIXME"` with a nonempty array of nonempty strings, such as
`{"FIXME": ["example/queue#125", "rust-lang/rust#123"]}`. A gap MUST count as
acknowledged only by a `{fixme}` reference under
{cite}`requirements.references.roles` whose body describes that gap and that
references the assessed definition, or, for a site review, the distributed requirement from within that site; a citation review MUST NOT accept a `{fixme}`; a plain
`FIXME` comment, another marker such as `TODO`, or prose MUST NOT. The strings
MUST list each distinct issue reference the acknowledging `{fixme}` references
name in their option lines, as written after `:github:`, and, for a `{fixme}`
naming no issue, its body's words, without comment delimiters, joined by single
spaces. A `{fixme}` reference describing a gap that the review establishes no
longer exists within its task's scope MUST itself be treated as a gap. A reference
describing only an implementation defect MUST NOT create a test-adequacy gap or
require implementation review; it MUST acknowledge a testing gap only when its
body describes that same gap. A `{fixme}` naming a GitHub issue that
{cite}`requirements.authoring.github_reads` reports closed MUST NOT count as
acknowledging its gap. A FIXME judgment MUST be grounded in recorded evidence
inputs or, for an acknowledgment supplied under
{cite}`requirements.authoring.fixme_inputs`, the reference-set digest covering
that acknowledgment.
:::
Input 4: 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 5: requirements selection requirements.references.coverage.report
requirements.references.coverage.report:md/requirements/references.md:262–279
:::{req} coverage.report
`habeas status`, and `habeas author` after it finishes, MUST report the number
of nodes without recent coverage under
{cite}`requirements.references.coverage.history`, except items inside a module
named `tests`, using the following summary:
```text
N nodes have coverage warnings. Use `status --coverage` to see them.
```
The summary MUST report zero when no nodes have warnings. Default output MUST
NOT list individual coverage warnings or coverage-history details, including
with `status --all` or `status --verbose`.
`habeas status --coverage` MUST list every warning, naming its file, line, kind,
and name, and report incomplete coverage history when applicable.
A warning MUST NOT fail validation, and repository validation MUST NOT read
Git history.
:::
Other sources
Input 1: requirements selection requirements.cli.behavior_review_guidance
requirements.cli.behavior_review_guidance:md/requirements/cli.md:332–337
:::{req} behavior_review_guidance
Habeas's bundled agent skills MUST direct agents reviewing code against requirements to inspect every end-user-observable result and branch, including errors and input handling, and verify both that the code fulfills each applicable requirement and that it introduces no additional end-user-observable behavior without an agreed requirement. They MUST explain the requirement and example review criteria in {cite}`requirements.ci.review_criteria`, including test adequacy and justified absence of tests for requirements, and the three outcomes and documented-gap convention in {cite}`requirements.ci.outcomes`. Agents MUST mark the roots of a requirement's implementation with `{impl}` and the tests that verify it with `{test}`, leaving code reached from those items unmarked, and use `{cite}` only for related code that does neither, under {cite}`requirements.references.procedure`. When Habeas warns that an item has no recent coverage under {cite}`requirements.references.coverage.report`, they MUST choose its references by that procedure, and for an item no other code reaches, determine whether it is dead code before changing anything. Where requirements interact, agents MUST mark every requirement implemented at the relevant point and explain how their texts jointly account for the behavior. A citation alone MUST NOT count as that explanation.
:::
Input 9: outline tests/authoring_cli.rs fn[skill_md]
- File:
tests/authoring_cli.rs - Selector:
fn[skill_md] - Kind:
fn tests/authoring_cli.rs:2893–2897
/// A bundled skill's raw `SKILL.md`.
// {cite}`habeas:util`
fn skill_md(name: &str) -> &'static str {
skill_files(name)[0].1
}
Input 10: outline tests/authoring_cli.rs fn[bundled_skill]
- File:
tests/authoring_cli.rs - Selector:
fn[bundled_skill] - Kind:
fn tests/authoring_cli.rs:2909–2918
/// 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"))
}
Input 11: 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 12: 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 13: 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 14: 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);
}