Skip to content

fix(openspec): openspec regenerate reads no openspec version #5375

Closed

Description

@dan-petty

Problem Description

Depends on #5355.

#5355 makes devops openspec check read the version that the openspec command on PATH prints, before its other checks (_version_finding, src/devops_cli/openspec/gate.py:111-131). When that version is not the lock's version, the gate stops and gives no advice to regenerate, because a binary other than the lock's writes other skill text.

devops openspec regenerate (src/devops_cli/commands/openspec.py:48-55) reads no version. It runs openspec update --force through regenerate_skills (src/devops_cli/openspec/skills.py:35-39) with the binary that PATH finds. Thus an older binary writes its skill text into the working tree. The openspec-gate pre-commit hook (.pre-commit-config.yaml:87-92) now stops a commit of that text. But the tree is already changed, and the user must restore the skill files from git.

The risk increases with #5078, which moves the pin to OpenSpec 2.0.0 and a new skill layout. A 1.x binary that stays first on PATH then writes the old layout.

Reproduction Steps

  1. Put an openspec binary that is older than the tools lock pin first on PATH.
  2. Run uv run devops openspec regenerate. It exits 0.
  3. Run git status --short .claude/skills .agents/skills .kilocode/skills. The skill files hold the text of the older release, if that release writes other text.
  4. Run uv run devops openspec check. It reports the version finding.

Expected vs Actual Behavior

Expected: regenerate reads the version first, with the same guard as the gate. When the binary prints another version than the lock's, or prints no version, regenerate writes nothing and exits 1. The message names the path, the printed version, the locked version and the install hint.

Actual: regenerate writes the skill text of the binary that PATH finds, whatever its version.

Proposed Fix

  • Move the version guard of the gate to one function that check_openspec and regenerate both call. On a finding, regenerate raises a domain error (exit 1) before openspec update --force.
  • Add a spec scenario and a test: an older binary on PATH makes regenerate exit 1, and it runs no openspec update --force.
  • Use the opt-out environment and the timeout of OpenSpecTool.run for the version run, as the gate does.

Existing tool: the guard of the gate in #5355 covers the need. This item reuses it and builds no new check.

Environment Diagnostics

Logs, Traces, or Terminal Output

# From the vetting verdict of #5355 (C2 / F6):
# src/devops_cli/commands/openspec.py:51 regenerate reads no version, so an older binary still
# writes the older skill text into the working tree. The openspec-gate pre-commit hook now stops
# a commit of that text.

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: none.
Tool: none found.

Proposed design

Problem statement

devops openspec regenerate runs openspec update --force with the binary that PATH finds, and it reads no version. A binary older than the tools lock pin then writes its own skill text into the working tree. The openspec-gate pre-commit hook refuses the commit of that text, but the tree is already changed, so the user must restore the skill files from git. The version guard that #5355 added is present at the refined commit (_version_finding, src/devops_cli/openspec/gate.py:111), and regenerate does not call it. The fix makes check_openspec and regenerate call one public guard, and makes regenerate raise a domain error before it writes.

Acceptance criteria

Requirement: Regenerate reads the version before it writes

devops openspec regenerate SHALL read the version of the openspec binary on PATH and SHALL stop with exit 1 before it writes any skill, when the printed version is not the version of the tools lock.

Scenario: An older binary on PATH

  • WHEN the openspec_fake fixture stands for a binary that prints 1.14.3, the tools lock pins another version, and devops openspec regenerate runs in the fake's tree
  • THEN the command exits 1 and the fake records no openspec update --force call

Requirement: Regenerate stops on a binary that prints no version

devops openspec regenerate SHALL stop with exit 1 and write no skill when the openspec binary on PATH prints no version line.

Scenario: A binary that prints no version

  • WHEN the fake answers the --version run with exit 1 and no output, and devops openspec regenerate runs
  • THEN the command exits 1 and the fake records no openspec update --force call

Requirement: The finding names the path, the versions and the hint

The error of the version finding SHALL name the binary path, the printed version, the locked version and the install hint.

Scenario: The message of the version finding

  • WHEN the fake binary prints 1.14.3, the tools lock pins another version, and devops openspec regenerate runs
  • THEN the command's error text holds the fake binary path, 1.14.3, the locked version and the text of MESSAGES.openspec.missing_hint

Requirement: One version guard serves check and regenerate

The version guard SHALL be one function of src/devops_cli/openspec/gate.py that check_openspec and regenerate both call.

Scenario: Check and regenerate share the finding

  • WHEN the fake binary prints 1.14.3 and check_openspec and devops openspec regenerate both run
  • THEN both report the same GateCheck.VERSION detail, and the regenerate run records no openspec update --force call

Requirement: The version run uses the tool's environment and timeout

The version run of regenerate SHALL go through OpenSpecTool.run, so it uses the same opt-out environment and timeout as the version run of the gate.

Scenario: The environment of the version run

  • WHEN the fake records the environment of the --version run of devops openspec regenerate
  • THEN the recorded call holds DO_NOT_TRACK, OPENSPEC_TELEMETRY, OPENSPEC_NO_UPDATE_CHECK and OPEN_SPEC_INTERACTIVE, and the isolated XDG_CONFIG_HOME and HOME that OpenSpecTool.run sets

Requirement: A matching binary still regenerates

devops openspec regenerate SHALL run openspec update --force and exit 0 when the binary on PATH prints the tools lock's version.

Scenario: The locked binary on PATH

  • WHEN the fake binary prints the tools lock's version and devops openspec regenerate runs
  • THEN the command exits 0 and the fake records the openspec update --force call

Requirement: A dry run changes nothing

devops --dry-run openspec regenerate SHALL write no skill file and SHALL exit 0, whatever version the openspec binary on PATH prints.

Scenario: A dry run with an older binary

  • WHEN the fake binary prints 1.14.3 and devops --dry-run openspec regenerate runs
  • THEN the command exits 0, the fake records no --version call and no openspec update --force call, and the skill files of the tree are unchanged

Requirement: The change holds the spec scenario

The change SHALL hold a spec delta scenario that states the version guard of devops openspec regenerate.

Scenario: The openspec row validates the change

  • WHEN the change folder of the item is in the worktree and uv run devops ci --check --only openspec runs
  • THEN the openspec row exits 0

Existing Tool Considered

None. The alternatives check of 2026-11-17 in the issue body records the verdict none and names no open, maintained tool or library that guards a project's own regenerate command against a binary on PATH whose version differs from the lock pin. The change reuses the guard that the gate already holds, version_finding (src/devops_cli/openspec/gate.py:111), so it builds no new check. The code it adds is one call site in src/devops_cli/commands/openspec.py and one test in tests/core/test_openspec_command.py: about 20 lines, about 20 minutes of work and under 30k tokens to build and keep.

Key questions

  • Where does the shared version guard live, and how does regenerate call it?: The guard stays in src/devops_cli/openspec/gate.py as version_finding, the current _version_finding with no leading underscore. check_openspec and regenerate both call it; regenerate calls it with the isolated tool and the worktree root, before regenerate_skills. (best practice) [sources: src/devops_cli/openspec/gate.py:111, src/devops_cli/openspec/gate.py:219, src/devops_cli/commands/openspec.py:51, src/devops_cli/openspec/skills.py:35]
    • Chosen: Share the gate's guard as version_finding. The gate owns the finding, its message and the lock read, and the issue asks for one function that both commands call.
    • Rejected: Copy the guard into src/devops_cli/commands/openspec.py. Two copies of the version rule drift apart, and the issue asks for one function.
    • Rejected: Put the guard in src/devops_cli/openspec/skills.py. skills.py writes the skills and holds no gate finding, and check_openspec does not import it.
  • How does regenerate stop and report the finding?: It raises ToolExecutionError(version_problem.detail, tool_name=BIN_OPENSPEC) before regenerate_skills runs. ToolExecutionError is a DevOpsCLIError whose default exit code is 1 (src/devops_cli/exceptions/base.py:19), and OTelTyper.command reports every DevOpsCLIError at the CLI's one exit seam with its message and exit code (src/devops_cli/core/cli.py:291, src/devops_cli/core/cli.py:359). The message is the finding's detail, so it names the path, the printed version, the locked version and the install hint. (best practice) [sources: src/devops_cli/core/cli.py:291, src/devops_cli/core/cli.py:359, src/devops_cli/exceptions/base.py:19, src/devops_cli/exceptions/tools.py:10, src/devops_cli/openspec/gate.py:111, src/devops_cli/lang/en/messages.py:530]
    • Chosen: Raise ToolExecutionError with the finding's detail. It is the project's error for an external tool problem, carries the tool name, and the command wrapper reports it at the one exit seam with exit code 1.
    • Rejected: Print the finding and raise typer.Exit(1). It duplicates the check command's print loop and bypasses the one exit seam that reports a domain error.
    • Rejected: Raise a new OpenSpec version error. It adds a class for one call site; ToolExecutionError already names an external tool and exits 1.
    • Rejected: Return the finding to the caller. regenerate returns None; a returned finding would not stop the run before regenerate_skills.
  • Which environment and timeout does the version run of regenerate use?: The version run goes through OpenSpecTool.run with VERSION_ARGS, as the gate does, so the telemetry opt-out environment (isolated_environment) and DEFAULT_OPENSPEC_COMMAND_TIMEOUT_SECONDS apply to it. (best practice) [sources: src/devops_cli/openspec/gate.py:114, src/devops_cli/openspec/tool.py:39, src/devops_cli/openspec/tool.py:73]
    • Chosen: Run the version through OpenSpecTool.run. The guard of the gate already runs the version through the tool, and the issue asks for the same environment and timeout.
    • Rejected: Run the binary with subprocess.run. It drops the opt-out environment and the timeout, and it adds a second code path for the same read.
  • Does the change alter the version behavior of devops openspec check?: No. check_openspec keeps its version finding, its message and its place before the other checks. Only the name and the visibility of the guard change, and the gate tests keep passing. (best practice) [sources: src/devops_cli/openspec/gate.py:229, tests/openspec/test_openspec_gate.py:179]
    • Chosen: Keep the check as it is and share the function. The issue moves the guard, not the check, so the behavior and the tests of the check stay.
    • Rejected: Change the message of the check too. The issue states no change to the message of the check.
  • Where does the new test live?: The test goes into tests/core/test_openspec_command.py, beside test_regenerate_writes_the_skills_under_the_isolated_profile_and_never_a_bare_update, with the openspec_fake fixture. That module tests the command's wiring, output and exit code; tests/openspec/test_openspec_gate.py tests the gate function and holds no regenerate test. (best practice) [sources: tests/core/test_openspec_command.py:1, tests/core/test_openspec_command.py:68, tests/openspec/test_openspec_gate.py:179]
    • Chosen: tests/core/test_openspec_command.py. That file already tests the regenerate command and its exit code, so the new command test stays with it.
    • Rejected: tests/openspec/test_openspec_gate.py. It holds the gate function's tests, not the regenerate command's test.
  • Does the version guard run in a dry run of devops openspec regenerate?: The guard runs only on a real run. regenerate reads is_dry_run() before it calls the guard, as check does at src/devops_cli/commands/openspec.py:32; in a dry run run_subprocess returns a PlannedProcessResult with no output (src/devops_cli/core/process.py:879), so a guard there would report a false unreadable version. The dry run keeps its current behavior: it changes nothing and exits 0. (best practice) [sources: src/devops_cli/commands/openspec.py:32, src/devops_cli/commands/openspec.py:51, src/devops_cli/core/process.py:879]
    • Chosen: Skip the guard in a dry run. A dry run writes nothing, so a version finding there would stop a preview and break the dry-run test.
    • Rejected: Run the guard in both modes. The dry-run process runner returns a planned result with no output, so the version read would return no version and raise a false finding.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/openspec
    status/new
    value/medium
    effort/low
    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: none

    Reason: The searches returned no open tool or library that guards a project's own regenerate/update command against a binary on PATH whose version differs from a lock pin. The need is a code change in this repository: reuse the version guard that #5355 adds to the gate (path_version plus the gate's version finding) inside regenerate, so no external alternative exists and the item builds no new check.

    Tool: none found

    Lacks:

    • A guard that runs before openspec update --force and stops the run when the binary on PATH prints another version than the lock's, or prints no version
    • A domain error (exit 1) that names the binary path, the printed version, the locked version and the install hint, before any skill text is written
    • Reuse of the gate's version finding with OpenSpecTool.run's opt-out environment and timeout, so check and regenerate share one function
    • A spec scenario and a test that an older binary on PATH makes regenerate exit 1 and run no openspec update --force

    Searches run:

    • openspec CLI verify version before update skills, results: 5
    • enforce pinned tool version on PATH before running command version manager, results: 5
    • OpenSpec spec-driven development CLI github Fission-AI, results: 5
    • mise asdf pin tool version and run command fails if wrong version on PATH, results: 5
    • npm package check installed binary version matches lockfile before running, results: 5
    • "openspec" npm package CLI update skills command, results: 5
    • version guard pre-commit hook tool version mismatch install hint, results: 5
    • OpenSpec AI coding agents spec changes tool, results: 5
    • asdf version manager .tool-versions shim wrong version, results: 5
    • mise-en-place dev tool version manager pin per project github, results: 5

    Sources:

    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. added
    status/in-review
    and removed
    status/ready
    on Nov 18, 2026
  8. removed
    status/in-review
    on Nov 18, 2026
  9. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor
  10. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-18 17:16 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/lowpriority/p2-mediumscope/openspecsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions