requirements.authoring.outline_tool
Requirements index · View definition
Requirement
The harness MUST expose an
outlinetool with this interface:outline({ file: String }) -> Array<OutlineEntry> OutlineEntry { item: String, kind: String, name: String?, children: Array<OutlineEntry>, }The tool MUST return the outline of a permitted file in a supported language under
, with each node’s selector under
, its kind, and its name when it is named, nested by outline ancestry and in source order. Results MUST contain no source text or line numbers and MUST NOT become evidence inputs; the model reads the nodes it relies on with the
habeastool. For a file using the plain-text profile, the outline lists itslinenodes. Explicitly requesting an excluded file MUST be handled as a denial under.
Rationale
The three supplied tests in src/authoring/tools.rs cover each obligation that requirements.authoring.outline_tool states itself. I did not request implementation source.
- Interface and arguments.
outline_tool_is_advertised_with_a_required_file_argumentasserts the exact parameter schema: an object with a stringfile,filerequired, and no additional properties. It also checks that the description says the tool returns an item selector, kind, name, no line numbers and no source text, and that the model should read nodes withhabeas.outline_lists_nested_nodes_without_text_or_inputschecks malformed arguments: a missingfile, a non-stringfile, an extra argument, and a nonexistent file. Each returns an error that names the problem. - Entry shape, nesting and order. The same test dispatches
outlineon a Rust file and compares the whole JSON result withassert_eq. The expected result hasstruct[Thing]followed byimpl[Thing]. Theimplentry hasfn[run]nested under it inchildren, and each entry hasitem,kind,nameandchildren. This checks selectors, kind, name, nesting by ancestry and source order. Because the comparison is exact, extra fields such as line numbers would fail it. - No source text. The test asserts that the doc comment text “Docs” is absent from the serialized result.
- No evidence inputs. The test asserts
outline.inputs.is_empty(). The other test assertssources.recorded_inputs().is_empty()after outline requests outside the project. - Plain-text profile. The test outlines
notes.txtcontainingalpha, a blank line andbeta. It asserts two entries, which shows the blank line is skipped. Every entry has kindline, a null name and an item starting withline@, and there is noline_startfield. - Excluded file handled as a denial. With
notes.txtdisallowed inhabeas.toml, the test asserts theoutlinecall returns an error of kindPermissionDenied. The error text namesnotes.txtand says “disallowed”, which matches theread_denialrequirement to name the path and the reason.unpermitted_requests_outside_the_project_are_recoverable_tool_errorsalso exercisesoutlineon an external path. It asserts the error says “outside the project” and is notPermissionDenied, and that no inputs are recorded.
The language list, the syntax-error behaviour, the #N and percent-encoding selector rules, and the structural hash belong to the cited requirements.references.outlines and requirements.references.outline_selectors. The checks on the denial error itself belong to requirements.authoring.read_denial. All of these are cited context, not obligations to retest here.
I found no unacknowledged gap.
Inputs
Tests
Input 5: outline src/authoring/tools.rs mod[tests]/fn[unpermitted_requests_outside_the_project_are_recoverable_tool_errors]
- File:
src/authoring/tools.rs - Selector:
mod[tests]/fn[unpermitted_requests_outside_the_project_are_recoverable_tool_errors] - Kind:
fn src/authoring/tools.rs:3086–3144
// {test}`requirements.authoring.read_denial`
// {test}`requirements.authoring.source_tools`
// {test}`requirements.authoring.file_discovery`
// {test}`requirements.authoring.text_search`
// {test}`requirements.authoring.outline_tool`
// {test}`requirements.authoring.tool_descriptions.special_cases`
#[test]
fn unpermitted_requests_outside_the_project_are_recoverable_tool_errors() {
let root = project();
let external = tempfile::tempdir().unwrap();
fs::write(external.path().join("lib.rs"), "fn external() {}\n").unwrap();
let file = external.path().join("lib.rs");
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let requests = [
("habeas", json!({"file": file, "line_start": 1})),
("habeas", json!({"file": file, "item": "fn[external]"})),
("list_files", json!({"path": external.path()})),
("outline", json!({"file": file})),
(
"ripgrep",
json!({"path": external.path(), "pattern": "external"}),
),
];
for (name, arguments) in &requests {
let error = dispatch(&sources, name, arguments).err().unwrap();
assert_ne!(
error.kind(),
io::ErrorKind::PermissionDenied,
"{name}: {error}"
);
assert!(error.to_string().contains("outside the project"), "{error}");
}
assert!(sources.recorded_inputs().is_empty());
// A matching disallow still aborts, as do in-project denials.
fs::write(
root.path().join("habeas.toml"),
format!(
"version = 1\n[evidence]\ndisallow = [{:?}]\n",
external.path().to_str().unwrap()
),
)
.unwrap();
fs::create_dir_all(root.path().join("evidence")).unwrap();
fs::write(root.path().join("evidence/old.json"), "{}\n").unwrap();
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
for (name, arguments) in &requests[..1] {
let error = dispatch(&sources, name, arguments).err().unwrap();
assert_eq!(error.kind(), io::ErrorKind::PermissionDenied, "{error}");
}
let error = dispatch(
&sources,
"habeas",
&json!({"file": "evidence/old.json", "item": ""}),
)
.err()
.unwrap();
assert_eq!(error.kind(), io::ErrorKind::PermissionDenied, "{error}");
}
Input 6: outline src/authoring/tools.rs mod[tests]/fn[outline_tool_is_advertised_with_a_required_file_argument]
- File:
src/authoring/tools.rs - Selector:
mod[tests]/fn[outline_tool_is_advertised_with_a_required_file_argument] - Kind:
fn src/authoring/tools.rs:3285–3317
// {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 7: outline src/authoring/tools.rs mod[tests]/fn[outline_lists_nested_nodes_without_text_or_inputs]
- File:
src/authoring/tools.rs - Selector:
mod[tests]/fn[outline_lists_nested_nodes_without_text_or_inputs] - Kind:
fn src/authoring/tools.rs:3360–3420
// {test}`requirements.authoring.outline_tool`
// {test}`requirements.references.outlines`
// {test}`requirements.authoring.no_line_numbers`
// {test}`requirements.authoring.read_denial`
#[test]
fn outline_lists_nested_nodes_without_text_or_inputs() {
let root = project();
fs::write(
root.path().join("src/lib.rs"),
"/// Docs.\nstruct Thing;\n\nimpl Thing {\n fn run(&self) {}\n}\n",
)
.unwrap();
fs::write(root.path().join("notes.txt"), "alpha\n\nbeta\n").unwrap();
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let outline = dispatch(&sources, "outline", &json!({"file":"src/lib.rs"})).unwrap();
assert!(outline.inputs.is_empty());
assert_eq!(
outline.result,
json!([
{"item": "struct[Thing]", "kind": "struct", "name": "Thing", "children": []},
{"item": "impl[Thing]", "kind": "impl", "name": "Thing", "children": [
{"item": "impl[Thing]/fn[run]", "kind": "fn", "name": "run", "children": []},
]},
])
);
assert!(!outline.result.to_string().contains("Docs"));
let plain = dispatch(&sources, "outline", &json!({"file":"notes.txt"})).unwrap();
let entries = plain.result.as_array().unwrap();
assert_eq!(entries.len(), 2);
assert!(entries.iter().all(|entry| entry["kind"] == "line"
&& entry["name"].is_null()
&& entry["item"].as_str().unwrap().starts_with("line@")));
assert!(entries[1].get("line_start").is_none());
for (arguments, message) in [
(json!({"file":"missing.rs"}), "missing.rs"),
(json!({}), "file"),
(json!({"file":1}), "file"),
(json!({"file":"src/lib.rs", "extra":true}), "extra"),
] {
let error = dispatch(&sources, "outline", &arguments).err().unwrap();
assert!(error.to_string().contains(message), "{arguments}: {error}");
}
let error = dispatch(&sources, "outline", &json!({})).err().unwrap();
assert!(
error.to_string().contains("file must be a string"),
"{error}"
);
fs::write(
root.path().join("habeas.toml"),
"version = 1\n[evidence]\ndisallow = ['notes.txt']\n",
)
.unwrap();
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let error = dispatch(&sources, "outline", &json!({"file":"notes.txt"}))
.err()
.unwrap();
assert_eq!(error.kind(), io::ErrorKind::PermissionDenied, "{error}");
assert!(error.to_string().contains("notes.txt"), "{error}");
assert!(error.to_string().contains("disallowed"), "{error}");
}
Referenced definitions
Input 2: requirements selection requirements.references.outlines
requirements.references.outlines:md/requirements/references.md:358–378
:::{req} outlines
Habeas MUST parse Rust, Python, TypeScript, CSS, Markdown, TOML, and YAML
sources with pinned tree-sitter grammars, selected by file extension compared
case-insensitively. A source with any syntax error MUST fail to parse, reporting
the line of its first error. Every
other text file MUST use a plain-text profile in which each line that is not
blank is an anonymous outline node of kind `line`. Each supported language MUST
have an outline profile that maps grammar node kinds to short outline kind names
and, for each mapped kind, states whether a node is named, and by which fields
or children, or anonymous. Only mapped kinds MUST appear in the outline; other
nodes MUST be transparent, so their outline descendants appear under the
nearest outline ancestor. A profile MAY attach grammar siblings to an outline
node, such as Rust attributes and doc comments preceding an item, so the outline
tree need not match the grammar tree exactly; attached siblings are part of that
node for its line range and hash. Every file's outline MUST have a root node
for the whole file, independent of language. Source in no other outline node,
such as top-level statements no profile maps, MUST belong to the root node;
profiles MUST NOT invent fallback kinds for it. Comments MUST NOT be outline nodes. Profiles MUST be
documented. Upgrading a grammar or profile MAY change outlines and MUST be
treated as a deliberate change.
:::
Input 3: requirements selection requirements.references.outline_selectors
requirements.references.outline_selectors:md/requirements/references.md:380–392
:::{req} outline_selectors
An outline selector MUST be a `/`-separated path of segments from the file's
root node to an outline node; the empty selector MUST select the root node. A
named node's segment MUST be `kind[name]`. An anonymous node's segment MUST be
`kind@hash`, where `hash` is the first twelve hexadecimal digits of its identity
hash under {cite}`requirements.references.structural_hash`. Siblings whose
segments would otherwise be identical MUST be disambiguated by `#N`, their
one-based position among those siblings in source order, except `line` nodes:
identical lines are interchangeable, so a `line` selector MUST resolve when any
line with that content exists in the file. In names, `%`, `[`, `]`, `/`, `#`,
`@`, and whitespace MUST be percent-encoded as UTF-8 bytes, so selectors are
reversible. Line numbers MUST NOT form part of a selector.
:::
Input 4: requirements selection requirements.authoring.read_denial
requirements.authoring.read_denial:md/requirements/authoring.md:701–708
:::{req} read_denial
When source-access policy denies a path that a model tool call names
explicitly, the harness MUST return a tool error naming the path and the reason
it cannot be read, add no evidence input, and continue the assessment.
Discovery and search MUST leave denied candidates out of their entries,
reporting untracked ones under {cite}`requirements.authoring.not_listed`. Malformed tool
arguments and ordinary read failures MUST also return explanatory tool errors.
:::
Other sources
Input 1: requirements selection requirements.authoring.outline_tool
requirements.authoring.outline_tool:md/requirements/authoring.md:790–812
:::{req} outline_tool
The harness MUST expose an `outline` tool with this interface:
```text
outline({ file: String }) -> Array<OutlineEntry>
OutlineEntry {
item: String,
kind: String,
name: String?,
children: Array<OutlineEntry>,
}
```
The tool MUST return the outline of a permitted file in a supported language
under {cite}`requirements.references.outlines`, with each node's selector under
{cite}`requirements.references.outline_selectors`, its kind, and its name when it
is named, nested by outline ancestry and in source order. Results MUST contain
no source text or line numbers and MUST NOT become evidence inputs; the model reads
the nodes it relies on with the `habeas` tool. For a file using the plain-text
profile, the outline lists its `line` nodes. Explicitly requesting an excluded
file MUST be handled as a denial under {cite}`requirements.authoring.read_denial`.
:::