Skip to content

test(openspec): version-check tests do not prove the unreadable branches #5373

Open

Description

@dan-petty

Update 2026-11-26 (infra move): devops install-tools and tools_lock are deleted (#6555), so the CLI test, TQ2, S1, S3 and S4 no longer apply. The version read is version_finding in openspec/gate.py. Left: assert the full unreadable detail in the gate test, treat a nonzero exit as no version (C3), and check TQ3.


Problem Description

Depends on #5355.

The vetting of #5355 found that the new tests do not prove some branches of the version read. A mutant that deletes such a branch passes the tests. The items below come from the verdict (TQ1, TQ2, TQ3, C3, S1, S3, S4). The line numbers are at the head of #5355 (59486f86b).

Test gaps:

  • TQ1. No CLI test and no gate test asserts the text that says the version cannot be read. A mutant that deletes the unreadable branch in src/devops_cli/commands/install_tools.py:410-411 or in src/devops_cli/openspec/gate.py:117-123 passes all 76 targeted tests. Without the branch, the check prints the "differs" line with None as the version. That line also names the path, and the check also exits 1, so the tests see no change. Also, the fake _record_npm (tests/commands/test_install_tools.py:412-461) always answers --version with exit 0 (line 431). Thus no CLI test proves the merged scenario "A command that prints no version fails the check", whose WHEN is "the openspec command on PATH exits 1".
  • TQ2. tests/tools_lock/test_versions.py:57-67 gives the failing answer an empty stdout. Thus the rule if result.returncode != 0: return (path, None) (src/devops_cli/tools_lock/versions.py:36-37) is not proven. A mutant that deletes the rule passes, because an empty stdout also gives no version line.
  • TQ3. tests/openspec/test_openspec_gate.py:159-175 asserts that the finding detail does not hold regenerate. This assertion proves nothing: missing_hint never holds regenerate, and the test edits no skill. Only the assertion on update --force proves the early return.

Code nits in the same files:

  • C3. _version_finding (src/devops_cli/openspec/gate.py:114) reads only stdout and ignores the exit code of openspec --version. path_version reads a nonzero exit as no version. The two readers must apply the same rule.
  • S1. path_version (src/devops_cli/tools_lock/versions.py:35) runs --version with the default subprocess timeout of 1800 s and does not change subprocess.TimeoutExpired into a domain error. OpenSpecTool.run (src/devops_cli/openspec/tool.py:66-84) uses DEFAULT_OPENSPEC_COMMAND_TIMEOUT_SECONDS (120 s) and raises ToolExecutionError.
  • S3. path_version passes no CONST_OPENSPEC_OPT_OUT_ENV, and the isolated child environment drops DO_NOT_TRACK, OPENSPEC_TELEMETRY and OPENSPEC_NO_UPDATE_CHECK. ADR 0010 sets the opt-outs on every run of the tool. Now no request goes out, because openspec --version exits before the telemetry hook of the tool. A later release of the tool can change this.
  • S4. The help text of --only-missing (src/devops_cli/lang/en/help.py:2333-2336, and the generated docs/commands/install-tools.md:15) says that the option installs each tool "whose command on PATH prints another version". The code reads the version of openspec only (_version_state, src/devops_cli/commands/install_tools.py:392-400).

Reproduction Steps

  1. Check out the head of fix: install-tools --check passes an older openspec binary #5355, or main after the merge.
  2. Delete the if version is None branch at src/devops_cli/commands/install_tools.py:410-411.
  3. Run uv run pytest tests/commands/test_install_tools.py tests/openspec/test_openspec_gate.py tests/tools_lock/test_versions.py.
  4. All tests pass.
  5. Do steps 2 to 4 again for src/devops_cli/openspec/gate.py:117-123 and for src/devops_cli/tools_lock/versions.py:36-37. All tests pass again.

Expected vs Actual Behavior

Expected: each branch of the version read has a test that fails when the branch is deleted. Both readers read a nonzero exit as no version. The version run has the timeout, the error type and the opt-outs of every other openspec run. The help text says that only the openspec version is read.

Actual: the mutants pass. The gate reads a version from a run that exits nonzero. The version run of path_version has a 1800 s timeout and no opt-outs. The help text says that the option reads the version of each tool.

Proposed Fix

  • TQ1: Let _record_npm answer --version with an exit code that the test sets. Add a CLI test in which openspec --version exits 1. Assert exit 1 and the full MESSAGES.install.check_version_unreadable line. In the gate test, assert the full MESSAGES.openspec.version_unreadable detail.
  • TQ2: In tests/tools_lock/test_versions.py:57-67, answer with ProcessAnswer(returncode=1, stdout="1.17.0\n", stderr="boom\n").
  • TQ3: Add a hand edit of a committed SKILL.md to the test at tests/openspec/test_openspec_gate.py:159. Then the regenerate assertion proves the early return.
  • C3: In _version_finding, read a nonzero exit as no version, as path_version does. One shared function in src/devops_cli/tools_lock/versions.py can hold the rule for both readers.
  • S1: Give the run in path_version the timeout DEFAULT_OPENSPEC_COMMAND_TIMEOUT_SECONDS. Change subprocess.TimeoutExpired into ToolExecutionError, as OpenSpecTool.run does.
  • S3: Pass CONST_OPENSPEC_OPT_OUT_ENV in the env argument of the version run.
  • S4: Change the help text to say that the option reads the version of the openspec command on PATH only. Then run uv run devops docs generate.

Existing tool: pytest and the process_fake fixture cover the tests. No new tool is necessary.

Acceptance

  • Each new test that proves a branch fails on the code before the fix. For a guard that exists already (the unreadable branches and the nonzero-exit rule), mutation evidence is sufficient: the test fails when the branch is deleted.
  • check_openspec gives the full MESSAGES.openspec.version_unreadable detail when openspec --version exits 1, and a gate test proves it.
  • uv run devops docs check passes.

Environment Diagnostics

Logs, Traces, or Terminal Output

# From the vetting verdict of #5355:
# A mutant that deletes the unreadable branches (install_tools.py:410-411, gate.py:117-123) passes all 76 tests.
# A mutant that deletes versions.py:36 passes, because the failing answer has an empty stdout.

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal keys are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Source: #5355

Alternatives check of 2026-11-17: not-applicable.
Class: test, no search.
Tool: none found.

Proposed design

Problem statement

The tests added in #5355 do not prove the unreadable-version branches. A mutant that deletes one branch passes. The gate and path_version apply different rules to a nonzero exit. The path_version run lacks the OpenSpec timeout, error type and opt-outs. The help text says that --only-missing reads every tool version, but the code reads only openspec.

Acceptance criteria

Requirement: CLI unreadable version branch

The CLI check MUST print the unreadable version line when openspec --version exits nonzero.

Scenario: Nonzero version exit in install-tools

  • WHEN a CLI test runs devops install-tools --check --tool openspec and the fake openspec --version exits 1.
  • THEN the command exits 1 and its output holds the full MESSAGES.install.check_version_unreadable line.

Requirement: Gate unreadable version detail

The OpenSpec gate MUST report the full unreadable version detail when openspec --version exits nonzero.

Scenario: Nonzero version exit in the gate

  • WHEN a gate test runs with an openspec --version answer that exits 1.
  • THEN the GateCheck.VERSION finding detail equals the formatted MESSAGES.openspec.version_unreadable text.

Requirement: Failing version command returns no version

path_version MUST return no version when the version command exits nonzero, even if stdout holds a version.

Scenario: Failing command with version output

  • WHEN the process fake answers openspec --version with return code 1, stdout 1.17.0\n and stderr boom\n.
  • THEN path_version("openspec") returns the PATH with None as the version.

Requirement: Hand-edited skill proves early return

The gate test MUST hand-edit a committed SKILL.md so the regenerate assertion proves the early return.

Scenario: Hand-edited committed skill

  • WHEN a gate test hand-edits a committed SKILL.md and runs the gate.
  • THEN the finding detail holds the pinned openspec update --force hint and does not hold regenerate.

Requirement: Gate reads nonzero exit as no version

_version_finding MUST read a nonzero exit of openspec --version as no version, as path_version does.

Scenario: Gate nonzero exit with version output

  • WHEN the openspec --version run exits 1 and prints a version.
  • THEN the gate reports the unreadable version finding, not the version-differs finding.

Requirement: Version run timeout

path_version MUST run the version command with DEFAULT_OPENSPEC_COMMAND_TIMEOUT_SECONDS and raise ToolExecutionError on a timeout.

Scenario: Version command timeout

  • WHEN the process fake makes openspec --version time out.
  • THEN path_version raises ToolExecutionError with the 120 s timeout in its message.

Requirement: Version run opt-outs

path_version MUST pass CONST_OPENSPEC_OPT_OUT_ENV in the environment of the version run.

Scenario: Version run opt-out environment

  • WHEN a test records the environment of the openspec --version run.
  • THEN the environment holds DO_NOT_TRACK, OPENSPEC_TELEMETRY and OPENSPEC_NO_UPDATE_CHECK.

Requirement: Help text names openspec only

The help text of --only-missing MUST say that the option reads only the openspec version from PATH.

Scenario: Generated install-tools help

  • WHEN uv run devops docs generate runs and then uv run devops docs check runs.
  • THEN the check exits 0 and docs/commands/install-tools.md says that the option reads the openspec version only.

Requirement: Mutation of guarded branches

Each new branch test MUST fail when its guarded branch is deleted.

Scenario: Deleted guarded branch

  • WHEN a mutant deletes one guarded branch in install_tools.py, gate.py or versions.py.
  • THEN the targeted pytest run fails.

Existing Tool Considered

The alternatives check in the issue body gives not-applicable and names no tool. The change extends the existing pytest tests and the process_fake fixture. It builds no new tool.

Key questions

  • Should one shared function hold the nonzero-exit rule for both version readers?: Yes. Put the rule in one helper in src/devops_cli/tools_lock/versions.py and call it from path_version and _version_finding. (best practice) [sources: src/devops_cli/tools_lock/versions.py:35-37, src/devops_cli/openspec/gate.py:114]
    • Chosen: Shared helper in versions.py. It keeps the two readers aligned and avoids a second copy of the rule.
    • Rejected: Duplicate the rule in gate.py. The two copies can drift, which is the defect C3 reports.
  • Should path_version use the OpenSpec timeout and error type?: Yes. Use DEFAULT_OPENSPEC_COMMAND_TIMEOUT_SECONDS and raise ToolExecutionError on subprocess.TimeoutExpired, as OpenSpecTool.run does. (best practice) [sources: src/devops_cli/openspec/tool.py:66-84, src/devops_cli/config/defaults.py:545]
    • Chosen: Use the OpenSpec timeout and error type. It bounds the wait to 120 s and gives callers one domain error.
    • Rejected: Keep the default 1800 s subprocess timeout. It can block the check for 30 minutes and leaks subprocess.TimeoutExpired.
  • Should the path_version run receive the OpenSpec opt-out environment?: Yes. Pass CONST_OPENSPEC_OPT_OUT_ENV in the env argument of the version run. (best practice) [sources: src/devops_cli/openspec/tool.py:43, src/devops_cli/config/constants.py:5605]
    • Chosen: Pass the opt-out environment. Every other openspec run sets these opt-outs, and a later release can send telemetry before the version exits.
    • Rejected: Leave the isolated environment unchanged. It drops DO_NOT_TRACK, OPENSPEC_TELEMETRY and OPENSPEC_NO_UPDATE_CHECK.
  • Should the help text say that --only-missing reads only the openspec version?: Yes. Change the help text to say that the option reads the openspec command version on PATH only. (best practice) [sources: src/devops_cli/commands/install_tools.py:392-400, src/devops_cli/lang/en/help.py:2333-2336]
    • Chosen: Say the openspec version only. _version_state reads only openspec, so the current text promises more than the code does.
    • Rejected: Read every tool version. That is a larger change, and no code does it.
  • Should the gate test hand-edit a committed SKILL.md?: Yes. Add a hand edit of a committed SKILL.md to the test so the regenerate assertion proves the early return. (best practice) [sources: tests/openspec/test_openspec_gate.py:159-175]
    • Chosen: Hand-edit a committed SKILL.md. The current regenerate assertion passes with no edit and proves nothing.
    • Rejected: Keep the current assertion. missing_hint never holds regenerate, so the assertion cannot prove the early return.
  • How should the CLI test make openspec --version exit nonzero?: Add a version_returncode parameter to _record_npm and return that code from its --version branch. (best practice) [sources: tests/commands/test_install_tools.py:412-461]
    • Chosen: Add version_returncode to _record_npm. The helper already stands in for npm, and one parameter keeps the fake in one place.
    • Rejected: Patch subprocess.run again in the test. It duplicates the fake and can hide the npm recording behavior.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/test
    scope/openspec
    status/new
    value/medium
    effort/medium
    on Nov 13, 2026
  2. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 13, 2026
  4. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Class: test. The check makes no search and no model call for an item of this class.

    Tool: none found

    Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.

  5. added
    status/ready
    and removed
    status/new
    on Nov 17, 2026
  6. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 2620fae (see proposed design in issue body).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/openspecsource/agentstatus/readytype/testvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions