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.authoring.finish_search.description

Requirements index · View definition

evidence Valid

Requirement

The model-facing search and finish_search tool descriptions MUST give the same selection guidance as cite requirements.authoring.search_accounting.instructions.

Rationale

Obligation. requirements.authoring.finish_search.description says the model-facing search and finish_search tool descriptions must give the same selection guidance as requirements.authoring.search_accounting.instructions. That guidance has four parts:

  • Include a tag only when its snippet information was used to justify the conclusion without an additional source read.
  • Entries whose source was read may be omitted, and including them is harmless.
  • Use used:[] when no entries qualify, including for an empty search.
  • Close every delivered search before submitting. finish_search records dependencies and does not request more source.

The search tools that deliver snippets are ripgrep and ast_grep. These are the “search” descriptions the requirement covers.

Test. src/authoring/tools.rs#mod[tests]/fn[finish_search_advertises_the_accounting_schema_and_selection_rule] carries the {test} reference to the subject.

  • For finish_search, it looks up the tool in definitions() and asserts that its description contains these phrases:
    • “snippets you used to justify your conclusion without an additional source read”
    • “Entries whose source you also read may be omitted; including them is harmless”
    • “Use used:[] when no entries qualify, including an empty search”
    • “Every delivered search must be finished before submission”
    • “no additional source is delivered”
    • the result form and an example call
  • For both ripgrep and ast_grep, it asserts that each description contains these phrases:
    • “tags whose snippets you used to justify your conclusion without an additional source read”
    • “Entries whose source you also read may be omitted; including them is harmless”
    • “Use an empty used list if no entries qualify”
    • “Before submitting, call finish_search”

Mapping.

  • The “used to justify without an additional source read” criterion is asserted in all three descriptions.
  • The “read entries may be omitted, including them harmless” clause is asserted in all three.
  • The used:[] / empty-list clause is asserted in all three.
  • The “close every search before submitting” duty is asserted in the finish_search description (“Every delivered search must be finished before submission”) and in both search descriptions (“Before submitting, call finish_search”).
  • The “does not request more source” clause is asserted in the finish_search description as “no additional source is delivered”. The search descriptions add the related statement that selected items become dependencies without another source read. That statement is not asserted, but the requirement asks for the same selection guidance, not for every sentence.

Cross-check. I read definitions in src/authoring/tools.rs. The actual ripgrep and ast_grep descriptions contain these phrases, so the assertions check real text. No other search tool exists. references and habeas are not result-delivering search tools.

Gaps. The test uses substring assertions rather than the exact instruction text. The requirement asks for the same guidance, not identical wording, so this is appropriate. A description that dropped or contradicted any of the key selection rules would fail the test. I found no unacknowledged gap and no marking gap.

Inputs

Implementation

Input 4: outline src/authoring/tools.rs fn[definitions]
// {impl}`requirements.authoring.file_discovery`
// {impl}`requirements.authoring.structural_search`
// {impl}`requirements.configuration.evidence_paths`
// {impl}`requirements.authoring.generated_inputs`
// {impl}`requirements.authoring.outline_tool`
// {impl}`requirements.authoring.reference_index`
// {impl}`requirements.authoring.github_reads`
// {impl}`requirements.authoring.finish_search`
// {impl}`requirements.authoring.finish_search.description`
// {impl}`requirements.authoring.tool_descriptions.common_case`
// {impl}`requirements.authoring.tool_descriptions.special_cases`
pub(crate) fn definitions() -> Vec<Value> {
    // Providers such as Anthropic require a plain object at the schema root.
    // Describe the alternative forms here and enforce them in read().
    let definitions = vec![
        json!({
            "name": "habeas",
            "description": "Read project source as evidence. Supply exactly one request form: file + line_start (optional line_end), file + item, requirements, or definition. Do not combine forms. Paths are project-relative. A line range is one-based and inclusive (omitted line_end reads through EOF) and returns {inputs, definitions}: the innermost outline nodes covering those lines, each with its item selector, kind, and source text, e.g. {\"file\":\"src/lib.rs\",\"line_start\":10,\"line_end\":20}. Line numbers only locate sources: results never give line numbers, and evidence records each node's selector and structural hash. Cite code by file and selector. The item form reads one outline node and returns {input, definitions}, e.g. {\"file\":\"src/lib.rs\",\"item\":\"impl[Thing]/fn[run]\"}; use the outline tool to list a file's selectors. Selectors are /-separated paths from the file's root: kind[name] for named nodes (Rust trait impls use impl[Thing/Trait]), kind@hash for anonymous nodes such as use declarations and plain-text lines (line@hash), and #N (one-based) for otherwise identical siblings; the empty item selects the whole file. Characters %, [, ], /, #, @ and whitespace in names are percent-encoded UTF-8 bytes. The requirements form takes a definition selection: a full requirement or example name, or a glob matching complete names where * matches any characters including dots, e.g. {\"requirements\":\"requirements.cli.*\"}. Definition reads use the full terminology name, e.g. {\"definition\":\"glossary.command\"}. The requirements and definition forms return {input, definitions}: the selected input and the terminology it needs.",
            "parameters": {"type":"object", "properties": {
                "file":{"type":"string"},
                "line_start":{"type":"integer","minimum":1},
                "line_end":{"type":"integer","minimum":1},
                "item":{"type":"string"},
                "requirements":{"type":"string"},
                "definition":{"type":"string"}
            }, "additionalProperties":false}
        }),
        json!({
            "name": "list_files", "description": "List the immediate files and directories of a project-relative directory (default .). The result is an array of {path, kind}, where kind is file or directory; returned paths can be listed or read in another call. Use list_files for directory entries and outline for selectable nodes in one file. Directory listings are not evidence inputs.",
            "parameters":{"type":"object","properties":{"path":{"type":"string","default":"."}},"additionalProperties":false}
        }),
        json!({
            "name":"outline", "description":"List a file's outline; file is a project-relative path. The result contains its selectable nodes nested by ancestry, in source order, each with its item selector (for habeas {file, item} reads), kind, and name (null when anonymous), and no line numbers. Rust, Python, TypeScript, CSS, Markdown, TOML, and YAML files have language outlines; other text files list one line node per nonblank line. Results contain no source text and are not evidence inputs; read the nodes you rely on with habeas.",
            "parameters":{"type":"object","properties":{"file":{"type":"string"}},"required":["file"],"additionalProperties":false}
        }),
        json!({
            "name":"ripgrep", "description":"Search a project-relative file or directory (default .) using ripgrep regex syntax and case-sensitive matching. Use ripgrep for text patterns, ast_grep for syntax-tree rules, and references for requirement-reference sites. Account for snippets you rely on with finish_search. The result is {search_id, matches: [{tag, file, item, kind, lines: [{text, matched}]}]}: one entry for each innermost outline node containing a match (a match in a comment belongs to the node the comment belongs to), with the node's item selector and kind, and its matching lines (matched true) plus context lines before and after each match (default 2; zero means matches only), in source order and without line numbers. Windows stop at item boundaries, overlapping windows are merged within each item, and a line with text \"…\" and matched false separates windows within one node. Results carry no definitions. Before submitting, call finish_search with the result UUID and the tags whose snippets you used to justify your conclusion without an additional source read. Entries whose source you also read may be omitted; including them is harmless. Use an empty used list if no entries qualify. Selected items become evidence dependencies without another source read. No matches returns an empty matches array. With referencing {selection, roles, scope}, search only sources within path that carry a reference in one of roles (impl, test, cite, or fixme; default [impl, test, cite]) to a requirement or example the selection matches (a full name, or a glob where * matches any characters including dots), including :impl: and :test: declaration anchors: scope node searches only the outline nodes that contain or are named by those references, and scope file (the default) their whole files, e.g. {\"pattern\":\"errors\",\"referencing\":{\"selection\":\"requirements.ci.*\",\"roles\":[\"impl\"],\"scope\":\"node\"}}.",
            "parameters":{"type":"object","properties":{"pattern":{"type":"string"},"path":{"type":"string","default":"."},"context":{"type":"integer","minimum":0,"default":2},"referencing":reference_scope_schema()},"required":["pattern"],"additionalProperties":false}
        }),
        json!({
            "name":"ast_grep", "description":"Search syntax trees in process with an ast-grep rule. Use ripgrep for text patterns, ast_grep for syntax-tree rules, and references for requirement-reference sites. Supply exactly one form: {language, rule, path (default .), referencing (optional)} or {query}. language is one of rust, python, typescript, tsx, css, markdown, toml, or yaml, matched with Habeas's pinned grammars; only files of that language are searched. rule is an object holding the keys of an ast-grep rule file's rule core, written as JSON: rule (required), and optional utils (named rules) and constraints (metavariable name to rule). A rule object combines atomic rules: pattern (code with metavariables, where $A matches one node, $$$A any number of nodes, and $_ one node without capturing), kind (a grammar node kind such as function_item), regex (a Rust regex the node's whole text must match), and nthChild; relational rules: inside, has, precedes, and follows, each taking a rule plus optional stopBy (neighbor, the default, end, or a rule) and field; and composite rules: all, any, not, and matches (a utils name). Patterns parse as standalone code, so a fragment that does not parse on its own, such as a type or parameter, needs the context and selector form: pattern: {context: \"fn f(x: &mut Vec<String>) {}\", selector: reference_type} parses context and matches the node of kind selector within it. Example: {\"language\":\"rust\",\"rule\":{\"rule\":{\"pattern\":\"$X.unwrap()\",\"inside\":{\"kind\":\"function_item\",\"stopBy\":\"end\"}}}}. path selects a project-relative file or directory (default .); referencing works as for ripgrep, and results are ordered by path and then line. The query form, e.g. {\"query\":\"requirements.ci.errors/error_accumulators\"}, runs a query a distributed requirement declares, named <full-name>/<query-name>, exactly as validation runs it, including its paths, exclude, and within, and returns each match's site. The result has ripgrep's form, {search_id, matches: [{tag, file, item, kind, lines: [{text, matched}]}]}: one entry for each innermost outline node containing a match (a match in a comment belongs to the node the comment belongs to; a query match belongs to its site), with the node's item selector and kind, and the matched lines, without line numbers. Results carry no definitions. Before submitting, call finish_search with the result UUID and the tags whose snippets you used to justify your conclusion without an additional source read. Entries whose source you also read may be omitted; including them is harmless. Use an empty used list if no entries qualify. Selected items become evidence dependencies without another source read. No matches returns an empty matches array.",
            "parameters":{"type":"object","properties":{"language":{"type":"string","enum":crate::structural::QueryLanguage::names()},"rule":{"type":"object"},"path":{"type":"string","default":"."},"referencing":reference_scope_schema(),"query":{"type":"string"}},"additionalProperties":false}
        }),
        json!({
            "name":"references", "description":"Locate definitions and reference sites without reading their text. Without selection, return every requirement and named example name with its kind and empty sites. With selection (a full name or a glob where * matches any characters including dots), return the selected names/kinds plus reference sites: definition name, role, file, and item selector, without line numbers. roles filters sites and anchors by impl, cite, or test (default all three); {impl} marks implementations, {cite} related sources, and {test} tests. For example {\"selection\":\"requirements.cli.status\",\"roles\":[\"impl\"]} locates only implementations. Repeated roles have no effect; [] returns names/kinds only. An :impl: or :test: anchor is reported with item null for a whole file or its selector for a node. Results contain no requirement text, example text, commentary, or source text and are not evidence inputs. Request needed source with habeas to read and record it.",
            "parameters":{"type":"object","properties":{
                "selection":{"type":"string"},
                "roles":{"type":"array","items":{"type":"string","enum":["impl","cite","test"]},"default":["impl","cite","test"]}
            },"additionalProperties":false}
        }),
        crate::github::tool_definition(),
        json!({
            "name":"next_page", "description":"Return the following page of a paged result of habeas (line-range form), list_files, outline, ripgrep, ast_grep, or references, in the same shape as its first page. token is the page's next value, e.g. {\"token\":\"abc123\"}. Tokens are opaque.",
            "parameters":{"type":"object","properties":{"token":{"type":"string"}},"required":["token"],"additionalProperties":false}
        }),
        json!({
            "name":"finish_search",
            "description":"Close a delivered search and record dependencies for snippets you used to justify your conclusion without an additional source read. search_id is the result's UUID and used is an array of its short entry tags, e.g. {\"search_id\":\"11111111-1111-4111-8111-111111111111\",\"used\":[\"1\"]}. Entries whose source you also read may be omitted; including them is harmless. Use used:[] when no entries qualify, including an empty search. Every delivered search must be finished before submission. The result is {search_id, finished:true}; no additional source is delivered.",
            "parameters":{"type":"object","properties":{
                "search_id":{"type":"string","format":"uuid"},
                "used":{"type":"array","items":{"type":"string"}}
            },"required":["search_id","used"],"additionalProperties":false}
        }),
    ];
    definitions
}

Tests

Input 3: outline src/authoring/tools.rs mod[tests]/fn[finish_search_advertises_the_accounting_schema_and_selection_rule]
    // {test}`requirements.authoring.finish_search`
    // {test}`requirements.authoring.finish_search.description`
    // {test}`requirements.authoring.tool_descriptions.common_case`
    #[test]
    fn finish_search_advertises_the_accounting_schema_and_selection_rule() {
        let tools = definitions();
        let finish = tools
            .iter()
            .find(|tool| tool["name"] == "finish_search")
            .unwrap();
        assert_eq!(
            finish["parameters"],
            json!({"type":"object","properties":{
            "search_id":{"type":"string","format":"uuid"},
            "used":{"type":"array","items":{"type":"string"}}
        },"required":["search_id","used"],"additionalProperties":false})
        );
        let description = finish["description"].as_str().unwrap();
        for phrase in [
            "snippets you used to justify your conclusion without an additional source read",
            "Entries whose source you also read may be omitted; including them is harmless",
            "Use used:[] when no entries qualify, including an empty search",
            "Every delivered search must be finished before submission",
            "{search_id, finished:true}",
            "no additional source is delivered",
            "search_id is the result's UUID and used is an array of its short entry tags",
            r#"{"search_id":"11111111-1111-4111-8111-111111111111","used":["1"]}"#,
        ] {
            assert!(description.contains(phrase), "{phrase}: {description}");
        }
        for name in ["ripgrep", "ast_grep"] {
            let description =
                tools.iter().find(|tool| tool["name"] == name).unwrap()["description"]
                    .as_str()
                    .unwrap();
            for phrase in [
                "tags whose snippets you used to justify your conclusion without an additional source read",
                "Entries whose source you also read may be omitted; including them is harmless",
                "Use an empty used list if no entries qualify",
                "Before submitting, call finish_search",
                "Use ripgrep for text patterns, ast_grep for syntax-tree rules, and references for requirement-reference sites",
            ] {
                assert!(
                    description.contains(phrase),
                    "{name}: {phrase}: {description}"
                );
            }
        }
    }

Referenced definitions

Input 2: requirements selection requirements.authoring.search_accounting.instructions
:::{req} search_accounting.instructions
The first delivered search result in each assessment MUST include an
`instructions` field containing this text:

```text
Before submitting your assessment, close every delivered search with finish_search({search_id, used:[tags]}). Submission fails while any search remains open. Include a tag only when you used information in its snippet to justify your conclusion without an additional source read. Entries whose source you subsequently read with habeas may be omitted; including them is harmless. Use used:[] when no entries qualify, including for an empty search. finish_search records dependencies and does not request more source.
```
:::

Other sources

Input 1: requirements selection requirements.authoring.finish_search.description
:::{req} finish_search.description
The model-facing search and `finish_search` tool descriptions MUST give the
same selection guidance as
{cite}`requirements.authoring.search_accounting.instructions`.
:::