Skip to content

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

Done

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-26: not-applicable.
Class: test, no model call.
Tool: none found.

Proposed design

Problem statement

The OpenSpec gate tests do not prove the unreadable-version branch or the nonzero-exit rule. A mutant that deletes one branch passes all targeted tests. The regenerate assertion in the gate test proves nothing because the test edits no skill. The gate also reads a version from a run that exits nonzero.

Acceptance criteria

Requirement: Gate unreadable version detail

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

Scenario: Nonzero version exit in the gate

  • WHEN a gate test runs check_openspec and the fake openspec --version exits 1.
  • THEN the GateCheck.VERSION finding detail equals the formatted MESSAGES.openspec.version_unreadable text.

Requirement: Gate reads nonzero exit as no version

version_finding MUST read a nonzero exit of openspec --version as no version.

Scenario: Gate nonzero exit with version output

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

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: Mutation of guarded branches

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

Scenario: Deleted guarded branch

  • WHEN the unreadable-version branch or the nonzero-exit rule in src/devops_cli/openspec/gate.py is deleted and the targeted pytest command runs.
  • THEN uv run pytest tests/openspec/test_openspec_gate.py 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 OpenSpecFake. It builds no new tool.

Key questions

  • Which function reads the openspec version in the current tree?: version_finding in src/devops_cli/openspec/gate.py reads the version. The infra move deleted tools_lock and its path_version reader. [sources: src/devops_cli/openspec/gate.py]
  • Should version_finding read a nonzero exit of openspec --version as no version?: Yes. A nonzero exit gives no trustworthy version, so the gate reports the unreadable finding. Put the rule in the one version guard that serves check and regenerate. (best practice) [sources: src/devops_cli/openspec/gate.py]
    • Chosen: Treat a nonzero exit as no version. A failed run gives no trustworthy version, and its stdout may hold a stale or partial version.
    • Rejected: Read stdout only. This is the defect C3 reports: the gate reads a version from a run that exits nonzero.
  • Should the gate test hand-edit a committed SKILL.md?: Yes. 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. (best practice) [sources: tests/openspec/test_openspec_gate.py:159]
    • 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.

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).

  7. devops-cli-service commented on Nov 27, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  8. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 29, 2026
  9. removed
    status/in-review
    on Nov 29, 2026
  10. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 16:17 UTC

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/agenttype/testvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions