Implemented plan-level and project-level locking with configurable timeouts.
Added locks table via Alembic migration storing owner_id, resource_type,
resource_id, acquired_at, and expires_at. Locks enforced in
PlanLifecycleService transitions. Support for re-entrant acquisition,
lock renewal, graceful shutdown release, and startup cleanup of expired
locks. Added diagnostics check for stale lock reporting.
ISSUES CLOSED: #327
Align actor add/remove/list/show commands to YAML-first configs,
namespaced names, and --format json|yaml|plain output support.
Changes:
- Add --format option to list, show, add, and update commands
- Add --update flag to add command for updating existing actors
- Add _actor_spec_dict helper for structured output serialization
- Update _print_actor to support format_output rendering
- Add Behave feature tests for CLI format scenarios (11 scenarios)
- Add Robot Framework integration test for show output fields
- Add ASV benchmark for actor CLI parsing overhead
- Add CLI reference documentation for actor commands
ISSUES CLOSED: #288
The step_register_skills_table step called add_skill in a loop but only
committed once at the end. Because SkillRepository.create() obtains a
new session per call and only flushes (never commits), the intermediate
sessions could be garbage-collected before the final commit, rolling
back their transactions on the shared SQLite :memory: connection. Moving
_commit_pending inside the loop ensures each skill is durably committed
before the next session is created.
ISSUES CLOSED: #418
Add extended CLI flags and output rendering for plan and action
commands in the v3 plan lifecycle.
Plan use command:
- --automation-profile flag validates against BUILTIN_PROFILES and
persists to plan metadata with PLAN provenance
- --invariant flag (repeatable) passes PlanInvariant objects with
InvariantSource.PLAN to PlanLifecycleService.use_action()
- --strategy-actor, --execution-actor, --estimation-actor, and
--invariant-actor flags validate namespace/name format via
validate_namespaced_actor() before setting on the plan
Plan status/list output:
- Profile and Invariants columns added to plan status summary table
- Profile and Invariants columns added to lifecycle-list table
- _plan_spec_dict includes estimation_actor, invariant_actor, and
invariants fields in all output formats (json, yaml, plain, table)
- _print_lifecycle_plan rich panel displays invariants with source
provenance tags
Action show output:
- _print_action displays estimation_actor, invariant_actor,
invariants list, inputs_schema, and automation_profile when present
- _action_spec_dict conditionally includes estimation_actor,
invariant_actor, and inputs_schema fields
Documentation:
- docs/reference/plan_cli.md documents all extended flags, actor
override validation, and usage examples
- docs/reference/action_cli.md documents extended output fields and
YAML configuration options
Tests:
- 29 Behave scenarios in features/cli_extensions.feature covering
automation profile, invariant flags, actor override validation,
plan status/list rendering, and action show extended fields
- 5 Robot Framework integration tests in robot/cli_extensions.robot
for plan use with invariants, profiles, and actor validation
- 6 ASV benchmark suites in benchmarks/cli_extensions_bench.py
measuring parsing overhead for all new flags and rendering paths
ISSUES CLOSED: #325
Each behave-parallel worker previously resolved to the same file-based
SQLite database (cleveragents.db or .cleveragents/db.sqlite) because
before_scenario removed the CLEVERAGENTS_DATABASE_URL env var and the
fallback paths are shared across processes. Under parallel execution
this caused intermittent 'database is locked' and duplicate-project
errors—most visibly in the coverage_report nox session.
Replace the env-var removal in before_scenario with unique temp database
paths via tempfile.mktemp(), giving every scenario its own isolated
database file. Temp files are cleaned up in after_scenario.
Also fix cli_streaming_steps.py where a Background + duplicate Given
sequence triggered a duplicate project name collision, and update
coverage_boost_steps.py so Settings-default assertions explicitly clear
the env vars before testing pydantic defaults.
Reverts the StaticPool fix (68bc068) as it is no longer needed on
develop-hamza-2. Restores the original SingletonThreadPool default
for sqlite:///:memory: engine creation.
The default SingletonThreadPool for sqlite:///:memory: can
non-deterministically lose flushed data when multiple sessions are
created without closing (as in the bulk-register table step).
Under CI with coverage --parallel-mode and behave-parallel --processes 32,
this caused list_all() to return 2 skills instead of 3.
StaticPool guarantees all sessions share the exact same DBAPI connection,
which is the SQLAlchemy-recommended pattern for :memory: test databases.
- extract BaseResourceHandler to eliminate ~90% duplication between
GitCheckoutHandler and FsDirectoryHandler
- raise RuntimeError when sandbox.context is None instead of silent
empty string fallback
- add threading.Lock to resolver handler cache for thread safety
- type resource_lookup/type_lookup as Callable instead of Any
- log original HandlerResolutionError at DEBUG before fallback
- use behave.runner.Context in step definitions per repo convention
- add with_superseded_by() helper for frozen model mutation
- document frozen model + superseded_by interaction in docstring
- clarify sequence_number uniqueness is a persistence concern
- add scenario for invalid corrects_decision_id ULID validation
- add scenario for with_superseded_by copy behavior
- type step helper dict as dict[str, Any]
Adds CorrectionRequest, CorrectionResult, CorrectionMode,
CorrectionPatch, CorrectionDryRunReport, CorrectionNotFoundError,
and CorrectionConflictError domain models.
Implements CorrectionService with BFS-based revert (marks decisions
as rolled back and restores via inverse changes) and append mode
(spawns a child correction plan). Includes request_correction()
with dry-run support and dispatch_correction() convenience method.
33 Behave scenarios, 8 Robot smoke tests, ASV benchmark suite,
and reference documentation.
Ref: Day-14 Rebaseline – M4.2 Decision-correction flows [Jeff]