13 KiB
description
| description |
|---|
| Archive a completed change in the experimental workflow |
Archive a completed change in the experimental workflow.
OpenSpec store (WealthLedger): Use only wealth-ledger-specs, whose physical root is specs/openspec. Every OpenSpec command that reads or writes specs or changes MUST include --store wealth-ledger-specs; keep this flag on every follow-up. Do not infer a store from cwd, the nearest root, or machine configuration.
OpenSpec version preflight: Before the first OpenSpec command, work from the workspace root and run bash specs/scripts/verify-openspec-version.sh. A missing or mismatched CLI is a blocking result.
Approval boundary: Archive requires explicit Change Owner approval of Proposal, Delta Specs, Design and Tasks in sequence. File/status existence is not approval. If approval evidence is unavailable, or an upstream artifact changed, invalidate dependent approvals and require cascading reapproval; stop without offering an override.
Planning gate: Before any archive mutation run bash specs/scripts/verify-openspec-planning.sh "<name>"; the full workspace dispatcher repeats it. A failure blocks archive without override, and structural success cannot replace semantic verification or independent read-only review.
<capability-path> is the spec directory relative to specs/ (for example, user-auth or identity/user-auth). Preserve the full path from each delta spec when resolving its main spec.
Input: Optionally specify a change name after /opsx-archive (e.g., /opsx-archive add-auth). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
Steps
-
Select the change
If a name is provided, use it. Otherwise:
- Infer from conversation context if the user mentioned a change
- Auto-select if only one active change exists
- If ambiguous, run
openspec list --json --store wealth-ledger-specsto get available changes and ask the user to select one
When prompting, show only active changes (not already archived). Include the schema used for each change if available.
Always announce: "Using change: " and how to override (e.g.,
/opsx-archive <other>).Load current archive inputs before the existing archive checks:
After resolving the selected change and planning root, run:
openspec instructions archive --change "<name>" --json --store wealth-ledger-specsKeep the same selected-root flags on this command. This lookup is advisory and optional: it only supplies extra prompt inputs, so it must never block archiving. If it exits non-zero or returns invalid JSON — for example on an older CLI that does not support this command yet — continue the archive workflow with no context and no operation guidance. Do not report an error and do not stop.
A successful response may omit both optional fields. Treat
contextas a required prompt-level input: read and consider it, and apply relevant project facts, conventions, and constraints. TreatoperationGuidanceas optional additive advice: read and consider every entry, and follow entries that are applicable and compatible with the built-in archive workflow.Keep both fields separate from built-in steps, explicit user choices, resolved paths, CLI checks, and command contracts. If context conflicts with one of those controlling inputs, report the conflict and preserve the controlling value. If guidance is inapplicable or conflicts with a controlling input, do not follow it and explain why. Do not infer replacement paths, skipped prompts, or flags from either field, and do not copy their text verbatim into specs, change artifacts, or archive summaries unless the user separately asks for it. These are prompt-level behavior contracts, not enforceable checks.
-
Check artifact completion status
Run
openspec status --change "<name>" --json --store wealth-ledger-specsto check artifact completion.Parse the JSON to understand:
schemaName: The workflow being usedplanningHome,changeRoot,artifactPaths, andactionContext: path and scope contextartifacts: List of artifacts with their status (done,skipped, or other)
If any artifacts are neither
donenorskipped(skipped artifacts satisfy the requirement - the change declares skip_specs):- Stop without syncing or archiving.
- Report the incomplete artifacts as blocking conditions.
- Do not ask for or accept a confirmation override.
-
Check task completion status
Read the tasks file (typically
tasks.md) to check for incomplete tasks.Count tasks marked with
- [ ](incomplete) vs- [x](complete).If incomplete tasks found:
- Stop without syncing or archiving.
- Report the incomplete tasks as blocking conditions.
- Do not ask for or accept a confirmation override.
If no tasks file exists: Stop without syncing or archiving. Report the missing
tasks.mdas a blocking condition.WealthLedger pre-archive gates:
- Run
bash specs/scripts/verify-workspace-change.sh "<name>"from the workspace root and require a successful result for every affected delivery area. - Require successful semantic verification against Proposal, Delta Specs, Design and Tasks.
- Require a completed independent read-only review with no unresolved Critical or Important finding.
- Stop if any gate or evidence is missing or unsuccessful. Do not ask for or accept a confirmation override.
-
Assess delta spec sync state
Use
artifactPaths.specs.existingOutputPathsfrom status JSON as the only delta-spec source. If thespecsentry is missing orexistingOutputPathsis empty, proceed without a sync prompt and do not infer delta specs from other artifacts.If delta specs exist:
- Compare each delta spec with its corresponding main spec at
<planningHome.root>/openspec/specs/<capability-path>/spec.md(use the store-awareplanningHome.rootfrom step 2, not a hardcoded repo path) - Determine what changes would be applied (adds, modifications, removals, renames)
- Show a combined summary before prompting
Prompt options:
- If changes needed: "Sync now (recommended)", "Archive without syncing"
- If already synced: "Archive now", "Sync anyway", "Cancel"
Route on the answer:
- "Cancel" — stop, do not archive
- "Archive without syncing" or "Archive now" — proceed to archive
- "Sync now" or "Sync anyway" — sync, then verify (below)
- Anything else — ask again rather than archiving
Before a selected sync writes any main spec, run
openspec instructions specs --change "<name>" --json --store wealth-ledger-specsonce with the same selected-root flags. Require a zero exit status and valid artifact-instruction JSON. If the lookup fails or returns invalid JSON, report the error and stop before writing any main spec or moving the change. A valid response with omittedrulesis the no-rules case. Apply returnedrulesonly to the content and form of main specs produced by this merge; do not use them as archive guidance, change CLI behavior, or copy the rule text into any output file.Then run the
/opsx-syncworkflow inline (agent-driven intelligent merge) for change '', passing the delta spec analysis and the fetched specs-rule snapshot from above, and wait for it to finish. The inline sync must reuse that snapshot without fetchingspecsinstructions again. Do not delegate it to a background task — step 5 would movechangeRootout from under a sync that is still reading it, leaving the change archived and the main specs never updated. If your agent can only run it by delegation, delegate synchronously and wait for the result.Then re-run the comparison from the top of this step against every capability that has a delta spec in
artifactPaths.specs.existingOutputPaths— not only the ones the sync reports it touched. A successful sync leaves nothing left to apply, so each capability must now read as already synced:- ADDED requirements present
- MODIFIED requirements carrying the scenario and description changes named in the delta, with their other scenarios intact
- REMOVED requirements gone — and where this sync retired a capability (removed its last requirement, leaving
## Requirementsempty), its main spec deleted rather than left empty; a spec the sync deliberately kept and reported is also a match - RENAMED requirements present under the new name and absent under the old one
If the sync failed, or any capability does not match, report what differs and stop — do not archive. Nothing has moved and
changeRootis intact, so the user can fix the mismatch or re-run the sync and start the archive again. - Compare each delta spec with its corresponding main spec at
-
Perform the archive
Create an
archivedirectory underplanningHome.changesDirif it doesn't exist:mkdir -p "<planningHome.changesDir>/archive"Generate the target name: use the change name as-is when it already starts with a
YYYY-MM-DD-prefix; otherwise prepend the current date asYYYY-MM-DD-<change-name>. Never stack a second date (same rule asopenspec archive --store wealth-ledger-specs).Check if target already exists:
- If yes: Fail with error, suggest renaming existing archive or using different date
- If no: Move
changeRootto the archive directory
mv "<changeRoot>" "<planningHome.changesDir>/archive/<target-name>" -
Display summary
Show archive completion summary including:
- Change name
- Schema that was used
- Archive location
- Spec sync status (synced / sync skipped / no delta specs)
- Confirmation that all planning artifacts and tasks were complete before archive
After the move succeeds, use a deterministic two-phase evidence protocol:
- First commit the delivered changes in each affected repository, including the synced/archive state in
specsand any as-built documentation indocs, and collect their actual commit IDs. - Then write Completion Evidence in the durable registry/history with the archive path, Delivery Map, those delivery commit IDs, exact verification commands, observed results and independent review verdict.
- Commit Completion Evidence as a final follow-up in
docs. The evidence cites the preceding docs delivery commit when docs was affected; when docs wasN/A, it preserves that reason and does not invent an implementation commit. Its own follow-up commit cannot self-reference and is reported in the archive summary instead of repeatedly rewriting the record.
Do not add these post-archive actions as unchecked tasks in the archived change and do not claim terminal
donebefore the evidence follow-up commit succeeds.
Output On Success
## Archive Complete
**Change:** <change-name>
**Schema:** <schema-name>
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
**Specs:** ✓ Synced to main specs
All artifacts complete. All tasks complete.
Output On Success (No Delta Specs)
## Archive Complete
**Change:** <change-name>
**Schema:** <schema-name>
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
**Specs:** No delta specs
All artifacts complete. All tasks complete.
Output On Error (Archive Exists)
## Archive Failed
**Change:** <change-name>
**Target:** the archive path derived from `planningHome.changesDir`/<target-name>/
Target archive directory already exists.
**Options:**
1. Rename the existing archive
2. Delete the existing archive if it's a duplicate
3. Wait until a different date to archive
Guardrails
- Announce the selected change; prompt for selection when it is ambiguous
- Use artifact graph (
openspec status --json --store wealth-ledger-specs) for completion checking - Treat incomplete artifacts, a missing
tasks.md, incomplete tasks, an affected delivery area failure, missing semantic verification and missing independent read-only review as hard blockers; never offer an override - Preserve .openspec.yaml when moving to archive (it moves with the directory)
- Show clear summary of what happened
- If sync is requested, run the
/opsx-syncworkflow inline (agent-driven) - Never archive while a spec sync is still in flight — run the sync inline and verify the main specs before moving
changeRoot - If delta specs exist, always run the sync assessment and show the combined summary before prompting
- Apply relevant runtime context and report conflicts; operation guidance remains advisory
- Consider every guidance entry and explain any inapplicable or conflicting advice
- Existing CLI checks, resolved paths, prompts, and command contracts are unchanged
- Artifact rules constrain only the specs being written and are never operation guidance
- Never copy runtime context, operation guidance, or artifact-rule text verbatim into output files