Architectural ideation on detecting documentation rot in ce-ai doctor, automating OpenSpec task reconciliation/archival, compacting historical archives, and maintaining living specifications across adopted projects.
In Compound Engineering, documentation is not an afterthought; it is the system's flight recorder and executable contract. However, as projects iterate, documentation naturally accumulates technical debt across four concrete surfaces:
In ce-ai right now, 3 completed features linger in openspec/changes/:
harness-manifest-sha256-coverage, doctor-kimi-marketplace-divergence, and linux-musl-static-release.
Root cause: All major tasks were checked [x], but subtasks (e.g. [ ] 1.1) or post-merge verification tasks ([ ] 3.7 Release tag) were left unchecked. Current probe_unarchived_completed_changes requires completed == total, so these are completely ignored.
openspec/changes/archive/ contains 108 subdirectories and over 540 Markdown files. Total markdown count across docs/ and openspec/ is 730 files!
Impact: Agent tools (find_by_name, grep_search) are flooded with stale delta proposals from months ago (e.g. v0_5_0_roadmap), consuming token context and diluting focus.
docs/solutions/ holds 72 files. Over time, refactorings rename or remove structs and CLI commands.
Impact: Solutions cite dead file paths and obsolete patterns. AI agents searching past learnings discover superseded workarounds and hallucinate dead APIs.
This technical debt is not unique to ce-ai; it emerges in any project adopted via ce-ai init-prj.
Opportunity: ce-ai doctor already inspects adopted workspaces. Adding doc hygiene probes gives every adopted project automated health auditing and compaction workflows.
The problem space is decomposed into four orthogonal axes covering detection, consolidation, hygiene, and governance:
doctor:openspec-lifecycle
doctor.archive:consolidation
solutions:drift-and-lint
governance:adoption-hygiene
.ce-ai.json, Turn-0 RepoState visibility, and CI quality gates across adopted repos.Top 7 survivor directions selected through adversarial verification against codebase grounding, ranked by leverage and expected value:
ce-ai archive compact)
4. Living System Specifications Promotion (openspec/specs/ vs Delta Specs)
5. Solution Library Drift Probe: Dead Link & Symbol Rot Detection
6. Automated Solution Refresh & Deduplication Workflow (ce-ai doc refresh)
7. Project-Wide Doc Debt Engine with Turn-0 RepoState Visibility
Upgrade probe_unarchived_completed_changes in src/commands/workflow.rs to detect "pseudo-incomplete" OpenSpec changes. Currently, if parent tasks (- [x] Task 1) are completed but subtasks (- [ ] 1.1) were left unchecked, or if all implementation tasks are checked while an external release step was unchecked, the probe completely ignores them. The new probe checks:
[x] even if nested subtasks are [ ].openspec/changes/<feature> have already landed on the default branch (main).
doctor surfaces: doctor-warn: openspec change 'X' code is merged on main with Y/Z tasks checked; run 'ce-ai archive X --auto-mark' or provides an interactive triage option in ce-ai doctor --fix.
openspec/changes/doctor-kimi-marketplace-divergence/tasks.md:5-30 (tasks 1-5 checked [x], subtasks [ ]) and src/commands/workflow.rs:975 (strict completed == total check). Exactly models why 3 merged PRs are stranded in ce-ai right now.
Instantly resolves the exact friction experienced in everyday compound engineering. Developers frequently merge PRs after checking main tasks without meticulously checking every atomic subtask line, causing finished work to linger in openspec/changes/ forever.
git log -n 1 -- <path> or branch comparison without executing heavy network calls.
An OpenSpec change that sits in openspec/changes/ with 0% or partial task completion and zero Git activity for more than 14-30 days represents dormant technical debt (abandoned experiments, forgotten features, or duplicate ideations).
ce-ai doctor introduces a Stale Pending Change Probe:
openspec/changes/<feature>/ or filesystem mtime fallback.doctor-warn: openspec change '<feature>' has been pending for 34 days with no git commits (progress: 1/5) — resume implementation, cancel/shelve, or archive with '--status "superseded/abandoned"'.openspec/changes/linux-musl-static-release/ has been sitting in openspec/changes/ untouched since release v1.50.1 while the codebase progressed to v1.53.0 with zero warning from doctor.
Eliminates invisible specification rot. Without this probe, developers start specs that get superseded by quick fixes or priority pivots, and they linger silently for months.
.ce-ai.json or marking a change as [WIP: Long-term] to prevent nagging on intentionally prolonged refactors.
ce-ai archive compact)
Implements a generational lifecycle for archived specifications. Currently, ce-ai has 108 separate subdirectories in openspec/changes/archive/ containing ~540 markdown files.
The compaction command ce-ai archive compact [--before <date>|--milestone <tag>]:
v0.5..v1.20) into a single consolidated milestone summary file: openspec/changes/archive/milestones/2026-Q1.md containing a structured table of features, proposals, release PR links, and final specs.exploration.md, tasks.md) into a compressed archive tarball (archive-2026-Q1.tar.gz) or removes the scaffolding while preserving the final contract.doctor warns when uncompacted archive directories exceed a threshold (e.g. doctor-info: archive has 108 packages (>30 threshold); run 'ce-ai archive compact').openspec/changes/archive/ (108 folders on disk) and external: Generational Garbage Collection (Eden vs Survivor vs Tenured) and RFC/ADR compaction conventions.
Directly saves hundreds of files from clogging agent token context, Git tree blobs, and file searches. Preserves 100% auditability while restoring repository lightness.
archive/README.md and ensure historical PRs can still trace their compacted specs.
openspec/specs/ vs Delta Specs)
Reframe OpenSpec changes as delta flight recorders rather than permanent destinations. In OpenSpec methodology, openspec/changes/<feature>/ describes what is changing, while openspec/specs/<domain>.md describes what the system is today.
When a change is finished and archived:
spec.md are promoted into the corresponding domain specification under openspec/specs/ (e.g. specs/harnesses.md, specs/doctor.md).specs/.ce-ai doctor audits if active changes are missing target domain mappings.specs/ as the durable living system specification and changes/ as transient deltas. In ce-ai today, specs/ is currently unused, forcing all knowledge to sit in 108 delta folders.
Transitions the codebase from an archaeology site of past PRs into a coherent, navigable living architecture. AI agents orient to 5-10 domain specs instead of wading through 100 historical change proposals.
Add a dedicated Solution Health Probe to ce-ai doctor that audits all files in docs/solutions/**/*.md:
src/harness/kimi.rs, components: [commands::workflow]). If a cited file does not exist in the working tree, emit: doctor-warn: solution 'architecture/xyz.md' references non-existent path 'src/old.rs' (refactored or deleted).title, module/category, problem_type, tags, applies_when) so search agents like learnings-researcher index them reliably.status: deprecated.docs/solutions/ (72 files) and docs/solutions/architecture/openspec-archive-command-and-ledger-synchronization.md:13-14 (cites components and files). Code refactors frequently invalidate past solution snippets without notice.
Directly prevents AI coding agents from hallucinating obsolete APIs and reproducing bugs that were fixed months ago. Keeps the team's institutional memory empirically grounded in current source code.
src/**, tests/**) should be validated.
ce-ai doc refresh)
Bridge the existing ce-compound-refresh agent skill with native CLI diagnostics. Over time, multiple solutions accumulate covering similar topics (e.g. 5 solutions on harness adapters, 4 on test isolation).
Introduce ce-ai doc refresh [--cluster]:
docs/solutions/./ce-compound-refresh skill to merge fragmented troubleshooting notes into a single durable architectural reference.docs/solutions/ contains overlapping topics in architecture/ and workflow-issues/, and external: the ce-compound-refresh skill already exists in the Compound Engineering plugin but lacks an automated discovery trigger.
Practices true Compound Engineering: rather than letting documentation fragment into 200 tiny notes, the system continuously refactors knowledge into dense, high-leverage principles.
Make documentation debt a first-class citizen in the Zero-Step Drift Recovery architecture. Any repository adopted via ce-ai init-prj runs ce-ai workflow resume at the start of every session (Turn-0).
Features:
RepoState: doc debt: 3 unarchived specs (code merged), 1 stale spec (34d), 2 dead solution links..ce-ai.json:
{
"doc_hygiene": {
"stale_spec_days": 21,
"archive_compaction_threshold": 30,
"check_solution_paths": true
}
}
ce-ai itself.CONCEPTS.md:53 (Zero-Step Drift Recovery) and src/commands/init_prj.rs.
Solves the user's primary prompt: "eso pasa en cualquier proyecto manejado con ce-ai también... habría que hacer que doctor vaya detectando eso si es posible". Bridges `doctor` diagnostics and Turn-0 session delivery into a cohesive governance shield.
To maintain high signal, 21 candidate ideas were critiqued and eliminated during Phase 3 filtering. Key rejections with explicit rationales:
| Candidate Move | Frame / Origin | Primary Axis | Rejection Rationale |
|---|---|---|---|
| Autonomous Silent Archival & Auto-Checking | Constraint-Flipping | doctor:openspec-lifecycle |
Violates State Determinism: Automatically ticking checkboxes and moving folders without user approval risks masking genuinely abandoned or broken tasks. Doctor must advise and offer --fix, not mutate silently. |
| Hard CI Failure on Any Doc Rot (Exit 6) | Assumption-Breaking | governance:adoption-hygiene |
Excessive Friction: Blocking builds because an archived spec is older than 60 days or a solution has a dead path halts emergency hotfixes. Better offered as an opt-in flag (ce-ai doctor --strict-docs). |
| Orphan Git Branch / Zero-Disk Archives | Constraint-Flipping | archive:consolidation |
DX Degradation: Storing archives exclusively on a separate branch or git tags breaks ordinary GitHub code search, web UI browsing, and local IDE grep navigation. Generational compaction achieves 90% of benefits with zero DX penalty. |
| Git Hook Auto-Archival on Commit | Inversion/Automation | governance:adoption-hygiene |
Fragile Integration: Client repositories often have custom git hook managers (Husky, lefthook) or complex rebase workflows where git hooks can fail or cause merge conflicts. Doctor probes are vastly safer. |
| Full AST Semantic Verification of Design.md | Assumption-Breaking | doctor:openspec-lifecycle |
Too Expensive & Brittle: Parsing arbitrary prose in design.md to map against Rust AST requires language-specific compiler frontends and fails on non-Rust adopted projects. Git commit & file existence heuristics provide 95% of the value at 1% of the complexity. |