requirements.authoring.fixme_inputs
Requirements index · View definition
Requirement
For a requirement or example assessment, the initial request MUST include every valid named
{fixme}reference to the subject found under, except a reference inside one of the subject’s sites under
, in this form:
Acknowledgment { file: String, item: String, body: String, issues: Array<{ reference: String, state: "open" | "closed" }>, }
fileanditemMUST locate the containing source by project-relative path and outline selector, using<root>for a whole file.bodyMUST contain the reference’s complete fenced commentary without its fences or source-comment delimiters, including its option lines, redacted under.
issuesMUST give every distinct issue its:github:lines name, in their order, with state supplied under. Acknowledgments MUST be ordered by file and position in the file and MUST carry no line numbers or containing implementation source.
The locations and bodies MUST be protected against staleness by the reference-set digest under
; the acknowledgment MUST NOT create an outline input merely to cover its containing source. Actual reads of that source MUST still be recorded under
. Sources MUST satisfy
; an inaccessible acknowledgment MUST be reported before inference.
Terminology definitions referenced by an acknowledgment’s body MUST contribute their complete, transitive declarations to the mandatory input set under
and MUST be recorded as definition inputs. Only the acknowledgment’s body MUST contribute these dependencies; its containing implementation source MUST NOT be supplied merely to discover them.
Rationale
The reviewed tests cover each obligation in requirements.authoring.fixme_inputs that is assessed here.
- Initial request contents.
tests/authoring_cli.rs#fn[initial_prompt_substitutes_subject_and_mandatory_inputs_into_the_template]parses the# Acknowledgmentssection of the prompt. For a requirement it asserts the exact JSON:file,item(fn[ready]),body(the:github:option line plus the commentary), andissueswith stateopen. For the example subject it asserts an empty list.- The example run only exercises the empty case, so no test has a
{fixme}naming an example.AssessmentSources::prepareis a single path for requirements and examples, so I treat this as the same behavior and not a separate gap.
- Form, ordering, root item, deduplication.
acknowledgment_metadata_is_ordered_and_deduplicates_issue_optionschecks these points:- Acknowledgments come out ordered by file (
a.txt,a.txt,z.txt) and by position within a file. - A whole-file source uses
<root>as its item. - The issue list is deduplicated and keeps its order (
o/r#2,o/r#1), with a state on each. - No mandatory input is created for the file.
- Acknowledgments come out ordered by file (
- Issue states.
initial_acknowledgments_supply_closed_and_missing_issue_states_without_sourcepoints the harness at a fake GitHub server. The server reportsclosedforexample/queue#125, and the test assertsclosedfor that issue and for the missing#404. It also asserts the commentary is present and the containing source (pub fn beta()) is absent. Open state is checked in the CLI prompt test. The “assume open when unreachable” rule belongs torequirements.authoring.github_reads, which the test also cites. - Sites exclusion and “valid named”.
cited_built_ins_contribute_their_text_and_fixmes_in_own_sites_do_notasserts that a{fixme}inside one of the subject’s own sites is excluded and one outside it is kept (fn[other],o/r#2).references_contribute_their_owning_outline_nodesasserts that an unnamed{fixme}yields no acknowledgment and that the body is exactlyThe gap.forfn[gap]. - Redaction.
model_inputs_reads_searches_and_citation_prompts_are_redactedasserts that a token in a{fixme}body appears as[REDACTED:GitHub Token]in the prompt, and that the containing functionfn gap()is not supplied. - Digest staleness.
tests/outcomes.rs#fn[editing_or_adding_a_fixme_makes_evidence_stale_without_requiring_source_reads]edits a{fixme}body and adds a new{fixme}. In both cases it asserts a “reference set changed” error and no “outline input changed” error. - No outline input; real reads recorded. The metadata test and the
references_contribute...test assert no outline input is created for acknowledgments.implementation_discovery_has_no_text_or_evidence_until_the_model_requests_a_readasserts that source is recorded only when the model actually reads it, and exactly once. - Inaccessible acknowledgment.
inaccessible_acknowledgment_source_aborts_preparationmakes the source file unreadable (mode0o000) and asserts that preparation errors, naming the file and “Permission denied”, before any inference. - Term dependencies.
acknowledgment_only_terms_are_supplied_and_validated_without_implementation_readschecks these points:- A
{term}used only in an acknowledgment body brings in the term and its transitive dependency in the prompt. - The containing source (
IMPLEMENTATION_BODY) is not supplied. - Changing an unread body does not make the evidence stale.
- Changing the transitive term does make it stale.
- A missing definition input is reported.
- A
I found no obligation without a test and no assertion that contradicts the requirement.
Inputs
Implementation
Input 20: outline src/authoring/inputs.rs impl[AssessmentSources]/fn[prepare]
- File:
src/authoring/inputs.rs - Selector:
impl[AssessmentSources]/fn[prepare] - Kind:
fn src/authoring/inputs.rs:65–296
// {impl}`requirements.authoring.invocation`
// {impl}`requirements.authoring.mandatory_inputs`
// {impl}`requirements.authoring_input`
// {impl}`requirements.examples.authoring_inputs`
// {impl}`requirements.examples.definition`
// {impl}`requirements.references.authoring_inputs`
// {impl}`requirements.definitions.authoring_inputs`
// {impl}`requirements.authoring.source_tools`
// {impl}`requirements.references.anchors`
// {impl}`requirements.ci.reference_set`
// {impl}`requirements.references.builtin_definitions`
// {impl}`requirements.references.site_review`
pub(crate) fn prepare(root: &Path, subject_name: &str) -> io::Result<Self> {
let root = fs::canonicalize(root)?;
let access = SourceAccess::load(&root)?;
let definitions = load_definitions(&root)?;
let subject = definitions
.get(subject_name)
.filter(|definition| definition.kind != DefinitionKind::Term)
.ok_or_else(|| {
io::Error::other(format!(
"{subject_name}: no matching requirement or named example"
))
})?;
let mut selectors = vec![InputSelector::Requirements {
requirements: subject_name.to_owned(),
}];
let mut builtins = Vec::new();
for (kind, name) in crate::text_references(&subject.text, true) {
// A `{fixme}` in a declaration is a validation error when named
// and is not an edge when unnamed.
if matches!(kind, ReferenceKind::Term | ReferenceKind::Fixme) {
continue;
}
// A built-in has no declaration; its fixed text is supplied instead.
if let Some(builtin) = crate::builtins::builtin(&name) {
if kind == ReferenceKind::Cite && !builtins.contains(&builtin.name) {
builtins.push(builtin.name);
}
continue;
}
if !definitions
.get(&name)
.is_some_and(|definition| definition.kind != DefinitionKind::Term)
{
return Err(io::Error::other(format!(
"{subject_name}: referenced subject {name} does not exist"
)));
}
// Only `{cite}` leaves the subject; its `{impl}` and `{test}`
// references point into it from the definitions it implements or tests.
if kind != ReferenceKind::Cite {
continue;
}
insert_selector(
&mut selectors,
InputSelector::Requirements { requirements: name },
);
}
let outlines = OutlineCache::default();
let mut errors = Vec::new();
let files = discovered_files(&root, &mut errors);
let references = crate::evidence::collect_references_with_progress(
&root,
&files,
&mut errors,
&mut |_| {},
);
if !errors.is_empty() {
return Err(io::Error::other(errors.join("\n")));
}
let sites =
crate::evidence::definition_sites(&root, subject_name, subject, &files, &outlines)?;
// The same edges determine the reference contributions below.
let reference_set = crate::evidence::reference_set_digest(
&root,
&outlines,
subject_name,
subject,
&references,
&sites,
);
// Tests contribute source. Refining declarations contribute their text;
// implementation references outside declarations only locate code.
for reference in references.iter().filter(|reference| {
reference.name == subject_name
&& matches!(reference.kind, ReferenceKind::Impl | ReferenceKind::Test)
}) {
// Generated evidence, including symlink aliases, is omitted by
// default rather than denied.
if access.omit_generated_evidence(&root, &reference.file) {
continue;
}
let selector = reference_selector(&root, &definitions, &outlines, reference)?;
if reference.kind == ReferenceKind::Test
|| matches!(selector, InputSelector::Requirements { .. })
{
access.file(&root, &reference.file)?;
insert_selector(&mut selectors, selector);
}
}
// {impl}`requirements.references.anchors`
for anchor in &subject.anchors {
if access.omit_generated_evidence(&root, Path::new(&anchor.file)) {
continue;
}
let selector = access
.file(&root, Path::new(&anchor.file))
.and_then(|_| {
anchor
.resolve(&root, &outlines)
.map(|_| anchor.selector())
.map_err(io::Error::other)
})
.map_err(|error| {
io::Error::new(
error.kind(),
format!(
"{subject_name}: cannot read :{}: anchor {}: {error}",
anchor.kind.label(),
anchor.label()
),
)
})?;
if anchor.kind == ReferenceKind::Test {
insert_selector(&mut selectors, selector);
}
}
// {impl}`requirements.authoring.fixme_inputs`
let mut acknowledgments = crate::evidence::fixme_acknowledgments(
&root,
&outlines,
references.iter().filter(|reference| {
reference.name == subject_name
&& !crate::sites::in_own_site(&root, &sites, reference)
&& !access.omit_generated_evidence(&root, &reference.file)
}),
)
.map_err(io::Error::other)?;
for acknowledgment in &acknowledgments {
access.file(&root, Path::new(acknowledgment["file"].as_str().unwrap()))?;
}
// Existing evidence only decides whether to reassess; its inputs are
// not carried forward.
let mut mandatory = Vec::new();
for selector in selectors {
if !generated_evidence_selector(&root, &access, &selector) {
mandatory.push(source_input(
&root,
&access,
&definitions,
&outlines,
&selector,
)?);
}
}
// The dependency collector receives bodies separately so Markdown and
// non-Markdown reference-literal rules keep their source semantics.
let dependencies = crate::terms::dependencies(
&root,
&definitions,
&outlines,
json!({"inputs": mandatory, "acknowledgments": acknowledgments})
.as_object()
.unwrap(),
Some(&subject.text),
)
.map_err(io::Error::other)?;
for definition in dependencies {
let input = source_input(
&root,
&access,
&definitions,
&outlines,
&InputSelector::Definition { definition },
)?;
if !mandatory.contains(&input) {
mandatory.push(input);
}
}
mandatory.extend(builtins.into_iter().map(builtin_input));
let github = GithubIssues::from_env(&root);
let issue_states = crate::github::input_issue_states(
&root,
&github,
&references,
&definitions,
&mandatory,
);
let issue_names = acknowledgments.iter().flat_map(|acknowledgment| {
crate::fixme::FixmeBody::parse(acknowledgment["body"].as_str().unwrap()).issues
});
let issues = github.read_all(issue_names);
for acknowledgment in &mut acknowledgments {
let parsed = crate::fixme::FixmeBody::parse(acknowledgment["body"].as_str().unwrap());
let mut seen = std::collections::BTreeSet::new();
acknowledgment["issues"] = parsed
.issues
.into_iter()
.filter(|issue| seen.insert(issue.clone()))
.map(|reference| {
let state = issues
.get(&reference)
.map_or("open", crate::github::IssueRead::state);
json!({"reference": reference, "state": state})
})
.collect();
}
Ok(Self {
root,
access,
subject_name: subject_name.to_owned(),
has_applicable_fixme: !acknowledgments.is_empty(),
subject_kind: AssessmentKind::Definition(
subject.kind,
crate::structural::has_query_directive(subject),
),
subject_text: subject.text.clone(),
outlines,
reference_set,
acknowledgments,
mandatory,
issue_states,
github,
recorded: Vec::new(),
})
}
Tests
Input 10: outline src/authoring/inputs.rs mod[tests]/fn[acknowledgment_only_terms_are_supplied_and_validated_without_implementation_reads]
- File:
src/authoring/inputs.rs - Selector:
mod[tests]/fn[acknowledgment_only_terms_are_supplied_and_validated_without_implementation_reads] - Kind:
fn src/authoring/inputs.rs:877–953
// {test}`requirements.authoring.fixme_inputs`
// {test}`requirements.definitions.dependencies`
// {test}`requirements.ci.reference_set`
// {test}`requirements.definitions.authoring_inputs`
#[test]
fn acknowledgment_only_terms_are_supplied_and_validated_without_implementation_reads() {
let root = project();
let (path, configuration) = crate::execution_coverage::configure(root.path()).unwrap();
fs::create_dir_all(path.parent().unwrap()).unwrap();
fs::write(path, configuration).unwrap();
fs::create_dir(root.path().join("evidence")).unwrap();
let terms = ":::{definition} unit\n:phrase: unit\nA unit.\n:::\n\n:::{definition} boundary\n:phrase: boundary\nA {term}`terms.unit` at the limit.\n:::\n";
fs::write(root.path().join("md/terms.md"), terms).unwrap();
let source = "// :::{fixme} requirements.ready\n// The {term}`terms.boundary` is untested.\n// :::\nfn gap() { panic!(\"IMPLEMENTATION_BODY\"); }\n";
fs::write(root.path().join("src/lib.rs"), source).unwrap();
let mut sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let prompt = super::super::initial_prompt(&sources).unwrap().joined();
assert!(prompt.contains("A unit."));
assert!(prompt.contains("at the limit."));
assert!(prompt.contains("is untested."));
assert!(!prompt.contains("IMPLEMENTATION_BODY"));
assert!(
!sources
.mandatory_inputs()
.iter()
.any(|input| input.get("item").is_some())
);
let mandatory = sources.mandatory_inputs().to_vec();
sources.record_inputs(&mandatory);
let record = json!({
"requirement": "The project MUST be ready.",
"determination": {"FIXME": ["The {term}`terms.boundary` is untested."]},
"rationale": "The boundary test is acknowledged as missing.",
"references": sources.reference_set,
"inputs": sources.recorded_inputs(),
});
let path = root.path().join("evidence/requirements.ready.json");
fs::write(&path, record.to_string()).unwrap();
let check = || {
crate::evidence::validate_repository(root.path())
.unwrap()
.errors
};
assert!(check().is_empty(), "{:?}", check());
// An unread body can change without changing the judgment's inputs.
fs::write(
root.path().join("src/lib.rs"),
source.replace("panic!(\"IMPLEMENTATION_BODY\")", "let _value = 1"),
)
.unwrap();
assert!(check().is_empty(), "{:?}", check());
// The acknowledgment introduces a real, transitive term dependency.
fs::write(
root.path().join("md/terms.md"),
terms.replace("A unit.", "A changed unit."),
)
.unwrap();
let errors = check().join("\n");
assert!(
errors.contains("input text changed for Definition { definition: \"terms.unit\" }"),
"{errors}"
);
fs::write(root.path().join("md/terms.md"), terms).unwrap();
let mut missing = record.clone();
missing["inputs"]
.as_array_mut()
.unwrap()
.retain(|input| input["definition"] != "terms.boundary");
fs::write(&path, missing.to_string()).unwrap();
let errors = check().join("\n");
assert!(
errors.contains("expected exactly one definition input for terms.boundary, found 0"),
"{errors}"
);
}
Input 11: outline src/authoring/inputs.rs mod[tests]/fn[acknowledgment_metadata_is_ordered_and_deduplicates_issue_options]
- File:
src/authoring/inputs.rs - Selector:
mod[tests]/fn[acknowledgment_metadata_is_ordered_and_deduplicates_issue_options] - Kind:
fn src/authoring/inputs.rs:1496–1543
// {test}`requirements.authoring.fixme_inputs`
#[test]
fn acknowledgment_metadata_is_ordered_and_deduplicates_issue_options() {
let root = project();
let acknowledgment = |issues: &str, body: &str| {
format!(":::{{fixme}} requirements.ready\n{issues}{body}\n:::\n")
};
let first = acknowledgment(
":github: o/r#2\n:github: o/r#1\n:github: o/r#2\n",
"First gap.",
);
let second = acknowledgment("", "Second gap.");
fs::write(root.path().join("a.txt"), format!("{first}\n{second}")).unwrap();
fs::write(root.path().join("z.txt"), acknowledgment("", "Last gap.")).unwrap();
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let metadata = sources.model_acknowledgments();
assert_eq!(metadata.len(), 3, "{metadata:?}");
assert_eq!(
metadata
.iter()
.map(|m| m["file"].as_str().unwrap())
.collect::<Vec<_>>(),
["a.txt", "a.txt", "z.txt"]
);
assert!(metadata[0]["body"].as_str().unwrap().contains("First gap."));
assert!(
metadata[1]["body"]
.as_str()
.unwrap()
.contains("Second gap.")
);
assert!(metadata[2]["body"].as_str().unwrap().contains("Last gap."));
assert_eq!(metadata[0]["item"], "<root>");
assert_eq!(
metadata[0]["issues"],
json!([
{"reference":"o/r#2","state":"open"}, {"reference":"o/r#1","state":"open"}
])
);
assert!(
sources
.mandatory_inputs()
.iter()
.all(|input| input.get("file").is_none()),
"{:?}",
sources.mandatory_inputs()
);
}
Input 12: outline src/authoring/inputs.rs mod[tests]/fn[inaccessible_acknowledgment_source_aborts_preparation]
- File:
src/authoring/inputs.rs - Selector:
mod[tests]/fn[inaccessible_acknowledgment_source_aborts_preparation] - Kind:
fn src/authoring/inputs.rs:1545–1567
// {test}`requirements.authoring.fixme_inputs`
#[cfg(unix)]
#[test]
fn inaccessible_acknowledgment_source_aborts_preparation() {
use std::os::unix::fs::PermissionsExt;
let root = project();
let path = root.path().join("src/gap.rs");
fs::write(
&path,
"// :::{fixme} requirements.ready\n// Untested.\n// :::\nfn gap() {}\n",
)
.unwrap();
fs::set_permissions(&path, fs::Permissions::from_mode(0o000)).unwrap();
if fs::read(&path).is_ok() {
fs::set_permissions(&path, fs::Permissions::from_mode(0o644)).unwrap();
return;
}
let result = AssessmentSources::prepare(root.path(), "requirements.ready");
fs::set_permissions(&path, fs::Permissions::from_mode(0o644)).unwrap();
let error = result.err().unwrap();
assert!(error.to_string().contains("gap.rs"), "{error}");
assert!(error.to_string().contains("Permission denied"), "{error}");
}
Input 13: outline src/authoring/inputs.rs mod[tests]/fn[cited_built_ins_contribute_their_text_and_fixmes_in_own_sites_do_not]
- File:
src/authoring/inputs.rs - Selector:
mod[tests]/fn[cited_built_ins_contribute_their_text_and_fixmes_in_own_sites_do_not] - Kind:
fn src/authoring/inputs.rs:1626–1704
// {test}`requirements.references.authoring_inputs`
// {test}`requirements.references.builtin_definitions`
// {test}`requirements.references.site_review`
// {test}`requirements.authoring.adaptive`
// {test}`requirements.authoring.fixme_inputs`
#[test]
fn cited_built_ins_contribute_their_text_and_fixmes_in_own_sites_do_not() {
let project = crate::authoring::tests::citing_site_project();
let root = project.path();
let fixme = |issue: &str| {
format!(
" // :::{{fixme}} requirements.rule\n // :github: o/r#{issue}\n // Panics instead of reporting.\n // :::\n"
)
};
let source = crate::sites::tests::SOURCE
.replace(
"fn check_two() {}",
&format!("fn check_two() {{\n{}}}", fixme("1")),
)
.replace(
"fn other() { panic!(\"y\"); }",
&format!("fn other() {{\n{}}}", fixme("2")),
);
fs::write(root.join("src/lib.rs"), &source).unwrap();
let sources = AssessmentSources::prepare(root, "requirements.rule").unwrap();
assert!(sources.has_applicable_fixme);
let own_site = AssessmentSources::prepare_site(
root,
"requirements.rule",
"src/lib.rs",
"fn[check_two]",
)
.unwrap();
assert!(own_site.has_applicable_fixme);
let clean_site = AssessmentSources::prepare_site(
root,
"requirements.rule",
"src/lib.rs",
"fn[check_one]",
)
.unwrap();
assert!(!clean_site.has_applicable_fixme);
assert!(clean_site.model_acknowledgments().is_empty());
let only_site = source.replace(&fixme("2"), "");
fs::write(root.join("src/lib.rs"), only_site).unwrap();
assert!(
!AssessmentSources::prepare(root, "requirements.rule")
.unwrap()
.has_applicable_fixme
);
fs::write(root.join("src/lib.rs"), &source).unwrap();
let mandatory = sources.mandatory_inputs();
let items = mandatory
.iter()
.filter_map(|input| input["item"].as_str())
.collect::<Vec<_>>();
// Only the acknowledgment outside the subject's own sites belongs to
// this assessment, and it contributes no containing source.
assert!(items.is_empty(), "{mandatory:#?}");
let acknowledgments = sources.model_acknowledgments();
assert_eq!(acknowledgments.len(), 1, "{acknowledgments:#?}");
assert_eq!(acknowledgments[0]["item"], "fn[other]");
assert_eq!(acknowledgments[0]["issues"][0]["reference"], "o/r#2");
// A cited built-in contributes its fixed text once, and a cited
// declaration its own declaration.
assert_eq!(
mandatory
.iter()
.filter(|input| input["builtin"] == "habeas:util")
.collect::<Vec<_>>(),
[&builtin_input("habeas:util")]
);
assert!(
mandatory
.iter()
.any(|input| input["requirements"] == "requirements.other"),
"{mandatory:#?}"
);
}
Input 14: outline src/authoring/inputs.rs mod[tests]/fn[references_contribute_their_owning_outline_nodes]
- File:
src/authoring/inputs.rs - Selector:
mod[tests]/fn[references_contribute_their_owning_outline_nodes] - Kind:
fn src/authoring/inputs.rs:1706–1766
// {test}`requirements.references.authoring_inputs`
// {test}`requirements.references.outline_comments`
// {test}`requirements.references.anchors`
// {test}`requirements.authoring.mandatory_inputs`
// {test}`requirements.authoring.fixme_inputs`
// {test}`requirements.references.roles`
#[test]
fn references_contribute_their_owning_outline_nodes() {
let root = project();
fs::create_dir_all(root.path().join("docs")).unwrap();
fs::write(
root.path().join("md/requirements.md"),
":::{req} ready\n:impl: src/lib.rs#mod[inner]\nThe project MUST be ready.\n:::\n",
)
.unwrap();
// A `{fixme}` contributes metadata for the node its comment belongs to;
// an unnamed one is not an acknowledgment edge.
fs::write(
root.path().join("src/lib.rs"),
"mod inner {\n fn unrelated() {}\n}\n\n// :::{fixme} requirements.ready\n// The gap.\n// :::\nfn gap() {}\n\n// :::{fixme}\n// :github: example/app#1\n// :::\nfn tracked() {}\n",
)
.unwrap();
fs::write(
root.path().join("docs/guide.md"),
format!(
"# Intro\n\nText.\n\n# Usage\n\nSee {}.\n",
role("test", "requirements.ready")
),
)
.unwrap();
fs::write(
root.path().join("notes.txt"),
format!("first\n{}\n", role("test", "requirements.ready")),
)
.unwrap();
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let items = sources
.mandatory_inputs()
.iter()
.filter(|input| input.get("item").is_some())
.map(|input| {
(
input["file"].as_str().unwrap(),
input["item"].as_str().unwrap(),
)
})
.collect::<Vec<_>>();
assert_eq!(
items,
[
("docs/guide.md", "section[Usage]"),
// A plain-text file contributes the complete file.
("notes.txt", ""),
]
);
let acknowledgments = sources.model_acknowledgments();
assert_eq!(acknowledgments.len(), 1, "{acknowledgments:#?}");
assert_eq!(acknowledgments[0]["file"], "src/lib.rs");
assert_eq!(acknowledgments[0]["item"], "fn[gap]");
assert_eq!(acknowledgments[0]["body"], "The gap.");
}
Input 15: outline src/authoring/tools.rs mod[tests]/fn[model_inputs_reads_searches_and_citation_prompts_are_redacted]
- File:
src/authoring/tools.rs - Selector:
mod[tests]/fn[model_inputs_reads_searches_and_citation_prompts_are_redacted] - Kind:
fn src/authoring/tools.rs:1696–1774
// {test}`requirements.authoring.redaction`
// {test}`requirements.authoring.credentials`
// {test}`requirements.authoring.source_tools`
// {test}`requirements.authoring.text_search`
// {test}`requirements.authoring.mandatory_inputs`
// {test}`requirements.authoring.citation_prompt`
// {test}`requirements.authoring.fixme_inputs`
#[test]
fn model_inputs_reads_searches_and_citation_prompts_are_redacted() {
let root = project();
let token = crate::redaction::tests::github_token();
fs::write(
root.path().join("habeas.toml"),
"version = 1\n[authoring.configs.local]\nbackend = 'ollama'\nmodel = 'm'\napi_key = 'plain ollama key'\n",
)
.unwrap();
fs::write(
root.path().join("src/lib.rs"),
format!(
"// {}\nfn client() -> &'static str {{\n \"{token}\"\n}}\n\n// :::{} requirements.ready\n// Defaults to {token}.\n// :::\nfn helper() {{}}\n\n// :::{{fixme}} requirements.ready\n// Missing check for {token}.\n// :::\nfn gap() {{}}\n",
role("test", "requirements.ready"),
"{cite}"
),
)
.unwrap();
git(root.path(), &["init", "--quiet"]);
git(root.path(), &["add", "."]);
let leaks = |value: &Value| {
let text = value.to_string();
text.contains(&token) || text.contains("plain ollama key")
};
// Mandatory inputs, and so the initial and verification prompts.
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let mandatory = Value::Array(sources.mandatory_inputs().to_vec());
assert!(!leaks(&mandatory), "{mandatory:#}");
assert!(mandatory.to_string().contains("[REDACTED:GitHub Token]"));
let prompt = super::super::initial_prompt(&sources).unwrap().joined();
assert!(!prompt.contains(&token), "{prompt}");
assert!(
prompt.contains("Missing check for [REDACTED:GitHub Token]."),
"{prompt}"
);
assert!(!prompt.contains("fn gap()"), "{prompt}");
// A habeas read of the configuration file and a line range.
let read = dispatch(&sources, "habeas", &json!({"file":"habeas.toml","item":""})).unwrap();
assert!(!leaks(&read.result), "{:#}", read.result);
assert!(
read.result["input"]["text"]
.as_array()
.unwrap()
.contains(&json!("api_key = '[REDACTED:api_key]'"))
);
let lines = dispatch(
&sources,
"habeas",
&json!({"file":"src/lib.rs","line_start":1}),
)
.unwrap();
assert!(!leaks(&lines.result), "{:#}", lines.result);
// Search results, even for a pattern matching the credential itself.
for pattern in ["ollama", "gh[p]_", "Defaults"] {
let search = dispatch(&sources, "ripgrep", &json!({"pattern": pattern})).unwrap();
assert!(
!search.result["matches"].as_array().unwrap().is_empty(),
"{pattern}"
);
assert!(!leaks(&search.result), "{pattern}: {:#}", search.result);
}
// A citation review's inputs and its commentary in the prompt.
let citation =
AssessmentSources::prepare_citation(root.path(), "src/lib.rs", "fn[helper]").unwrap();
assert!(!leaks(&Value::Array(citation.mandatory_inputs().to_vec())));
let prompt = super::super::initial_prompt(&citation).unwrap().joined();
assert!(!prompt.contains(&token), "{prompt}");
assert!(
prompt.contains("Defaults to [REDACTED:GitHub Token]."),
"{prompt}"
);
}
Input 16: outline tests/authoring_batch.rs fn[initial_acknowledgments_supply_closed_and_missing_issue_states_without_source]
- File:
tests/authoring_batch.rs - Selector:
fn[initial_acknowledgments_supply_closed_and_missing_issue_states_without_source] - Kind:
fn tests/authoring_batch.rs:2346–2382
// {test}`requirements.authoring.fixme_inputs`
// {test}`requirements.authoring.github_reads`
#[test]
fn initial_acknowledgments_supply_closed_and_missing_issue_states_without_source() {
let server = Server::start(false, None);
let github = FakeGithub::start();
*github.state.lock().unwrap() = "closed";
let fixture = Fixture::new(&server.endpoint, None);
let source = fixture.project.join("src/lib.rs");
fs::write(&source, fs::read_to_string(&source).unwrap().replace(
"pub fn beta()",
"// :::{fixme} requirements.beta\n// :github: example/queue#125\n// :github: example/queue#404\n// Boundary cases are untested.\n// :::\npub fn beta()",
)).unwrap();
let output = fixture
.command()
.env("HABEAS_GITHUB_API_URL", &github.endpoint)
.args(["author", "requirements.beta"])
.output()
.unwrap();
assert!(output.status.success(), "{output:?}");
let state = server.requests.0.lock().unwrap();
let request = &state.conversations[0].1;
let user = request["messages"]
.as_array()
.unwrap()
.iter()
.find(|m| m["role"] == "user")
.unwrap()["content"]
.as_str()
.unwrap();
for issue in ["example/queue#125", "example/queue#404"] {
let expected = format!("\"reference\": \"{issue}\",\n \"state\": \"closed\"");
assert!(user.contains(&expected), "{user}");
}
assert!(user.contains("Boundary cases are untested."), "{user}");
assert!(!user.contains("pub fn beta()"), "{user}");
}
Input 17: outline tests/authoring_cli.rs fn[implementation_discovery_has_no_text_or_evidence_until_the_model_requests_a_read]
- File:
tests/authoring_cli.rs - Selector:
fn[implementation_discovery_has_no_text_or_evidence_until_the_model_requests_a_read] - Kind:
fn tests/authoring_cli.rs:292–364
// {test}`requirements.authoring.mandatory_inputs`
// {test}`requirements.authoring.reference_index`
// {test}`requirements.authoring.delivered_inputs`
// {test}`requirements.authoring.fixme_inputs`
// {test}`requirements.authoring.complete_initial_bundle`
#[test]
fn implementation_discovery_has_no_text_or_evidence_until_the_model_requests_a_read() {
let server = Server::start(vec![
reply(vec![call(
"locate",
"references",
json!({"selection": SUBJECT, "roles": ["impl"]}),
)]),
reply(vec![call(
"read",
"habeas",
json!({"file": "src/lib.rs", "item": "fn[ready]"}),
)]),
reply(vec![call(
"submit",
"submit_judgment",
json!({"determination": true, "rationale": "The tests check the requirement."}),
)]),
]);
let fixture = Fixture::new(&server.endpoint);
let output = fixture.run(&["author", SUBJECT]);
assert!(output.status.success(), "{output:?}");
let requests = server.finish();
assert_eq!(requests.len(), 3);
let prompt = prompt_text(&requests[0].body);
assert!(prompt.contains("fn ready_test()"));
assert!(prompt.contains("One acknowledged gap."));
assert!(!prompt.contains("pub fn ready()"));
let tool_result = |request: &Request| -> Value {
let message = request.body["messages"]
.as_array()
.unwrap()
.iter()
.rev()
.find(|message| message["role"] == "tool")
.unwrap();
serde_json::from_str(message["content"].as_str().unwrap()).unwrap()
};
let locations = tool_result(&requests[1]);
assert!(locations.to_string().contains("fn[ready]"), "{locations:#}");
for text in [
REQUIREMENT,
"One acknowledged gap.",
"pub fn ready()",
"\"input\"",
"\"inputs\"",
] {
assert!(!locations.to_string().contains(text), "{locations:#}");
}
let read = tool_result(&requests[2]);
assert!(read["input"]["text"].to_string().contains("pub fn ready()"));
assert_eq!(read["input"]["file"], "src/lib.rs");
assert_eq!(read["input"]["item"], "fn[ready]");
assert_eq!(
read["input"]["hash"],
habeas::outline_input(&fixture.project, "src/lib.rs", "fn[ready]").unwrap()["hash"]
);
let record: Value = serde_json::from_slice(&fs::read(&fixture.evidence).unwrap()).unwrap();
let inputs = record["inputs"].as_array().unwrap();
assert_eq!(
inputs
.iter()
.filter(|input| input["file"] == "src/lib.rs" && input["item"] == "fn[ready]")
.count(),
1
);
assert!(!fixture.usage()["inputs"].to_string().contains("references"));
}
Input 18: outline tests/authoring_cli.rs fn[initial_prompt_substitutes_subject_and_mandatory_inputs_into_the_template]
- File:
tests/authoring_cli.rs - Selector:
fn[initial_prompt_substitutes_subject_and_mandatory_inputs_into_the_template] - Kind:
fn tests/authoring_cli.rs:1067–1232
// {test}`requirements.authoring.initial_prompt`
// {test}`requirements.authoring.prompt_parts`
// {test}`requirements.authoring.fixme_inputs`
// {test}`requirements.authoring.invocation`
#[test]
fn initial_prompt_substitutes_subject_and_mandatory_inputs_into_the_template() {
let template = approved_text("initial_prompt", 0);
let subject_template = approved_text("initial_prompt", 1);
for (subject, kind) in [
(SUBJECT, "requirement"),
("requirements.ready_case", "example"),
] {
let server = Server::start(vec![reply(vec![call(
"submit",
"submit_judgment",
json!({"determination":true,"rationale":"covered"}),
)])]);
let fixture = Fixture::new(&server.endpoint);
fs::write(
fixture.project.join("md/requirements.md"),
format!(
":::{{req}} ready\n{REQUIREMENT}\n:::\n\n:::{{example}} ready_case\nCalling ready succeeds. {{cite}}`requirements.ready`\n:::\n"
),
)
.unwrap();
let output = fixture.run(&["author", subject]);
assert!(output.status.success(), "{output:?}");
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(
stdout.starts_with(&format!("{subject}: ollama / {MODEL}")),
"{stdout}"
);
let evidence_path = stdout
.lines()
.find_map(|line| line.strip_prefix("Evidence: "))
.unwrap();
assert_eq!(
std::path::Path::new(evidence_path),
fixture.project.join(format!("evidence/{subject}.json"))
);
let record: Value = serde_json::from_slice(&fs::read(evidence_path).unwrap()).unwrap();
let field = if kind == "requirement" {
"requirement"
} else {
"example"
};
let other = if kind == "requirement" {
"example"
} else {
"requirement"
};
assert!(record.get(other).is_none(), "{record}");
assert_eq!(
record[field],
if kind == "requirement" {
REQUIREMENT
} else {
"Calling ready succeeds. {cite}`requirements.ready`"
}
);
let usage_path = stdout
.lines()
.find_map(|line| line.strip_prefix("Usage: "))
.unwrap();
assert!(std::path::Path::new(usage_path).is_file(), "{stdout}");
let requests = server.finish();
let (system, prompt) = opening(&requests[0].body);
let task = if kind == "requirement" {
format!(
"{}\n{}",
approved_text("requirement_task", 0),
approved_text("testing_bar", 0)
)
} else {
approved_text("example_task", 0).to_owned()
};
// Apart from the substitutions, the system prompt is the first block
// as written, with nothing that names the subject.
let expected = template
.replace("{{subject_kind}}", kind)
.replace(
"{{habeas_background}}",
approved_text("habeas_background", 0),
)
.replace("{{reference_roles}}", approved_text("habeas_background", 1))
.replace("{{subject_task}}", &task)
.replace("{{judgment_rules}}", approved_text("judgment_rules", 0));
assert!(!expected.contains("{{"), "{expected}");
assert_eq!(system, expected);
assert!(!system.contains(subject), "{system}");
let acknowledgments: Value = serde_json::from_str(
prompt
.split_once("# Acknowledgments\n\n")
.unwrap()
.1
.split_once("\n\n# Mandatory inputs")
.unwrap()
.0,
)
.unwrap();
if kind == "requirement" {
assert_eq!(
acknowledgments,
json!([{
"body": ":github: example/app#125\n One acknowledged gap.",
"file": "src/lib.rs",
"issues": [{"reference": "example/app#125", "state": "open"}],
"item": "fn[ready]",
}])
);
} else {
assert_eq!(acknowledgments, json!([]));
}
let (before, after) = subject_template.split_once("{{mandatory_inputs}}").unwrap();
// The subject is not distributed, so its distributed task is empty.
let before = before
.replace("{{subject_kind}}", kind)
.replace("{{subject_name}}", subject)
.replace("{{distributed_task}}", "")
.replace(
"{{acknowledgments}}",
&serde_json::to_string_pretty(&acknowledgments).unwrap(),
);
assert!(
before.contains(&format!("\nSubject: {kind} {subject}\n")),
"{before}"
);
assert!(!before.contains("{{") && !after.contains("{{"));
// Apart from the substitutions, the subject message is the second
// block as written.
assert!(prompt.starts_with(&before), "{prompt}");
assert!(prompt.ends_with(after), "{prompt}");
let rendered = &prompt[before.len()..prompt.len() - after.len()];
// The mandatory inputs are a JSON array of evidence inputs.
let inputs: Vec<Value> = serde_json::from_str(rendered).unwrap();
assert!(!inputs.is_empty());
for input in &inputs {
let forms = [
("file", &["item", "hash", "text"][..]),
("requirements", &["matches", "text"][..]),
("definition", &["text"][..]),
];
let matching = forms
.iter()
.filter(|(key, _)| input.get(key).is_some())
.collect::<Vec<_>>();
assert_eq!(matching.len(), 1, "one evidence-input form: {input}");
for field in matching[0].1 {
assert!(input.get(field).is_some(), "{input} lacks {field}");
}
}
let defined = |name: &str| {
inputs
.iter()
.any(|input| input["definition"] == name || input["requirements"] == name)
};
assert!(defined(subject), "{inputs:?}");
if kind == "example" {
assert!(defined(SUBJECT), "cited requirement supplied: {inputs:?}");
} else {
assert!(defined("terms.readiness"), "{inputs:?}");
}
}
}
Input 19: outline tests/outcomes.rs fn[editing_or_adding_a_fixme_makes_evidence_stale_without_requiring_source_reads]
- File:
tests/outcomes.rs - Selector:
fn[editing_or_adding_a_fixme_makes_evidence_stale_without_requiring_source_reads] - Kind:
fn tests/outcomes.rs:529–572
// {test}`requirements.ci.reference_set`
// {test}`requirements.references.evidence_coverage`
// {test}`requirements.authoring.fixme_inputs`
#[test]
fn editing_or_adding_a_fixme_makes_evidence_stale_without_requiring_source_reads() {
let temp = fixture();
let observed = temp.path().join("observed.rs");
let source = fs::read_to_string(&observed).unwrap();
// Comments do not change the input's hash, but the `{fixme}` body is
// part of the reference set.
fs::write(&observed, source.replace("are untested", "remain untested")).unwrap();
let errors = habeas::validate_repository(temp.path()).unwrap().errors;
assert!(
errors.iter().any(
|error| error.contains("evidence/requirements.timeout.json: reference set changed")
),
"{errors:?}"
);
assert!(
!errors
.iter()
.any(|error| error.contains("outline input changed")),
"{errors:?}"
);
fs::write(&observed, &source).unwrap();
fs::write(
temp.path().join("other.rs"),
fixme("requirements.timeout", &[], "Another gap."),
)
.unwrap();
let errors = habeas::validate_repository(temp.path()).unwrap().errors;
assert!(
errors.iter().any(
|error| error.contains("evidence/requirements.timeout.json: reference set changed")
),
"{errors:?}"
);
assert!(
!errors
.iter()
.any(|error| error.contains("no input covers {fixme}")),
"{errors:?}"
);
}
Referenced definitions
Input 2: requirements selection requirements.references.discovery
requirements.references.discovery:md/requirements/references.md:99–112
:::{req} discovery
Habeas MUST find the references of {cite}`requirements.references.roles`
in project source files, where {cite}`requirements.references.reference_contexts`
says they count, and MUST fail with the source file and line if a
name has no matching `{req}` or `{example}` definition. In Markdown, escaped
roles and roles in code examples MUST remain literal. Reference discovery MUST
consider exactly the project sources that source-access policy permits under
{cite}`requirements.authoring.source_tools`: in a Git worktree, files present in
the Git index, including staged new files; outside Git, all project files; in
both cases excluding the project-root `book` and `evidence` directories, `.git`
and `target` directories at any depth, and paths disallowed by
{cite}`requirements.configuration.evidence_paths`. Evidence snapshots and
generated build output MUST therefore not be counted as source references.
:::
Input 3: requirements selection requirements.references.site_review
requirements.references.site_review:md/requirements/references.md:521–559
:::{req} site_review
Every site of a distributed requirement under
{cite}`requirements.references.distributed` MUST have a site review: an
assessment of whether that site upholds the requirement, recorded at
`evidence/sites/<full-name>/<file>/<selector>.json`, where `<file>` and
`<selector>` are encoded as under
{cite}`requirements.references.citation_review`. The review MUST use the prompt
defined by {cite}`requirements.authoring.site_prompt`. Mandatory inputs, under
{cite}`requirements.authoring.mandatory_inputs`, MUST be the site's outline
node, the requirement's complete declaration, and each declaration the
requirement cites. The record MUST contain the requirement's full name, the
site's file and selector, `queries`, the sorted names of the queries with a
match at the site, `applies`, `determination`, `rationale`, and `inputs`, with
determinations under {cite}`requirements.ci.outcomes`. `applies` MUST be a
Boolean recording whether the requirement applies to the site. A site to which
the requirement does not apply MUST be judged `true`, and the rationale MUST
explain why it does not apply. `habeas info` MUST report, for each selected
distributed requirement, how many of its sites the requirement does not apply
to.
Validation MUST require a current, accepted review for every site, MUST report a
false review with its rationale, and MUST report stale, missing, or orphaned
reviews; a review is orphaned when its file and selector no longer name a site
of the requirement. A `{fixme}` naming the requirement inside a site
acknowledges a gap at that site only: it MUST be an input to that site's review
and MUST NOT contribute to the requirement's own review, coverage, or reference
set. A review MUST become stale when the site's hash, the requirement's
declaration, a cited declaration, its `queries`, or the `{fixme}` references
naming the requirement inside the site, with the words of their bodies, change.
Each site review's determination MUST be checked on its own, independently of
the requirement's evidence. Authoring with `--all` MUST include site reviews,
`habeas author sites:<full-name>` MUST author the site reviews of the named
requirement, and `habeas author sites:<full-name>/<file>#<selector>` MUST author
the review of the one site it names, under
{cite}`requirements.authoring.refresh`, where omitting `#<selector>` names the
file's root node. `habeas status` MUST report missing, stale, invalid, and false
site reviews with their requirement, file, and selector, and `habeas info` MUST
list each selected requirement's sites with their determinations.
:::
Input 4: requirements selection requirements.authoring.redaction
requirements.authoring.redaction:md/requirements/authoring.md:1795–1817
:::{req} redaction
Every source text the harness supplies to a model, including mandatory inputs,
`habeas` reads, and `ripgrep` results, and every source text Habeas displays in
the book or `habeas info`, MUST be redacted:
1. In a workspace `habeas.toml` or user configuration file, the value of every
explicit credential field defined by {cite}`requirements.authoring.credentials`
MUST be replaced. Such a file that is not valid TOML MUST be replaced whole,
with `configuration` as the kind, because its fields cannot be located.
2. In every source, each match of a built-in rule of the `secretshape` crate MUST
be replaced. The replaced region MUST be extended through each adjacent region
that the crate's entropy heuristic flags and that only whitespace separates
from the region, repeating until no flagged region is adjacent. The heuristic
MUST NOT cause redaction on its own.
A replacement MUST read `[REDACTED:<kind>]`, where `<kind>` is the credential
field or the rule's name, and MUST keep every line break within the replaced
text, so line numbers are unchanged. Outlines MUST be built from the original
source, and the structural hash MUST hash each text piece that overlaps a
redacted region in its redacted form, so evidence never depends on a credential's
value and redaction never changes or breaks a file's outline. The `secretshape` version MUST be pinned exactly; upgrading
it MAY change redaction and hashes and MUST be treated as a deliberate change.
:::
Input 5: requirements selection requirements.authoring.github_reads
requirements.authoring.github_reads:md/requirements/authoring.md:1091–1122
:::{req} github_reads
The harness MUST expose a `github` tool with this interface:
```text
github({ issue: String }) -> Issue
Issue { reference: String, state: "open" | "closed", title: String, body: String }
```
`issue` MUST have the form `<owner>/<repo>#<number>`. The tool MUST read the issue
or pull request through the GitHub API, authenticating with the `GITHUB_TOKEN`
environment variable when that is set, and MUST return its body redacted under
{cite}`requirements.authoring.redaction`. GitHub reads cannot be reproduced
later, so their results MUST NOT be recorded as evidence inputs and MUST NOT
make evidence stale. Every GitHub read by Habeas, including this tool's, the
lookups below, and those of {cite}`requirements.cli.fixme_issues`, MUST go
through one cache under the state root of
{cite}`requirements.configuration.state_location`, keyed by issue, and MUST
reuse a cached result less than one hour old instead of contacting GitHub. A malformed reference, a missing issue, or a failed request
MUST return an explanatory tool error.
When the mandatory inputs contain a `{fixme}` reference under
{cite}`requirements.references.roles`, or the initial request includes one under
{cite}`requirements.authoring.fixme_inputs`, the harness MUST look up the state of
each issue its `:github:` lines name in the same way and MUST supply each state
with the corresponding source input or acknowledgment as `open` or `closed`;
when GitHub cannot be reached, the issue MUST be assumed open. These states MUST
NOT be recorded either. Instead, `habeas status` and `habeas author` MUST treat a recorded FIXME determination as stale, exactly as if one of its inputs had changed, when an issue that one of its acknowledging `{fixme}` references names, or for a site review the `{fixme}` references inside the site, is closed or does not exist; repository validation, which never contacts GitHub, MUST NOT.
The harness MAY take the GitHub API base URL from `HABEAS_GITHUB_API_URL`,
accepting only `http://127.0.0.1:<port>`, so that tests can use a local server.
:::
Input 6: requirements selection requirements.ci.reference_set
requirements.ci.reference_set:md/requirements/ci.md:154–170
:::{req} reference_set
A definition's reference set MUST consist of its current incoming `{impl}`, `{test}`, and `{fixme}` edges, except a `{fixme}` inside a site of the definition under {cite}`requirements.references.site_review`, under {cite}`requirements.references.roles` and
{cite}`requirements.references.anchors`: for each edge, its role and the file and
outline selector of the node the reference belongs to under
{cite}`requirements.references.outline_comments`, or of the anchored file or
node, and, for a fenced reference in a source outside the book, the words of
its body under the word rule of {cite}`requirements.references.structural_hash`.
`{cite}` references MUST NOT contribute. The reference-set digest MUST be
the SHA-256 digest of an unambiguous encoding of those entries in sorted order,
so it does not depend on line numbers or on the order references are found.
Authoring MUST record the digest of the reference set it supplied, and
validation MUST recompute it and report a changed reference set as stale
evidence. Adding or removing an `{impl}`, `{test}`, or `{fixme}` reference or anchor,
changing its role, editing its commentary, or moving it to a different node
MUST therefore make the evidence stale even when no recorded input changed; moving a reference within
the node it belongs to MUST NOT.
:::
Input 7: requirements selection requirements.authoring.delivered_inputs
requirements.authoring.delivered_inputs:md/requirements/authoring.md:2142–2150
:::{req} delivered_inputs
The harness MUST record the sources it supplies to the model, including
mandatory inputs, additional reads, and selected search dependencies under
{cite}`requirements.authoring.finish_search.inputs`, using the evidence input formats
defined by {cite}`requirements.ci.outline_inputs`,
{cite}`requirements.ci.requirements_inputs`, and
{cite}`requirements.definitions.inputs`. The harness MUST create these records
itself so ordinary evidence validation can check them later.
:::
Input 8: requirements selection requirements.authoring.source_tools
requirements.authoring.source_tools:md/requirements/authoring.md:637–699
:::{req} source_tools
The harness MUST expose a `habeas` tool accepting exactly one of these request
forms. Each form MUST correspond to one existing evidence-input kind:
| Request fields | Evidence input returned | Definition |
| --- | --- | --- |
| `file: String`, `line_start: Integer`, optional `line_end: Integer` | Outline inputs for the innermost outline nodes covering the range | {cite}`requirements.ci.outline_inputs` |
| `file: String`, `item: String` | Outline input | {cite}`requirements.ci.outline_inputs` |
| `requirements: String` | Requirements input, including its matching names | {cite}`requirements.ci.requirements_inputs` |
| `definition: String` | Definition input | {cite}`requirements.definitions.inputs` |
Selector arguments MUST use the syntax defined by
{cite}`requirements.references.outline_selectors`. Reads MUST use the current
project working tree, including unstaged changes to tracked files and staged new
files. By default, source inputs MUST stay within the project root after
resolving symlinks; in a Git worktree, both the requested file and its resolved
target MUST be present in the Git index. Projects outside Git MUST use the same
containment rules without requiring an index. Failure to read an existing
repository's index MUST be reported as an error.
The project-root `evidence/` directory MUST be excluded from model reads by
default, including symlink aliases. Every source the harness supplies to the
model MUST be redacted under {cite}`requirements.authoring.redaction`. Generated build outputs MUST follow
{cite}`requirements.authoring.generated_inputs`. Workspace path overrides MUST
follow {cite}`requirements.configuration.evidence_paths`, including explicit
permission for otherwise excluded inputs. A denied mandatory input MUST abort
under {cite}`requirements.authoring.read_denial.mandatory`, and a denied model
read MUST return a tool error under {cite}`requirements.authoring.read_denial`.
Line numbers are only a way to request sources; recorded evidence MUST identify
sources by outline selector and structural hash, never by line number. Request
line numbers MUST be one-based and inclusive, and omitting `line_end` MUST read
through EOF. A line-range request MUST be resolved to the innermost outline
nodes covering the requested lines, which are `line` nodes in a file using the
plain-text profile; the result MUST show the model each node's selector and
source text, without line numbers, and the harness MUST record those nodes as
outline inputs. The model-facing tool description MUST include the argument conventions
from the cited requirements, including outline selector syntax, definition
selections, and full definition names, with a short request example for each form.
A successful call MUST return the requested evidence input, populated by the
harness with the selected source text, using the existing evidence schema.
{cite}`requirements.ci.schema`
Required terminology dependencies MUST be returned alongside it as additional
definition inputs under {cite}`requirements.definitions.authoring_inputs`.
For item, requirement, and definition selections, the result MUST have this shape:
```text
HabeasResult {
input: EvidenceInput,
definitions: Array<DefinitionInput>,
}
```
Line-range selections can contain multiple outline nodes. Their result MUST use
`inputs: Array<EvidenceInput>` instead of the singular `input` field, including
when only one node is selected.
`definitions` MUST be empty when no additional terminology is required. The
harness MUST record inputs supplied to the model in the assessment's evidence.
A failed read MUST add no evidence input. Access-policy denials MUST be handled
under {cite}`requirements.authoring.read_denial`; other failed reads MUST return
an explanatory tool error.
:::
Input 9: requirements selection requirements.definitions.authoring_inputs
requirements.definitions.authoring_inputs:md/requirements/definitions.md:53–65
:::{req} authoring_inputs
When preparing the mandatory input set defined by
{cite}`requirements.authoring.mandatory_inputs`, every terminology definition
referenced by the subject, any contributed source, or an acknowledgment supplied
under {cite}`requirements.authoring.fixme_inputs` MUST contribute its complete
fenced declaration, including its phrase option. Definitions referenced by those
definitions MUST also be included transitively, without duplicates or
nontermination on cycles.
When an additional source read introduces a terminology dependency, the same
complete, transitive definition set MUST be supplied to the model and recorded
before accepting a submission.
:::
Other sources
Input 1: requirements selection requirements.authoring.fixme_inputs
requirements.authoring.fixme_inputs:md/requirements/authoring.md:1305–1345
:::{req} fixme_inputs
For a requirement or example assessment, the initial request MUST include every
valid named `{fixme}` reference to the subject found under
{cite}`requirements.references.discovery`, except a reference inside one of
the subject's sites under {cite}`requirements.references.site_review`, in this
form:
```text
Acknowledgment {
file: String,
item: String,
body: String,
issues: Array<{ reference: String, state: "open" | "closed" }>,
}
```
`file` and `item` MUST locate the containing source by project-relative path and
outline selector, using `<root>` for a whole file. `body` MUST contain the
reference's complete fenced commentary without its fences or source-comment
delimiters, including its option lines, redacted under
{cite}`requirements.authoring.redaction`. `issues` MUST give every distinct issue
its `:github:` lines name, in their order, with state supplied under
{cite}`requirements.authoring.github_reads`. Acknowledgments MUST be ordered by
file and position in the file and MUST carry no line numbers or containing
implementation source.
The locations and bodies MUST be protected against staleness by the reference-set
digest under {cite}`requirements.ci.reference_set`; the acknowledgment MUST NOT
create an outline input merely to cover its containing source. Actual reads of
that source MUST still be recorded under
{cite}`requirements.authoring.delivered_inputs`. Sources MUST satisfy
{cite}`requirements.authoring.source_tools`; an inaccessible acknowledgment
MUST be reported before inference.
Terminology definitions referenced by an acknowledgment's body MUST contribute
their complete, transitive declarations to the mandatory input set under
{cite}`requirements.definitions.authoring_inputs` and MUST be recorded as
definition inputs. Only the acknowledgment's body MUST contribute these
dependencies; its containing implementation source MUST NOT be supplied merely
to discover them.
:::