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.tool_descriptions.common_case

Requirements index · View definition

evidence Valid

Requirement

Each model tool’s description MUST give what the model needs in the common case: what the tool does, when to use it rather than another tool, each argument’s meaning and form, with a short example where the form is not obvious, and the form of a successful result.

Rationale

The reviewed tests adequately check requirements.authoring.tool_descriptions.common_case. I did not read the implementation. I judged only from the supplied tests and the requirement text.

Obligations derived from the requirement. Every model tool’s description must give:

  1. what the tool does;
  2. when to use it rather than another tool;
  3. each argument’s meaning and form, with a short example where the form is not obvious;
  4. the form of a successful result.

Coverage by tool.

  • All tools in definitions(). src/authoring/tools.rs#mod[tests]/fn[descriptions_give_each_argument_and_the_result_form] loops over every advertised tool.
    • It asserts that the description has at least two sentences.
    • It asserts that the description mentions every parameter name.
    • It asserts a per-tool result-form phrase for habeas, list_files, outline, ripgrep, ast_grep, references, next_page, github and finish_search.
    • For list_files, next_page and github it also asserts purpose, argument-form and example phrases, such as {"token":"abc123"} and <owner>/<repo>#<number>.
    • Its list_files phrase “Use list_files for directory entries and outline for selectable nodes in one file” gives when-to-use guidance.
  • habeas. fn[habeas_tool_describes_its_argument_conventions_with_an_example_per_form] asserts the following:
    • the purpose;
    • the “exactly one request form” rule;
    • line-range conventions;
    • the selector syntax;
    • a short example for each of the four request forms;
    • the result shapes;
    • the pointer to the outline tool;
    • the exact parameter key list.
  • outline. fn[outline_tool_is_advertised_with_a_required_file_argument] asserts the schema, the purpose, the file argument’s form, the result contents, and the link to habeas reads.
  • references. fn[references_tool_is_advertised_with_an_optional_selection] asserts the schema, the purpose, the meaning of selection and roles, and the result contents. It also asserts a worked example and the pointer to habeas.
  • finish_search. fn[finish_search_advertises_the_accounting_schema_and_selection_rule] asserts the argument meanings, an example, and the result {search_id, finished:true}. It also asserts the cross-tool guidance in the ripgrep and ast_grep descriptions.
  • ripgrep. fn[ripgrep_tool_is_advertised_with_its_interface_and_conventions] asserts the schema, argument defaults and semantics, the result form, a worked example, and when to use it rather than ast_grep.
  • ast_grep. fn[ast_grep_tool_is_advertised_with_both_forms_and_rule_syntax] asserts the two request forms, the rule syntax, the result form, and examples of both forms.
  • Submission tools. src/authoring/mod.rs#mod[submission_description_tests]/fn[submission_descriptions_explain_arguments_and_successful_completion] covers submit_judgment and submit_verification, each with and without the site variant.
    • It asserts that every argument name appears in the description.
    • It asserts phrases for the form and meaning of the rationale, the identification of locations, and the owner/repo#123 issue form.
    • It asserts the {"FIXME":[...]} form for submit_judgment, and the real, acknowledged and [] forms for submit_verification.
    • It asserts that applies appears only in the site variant.
    • It asserts the successful-completion form: “A successful submission ends”.

Assessment.

  • The assertions are content checks on the exact advertised descriptions. A description that dropped an argument, an example, or the result form would fail.
  • The checks are phrase-based, so they cannot prove prose quality. That is inherent in checking this requirement, and the phrases chosen target the requirement’s elements.
  • I found no uncovered tool, argument class, or result form.
  • No acknowledgments apply, and none are needed.

Inputs

Tests

Input 2: outline src/authoring/mod.rs mod[submission_description_tests]/fn[submission_descriptions_explain_arguments_and_successful_completion]
  • File: src/authoring/mod.rs
  • Selector: mod[submission_description_tests]/fn[submission_descriptions_explain_arguments_and_successful_completion]
  • Kind: fn
  • src/authoring/mod.rs:1178–1225
    // {test}`requirements.authoring.tool_descriptions.common_case`
    // {test}`requirements.authoring.no_line_numbers`
    #[test]
    fn submission_descriptions_explain_arguments_and_successful_completion() {
        for tool in ["submit_judgment", "submit_verification"] {
            for site in [false, true] {
                let definitions = super::tool_definitions_with(tool, site).unwrap();
                let value = serde_json::to_value(definitions.last().unwrap()).unwrap();
                let description = value["description"].as_str().unwrap();
                for argument in value["parameters"]["properties"]
                    .as_object()
                    .unwrap()
                    .keys()
                {
                    assert!(
                        description.contains(argument),
                        "{tool} omits {argument}: {description}"
                    );
                }
                for phrase in [
                    "until one submission is accepted",
                    "source tool",
                    "nonempty explanation",
                    "outline selectors",
                    "never line numbers",
                    "A successful submission ends",
                    "owner/repo#123",
                ] {
                    assert!(
                        description.contains(phrase),
                        "{tool} omits {phrase}: {description}"
                    );
                }
                if tool == "submit_judgment" {
                    assert!(
                        description.contains("true when the subject meets its review criteria")
                    );
                    assert!(description.contains("false when it has an unacknowledged gap"));
                    assert!(description.contains(r#"{"FIXME":["owner/repo#123"]}"#));
                } else {
                    assert!(description.contains("real says whether the alleged gap is real"));
                    assert!(description.contains("acknowledged says whether"));
                    assert!(description.contains("or [] when none apply"));
                }
                assert_eq!(description.contains("applies says whether"), site);
            }
        }
    }
Input 3: outline src/authoring/tools.rs mod[tests]/fn[habeas_tool_describes_its_argument_conventions_with_an_example_per_form]
  • File: src/authoring/tools.rs
  • Selector: mod[tests]/fn[habeas_tool_describes_its_argument_conventions_with_an_example_per_form]
  • Kind: fn
  • src/authoring/tools.rs:3227–3283
    // {test}`requirements.authoring.source_tools`
    // {test}`requirements.authoring.tool_descriptions.common_case`
    #[test]
    fn habeas_tool_describes_its_argument_conventions_with_an_example_per_form() {
        let definitions = definitions();
        let habeas = definitions
            .iter()
            .find(|definition| definition["name"] == "habeas")
            .expect("habeas tool is advertised");
        let description = habeas["description"].as_str().unwrap();
        for phrase in [
            // Request forms and line conventions.
            "Read project source as evidence",
            "Paths are project-relative",
            "use the outline tool to list a file's selectors",
            "exactly one request form",
            "one-based and inclusive",
            "omitted line_end reads through EOF",
            "{inputs, definitions}",
            "{input, definitions}",
            // Outline selector syntax.
            "kind[name]",
            "impl[Thing/Trait]",
            "kind@hash",
            "#N",
            "percent-encoded",
            // Definition selections and full definition names.
            "definition selection",
            "* matches any characters including dots",
            "full terminology name",
            // A short request example for each form.
            r#"{"file":"src/lib.rs","line_start":10,"line_end":20}"#,
            r#"{"file":"src/lib.rs","item":"impl[Thing]/fn[run]"}"#,
            r#"{"requirements":"requirements.cli.*"}"#,
            r#"{"definition":"glossary.command"}"#,
        ] {
            assert!(
                description.contains(phrase),
                "missing {phrase:?}: {description}"
            );
        }
        assert_eq!(
            habeas["parameters"]["properties"]
                .as_object()
                .unwrap()
                .keys()
                .collect::<Vec<_>>(),
            [
                "file",
                "line_start",
                "line_end",
                "item",
                "requirements",
                "definition"
            ]
        );
    }
Input 4: outline src/authoring/tools.rs mod[tests]/fn[outline_tool_is_advertised_with_a_required_file_argument]
    // {test}`requirements.authoring.outline_tool`
    // {test}`requirements.authoring.tool_descriptions.common_case`
    #[test]
    fn outline_tool_is_advertised_with_a_required_file_argument() {
        let definitions = definitions();
        let outline = definitions
            .iter()
            .find(|definition| definition["name"] == "outline")
            .expect("outline tool is advertised");
        assert_eq!(
            outline["parameters"],
            json!({
                "type": "object",
                "properties": {"file": {"type": "string"}},
                "required": ["file"],
                "additionalProperties": false
            })
        );
        let description = outline["description"].as_str().unwrap();
        for phrase in [
            "item selector",
            "List a file's outline",
            "file is a project-relative path",
            "kind",
            "name",
            "no line numbers",
            "no source text",
            "for habeas {file, item} reads",
            "read the nodes you rely on with habeas",
        ] {
            assert!(description.contains(phrase), "{description}");
        }
    }
Input 5: outline src/authoring/tools.rs mod[tests]/fn[references_tool_is_advertised_with_an_optional_selection]
    // {test}`requirements.authoring.reference_index`
    // {test}`requirements.authoring.tool_descriptions.common_case`
    #[test]
    fn references_tool_is_advertised_with_an_optional_selection() {
        let definitions = definitions();
        let references = definitions
            .iter()
            .find(|definition| definition["name"] == "references")
            .expect("references tool is advertised");
        assert_eq!(
            references["parameters"],
            json!({
                "type": "object",
                "properties": {
                    "selection": {"type": "string"},
                    "roles": {"type":"array","items":{"type":"string","enum":["impl","cite","test"]},"default":["impl","cite","test"]}
                },
                "additionalProperties": false
            })
        );
        let description = references["description"].as_str().unwrap();
        for phrase in [
            "{impl}",
            "{cite}",
            "{test}",
            "glob",
            ":impl:",
            "null",
            "Without selection, return every requirement and named example name with its kind and empty sites",
            "a full name or a glob where * matches any characters including dots",
            "roles filters sites and anchors by impl, cite, or test (default all three)",
            "Locate definitions and reference sites without reading their text",
            "[] returns names/kinds only",
            "{impl} marks implementations, {cite} related sources, and {test} tests",
            r#"{"selection":"requirements.cli.status","roles":["impl"]}"#,
            "Request needed source with habeas",
        ] {
            assert!(description.contains(phrase), "{phrase}: {description}");
        }
    }
Input 6: 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}"
                );
            }
        }
    }
Input 7: outline src/authoring/tools.rs mod[tests]/fn[ripgrep_tool_is_advertised_with_its_interface_and_conventions]
    // {test}`requirements.authoring.text_search`
    // {test}`requirements.authoring.tool_descriptions.common_case`
    #[test]
    fn ripgrep_tool_is_advertised_with_its_interface_and_conventions() {
        let definitions = definitions();
        let ripgrep = definitions
            .iter()
            .find(|definition| definition["name"] == "ripgrep")
            .expect("ripgrep tool is advertised");
        assert_eq!(
            ripgrep["parameters"],
            json!({
                "type": "object",
                "properties": {
                    "pattern": {"type": "string"},
                    "path": {"type": "string", "default": "."},
                    "context": {"type": "integer", "minimum": 0, "default": 2},
                    "referencing": {
                        "type": "object",
                        "properties": {
                            "selection": {"type": "string"},
                            "roles": {
                                "type": "array",
                                "items": {"type": "string", "enum": ["impl", "test", "cite", "fixme"]},
                                "default": ["impl", "test", "cite"]
                            },
                            "scope": {"type": "string", "enum": ["node", "file"], "default": "file"}
                        },
                        "required": ["selection"],
                        "additionalProperties": false
                    }
                },
                "required": ["pattern"],
                "additionalProperties": false
            })
        );
        let description = ripgrep["description"].as_str().unwrap();
        for phrase in [
            "ripgrep regex syntax",
            "case-sensitive",
            "default 2",
            "zero means matches only",
            "overlapping windows are merged",
            "Windows stop at item boundaries",
            "Before submitting, call finish_search",
            "{search_id, matches: [{tag, file, item, kind, lines: [{text, matched}]}]}",
            "without line numbers",
            "separates windows within one node",
            "one entry for each innermost outline node containing a match",
            "a match in a comment belongs to the node the comment belongs to",
            "Results carry no definitions",
            "Selected items become evidence dependencies without another source read",
            "No matches returns an empty matches array",
            "With referencing {selection, roles, scope}",
            "Search a project-relative file or directory (default .)",
            "default [impl, test, cite]",
            "including :impl: and :test: declaration anchors",
            "scope node searches only the outline nodes that contain or are named by those references",
            "scope file (the default) their whole files",
            r#"{"pattern":"errors","referencing":{"selection":"requirements.ci.*","roles":["impl"],"scope":"node"}}"#,
        ] {
            assert!(description.contains(phrase), "{phrase:?} in {description}");
        }
    }
Input 8: outline src/authoring/tools.rs mod[tests]/fn[descriptions_give_each_argument_and_the_result_form]
    // {test}`requirements.authoring.tool_descriptions.common_case`
    // {test}`requirements.authoring.tool_descriptions.special_cases`
    #[test]
    fn descriptions_give_each_argument_and_the_result_form() {
        for definition in definitions() {
            let name = definition["name"].as_str().unwrap();
            let description = definition["description"].as_str().unwrap();
            // At least a few sentences.
            assert!(
                description.matches(". ").count() >= 2,
                "{name}: {description}"
            );
            for argument in definition["parameters"]["properties"]
                .as_object()
                .unwrap()
                .keys()
            {
                assert!(
                    description.contains(argument.as_str()),
                    "{name} omits {argument}"
                );
            }
            let result = match name {
                "habeas" => "{input, definitions}",
                "list_files" => "{path, kind}",
                "outline" => "item selector",
                "ripgrep" | "ast_grep" => {
                    "{search_id, matches: [{tag, file, item, kind, lines: [{text, matched}]}]}"
                }
                "references" => "definition name, role, file, and item",
                "next_page" => "same shape",
                "github" => "state (open or closed), title, and body",
                "finish_search" => "{search_id, finished:true}",
                _ => continue,
            };
            assert!(
                description.contains(result),
                "{name} omits its result: {description}"
            );
            let phrases: &[&str] = match name {
                "list_files" => &[
                    "immediate files and directories",
                    "Use list_files for directory entries and outline for selectable nodes in one file",
                    "project-relative",
                    "default .",
                    "listed or read",
                    "not evidence inputs",
                ],
                "next_page" => &[
                    "following page",
                    "habeas (line-range form), list_files, outline, ripgrep, ast_grep, or references",
                    "same shape",
                    "token is the page's next value",
                    "opaque",
                    r#"{"token":"abc123"}"#,
                ],
                "github" => &[
                    "<owner>/<repo>#<number>",
                    "issue or pull request",
                    "one a {fixme} option line names",
                ],
                _ => &[],
            };
            for phrase in phrases {
                assert!(
                    description.contains(phrase),
                    "{name}: missing {phrase}: {description}"
                );
            }
        }
    }
Input 9: outline src/authoring/tools.rs mod[tests]/fn[ast_grep_tool_is_advertised_with_both_forms_and_rule_syntax]
    // {test}`requirements.authoring.structural_search`
    // {test}`requirements.authoring.result_pages`
    // {test}`requirements.authoring.tool_descriptions.common_case`
    #[test]
    fn ast_grep_tool_is_advertised_with_both_forms_and_rule_syntax() {
        let definitions = definitions();
        let names = definitions
            .iter()
            .map(|definition| definition["name"].as_str().unwrap())
            .collect::<Vec<_>>();
        assert_eq!(
            names,
            [
                "habeas",
                "list_files",
                "outline",
                "ripgrep",
                "ast_grep",
                "references",
                "github",
                "next_page",
                "finish_search"
            ]
        );
        let ast_grep = &definitions[4];
        let ripgrep = &definitions[3];
        assert_eq!(
            ast_grep["parameters"],
            json!({
                "type": "object",
                "properties": {
                    "language": {
                        "type": "string",
                        "enum": ["rust", "python", "typescript", "tsx", "css", "markdown", "toml", "yaml"]
                    },
                    "rule": {"type": "object"},
                    "path": {"type": "string", "default": "."},
                    "referencing": ripgrep["parameters"]["properties"]["referencing"],
                    "query": {"type": "string"}
                },
                "additionalProperties": false
            })
        );
        let description = ast_grep["description"].as_str().unwrap();
        for phrase in [
            "{language, rule, path (default .), referencing (optional)} or {query}",
            "matched with Habeas's pinned grammars",
            "Search syntax trees in process with an ast-grep rule",
            "path selects a project-relative file or directory (default .)",
            "language is one of rust, python, typescript, tsx, css, markdown, toml, or yaml",
            "rule (required), and optional utils (named rules) and constraints",
            "pattern (code with metavariables",
            "kind (a grammar node kind",
            "inside, has, precedes, and follows",
            "all, any, not, and matches",
            "the context and selector form",
            "path selects a project-relative file or directory (default .); referencing works as for ripgrep, and results are ordered by path and then line",
            "named <full-name>/<query-name>, exactly as validation runs it, including its paths, exclude, and within, and returns each match's site",
            "Before submitting, call finish_search",
            "{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",
            "the matched lines, without line numbers",
            "Results carry no definitions",
            "Selected items become evidence dependencies without another source read",
            "No matches returns an empty matches array",
            r#"{"language":"rust","rule":{"rule":{"pattern":"$X.unwrap()","inside":{"kind":"function_item","stopBy":"end"}}}}"#,
            r#"{"query":"requirements.ci.errors/error_accumulators"}"#,
        ] {
            assert!(description.contains(phrase), "{phrase:?} in {description}");
        }
    }

Other sources

Input 1: requirements selection requirements.authoring.tool_descriptions.common_case
:::{req} tool_descriptions.common_case
Each model tool's description MUST give what the model needs in the common
case: what the tool does, when to use it rather than another tool, each
argument's meaning and form, with a short example where the form is not
obvious, and the form of a successful result.
:::