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.distributed_guidance.queries

Requirements index · View definition

evidence Valid

Requirement

The bundled skills MUST direct agents to write site queries that select every place the obligation applies and no others, violation queries for every kind of construct that could break it, and, for every query, match and no_match snippets that test its conditions.

Rationale

The requirement has three obligations for the bundled skills. They must direct agents to (1) write site queries that select every place the obligation applies and no others, (2) write violation queries for every kind of construct that could break it, and (3) give every query match and no_match snippets that test its conditions.

The marked test is tests/authoring_cli.rs#fn[bundled_skills_direct_exact_site_queries_violation_queries_and_snippets]. It reads the ## Do section of the habeas skill’s references/distributed-requirements.md through distributed_reference() and section(). section() collapses whitespace and stops at the next heading, so the assertions apply only to the Do list. assert_text then asserts that each of these phrases appears, and it panics if one is missing:

  • “check that the site queries select every place the obligation applies and no others” covers obligation 1.
  • “Write a violation query, with within naming the site query, for every kind of construct that could break the obligation” covers obligation 2, including “every kind of construct”.
  • “Give every query match and no_match snippets that test its conditions” covers obligation 3.
  • “This applies to violation queries too.” covers obligation 3 for violation queries, so “every query” includes them.

I read the reference’s ## Do section. It contains these directives, and the requirement’s :impl: anchor names this file.

bundled_skills_give_distributed_guidance_as_do_and_dont_lists also checks that the Do list contains the violation-query, snippet and site-query items. It is marked for a different requirement, so I treated it only as supporting evidence.

The requirement is about whether the skill text contains directives. For that, a text-presence assertion on the right section is the appropriate check. It would fail if any of the three directives were removed or moved out of the Do list. The requirement does not specify how snippets should be written, such as nearby-code no_match examples, so I did not treat those as untested obligations.

I found no gaps and no acknowledgments are needed.

Inputs

Implementation

Input 3: outline assets/skills/habeas/references/distributed-requirements.md section[Distributed%20requirements]/section[Do]
## Do

- Make a requirement distributed only when its obligation applies on its own at
  each site; when particular code carries out the requirement as a whole, use
  `{impl}` there.
- Describe sites exactly as the site queries select them. When a query relies on
  a convention, such as how a variable is named, state the convention as an
  obligation, so code that breaks it is a real gap you fix in the code.
- Separate obligations each site upholds from obligations particular code
  carries out, and mark that code `{impl}`.
- State the requirement's scope in its text, and use `paths` and `exclude` for
  scope a rule cannot see, such as authoring code outside validation.
- Give every query `match` and `no_match` snippets that test its conditions the
  way you would test code: `match` snippets for what it selects, and `no_match`
  snippets for nearby code it must not select, such as the right type with the
  wrong name. A condition needs no snippet of its own. This applies to violation
  queries too.
- Write a violation query, with `within` naming the site query, for every kind
  of construct that could break the obligation, such as each early exit in a
  function that must keep going.
- Before the habeas-requirements review (its step 3), check that the site
  queries select every place the obligation
  applies and no others: think about places they could miss, such as a list
  held in a local variable or under another name, and places they select that
  the obligation does not cover. Widen or narrow the query, or state the
  convention as an obligation so a miss becomes a code gap. The requirement's
  review searches for both.
- Present the queries and snippets with the requirement text when reviewing it
  with the user.
- Check with `habeas info <full-name>` that the sites are the ones you expect.
- Let `habeas author --all` author the site reviews.

Tests

Input 2: outline tests/authoring_cli.rs fn[bundled_skills_direct_exact_site_queries_violation_queries_and_snippets]
// {test}`requirements.cli.distributed_guidance.queries`
#[test]
fn bundled_skills_direct_exact_site_queries_violation_queries_and_snippets() {
    assert_text(
        "Do list",
        &section(distributed_reference(), "## Do"),
        &[
            "check that the site queries select every place the obligation applies and no others",
            "Write a violation query, with `within` naming the site query, for every kind of construct that could break the obligation",
            "Give every query `match` and `no_match` snippets that test its conditions",
            "This applies to violation queries too.",
        ],
    );
}

Other sources

Input 1: requirements selection requirements.cli.distributed_guidance.queries
:::{req} distributed_guidance.queries
The bundled skills MUST direct agents to write site queries that select every place the obligation applies and no others, violation queries for every kind of construct that could break it, and, for every query, `match` and `no_match` snippets that test its conditions.
:::
Input 4: outline tests/authoring_cli.rs fn[bundled_skills_give_distributed_guidance_as_do_and_dont_lists]
// {test}`requirements.cli.distributed_guidance.lists`
#[test]
fn bundled_skills_give_distributed_guidance_as_do_and_dont_lists() {
    let reference = distributed_reference();
    for (heading, prefix) in [("## Do", "- "), ("## Don't", "- Don't ")] {
        let (_, rest) = reference.split_once(&format!("\n{heading}\n")).unwrap();
        let list = rest.split("\n## ").next().unwrap();
        let items = list
            .lines()
            .filter(|line| line.starts_with("- "))
            .collect::<Vec<_>>();
        assert!(items.len() >= 2, "{heading}");
        for item in &items {
            assert!(item.starts_with(prefix), "{heading}: {item}");
            if heading == "## Do" {
                assert!(!item.starts_with("- Don't "), "{heading}: {item}");
            }
        }
    }
    assert_text(
        "Do list",
        &section(reference, "## Do"),
        &[
            "- Make a requirement distributed only when",
            "- Separate obligations each site upholds",
            "- Write a violation query",
            "- Give every query `match` and `no_match` snippets",
            "check that the site queries select every place the obligation applies and no others",
            "- Describe sites exactly as the site queries select them",
            "- Let `habeas author --all` author the site reviews.",
        ],
    );
    assert_text(
        "Don't list",
        &section(reference, "## Don't"),
        &[
            "- Don't describe sites more broadly",
            "- Don't state a per-site obligation",
            "- Don't reference the distributed requirement from a site",
            "- Don't re-run a false site review for a different result",
        ],
    );
}