requirements.cli.fixme_issues
Requirements index · View definition
Requirement
habeas statusMUST look up, under, every issue that a
:github:option line of a named or unnamed{fixme}undernames, and MUST report each
{fixme}naming an issue that is closed or does not exist as an error, with its file and line and the issue. It MUST also report the item that contains that{fixme}as failing: the outline node containing it, or the requirement or example declaration whose body contains it, in the same way it reports an uncovered Rust item. When GitHub cannot be reached, the issue MUST be assumed open. Repository validation MUST NOT contact GitHub.
Rationale
I judge the tests adequate for requirements.cli.fixme_issues. Two marked tests cover its obligations. The first is src/github.rs#mod[tests]/fn[closed_and_missing_issues_fail_their_fixmes_items_and_acknowledged_records]. The second is tests/authoring_batch.rs#fn[closing_an_acknowledged_issue_makes_the_fixme_record_stale_and_reassessed]. I did not request implementation source. I read the src/github.rs fixture only to see the inputs.
Obligations and the tests that cover them
- Look up every issue a
:github:line names, for named and unnamed{fixme}.- The
src/github.rsfixture (mod[tests]/fn[project]) has a named fixme insrc/lib.rsthat lists two issues, o/r#1 (closed) and o/r#2 (open). - It also has an unnamed fixme in the
rules.readyrequirement body (o/r#3, which does not exist), and the test adds an unnamed fixme in an example body (o/r#3). - The test asserts that o/r#1 and o/r#3 are reported and that nothing mentions o/r#2, so the open issue in a multi-issue fixme is not flagged.
- The integration test uses a named fixme in
src/lib.rsand runs the realhabeas statusbinary against a fake GitHub server.
- The
- Report each fixme naming a closed or missing issue as an error with file, line and issue.
- Exact strings are asserted:
src/lib.rs:1: {fixme} names o/r#1, which is closed,md/rules.md:6: {fixme} names o/r#3, which does not exist, andsrc/lib.rs:5: {fixme} names example/queue#125, which is closedin the CLI output. - Both the closed and the does-not-exist states are covered.
- Exact strings are asserted:
- Report the containing item as failing.
- A Rust outline node:
src/lib.rs:6: fn ready fails: its {fixme} at line 1 …. - A requirement declaration:
requirement rules.ready fails: …. - An example declaration:
example rules.unfinished fails: …. - The CLI test also checks
fn beta failsin status output. - The test fixes the exact error count at 7, so extra or missing reports would be caught.
- A Rust outline node:
- Assume the issue is open when GitHub cannot be reached.
GithubIssues::offline()and a connection to127.0.0.1:9each leaveerrorsidentical to the baseline.
- Look up through the shared cache under
requirements.authoring.github_reads.- The integration test asserts that the cache file exists under the state root.
- A cached open state is reused with no new request after the issue closes on the server.
- After the cache file is removed, exactly one new request is made and the closed state is reported.
- Repository validation MUST NOT contact GitHub.
- The unit test asserts
github.count() == 0afterinspect_repository. - The integration test calls
habeas::validate_repository, which accepts the project, and the fake server’s request count does not change.
- The unit test asserts
Gaps and acknowledgments
I found no unresolved gap. The tests use real assertions on the outcomes, and the marked tests carry {test} references. There are no acknowledgments.
Inputs
Tests
Input 4: outline src/github.rs mod[tests]/fn[closed_and_missing_issues_fail_their_fixmes_items_and_acknowledged_records]
- File:
src/github.rs - Selector:
mod[tests]/fn[closed_and_missing_issues_fail_their_fixmes_items_and_acknowledged_records] - Kind:
fn src/github.rs:1000–1065
// {test}`requirements.cli.fixme_issues`
// {test}`requirements.authoring.github_reads`
#[test]
fn closed_and_missing_issues_fail_their_fixmes_items_and_acknowledged_records() {
let github = FakeGithub::start(&[
("/repos/o/r/issues/1", 200, issue("closed", "")),
("/repos/o/r/issues/2", 200, issue("open", "")),
]);
let temp = project();
let chapter = temp.path().join("md/rules.md");
let mut text = fs::read_to_string(&chapter).unwrap();
text.push_str(
"\n::::{example} unfinished\nGiven ready, it succeeds. {cite}`rules.ready`\n\n:::{fixme}\n:github: o/r#3\nThe example is untested.\n:::\n::::\n",
);
fs::write(&chapter, text).unwrap();
let mut inspection = crate::evidence::inspect_repository(temp.path()).unwrap();
let before = inspection.report.errors.clone();
assert_eq!(github.count(), 0, "inspection reads no issues");
let issues = GithubIssues::with_api(github.endpoint.clone(), None, None);
add_issue_findings(&mut inspection, &issues);
let added = inspection.report.errors[before.len()..].to_vec();
for expected in [
"src/lib.rs:1: {fixme} names o/r#1, which is closed",
"src/lib.rs:6: fn ready fails: its {fixme} at line 1 names o/r#1, which is closed",
"md/rules.md:6: {fixme} names o/r#3, which does not exist",
"md/rules.md:3: requirement rules.ready fails: its {fixme} at line 6 names o/r#3, which does not exist",
"evidence/rules.ready.json: stale: issue o/r#1, named by the acknowledging {fixme} to rules.ready at src/lib.rs:1, is closed; reassess the record",
] {
assert!(
added.iter().any(|error| error == expected),
"{expected}\n{added:#?}"
);
}
assert!(
added.iter().any(
|error| error.contains("example rules.unfinished fails: its {fixme}")
&& error.contains("o/r#3, which does not exist")
),
"{added:#?}"
);
assert_eq!(added.len(), 7, "{added:#?}");
assert!(!added.iter().any(|error| error.contains("o/r#2")));
let missing = FakeGithub::start(&[]);
let mut missing_inspection = crate::evidence::inspect_repository(temp.path()).unwrap();
add_issue_findings(
&mut missing_inspection,
&GithubIssues::with_api(missing.endpoint.clone(), None, None),
);
assert!(
missing_inspection.report.errors.iter().any(|error| error
.contains("evidence/rules.ready.json: stale: issue o/r#1")
&& error.contains("does not exist")),
"{:?}",
missing_inspection.report.errors
);
// Unreachable issues count as open, and nothing is added.
let mut inspection = crate::evidence::inspect_repository(temp.path()).unwrap();
add_issue_findings(&mut inspection, &GithubIssues::offline());
assert_eq!(inspection.report.errors, before);
let mut inspection = crate::evidence::inspect_repository(temp.path()).unwrap();
let unreachable = GithubIssues::with_api("http://127.0.0.1:9".to_owned(), None, None);
add_issue_findings(&mut inspection, &unreachable);
assert_eq!(inspection.report.errors, before);
}
Input 5: outline tests/authoring_batch.rs fn[closing_an_acknowledged_issue_makes_the_fixme_record_stale_and_reassessed]
- File:
tests/authoring_batch.rs - Selector:
fn[closing_an_acknowledged_issue_makes_the_fixme_record_stale_and_reassessed] - Kind:
fn tests/authoring_batch.rs:2384–2483
// {test}`requirements.ci.fixme_closed_issue`
// {test}`requirements.cli.fixme_issues`
// {test}`requirements.authoring.github_reads`
// {test}`requirements.authoring.batch`
// {test}`requirements.ci.outcomes`
// {test}`requirements.configuration.state_location`
#[test]
fn closing_an_acknowledged_issue_makes_the_fixme_record_stale_and_reassessed() {
let server = Server::start_with(false, Behavior::ClosedIssueIsFalse);
let github = FakeGithub::start();
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// Zero capacity is untested.\n// :::\npub fn beta()",
),
)
.unwrap();
let run = |args: &[&str]| {
let output = fixture
.command()
.env("HABEAS_GITHUB_API_URL", &github.endpoint)
.env("GITHUB_TOKEN", "TEST_GITHUB_TOKEN")
.args(args)
.output()
.unwrap();
assert!(
output.status.success(),
"{}",
String::from_utf8_lossy(&output.stderr)
);
String::from_utf8(output.stdout).unwrap()
};
run(&["author", "--all"]);
assert!(github.headers.lock().unwrap().iter().any(|headers| {
headers
.to_ascii_lowercase()
.contains("authorization: bearer test_github_token\r\n")
}));
assert_eq!(server.subjects().len(), 6);
// The issue was open, so record the acknowledged gap as current FIXME
// evidence.
let mut beta = fixture.evidence("requirements.beta");
beta["determination"] = json!({"FIXME": ["example/queue#125"]});
fs::write(
fixture.project.join("evidence/requirements.beta.json"),
serde_json::to_vec_pretty(&beta).unwrap(),
)
.unwrap();
let cache = fixture.state.join(if cfg!(windows) {
"habeas/state/github/example+queue+125.json"
} else {
"habeas/github/example+queue+125.json"
});
assert!(
cache.exists(),
"GitHub reads are cached under the state root"
);
let status = run(&["status"]);
assert!(!status.contains("stale"), "{status}");
let reads = github.requests();
*github.state.lock().unwrap() = "closed";
// The cached open state is reused for an hour.
assert!(!run(&["status"]).contains("stale"));
assert_eq!(github.requests(), reads);
fs::remove_file(&cache).unwrap();
let status = run(&["status"]);
assert_eq!(github.requests(), reads + 1);
let row = status
.lines()
.find(|line| line.starts_with("| `requirements.beta`"))
.unwrap_or_else(|| panic!("{status}"));
assert!(row.contains("Invalid"), "{status}");
for expected in [
"evidence/requirements.beta.json: stale: issue example/queue#125, named by the acknowledging {fixme} to requirements.beta at src/lib.rs:5, is closed",
"src/lib.rs:5: {fixme} names example/queue#125, which is closed",
"src/lib.rs:9: fn beta fails: its {fixme} at line 5 names example/queue#125, which is closed",
] {
assert!(status.contains(expected), "{expected}\n{status}");
}
// Repository validation, which does not contact GitHub, still accepts it.
let report = habeas::validate_repository(&fixture.project).unwrap();
assert!(report.errors.is_empty(), "{:?}", report.errors);
assert_eq!(github.requests(), reads + 1);
run(&["author", "--all"]);
let subjects = server.subjects();
assert_eq!(subjects.len(), 7, "{subjects:?}");
assert_eq!(subjects[6], "requirement requirements.beta");
let beta = fixture.evidence("requirements.beta");
assert_eq!(beta["determination"], json!(false), "{beta}");
// Issue states are supplied with inputs but never recorded.
assert!(!beta.to_string().contains("github_issues"), "{beta}");
for run in fixture.usage() {
assert!(!run.to_string().contains("github_issues"), "{run}");
}
}
Referenced definitions
Input 2: 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 3: requirements selection requirements.references.roles
requirements.references.roles:md/requirements/references.md:3–49
:::{req} roles
Project text files MAY use the `{impl}`, `{cite}`, and `{test}` roles with a backtick-delimited full requirement or example name, or with a built-in name under {cite}`requirements.references.builtin_definitions`, and MAY use the `{fixme}` role in fenced form. A reference MAY instead be written in fenced form, `:::{role} name` on one line, a body, and a closing fence, following the fence rules of {cite}`requirements.ci.span` and {cite}`requirements.ci.fence_lengths`; the fenced form is the same edge with attached commentary, and the inline form carries none. In a source comment, fence lines MUST be recognized after removing each line's comment delimiters within one comment run under {cite}`requirements.references.outline_comments`, and a fence that does not close within its comment run MUST be a validation error. Each reference is a directed edge between its source and the named definition. A source is a project source item or a requirement or example declaration. The roles MUST mean:
- `{cite}`: the source relies on, supports, or refers to the definition. It is an
edge from the source to the definition.
- `{impl}`: the source implements part of the definition: it makes a decision,
performs a check, produces an output, or handles a case that the definition
specifies. A requirement MAY implement part of another requirement by refining
one of its obligations. Calling code that implements a definition, or
producing a result a caller uses to meet it, MUST NOT by itself count as
implementing it. A check MUST count only if the definition states it, or the
source could not meet one of the definition's obligations without it; source
that checks it is consistent with a definition, such as recognizing a form the
definition specifies in order to decide whether to run other behavior, relies
on that definition and calls for `{cite}`. A requirement stating a convention
for every output of a kind, such as every validation error, is implemented by
the source that carries out the convention as a whole, such as the step that
collects and reports those outputs.
- `{test}`: the source is designed to verify behavior the definition specifies:
a test through its scenario and the assertions about that scenario's outcome,
or a named example through the concrete case it describes.
- `{fixme}`: the source acknowledges a known gap in fulfilling the definition. It
MUST use the fenced form, and its body MUST describe the gap. The body MAY
begin with option lines naming issues that track the gap, one per line, in the
form `:github: <owner>/<repo>#<number>`, such as
`:github: rust-lang/rust#123`. `github` MUST be the only recognized option.
A named `{fixme}` MAY appear only in sources outside the book. Validation MUST report
any other option line, a `:github:` value not in that form, an inline
`{fixme}`, a `{fixme}` in a requirement or example declaration, and a
`{fixme}` whose body, without option lines and comment delimiters, is empty.
An unnamed `{fixme}`, a fence of `:::{fixme}` with no name, MAY appear in any
project text, including a requirement or example body, to tie that place to
the issues it names. It MUST have at least one `:github:` option line and MAY
have a description; it is not a reference edge, acknowledges no gap, needs no
coverage, and does not count as a reference for Rust item coverage. Its
issues are checked under {cite}`requirements.cli.fixme_issues`.
`{impl}`, `{test}`, and `{fixme}` are edges from the definition to the source.
Only requirements and examples are assessed; code is reviewed as part of the
definitions it implements or tests.
```text
{impl}`requirements.references.roles`
{cite}`requirements.references.roles`
{test}`requirements.references.roles`
```
:::
Other sources
Input 1: requirements selection requirements.cli.fixme_issues
requirements.cli.fixme_issues:md/requirements/cli.md:40–50
:::{req} fixme_issues
`habeas status` MUST look up, under {cite}`requirements.authoring.github_reads`,
every issue that a `:github:` option line of a named or unnamed `{fixme}` under
{cite}`requirements.references.roles` names, and MUST report each `{fixme}`
naming an issue that is closed or does not exist as an error, with its file and
line and the issue. It MUST also report the item that contains that `{fixme}` as
failing: the outline node containing it, or the requirement or example
declaration whose body contains it, in the same way it reports an uncovered
Rust item. When GitHub cannot be reached, the issue MUST be assumed open.
Repository validation MUST NOT contact GitHub.
:::