Created ADR-042 (Resource Type Inheritance) defining single-inheritance `inherits` field on resource type definitions with field resolution, collection merging, handler inheritance, polymorphic tool binding, auto-discovery, and DAG query matching. Max depth 5, single inheritance. Created ADR-043 (Devcontainer Integration) defining devcontainer-instance as a subtype of container-instance with lazy activation lifecycle, devcontainer.json parsing, three container-project association patterns (auto-detect, explicit mount, clone-into), and execution environment routing with a 6-level precedence chain. Specification updates across 20+ sections: - Glossary: Resource Type Inheritance, Devcontainer, Execution Environment - Resource type YAML schema: `inherits` field with structure reference - Handler, sandbox strategy, and coherence tables: devcontainer-instance - Auto-discovery: devcontainer detection subsection with WBS diagram - Tool capability metadata: structured environment subfields - Technology stack: devcontainer CLI row - Project model: execution environment subsection with YAML example - CLI agents resource add: --mount, --clone-into flags + 4 new examples - CLI agents plan use: --execution-environment, --execution-env-priority - CLI agents project context set: same execution environment flags - Command synopsis block: updated for all new flags - Execution environment routing section with precedence table + algorithm - Resource type YAML Example 6: Devcontainer Instance (inherited type) - End-to-end Example 16: Devcontainer-Driven Development - End-to-end Example 17: Explicit Container with Directory Mount - End-to-end Example 18: Container with Remote Repo Clone Also fixed ADR index: added missing ADR-036 through ADR-040 entries, updated next ADR number to 044. CONTRIBUTING.md fixes backported from sister project: - Fixed State label capitalization (State/In Progress -> State/In progress, State/In Review -> State/In review) to match label definitions. - Subtasks section: changed from optional to required, with exception clause for trivially simple issues. - Parent links: updated to use Forgejo dependency system instead of textual references in issue descriptions. - Fixed nox session flag typos: nox -e -> nox -s (7 occurrences). - Replaced "Epics and Legendaries" section with comprehensive "Ticket Type Hierarchy" defining the three-tier hierarchy (Issue -> Epic -> Legendary) with formal criteria tables, cross-cutting rules for hierarchy enforcement, completion semantics, promotion/demotion, and milestone relationship rules. - Fixed broken internal links referencing old "Epics and Legendaries" anchor to use "Ticket Type Hierarchy" (3 occurrences). - Traceability example: replaced project-specific code reference with generic example. - Removed stray horizontal rule before Project-Specific Guidelines. ISSUES CLOSED: #491
14 KiB
Architecture Decision Records
This directory contains the Architecture Decision Records (ADRs) for CleverAgents. Each ADR captures a single significant architectural decision — the context that motivated it, the decision itself, its design implications, constraints, consequences, and how compliance is verified.
All ADRs derive their content from the CleverAgents Specification, which is the sole source of truth for the system's architecture and behavior.
ADR Format
Every ADR follows a consistent template with metadata, content, and governance sections:
Metadata
Presented as plain text fields at the top of each ADR, one per line:
| Field | Purpose |
|---|---|
| Status | Current state of the decision: Accepted, Proposed, Deprecated, or Superseded. |
| Date | Date the decision was accepted or last revised. |
| Supersedes | Reference to a prior ADR this one replaces, or None. |
| Author(s) | Contributors who authored or substantially edited the ADR text. |
| Approver(s) | Person(s) who verified the voting record and signed off on acceptance. |
Content Sections
Context
Describes the problem, situation, or forces that motivated the decision. This section explains why the ADR exists — what technical challenge, scaling concern, or design tension required an explicit architectural choice. It should give a reader who is unfamiliar with the project enough background to understand the decision without reading the full specification.
Decision
States the architectural choice that was made, written in declarative form (e.g., "CleverAgents adopts X"). This is the core commitment of the ADR — a concise, authoritative statement of what was decided. Implementation details belong in Design; this section focuses on the what, not the how.
Design
Provides the structural details that realize the decision: components, interfaces, data models, patterns, protocols, and interaction flows. This is typically the longest section of an ADR and may include sub-headings, diagrams, and code-level specifics. The Design section should give an implementer enough information to build the feature correctly without inventing architectural choices on their own.
Constraints
Lists the explicit rules and restrictions the decision imposes on the codebase. Constraints are enforceable invariants — statements like "module X must never import from module Y" or "all domain models must use Pydantic strict mode." They serve as guardrails that CI checks, linters, and code review can verify mechanically.
Consequences
Documents the outcomes of the decision, organized into three categories: Positive (benefits gained), Negative (trade-offs accepted), and Risks (potential future problems). Honest accounting of trade-offs is essential — an ADR that lists only positive consequences is incomplete. This section helps future readers understand whether the decision's assumptions still hold.
Alternatives Considered
Describes other options that were evaluated and explains why they were not chosen. Each alternative should include enough detail for a reader to understand the rejected approach and the reasoning behind the rejection. When the decision is directly prescribed by the specification with no practical alternatives, this section may read "None — specification-driven requirement."
Compliance
Specifies how adherence to the decision is verified in practice. This includes CI checks, linting rules, architecture tests, code review expectations, and any other enforcement mechanisms. A decision without a compliance strategy is aspirational rather than architectural — this section ensures every ADR is backed by concrete verification.
Related ADRs
A table of cross-references to other ADRs that interact with this decision. Each entry includes a link to the related ADR, its title, and a brief description of the relationship (e.g., "Provides the persistence layer used by this system" or "Defines the validation strategy referenced in the Constraints section"). Cross-references are maintained in both directions — when a new ADR references an existing one, the existing ADR's Related ADRs table is updated as well. This is always the second-to-last section.
Acceptance
Records the governance process for the ADR. Contains three sub-tables — Votes For, Votes Against, and Abstentions — each listing the voter's identity, an optional comment, and a total count. The Acceptance section is populated during the review process: votes are cast, recorded, and once the outcome is determined the ADR's status is updated to Accepted (or remains Proposed if rejected). This is always the last section of every ADR.
ADR Inventory
Tier 1 — Foundational
These ADRs establish the structural and technological foundation upon which all other decisions rest.
| ADR | Title | Summary |
|---|---|---|
| ADR-001 | Layered Architecture | Four-layer architecture with hexagonal ports/adapters, CQRS, and event-driven patterns. |
| ADR-002 | Namespace System | Universal [[server:]namespace/]name naming for all entities. |
| ADR-003 | Dependency Injection | dependency-injector DeclarativeContainer for all service wiring. |
| ADR-004 | Data Validation | Pydantic V2 strict mode for all domain models and configuration objects. |
| ADR-005 | Technical Stack | Python 3.13, Typer, LangChain/LangGraph, SQLAlchemy, and supporting libraries. |
Tier 2 — Core Domain
These ADRs define the domain model — the entities, lifecycles, and relationships that constitute the system's core logic.
| ADR | Title | Summary |
|---|---|---|
| ADR-006 | Plan Lifecycle | Action, Strategize, Execute, Apply phases with states and reversion rules. |
| ADR-007 | Decision Tree and Correction | Eleven decision types, persistent decision graph, unified correction mechanism. |
| ADR-008 | Resource System | Typed resources with DAG relationships, registry, and sandbox strategies. |
| ADR-009 | Project Model | Named scope linking resources, context configuration, and invariants. |
| ADR-010 | Actor and Agent Architecture | Actor-as-graph via LangGraph, hierarchical composition, role-based specialization. |
| ADR-011 | Tool System | Four-stage lifecycle, dual role, adapter layer, resource bindings. |
| ADR-012 | Skill System | Composable tool collections with hierarchical inclusion and flattening. |
| ADR-013 | Validation Abstraction | Tool subtype with structured pass/fail, attachment scoping, and gating semantics. |
| ADR-033 | Decision Recording Protocol | Tool-based record_decision mechanism, system vs. actor creation classification, context snapshot capture. |
| ADR-034 | Decision Tree Versioning and History | Dual structure (structural tree + influence DAG), implicit versioning via superseded_by, historical reconstruction. |
| ADR-035 | Decision Tree Rollback and Replay | Mid-Strategize replay, Execute-phase decision-aligned checkpoints, three rollback tiers, cross-plan cascading. |
Tier 3 — Infrastructure and Behavior
These ADRs govern cross-cutting behavioral systems and infrastructure concerns.
| ADR | Title | Summary |
|---|---|---|
| ADR-014 | Context Management (ACMS) | Unified Knowledge Ontology, Context Retrieval Pipeline, 10-component assembly pipeline. |
| ADR-015 | Sandbox and Checkpoint | Five isolation strategies, lazy sandboxing, checkpoint/restore per tool. |
| ADR-016 | Invariant System | Four scopes with precedence, reconciliation actor, and child plan inheritance. |
| ADR-017 | Automation Profiles | Confidence thresholds controlling autonomy across eight built-in profiles. Composes a SafetyProfile sub-model (ADR-041). |
| ADR-018 | Semantic Error Prevention | Four prevention layers from decision-time validation to predictive guards. |
| ADR-041 | Safety Profile Extraction | Safety constraints extracted into a composed SafetyProfile sub-model within AutomationProfile. |
| ADR-019 | Storage and Persistence | SQLite/SQLAlchemy with repository pattern, Unit of Work, and Alembic migrations. |
| ADR-020 | Session Model | Conversation threads with orchestrator binding and session-scoped context. |
| ADR-036 | Resource DAG Operational Semantics | Ten operational purposes of the resource DAG with sandbox boundary algebra, checkpoint boundaries, and dependency ordering. |
| ADR-037 | Tool Reachability and Access Projection | Forward, inverse, and cross-equivalence reachability with AccessProjection protocol and read/write routing. |
| ADR-038 | Cross-Mechanism Sandbox Coordination | Coherence properties, write-then-sync protocol, conflict resolution, and lazy virtual node materialization. |
| ADR-042 | Resource Type Inheritance | Single-inheritance inherits field on resource type definitions with polymorphic tool binding, auto-discovery, and DAG queries. |
Tier 4 — Integration and Operations
These ADRs address external integrations, operational interfaces, and deployment concerns.
| ADR | Title | Summary |
|---|---|---|
| ADR-021 | CLI and Output Rendering | Typer-based agents <noun> <verb> pattern with six output formats. |
| ADR-022 | LangChain/LangGraph Integration | Provider-agnostic LLM abstraction with StateGraph orchestration. |
| ADR-023 | Server Mode | Client/server deployment with shared namespaces and remote execution. |
| ADR-024 | Configuration System | TOML global config with dot-path keys, YAML entity config, resolution chain. |
| ADR-025 | Observability and Logging | structlog JSON output with context binding, optional LangSmith tracing. |
| ADR-026 | Agent Client Protocol (ACP) | Versioned client-server contract for sessions, plans, registries, and event streaming. |
| ADR-027 | Language Server Protocol (LSP) Integration | Actor-attached language intelligence via LSP servers registered in the LSP Registry. |
| ADR-028 | Agent Skills Standard (AgentSkills.io) | SKILL.md-based progressive disclosure skills integrated as tool sources and actor graph nodes. |
| ADR-029 | Model Context Protocol (MCP) Adoption | MCP tool discovery, registry integration, skill composition, and actor-graph usage. |
| ADR-030 | Skill Abstraction Definition | Canonical definition of a skill as a composable collection of tools from four sources (MCP, Agent Skills, built-in, custom). |
| ADR-031 | Actor Abstraction Definition | Canonical definition of an actor as anything conversational — single LLM, composed graph, or hierarchical orchestrator. |
| ADR-032 | Jinja2 YAML Template Preprocessing | Two-phase YAML processing: sandboxed Jinja2 template rendering followed by environment variable interpolation with type coercion. |
| ADR-039 | Container and Execution Environment Resource Types | Seven engine-agnostic container resource types plus executable discovery for tool/LSP dependency resolution. |
| ADR-040 | LSP Resource Types | Three LSP resource types (lsp-server, lsp-workspace, lsp-document) for language intelligence integration. |
| ADR-043 | Devcontainer Integration and Container-Project Association | Auto-detected devcontainer-instance subtype, container-project association patterns, and execution environment routing with precedence. |
Creating a New ADR
- Assign the next sequential number (e.g.,
ADR-044). - Create a file named
ADR-0NN-<kebab-case-title>.mdin this directory. - Copy the template structure from any existing ADR.
- Fill in the metadata table with
Status: Proposed, the current date, author(s), and leave approver(s) blank. - Add the Related ADRs table with links, titles, and relationship descriptions.
- Leave the Acceptance section with empty voting tables — votes are recorded during the review process.
- Fill in all content sections (Context through Compliance). Every section is required — use "N/A" only if genuinely not applicable.
- Add the new ADR to the inventory table above and to the
navsection inmkdocs.yml. - Cross-reference related ADRs in both directions (update existing ADRs' Related ADRs tables).
- Once voting concludes and the ADR is accepted, update
StatustoAccepted, record all votes, and add the approver(s).