Repository navigation
fix(openspec): openspec regenerate reads no openspec version #5375
Description
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
- Put an
openspecbinary that is older than the tools lock pin first on PATH. - Run
uv run devops openspec regenerate. It exits 0. - 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. - 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_openspecandregenerateboth call. On a finding,regenerateraises a domain error (exit 1) beforeopenspec update --force. - Add a spec scenario and a test: an older binary on PATH makes
regenerateexit 1, and it runs noopenspec update --force. - Use the opt-out environment and the timeout of
OpenSpecTool.runfor 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
- DevOps CLI Version: head of fix: install-tools --check passes an older openspec binary #5355 (
59486f86b), on 0.126.x - Python Version: 3.14.10
- OS & Architecture: Linux x86_64
- Execution Environment: DevContainer, or a native workstation with an older
openspecfirst on PATH
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_fakefixture stands for a binary that prints1.14.3, the tools lock pins another version, anddevops openspec regenerateruns in the fake's tree - THEN the command exits 1 and the fake records no
openspec update --forcecall
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
--versionrun with exit 1 and no output, anddevops openspec regenerateruns - THEN the command exits 1 and the fake records no
openspec update --forcecall
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, anddevops openspec regenerateruns - THEN the command's error text holds the fake binary path,
1.14.3, the locked version and the text ofMESSAGES.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.3andcheck_openspecanddevops openspec regenerateboth run - THEN both report the same
GateCheck.VERSIONdetail, and the regenerate run records noopenspec update --forcecall
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
--versionrun ofdevops openspec regenerate - THEN the recorded call holds
DO_NOT_TRACK,OPENSPEC_TELEMETRY,OPENSPEC_NO_UPDATE_CHECKandOPEN_SPEC_INTERACTIVE, and the isolatedXDG_CONFIG_HOMEandHOMEthatOpenSpecTool.runsets
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 regenerateruns - THEN the command exits 0 and the fake records the
openspec update --forcecall
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.3anddevops --dry-run openspec regenerateruns - THEN the command exits 0, the fake records no
--versioncall and noopenspec update --forcecall, 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 openspecruns - THEN the
openspecrow 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
regeneratecall it?: The guard stays insrc/devops_cli/openspec/gate.pyasversion_finding, the current_version_findingwith no leading underscore.check_openspecandregenerateboth call it;regeneratecalls it with the isolated tool and the worktree root, beforeregenerate_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.pywrites the skills and holds no gate finding, andcheck_openspecdoes not import it.
- Chosen: Share the gate's guard as
- How does
regeneratestop and report the finding?: It raisesToolExecutionError(version_problem.detail, tool_name=BIN_OPENSPEC)beforeregenerate_skillsruns.ToolExecutionErroris aDevOpsCLIErrorwhose default exit code is 1 (src/devops_cli/exceptions/base.py:19), andOTelTyper.commandreports everyDevOpsCLIErrorat 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'sdetail, 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
ToolExecutionErrorwith 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;
ToolExecutionErroralready names an external tool and exits 1. - Rejected: Return the finding to the caller.
regeneratereturnsNone; a returned finding would not stop the run beforeregenerate_skills.
- Chosen: Raise
- Which environment and timeout does the version run of
regenerateuse?: The version run goes throughOpenSpecTool.runwithVERSION_ARGS, as the gate does, so the telemetry opt-out environment (isolated_environment) andDEFAULT_OPENSPEC_COMMAND_TIMEOUT_SECONDSapply 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.
- Chosen: Run the version through
- Does the change alter the version behavior of
devops openspec check?: No.check_openspeckeeps 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, besidetest_regenerate_writes_the_skills_under_the_isolated_profile_and_never_a_bare_update, with theopenspec_fakefixture. That module tests the command's wiring, output and exit code;tests/openspec/test_openspec_gate.pytests 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 theregeneratecommand 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 theregeneratecommand's test.
- Chosen:
- Does the version guard run in a dry run of
devops openspec regenerate?: The guard runs only on a real run.regeneratereadsis_dry_run()before it calls the guard, ascheckdoes atsrc/devops_cli/commands/openspec.py:32; in a dry runrun_subprocessreturns aPlannedProcessResultwith 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
dan-petty commentedon Nov 13, 2026
Both deal with an older openspec binary on PATH causing wrong skill text, but #5107 fixes install-tools --check reporting while this item adds a version guard to regenerate itself.devops-cli-service commentedon Nov 17, 2026
Alternatives check: none
Reason: The searches returned no open tool or library that guards a project's own
regenerate/updatecommand 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_versionplus the gate's version finding) insideregenerate, so no external alternative exists and the item builds no new check.Tool: none found
Lacks:
openspec update --forceand stops the run when the binary on PATH prints another version than the lock's, or prints no versionOpenSpecTool.run's opt-out environment and timeout, so check and regenerate share one functionregenerateexit 1 and run noopenspec update --forceSearches run:
Sources:
Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 17, 2026
Status set to Ready at 2620fae (see proposed design in issue body).
devops-cli-service commentedon Nov 18, 2026
Released in v0.177.1: https://github.com/dan-petty/devops-cli/releases/tag/v0.177.1
devops-cli-service commentedon Nov 18, 2026
Live since 2026-11-18 17:16 UTC