diff --git a/openspec/changes/fix-schema-init-force-validation-order/.openspec.yaml b/openspec/changes/archive/2026-07-28-fix-schema-init-force-validation-order/.openspec.yaml similarity index 100% rename from openspec/changes/fix-schema-init-force-validation-order/.openspec.yaml rename to openspec/changes/archive/2026-07-28-fix-schema-init-force-validation-order/.openspec.yaml diff --git a/openspec/changes/fix-schema-init-force-validation-order/design.md b/openspec/changes/archive/2026-07-28-fix-schema-init-force-validation-order/design.md similarity index 100% rename from openspec/changes/fix-schema-init-force-validation-order/design.md rename to openspec/changes/archive/2026-07-28-fix-schema-init-force-validation-order/design.md diff --git a/openspec/changes/fix-schema-init-force-validation-order/proposal.md b/openspec/changes/archive/2026-07-28-fix-schema-init-force-validation-order/proposal.md similarity index 100% rename from openspec/changes/fix-schema-init-force-validation-order/proposal.md rename to openspec/changes/archive/2026-07-28-fix-schema-init-force-validation-order/proposal.md diff --git a/openspec/changes/fix-schema-init-force-validation-order/specs/schema-init-command/spec.md b/openspec/changes/archive/2026-07-28-fix-schema-init-force-validation-order/specs/schema-init-command/spec.md similarity index 100% rename from openspec/changes/fix-schema-init-force-validation-order/specs/schema-init-command/spec.md rename to openspec/changes/archive/2026-07-28-fix-schema-init-force-validation-order/specs/schema-init-command/spec.md diff --git a/openspec/changes/fix-schema-init-force-validation-order/tasks.md b/openspec/changes/archive/2026-07-28-fix-schema-init-force-validation-order/tasks.md similarity index 100% rename from openspec/changes/fix-schema-init-force-validation-order/tasks.md rename to openspec/changes/archive/2026-07-28-fix-schema-init-force-validation-order/tasks.md diff --git a/openspec/specs/schema-init-command/spec.md b/openspec/specs/schema-init-command/spec.md index f5017dc4fe..88fb170382 100644 --- a/openspec/specs/schema-init-command/spec.md +++ b/openspec/specs/schema-init-command/spec.md @@ -2,7 +2,6 @@ ## Purpose Define `openspec schema init` behavior for creating project-local schema skeletons in interactive and non-interactive modes. - ## Requirements ### Requirement: Schema init command creates project-local schema The CLI SHALL provide an `openspec schema init ` command that creates a new schema directory under `openspec/schemas//` with a valid `schema.yaml` file and default template files. @@ -74,3 +73,23 @@ The CLI SHALL support `--json` flag for machine-readable output. - **THEN** system outputs JSON with `error` field describing the issue - **AND** exits with non-zero code +### Requirement: Schema init validates artifacts before forced replacement +The CLI SHALL validate all requested artifact IDs before replacing an existing project-local schema. If artifact validation fails, the CLI SHALL leave the existing schema directory and all of its contents unchanged on every supported platform. + +#### Scenario: Unknown artifact preserves existing schema +- **GIVEN** `openspec/schemas/tdd-driven/` already exists with user-authored files +- **WHEN** the user runs `schema init tdd-driven` with `--force` and an artifact list containing the unknown ID `task` +- **THEN** the command exits with a non-zero status and reports the unknown artifact +- **AND** the existing `tdd-driven` schema directory and its contents remain unchanged + +#### Scenario: Unknown artifact preserves a schema at a Windows project path +- **GIVEN** an existing project-local schema is resolved from a Windows filesystem path +- **WHEN** forced schema initialization fails artifact validation +- **THEN** the resolved schema directory and its contents remain unchanged + +#### Scenario: Valid artifacts allow forced replacement +- **GIVEN** a project-local schema already exists +- **WHEN** the user runs `schema init` with `--force` and only valid artifact IDs +- **THEN** the command replaces the existing schema with the newly generated schema +- **AND** reports successful creation +