Repository navigation
Description
What happened
PR #2801 was made by the implement job. In it, the agent replaced the whole of the test file tests/test_config_write_history.py with two new tests. Seven existing tests were deleted (141 lines). All checks of the step passed, because a deleted test cannot fail. The pull request was then merged. The restore of the tests is #(the issue that restores them).
The job judges the work with the verification commands of the group, ruff check and mypy. Nothing checks that the step keeps the tests that existed before it.
What should happen
A step may add tests. It may not remove an existing test. After the run, for each existing test file that the step changed, every test function that the file had at the start of the step must still be in the file (a function with the same name, at module level or in the same class). When a function is missing, the step stops and names the file and the functions. A person who really wants to remove a test does it in a pull request of their own.
Use the Python parser in the standard library (ast) to list the names. Do not parse with a regular expression.
Evidence
- Merged PR fix(config): config files and their copies keep the mode of the file,... #2801, file
tests/test_config_write_history.py. _exit_failureinsrc/devops_cli/roadmap/implement_step.pyholds the exit checks to which the new check is added.
Acceptance criteria
- A step that replaces a test file and drops one of its tests stops with a reason that names the file and the test.
- A step that adds tests to an existing file ends done.
- A step that renames a test stops (the rule is by name).
- A new test file, and a file with a syntax error, do not crash the check.
- The
roadmap-implement-stepspec names the check. -
uv run devops cipasses.
Proposed design
Problem statement
The implement step judges its work with ruff and mypy. Nothing checks that the step keeps the test functions that existed before it. PR #2801 deleted seven existing tests from tests/test_config_write_history.py, and all checks passed because a deleted test cannot fail. The step must stop when it removes an existing test function from a test file.
Acceptance criteria
Requirement: Test removal stops the step
A step that removes a test function from an existing test file SHALL stop with a reason that names the file and the missing test function.
Scenario: Step drops one test from a file
- WHEN A step changes a test file and one of its test functions is missing after the step
- THEN The step stops with a reason that names the file path and the missing test function name
Requirement: Test addition ends done
A step that adds test functions to an existing test file SHALL end done when all original test functions are still present.
Scenario: Step adds a new test to a file
- WHEN A step changes a test file and all original test functions are still present with new ones added
- THEN The step ends done
Requirement: Test rename stops the step
A step that renames a test function SHALL stop because the rule is by name.
Scenario: Step renames a test function
- WHEN A step changes a test file and a test function name changes to a different name
- THEN The step stops with a reason that names the file path and the missing test function name
Requirement: No crash on new file or syntax error
The check SHALL not crash when a test file is new or has a syntax error.
Scenario: New test file
- WHEN A step creates a new test file that did not exist before the step
- THEN The check passes without error and the step continues
Requirement: Spec names the check
The roadmap-implement-step spec SHALL name the test-removal check.
Scenario: Spec contains the check
- WHEN The roadmap-implement-step spec is read
- THEN It names the test-removal check and its rule
Requirement: CI passes
uv run devops ci SHALL pass after the change.
Scenario: CI runs
- WHEN uv run devops ci is run on the branch
- THEN It exits 0
Existing Tool Considered
No check has run. No open, maintained tool covers the need of comparing test function names before and after a step. The project builds its own check using the Python standard library ast module. The written cost is about 1200 tokens to build: a function of 20 lines to extract test names from a file, 10 lines to compare the before and after sets, 5 lines to wire the check into _exit_failure, and 80 lines of tests. Ongoing cost is minimal because the check uses only the standard library and compares two sets of names.
Key questions
- How to extract test function names from a Python file?: Use ast.parse to get the module tree, then collect the names of FunctionDef and AsyncFunctionDef nodes whose name starts with test_, at module level or as methods of a ClassDef node. (best practice) [sources: src/devops_cli/roadmap/implement_step.py, tests/test_config_write_history.py]
- Chosen: ast module. The body mandates it. It is in the standard library, needs no dependency, and handles classes and async functions correctly.
- Rejected: Regular expression. The body rejects it. A regex cannot handle nested classes, decorators, or syntax errors safely.
- Rejected: pytest collection. Requires importing pytest and making the file importable. Overkill for a name comparison, and the file may have import errors.
- Where in the exit check sequence to place the new check?: After _static_failure, as the last check in _exit_failure. It is a file-level guard on the changed files, the same category as the static checks. (best practice) [sources: src/devops_cli/roadmap/implement_step.py]
- Chosen: After _static_failure. It guards the changed files, the same category as the static checks. Placing it last means the cheaper checks run first.
- Rejected: Before _verification_failure. Verification commands are the primary gate named by the task group. The test-removal check is a secondary guard.
- Rejected: Before _format_failure. Formatting is a lower-priority concern. The test-removal check is more important than formatting.
- How to obtain the before content of a changed test file?: Read the file from git at the start commit using git show :. The step already tracks start as the HEAD before the run. (best practice) [sources: src/devops_cli/roadmap/implement_step.py]
- Chosen: git show start:path. The step already has start. Git is the source of truth for the before state. The pattern matches _discarded_diff and _reset.
- Rejected: Read the file before the agent runs. The agent may change the file. The step's pattern is to compare against the start commit, not a pre-read snapshot.
- What to do when ast.parse raises on a file?: Skip the check for that file. A file that cannot be parsed has no test functions to compare, and the step must not crash. A syntax error is caught by ruff check or mypy. (best practice) [sources: src/devops_cli/roadmap/implement_step.py]
- Chosen: Skip the file. The body says a syntax error must not crash the check. A syntax error is caught by the static checks.
- Rejected: Fail the step. A syntax error is already caught by ruff check or mypy. Failing here adds no value and crashes the step.
- What is the failure message format?: Name the file path and the list of missing test function names. Follow the pattern of other failure messages in _exit_failure, using a MESSAGES entry. (best practice) [sources: src/devops_cli/roadmap/implement_step.py]
- Chosen: Name file and functions. The body says the step stops and names the file and the functions. This matches the pattern of _link_failure and _format_failure.
- Rejected: Name only the file. The body requires naming the functions. Naming only the file does not meet the requirement.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Oct 30, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(roadmap)scope of the title gives the scope.The immediate damage is handled by #2803, but the guard prevents recurring silent test loss.Silent deletion of tests undermines the entire verification pipeline and hides regressions.Requires ast-based before/after comparison of test function names and integration into the existing _exit_failure checks.Both address the same incident (PR #2801 deleting tests), but #2803 restores the deleted tests while the candidate adds a guard to prevent future deletions.devops-cli-service commentedon Oct 30, 2026
Status set to Ready at 6c50285 (see proposed design in issue body).
chore(main): release 0.23.0 (#2802)