Skip to content

feat(openspec): scaffold OpenSpec and gate its change folders in devops ci #1844

Closed

Description

@dan-petty

Status

This item is step 2 of 8 of the OpenSpec adoption. Issue #1753 and docs/adr/0010-openspec-is-the-spec-and-change-proposal-layer.md decided that adoption.

Pull request #1868 (c63daf9f, Part of #1844) delivered the first part on 2026-10-22. It added the scaffold, the gate and the openspec row of devops ci. The gate passes on the tree at the tip.

ADR 0012 (docs/adr/0012-releases-are-derived-by-release-please-from-trunk-and-milestones-are-planning-buckets.md) moves the archive of a change into the pull request that closes it. So a release cut no longer archives. Two pieces of #1868 then have no purpose: the archive-ordering function and the rehearsal of the cut. Issue #1846 deletes them. The overlap check stays, because it reads no git history and archives nothing.

This issue stays open for the last part. The last part adds the wrapper devops openspec archive and its tests. The person set the permissions of .claude/settings.json on 2026-10-22: the allow list holds Bash(uv run devops *), Bash(openspec *) and Bash(tuicr *), and no deny list exists. So the last part adds no settings test and no settings change.

Friction

Before #1868, the repository had nowhere to plan into and nothing that kept a plan valid. The pinned tool also has defects that only a mechanical check holds back. Each defect was tried against OpenSpec 1.14.3 on 2026-10-22.

  • There was no openspec/ tree, no config.yaml with the planning conventions for every agent, and no committed skills. A cloud agent or a fresh clone reads the checkout and never runs an install. So the generated skills are committed.
  • The tool has no project-level profile pin. The wider global profile of a developer rewrote six of the eight skill files. It also added the archive and sync skills and a commands tree. Those skills write openspec/specs/, and only the pull request that closes a change may write it (ADR 0012).
  • config.yaml fails quietly. The tool exits 0 in each case below and prints a warning in some.
    • A plain scalar with a space and a hash is cut at the comment.
    • An unknown top-level key is ignored.
    • A plain scalar with a colon and a space becomes a mapping and drops the guidance.
    • A rule under an unknown artifact id is ignored.
    • A context over 50 KB is ignored.
  • A folder of only .openspec.yaml and a delta passes validate --strict and a readiness rule that reads paths only. So an empty plan would count as a plan.
  • AGENTS.md names task files until the switch (feat(sdlc): an OpenSpec change folder is the record of every item, and readiness checks its archive #1847). So a change folder planned before the switch is a second record, and review refuses it. The gate keeps such a folder valid and named <issue>-<slug>.
  • validate passes changes that fail when archived. A missing Purpose leaves a placeholder that validate then rejects. A MODIFIED of a spec that does not exist makes archive refuse. A duplicate ADDED with other text makes archive refuse. Two changes that MODIFY one requirement both archive, and the spec keeps one text.
  • ADR 0012 archives in the pull request that closes the change. There the author sees each refusal and fixes it. A git conflict shows two archives that clash. So the gate does not rehearse archive.

Evidence

  • ADR 0010 records the trial. The task file docs/agent/tasks/task-1844-openspec-scaffold-and-gate.md records the check of 2026-10-22 against OpenSpec 1.14.3.
  • openspec init --tools claude,agents under the custom profile writes 12 files (127 KB). They are two trees of four byte-identical SKILL.md, .agents/skills/.openspec-target, openspec/config.yaml and two .gitkeep. A second run of openspec update --force under the isolated configuration changed no file on a second machine.
  • ADR 0010 records three runs on 16 cores. validate --all --strict took 0.4 to 1.5 s with 40 to 50 changes. It took 1.7 to 5.5 s with 600 changes. The whole gate took 4.0 to 4.5 s on this repository (task file). At the tip, uv run devops openspec check passed in 7.4 s.
  • The gate runs in the static job, whose check name is Static Analysis. ADR 0012 makes that check required for every pull request into main. After that setting, the gate binds every pull request.
  • ADR 0012 tried the archive in each pull request. Two modifications of one requirement conflict. Two additions to one capability conflict. A modification and an addition are clean in both orders. A second archive after a rebase gave a result byte-identical to a serial archive.
  • openspec validate --all --strict covers the specs on the tree. A scratch spec with a placeholder Purpose failed in the same way under --all --strict and under --specs --strict (OpenSpec 1.14.3, 2026-10-22). So the gate needs no separate --specs run.

Existing tool considered

OpenSpec is the open tool. The item uses validate, archive, instructions, update and the generated skills as shipped, with the default spec-driven schema. A fork of the schema copies 16 KB of upstream instructions and four templates that change weekly.

Two thin commands are internal: check and regenerate. No open tool pins the profile and the configuration of a project. check runs the pinned tool and reports each problem with the check that found it. regenerate runs openspec update --force under the isolated configuration.

Cost of the glue that stays, as the text of #1868 estimates it: about 60,000 tokens and half a day to write and test. The glue is the runner, the gate, the regeneration, the fake, the recorder and the record. Maintenance is one re-recording of the real tool at each bump of the pin. It takes about 50 seconds of tool time and no tokens beyond reading the diff. tests/test_openspec_contract.py bounds the fixing: it fails when the record is not of the locked version.

The task file estimates the cost of the code that ADR 0012 makes unneeded. The archive function took about 30,000 tokens to write and test and 15,000 more to fix. It took three hours. The total is about 45,000 tokens and three hours. #1846 deletes it. The cost of our own code is no reason to keep it.

The wrapper is the only new code. It is about 20 lines of command plus tests. The permission system of Claude Code is not used for archive: the settings allow the direct tool, so the wrapper is a convention that ADR 0012 requires for the isolated configuration.

The last part also builds the wrapper devops openspec archive of about 20 lines (ADR 0012, What Stays Custom). No open tool keeps the per-user configuration and the telemetry of OpenSpec out of an archive run. So the wrapper runs the pinned tool under the isolated configuration. The author of the last part states the tokens to implement, maintain and fix, and the elapsed time, in the pull request before work starts.

The change

Kept from #1868

  • The scaffold is the openspec init output under the isolated custom profile (propose, explore, apply and update; delivery skills; --tools claude,agents). It holds the eight SKILL.md files in .claude/skills/openspec-*/ and .agents/skills/openspec-*/, .agents/skills/.openspec-target, openspec/config.yaml and two .gitkeep files.
  • openspec/config.yaml is the file of ADR 0010 (Design: Agent files and openspec/config.yaml). Every rule is a folded scalar (- >-).
  • .gitignore re-includes only .claude/skills/openspec-*/. Other skills, settings.local.json and worktrees stay ignored.
  • devops openspec check and devops openspec regenerate live in src/devops_cli/commands/openspec.py (45 lines) and the package src/devops_cli/openspec/. Every pattern and key list is in src/devops_cli/config/constants.py or defaults.py.
  • The child environment sets DO_NOT_TRACK=1, OPENSPEC_TELEMETRY=0, OPENSPEC_NO_UPDATE_CHECK=1 and OPEN_SPEC_INTERACTIVE=0. It also sets XDG_CONFIG_HOME to a scratch directory that holds the isolated configuration. The values go through the env argument, because extra_allowed_env keeps only a variable that the parent process already has.
  • After feat(openspec): the pull request that closes a change archives it, and readiness checks the archived folder #1846, check runs five checks:
    1. openspec validate --all --strict. It fails an unknown key in .openspec.yaml. It also covers the specs on the tree.
    2. openspec validate --archived. It is a separate run, because --archived replaces --all. It fails an archived change with unticked tasks.
    3. A regeneration of the skills with openspec update --force under the isolated configuration, in a scratch copy. The gate compares the result with the tree.
    4. openspec instructions for the proposal, specs, design, tasks and apply operations of a probe change. Any output to standard error is a failure.
    5. The overlap check. It reads openspec show <change> --json --deltas-only for each active change. It fails when two active changes MODIFY, REMOVE or RENAME one requirement. It reads no git history.
  • check fails first, and names uv run devops install-tools --tool openspec --only-missing, when openspec is not on PATH. A tree with no change and no spec passes.
  • regenerate makes a scratch XDG_CONFIG_HOME. It sets telemetry.enabled false with the opt-out prefix, because the command sends an event otherwise. It sets delivery skills, profile custom and the four workflows. Then it runs openspec update --force in the tree. A bare openspec update is forbidden, because it takes the global profile of the user.
  • tests/test_change_folders.py holds every active folder under openspec/changes/ to these rules:
    • The name matches the closed grammar openspec/changes/(?P<issue>\d+)-[^/]+/.+.
    • proposal.md and tasks.md exist, and tasks.md holds at least one ## <n>. group with a task-list item.
    • proposal.md has the headings ## Feasibility and ## Existing Tool Considered, found with markdown-it.
    • No PR, Status, Milestone or Priority line exists.
  • tests/test_openspec_scaffold.py parses openspec/config.yaml with yaml.compose. It allows only the keys schema, context, rules and operations, and only folded or literal scalars as rule items. It also checks that metadata.generatedBy in all eight SKILL.md equals the pin in tools.lock, and that the two skill trees are identical.
  • The openspec row of devops ci (CheckSpec in src/devops_cli/commands/ci.py) runs uv run devops openspec check. It has no path filter and no exemption. The pre-commit hook openspec-gate runs uv run devops ci --only openspec on a commit that touches openspec/, .claude/skills/ or .agents/skills/.
  • The static job of .github/workflows/ci.yml runs actions/setup-node (v7.1.0, pinned by commit 949feb2413d6458794dcd2491c4babbbce0c15c1) with .node-version. Then it runs uv run devops install-tools --tool openspec --only-missing before the gate.
  • .github/workflows/copilot-setup-steps.yml is written by hand, with pinned actions, the pinned install and the opt-outs. openspec init --copilot-cloud is not used, because its workflow runs an unpinned actions/checkout@v4 and npm install -g @fission-ai/openspec. GitHub runs this file only from the default branch.
  • The documentation inventory (CONST_DOCS_INVENTORY) classes openspec/changes/**/*.md as record and openspec/specs/**/*.md as release artifact, so the inventory does not name-check the specs. The eight SKILL.md get a new class, tool-generated. Review routing gains openspec/** and the generated skill globs, and keeps the docs/agent/tasks/** entry until the switch.
  • The header of tools.lock gains the runbook steps that regenerate the skills and run the gate. devops docs generate --sync-readme covers the reference of the new commands.

Deleted by #1846

The last part

  • .claude/settings.json: no change in the last part. The person set the allow list and removed the deny list on 2026-10-22 (the pull request that carried the settings change also deleted tests/test_claude_code_settings.py).

  • Direct openspec archive is therefore not blocked. A closing pull request should still archive with the wrapper, as a convention.

  • ADR 0012 (What Stays Custom) requires the wrapper, because the configuration and the telemetry of the tool must stay isolated. The wrapper runs through the entry Bash(uv run devops *).

  • The wrapper devops openspec archive <name> lives in src/devops_cli/commands/openspec.py and the package src/devops_cli/openspec/. It runs openspec archive <name> --yes under the isolated configuration with the four opt-outs, and it passes no --skip-specs. It then runs openspec validate --all --strict. It exits 1 when either run fails. It has --dry-run, as regenerate has.

  • The apply guidance of openspec/config.yaml and each passage of ADR 0010 that tells an agent to run openspec archive directly name the wrapper instead.

  • No permission entries and no settings test are part of the last part.

  • While release/v0.2.39 exists, the last part targets it, says Closes #1844 and adds changelog.d/1844.md under ### Added. After the old pipeline ends, the last part targets main, says Closes #1844 and adds no fragment. The pull request title is then the changelog entry.

Planning record: this item is planned under the current rules, with the task file. It has no change folder, because AGENTS.md names task files until the switch (#1847).

What it deletes

The last part deletes one section of the task file. It deletes no code. #1846 deletes the cut-only code of the first part. At the tip, archive.py holds 151 lines and tests/test_openspec_archive.py 218 lines. _rehearsal_findings in gate.py holds 15 lines.

Tests

The test floor refuses every program but git, bwrap and a few kubectl forms. So no test starts openspec or npm.

  • OpenSpecFake (tests/support/fakes/openspec.py) replays the runs of the real tool, recorded over twelve scenarios in tests/fixtures/openspec_runs/recorded_runs.json. tests/test_openspec_contract.py fails when the record is not of the locked version or holds a run that the gate no longer starts.
  • tests/test_openspec_gate.py, tests/test_openspec_command.py and tests/test_openspec_tool.py assert the child environment: the four opt-outs and an isolated configuration directory. They also assert that regenerate never runs a bare update.
  • tests/test_change_folders.py and the configuration tests each have a failing fixture. tests/test_workflow_contracts.py covers the pinned setup-node and copilot-setup-steps.yml.
  • The real tool runs in the openspec row on every pull request. That run is the contract check against the pinned binary.
  • feat(openspec): the pull request that closes a change archives it, and readiness checks the archived folder #1846 removes the order tests, which use real git in tmp_path. It also removes the scenarios that only the rehearsal reads.
  • The last part adds no settings test.
  • The last part adds tests of the wrapper in tests/test_openspec_command.py. They use OpenSpecFake with recorded runs of archive that tests/support/openspec_recording.py makes. One test shows the order: archive, then validate --all --strict. Another shows that a failed archive skips validate and exits 1.

Order and dependencies

Acceptance criteria

Delivered by #1868. A test checks each one at the tip.

  • uv run devops ci runs an openspec row and passes on the repository tree. It fails with a clear message when openspec is missing. The message names uv run devops install-tools --tool openspec --only-missing.
  • uv run devops openspec regenerate leaves the tree unchanged under a wider global profile. check fails when a skill file was edited by hand or when the profile is wider.
  • check fails an unknown key in .openspec.yaml and an archived change with an unticked task.
  • tests/test_change_folders.py fails a folder that is not named <issue>-<slug>, a folder with no tasks.md group and a folder with a Status line. tests/test_openspec_scaffold.py fails a plain scalar rule and an unknown key in config.yaml.
  • The inventory classifies every new Markdown file, and devops docs check passes.
  • The pre-commit hook and the static job run the row, and copilot-setup-steps.yml exists. AGENTS.md stays within CONST_AGENTS_MD_MAX_CHARS (40,000 characters; 37,286 at the tip).
  • The record of the real tool equals the pin in tools.lock (tests/test_openspec_contract.py).

Open, for the last part:

  • The wrapper has tests in tests/test_openspec_command.py (see the section Tests).

  • uv run devops openspec archive <name> archives the change and then runs openspec validate --all --strict. It runs both under the isolated configuration, and it exits 1 when either run fails.

  • uv run devops ci passes with every row.

  • Pending a person: when .github/workflows/copilot-setup-steps.yml is on main, run the workflow once from the Actions tab. Confirm that a Copilot cloud agent session finds openspec on its PATH. At the tip the file is on release/v0.2.39 and not on main, and GitHub runs the file only from the default branch.

  • Pending a person: with a devcontainer rebuilt after feat(install-tools): install OpenSpec from a pinned npm lockfile with telemetry off #1857, run uv run devops ci. Expect every row, the openspec row included, to pass with openspec on PATH.

Activity

  1. added
    source/agent
    type/feature
    on Oct 22, 2026
  2. dan-petty commented on Oct 22, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Type: type/feature. The candidate proposes scaffolding OpenSpec and gating its change folders, which is a new feature.
    • Priority: P1-High. This is step 2 of 8 in adopting OpenSpec, and addresses critical friction points in planning and validation.
    • Value: High. The change enables proper planning and validation of changes, which is essential for the project's development workflow.
    • Effort: Medium. The effort involves setting up OpenSpec scaffolding, configuring validation rules, and ensuring CI gates work correctly.
  3. added this to the v0.2.39 milestone on Oct 22, 2026
  4. added
    status/in-progress
    on Oct 22, 2026
  5. dan-petty commented on Oct 22, 2026

    @dan-petty
    OwnerAuthor

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

  6. dan-petty commented on Oct 23, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1943, merged into release/v0.2.39 as 8f0e1b4.

    Cause

    ADR 0012 requires a wrapper for the archive of a change. A direct openspec archive runs without the isolated configuration and the opt-outs. It can also leave a spec that openspec validate rejects, such as a placeholder Purpose.

    Change

    devops openspec archive <change> runs openspec archive <change> --yes and then openspec validate --all --strict. Both runs use the isolated configuration with the four opt-outs. The command passes no --skip-specs. It exits 1 when a run fails. A failed archive skips the validation. The option --dry-run prints both commands and starts no process. MCP does not expose the command, because it writes openspec/specs/.

    A failed run prints its whole output, and then a short error names the command and the exit code. The validation prints one line for each passing spec before the failure, so a cut of the output would hide the spec that failed. A failed validation also says that the archive is applied, so the author fixes the spec and does not run the archive again.

    The apply guidance of openspec/config.yaml and the passages of ADR 0010 that told an agent to run the direct tool now name the wrapper. The wrapper is a convention, because the settings allow the direct tool. The generated skills still name the direct tool. devops openspec regenerate owns them, and #1846 records that nobody edits them.

    Existing tool considered

    openspec archive and openspec validate are the open tools. The wrapper runs them as shipped. No op…

    20 file(s) changed.

    How it was verified

    Check runs at ddaf9f4:

    • Prune PR DevContainer Images: pass
    • Audit Defect PR Hardening: skipping
    • zizmor: pass
    • devops-cli: pass
    • bandit: pass
    • CodeQL: pass
    • Dependency Freshness: skipping
    • Static Analysis: pass
    • Rule Pack Tests: pass
    • Changed-Test Independence: pass
    • Fail-to-Pass Self-Check: pass
    • Tests & Coverage: pass
    • Analyze (python): pass
    • Fail-to-Pass Check: pass
    • Analyze (actions): pass
    • Service Image: skipping
    • DevContainer Image: skipping

    Acceptance Criteria of docs/agent/tasks/task-1844-openspec-scaffold-and-gate.md:

    • uv run devops ci runs an openspec row, passes on the empty tree, and fails with a clear message when openspec is missing, naming uv run devops install-tools --tool openspec --only-missing. The real gate passed the repository's empty tree in 4.3 s and failed with the message on a PATH without the tool; tests/test_openspec_gate.py checks the commands of the empty tree in order and the missing tool (exit code 1, DEPENDENCY_MISSING, no process started), and tests/test_openspec_command.py the exit code and output of both cases.
    • uv run devops openspec regenerate leaves the tree unchanged under any developer's global profile, and check fails when a skill file was hand-edited or the profile is wider. The real tool did, as the Feasibility field records; tests/test_openspec_command.py checks that regenerate sets the four isolated settings and runs update --force and never a bare update, tests/test_openspec_gate.py that every run opts out under a configuration directory of its own whatever the environment says, and that a hand-edited skill, an added archive skill, a deleted skill and a skill tree deleted whole are each reported.
    • check fails a requirement modified by two active changes. tests/test_openspec_gate.py reports, from the real tool's recorded runs, a requirement modified twice and a requirement renamed and modified, each by the check that finds it; and it checks that a change which modifies a requirement another active change adds passes, that a change declaring skip_specs passes, and that no run of the gate is an archive. A missing Purpose, a MODIFIED of a spec that does not exist and a duplicate ADDED show only in the pull request that closes the change: validate --all --strict fails the placeholder Purpose of the archived spec, and openspec archive refuses the other two and changes no file (feat(openspec): the pull request that closes a change archives it, and readiness checks the archived folder #1846).
    • tests/test_change_folders.py fails a folder not named <issue>-<slug>, one with no tasks.md group and one carrying a Status line, and tests/test_openspec_scaffold.py fails a plain scalar rule and an unknown key, each with its line.
    • The inventory classifies every new Markdown file and devops docs check passes.
    • The pre-commit hook and the static job run the row, copilot-setup-steps.yml exists, and AGENTS.md is within CONST_AGENTS_MD_MAX_CHARS, which tests/test_agents_md_claims.py checks. devops ci --dry-run lists the row, and tests/test_openspec_scaffold.py checks the hook and tests/test_workflow_contracts.py both workflows and that every remote action is pinned.
    • The tests that replay the tool hold the record to the pin and to the gate's commands: tests/test_openspec_contract.py fails when the record is not of the locked version, when a scenario is not recorded, and when the record holds a run the gate no longer starts.
    • The permissions entries are in .claude/settings.json. A person applied them, because an agent may not edit that file. On 2026-10-22 the person set the allow list to Bash(uv run devops *), Bash(openspec *) and Bash(tuicr *), and removed the deny list. The same change deletes tests/test_claude_code_settings.py. The last part of feat(openspec): scaffold OpenSpec and gate its change folders in devops ci #1844 adds no settings test.
    • uv run devops openspec archive <name> archives the change and then runs openspec validate --all --strict, both under the isolated configuration, and exits 1 when either run fails. tests/test_openspec_command.py checks it from the real tool's recorded runs, as the Tests paragraph above lists.
    • The apply guidance of openspec/config.yaml and each passage of ADR 0010 that told an agent to run openspec archive directly name the wrapper. The copy of the configuration in ADR 0010 equals the file, and the size that ADR 0010 gives for its quoted AGENTS.md wording is 8 characters longer (39,992 of 40,000).
    • Known limit, decided in #1846: the generated skills openspec-apply-change and openspec-update-change, in .claude/skills/ and .agents/skills/, tell an agent to run openspec archive "<name>" directly. devops openspec regenerate owns those files, so nobody edits them. The wrapper is a convention, and the settings enforce neither form.
    • Pending a person: after the release that carries .github/workflows/copilot-setup-steps.yml merges to main, run the workflow once from the Actions tab and confirm that a Copilot cloud agent session finds openspec on its PATH. GitHub runs the file only from the default branch, so until then that agent finds the committed skills and no binary.
    • Pending a person: with a devcontainer rebuilt after feat(install-tools): install OpenSpec from a pinned npm lockfile with telemetry off #1842, run uv run devops ci and expect every row, the openspec row included, to pass with openspec on PATH.
  7. added a commit that references this issue on Oct 23, 2026
  8. removed
    status/in-progress
    on Oct 30, 2026
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

    source/agenttype/feature

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions