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.definition_glob_search

Requirements index · View definition

evidence Valid

Example

Given a requirement foo.ready and a named example foo.case, habeas info 'foo.*' displays both, and habeas status 'foo.*' --all lists both with their kinds and evidence states. cite requirements.cli.info cite requirements.cli.status

Rationale

The example requirements.cli.definition_glob_search gives a concrete case. The case has a requirement foo.ready and a named example foo.case. habeas info 'foo.*' must display both. habeas status 'foo.*' --all must list both with their kinds and evidence states.

tests/commands.rs#fn[definition_glob_lists_a_requirement_and_an_example_in_info_and_status] is a dedicated test that reproduces this case:

  • Setup: It builds a project with foo.ready (a requirement) and foo.case (an example). It adds a decoy bar.other in a separate file. It writes an evidence record for foo.ready only, with determination false.
  • info outcome: It runs info foo.*. It asserts that the output contains # \foo.case`with the## Examplebody. It asserts that the output also contains# `foo.ready`with the## Requirementbody. It asserts thatbar.otheris absent, which checks that the glob selects only thefoo.*` definitions.
  • status outcome: It runs status foo.* --all. It finds the table row for each definition. It asserts that the foo.case row shows (example) and Missing. It asserts that the foo.ready row shows (requirement) and Determination false. It asserts that bar.other is absent. These assertions check that both definitions are listed with their kind and evidence state.

Two further tests cite the example. info_renders_exact_and_glob_matches_as_markdown_without_an_index checks that an info glob returns a requirement and an example in full-name order, and that an exact name is not widened. status_and_info_accept_a_definition_selection checks the status glob with --all and the help text. Together they cover the glob behavior, including the cited requirements.cli.info and requirements.cli.status requirements. No expected result contradicts the example, and I found no outcome stated in the example that the tests leave unchecked.

Inputs

Tests

Input 4: outline tests/commands.rs fn[info_renders_exact_and_glob_matches_as_markdown_without_an_index]
  • File: tests/commands.rs
  • Selector: fn[info_renders_exact_and_glob_matches_as_markdown_without_an_index]
  • Kind: fn
  • tests/commands.rs:515–590
// {test}`requirements.cli.info`
// {test}`requirements.cli.definition_glob_search`
// {test}`requirements.index.invalid_detail`
#[test]
fn info_renders_exact_and_glob_matches_as_markdown_without_an_index() {
    let temp = fixture();
    let output = habeas(temp.path(), &["info", "requirements.ready"]);
    assert!(output.status.success(), "{:?}", output);
    let exact = String::from_utf8(output.stdout).unwrap();
    assert!(exact.starts_with("# `requirements.ready`\n"), "{exact}");
    assert!(!exact.contains("# `requirements.xready`"), "{exact}");
    assert!(
        exact.contains("## Requirement\n\n> Ready MUST work."),
        "{exact}"
    );
    assert!(
        exact.contains("## Rationale\n\n**ready** was inspected."),
        "{exact}"
    );
    assert!(exact.contains("## Inputs"), "{exact}");
    assert!(exact.contains("src/main.rs:1–1"), "{exact}");
    assert!(
        exact.contains("```rust,noplayground\nfn main() {}"),
        "{exact}"
    );
    assert!(
        exact.contains("img.shields.io/badge/evidence-Valid-237346"),
        "{exact}"
    );

    let output = habeas(temp.path(), &["info", "requirements.*"]);
    assert!(output.status.success(), "{:?}", output);
    let matches = String::from_utf8(output.stdout).unwrap();
    let pending = matches.find("# `requirements.pending`").unwrap();
    let ready = matches.find("# `requirements.ready`").unwrap();
    assert!(pending < ready, "{matches}");
    assert!(matches.contains("# `requirements.xready`"), "{matches}");
    assert!(
        matches.contains("# `requirements.case`\n\nDefinition:"),
        "{matches}"
    );
    assert!(
        matches.contains("## Example\n\n> Given ready, it works."),
        "{matches}"
    );
    assert!(matches.contains("\n\n---\n\n"), "{matches}");
    for (name, state, finding) in [
        ("pending", "Determination_false", "determination is false"),
        ("stale", "Invalid", "requirement text changed"),
        ("stale_input", "Invalid", "outline input changed"),
    ] {
        let output = habeas(temp.path(), &["info", &format!("requirements.{name}")]);
        assert!(output.status.success(), "{output:?}");
        let text = String::from_utf8(output.stdout).unwrap();
        assert!(text.contains(&format!("evidence-{state}")), "{text}");
        assert!(text.contains("## Validation findings"), "{text}");
        assert!(text.contains(finding), "{text}");
    }

    let missing = habeas(temp.path(), &["info", "requirements.absent"]);
    assert!(missing.status.success(), "{:?}", missing);
    let missing = String::from_utf8(missing.stdout).unwrap();
    assert!(missing.contains("## Validation findings"), "{missing}");
    assert!(missing.contains("missing for requirement"), "{missing}");
    assert!(missing.contains("No rationale recorded."), "{missing}");
    assert!(missing.contains("No inputs recorded."), "{missing}");

    let malformed = habeas(temp.path(), &["info", "requirements.malformed"]);
    assert!(malformed.status.success(), "{:?}", malformed);
    let malformed = String::from_utf8(malformed.stdout).unwrap();
    assert!(
        malformed.contains("## Unreadable evidence record"),
        "{malformed}"
    );
    assert!(malformed.contains("```json\n{broken\n```"), "{malformed}");
}
Input 5: outline tests/commands.rs fn[status_and_info_accept_a_definition_selection]
// {test}`requirements.cli.status`
// {test}`requirements.cli.info`
// {test}`requirements.cli.definition_glob_search`
#[test]
fn status_and_info_accept_a_definition_selection() {
    let temp = fixture();
    for (command, usage) in [("status", "[SELECTION]"), ("info", "<SELECTION>")] {
        let help = habeas(temp.path(), &[command, "--help"]);
        assert!(help.status.success(), "{help:?}");
        let help = String::from_utf8(help.stdout).unwrap();
        assert!(help.contains(usage), "{help}");
        assert!(
            help.contains("A full requirement or example name, or a definition glob"),
            "{help}"
        );
    }
    let status = habeas(temp.path(), &["status", "requirements.c*", "--all"]);
    assert!(status.status.success(), "{status:?}");
    let status = String::from_utf8(status.stdout).unwrap();
    assert!(
        status.contains("| `requirements.case` (example)"),
        "{status}"
    );
    assert!(!status.contains("| `requirements.ready`"), "{status}");
    let info = habeas(temp.path(), &["info", "requirements.case"]);
    assert!(info.status.success(), "{info:?}");
    let info = String::from_utf8(info.stdout).unwrap();
    assert!(info.starts_with("# `requirements.case`\n"), "{info}");
    assert!(!info.contains("# `requirements.ready`"), "{info}");
}
Input 6: outline tests/commands.rs fn[definition_glob_lists_a_requirement_and_an_example_in_info_and_status]
  • File: tests/commands.rs
  • Selector: fn[definition_glob_lists_a_requirement_and_an_example_in_info_and_status]
  • Kind: fn
  • tests/commands.rs:745–813
// {test}`requirements.cli.definition_glob_search`
#[test]
fn definition_glob_lists_a_requirement_and_an_example_in_info_and_status() {
    let temp = TempDir::new().unwrap();
    let root = temp.path();
    fs::create_dir_all(root.join("md")).unwrap();
    fs::create_dir_all(root.join("evidence")).unwrap();
    fs::write(root.join("Cargo.toml"), "[package]\nname = \"fixture\"\n").unwrap();
    fs::write(root.join("book.toml"), "[book]\nsrc = \"md\"\n").unwrap();
    fs::write(
        root.join("md/foo.md"),
        ":::{req} ready\nReady MUST work.\n:::\n\n:::{example} case\nGiven ready, it works.\n:::\n",
    )
    .unwrap();
    fs::write(
        root.join("md/bar.md"),
        ":::{req} other\nOther MUST work.\n:::\n",
    )
    .unwrap();
    fs::write(
        root.join("evidence/foo.ready.json"),
        json!({
            "requirement": "Ready MUST work.",
            "determination": false,
            "rationale": "Not yet.",
            "references": habeas::reference_set_digest_for(root, "foo.ready").unwrap(),
            "inputs": []
        })
        .to_string(),
    )
    .unwrap();

    let info = habeas(root, &["info", "foo.*"]);
    assert!(info.status.success(), "{info:?}");
    let info = String::from_utf8(info.stdout).unwrap();
    assert!(info.starts_with("# `foo.case`\n"), "{info}");
    assert!(
        info.contains("## Example\n\n> Given ready, it works."),
        "{info}"
    );
    assert!(info.contains("# `foo.ready`\n"), "{info}");
    assert!(
        info.contains("## Requirement\n\n> Ready MUST work."),
        "{info}"
    );
    assert!(!info.contains("bar.other"), "{info}");

    let status = habeas(root, &["status", "foo.*", "--all"]);
    assert!(status.status.success(), "{status:?}");
    let status = String::from_utf8(status.stdout).unwrap();
    let row = |name: &str| {
        status
            .lines()
            .find(|line| line.starts_with(&format!("| `{name}`")))
            .unwrap_or_else(|| panic!("{name} missing: {status}"))
            .to_owned()
    };
    let case = row("foo.case");
    assert!(
        case.contains("(example)") && case.contains("| Missing"),
        "{case}"
    );
    let ready = row("foo.ready");
    assert!(
        ready.contains("(requirement)") && ready.contains("| Determination false"),
        "{ready}"
    );
    assert!(!status.contains("`bar.other`"), "{status}");
}

Referenced definitions

Input 2: requirements selection requirements.cli.info
:::{req} info
`habeas info <selection>` MUST show the requirements and named examples matched by the {term}`requirements.references.definition_selection`. It MUST print matches in full-name order as Markdown with the same kind-labeled definition, Validation findings, Rationale, and Inputs structure and evidence states as mdBook detail pages, including readable output for missing or invalid evidence. It MUST work without a requirements index directive and report an invalid selection or no matches clearly. Habeas's bundled agent guidance MUST tell agents they can use this command to inspect a requirement or named example.
:::
Input 3: requirements selection requirements.cli.status
:::{req} status
`habeas status [<selection>] [--all] [--verbose] [--coverage]` MUST consider requirements and named examples matched by the {term}`requirements.references.definition_selection`; without a selection it MUST consider every definition. By default, it MUST list matching definitions in full-name order when their evidence is missing, has a false determination, or fails the same evidence and reference checks as `habeas::validate()`. It MUST summarize FIXME judgments under {cite}`requirements.cli.fixme_summary`, with accepted FIXME subjects listed individually only when `--verbose` or `--all` is selected. `--all` MUST list every matching definition with its kind and evidence state. Every form MUST show validation findings, the coverage report under {cite}`requirements.references.coverage.report`, using its node-count summary by default and showing individual warnings and coverage-history details only with `--coverage`, work from within a Cargo and mdBook project, and report invalid arguments or a supplied selection matching no definition clearly. When files that reference discovery does not consider because they are untracked in a Git worktree contain references, `habeas status` MUST list them with a reminder to stage them with `git add`. Every form MUST also list, in a "Disagreements" section, each selected definition, citation review, and site review whose recorded rationale states that its assessments disagreed under {cite}`requirements.authoring.confirmation`, so those findings are visible although validation accepts them.
:::
Input 7: definition requirements.references.definition_selection
:::{definition} definition_selection
:phrase: definition selection

A full requirement or example name, or a definition glob, identifying the
requirements and named examples it matches under
{cite}`requirements.references.definition_globs`. A name without `*` selects
exactly that definition.
:::

Other sources

Input 1: requirements selection requirements.cli.definition_glob_search
:::{example} definition_glob_search
Given a requirement `foo.ready` and a named example `foo.case`, `habeas info 'foo.*'` displays both, and `habeas status 'foo.*' --all` lists both with their kinds and evidence states. {cite}`requirements.cli.info` {cite}`requirements.cli.status`
:::