requirements.cli.refactor_skill.limits
Requirements index · View definition
Requirement
The
habeas-refactorskill MUST tell agents not to edit evidence files by hand to follow a move, and that renaming a function or editing moved text is not a move and needs reassessment.
Rationale
Verdict: the subject’s obligations are carried out by assets/skills/habeas-refactor/SKILL.md and tested. I found no gaps.
The requirement text is the skill’s ## Gotchas section in assets/skills/habeas-refactor/SKILL.md. It has two obligations, and the skill covers both:
-
Do not hand-edit evidence files to follow a move. The first Gotchas bullet says “Never edit evidence files by hand to follow a move;
habeas refactorupdates them only where it can check that nothing reviewed changed.” -
A rename or edited moved text is not a move and needs reassessment.
- The second bullet says “A rename is not a move.” Renaming a function, type, or other item changes its code and structural hash, so “its evidence needs reassessment with habeas-evidence.”
- The third bullet says editing moved code or text in the same step leaves every record that read it stale. It tells the agent to move first, run the command, commit, then edit.
- Workflow step 8 then has the agent reassess what remains stale with
habeas author --all.
The third bullet doesn’t use the word “reassessment” itself, but “stale” plus step 8 conveys it.
Test: tests/authoring_cli.rs#fn[the_refactor_skill_never_hand_edits_evidence_and_a_rename_is_not_a_move] carries the {test} reference to the subject.
- It extracts the
## Gotchassection, with line wrapping collapsed bycollapse. - It asserts that the section contains these four phrases:
- “Never edit evidence files by hand to follow a move”
- “A rename is not a move. Renaming a function, type, or other item changes its code”
- “its evidence needs reassessment”
- “Editing moved code or text in the same step leaves every record that read it stale”
- Together these cover each obligation, and they match the wording in the skill file.
The skill file is a document with no conditionals, and the subject’s text names no failure or boundary cases, so nothing else needs a test.
Inputs
Implementation
Input 3: outline assets/skills/habeas-refactor/SKILL.md (whole file)
- File:
assets/skills/habeas-refactor/SKILL.md - Selector:
(root) - Kind:
file assets/skills/habeas-refactor/SKILL.md:1–71
---
name: habeas-refactor
description: Use when a change moves code, tests, or requirements in a Habeas project to another file, chapter, or outline node, such as moving a function to another module, renaming or splitting a file, splitting or merging modules or chapters, or moving or renaming a requirement, so that evidence whose content is unchanged is not invalidated. Covers making the move and running `habeas refactor` to update evidence, references, and anchors. Not for changing what code or requirements say; use habeas-requirements.
---
# Habeas refactor
Evidence records where it read code and requirements: files, outline selectors
such as `fn[load]`, and full definition names. A move changes those addresses
without changing what was reviewed. `habeas refactor` rewrites the addresses,
so the evidence stays current without a model reassessing it.
## Workflow
Run commands from the project root, the directory with `book.toml` and
`Cargo.toml`.
- [ ] 1. Make the move with your own edits: move the file, cut and paste the
function, or move the `{req}` directive to its new chapter. Change
nothing else in this step. Keep the moved code's text, including doc
comments, and the moved requirement's text exactly as they were. Leave
`{impl}`, `{test}`, `{cite}`, `{fixme}`, and `{term}` references to a
moved definition, and `:impl:` and `:test:` anchors to a moved file,
as they are; the command rewrites them.
- [ ] 2. Record the move in the Git index: `git mv` for a moved file, or
`git add -A` on both the old and new paths. Reference discovery reads
only files in the Git index, so a stale old path still counts.
- [ ] 3. `habeas refactor --dry-run` with one `--map <old>=<new>` for every
moved file or directory, node, and definition name:
- a file or directory: `--map src/config.rs=src/settings.rs`, which also
covers every file under a directory;
- a node: `--map 'src/config.rs#fn[load]=src/config/load.rs#fn[load]'`,
which also covers the nodes inside it (quote it for the shell);
- a definition: `--map requirements.cli.check=requirements.core.check`,
which also covers the names beneath it, such as
`requirements.cli.check.case`.
To find a node's selector, `habeas info <name>` lists the inputs of a
requirement that reads it.
- [ ] 4. Review the report:
- "Would rewrite" lists the sources whose references or anchors change;
- "Would change" lists the records it updates, with each code span in
their rationales that still mentions an old path. The command leaves
rationale prose alone; show these spans to the user, and if they ask
for a record to be reassessed, run `habeas author --force <full-name>`
after step 7;
- "Would leave ... unchanged" lists records a mapping affects that fail a
check, with the reason. An unexpected one usually means the moved text
changed, or a mapping is missing; fix that and run the dry run again.
- [ ] 5. Run the same command without `--dry-run`.
- [ ] 6. `habeas status`. Only the records the report left unchanged, and any
that were stale before, should need attention.
- [ ] 7. Commit the move, the rewritten references, and the `evidence/` changes
together, before any change to behavior or text.
- [ ] 8. Next, reassess what remains stale with `habeas author --all`,
following the habeas-evidence skill, and if assessments disagree, its
"Disagreeing assessments"; then make any behavior or text changes as separate commits under
the habeas-requirements skill.
## Gotchas
- Never edit evidence files by hand to follow a move; `habeas refactor` updates
them only where it can check that nothing reviewed changed.
- A rename is not a move. Renaming a function, type, or other item changes its
code, and so its structural hash: its evidence needs reassessment with
habeas-evidence. Renaming a requirement's ID is a definition mapping, and
works when its text is otherwise unchanged.
- Editing moved code or text in the same step leaves every record that read it
stale. Move first, run the command, commit, then edit.
- A requirements input that selects a glob, such as `requirements.cli.*`, stays
stale when a definition moves out of it or into it: what it matches changed.
Tests
Input 2: outline tests/authoring_cli.rs fn[the_refactor_skill_never_hand_edits_evidence_and_a_rename_is_not_a_move]
- File:
tests/authoring_cli.rs - Selector:
fn[the_refactor_skill_never_hand_edits_evidence_and_a_rename_is_not_a_move] - Kind:
fn tests/authoring_cli.rs:5098–5111
// {test}`requirements.cli.refactor_skill.limits`
#[test]
fn the_refactor_skill_never_hand_edits_evidence_and_a_rename_is_not_a_move() {
assert_text(
"refactor gotchas",
§ion(skill_md("habeas-refactor"), "## Gotchas"),
&[
"Never edit evidence files by hand to follow a move",
"A rename is not a move. Renaming a function, type, or other item changes its code",
"its evidence needs reassessment",
"Editing moved code or text in the same step leaves every record that read it stale",
],
);
}
Other sources
Input 1: requirements selection requirements.cli.refactor_skill.limits
requirements.cli.refactor_skill.limits:md/requirements/cli.md:437–442
:::{req} refactor_skill.limits
The `habeas-refactor` skill MUST tell agents not to edit evidence files by hand
to follow a move, and that renaming a function or editing moved text is not a
move and needs reassessment.
:::