078112ba66
CI / push-validation (pull_request) Successful in 18s
CI / helm (pull_request) Successful in 24s
CI / build (pull_request) Successful in 33s
CI / quality (pull_request) Successful in 34s
CI / lint (pull_request) Successful in 46s
CI / typecheck (pull_request) Successful in 57s
CI / security (pull_request) Successful in 58s
CI / integration_tests (pull_request) Successful in 4m15s
CI / e2e_tests (pull_request) Successful in 4m21s
CI / unit_tests (pull_request) Successful in 5m42s
CI / docker (pull_request) Successful in 9s
CI / coverage (pull_request) Successful in 12m21s
CI / status-check (pull_request) Successful in 1s
- Add CHANGELOG.md entries for v3.0.0 and v3.1.0 - Create docs/cli/README.md with CLI command reference - Create docs/architecture/README.md with architecture overview - Create docs/configuration/README.md with YAML schema reference - Update CONTRIBUTORS.md with documentation automation entry
CleverAgents Architecture
CleverAgents uses a layered architecture for autonomous code modification. This document
provides a high-level overview. For detailed design decisions, see docs/adr/ (48 ADRs)
and docs/architecture.md.
Core Layers
Domain Layer
- Pydantic v2 domain models with
frozen=Truefor immutability. All models inherit fromcleveragents.domain.DomainBaseModelwhich provides sharedmodel_config. - SQLite persistence via SQLAlchemy ORM and Alembic migrations
(
alembic/versions/). Default database:~/.cleveragents/cleveragents.db. - Key entities:
Action,Resource,Project,Plan,Actor,Decision,ChangeSet,Session,Invariant,Skill,Tool. - Repository pattern: Each entity has a corresponding repository class (e.g.,
cleveragents.domain.ActionRepository) providing CRUD operations.
Actor Layer
- Actor YAML v3 schema (
version: "3",type: llm|tool|graph). Defined incleveragents.actor.config.ActorConfigSchema. - LangGraph StateGraph compilation:
cleveragents.actor.compiler.ActorCompilertranslates YAML actor definitions into executable LangGraphStateGraphinstances. - Subgraph resolution, cycle detection, entry/exit validation.
- Actor types:
llm— LLM-backed actor with model, system prompt, and tool bindings.tool— Pure tool executor without LLM.graph— Composite actor composed of sub-actors connected by edges.
- Actor registry (
cleveragents.actor.registry.ActorRegistry): Persists and resolves actors by namespace/name.
Execution Layer
- Actor-based LLM execution path:
cleveragents.plan.executor.PlanExecutororchestrates the Strategize → Execute → Apply lifecycle. - Git worktree sandbox (
cleveragents.sandbox.GitWorktreeSandbox): Isolated working directory usinggit worktree addso LLM-generated changes do not affect the original repository untilplan applyis called. - ChangeSet (
cleveragents.changeset.ChangeSet): Built from tool invocations (not parsed from LLM output) to ensure structural correctness. - MCP adapter (
cleveragents.mcp.MCPToolAdapter): External tool server connectivity via the Model Context Protocol.
ACMS Layer (Adaptive Context Management System)
- UKO (Universal Knowledge Ontology): Four-layer ontology hierarchy for
structured knowledge representation. Defined in
docs/ontology/uko.ttl. - CRP (Context Retrieval Pipeline): Six context strategies for assembling
relevant context for LLM execution. Documented in
docs/reference/crp.md. - Context tiers: Hot/warm/cold tier service (
cleveragents.acms.ContextTierService) with LRU eviction, staleness enforcement, and actor-scoped views. - Skeleton compressor (
cleveragents.acms.SkeletonCompressor): Reduces large codebases to structural skeletons for context budget management.
Plan Lifecycle
The plan lifecycle follows a state machine with four primary phases:
- Use (
agents plan use) — Create plan record, associate with action, initialize state machine. Defined incleveragents.cli.plan.use_plan. - Execute (
agents plan execute <plan_id>) — Invoke actor-based LLM path. Strategize phase builds decision tree; Execute phase produces ChangeSet via tool invocations. Defined incleveragents.cli.plan.execute_plan. - Diff (
agents plan diff <plan_id>) — Show pending changes in sandbox without modifying the target repository. Defined incleveragents.cli.plan.diff_plan. - Apply (
agents plan apply <plan_id>) — Merge sandbox branch into target repository viagit mergewith a structured commit. Defined incleveragents.cli.plan.apply_plan.
Validation Layer
- Validation runner (
cleveragents.validation.ValidationRunner): Executes required and informational validations. Required validations block Apply if they fail. - Fix-then-revalidate loop: Failed required validations trigger a correction cycle before re-running the validation.
- Invariant reconciliation (
cleveragents.invariant.InvariantReconciliationActor): Runs automatically at every plan phase transition; failures block the transition and emitINVARIANT_VIOLATEDevents.
Key Design Decisions
- Changes in sandbox do not affect original until Apply: The git worktree sandbox
provides complete isolation. See ADR-015 (
docs/adr/ADR-015-sandbox-and-checkpoint.md). - ChangeSet built from tool invocations: Structural correctness is guaranteed by
building ChangeSets from tool call results rather than parsing LLM text output.
See ADR-007 (
docs/adr/ADR-007-decision-tree-and-correction.md). - Pydantic v2 with
frozen=True: Domain models are immutable to prevent accidental mutation. See ADR-004 (docs/adr/ADR-004-data-validation.md). - Layered architecture: CLI → Service → Domain → Persistence separation of concerns.
See ADR-001 (
docs/adr/ADR-001-layered-architecture.md). - LangGraph for actor compilation: StateGraph provides deterministic execution flow
with cycle detection. See ADR-022 (
docs/adr/ADR-022-langchain-langgraph-integration.md).
Further Reading
- Architecture Decision Records:
docs/adr/(48 ADRs covering all major design choices) - Full architecture specification:
docs/architecture.md - Module guides:
docs/modules/ - API reference:
docs/api/