Refs: #408
37 KiB
Implementation Notes
This document is the chronological record of decisions, discoveries, bugfixes, and design notes made during the development of CleverAgents. Each entry is timestamped and attributed to the developer who performed the work. These notes were captured in real time as the implementation progressed and are preserved here as the authoritative development history.
Phase 0: Discovery and Requirements Elaboration
- 2025-11-01: Implemented CLI inventory extraction tools, server endpoint extraction, data contract extraction, shell asset extraction.
- 2025-11-02: Implemented environment variable extraction and implicit behavior extraction tools.
- 2025-11-04: Completed workflow parity matrix generator and cloud features identification. All discovery artifacts stored in
docs/reference/.
Phase 1: Target Architecture Definition
- 2025-11-04: Completed all 10 Architecture Decision Records.
- 2025-11-05: Package structure created based on ADR-001. All ADRs documented in
docs/architecture/decisions/. - 2026-02-11: CLI syntax updated to spec-aligned forms (
action createvia--config,plan usepositional args,project createpositional). Legacy--name/--projectexamples retained in historical notes only. - 2026-02-11: Action config YAML baseline (spec-aligned):
name: local/example-action description: Example action for CLI flows strategy_actor: openai/gpt-4 execution_actor: openai/gpt-4 definition_of_done: "All steps complete"
Phase 2: Runtime Foundation and Ongoing Development
Legacy Phase 2 Work (Pre-Rebaseline)
2025-11-22: Week 12 Complete, Phase 2 Core Functionality DONE
- CLI Streaming Integration fully implemented.
- AutoDebugGraph Implementation complete.
- Mock provider enhancements with configurable failure modes.
- Infrastructure improvements (DebugAttempt model, repositories).
- 2026-02-11: CLI syntax refreshed to spec-aligned forms in current execution sections; legacy
--name/--projectexamples retained only in historical notes.
2025-12-05: LangSmith observability integration complete.
2025-12-08: Actor-first provider wiring complete.
2025-12-17: Stage 7 performance optimization complete.
2026-02-02: Stage 7.5 Actor Configuration System complete.
Plan and Action Domain Models (A1-A4)
2026-02-05: Stage A1 & A2 Complete - Plan and Action Domain Models
- Created
Planmodel withPlanPhaseenum (ACTION, STRATEGIZE, EXECUTE, APPLY, APPLIED),ActionStateenum (AVAILABLE, DRAFT, ARCHIVED),ProcessingStateenum (QUEUED, PROCESSING, ERRORED, COMPLETE, CANCELLED),NamespacedNamemodel withparse()andstr()methods,PlanIdentitymodel with ULID validation,can_transition()function for phase transition validation. - Created
Actionmodel withActionArgumentmodel withparse()method for CLI argument parsing, argument validation including type checking. - Added 52 Behave test scenarios across 2 feature files:
plan_model.feature(30 scenarios),action_model.feature(22 scenarios).
2026-02-05: Stage A3 Complete - PlanLifecycleService
- Created
PlanLifecycleServicewith full plan lifecycle management (Action -> Strategize -> Execute -> Apply -> Applied), Action CRUD operations, phase transition methods, state management, custom exceptions (InvalidPhaseTransitionError,ActionNotAvailableError,PlanNotReadyError). - Added python-ulid dependency for ULID generation.
- Total new test scenarios: 81 (30 + 22 + 29).
2026-02-05: Stage A4 In Progress - Plan CLI Commands
- Created
action.pyCLI withaction create,action list,action show,action available,action archivecommands. - Extended
plan.pywith v3 lifecycle commands:plan use,plan execute,plan apply,plan status,plan list,plan cancel. - Total test scenarios: 96 (81 + 15).
Critical Architectural Decision
2026-02-06: CRITICAL ARCHITECTURAL DECISION - Tool-Based Resource Modification
- REPLACED: OutputParser/code fence parsing approach.
- WITH: Tool-based change tracking (modern approach used by Claude Code, Cursor, Aider).
- Key changes:
- LLMs call skills/tools directly (edit_file, write_file, delete_file, etc.).
- Skills operate on sandbox state directly.
- ChangeSet is built from skill invocation history, NOT by parsing LLM text output.
- Added built-in resource skills (now C4.file/C4.search/C4.git): file ops, dir ops, search, git ops.
- Added MCP skill adapter (now C7.mcp): connect to external MCP servers.
- Replaced C4 "Multi-File ChangeSet Generation" with "Tool-Based Change Tracking".
- Added SkillInvocationTracker and ToolCallRouter components.
- Rationale:
- No parsing ambiguity (is this code or explanation?).
- Each operation is explicit, typed, and trackable.
- Supports rollback (replay inverse of recorded changes).
- Resource-agnostic (works for files, databases, APIs, any resource type).
- Compatible with MCP standard for external tools.
Quality Automation Setup (Q0-Q2) [Brent]
2026-02-09: Task Q0.6b Complete - README.md Setup Instructions
- Updated README.md Quick Start: added
devextras topip install, addedscripts/setup-dev.shstep. - Updated README.md Developing section: fixed
oxttypo ->nox, added quality/security nox sessions, linked todocs/development/quality-automation.md.
2026-02-09: Ruff Cleanup in src/cleveragents/ - StrEnum Migration
- Fixed all 26 ruff findings (all UP042:
str, Enum->StrEnum) + 12 consequent F401 unusedEnumimports. - Migrated 26 enum classes across 15 files from
class Foo(str, Enum)toclass Foo(StrEnum). StrEnum(Python 3.11+) is the modern replacement; project targets Python 3.13.- Semantic difference:
str(StrEnum.MEMBER)returns the value (e.g.,"foo") rather than"ClassName.MEMBER"— this is the correct/intended behavior for config/JSON string enums. - Verified: no code uses
str()on enum members in the old format; all tests pass (304 scenarios, 0 failures).
2026-02-09: Task Q0.9 Complete - Ruff Lint Findings in features/
- Fixed all 200 ruff lint findings in
features/directory -> 0 findings. - Config-level suppressions (168 findings): Added
per-file-ignoresinpyproject.tomlfor Behave-specific patterns (F811 for redefinedstep_impl, E501 for long step decorator strings). - Manual fixes (31 findings across 18 files): SIM115, UP028, SIM117, RUF005, B904, RUF012, SIM105, B007, B018, F821, SIM102, I001.
2026-02-09: Task Q0.8 Complete - Bandit Security Findings Remediation
- Fixed all 16 pre-existing bandit findings (2 HIGH, 3 MEDIUM, 11 LOW) -> 0 findings.
- Security hardening (HIGH+MEDIUM): Replaced
jinja2.Environmentwithjinja2.sandbox.SandboxedEnvironment, added_validate_code_ast()helper for AST-based pre-validation, added_validate_lambda_ast()helper restrictingeval()to lambda-only expressions. - Code quality (LOW): Replaced 6
assertstatements with properif/raise, replacedtry/except/passwithcontextlib.suppress(Exception), added logging to silent exception handlers.
2026-02-09: Stages Q0, Q1, Q2 Complete - Full Quality Automation Setup
- Stage Q0 - Pre-commit Hooks: Created
.pre-commit-config.yamlwith 12 hooks across 5 categories (branch protection, general checks, Ruff, Pyright, Bandit, Vulture, Semgrep, Commitizen). - Discovery: CI platform is Forgejo (
.forgejo/), NOT GitHub. Stage Q1 must use Forgejo Actions. - Discovery: 37 source files have formatting issues, ~27 files have trailing whitespace - pre-existing debt.
- Discovery:
features/steps/actor_cli_steps.pyhas many F811 (redefined step_impl) violations - Behave pattern. - Discovery: Average code complexity is A (3.56) across 979 blocks - good baseline.
- Discovery: High complexity methods identified:
LegacyDataMigrator.migrate_project_dataE(37),ProviderRegistry._create_provider_llmC(20),ProviderRegistry.create_ai_providerC(18). - Stage Q1 - CI/CD Pipeline: Extended
.forgejo/workflows/ci.ymlwith security, quality, coverage jobs. Createdscripts/check-quality-gates.py. - Stage Q2 - Advanced Automation: Created nightly quality monitoring workflow, ADR compliance checker, PR template. New nox sessions:
pre_commit,security_scan,dead_code,complexity,adr_compliance.
2026-02-10: Task 10B.4 - Quality Metrics Baseline Established [Brent]
- Ran full quality suite via nox to establish current baseline:
- Unit Tests: 105 features, 1613 scenarios, 7555 steps - ALL PASS
- Lint (ruff): 0 findings
- Typecheck (pyright): 0 errors, 0 warnings
- Security (bandit): 0 findings
- Dead Code (vulture): 0 findings
- Complexity (radon): Average A (3.56), 981 blocks analyzed, no grade-F methods
- Coverage: 96% (9860 statements, 269 missing, 2852 branches, 213 branch-miss)
- Fixed pre-existing test failure: Rich table column wrapping at narrow terminal widths. Fixed by patching console width to 200 in test setup.
- Fixed missing dependency: added
langchain-anthropic>=0.2.0topyproject.toml.
2026-02-10: Task Q1.5 Complete - Branch Protection Rules Documentation [Brent]
- Created
docs/development/ci-cd.md(224 lines) documenting branch protection rules, review priority matrix, CI job dependency graph, quality gates summary.
Edge Case and Validation Tests [Brent]
2026-02-10: Task 10C.1 Complete - Edge Case Test Scenarios
- Created
features/edge_case_plan_scenarios.feature(26 scenarios, 141 steps) covering concurrent plan execution, resource conflict scenarios, validation failure chains, rollback edge cases.
2026-02-10: Task 10C.4 Complete - Validation Test Fixtures
- Created
features/validation_test_fixtures.feature(34 scenarios, 81 steps) covering AST security validation, lambda AST validation, Python content sanitization, project model validation, change list coercion, ActionArgument parsing. - Fixed step name collisions with existing step files.
- Fixed irrecoverable syntax scenario:
"def broken("is actually recoverable via docstring wrapping; replaced with null byte input which is truly irrecoverable.
CI/CD Pipeline Stabilization [Brent]
2026-02-12: Task Q0-min-ci In Progress - Nox-Based PR Validation Workflow
- Rewrote
.forgejo/workflows/ci.ymlto route ALL jobs through nox sessions instead of direct tool invocations. - Coverage boost 92%->97%: Wrote 108 new Behave scenarios covering 6 largest coverage gaps.
- Key discovery: Behave loads ALL step definition files globally; any
@given/@when/@thenpattern matching an existing one causesAmbiguousSteperrors.
2026-02-12: Bugfix - Integration Test Failure in Robot.Actor Configuration
- Root cause:
robot/ci_nox_validation.robotrannox --listduring integration tests. Whenpabotexecuted all Robot suites in parallel, thenox --liststdout leaked into the siblingrobot/actor_configuration.robotprocess, causingJSONDecodeError. - Fix: Added
slowtag to interfering test cases; replaced hardcoded venv paths withpython.
2026-02-12: Bugfix - CI security Job Failure (session name mismatch)
- Root cause: CI referenced
nox -s security_scanandnox -s dead_code, but the noxfile only had a session namedsecurity. - Fix: Renamed
securitytosecurity_scan, added standalonedead_codesession.
2026-02-12: Bugfix - CI unit_tests Failure: Rich Console Line-Wrapping
- Root cause: Rich's
Consolewraps output at 80 columns. On CI, temp directory paths exceed 80 chars, splitting filenames across lines. - Fix: Collapse Rich line-wraps via
clean_output.replace("\n", "")before assertions.
2026-02-12: Bugfix - CI integration_tests Failures (3 categories)
- Issue 1:
ModuleNotFoundError— hardcoded/apppath doesn't exist on CI. Fixed with${CURDIR}/..relative paths. - Issue 2:
--load-contexthelp text assertion failures — Rich output goes to stderr when no TTY. Fixed withstderr=STDOUTmerge. - Issue 3:
FileNotFoundError: robot— pabot subprocess spawning exhausts container resources. Restored--exclude discoveryflag.
2026-02-13: Bugfix - CI security Job Failure (missing build/ directory)
- Root cause:
build/directory does not exist in fresh CI checkout. Bandit cannot create intermediate directories. - Fix: Added
os.makedirs("build", exist_ok=True)before bandit invocation.
2026-02-13: Bugfix - CI integration_tests Failures (3 categories)
- Issue 1:
FileNotFoundError: robotafter ~17 suites — container resource exhaustion. Capped pabot parallelism tomin(default, 2), explicitly prepend venvbin/to PATH. - Issue 2: Rich ANSI escape codes split
--load-contextstring. Addedenv:NO_COLOR=1. - Issue 3:
initial_next_command_test.robotexit code 3 — missingOPENAI_API_KEY. Tagged asslow.
2026-02-13: Bugfix - CI integration_tests Failures Round 2 (pabot resource exhaustion + ANSI codes)
robotis findable at session start yet pabot still fails after ~24 suites even with--processes 2.- Root cause confirmed:
FileNotFoundErrorfromsubprocess.Popenon Linux occurs when the system cannotexecve()due to exhausted PIDs or file descriptors, not because the binary is missing. - Fix: Replaced
pabotwithrobot(sequential execution). CI values reliability over speed. NO_COLOR=1insufficient — Rich still embeds non-color ANSI sequences (bold, reset). Addedenv:TERM=dumb.
2026-02-13: Bugfix - CI integration_tests Failures Round 3 (venv PATH, Resource paths, hanging tests)
- Issue 1:
python -m cleveragentsuses system Python — venv PATH line was accidentally removed. Restored. - Issue 2: Robot
Resourcefile resolution fails on CI — bare relative references. Converted all to${CURDIR}/absolute paths across 30 robot files. - Issue 3:
rxpy_route_validation.robottests hang — missingtimeoutparameters onRun Processcalls. Addedtimeout=30sto all 9 calls.
2026-02-13: Bugfix - CI integration_tests Failures Round 4 (duplicate Settings blocks, venv Python injection, CI debug)
- Issue 1: Duplicate
*** Settings ***blocks in 14 robot files created by sed-based conversion. Merged into single blocks. - Issue 2: Bare
pythoninRun Processcalls resolves to system Python on CI. Noxfile now passes--variable PYTHON:<venv-python-path>torobot. All 14 files updated to use${PYTHON}. - Issue 3: Hardcoded
/app/srcpath insystem_prompt_template_rendering.robot. Removed (venv Python already has package installed).
2026-02-13: Bugfix - CI integration_tests Failures Round 5 (guard cleanup when OpenAI key missing)
- Root cause:
robot/scientific_paper_basic.robotsuite setup skips on missingOPENAI_API_KEY, leaving${CONTEXT_DIR}empty. Teardown'sRemove Directory ${CONTEXT_DIR} recursive=Trueresolves to CWD, deleting the repo root (including.noxvenv androbot/*.resourcefiles), causing all downstream suites to fail. - Fix: Initialize
${CONTEXT_DIR}to${TEMPDIR}/paper_basic_contextsand guard cleanup with empty check.
2026-02-13: Enhancement - Restore parallel Robot runs + silence discovery resource warning
- Reintroduced
pabotwith conservative parallelism (max 2 processes) now that teardown bug is fixed. - Added
robot/discovery_common.resourcestub to silence non-fatal import warning.
Coverage and Security Enforcement [Brent]
2026-02-13: Task Q0-min-coverage In Progress - Coverage Threshold Enforcement
- Enhanced
coverage_reportnox session:COVERAGE_THRESHOLD = 97constant, generates HTML/XML/JSON reports before checking threshold, emits CI-parseable summary line. - Created
docs/development/testing.md(180+ lines): full testing guide covering unit (Behave), integration (Robot), benchmarks (ASV), and coverage. - Created
features/coverage_threshold_enforcement.feature(11 scenarios). - Verification: 2235 unit scenarios passed, 211 integration tests passed, 97.5% coverage.
2026-02-13: Task Q0-adv-security In Progress - Align Security Scans with Nox
- Added Semgrep as Step 3 in
security_scansession (between Bandit and Vulture). - Changed semgrep hook from wrapper script to direct invocation.
- Updated quality-automation docs with revised thresholds (85->97%).
Plan Model Alignment [Luis]
2026-02-13: Stage A2b.beta Complete - Plan Model Alignment
- Rewrote
plan.pyto align with spec:processing_statereplacesaction_state/state,project_linksreplacesproject_ids, addedaction_name,automation_profile,invariants, actor fields, subplan hierarchy. - Rebased
feature/m1-plan-modelonto A2b.alpha commit. Resolved 30 merge conflicts. Key design decisions during merge:- Plan field name:
processing_state(per spec), NOTstate. - Invariant enum:
InvariantSource(our naming), NOTInvariantScope. - Action model: HEAD taken as-is (authoritative for action domain).
- No
action_idon Action domain model — usesnamespaced_nameonly. project_linksused everywhere (NOTproject_ids).
- Plan field name:
- Fixed 6 post-rebase test failures.
- Final results: 130 Behave features / 2246 scenarios / 9868 steps all pass, 206 Robot tests all pass,
plan.pycoverage 100%.
Persistence Layer (A5)
2026-02-09: Stage A5.3 + A5.4 Complete - v3 SQLAlchemy Models
- Created
LifecycleActionModel(table:actions_v3) andLifecyclePlanModel(table:lifecycle_plans) with full spec alignment. - Used
__allow_unmapped__ = Trueon both models forfrom __future__ import annotationscompatibility. - Legacy note: These v3 ORM models use
action_id/project_idsand draft-style fields; they are superseded by the A5 rebaseline.
2026-02-09: Stage A5.6 Complete - ActionRepository (Luis tasks A5.6a-A5.6j)
- Created
ActionRepositorywith session-factory pattern, 10 methods,@database_retryon all public methods. - All mutating methods flush (do NOT commit) — caller/UnitOfWork handles commit.
- Uses
Anytype hints for domain Action objects to avoid circular import issues.
Sandbox Infrastructure [Luis]
2026-02-09: Stage B3.1 + B3.2 + B3.5 + B3.6 + B3.7 + B3.8 Complete - Sandbox Infrastructure
- Created
src/cleveragents/infrastructure/sandbox/package with 6 modules:protocol.py,no_sandbox.py,factory.py,manager.py,merge.py,__init__.py. - Design decisions:
- Factory accepts raw strings rather than Resource objects (Resource model not yet implemented). This decouples the sandbox layer from the domain model.
SandboxStatus.assert_transition()provides a convenient guard that raisesSandboxStateErroron invalid transitions.NoSandbox.rollback()always raisesSandboxRollbackErrorrather than being a no-op, because silently swallowing rollback requests for unsandboxed resources would hide bugs.
2026-02-09: Stage A2.1 Already Complete
estimation_actorfield already present in action model.review_actorfield already present. Also hasapply_actor(bonus field from earlier work).safety_profileremains DEFERRED to post-30 per plan.
Security Hardening (SEC1) [Luis]
2026-02-09: Stage SEC1 Complete - Remove eval() Vulnerability
- Audit results (7 matches in
src/cleveragents/): 2 real vulnerabilities, 4 false positives. - Fixes applied:
SimpleToolAgent— added named operation registry (_SAFE_OPERATIONS), legacycodeblocks fully rejected.ReactiveStreamRouter— added named transform registry, legacyfnstring expressions that are not in the registry fully rejected. Noeval()orexec()calls remain.
2026-02-10: Stage SEC1.5 Complete - Security BDD tests
- Created
features/security_eval.featurewith 8 scenarios covering code injection rejection, malicious transform rejection, valid config acceptance, custom registered operations.
Subplan Model [Luis]
2026-02-09: Stage E1 Complete - Subplan Model (Luis tasks E1.1-E1.5)
- Added
ExecutionMode,SubplanMergeStrategyenums,SubplanConfig,SubplanStatus,SubplanAttemptmodels,SubplanFailureHandlerclass. - Renamed from
MergeStrategytoSubplanMergeStrategyto avoid collision with infrastructure-levelMergeStrategyprotocol. - Used Pydantic BaseModel instead of dataclass (per ADR-004) for
SubplanAttemptandSubplanStatus.
Automation Levels [Luis]
2026-02-09: Stage A6 Complete - Automation Levels Foundation
- Added
AutomationLevelenum (MANUAL, REVIEW_BEFORE_APPLY, FULL_AUTOMATION). - Updated
PlanLifecycleServicewithshould_auto_progress(),auto_progress(),pause_plan(),resume_plan(),set_plan_automation_level(). complete_strategize()andcomplete_execute()now callauto_progress()automatically.
2026-02-10: Stage A6.5 Complete - Automation Levels BDD Tests
- Created
features/automation_levels.featurewith 24 Behave scenarios. - Discovery: pydantic-settings
BaseSettingsdoes not accept constructor keyword overrides for fields withvalidation_alias; must set attribute after construction.
Action YAML Schema [Aditya]
2026-02-13: Stage A2b.gamma Complete - Action YAML Schema + Examples + Loader
- Created
docs/schema/action.schema.yaml, 5 example action YAMLs,ActionConfigSchemaPydantic model withfrom_yaml()/from_yaml_file()factory methods, camelCase->snake_case key normalization,${ENV_VAR}interpolation, invariant normalization. - 31 Behave scenarios, 6 Robot smoke tests, 3 ASV benchmark suites. Coverage: 98%.
Tool and Skill Domain Models [Jeff]
2026-02-13: Stage C0.domain Complete - Tool and Validation Domain Models
- Created
tool.py(624 lines) with 6 StrEnums, 5 Pydantic models, full validators, factory methods. - Key decision: YAML loader implemented as
from_config()class methods (matches action.py pattern) rather than separate module. - Key decision:
ValidationextendsToolvia Pydantic model inheritance. - Key decision:
wrapsfield sets source towrappedimplicitly;transformrequired whenwrapsis set.
2026-02-13: Stage C0.skill.domain Complete - Skill Domain Model and Resolver
- Created
skill.py(475 lines) with 9 Pydantic models.SkillResolver.resolve()flattens includes, de-duplicates tools, rejects cycles with path traces. - Key decision:
SkillResolveris a standalone class (not a method on Skill) to support registry-backed resolution. - Key decision:
ResolvedToolEntryincludes source tracking for compiler diagnostics.
Resource Registry [Jeff]
2026-02-13: Stage B1.core.db Complete - Resource Registry Database Tables
- Created Alembic migration with 3 tables:
resource_types,resources,resource_edges. - Key design decision:
resource_typesPK is the namespaced name string (not ULID) since types are schema-level definitions with stable identifiers. - Key design decision:
link_typeenum ('contains', 'references', 'derived_from') covers hierarchical containment, cross-layer references, and derived virtual resources. - Key design decision:
auto_discoveredflag on both resources and edges tracks provenance for cleanup/refresh operations.
Session Domain [Jeff]
2026-02-13: Stage A7.domain Complete - Session Domain Models and Contracts
- Created
session.pywithMessageRoleenum,SessionMessage,SessionTokenUsage,Sessionmodels, error classes,SessionServiceABC. - Key decision: SessionService is an ABC (not Protocol) to enforce explicit inheritance and make contract violations visible at class definition time.
- Key decision: Messages are ordered by
sequence_number(not timestamp) to guarantee stable ordering across serialization boundaries.
CLI Spec Alignment [Jeff]
2026-02-14: Stage A4b.action Complete - Action CLI Spec Alignment
- Rewrote
action.py: config-onlyaction create --config <file>, removedaction availablecommand, added filters toaction list.
2026-02-14: Stage A4b.plan Complete - Plan CLI Flag Alignment
- Updated
plan.py:plan usenow accepts multiple PROJECT args,--automation-profile,--invariant(repeatable), actor overrides,--arg name=value. Alignedplan listfilters. Added--reasontoplan cancel.
2026-02-14: Stage A4b.outputs Complete - CLI Output Format Stabilization
- Created
formatting.py: sharedformat_output()helper withOutputFormatenum, JSON/YAML/plain/table/rich serializers. Handles datetime, Enum, nested structures.
Tool Runtime and Built-ins [Jeff]
2026-02-14: Stage C0.runtime Complete - Tool Runtime Core
- Created
runtime.py(ToolSpec, ToolResult, ToolError),registry.py(thread-safe ToolRegistry with RLock),runner.py(ToolRunner with 4-stage lifecycle: discover/activate/execute/deactivate). - New tool modules have 100% coverage.
2026-02-14: Stage C0.files Complete - Built-in File Tools
- Created
src/cleveragents/tool/builtins/package with 6 file tools (file-read/write/edit/delete/list/search), path traversal prevention, ChangeSetEntry/ChangeSet/ChangeSetCapture models. - 2026-02-14: Commit traceability sweep found no matching git log entries for skill schema/examples, skill CLI, provider actors, MCP config/adapter, actor compiler, or skill registry persistence; Section 2B traceability tasks remain open.
Tool and Session Persistence [Luis]
2026-02-14: Stage C1.tool.registry Complete - Tool Registry Persistence
- Created Alembic migration with 3 tables:
tools,tool_resource_bindings,validation_attachments. - Created
ToolRegistryRepository(5 methods),ValidationAttachmentRepository(4 methods),ToolRegistryService(8 methods). - Key decision:
ToolModel.to_domain()returns a dict (not a domain object) to decouple persistence from domain model until full integration is complete. - Key decision:
ToolRegistryRepository.delete()pre-checks for activeValidationAttachmentModelrows before allowing deletion. - Key decision: Validation attachments are resource-scoped with optional project_name and plan_id narrowing.
2026-02-15: Stage A7.persistence Complete - Session Persistence and Repositories
- Created Alembic migration with 2 tables:
sessions,session_messages. - Created
SessionRepository(5 methods),SessionMessageRepository(3 methods),PersistentSessionService(8 methods). - Key decision:
PersistentSessionServiceextends the domainSessionServiceABC. - Key decision:
append_message()auto-calculates sequence number and updates parent session'supdated_attimestamp. - Key decision:
import_session()validates schema version and SHA-256 checksum before persisting, then generates fresh ULIDs to avoid ID collisions. - Key decision:
update_token_usage()uses cumulative addition (+=) rather than replacement.
2026-02-15: Bugfix - Benchmark Unique Name Constraint [Luis]
- ASV benchmark suites that create tools/resources now use unique names per iteration to avoid UNIQUE constraint failures when ASV runs multiple iterations.
Skill and Actor YAML [Aditya]
2026-02-16: C0.skill.schema Complete - Skill YAML Schema + Examples + Loader
- Created
docs/schema/skill.schema.yaml, 5 example skill YAMLs,SkillConfigSchemaPydantic model withfrom_yaml()/from_yaml_file()factory methods, camelCase->snake_case normalization,${ENV_VAR}interpolation. - 36 Behave scenarios, 6 Robot smoke tests, 3 ASV benchmarks.
2026-02-17: Task C1.schema Complete - Actor YAML Schema Models
- Created
src/cleveragents/actor/schema.py(695 lines) with three actor types (LLM, TOOL, GRAPH), graph topology validation with cycle detection using DFS, type-specific field requirements, environment variable interpolation. - 5 example actor YAMLs, 50+ Behave scenarios, 11 Robot test cases, 8 ASV benchmark classes.
2026-02-17: C0.skill.cli Complete - Skill CLI Commands + Output Formatting
- Created
SkillServicewith dual-mode storage pattern (in-memory fallback, ready forUnitOfWorkpersistence). - Created
skill.pyTyper command group with 5 subcommands (skill add,remove,list,show,tools), all supporting 6 output formats. - Key decision: Module-level
_servicesingleton (not DI container) matches the pattern inaction.pyCLI;_reset_skill_service()enables test isolation.
Bugfixes and Merges
2026-02-17: Bugfix - Unit Test and Benchmark Failures After Master Merge [Brent]
- Unit test failure — Session mismatch in project repository steps. The
NamespacedProjectRepositorycreates a new SQLAlchemy session per method call. Fix: Changed session factory to always return the same session instance. - Benchmark failures — 5 distinct issues across 7 files: missing parameterized setup params, renamed
PlanPhase.APPLIED->APPLY, per-iteration plan creation, batch counters for unique IDs across ASV iterations, simplified action reuse.
2026-02-18: Task C1.examples Complete - Actor YAML Examples and Documentation
- Created
docs/reference/actors_examples.md(1098 lines) with pattern-based organization (Strategist, Executor, Reviewer, Tool-Only, Validation-Node, Graph, Hierarchical). - 25 Behave scenarios, 16 Robot test cases, 7 ASV benchmarks.
- Bug fixes: Missing
descriptionfields in test YAML strings,context_viewstep definition conflict, enhanced parallel execution detection.
Actor Loader [Aditya]
2026-02-19: Task C2.loader Complete - Actor Registry and Loader
- Created
src/cleveragents/actor/loader.py(277 lines) —ActorLoaderclass with thread-safe discovery, SHA-256 content-hash caching, and namespace management. - 23 Behave scenarios, 4 Robot test cases, 4 ASV benchmarks. Coverage: 98%.
- Key design decisions: SHA-256 content hashing (not mtime) for deterministic cache invalidation, single consolidated
ValidationErrorfor duplicates/errors, tool reference resolution at load time via optionalToolRegistry,local/default namespace applied during YAML parsing.
Plan Checklist Rebaseline
2026-02-13: Plan Update - Rebaseline A5 Persistence Checklist
- Rewrote A5 plan persistence checklist to replace legacy tasks with spec-aligned rebaseline migrations, ORM mappings, repositories, and persistence tests.
2026-02-13: Plan Update - A5 Ownership + Validation Attachments
- Reassigned A5.alpha migrations to Hamza to align DB/migration expertise.
- Rebased tool registry tasks to make validation attachments explicitly resource-scoped with required/informational mode.
2026-02-13: Plan Update - Consolidate Skills/Actors/MCP + B0 DB Ownership
- Retired duplicate C2/C3/C4 blocks; canonical tasks consolidated under C0.skill, C1/C2, C7.mcp, C8.providers.
- Reassigned B0.db resource/project migrations to Hamza.
2026-02-13: Plan Update - Tool Runtime Naming Consolidation
- Renamed M1 tool runtime block to C0 runtime core and M3 lifecycle block to C0.lifecycle to avoid duplicate naming.
2026-02-13: Plan Update - Spec Alignment Pass
- Updated A4b CLI to use
processing_stateterminology. - Corrected skill registry dependency references.
2026-02-13: Plan Update - C1 Numbering Disambiguation
- Renamed tool registry group to C1.tool to avoid collision with actor schema C1 group.
Change Tracking and Tool Router
2026-02-19: Stage C5.model COMMIT Complete - ChangeSet models and invocation tracker [Luis]
- Added
ToolInvocationPydantic model,InvocationTrackerProtocol andInMemoryInvocationTracker, per-change field validators,sorted_entries()andgrouped_by_resource()methods,normalize_change_path()utility. - 21 BDD scenarios, 5 integration smoke tests, 4 ASV benchmark suites.
2026-02-19: Stage C4.git COMMIT Complete - Add git operation skills [Luis]
- Created
git_tools.py: 4 read-only git tools (status, diff, log, blame) with safe environment variables, path traversal guards, and user-friendly error mapping for 5 common git failure patterns. - 16 BDD scenarios, 5 integration smoke tests, 3 ASV benchmark suites.
2026-02-19: Combined merge branch fix - Alembic merge migration [Luis]
- Created merge migration to resolve "Multiple head revisions" error between
a7_001_session_tablesandc0_001_skill_registryheads.
2026-02-19: Stage SEC1.eval COMMIT Complete - Remove eval-based config parsing [Luis]
- Created config security scanner detecting 15 disallowed patterns across YAML/TOML/generic configs. Reports file path + line number + severity for each violation.
- Extended security eval feature from 8 to 16 scenarios.
Execution Pipeline and Apply
2026-02-20: D0b.execute — Plan Execute via Actors (M1 Critical Blocker)
- Created
PlanExecutororchestrator withStrategizeStubActor(read-only, produces decisions) andExecuteStubActor(sandbox resources, routes tool calls). - Strategize phase is read-only. Execute phase uses sandbox resources and routes tool calls through ToolRunner.
- Phase guards prevent Execute when Plan is not in Strategize COMPLETE state.
- Streaming hooks emit interim status updates.
2026-02-20: D0b.apply Complete - Diff Review + Apply Integration [Jeff]
- Created
PlanApplyServicewithdiff(),artifacts(),persist_apply_summary(),handle_merge_failure(),guard_empty_changeset(). - Key decision: Used
error_detailsdict on Plan as general metadata store for apply summary fields until a dedicated metadata field lands. - Key decision: Service accepts optional
changeset_store— when None, builds stub SpecChangeSet from plan metadata only.
2026-02-20: C5.router Complete - Tool Call Router for LLM Providers [Jeff]
- Created
router.py(~890 lines) —ToolCallRoutertranslating between LLM provider tool call formats and internalToolRunner: provider format detection, normalization, deterministic ID generation, error classification, schema adaptation, batch routing, streaming support. - Key discovery:
ToolRunner.execute()catches handler exceptions internally and returnsToolResult(success=False)rather than raising, so streaming produces COMPLETE + failed result (not ERROR update) for tool failures. - Key discovery: Pyright strict mode requires all Pydantic model fields (even those with defaults via
Field(default=...)) to be explicitly passed in constructor calls. - Key discovery: Behave step name collision with existing
coverage_boost_extra_steps.py; renamed to avoidAmbiguousSteperror.
A9.service: Config Service with Multi-Level Resolution
- 2026-02-23 [Jeff]: Implemented
ConfigServiceinsrc/cleveragents/application/services/config_service.pywith:- Five-level resolution chain: CLI flag > env var > project-scoped > global config > default
- Typed config key registry with 24 entries across 6 sections:
core.*(7),plan.*(3),provider.*(4),sandbox.*(3),context.*(3),index.*(4) - TOML file management (
~/.cleveragents/config.toml) with auto-created parent directories viatomlkit ResolvedValuereturn type includes winning value, source level, and optional verbose chain- Env var interpolation following
CLEVERAGENTS_<SECTION>_<KEY>convention - Validation: unknown keys raise
ValueErrorwith sample of valid keys; type mismatches raiseTypeErrorwith actionable messages - Boolean coercion from string: true/false, 1/0, yes/no (case-insensitive)
- 2026-02-23 [Jeff]: Added
docs/reference/config_resolution.mddocumenting all 24 config keys with types, defaults, env var mappings, and precedence rules - 2026-02-23 [Jeff]: Added
features/config_resolution.featurewith 31 Behave scenarios covering every resolution level, env var overrides, type coercion, unknown key rejection, TOML roundtrips, and verbose chain output - 2026-02-23 [Jeff]: Added
robot/config_resolution.robotwith 8 Robot Framework end-to-end tests exercising default/global/env/CLI resolution, unknown key rejection, type coercion, and env var convention - 2026-02-23 [Jeff]: Added
benchmarks/config_resolution_bench.pywith 6 ASV benchmark suites for resolution performance at each level, bulk operations, and validation throughput - 2026-02-23 [Jeff]: Exported
ConfigService,ConfigEntry,ConfigLevel,ResolvedValuefromapplication.services.__init__; updated vulture whitelist for new public API
CLI1.alpha: Plan/Action CLI Extensions
- 2026-02-23 [Jeff]: Implemented CLI1.alpha. Key changes:
- Added
validate_namespaced_actor()toplan.pyfor strictnamespace/namevalidation on actor override flags (--strategy-actor,--execution-actor,--estimation-actor,--invariant-actor) - Updated
_plan_spec_dict()to includeestimation_actor,invariant_actor, andinvariantsfields in all output formats (json, yaml, plain, table) - Updated
_print_lifecycle_plan()rich panel to display invariants with source provenance tags - Updated
plan_statussummary table to include Profile and Invariants columns - Updated
lifecycle_list_planstable to include Profile and Invariants columns - Extended
action.py_action_spec_dict()to conditionally includeestimation_actor,invariant_actor, andinputs_schemafields - Extended
_print_action()rich panel to display estimation actor, invariant actor, invariants list, inputs_schema, and automation_profile --automation-profileflag onplan usevalidates againstBUILTIN_PROFILESand persists to plan metadata--invariantflags onplan useare passed through toPlanLifecycleService.use_action()asPlanInvariantobjects withInvariantSource.PLAN- Created
docs/reference/plan_cli.mdanddocs/reference/action_cli.mdreference documentation - Created
features/cli_extensions.featurewith 25 Behave scenarios covering all new functionality - Created
features/steps/cli_extensions_steps.pywith all step definitions - Created
robot/cli_extensions.robotwith 5 Robot Framework integration tests - Created
benchmarks/cli_extensions_bench.pywith 6 ASV benchmark suites
- Added