requirements.refactor.record_fields
Requirements index · View definition
Requirement
For each changed record,
habeas refactorMUST rewrite every recorded file, selector, definition name, definition selection, and match the mappings cover, including thecitations,requirement,file, anditemfields of citation and site reviews, and MUST record the current text, hash, and reference-set digest where it rewrote the corresponding field.
Rationale
I found no gap. Each obligation maps to code reachable from the {impl} item, and each is exercised by a {test} that asserts the outcome.
Code
src/refactor.rs#fn[rewrite_record]carries the{impl}forrequirements.refactor.record_fields.- Definition records:
- It maps the record’s own name through
mappings.name. - It records the current definition text from
definitions_post. - It records the current reference-set digest in the
referencesfield, and refuses to change a field whose recorded value was already stale.
- It maps the record’s own name through
- Citation and site reviews:
- It rewrites
fileanditemthroughmappings.node. - For citations, it rewrites each
citations[].namethroughmappings.nameand rewrites thecommentarytext throughrewrite_source. - For sites, it rewrites
requirementthroughmappings.name.
- It rewrites
- Recorded inputs:
rewrite_recordcallsrewrite_inputon each input.rewrite_inputis reachable fromrewrite_record, so it needs no reference of its own for this requirement.- Outline inputs: it rewrites the recorded
fileanditem(selector) and records the currenthash. - Definition inputs: it rewrites the
definitionname and records the current definition text. - Requirements inputs: it rewrites the
requirementsselection viamappings.selection, maps thematcheslist, and re-resolves it to record the current text.
- Outline inputs: it rewrites the recorded
Tests
tests/refactor.rs#fn[a_moved_function_keeps_its_evidence_current]covers outline-input file and selector, and the recorded hash and reference-set digest. It assertsinputs[1].filechanged and thaterrors(root)is empty afterwards.tests/refactor.rs#fn[a_moved_term_rewrites_definition_inputs_and_the_texts_using_it]covers the definition name in a definition input and the record’srequirementtext.tests/refactor.rs#fn[a_moved_chapter_rewrites_glob_selections_and_their_matches]covers therequirementsselection and thematcheslist.tests/refactor.rs#fn[a_citation_review_follows_its_item_and_the_name_it_cites]coversfile,itemandcitations[].namein citation reviews, plus the inputs.tests/refactor.rs#fn[a_citation_reviews_commentary_follows_a_renamed_requirement]covers rewriting of citation commentary and of a definition input.src/refactor/tests.rs#fn[site_reviews_follow_their_site_and_renamed_requirement]covers the site reviewrequirement,fileanditemfields.
No {fixme} references apply.
Inputs
Implementation
Input 3: outline src/refactor.rs fn[rewrite_record]
- File:
src/refactor.rs - Selector:
fn[rewrite_record] - Kind:
fn src/refactor.rs:722–894
/// Decides one record under the mappings.
// {impl}`requirements.refactor.whole_record`
// {impl}`requirements.refactor.subject_text`
// {impl}`requirements.refactor.record_fields`
// {impl}`requirements.refactor.reference_digest`
fn rewrite_record(states: &States, path: &str, record: &Value) -> io::Result<Outcome> {
let mappings = &states.mappings;
let Some(kind) = record_kind(path) else {
return Ok(Outcome::Unaffected);
};
let mut value = record.clone();
let mut changed = false;
let mut failures = Vec::new();
let new_path = match &kind {
RecordKind::Definition(name) => {
let new = mappings.name(name).unwrap_or_else(|| name.clone());
let field = if record.get("example").is_some() {
"example"
} else {
"requirement"
};
let body = |definitions: &BTreeMap<String, Declaration>, name: &str| {
definitions
.get(name)
.map(|definition| definition.text.clone())
};
if new != *name
|| body(&states.definitions, name) != body(&states.definitions_post, &new)
{
match (
body(&states.definitions_back, name),
body(&states.definitions_post, &new),
) {
(Some(back), Some(current))
if Some(back.as_str()) == record[field].as_str() =>
{
value[field] = Value::String(current);
changed = true;
}
(_, None) => {
failures.push(format!("{new}: no current definition"));
changed = true;
}
_ => {
failures.push(format!("{field} text of {new} changed"));
changed = true;
}
}
}
if let Some(recorded) = record.get("references").and_then(Value::as_str)
&& let Some((current, back)) = states.digests(&new, name)?
&& current != recorded
&& (new != *name || current != back)
{
if back == recorded {
value["references"] = Value::String(current);
changed = true;
} else {
failures.push(format!("the reference set of {new} changed"));
changed = true;
}
}
if new != *name {
changed = true;
}
format!("evidence/{new}.json")
}
RecordKind::Citation | RecordKind::Site => {
let file = record
.get("file")
.and_then(Value::as_str)
.unwrap_or_default();
let item = record
.get("item")
.and_then(Value::as_str)
.unwrap_or_default();
let (new_file, new_item) = mappings
.node(file, item)
.unwrap_or((file.to_owned(), item.to_owned()));
if (new_file.as_str(), new_item.as_str()) != (file, item) {
value["file"] = json!(new_file);
value["item"] = json!(new_item);
changed = true;
}
match &kind {
RecordKind::Citation => {
if let Some(citations) =
value.get_mut("citations").and_then(Value::as_array_mut)
{
for citation in citations {
let name = citation["name"].as_str().unwrap_or_default();
if let Some(new) = mappings.name(name) {
citation["name"] = json!(new);
changed = true;
}
let commentary = citation["commentary"]
.as_str()
.unwrap_or_default()
.to_owned();
let (new, edits) =
rewrite_source(mappings, Path::new("commentary"), &commentary);
if edits > 0 {
citation["commentary"] = json!(new);
changed = true;
}
}
}
// :::{impl} requirements.refactor.equivalence
// A citation review validates against the citations its
// item currently carries, so a review whose rewritten
// citations differ from those would validate differently
// after the move; the record is left unchanged instead.
// :::
if changed && !same_citations(states, &new_file, &new_item, &value) {
failures.push(format!(
"the citations of {} differ from the recorded ones",
address(&new_file, &new_item)
));
}
crate::citations::review_path(&new_file, &new_item)
}
_ => {
let requirement = record
.get("requirement")
.and_then(Value::as_str)
.unwrap_or_default();
let new = mappings
.name(requirement)
.unwrap_or_else(|| requirement.to_owned());
if new != requirement {
value["requirement"] = json!(new);
changed = true;
}
crate::sites::review_path(&new, &new_file, &new_item)
}
}
}
};
if let Some(inputs) = value.get_mut("inputs").and_then(Value::as_array_mut) {
for (index, input) in inputs.iter_mut().enumerate() {
match rewrite_input(states, input) {
None => {}
Some(Ok(new)) => {
if new != *input {
*input = new;
changed = true;
}
}
Some(Err(error)) => {
failures.push(format!("inputs[{index}]: {error}"));
changed = true;
}
}
}
}
if !changed {
return Ok(Outcome::Unaffected);
}
if !failures.is_empty() {
return Ok(Outcome::Unchanged(failures.join("; ")));
}
let mut mentions = Vec::new();
if let Some(rationale) = value.get("rationale").and_then(Value::as_str) {
let (rewritten, found) = rewrite_rationale(mappings, rationale);
value["rationale"] = Value::String(rewritten);
mentions = found;
}
Ok(Outcome::Changed {
path: new_path,
value,
mentions,
})
}
Tests
Input 2: outline src/refactor/tests.rs fn[site_reviews_follow_their_site_and_renamed_requirement]
- File:
src/refactor/tests.rs - Selector:
fn[site_reviews_follow_their_site_and_renamed_requirement] - Kind:
fn src/refactor/tests.rs:249–320
// {test}`requirements.refactor.record_files`
// {test}`requirements.refactor.record_fields`
// {test}`requirements.refactor.equivalence`
#[test]
fn site_reviews_follow_their_site_and_renamed_requirement() {
use crate::sites::tests::{RULE, SOURCE, inspect, project, write_review};
let temp = project(RULE, SOURCE);
let root = temp.path();
fs::write(
root.join("evidence/requirements.rule.json"),
json!({"requirement": "x", "determination": true, "rationale": "Fine.", "inputs": []})
.to_string(),
)
.unwrap();
crate::evidence::tests::stamp_reference_sets(root);
write_review(
root,
"fn[check_one]",
json!({"queries": ["checkers", "panics"]}),
);
write_review(root, "fn[check_two]", json!({}));
write_review(
root,
"mod[inner]/fn[check_three]",
json!({"queries": ["checkers", "panics"]}),
);
let site_errors = |root: &Path| {
let (errors, _) = inspect(root);
errors
.into_iter()
.filter(|error| error.starts_with("evidence/sites/"))
.collect::<Vec<_>>()
};
assert_eq!(site_errors(root), Vec::<String>::new());
// The requirement moves to the `rules` chapter and `check_two` to its
// own file, both unchanged.
let chapter = fs::read_to_string(root.join("md/requirements.md")).unwrap();
fs::remove_file(root.join("md/requirements.md")).unwrap();
fs::write(root.join("md/rules.md"), chapter).unwrap();
fs::write(
root.join("src/lib.rs"),
SOURCE.replace("fn check_two() {}\n", ""),
)
.unwrap();
fs::write(root.join("src/other.rs"), "fn check_two() {}\n").unwrap();
let report = refactor(
root,
&[
"requirements.rule=rules.rule".to_owned(),
"src/lib.rs#fn[check_two]=src/other.rs#fn[check_two]".to_owned(),
],
false,
)
.unwrap();
assert!(
report.contains(
"- evidence/sites/requirements.rule/src/lib.rs/fn[check_two].json -> evidence/sites/rules.rule/src/other.rs/fn[check_two].json"
),
"{report}"
);
let moved: Value = serde_json::from_str(
&fs::read_to_string(root.join("evidence/sites/rules.rule/src/other.rs/fn[check_two].json"))
.unwrap(),
)
.unwrap();
assert_eq!(moved["requirement"], "rules.rule");
assert_eq!(moved["file"], "src/other.rs");
assert_eq!(moved["item"], "fn[check_two]");
assert!(!root.join("evidence/sites/requirements.rule").exists());
assert_eq!(site_errors(root), Vec::<String>::new());
}
Input 4: outline tests/refactor.rs fn[a_moved_function_keeps_its_evidence_current]
- File:
tests/refactor.rs - Selector:
fn[a_moved_function_keeps_its_evidence_current] - Kind:
fn tests/refactor.rs:171–241
// {test}`requirements.refactor.moved_function`
// {test}`requirements.refactor.command`
// {test}`requirements.refactor.outline_inputs`
// {test}`requirements.refactor.reference_digest`
// {test}`requirements.refactor.rationale.addresses`
// {test}`requirements.refactor.rationale.untouched`
// {test}`requirements.refactor.record_fields`
// {test}`requirements.refactor.equivalence`
// {test}`requirements.refactor.whole_record`
// {test}`requirements.refactor.mappings`
#[test]
fn a_moved_function_keeps_its_evidence_current() {
let temp = project();
let root = temp.path();
author(root);
assert_eq!(errors(root), Vec::<String>::new());
move_load(root, "");
let stale = errors(root);
assert!(
stale.iter().any(|error| error.contains("fn[load]")),
"{stale:#?}"
);
let unaffected = fs::read(root.join("evidence/rules.check.json")).unwrap();
let output = refactor(
root,
&[
"--map",
"src/config.rs#fn[load]=src/config/load.rs#fn[load]",
],
);
assert!(output.status.success(), "{output:?}");
let report = stdout(&output);
assert!(
report.contains("Changed 1 records:\n- evidence/rules.load.json\n"),
"{report}"
);
// The other mention of the old file is listed for review.
assert!(
report.contains("review the rationale's `src/config.rs`"),
"{report}"
);
// `rules.check` reads no moved node, so it is unaffected and unchanged.
assert!(!report.contains("rules.check"), "{report}");
assert_eq!(
fs::read(root.join("evidence/rules.check.json")).unwrap(),
unaffected
);
assert_eq!(errors(root), Vec::<String>::new());
let record: Value =
serde_json::from_str(&fs::read_to_string(root.join("evidence/rules.load.json")).unwrap())
.unwrap();
assert_eq!(record["inputs"][1]["file"], "src/config/load.rs");
assert_eq!(
record["rationale"],
"`src/config/load.rs#fn[load]` loads it, as `rules.load` asks; `verify` tests it in `src/config.rs`."
);
// Running it again changes nothing.
let again = refactor(
root,
&[
"--map",
"src/config.rs#fn[load]=src/config/load.rs#fn[load]",
],
);
assert!(
stdout(&again).contains("Changed 0 records:"),
"{}",
stdout(&again)
);
}
Input 5: outline tests/refactor.rs fn[a_citation_review_follows_its_item_and_the_name_it_cites]
- File:
tests/refactor.rs - Selector:
fn[a_citation_review_follows_its_item_and_the_name_it_cites] - Kind:
fn tests/refactor.rs:569–653
// {test}`requirements.refactor.record_files`
// {test}`requirements.refactor.record_fields`
// {test}`requirements.refactor.equivalence`
#[test]
fn a_citation_review_follows_its_item_and_the_name_it_cites() {
let temp = project();
let root = temp.path();
let cited = format!(
"{}\n// {{cite}}`rules.load`\nfn helper() {{}}\n",
config_source("")
);
fs::write(root.join("src/config.rs"), &cited).unwrap();
author(root);
let review = |root: &Path, file: &str, name: &str, text: &[&str]| {
json!({
"file": file,
"item": "fn[helper]",
"citations": [{"role": "cite", "name": name, "commentary": ""}],
"determination": true,
"rationale": format!("`{file}#fn[helper]` relies on `{name}`."),
"inputs": [
habeas::outline_input(root, file, "fn[helper]").unwrap(),
requirements_input(name, &[name], text),
],
})
};
fs::create_dir_all(root.join("evidence/citations/src/config.rs")).unwrap();
fs::write(
root.join("evidence/citations/src/config.rs/fn[helper].json"),
serde_json::to_string_pretty(&review(root, "src/config.rs", "rules.load", &LOAD_TEXT))
.unwrap(),
)
.unwrap();
assert_eq!(errors(root), Vec::<String>::new());
// The helper moves to its own file, and `load` to the `core` chapter.
fs::write(root.join("src/config.rs"), config_source("")).unwrap();
fs::write(
root.join("src/helper.rs"),
"// {cite}`rules.load`\nfn helper() {}\n",
)
.unwrap();
fs::write(
root.join("md/rules.md"),
"# Rules\n\n:::{req} check\n:impl: data.txt\nThe data MUST be checked.\n:::\n",
)
.unwrap();
fs::write(
root.join("md/core.md"),
"# Core\n\n:::{req} load\nConfiguration MUST load.\n:::\n",
)
.unwrap();
let output = refactor(
root,
&[
"--map",
"src/config.rs#fn[helper]=src/helper.rs#fn[helper]",
"--map",
"rules.load=core.load",
],
);
assert!(output.status.success(), "{output:?}");
assert!(
stdout(&output).contains(
"- evidence/citations/src/config.rs/fn[helper].json -> evidence/citations/src/helper.rs/fn[helper].json"
),
"{}",
stdout(&output)
);
assert!(!root.join("evidence/citations/src/config.rs").exists());
let moved: Value = serde_json::from_str(
&fs::read_to_string(root.join("evidence/citations/src/helper.rs/fn[helper].json")).unwrap(),
)
.unwrap();
assert_eq!(
moved,
review(root, "src/helper.rs", "core.load", &LOAD_TEXT)
);
let remaining = errors(root);
assert!(
remaining
.iter()
.all(|error| error.starts_with("evidence/rules.check.json")),
"{remaining:#?}"
);
}
Input 6: outline tests/refactor.rs fn[a_moved_term_rewrites_definition_inputs_and_the_texts_using_it]
- File:
tests/refactor.rs - Selector:
fn[a_moved_term_rewrites_definition_inputs_and_the_texts_using_it] - Kind:
fn tests/refactor.rs:832–868
// {test}`requirements.refactor.definition_inputs`
// {test}`requirements.refactor.subject_text`
// {test}`requirements.refactor.reference_rewrite`
// {test}`requirements.refactor.rationale.names`
// {test}`requirements.refactor.record_fields`
#[test]
fn a_moved_term_rewrites_definition_inputs_and_the_texts_using_it() {
let temp = project();
let root = temp.path();
add_term(root);
assert_eq!(usage_errors(root), Vec::<String>::new());
fs::remove_file(root.join("md/terms.md")).unwrap();
fs::write(
root.join("md/glossary.md"),
"# Glossary\n\n:::{definition} term\n:phrase: term\n\nA word.\n:::\n",
)
.unwrap();
let output = refactor(root, &["--map", "terms.term=glossary.term"]);
assert!(output.status.success(), "{output:?}");
assert_eq!(
fs::read_to_string(root.join("md/usage.md")).unwrap(),
"# Usage\n\n:::{req} use\nThe {term}`glossary.term` MUST be used.\n:::\n"
);
let record: Value =
serde_json::from_str(&fs::read_to_string(root.join("evidence/usage.use.json")).unwrap())
.unwrap();
assert_eq!(
record["requirement"],
"The {term}`glossary.term` MUST be used."
);
assert_eq!(record["inputs"][1]["definition"], "glossary.term");
assert_eq!(
record["rationale"],
"Nothing implements `usage.use`, which uses `glossary.term`."
);
assert_eq!(usage_errors(root), Vec::<String>::new());
}
Input 7: outline tests/refactor.rs fn[a_moved_chapter_rewrites_glob_selections_and_their_matches]
- File:
tests/refactor.rs - Selector:
fn[a_moved_chapter_rewrites_glob_selections_and_their_matches] - Kind:
fn tests/refactor.rs:955–982
// {test}`requirements.refactor.record_fields`
// {test}`requirements.refactor.definition_inputs`
// {test}`requirements.refactor.equivalence`
// {test}`requirements.refactor.mappings`
#[test]
fn a_moved_chapter_rewrites_glob_selections_and_their_matches() {
let temp = project();
let root = temp.path();
author(root);
let chapter = fs::read_to_string(root.join("md/rules.md")).unwrap();
fs::remove_file(root.join("md/rules.md")).unwrap();
fs::write(
root.join("md/core.md"),
chapter.replace("# Rules", "# Core"),
)
.unwrap();
let output = refactor(root, &["--map", "rules=core"]);
assert!(output.status.success(), "{output:?}");
let record: Value =
serde_json::from_str(&fs::read_to_string(root.join("evidence/core.check.json")).unwrap())
.unwrap();
assert_eq!(record["inputs"][0]["requirements"], "core.*");
assert_eq!(
record["inputs"][0]["matches"],
json!(["core.check", "core.load"])
);
assert_eq!(errors(root), Vec::<String>::new());
}
Input 8: outline tests/refactor.rs fn[a_citation_reviews_commentary_follows_a_renamed_requirement]
- File:
tests/refactor.rs - Selector:
fn[a_citation_reviews_commentary_follows_a_renamed_requirement] - Kind:
fn tests/refactor.rs:984–1046
// {test}`requirements.refactor.record_fields`
#[test]
fn a_citation_reviews_commentary_follows_a_renamed_requirement() {
let temp = project();
let root = temp.path();
let source = |name: &str| {
format!(
"{}\n// :::{{cite}} rules.check\n// Shares {{term}}`{name}` wording.\n// :::\nfn helper() {{}}\n",
config_source("")
)
};
fs::write(
root.join("md/terms.md"),
"# Terms\n\n:::{definition} word\n:phrase: word\n\nA word.\n:::\n",
)
.unwrap();
fs::write(root.join("src/config.rs"), source("terms.word")).unwrap();
author(root);
let review = |name: &str| {
json!({
"file": "src/config.rs",
"item": "fn[helper]",
"citations": [{"role": "cite", "name": "rules.check", "commentary": format!("Shares {{term}}`{name}` wording.")}],
"determination": true,
"rationale": "It relies on `rules.check`.",
"inputs": [
habeas::outline_input(root, "src/config.rs", "fn[helper]").unwrap(),
requirements_input("rules.check", &["rules.check"], &CHECK_TEXT),
{"definition": name, "text": [":::{definition} word", ":phrase: word", "", "A word.", ":::"]},
],
})
};
let path = root.join("evidence/citations/src/config.rs/fn[helper].json");
fs::create_dir_all(path.parent().unwrap()).unwrap();
fs::write(
&path,
serde_json::to_string_pretty(&review("terms.word")).unwrap(),
)
.unwrap();
let citation_errors = |root: &Path| {
errors(root)
.into_iter()
.filter(|error| error.starts_with("evidence/citations/"))
.collect::<Vec<_>>()
};
assert_eq!(citation_errors(root), Vec::<String>::new());
fs::remove_file(root.join("md/terms.md")).unwrap();
fs::write(
root.join("md/glossary.md"),
"# Glossary\n\n:::{definition} word\n:phrase: word\n\nA word.\n:::\n",
)
.unwrap();
let output = refactor(root, &["--map", "terms.word=glossary.word"]);
assert!(output.status.success(), "{output:?}");
assert_eq!(
fs::read_to_string(root.join("src/config.rs")).unwrap(),
source("glossary.word")
);
let record: Value = serde_json::from_str(&fs::read_to_string(&path).unwrap()).unwrap();
assert_eq!(record["citations"], review("glossary.word")["citations"]);
assert_eq!(record["inputs"][2]["definition"], "glossary.word");
assert_eq!(citation_errors(root), Vec::<String>::new());
}
Other sources
Input 1: requirements selection requirements.refactor.record_fields
requirements.refactor.record_fields:md/requirements/refactor.md:118–124
:::{req} record_fields
For each changed record, `habeas refactor` MUST rewrite every recorded file,
selector, definition name, definition selection, and match the mappings cover,
including the `citations`, `requirement`, `file`, and `item` fields of citation
and site reviews, and MUST record the current text, hash, and reference-set
digest where it rewrote the corresponding field.
:::
Input 9: outline src/refactor.rs fn[rewrite_input]
- File:
src/refactor.rs - Selector:
fn[rewrite_input] - Kind:
fn src/refactor.rs:623–720
/// Rewrites one input, or returns `None` when no mapping affects it.
// {impl}`requirements.refactor.outline_inputs`
// {impl}`requirements.refactor.definition_inputs`
fn rewrite_input(states: &States, input: &Value) -> Option<Result<Value, String>> {
let mappings = &states.mappings;
let root = &states.root;
match InputSelector::from_input(input)? {
InputSelector::Outline { file, item } => {
let recorded = input.get("hash").and_then(Value::as_str)?;
let mapped = mappings.node(&file, &item);
let (new_file, new_item) = mapped.clone().unwrap_or((file.clone(), item.clone()));
if mapped.is_none() && !states.rewritten.contains_key(&new_file) {
return None;
}
let back = states.hash(&states.outlines_back, &new_file, &new_item);
let current = states.hash(&states.outlines_post, &new_file, &new_item);
Some(match (back, current) {
(Ok(back), Ok(current)) if back == recorded => {
Ok(json!({"file": new_file, "item": new_item, "hash": current}))
}
(Err(error), _) | (_, Err(error)) => Err(error),
_ => Err(format!(
"{} no longer has the recorded hash",
address(&new_file, &new_item)
)),
})
}
selector @ (InputSelector::Requirements { .. } | InputSelector::Definition { .. }) => {
let (new_selector, names) = match &selector {
InputSelector::Requirements { requirements } => (
InputSelector::Requirements {
requirements: mappings
.selection(requirements)
.unwrap_or_else(|| requirements.clone()),
},
input
.get("matches")
.and_then(Value::as_array)
.into_iter()
.flatten()
.filter_map(Value::as_str)
.map(str::to_owned)
.collect::<Vec<_>>(),
),
InputSelector::Definition { definition } => (
InputSelector::Definition {
definition: mappings
.name(definition)
.unwrap_or_else(|| definition.clone()),
},
vec![definition.clone()],
),
InputSelector::Outline { .. } => unreachable!(),
};
let affected = new_selector != selector
|| names.iter().any(|name| {
let new = mappings.name(name).unwrap_or_else(|| name.clone());
mappings.name(name).is_some()
|| states.definitions.get(name).map(|d| &d.raw_lines)
!= states.definitions_post.get(&new).map(|d| &d.raw_lines)
});
if !affected {
return None;
}
let back = selector
.resolve(root, &states.definitions_back, &states.outlines_back)
.map(|resolved| selector.to_input(&resolved));
let current = new_selector
.resolve(root, &states.definitions_post, &states.outlines_post)
.map(|resolved| new_selector.to_input(&resolved));
Some(match (back, current) {
(Ok(back), Ok(current))
if &back == input && {
let mut mapped = names
.iter()
.map(|name| mappings.name(name).unwrap_or_else(|| name.clone()))
.collect::<Vec<_>>();
mapped.sort();
current
.get("matches")
.is_none_or(|matches| *matches == json!(mapped))
} =>
{
Ok(current)
}
(_, Err(error)) => Err(error),
_ => Err(format!(
"{} no longer selects what it recorded",
match &new_selector {
InputSelector::Requirements { requirements } => requirements,
InputSelector::Definition { definition } => definition,
InputSelector::Outline { .. } => unreachable!(),
}
)),
})
}
}
}