ce-ideate discovery report

OpenSpec Change Archival: Command vs Manual Convention

An architectural evaluation of why 33 completed OpenSpec changes lingered unarchived in ce-ai, exploring candidate CLI tooling, safety guarantees, and lifecycle automation.

Date
Topic openspec-archive-command-and-convention
Focus no hay un comando de archive en ce-ai es una convención, evalua
Mode repo-grounded

1. Grounding Context (Codebase & Historical Trace)

In ce-ai, the OpenSpec methodology requires changes to be drafted under openspec/changes/<feature>/ (with proposal.md, exploration.md, design.md, spec.md, and tasks.md). Upon implementation completion and merging, changes are meant to be moved to openspec/changes/archive/<feature> as an audit trail linking releases to contracts.

Diagnostic Implementation (v1.44.2 / Issue #323)

ce-ai implemented probe_unarchived_completed_changes (in src/commands/workflow.rs:923) to detect folders where completed_tasks == total_tasks. It alerts deterministically at Turn-0 session resume and in ce-ai doctor.

The Deliberate "No-Auto-Mv" Boundary

During Issue #323 design (exploration.md), automated git mv was ruled out-of-scope because ce-ai strives never to mutate git index or filesystem trees without explicit developer request. Archiving was declared an explicit developer or agent convention.

The Empirical Consequence: 33 Lingering Folders

Because no CLI command existed (e.g. ce-ai workflow archive) and archiving required multi-step manual shell commands and markdown table editing in archive/README.md, 33 completed change folders accumulated in openspec/changes/, generating 33 warnings on every doctor check.

Dual Completion Criteria in archive/README.md

Archival is governed by two criteria: (1) Mechanical: 100% tasks marked [x], and (2) STATUS-verified shipped: tasks.md opened with > STATUS header citing live code symbols or CHANGELOG releases. Currently, only Criterion 1 has machine detection.

2. Topic Surface Decomposition (Axes)

1. Invocation & Surface Design Surface

Where and how the capability is exposed to humans and agents (dedicated subcommand vs doctor flag vs TUI).

2. Archival Mechanics & Git Safety Safety

How physical mutations occur safely without racing active worktrees, dirty files, or causing untracked loss.

3. Lifecycle Trigger & Automation Hooks Lifecycle

When archival is proposed or executed (Stage 7 shipping, PR merge, release tagging, or post-merge cleanup).

4. Audit Trail & Verification Contract Governance

Validating Criterion 1 (tasks) vs Criterion 2 (STATUS), and syncing archive/README.md triage tables.

5. Batch & Multi-Feature Remediation Remediation

How to drain the existing 33-feature backlog smoothly with preview, dry-run, and conflict handling.

3. Ranked Ideas

#1

Dedicated ce-ai workflow archive [feature] CLI Command with --all & --dry-run

Invocation & Surface Design Confidence: 95% Complexity: Low
Description
Introduce an explicit subcommand under workflow: ce-ai workflow archive [feature] (aliased to ce-ai archive). When executed with a feature name, it verifies task completion (or STATUS header), ensures target destination does not collide, and moves the folder from openspec/changes/<feature> to openspec/changes/archive/<feature> using git-aware moving. Adding --all iterates over all completed folders discovered by probe_unarchived_completed_changes, immediately solving the 33-folder backlog. Includes --dry-run for zero-risk inspection.
Basis (direct)
direct:src/commands/workflow.rs:923
probe_unarchived_completed_changes already implements the exact discovery logic returning Vec<UnarchivedChange> with full task progress. The command simply provides the actionable execution arm that this probe was missing.
Rationale & Why It Matters
Replaces clumsy manual terminal typing (mkdir -p openspec/changes/archive && git mv openspec/changes/feat openspec/changes/archive/) with a single deterministic command. Both human engineers and AI agents can invoke it deterministically when directed by doctor.
Tradeoffs & Downsides
Requires developers or agents to remember to run it after feature work unless paired with lifecycle hooks (Idea #5).
#2

ce-ai doctor --fix Self-Healing Diagnostic Remediation

Invocation & Surface Design Confidence: 90% Complexity: Low
Description
Add a --fix flag to ce-ai doctor following industry standards like cargo fix or ruff --fix. When doctor discovers completed unarchived OpenSpec changes (lines 613-619), --fix automatically prompts the operator (or automatically executes in non-interactive agent mode with --yes) to archive all verified completed changes safely.
Basis (direct)
direct:src/commands/doctor.rs:615-619
Currently, doctor prints: doctor-warn: openspec change 'xxx' is complete (N/N tasks) but not archived — see openspec/changes/archive/README.md. With --fix, doctor bridges diagnosis with immediate remediation without forcing the user to switch commands.
Rationale & Why It Matters
When users see 33 warnings in ce-ai doctor, their natural reaction is "how do I fix this?". Allowing ce-ai doctor --fix provides instant cognitive closure and self-healing.
Tradeoffs & Downsides
Mutating filesystem inside doctor requires careful opt-in guards (interactive confirmation or explicit --yes) to prevent unexpected changes during automated CI runs.
#3

Two-Tier Archival Engine: Mechanical vs STATUS-Attested (Criterion 2)

Audit Trail & Verification Contract Confidence: 88% Complexity: Medium
Description
Expand the archival engine beyond naive checkbox counting. Support Criterion (2) from archive/README.md via CLI: ce-ai workflow archive <feature> --status "Shipped in v1.45.0, PR #325". This command automatically writes the formal > STATUS: Shipped in ... markdown callout at the top of tasks.md, declaring residual tasks intentionally unaudited, and archives the folder.
OpenSpec Folder tasks.md Active Change State Archival Engine Criterion 1: 100% [x] Criterion 2: --status <ref> Archive Destination openspec/.../archive/ Audit Trail Preserved
Basis (direct)
direct:openspec/changes/archive/README.md:3-9
"A folder is archived when either: 1. All tasks checked — mechanical completion; or 2. STATUS-verified shipped — tasks.md opens with a `> STATUS` header citing feature-level ship evidence."
Rationale & Why It Matters
In real-world development, features often ship with minor optional tasks cut or rescoped. Without Criterion 2 tooling, developers are stuck either checking false boxes or leaving folders in limbo forever.
Tradeoffs & Downsides
Requires validating that the supplied status string actually points to a real commit, PR, or CHANGELOG entry to prevent fake attestations.
#4

Atomic Safe-Mover with Git Worktree & Dirty Tree Isolation

Archival Mechanics & Git Safety Confidence: 92% Complexity: Medium
Description
Implement a hardened filesystem mover crate::workflow::archive_feature(repo_root, feature) that guarantees zero data loss: (1) asserts destination archive/<feature> does not already exist, (2) verifies the feature folder has no uncommitted git conflicts, (3) uses git mv when git is available and clean, or atomic directory rename + git stage fallback, and (4) arms the operation in ce-ai's append-only install journal (Issue #331) for rollback recovery if interrupted.
Basis (direct)
direct:src/state/journal.rs & src/state/mod.rs (write_atomic)
Directly addresses the primary risk cited in unarchived-completed-changes-detection/exploration.md (Tradeoff 1): preventing unrequested git staging races and dirty working tree corruption.
Rationale & Why It Matters
Eliminates the danger that moving files might clobber active unstaged work or break across OS boundaries (e.g. Windows file locking or macOS case-insensitive paths).
Tradeoffs & Downsides
Slightly more complex implementation than a simple std::fs::rename, but non-negotiable under ISO 27002 and NIST CP-9 invariants.
#5

Stage 7 Shipping & Release Lifecycle Auto-Archival Hook

Lifecycle Trigger & Automation Hooks Confidence: 85% Complexity: Medium
Description
Integrate archival directly into Stage 7 of the Compound Engineering flywheel (ce-commit-push-pr skill and AGENTS.md Hard Invariant #10: Post-Merge Cleanup). When an agent creates the shipping PR or runs post-merge branch pruning on main, the active feature is automatically staged into openspec/changes/archive/ as part of the release commit.
Basis (direct)
direct:AGENTS.md:10 (Post-Merge Cleanup) & AGENTS.md:9 (Mandatory Versioning)
Rule 10 mandates: "Immediately after merging a PR, switch to main, run git pull, delete merged local branches... and remove turn-created temporary worktrees." Adding OpenSpec archival to this exact post-merge checklist prevents unarchived folders from ever entering main unarchived.
Rationale & Why It Matters
Shifts archival from an asynchronous cleanup chore to a synchronous stage of shipping. Features are archived at the exact moment they are delivered, cutting backlog formation at the source.
Tradeoffs & Downsides
If a PR is closed without merging or rejected, premature archival on the feature branch could require restoring the folder.
#6

Automated archive/README.md Triage Ledger Sync & CHANGELOG Cross-Referencing

Audit Trail & Verification Contract Confidence: 84% Complexity: Low
Description
Whenever a feature is archived, ce-ai automatically parses the current SemVer version in Cargo.toml, updates the Historical Notes and Triage table in openspec/changes/archive/README.md, and optionally formats a link ready for CHANGELOG.md linking the release notes to the archived spec.
Basis (direct)
direct:openspec/changes/archive/README.md:14-32
Every previous archival sweep (v1.20.1, v1.21.0, v1.44.2) required manual markdown documentation in archive/README.md. Automating this bookkeeping keeps the audit trail synchronized with zero human effort.
Rationale & Why It Matters
Ensures the archive doesn't become a graveyard of forgotten files, but remains an active, indexed historical ledger.
Tradeoffs & Downsides
Must parse markdown tables reliably without clobbering manual notes written by human maintainers.
#7

Interactive TUI Archival Drawer in Ratatui Dashboard

Batch & Multi-Feature Remediation Confidence: 80% Complexity: Medium
Description
Add a dedicated "Archival Ledger" view within ce-ai tui (accessible via the Workflow dashboard tab). The view lists all unarchived completed folders with task counts, git branch origin, and last modified date. Operators can use up/down arrows and Space to select multiple features, then press [a] to execute a batch archive with live progress indicators.
Basis (direct)
direct:src/tui.rs & CONCEPTS.md:26
Leverages ce-ai's rich interactive Ratatui dashboard, giving human developers visual control over batch triaging without memorizing CLI syntax.
Rationale & Why It Matters
Provides a high-delight, zero-cognitive-overhead interface for developers who prefer interactive terminal dashboards over raw CLI command strings.
Tradeoffs & Downsides
Only benefits interactive human users; headless CI and autonomous AI agents require the CLI command (Idea #1) and doctor fix (Idea #2).

4. Rejection Summary (Considered & Cut)

# Idea Reason Rejected / Cut
1 In-Place Archival via Frozen State Metadata Rejected: Violates the established single source of truth in openspec/changes/archive/ and breaks directory browsing conventions across harnesses.
2 Git Pre-Commit Archival Interception Hook Rejected: Too intrusive; interrupts iterative developer commits before PR review is even finalized.
3 Changesets-Inspired "Consume on Release" Ceremony Rejected: Conceptually sound but overlaps heavily with Idea #5 (Stage 7 lifecycle hook); absorbed into that unified candidate.
4 Database Migration Lifecycle Model Rejected: Unnecessary conceptual complexity; treating folders as stateful migration items adds overhead without additional safety.
5 Zero-Move Virtual Archive Index (.ce-ai/archive-index.json) Rejected: Creates split state between index file and filesystem reality, defeating git grep and directory transparency.
6 Unconditional Auto-Archive in Background Sync Watcher Rejected: Severe race condition risk with active developer editor saves and multi-worktree checkouts; violates NIST atomic safety principles.

5. Synthesis & Recommended Direction

The Core Root Cause: The current warning fatigue (33 completed folders lingering unarchived) is the direct consequence of implementing detection in Issue #323 without providing an execution tool. Leaving archival purely to "manual convention" created friction that both humans and AI agents avoid.

Recommended Strategy: Implement a cohesive 3-part solution:

  1. Immediate Remediation (Ideas #1 & #2): Ship ce-ai workflow archive [feature] [--all] [--dry-run] alongside ce-ai doctor --fix. This immediately drains the 33-folder backlog in one safe turn.
  2. Hardened Mechanics (Ideas #3 & #4): Base the archive operation on the journaled Atomic Safe-Mover, adding support for Criterion 2 (--status <ref>) so shipped changes with rescoped tasks can be archived cleanly.
  3. Prevention Hook (Idea #5): Wire archival into Stage 7 shipping and AGENTS.md Rule 10 cleanup so new backlogs never form.