Commit Graph

1002 Commits

Author SHA1 Message Date
freemo 92f7feaa32 feat(cli): add auth and team commands
Implement auth login/logout/status and team list/use CLI commands
with stubbed responses when server is disabled. Includes token
storage via OS keyring with encrypted file fallback.

Key changes:
- Add agents auth login/logout/status commands
- Add agents team list/use commands
- Add TokenStore with keyring + encrypted file fallback
- Add auth_token, active_team, default_namespace settings
- Wire AuthClient and ServerClient stubs
- Add Behave BDD tests, Robot integration tests, ASV benchmarks

ISSUES CLOSED: #340
2026-03-10 06:13:59 +00:00
hamza.khyari fcdf80f342 Merge pull request 'feat(context): add repo indexing service' (#610) from feature/m4-context-indexing into master
Reviewed-on: cleveragents/cleveragents-core#610
Reviewed-by: Brent Edwards <brent.edwards@cleverthis.com>
2026-03-10 00:02:19 +00:00
hamza.khyari 7d958121ad feat(context): add repo indexing service
Add RepoIndexingService with incremental refresh, language detection,
SHA-256 hashing, and policy enforcement. Includes domain models,
DB persistence, DI wiring, Behave/Robot/ASV tests, and reference docs.

ISSUES CLOSED: #195
2026-03-09 23:55:33 +00:00
freemo 83f2f3a0a1 Docs: Daily update to timeline 2026-03-09 17:01:41 -04:00
freemo 0a8f054241 Docs: Fixed missing items from nav bar 2026-03-09 15:32:39 -04:00
freemo e8d777825b Docs: daily update to timeline 2026-03-09 15:29:48 -04:00
freemo a808c395f9 test(coverage): add Behave BDD tests to improve unit test coverage across 53 source modules
Add 53 new .feature files and corresponding step definition files targeting
uncovered lines identified in build/coverage.xml. Fix AmbiguousStep conflicts
in 7 pre-existing step files by disambiguating step text.

New tests cover: ACP clients/facade, actor CLI/config, application container,
ACMS service/strategies, async worker, automation profile CLI, autonomy
guardrail, bridge, change model, config CLI/service, context service,
cross-plan correction, database models, decision service, decomposition
clustering/service, discovery handler, langchain chat provider, langgraph
nodes, materializers, multi-project service, plan apply/CLI/lifecycle/model/
preflight/resume/service, PostgreSQL analyzer, project CLI/context CLI,
provider registry, reactive application/route, repositories, resolver handler,
resource registry service, resume model, retry patterns, sandbox protocol,
server CLI, skill CLI/service, skills registry, subplan execution/service,
system CLI, UKO loader, UoW, and YAML template engine.

Closes #645
2026-03-09 13:01:58 -04:00
freemo e5c0b10985 Docs: Fided some discrepencies in timeline 2026-03-09 10:43:38 -04:00
brent.edwards 16dc4ab18d fix(project): show created project after creation (#593)
## Summary

Fix `agents project show` not finding a project immediately after creation. Extends the `session.commit()` fix from #589 to also cover `update()` and `delete()` in `NamespacedProjectRepository`.

## Changes

**Production fix** (`src/cleveragents/infrastructure/database/repositories.py`):
- Add `session.commit()` to `create()`, `update()`, and `delete()` methods
- Add `finally: session.close()` guard to all three methods
- Update class docstring to reflect commit-per-method pattern

**Tests & benchmarks**:
- 3 Behave BDD regression scenarios (`features/project_show_after_create.feature`)
- Robot Framework integration smoke tests with "not found" assertion (`robot/project_show_after_create.robot`)
- ASV benchmarks for create-then-show round-trip (`benchmarks/project_show_after_create_bench.py`)

## Review feedback addressed

- **F1**: Removed unrelated em-dash CHANGELOG edits — wrote clean entry from scratch
- **F2**: Kept Suite Setup/Teardown (required for `${PYTHON}` variable); updated stale docs
- **F3**: Added "not found" string assertion to Robot negative test case
- **F4**: Removed redundant `Base.metadata.create_all()` from `_make_fresh_repo()` helper
- Updated all stale TDD "expected to fail" comments — this PR includes the fix

## Process

- Single squashed commit, rebased onto `master` (no merge commits)
- Prescribed commit message from issue #590 metadata

ISSUES CLOSED: #590

Reviewed-on: cleveragents/cleveragents-core#593
Reviewed-by: Rui Hu <rui.hu@cleverthis.com>
Co-authored-by: Brent E. Edwards <brent.edwards@cleverthis.com>
Co-committed-by: Brent E. Edwards <brent.edwards@cleverthis.com>
2026-03-09 07:56:38 +00:00
brent.edwards 26de6bb7de fix(project): persist project to database during creation (#591)
## Summary

Fix `agents project create` not persisting projects to the database. `NamespacedProjectRepository.create()` called `session.flush()` but never `session.commit()`, so projects were invisible to subsequent `agents project list` invocations that open a separate session.

## Changes

**Production fix** (`src/cleveragents/infrastructure/database/repositories.py`):
- Replace `session.flush()` with `session.commit()` in `NamespacedProjectRepository.create()`
- Add `finally: session.close()` guard for proper session lifecycle

**Tests & benchmarks**:
- 4 Behave BDD regression scenarios (`features/project_create_persist.feature`)
- Robot Framework integration smoke tests (`robot/project_create_persist.robot`)
- ASV benchmarks for create-then-list round-trip (`benchmarks/project_create_persist_bench.py`)

## Review feedback addressed

- **H3**: Added `finally: session.close()` to `create()` method
- **M1**: Removed redundant `session.flush()` before `session.commit()`
- **M2**: Updated stale TDD "expected to fail" comments — this PR includes the fix
- **M4**: Rewrote CHANGELOG entry to describe the fix, not just tests
- **F1**: Updated Robot documentation (Suite Setup/Teardown kept — needed for `${PYTHON}`)
- **F2**: Fixed bare assertion `"my-app"` to `"local/my-app"` in namespace scenario
- **F3**: Removed redundant `Base.metadata.create_all()` from `_make_fresh_repo()`

## Process

- Single squashed commit, rebased onto `master` (no merge commits)
- Prescribed commit message from issue #589 metadata

ISSUES CLOSED: #589

Reviewed-on: cleveragents/cleveragents-core#591
Reviewed-by: Rui Hu <rui.hu@cleverthis.com>
Co-authored-by: Brent E. Edwards <brent.edwards@cleverthis.com>
Co-committed-by: Brent E. Edwards <brent.edwards@cleverthis.com>
2026-03-09 06:59:15 +00:00
freemo 583e6b7ea2 feat(correcting-plans): implement Predictive Error Prevention (Layer 4) with Error Pattern Database
Implement spec-mandated Layer 4 Predictive Error Prevention system:

- ErrorPattern domain model with pattern text, historical failures,
  preventive checks, frequency tracking, and keyword-based matching.
- ErrorPatternRepository with in-memory CRUD + context-matching query.
- ErrorPatternService with record_failure(), match_patterns(), and
  get_statistics() methods.
- Wire into plan execution via plan_lifecycle_service pre-execution hook.
- Add error pattern statistics to CLI diagnostics output.

Behave BDD: 11 scenarios covering recording, matching, formatting, stats.
Robot Framework: 3 integration smoke tests.
ASV benchmarks: pattern matching performance.

ISSUES CLOSED: #571
2026-03-08 21:53:21 -04:00
freemo 61fc70d84b fix(cli): pass decision tree and influence edges to CorrectionService in plan correct handler (#639)
## Summary

Fixes the `plan correct` CLI handler which never passes the decision tree or influence edges to `CorrectionService`, producing single-node impact analysis regardless of the plan's actual decision structure.

Closes #606

## Root Cause

The `correct_decision()` handler in `plan.py` created a bare `CorrectionService()` and called `analyze_impact()` and `execute_correction()` without passing `decision_tree` or `influence_edges`. Both parameters default to `None` -> empty dicts, causing `_compute_affected_subtree()` BFS to return only the single target decision, ignoring all descendants and influence-DAG dependents.

## Changes

### Production Fix (`src/cleveragents/cli/commands/plan.py`)
- Resolve `DecisionService` via `get_container()` (following the pattern used by `plan explain` and `plan tree`)
- Build structural tree adjacency list from `decision_svc.list_decisions(plan_id)` using `parent_decision_id` relationships
- Fetch influence edges from `decision_svc.get_influence_edges(plan_id)`
- Pass both `decision_tree` and `influence_edges` to `svc.analyze_impact()` and `svc.execute_correction()`

### Existing Test Fixups
- Updated 4 step definition files that mock `CorrectionService` to also mock the new `DecisionService` resolution path

### New Tests
- **Behave BDD**: 3 scenarios verifying tree/edge forwarding (dry-run subtree, execution subtree, leaf node)
- **Robot Framework**: 3 integration smoke tests
- **ASV Benchmark**: Tree building and analyze_impact overhead benchmarks

## Quality Gates

- `nox -s lint` — PASSED
- `nox -s typecheck` — 0 errors
- `nox -s unit_tests` — 9,109 scenarios, 0 failures
- `nox -s coverage_report` — 97%

ISSUES CLOSED: #606

Reviewed-on: cleveragents/cleveragents-core#639
Co-authored-by: Jeffrey Phillips Freeman <jeffrey.freeman@cleverthis.com>
Co-committed-by: Jeffrey Phillips Freeman <jeffrey.freeman@cleverthis.com>
2026-03-08 23:28:05 +00:00
freemo a44082ab70 feat(guardrails): implement Plan Generation Pre-flight Guardrails (7 checks before execution)
Implement spec-mandated pre-flight guardrail checks that validate plan
readiness before entering the Strategize phase:

1. Action schema validation — verifies action exists and is well-formed.
2. Actor availability — confirms all 4 actor roles registered.
3. Skill/tool existence — transitively resolves all tools/skills.
4. Automation policy — verifies profile permits execution.
5. Rollback feasibility — ensures all tools checkpointable if required.
6. Resource accessibility — shallow connectivity check on linked resources.
7. Validation attachment resolution — pre-resolves all applicable validations.

PlanPreflightGuardrail service runs all 7 checks via run_all_checks().
On first failure, raises PreflightRejection with check name and message.
Wired into plan_lifecycle_service before Strategize phase.

Behave BDD: 18 scenarios covering all 7 checks (positive + negative).
Robot Framework: 3 integration smoke tests.
ASV benchmarks: pre-flight check execution time.

ISSUES CLOSED: #582
2026-03-08 22:31:40 +00:00
freemo 7b1020e735 feat(security): implement Prompt Injection Mitigation (5 mechanisms)
Implement spec-mandated prompt injection protections:

1. Input sanitization (PromptSanitizer.sanitize_user_input): escapes HTML
   entities, strips C0/C1 control characters, rejects 8 known injection
   patterns including instruction override, role assumption, ChatML tags,
   and boundary marker spoofing.

2. Prompt boundary markers (PromptSanitizer.wrap_user_content): wraps user
   content with [USER_CONTENT_START]/[USER_CONTENT_END] markers;
   augment_system_prompt() prepends boundary recognition instructions.

3. Output validation: existing schema_validator.py validates tool I/O
   against JSON Schema in ToolRuntime.execute() (verified, tested).

4. Tool capability restrictions: existing _enforce_capabilities() in
   lifecycle.py enforces read_only/writes/checkpointable/side_effects
   declarations (verified, tested).

5. Unsafe tool gating: existing _enforce_capabilities() blocks unsafe
   tools unless allow_unsafe_tools=true in automation profile (verified,
   tested).

Integrates sanitizer into session prompt construction, invariant text
processing, and action argument handling paths.

ISSUES CLOSED: #572
2026-03-08 22:19:40 +00:00
freemo d3cc7d30d7 fix(tool): persist tool registration to database after add
ToolRegistryRepository.create(), .update(), and .delete() called
session.flush() but never session.commit().  The CLI factory creates a
raw sessionmaker without a UnitOfWork wrapper, so the transaction was
never committed and SQLAlchemy performed an implicit rollback when the
session was garbage-collected.

The same bug existed in ValidationAttachmentRepository.attach() and
.detach().

Changes:
- Add session.commit() after session.flush() in all five mutating
  methods across ToolRegistryRepository and
  ValidationAttachmentRepository.
- Add finally: session.close() to guarantee session cleanup regardless
  of success or failure.
- Update class docstrings to reflect the new commit-on-write semantics.
- Add Behave BDD feature (tool_add_persist.feature) with scenarios for
  single-tool round-trip, multi-tool persistence, and duplicate
  rejection, using file-based SQLite to reproduce the cross-session
  issue.
- Add Robot Framework integration test (tool_add_persist.robot) with
  add-then-list and fresh-list-empty scenarios.
- Add ASV benchmark (tool_add_persist_bench.py) with
  track_list_after_add_count metric.

Key decisions:
- File-based SQLite (not in-memory) is used in tests because the bug
  only manifests when the session/engine is fully disposed between add
  and list, simulating separate CLI invocations.
- Step patterns are prefixed with "tool-persist" to avoid AmbiguousStep
  collisions with existing tool_registry_steps.py.
- The commit-in-repository approach was chosen over adding a UnitOfWork
  to the CLI factory because the CLI commands are simple CRUD operations
  that should auto-persist without requiring callers to remember to
  commit.

ISSUES CLOSED: #621
2026-03-08 22:11:49 +00:00
freemo 9704281bdd fix(skill): persist skill registration to database after add
Wire SkillService to use SkillRepository for database persistence,
fixing the bug where `agents skill add` stored skills only in an
in-memory OrderedDict that was lost when the CLI process exited.

Changes:
- SkillService now accepts optional skill_repo and session_factory
  parameters.  When provided, add_skill() persists to the database
  and the constructor pre-loads existing skills from DB rows.
- _get_skill_service() in the CLI now creates a DB-backed service
  following the same engine/sessionmaker/repository pattern used by
  the tool CLI (tool.py).
- _reset_skill_service() now installs a fresh in-memory SkillService
  (instead of setting None) to avoid DB side-effects during unit
  testing with parallel runners.
- remove_skill() also persists the deletion to the database.

Test coverage:
- Behave BDD: features/skill_add_persist.feature (4 scenarios)
- Robot Framework: robot/skill_add_persist.robot (3 smoke tests)
- ASV benchmark: benchmarks/skill_add_persist_bench.py

ISSUES CLOSED: #620
2026-03-08 02:57:44 +00:00
freemo a4ac36cd50 Docs: Daily update to timeline 2026-03-07 18:37:05 -05:00
freemo ca4621f9ec Docs: Updated CONTRIBUTING.md to reflect new TDD bug workflow 2026-03-07 16:50:41 -05:00
freemo 64cfdc782a fix(resource): call bootstrap_builtin_types during initialization
Add a call to bootstrap_builtin_types() in init_command() (project.py)
immediately after initialize_project() returns.  This seeds the built-in
resource types (fs-directory, git-checkout, etc.) into the database so
that "resource add" commands succeed without "Resource type not found"
errors.

The call is idempotent — invoking it multiple times will not create
duplicate types.

Also fix the TDD robot test (resource_type_bootstrap_git.robot) to
initialize a project before running "resource add", and fix a
pre-existing parallel test failure in plan_commands_new_coverage where
unittest.mock.patch could not reliably intercept PlanApplyService under
behave-parallel fork() workers.

ISSUES CLOSED: #523, #524
2026-03-07 19:36:09 +00:00
brent.edwards 709f65a6fd test(resource): add failing tests for built-in git-checkout type bootstrap
Add TDD-style failing tests that verify the built-in git-checkout resource
type is available after initialization. Tests assert the correct expected
behavior: after agents init, the git-checkout type should exist in the
registry and 'agents resource add git-checkout' should succeed.

Tests are expected to fail until bug #524 is fixed, because
bootstrap_builtin_types() is never called during initialization. The fix
branch should be based on this branch so the fix commit inherits these tests.

Files added:
- features/resource_type_bootstrap_git.feature (2 Behave scenarios)
- features/steps/resource_type_bootstrap_git_steps.py (step definitions)
- robot/resource_type_bootstrap_git.robot (Robot Framework smoke test)

ISSUES CLOSED: #553
2026-03-07 19:36:09 +00:00
freemo f6d27de1cd feat(extensibility): implement pluggable scope chain resolution
Introduce ComponentResolver with a deterministic 3-level scope chain
(plan > project > global) for resolving pluggable Protocol-based
components. The resolver supports caching, thread-safety, config.toml
extension loading, plan metadata loading, introspection APIs, and
security-restricted dynamic imports.

Includes 39 BDD scenarios, 9 Robot Framework integration tests,
ASV benchmarks, and vulture whitelist updates. 100% code coverage
on component_resolver.py; overall coverage at 97.07%.

ISSUES CLOSED: #552
2026-03-07 11:49:14 -05:00
freemo 620adfee01 fix(cli): add --yes flag to agents init for non-interactive setup
Added --yes/-y flag to the agents init CLI command to support non-interactive
initialization as specified in the documentation. When --yes is passed, all
interactive prompts are skipped and default values are applied. The command
produces the expected initialization summary output including data directory,
config file, database, and created directories.

The flag was added to both the top-level "agents init" command in main.py and
the "agents project init" subcommand in project.py. Both delegate to the shared
init_command() function which now accepts a yes parameter and produces
spec-aligned Rich panel output (Data Dir, Config, Database, Directories) with
the "Initialized (non-interactive)" status message when yes=True. When
yes=False (default), existing interactive behavior is preserved unchanged.

ISSUES CLOSED: #522
2026-03-07 15:07:17 +00:00
freemo 4221582368 feat(acms): implement pipeline Phase 3 components
Implemented the remaining ACMS pipeline components and advanced context
strategies:

Pipeline Phase 3:
- FragmentOrdererProtocol + RelevanceCoherenceOrderer: orders fragments
  by relevance while maintaining narrative coherence via UKO node prefix
  grouping.  Groups related fragments together, sorts groups by max
  relevance, and within groups orders by relevance desc / depth asc.
- PreambleGeneratorProtocol + ProvenancePreambleGenerator: generates
  provenance preamble with strategy contributions (fragment counts and
  token percentages), confidence indicators (avg/min/max), tier and
  depth distribution, UKO node coverage, and coverage gap detection.

Advanced Strategies:
- ArceStrategy (quality 0.95): adaptive recursive context expansion with
  iterative multi-backend refinement and configurable iteration limit
  (default 5) to prevent unbounded refinement.  Uses composite scoring
  (relevance + depth + diversity) with contextual boosting for fragments
  related to the current top-ranked anchor set.
- TemporalArchaeologyStrategy (quality 0.5): historical context retrieval
  from graph+cold backends.  Prioritises cold-tier fragments using a
  temporal scoring model (tier bonus + relevance + depth).
- PlanDecisionContextStrategy (quality 0.7): decision history retrieval
  from warm/cold backends.  Prioritises warm then cold tier fragments
  for correction and retry scenarios.

All strategies registered in strategy registry with correct quality scores
and backend requirements.  All components implement their respective
Protocol interfaces and can be injected into the ContextAssemblyPipeline
via constructor dependency injection.

Tests:
- 33 BDD scenarios in features/acms_pipeline_phase3.feature
- Robot Framework integration tests in robot/acms_pipeline_phase3.robot
- ASV performance benchmarks in benchmarks/acms_pipeline_phase3_bench.py

ISSUES CLOSED: #545
2026-03-07 14:53:18 +00:00
brent.edwards 272f907851 Merge pull request 'test(resource): add failing tests for built-in git-checkout type bootstrap (#524)' (#568) from feature/m3-test-resource-bootstrap-git into master
Reviewed-on: cleveragents/cleveragents-core#568
Reviewed-by: Hamza Khyari <hamza.khyari@cleverthis.com>
2026-03-07 02:52:50 +00:00
brent.edwards 775d72dcf4 Merge remote-tracking branch 'https-origin/master' into HEAD
# Conflicts:
#	CHANGELOG.md
#	behave.ini
2026-03-07 02:46:14 +00:00
brent.edwards 50228dfe4e fix(test): use in-memory SQLite for Robot git-checkout resource add test
The "Resource Add Git Checkout Should Not Fail With Type Not Found"
Robot test was calling the CLI process directly, which hits the real
database file that does not exist in CI — causing
sqlite3.OperationalError.  Rewrite the test to use an in-memory
SQLite database with register_resource(), matching the pattern used
by the fs-directory Robot tests.

Also fix common.resource path to use ${CURDIR}/common.resource.

Refs: #524
2026-03-07 02:43:49 +00:00
brent.edwards 5e595260b7 Merge pull request 'test(resource): add failing tests for built-in fs-directory type bootstrap (#537)' (#567) from feature/m3-test-resource-bootstrap-fs into master
Reviewed-on: cleveragents/cleveragents-core#567
2026-03-07 02:31:44 +00:00
brent.edwards ee59f8c2ab Merge branch 'master' into HEAD
# Conflicts:
#	CHANGELOG.md
2026-03-07 02:25:07 +00:00
brent.edwards 01ac466c2e Merge pull request 'test(cli): add failing tests for agents init --yes missing option (#536)' (#566) from feature/m3-test-init-yes-flag into master
Reviewed-on: cleveragents/cleveragents-core#566
Reviewed-by: Hamza Khyari <hamza.khyari@cleverthis.com>
2026-03-07 02:19:02 +00:00
brent.edwards 8c7497ddb3 Merge branch 'master' into HEAD
# Conflicts:
#	CHANGELOG.md
2026-03-07 02:09:56 +00:00
freemo fde8618665 docs(timeline): Day 26 PM sweep — schedule adherence, PR status, spec gap analysis
Day 26 (2026-03-06) comprehensive PM update:

- Schedule adherence entry with milestone forecasts and developer status
- Updated Current Status Summary: 272 issues closed (77%), 1570/1922 SP (82%)
- PR #617 (UKO Layer 1) and #611 (domain analyzers) merged late Day 26
- Open PR count: 19 -> 15 (merge rate exceeding new PR rate for first time)
- Spec gap analysis: no major coverage gaps found across all 44K-line spec
- All 15 open PRs have PM status comments with action items and deadlines
- Updated milestone roadmap, track forecasts, developer forecasts, risk summary
- Workstream and completion sections updated with Day 26 merges

ISSUES CLOSED: none (PM/docs update only)
2026-03-06 23:43:34 +00:00
hamza.khyari b157c05476 Merge pull request 'feat(acms): implement UKO Layer 1 Domain Ontologies (uko-code, uko-doc, uko-data, uko-infra)' (#617) from feature/m6-uko-layer1-domain-ontologies into master
Reviewed-on: cleveragents/cleveragents-core#617
Reviewed-by: Aditya Chhabra <aditya.chhabra@cleverthis.com>
2026-03-06 23:34:12 +00:00
hamza.khyari 44fae392d7 fix(acms): address self-review findings F1-F4 on PR #617
F1 [P1]: Split Turtle validation (125 lines) from ontology_registry.py
into _turtle_validation.py. Registry is now 412 lines (was 514).

F2 [P2]: Deduplicate DetailLevelMap presets — depth_breadth_projection.py
code_detail_map/docs_detail_map/database_detail_map/infra_detail_map now
delegate to ontology_registry.get_domain() instead of hardcoding level
dicts. Removes 112 lines of duplicated data.

F3 [P2]: Add __all__ to ontology_registry.py (18 exports, ruff-sorted).

F4 [P3]: Remove unused import logging / logger from ontology_registry.py.

Refs: #574
2026-03-06 23:26:35 +00:00
hamza.khyari 04f24b39c0 feat(acms): implement UKO Layer 1 Domain Ontologies (uko-code, uko-doc, uko-data, uko-infra)
Implement the four Layer 1 domain-specific OWL/Turtle ontology vocabularies
that specialize Layer 0 universal concepts for specific knowledge domains.

Ontology (docs/ontology/uko.ttl):
- Added uko-doc: namespace with 17 classes (Document, Part, Chapter, Section,
  Subsection, Paragraph, Sentence, CodeBlock, Citation, Figure, Table,
  Footnote, Annotation, Bookmark, CrossReference, PageBreak, SectionBreak),
  5 properties, and 4 relationships
- Added uko-data: namespace with 13 classes (Schema, Table, Column, View,
  StoredProcedure, Constraint, Index, ForeignKey, Trigger, Annotation,
  Bookmark, PartitionBoundary, ShardBoundary), 6 properties, and
  5 relationships
- Added uko-infra: namespace with 7 classes (Service, Network, Endpoint,
  ConfigKey, Volume, FirewallRule, SubnetBoundary) and 2 relationships
- All classes use rdfs:subClassOf from Layer 0 base classes

Domain registry (ontology_registry.py):
- DomainDescriptor dataclass with namespace IRI, prefix, layer, classes,
  superclass mappings, and DetailLevelMap
- Registry functions: get_domain(), list_domains(), get_layer1_domains()
- DetailLevelMap chain builder for hierarchical depth resolution
- Turtle validation with TurtleValidationError (no rdflib dependency)
- All DetailLevelMap data inlined to maintain DIP compliance (domain
  layer does not import from application layer)

DetailLevelMap presets (depth_breadth_projection.py):
- code_detail_map: 10 spec-complete levels (depths 0-9)
- docs_detail_map: 11 spec-complete levels (depths 0-10)
- database_detail_map: 12 spec-complete levels (depths 0-11)
- infra_detail_map: 9 spec-complete levels (depths 0-8)

Tests:
- 31 BDD scenarios in uko_ontology_registry.feature covering domain
  lookup, all DetailLevelMap levels, inheritance chains, Turtle
  validation, Universal View Guarantee, and negative/edge cases
- 6 Robot Framework integration tests
- Updated existing tests: depth_breadth_projection.feature (TABLE_LISTING
  depth 0->1, added SCHEMA_LISTING), uko_ontology.feature (Layer 1
  node count 8->67)

Spec reference: docs/specification.md §41830-42332

ISSUES CLOSED: #574
2026-03-06 23:14:30 +00:00
hamza.khyari 95c9c9f3a4 Merge pull request 'feat(acms): add PostgreSQL and Docker Compose domain analyzers' (#611) from feature/m6-acms-domain-specific-analyzers into master
Reviewed-on: cleveragents/cleveragents-core#611
Reviewed-by: Brent Edwards <brent.edwards@cleverthis.com>
2026-03-06 23:07:25 +00:00
brent.edwards dc1ecaab47 test(resource): add failing tests for built-in fs-directory type bootstrap
Add TDD-style Behave BDD tests for the built-in fs-directory resource type
bootstrap (bug #523). Three Gherkin scenarios: one failing TDD test
reproducing the bug (no bootstrap called during init, tagged @wip), and
two regression tests verifying bootstrap_builtin_types() seeds correct
data and resource add fs-directory succeeds after bootstrap. Includes
Robot Framework regression tests.

Review feedback addressed:
- Removed all 21 unnecessary # type: ignore comments (hurui200320 M1)
- Fixed is not True to is False for clarity (Aditya F2)
- Fixed Robot common.resource path to ${CURDIR}/common.resource (hurui200320 L1)
- Squashed all commits into one and rebased onto master (C1, C2)
- Added CHANGELOG entry with correct scenario count

Closes #537
2026-03-06 20:44:36 +00:00
hamza.khyari fb96d7910b fix(changelog): prepend #588 entry to top of Unreleased section (F8)
Move the (#588) CHANGELOG entry from after (#203) to the top of the
## Unreleased section, matching the convention that newest entries are
prepended first. All pre-existing entries (#473, #495, #203, #494)
remain intact and unmodified.

Addresses reviewer finding F8 from PR #611 second-pass review.
Refs: #588
2026-03-06 20:31:09 +00:00
brent.edwards 4e3bf7d3ad test(cli): add failing tests for agents init --yes missing option
Add TDD-style Behave BDD tests for the missing agents init --yes flag
(bug #522). Five Gherkin scenarios cover: exit code validation, prompt
suppression, -y alias, output summary fields, and interactive-mode
regression guard. Includes Robot Framework smoke tests (tagged @wip)
and ASV benchmarks.

Configure behave.ini to exclude @wip scenarios globally and noxfile.py
to exclude wip-tagged Robot suites, so TDD-failing tests do not break CI.

Review feedback addressed:
- Remove unnecessary # type: ignore from benchmark (outside Pyright scope)
- Fix Then...Then to Then...And in Gherkin (L1)
- Fix CHANGELOG 'three scenarios' to 'five scenarios' (L2)
- Add behave.ini documentation for @wip workaround (Aditya F1)
- Rename Scenario 2 title to 'suppresses interactive prompts' (Aditya F2)

Closes #536
2026-03-06 20:28:37 +00:00
hamza.khyari 13618fb8d5 fix(acms): address PR #611 review findings F1-F7
- F1/F2 [P1]: Split postgresql_analyzer.py (695→310 lines) by
  extracting regex patterns, URI builders, and parsing functions
  into _postgresql_helpers.py (440 lines).  Split
  domain_analyzers.feature (605→217 lines) into separate
  postgresql_analyzer.feature (201) and
  docker_compose_analyzer.feature (199).

- F3 [P1]: Fix _extract_body and _split_entries to track
  single-quoted SQL string literals so parentheses inside
  DEFAULT/CHECK values (e.g. 'func(x)') do not corrupt depth
  counting.  Added regression scenarios.

- F4 [P2]: Remove prohibited `# type: ignore[arg-type]` by
  adding a static protocol assertion for _DuplicatePyAnalyzer.

- F5 [P2]: Add 1 MiB size guard before yaml.safe_load in
  DockerComposeAnalyzer to mitigate billion-laughs alias
  expansion attacks.

- F6 [P2]: Fix quoted-keyword column names (e.g. "primary")
  being silently dropped by checking raw_first.startswith('"')
  before keyword filtering.  Added regression scenario.

- F7 [P2]: Out-of-scope file changes resolved by rebase onto
  master (changes already merged via other PRs).

All nox gates pass: lint (0 errors), typecheck (0 errors),
security_scan, behave (57 scenarios, 211 steps, 0 failures).
2026-03-06 20:07:03 +00:00
hamza.khyari 77db78d768 feat(acms): add PostgreSQL and Docker Compose domain analyzers (#588)
Add Phase 2 domain-specific analyzers for the ACMS UKO indexing pipeline:

- PostgreSQLAnalyzer: regex-based DDL parser extracting uko-data:Table,
  Column, ForeignKey, View, and Schema triples with column metadata
  (data type, nullability, primary key constraints).
- DockerComposeAnalyzer: YAML-based parser extracting uko-infra:
  DeploymentUnit, Service, Port, EnvironmentVariable, and connectsTo
  triples. Validates Compose format via services/version key detection.

Both satisfy AnalyzerProtocol and register in AnalyzerRegistry by file
extension (.sql/.ddl and .yml/.yaml respectively).

Includes 34 Behave BDD scenarios (protocol conformance, registry ops,
triple extraction for all 4 analyzers, error handling, cross-analyzer
URI scheme and confidence checks), 6 Robot Framework integration smoke
tests, updated __init__.py exports, vulture whitelist, and CHANGELOG.
2026-03-06 19:56:21 +00:00
CoreRasurae 23803f14ec feat(lsp): add LSP server stub
Added minimal LSP server entrypoint supporting initialize/shutdown/exit
handshake over JSON-RPC stdin/stdout transport with Content-Length
framing. Unsupported methods return MethodNotFound error with descriptive
message. Wired LSP requests through ACP facade in local mode. Added
agents lsp serve CLI command with --log-level flag, PID output, and
startup banner. Created reference documentation for the stub server.
Includes Behave BDD tests for protocol handshake, Robot smoke test, and
ASV startup latency benchmark.

ISSUES CLOSED: #203
2026-03-06 18:16:47 +00:00
aditya 2bf35e5403 Merge pull request 'feature/m6plus-event-bus' (#509) from feature/m6plus-event-bus into master
Reviewed-on: cleveragents/cleveragents-core#509
Reviewed-by: Hamza Khyari <hamza.khyari@cleverthis.com>
2026-03-06 13:29:03 +00:00
aditya 3d2b138379 Merge branch 'master' into feature/m6plus-event-bus 2026-03-06 12:44:37 +00:00
hurui200320 09d92ac67b test(e2e): validate M4 acceptance criteria for v3.3.0 milestone closure (#560)
## Summary

Validates all M4 acceptance criteria for v3.3.0 milestone closure. Adds CLI-exercising integration tests for the three subplan commands that lacked actual CLI invocation, fixes a pre-existing unit test failure, and corrects CONTRIBUTORS.md ordering.

## Changes

### New CLI Integration Tests (Robot Framework)

Three new test cases in `robot/m4_e2e_verification.robot` with helper functions in `robot/helper_m4_e2e_verification.py`:

| Test | CLI Command | Mocking Approach |
|------|-------------|-----------------|
| `CLI Plan Use Creates Plan With Subplan Config` | `plan use local/refactor-action local/monorepo` | Patches `_get_lifecycle_service`; mocks `get_action_by_name` + `use_action` |
| `CLI Plan Execute Transitions With Subplans` | `plan execute <plan_id>` | Patches `_get_lifecycle_service`; mocks `get_plan` + `execute_plan` |
| `CLI Plan Tree Displays Subplan Hierarchy` | `plan tree <plan_id> --format json` | Patches `get_container`; real `Decision` objects with `SUBPLAN_SPAWN`/`SUBPLAN_PARALLEL_SPAWN` types |

All three follow the same pattern as the existing `plan-diff` test: Typer `CliRunner.invoke()` with mocked services.

### Pre-existing Unit Test Fix

**File:** `features/steps/repositories_uncovered_branches_steps.py`
**Scenario:** `repo branch cov upsert profile with schema version mismatch` (line 110)
**Root cause:** Plain `sessionmaker` returns a new session per call. The `Given` step inserted via session A and committed session B (different session), so the `When` step's session C couldn't see the uncommitted data.
**Fix:** Changed to `scoped_session(sessionmaker(...))` so all factory calls return the same thread-local session.

### Other Fixes
- **CONTRIBUTORS.md**: Moved "Rui Hu" to correct alphabetical position (between Freeman and Khyari)
- **CHANGELOG.md**: Updated #495 entry to document CLI test additions

## M4 Acceptance Criteria Verification

All 7 criteria exercised by 10 E2E tests (7 existing + 3 new) + 8 smoke tests:

| # | Criterion | Test(s) | Status |
|---|-----------|---------|--------|
| 1 | Subplans spawned during Execute via SubplanConfig | `spawn-subplans`, **`cli-plan-use`**, **`cli-plan-execute`** | PASS |
| 2 | Parallel execution with max_parallel bounds | `parallel-exec` | PASS |
| 3 | Three-way merge combines non-conflicting changes | `merge-clean` | PASS |
| 4 | Merge conflicts surfaced with git markers | `merge-conflict` | PASS |
| 5 | Parent plan tracks subplan statuses | `parent-tracking` | PASS |
| 6 | Plan tree displays subplan hierarchy | `plan-tree`, **`cli-plan-tree`** | PASS |
| 7 | Plan diff shows merged results | `plan-diff` (already uses CLI) | PASS |

## Quality Gates

| Stage | Result |
|-------|--------|
| lint | pass |
| format | pass (1074 files unchanged) |
| typecheck | pass (0 errors) |
| unit_tests | 8524 scenarios, 0 failures |
| integration_tests | 1110/1118 pass (8 pre-existing failures in `cli_plan_context_commands.robot`, identical on master) |
| coverage_report | 97% (threshold: 97%) |
| security_scan | pass |
| dead_code | pass |
| docs | pass |
| build | pass |
| benchmark | pass |

## Files Changed

- `CHANGELOG.md` — Updated #495 entry
- `CONTRIBUTORS.md` — Fixed alphabetical ordering
- `features/steps/repositories_uncovered_branches_steps.py` — `scoped_session` fix
- `robot/helper_m4_e2e_verification.py` — 3 new helper functions + imports
- `robot/m4_e2e_verification.robot` — 3 new test cases

ISSUES CLOSED: #495

Reviewed-on: cleveragents/cleveragents-core#560
Reviewed-by: Luis Mendes <luis.mendes@cleverthis.com>
Co-authored-by: Rui Hu <rui.hu@cleverthis.com>
Co-committed-by: Rui Hu <rui.hu@cleverthis.com>
2026-03-06 03:22:45 +00:00
hamza.khyari 1a54dd2d2f Merge pull request 'feat(acms): add scoped backend view filtering' (#607) from feature/m6-acms-scoped-view into master
Reviewed-on: cleveragents/cleveragents-core#607
Reviewed-by: Brent Edwards <brent.edwards@cleverthis.com>
2026-03-06 00:54:59 +00:00
hamza.khyari b028c80cab feat(acms): add scoped backend view filtering
Add project-resource isolation to the ACMS context tier system via
ScopedBackendView, ResourceScope, alias resolution, DAG expansion,
and enforcement hooks.

Core types (scoped_view.py): ResourceScope, ScopeViolationError,
ScopedBackendView, ScopedBackendSet, create_scoped_backend_set.

Scope resolution (scope_resolution.py): ResourceAliasResolver,
validate_project_scope, validate_resource_scope, resolve_resource_scope
with registry_lookup callback for DAG expansion.

Tier integration (scoped_tiers.py): ScopedTierMixin with get_scoped,
get_scoped_by_resource, validate_fragment_scope, store_with_scope_check,
get_scoped_metrics mixed into ContextTierService.

Backward compat: tiers.py re-exports ScopedBackendView.

Tests: 74 Behave scenarios (235 steps), 8 Robot Framework cases,
7 ASV benchmark suites. Lint and typecheck clean.

ISSUES CLOSED: #193
2026-03-06 00:49:33 +00:00
brent.edwards b5915feb6b Merge pull request 'ci(opencode.json): add file from Luis's suggestions' (#609) from feature/following-luis-suggestion into master
Reviewed-on: cleveragents/cleveragents-core#609
Reviewed-by: Luis Mendes <luis.mendes@cleverthis.com>
2026-03-05 23:49:44 +00:00
brent.edwards d2a8ead45c Merge branch 'master' into feature/following-luis-suggestion 2026-03-05 23:44:42 +00:00
hamza.khyari f0708c8d05 Merge pull request 'feat(acms): add context strategy registry with plugin discovery' (#565) from feature/m6-acms-strategy-registry into master
Reviewed-on: cleveragents/cleveragents-core#565
Reviewed-by: Brent Edwards <brent.edwards@cleverthis.com>
2026-03-05 23:40:17 +00:00
brent.edwards 50458d1c9f ci(opencode.json): change based on Luis's comments 2026-03-05 23:39:16 +00:00