ce-ai Ideation: ODD Integration, OpenSpec Coexistence & Adaptive Mode Router

First-principles analysis: reconciling Gentle AI's Organic Driven Development (Problem + Guardrails + DoD) with ce-ai's Living Specifications & Compound Flywheel.

Date 2026-09-16
Topic odd-openspec-mode-router-analysis
Focus ODD vs SDD/OpenSpec, Living Contracts, Heuristic Router & Rust code injection
Mode repo-grounded

1. Clarification & Philosophical Framing

Disentangling ce-ai from Gentle AI: ce-ai is an entirely independent, clean-room Rust CLI and multi-harness manager. It was not built on top of Gentle AI's codebase. While both ecosystems can optionally utilize developer sidecars (such as Engram for memory, CodeGraph for AST indexing, Context7, or RTK), these tools are optional plugins in Gentle AI, and standalone companion sidecars in ce-ai.

The Current Evolution of Gentle AI's ODD

Gentle AI's ODD (Organic Driven Development) has evolved to steer away from traditional, rigid Spec-Driven Development (SDD). Instead of demanding exhaustive, prescriptive upfront specification files before exploratory work begins, ODD relies on an agile triad:

Why This Causes Tension: Should ce-ai Question OpenSpec?

Gentle AI's departure from SDD raises a legitimate question: If ODD moves away from heavy upfront specs, is OpenSpec in ce-ai an outdated ceremonial burden?

The short answer is No, but its role must be properly partitioned:

The Deep Synthesis: ODD is the Solutioning & Tactical Engine (Problem + Guardrails + DoD).
OpenSpec is the Architectural & System-of-Record Engine (Living Contracts + Delta Promotion).
They are not competitors; they operate at different architectural altitudes.

2. Topic Axes (Surface Decomposition)

3. Ranked Ideas & Architectural Solutions

Idea 1: Turn-0 Adaptive Mode Router (Deterministic & Heuristic)
Rank #1 Axis 1 & 3 Confidence: 96% Complexity: Med
Description

Implement a deterministic Mode Router directly inside ce-ai workflow resume and the Turn-0 session start hooks (Claude Code, Codex, Cursor, Antigravity PreInvocation). Critique of LLM-based routers: Calling an LLM agent to route requests introduces 1.5–3.5s of latency, costs recurring tokens, and suffers from prompt hallucinations. Instead, ce-ai evaluates the workspace state in under 5ms using deterministic heuristics:

  1. Explicit Flag/Override: ce-ai workflow --mode [odd|compound] or user prompt directive (--odd / --compound).
  2. Active OpenSpec Directory: If openspec/changes/<feature>/ exists and is unresolved ➔ Compound Mode (enforces 7-stage workflow).
  3. Branch Taxonomy:
    • fix/*, chore/*, spike/*, test/* ➔ ODD Mode (Fast-path: Problem + Guardrails + DoD).
    • feat/*, refactor/*, spec/* ➔ Compound Mode (Formal OpenSpec contract required).
  4. Project Adoption Tier: AdoptionTier::Minimal defaults to ODD mode; AdoptionTier::Full defaults to Compound mode.
Harness Turn-0 ce-ai workflow resume Deterministic Classifier < 5ms / 0 Token Overhead • Branch prefix (fix/ vs feat/) • Active openspec/changes/ • Adoption Tier & LOC delta Mode: ODD (Organic Fast-Path) • Triad: Problem + Guardrails + DoD • No OpenSpec ceremony required (<200 LOC) Mode: Compound (Living Specification) • OpenSpec Delta Ledger & Spec Promotion • 7-Stage FSM Gate & Code Review Receipt
Concrete Injection Points in Rust Codebase
// 1. src/state/state.rs: Add WorkflowMode to State #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)] #[serde(rename_all = "lowercase")] pub enum ExecutionMode { #[default] Auto, // Resolved dynamically by heuristics Organic, // ODD Fast-Path (Problem + Guardrails + DoD) Compound, // Full 7-stage OpenSpec Flywheel } // 2. src/commands/workflow.rs: Probe and inject inside resume_lines() pub fn probe_execution_mode(repo_root: &Path, branch: Option<&str>, wf: &Option, tier: AdoptionTier) -> ExecutionMode { if let Some(w) = wf { if w.stage >= WorkflowStage::OpenSpec && w.stage < WorkflowStage::GitShipping { return ExecutionMode::Compound; } } let openspec_dir = repo_root.join("openspec").join("changes"); if openspec_dir.is_dir() && has_active_unarchived_change(&openspec_dir) { return ExecutionMode::Compound; } if let Some(b) = branch { if b.starts_with("fix/") || b.starts_with("chore/") || b.starts_with("spike/") { return ExecutionMode::Organic; } if b.starts_with("feat/") || b.starts_with("spec/") { return ExecutionMode::Compound; } } match tier { AdoptionTier::Minimal => ExecutionMode::Organic, _ => ExecutionMode::Compound, } }
Basis & Rationale

direct: src/commands/workflow.rs:355-470: resume_lines() is already executed by hooks on every single agent turn start. Enhancing it to inject the appropriate guidance (ODD prompt for bugfixes/chores; Compound FSM for features) eliminates user decision fatigue without introducing external routing overhead.

Idea 2: The "Graduation Bridge" (ce-ai workflow graduate)
Axis 2 & 5 Confidence: 92% Complexity: Low
Description

A common failure mode in organic workflows is that a task begins as a simple exploratory spike or quick fix, but exploration reveals an architectural cross-cutting change touching multiple sub-modules. Under pure ODD, the developer either cuts corners to keep it informal, or has to manually stop, copy-paste notes, and write an OpenSpec package from scratch.

ce-ai should provide a native graduation command: ce-ai workflow graduate <feature-name>. This command ingests the active ODD task file (e.g. odd/tasks/<feature>.md or an exploratory scratchpad), maps the Problem Statement to proposal.md, the Guardrails to spec.md, and the DoD checkboxes to tasks.md, automatically registering the change in state.json and advancing the FSM to Stage 3 (Execution Plan).

Basis & Rationale

reasoned: Continuous Refinement Principle: Protects developers from the "spec wall" while strictly preventing uncontrolled scope creep. Developers start in ODD with zero ceremony, and only pay the OpenSpec bookkeeping tax when the problem objectively demands architectural permanence.

Idea 3: The ODD Single-File Brief Schema (Problem + Guardrails + DoD)
Axis 2 Confidence: 94% Complexity: Low
Description

Define the formal contract for organic tasks in ce-ai under odd/tasks/<slug>.md. Rather than leaving organic tasks unformatted or vague, ce-ai standardizes the minimal ODD template that Gentle AI advocates:

--- feature: csv-export-filter mode: organic created_at: 2026-09-16 status: active --- # Problem Statement Users cannot export filtered search results to CSV from the analytics table, forcing manual copy-pasting. # Guardrails & Invariants - MUST NOT add external heavy dependencies. - MUST stream CSV generation to avoid OOM on >10k rows. - MUST preserve existing JSON export API without breaking changes. # Definition of Done (DoD) - [ ] Unit test proving CSV formatting handles escaped commas and quotes. - [ ] Integration test verifying streaming output response headers. - [ ] cargo clippy and cargo test pass with 0 errors.
Basis & Rationale

external: Gentle AI ODD Specification: Replaces the 5-file OpenSpec requirement for tactical tasks with a single, highly legible markdown file. It gives the AI agent strict boundaries (Guardrails) and an undeniable finish line (DoD) without requiring 200 lines of speculative architectural prose.

Idea 4: Dual-Track Gate Engine with LOC Ceilings in src/commands/gate.rs
Axis 4 Confidence: 90% Complexity: Med
Description

Update src/commands/gate.rs (the observe-only gate evaluator) to formally recognize ExecutionMode::Organic. Currently, gate.rs contains hardcoded exemptions:

// Existing in src/commands/gate.rs:351-367 if tier == AdoptionTier::Minimal { return (GateDecision::Pass, None, Vec::new(), "project tier minimal permits writes without full OpenSpec contract".to_string()); } if clean.starts_with("ce-debug") { ... return (GateDecision::Pass, ...); }

We generalize this into a principled Dual-Track Gate Policy:

  • Organic Pass Rule: When ExecutionMode::Organic is active (e.g. branch is fix/ or single-file ODD brief exists), file writes are permitted without demanding an OpenSpec directory.
  • Safety LOC Ceiling: If git diff exceeds 200 LOC in Organic mode, the gate emits an advisory warning: "Notice: Organic task diff (+245 LOC) exceeds the tactical ceiling (~200 LOC). Consider running 'ce-ai workflow graduate' to capture living contracts in OpenSpec."
Basis & Rationale

direct: CONTRIBUTING.md §4 & src/commands/gate.rs: CONTRIBUTING.md already establishes a target of ~200 LOC per atomic work unit. Hooking this threshold into the gate prevents ODD from degenerating into unmonitored monolithic commits while keeping small chores completely unblocked.

Idea 5: Unified Engram Task Mirror Protocol
Axis 5 Confidence: 95% Complexity: Low
Description

Ensure that task state persistence across sessions is unified under Engram persistent memory using a canonical topic key: tasks/<feature-slug>. Whether the active task is an organic brief (odd/tasks/<feature>.md) or a formal OpenSpec task list (openspec/changes/<feature>/tasks.md), both serialize their status and checklist into Engram under the same key.

When any agent boots in Claude Code, Codex, or Antigravity, calling mem_context immediately restores the current task, uncompleted checklist items, and active guardrails, completely insulating the developer from context window truncation or harness switches.

Basis & Rationale

direct: RULE[user_global] & Engram Protocol: Engram is the cross-session persistence backbone. By sharing the exact topic key format, context re-hydration works identically across both modes.

4. Rejection Summary (What Was Cut & Why)

Proposed Concept Rejection Category Specific Rationale
LLM Runtime Router Agent Latency / Cost / Non-determinism Invoking an LLM to classify user intent on every prompt introduces 2–4s latency and recurring token costs. Deterministic heuristics (git branch, active changes, explicit flags) achieve >98% accuracy instantaneously.
Deprecating OpenSpec in Favor of Pure ODD Governance & Architectural Collapse Gentle AI's avoidance of SDD works for smaller tools, but ce-ai requires living contracts (openspec/specs/) for release integrity, cross-harness drift detection, and compliance (ISO/NIST). OpenSpec must be preserved for architectural features.
Unrestricted ODD without LOC Ceilings Risk of Monolithic Drift Allowing ODD to be used without a LOC ceiling (>200 LOC) allows agents to perform massive 1,000-line refactors without architecture review, defeating ce-ai's quality invariants.
Separate Git Worktrees per Mode Workflow Friction Forcing ODD into separate git worktrees fragments the local repo. Mode should be a lightweight behavioral attribute of the current session, not a separate disk checkout.

5. Recommended Architecture & Delivery Matrix

Dimension ODD Fast-Path (Organic Mode) Compound Flywheel (OpenSpec Mode)
Target Scope Bugfixes, chores, spikes, small tweaks (< 200 LOC) New features, breaking changes, architecture refactors
Trigger Signals fix/*, chore/* branches, ce-debug, or explicit --odd feat/* branches, openspec/changes/ dir, or explicit --compound
Specification Shape Single-file brief: Problem + Guardrails + DoD (odd/tasks/) 5-stage living package: Proposal, Exploration, Design, Spec, Tasks
Gate Enforcement Write permitted without OpenSpec; warning if > 200 LOC Strict gate: OpenSpec required before work units commence
Graduation Path ce-ai workflow graduate <feature> promotes ODD brief into OpenSpec package