Commit Graph

213 Commits

Author SHA1 Message Date
freemo 7f5a330f23 docs(changelog): add Fixed entries for PRs #1498, #1481, #1479
CI / lint (push) Failing after 20s
CI / helm (push) Successful in 29s
CI / quality (push) Successful in 34s
CI / security (push) Failing after 51s
CI / build (push) Successful in 1m0s
CI / typecheck (push) Failing after 1m2s
CI / coverage (push) Has been skipped
CI / benchmark-regression (push) Has been skipped
CI / unit_tests (push) Failing after 2m11s
CI / docker (push) Has been skipped
CI / e2e_tests (push) Failing after 15m58s
CI / integration_tests (push) Failing after 20m51s
CI / status-check (push) Failing after 1s
CI / benchmark-publish (push) Has been cancelled
- tool add: handle tool: wrapper key (#1471)
- session export: sha256: prefix checksum (#1450)
- ThoughtBlockWidget: correct background color (#1448)

ISSUES CLOSED: #1471 #1450 #1448
2026-04-02 20:21:43 +00:00
freemo 71177c6e1a docs: update changelog, API docs, and architecture for 2026-04-02 merged PRs
CI / lint (push) Failing after 18s
CI / build (push) Successful in 18s
CI / helm (push) Successful in 29s
CI / quality (push) Successful in 37s
CI / security (push) Failing after 52s
CI / typecheck (push) Failing after 58s
CI / coverage (push) Has been skipped
CI / benchmark-regression (push) Has been skipped
CI / unit_tests (push) Failing after 1m58s
CI / docker (push) Has been skipped
CI / benchmark-publish (push) Has been cancelled
CI / e2e_tests (push) Has been cancelled
CI / integration_tests (push) Has been cancelled
CI / status-check (push) Has been cancelled
- CHANGELOG: add [Unreleased] entries for TUI first-run experience (#1391),
  session Markdown export (#1004), and UKO provenance/temporal versioning (#891)
- README: add first-run experience and Markdown transcript export bullets
- docs/api/tui.md: new TUI API reference covering first-run, persona system,
  input routing, slash commands, session export/import, and widgets
- docs/api/index.md: add TUI entry to module index
- docs/api/resource.md: document DatabaseResourceHandler and DevcontainerHandler
  full protocol implementations with method tables and examples
- docs/architecture.md: expand UKO section with provenance/temporal versioning
  details; update TUI design decision summary
- mkdocs.yml: add TUI page to API Reference nav

ISSUES CLOSED: #1391 #1004 #891
2026-04-02 19:30:53 +00:00
freemo 0d4c5b6ff1 docs: add v3.7.0 cycle-2 documentation for UKO runtime, TUI permissions, database handler, and thought blocks
CI / lint (push) Failing after 24s
CI / build (push) Successful in 14s
CI / helm (push) Successful in 25s
CI / typecheck (push) Successful in 49s
CI / coverage (push) Has been skipped
CI / benchmark-regression (push) Has been skipped
CI / unit_tests (push) Failing after 1m45s
CI / integration_tests (push) Has been cancelled
CI / security (push) Has been cancelled
CI / quality (push) Has been cancelled
CI / e2e_tests (push) Has been cancelled
CI / benchmark-publish (push) Has been cancelled
CI / status-check (push) Has been cancelled
CI / docker (push) Has been cancelled
- CHANGELOG.md: extend [3.7.0] section with 15 new entries covering
  PermissionsScreen, ThoughtBlock, UKO runtime services, ACMS Phase 2
  protocol aliases, DevcontainerHandler protocol completion,
  DatabaseResourceHandler CRUD/checkpoint, estimation lifecycle hook,
  user_identity domain events, PLAN_APPLIED/PLAN_CANCELLED enrichment,
  server serve subcommand, async audit refactor, and CLI flag fixes
- README.md: extend Highlights with permissions screen, thought blocks,
  UKO runtime, database handler, and estimation lifecycle
- docs/reference/uko_runtime.md: new reference for UKOQueryInterface,
  UKOInferenceEngine, and UKOGraphPersistence (issue #891)
- docs/reference/tui_permissions.md: new reference for PermissionsScreen,
  PermissionRequestService, and all domain models (issue #996)
- docs/reference/tui_thought_block.md: new reference for ThoughtBlock
  domain model and ThoughtBlockWidget (issue #1001)
- docs/reference/database_handler.md: new reference for
  DatabaseResourceHandler CRUD and checkpoint methods (issue #1241)
- docs/reference/devcontainer_resources.md: add DevcontainerHandler
  protocol methods section (delete, list_children, diff, create_sandbox)
  (issue #1242)
- docs/reference/tui.md: extend architecture table and add Permissions
  Screen and Actor Thought Blocks sections

ISSUES CLOSED: #1393
2026-04-02 17:35:41 +00:00
freemo dd3770f930 refactor(correction): eliminate redundant fields in CorrectionDryRunReport (#1278)
CI / security (push) Has been cancelled
CI / benchmark-publish (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / unit_tests (push) Has been cancelled
CI / build (push) Has been cancelled
CI / typecheck (push) Has been cancelled
CI / quality (push) Has been cancelled
CI / e2e_tests (push) Has been cancelled
CI / integration_tests (push) Has been cancelled
CI / helm (push) Has been cancelled
CI / coverage (push) Has been cancelled
CI / benchmark-regression (push) Has been cancelled
CI / status-check (push) Has been cancelled
CI / docker (push) Has been cancelled
Remove three top-level fields from CorrectionDryRunReport that duplicated data already present in the embedded CorrectionImpact object:

- excluded_decisions → now accessed via report.impact.excluded_decisions
- rollback_tier_depth → now accessed via report.impact.rollback_tier_depth
- child_plans_to_rollback → now accessed via report.impact.affected_child_plans

The redundant fields created a divergence risk: both models are frozen=True Pydantic models, so post-construction mutation is impossible, but nothing prevented constructing an instance where the top-level copies disagreed with the impact sub-object.

Approach: Option B (nest-only) — remove the duplicated top-level fields and update all consumers to use the impact object's fields instead.

Closes #1087

Co-authored-by: Jeffrey Phillips Freeman <the@jeffreyfreeman.me>
Co-committed-by: Jeffrey Phillips Freeman <the@jeffreyfreeman.me>
2026-04-02 16:59:40 +00:00
freemo b772a43ac6 docs: add TUI reference, persona docs, and v3.7.0 changelog
CI / lint (push) Has been cancelled
CI / typecheck (push) Has been cancelled
CI / status-check (push) Has been cancelled
CI / security (push) Has been cancelled
CI / coverage (push) Has been cancelled
CI / benchmark-regression (push) Has been cancelled
CI / build (push) Has been cancelled
CI / docker (push) Has been cancelled
CI / quality (push) Has been cancelled
CI / unit_tests (push) Has been cancelled
CI / integration_tests (push) Has been cancelled
CI / e2e_tests (push) Has been cancelled
CI / helm (push) Has been cancelled
CI / benchmark-publish (push) Has been cancelled
- docs/reference/tui.md: new TUI reference covering launch, layout,
  key bindings, input modes, help panel (F1), persona bar, full slash
  command catalog (67 commands / 14 groups), persona YAML schema, and
  module architecture table
- docs/reference/persona.md: new persona system reference covering
  storage layout, YAML schema, validation rules, argument presets,
  PersonaRegistry and PersonaState Python APIs, and TUI slash commands
- CHANGELOG.md: add [3.7.0] section summarising TUI, persona system,
  session management, server mode, A2A integration, and key fixes
- README.md: extend Highlights with TUI, persona, session, server mode,
  and A2A; add TUI quick-start, session management, and server mode
  usage examples
2026-04-02 16:52:59 +00:00
hamza.khyari c200fe0f86 feat(lsp): implement get_hover and get_definitions for LSP runtime (#1240)
CI / lint (push) Successful in 18s
CI / unit_tests (push) Has been cancelled
CI / e2e_tests (push) Has been cancelled
CI / benchmark-publish (push) Has been cancelled
CI / build (push) Has been cancelled
CI / typecheck (push) Has been cancelled
CI / security (push) Has been cancelled
CI / integration_tests (push) Has been cancelled
CI / helm (push) Has been cancelled
CI / quality (push) Has been cancelled
CI / coverage (push) Has been cancelled
CI / status-check (push) Has been cancelled
CI / benchmark-regression (push) Has been cancelled
CI / docker (push) Has been cancelled
Add hover and definition support to LspClient and LspRuntime.

- LspClient.get_hover(): sends textDocument/hover, returns Hover dict or None
- LspClient.get_definitions(): sends textDocument/definition, handles
  Location, Location[], and LocationLink[] responses
- LspRuntime wrappers: input validation, file reading, language
  detection, 1-based to 0-based line/column conversion
- try/finally for did_close() safety on both new methods
- Tool adapter: HOVER and DEFINITIONS dispatch to runtime instead of
  raising LspNotAvailableError
- Updated lsp_tool_adapter_coverage test (HOVER -> REFERENCES)
- 21 Behave BDD scenarios with full path coverage

Closes #1243

Co-authored-by: Hamza Khyari <hamza.khyari@cleverthis.com>
Co-committed-by: Hamza Khyari <hamza.khyari@cleverthis.com>
2026-04-02 16:52:33 +00:00
CoreRasurae b21e0fedea test(bdd): add direct test for _fast_init_or_upgrade early-return behavior
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 21s
CI / helm (pull_request) Successful in 24s
CI / typecheck (pull_request) Successful in 50s
CI / security (pull_request) Successful in 1m10s
CI / lint (pull_request) Successful in 3m20s
CI / quality (pull_request) Successful in 3m45s
CI / unit_tests (pull_request) Successful in 5m53s
CI / docker (pull_request) Successful in 1m32s
CI / coverage (pull_request) Successful in 12m27s
CI / e2e_tests (pull_request) Successful in 19m48s
CI / integration_tests (pull_request) Successful in 22m24s
CI / status-check (pull_request) Successful in 1s
CI / build (push) Successful in 16s
CI / helm (push) Successful in 22s
CI / lint (push) Successful in 3m17s
CI / quality (push) Successful in 3m39s
CI / typecheck (push) Successful in 3m53s
CI / security (push) Successful in 4m4s
CI / unit_tests (push) Successful in 9m13s
CI / docker (push) Successful in 20s
CI / coverage (push) Successful in 12m20s
CI / e2e_tests (push) Successful in 19m18s
CI / integration_tests (push) Successful in 24m36s
CI / status-check (push) Successful in 2s
CI / benchmark-regression (push) Has been skipped
CI / benchmark-regression (pull_request) Successful in 55m5s
CI / benchmark-publish (push) Successful in 28m26s
Add 8 BDD scenarios in features/fast_init_upgrade.feature that directly
exercise the _fast_init_or_upgrade closure installed by
_install_template_db_patch in features/environment.py.

Scenarios cover all code paths:
- Non-empty DB with matching prefix → early return (original NOT invoked)
- Non-existent DB with matching prefix → template copied (original NOT invoked)
- Existing empty DB with matching prefix → template copied (original NOT invoked)
- Non-matching prefix → delegates to original init_or_upgrade
- In-memory SQLite → delegates to original init_or_upgrade
- Non-SQLite URL → delegates to original init_or_upgrade
- Bare sqlite:// URL → delegates to original init_or_upgrade
- Delegation forwards runner instance and keyword arguments correctly

Test infrastructure:
- features/mocks/fast_init_test_helpers.py provides a context manager
  (patch_original_init_or_upgrade) that replaces the _original_init_or_upgrade
  reference inside the closure via cell_contents manipulation, enabling
  precise call-tracking without recreating the function under test.
- All scenarios tagged @mock_only to skip unnecessary DB setup.
- Cleanup registered via context._cleanup_handlers for temp file removal.
- Works in both sequential and parallel execution modes.

Review fix round:
- Added bare sqlite:// URL scenario covering the second branch of the
  in-memory disjunction (L1).
- Added scenario verifying runner instance and keyword argument forwarding
  through the delegation path (L2, L3).
- Replaced hardcoded test credentials with clearly synthetic pattern (I4).
- Fixed CHANGELOG wording that incorrectly claimed mktemp replacement (L5).

ISSUES CLOSED: #733
2026-04-01 23:52:20 +01:00
brent.edwards 0ae733d01f feat(tui): implement help panel (F1) with context-sensitive help
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 18s
CI / helm (pull_request) Successful in 23s
CI / lint (pull_request) Successful in 3m20s
CI / quality (pull_request) Successful in 3m44s
CI / typecheck (pull_request) Successful in 3m58s
CI / security (pull_request) Successful in 4m10s
CI / unit_tests (pull_request) Successful in 9m2s
CI / docker (pull_request) Successful in 1m30s
CI / coverage (pull_request) Successful in 9m3s
CI / e2e_tests (pull_request) Successful in 22m5s
CI / integration_tests (pull_request) Successful in 24m37s
CI / status-check (pull_request) Successful in 2s
CI / benchmark-regression (pull_request) Successful in 55m59s
Add a dedicated TUI help overlay toggled by F1 and resolve its content from the current prompt mode for main-screen, slash-command, reference, and shell contexts.

Extend Behave and Robot coverage for the new help-panel widget, app wiring, context switching, and toggle behavior.

ISSUES CLOSED: #1013
2026-04-01 21:51:14 +00:00
brent.edwards dc1359fc07 feat(tui): enumerate full slash command set (60+ commands, 14 groups)
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 17s
CI / helm (pull_request) Successful in 22s
CI / lint (pull_request) Successful in 3m19s
CI / quality (pull_request) Successful in 3m46s
CI / typecheck (pull_request) Successful in 3m56s
CI / security (pull_request) Successful in 4m8s
CI / unit_tests (pull_request) Successful in 9m14s
CI / docker (pull_request) Successful in 1m19s
CI / coverage (pull_request) Successful in 9m24s
CI / e2e_tests (pull_request) Successful in 17m12s
CI / integration_tests (pull_request) Successful in 25m32s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-regression (pull_request) Successful in 54m48s
Add a specification-aligned slash command catalog and wire it into TUI overlay initialization so command discovery reflects the complete command surface. Cover command and group cardinality plus representative command presence in Behave tests.

ISSUES CLOSED: #1002
2026-04-01 09:23:21 +00:00
aditya 137d040c4d feat(acms): implement DepthReductionCompressor for skeleton compression
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 18s
CI / helm (pull_request) Successful in 22s
CI / quality (pull_request) Successful in 56s
CI / lint (pull_request) Successful in 3m21s
CI / typecheck (pull_request) Successful in 4m0s
CI / security (pull_request) Successful in 4m19s
CI / unit_tests (pull_request) Successful in 9m32s
CI / docker (pull_request) Successful in 1m22s
CI / coverage (pull_request) Successful in 12m27s
CI / e2e_tests (pull_request) Successful in 20m3s
CI / integration_tests (pull_request) Successful in 21m20s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-regression (pull_request) Successful in 54m56s
Add a production skeleton compressor that re-renders inherited fragments to overview depths via the UKO detail-level map chain, fits the result within the configured skeleton budget, and wires the pipeline default to the new compressor.

Address prior review feedback by extracting the render visitors into a dedicated module, restoring projected metadata to native runtime types, constraining builtin component resolution with an allowlist, and keeping child-context inheritance compatible with CRP context fragments for the Robot integration path.

Reproduced the Forgejo lint job in a clean python:3.13-slim container with the CI commands All checks passed! and 1740 files already formatted; both passed, so the earlier lint failure appears to have been transient runner behavior rather than a source-level defect.

ISSUES CLOSED: #919
2026-04-01 06:16:41 +00:00
brent.edwards 81c141716b test(integration): workflow example 2 — automated test generation for a module (trusted profile) (#1176)
CI / build (push) Successful in 22s
CI / helm (push) Successful in 22s
CI / lint (push) Successful in 3m20s
CI / quality (push) Successful in 3m46s
CI / typecheck (push) Successful in 3m56s
CI / security (push) Successful in 4m11s
CI / unit_tests (push) Successful in 8m55s
CI / docker (push) Successful in 1m35s
CI / coverage (push) Successful in 12m29s
CI / e2e_tests (push) Successful in 18m50s
CI / integration_tests (push) Successful in 24m10s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Has been cancelled
CI / benchmark-regression (push) Has been cancelled
## Summary
- Refactors WF02 integration helper into focused modules to satisfy maintainability guidelines and keep command responsibilities isolated.
- Moves WF02 artifact assertions onto lifecycle-produced change artifacts and verifies user-facing `plan artifacts` flow with mocked providers.
- Reworks WF02 coverage-gate assertions to run through validation registration/attachment/execution lifecycle and apply-gate outcomes.

## What changed in this fix round (cycle-6)
- **CI must-fix — trusted profile lifecycle integration failure:**
  - Fixed failing integration test `WF02 Trusted Profile Auto Runs Strategize And Execute` caused by legacy AutomationProfile fields that no longer exist.
  - Updated WF02 trusted-profile assertions from removed legacy fields (`auto_strategize`, `auto_execute`, `auto_apply`) to current spec-aligned fields (`decompose_task`, `create_tool`, `select_tool`).
  - Key module: `robot/wf02_test_generation_commands.py` (`wf02_trusted_lifecycle`).

## Prior fix rounds retained
- **P1 must-fix — validation payload assertions strengthened:**
  - Added explicit assertions for validation payload correctness in both failing and passing branches.
  - Assertions now verify:
    - validation identity (`local/auth-coverage` on `local/api-service-repo`)
    - required-mode semantics (`mode=required`, required pass/fail counters, `all_required_passed`)
    - `passed` boolean for each branch
    - measured-vs-target semantics (`measured_coverage` compared against `target`).
  - Key module: `robot/wf02_test_generation_validation.py`.

- **P2 should-fix — artifact membership assertions tightened:**
  - Artifact assertions now enforce exact expected membership and count instead of permissive subset checks.
  - Persisted changeset assertions were aligned to the same strict set/count checks.
  - Key module: `robot/wf02_test_generation_artifacts.py`.

- **P2 should-fix — removed unused helper:**
  - Deleted unused `_bind_changeset_to_plan` helper to eliminate dead code.
  - Key module: `robot/wf02_test_generation_artifacts.py`.

- **P2 should-fix — concrete typing:**
  - Replaced `_setup_validation_db` return type from `tuple[Any, Any]` to concrete typed return (`Callable[[], _NoCloseSession]`, `Session`).
  - Key module: `robot/wf02_test_generation_validation.py`.

## Quality gates
- `nox -e lint` 
- `nox -e typecheck` 
- `nox -e unit_tests` 
- `nox -e integration_tests` 
- `nox -e e2e_tests` 
- `nox -e coverage_report`  (coverage: **98.74%**)

## Scope / limitations
- No deferred items identified in cycle-6.

Closes #766

Reviewed-on: #1176
Reviewed-by: Jeffrey Phillips Freeman <jeffrey.freeman@cleverthis.com>
Co-authored-by: Brent Edwards <brent.edwards@cleverthis.com>
Co-committed-by: Brent Edwards <brent.edwards@cleverthis.com>
2026-04-01 03:30:00 +00:00
brent.edwards 91cc0b1446 test: add TDD bug-capture test for #1025 — plan correct auto-resolve (#1172)
CI / quality (push) Successful in 36s
CI / build (push) Successful in 20s
CI / helm (push) Successful in 22s
CI / lint (push) Successful in 3m21s
CI / typecheck (push) Successful in 3m57s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 4m7s
CI / unit_tests (push) Successful in 9m18s
CI / docker (push) Successful in 1m18s
CI / coverage (push) Successful in 12m28s
CI / e2e_tests (push) Failing after 19m0s
CI / integration_tests (push) Successful in 24m45s
CI / status-check (push) Failing after 1s
CI / benchmark-publish (push) Successful in 28m39s
## Summary
- add Behave `@tdd_expected_fail` bug-capture scenarios for `plan correct` auto-resolve without `--plan`
- add shared mock fixtures and Robot integration coverage for isolated-container divergence reproducing bug #1025
- add ASV benchmark coverage for active-plan filtering and document the new TDD capture in changelog

## Testing
- nox -s unit_tests -- features/tdd_plan_correct_auto_resolve.feature
- nox -s integration_tests -- --include tdd_bug_1025
- nox -s lint
- nox -s typecheck
- nox -s coverage_report
- nox

Closes #1035

Reviewed-on: #1172
Reviewed-by: Jeffrey Phillips Freeman <jeffrey.freeman@cleverthis.com>
Co-authored-by: Brent Edwards <brent.edwards@cleverthis.com>
Co-committed-by: Brent Edwards <brent.edwards@cleverthis.com>
2026-04-01 00:40:46 +00:00
hamza.khyari 5e96b4bf80 feat(resource): implement 6-level execution environment precedence chain
CI / build (pull_request) Successful in 16s
CI / helm (pull_request) Successful in 21s
CI / lint (pull_request) Successful in 3m18s
CI / quality (pull_request) Successful in 3m47s
CI / typecheck (pull_request) Successful in 3m57s
CI / security (pull_request) Successful in 4m6s
CI / benchmark-publish (pull_request) Has been skipped
CI / integration_tests (pull_request) Successful in 7m6s
CI / unit_tests (pull_request) Successful in 7m18s
CI / docker (pull_request) Successful in 1m19s
CI / coverage (pull_request) Successful in 11m49s
CI / e2e_tests (pull_request) Successful in 20m44s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-regression (pull_request) Successful in 55m9s
Implement the spec's 6-level execution environment precedence chain
(spec lines 19324-19386):

1. Plan override (priority=override) — always wins
2. Project override (priority=override) — wins over devcontainer
3. Nearest-ancestor devcontainer — auto-discovered
4. Plan fallback (priority=fallback) — defers to devcontainer
5. Project fallback (priority=fallback) — defers to closer scopes
6. Host default — final fallback

- New resolve_with_precedence() API on ExecutionEnvironmentResolver
- Added execution_env_priority field to ContextConfig (project model)
- has_devcontainer() helper for devcontainer-instance detection
- Legacy 4-level resolve() preserved for backward compatibility
- _parse_priority() defaults missing priority to FALLBACK
- 13 new Behave scenarios testing all 6 levels + edge cases
- Updated CHANGELOG

ISSUES CLOSED: #877
2026-03-31 16:01:58 +00:00
hamza.khyari cd9cb9e889 fix(cli): honour project-level execution-env-priority in resolution
CI / build (pull_request) Successful in 15s
CI / helm (pull_request) Successful in 22s
CI / lint (pull_request) Successful in 3m19s
CI / quality (pull_request) Successful in 3m54s
CI / typecheck (pull_request) Successful in 3m57s
CI / security (pull_request) Successful in 4m27s
CI / integration_tests (pull_request) Successful in 7m1s
CI / unit_tests (pull_request) Successful in 7m44s
CI / docker (pull_request) Successful in 1m31s
CI / coverage (pull_request) Successful in 12m18s
CI / e2e_tests (pull_request) Successful in 21m52s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 54m34s
Thread plan_env and project_env through the tool execution chain so
the ExecutionEnvironmentResolver receives project-level execution
environment values stored in ContextConfig.execution_environment.

The resolver's precedence logic (tool > plan > project > default) was
already correct, but callers never passed project_env — tools always
fell through to the global HOST default, ignoring project-level
overrides entirely.

Changes:
- PlanExecutionContext: add plan_env and project_env fields + properties
- ToolCallRouter: accept plan_env/project_env in constructor, pass to
  runner.execute() in route() and route_streaming()
- ToolCallingRuntime: accept plan_env/project_env, pass to
  runner.execute() in the direct-runner fallback path
- Update monkey-patched execute stubs in tool_router_steps.py to accept
  explicit plan_env/project_env keyword arguments
- Add 4 BDD scenarios proving plan_env/project_env reach the resolver
  via ToolCallRouter (project-only, plan-only, both, neither)

Dependency: requires PR #1135 to be merged first (adds CLI flag and
persistence for project-level execution-env-priority).

Closes #1080

ISSUES CLOSED: #1080
2026-03-31 11:31:00 +00:00
hamza.khyari 3f66221938 test(integration): workflow example 5 — database schema migration with safety nets (review profile)
CI / build (pull_request) Successful in 25s
CI / helm (pull_request) Successful in 29s
CI / lint (pull_request) Successful in 3m47s
CI / typecheck (pull_request) Successful in 4m20s
CI / quality (pull_request) Successful in 4m23s
CI / security (pull_request) Successful in 4m49s
CI / integration_tests (pull_request) Successful in 7m27s
CI / unit_tests (pull_request) Successful in 8m11s
CI / docker (pull_request) Successful in 1m31s
CI / coverage (pull_request) Successful in 12m17s
CI / e2e_tests (pull_request) Successful in 22m57s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 54m40s
Robot Framework integration test suite for Specification Workflow Example 5:
Database Schema Migration with Safety Nets.  Exercises the review automation
profile with custom resource types, custom skills with database tools,
phased child plan execution, checkpointing, and rollback.

- 7 test cases covering: custom resource type registration, review profile
  behavior, custom skill with 3 database tools, action creation with
  review profile, checkpoint/rollback via managers, 5-phase sequential
  SubplanService.spawn with fail-fast, and plan lifecycle through
  strategize-to-execute
- Uses mocked LLM providers (CLEVERAGENTS_TESTING_USE_MOCK_AI=true)
- All Run Process calls have timeout=60s on_timeout=kill
- Fix environment-dependent test failures: mock shutil.disk_usage in
  disk space and diagnostics --check Behave steps so tests pass
  regardless of CI runner disk space; Robot diagnostics test tolerates
  disk-space errors

ISSUES CLOSED: #769
2026-03-31 11:03:20 +00:00
CoreRasurae a4a6b061a6 fix(db): align v3_plans schema with specification DDL
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 18s
CI / lint (pull_request) Successful in 20s
CI / helm (pull_request) Successful in 22s
CI / typecheck (pull_request) Successful in 51s
CI / quality (pull_request) Successful in 3m45s
CI / integration_tests (pull_request) Successful in 3m59s
CI / security (pull_request) Successful in 4m8s
CI / unit_tests (pull_request) Successful in 5m44s
CI / docker (pull_request) Successful in 1m32s
CI / coverage (pull_request) Successful in 11m50s
CI / e2e_tests (pull_request) Successful in 20m28s
CI / status-check (pull_request) Successful in 1s
CI / lint (push) Successful in 17s
CI / build (push) Successful in 18s
CI / helm (push) Successful in 22s
CI / quality (push) Successful in 31s
CI / typecheck (push) Successful in 1m1s
CI / benchmark-regression (push) Has been skipped
CI / unit_tests (push) Successful in 3m57s
CI / security (push) Successful in 4m3s
CI / docker (push) Successful in 1m21s
CI / integration_tests (push) Successful in 7m11s
CI / coverage (push) Successful in 11m56s
CI / e2e_tests (push) Successful in 20m56s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Successful in 28m22s
CI / benchmark-regression (pull_request) Successful in 55m20s
Aligned v3_plans table with specification DDL:

1. Added effective_profile_snapshot column (TEXT NOT NULL) for
   storing frozen JSON snapshot of automation profile at plan
   creation time.  Added Pydantic field_validator ensuring the
   value is well-formed JSON.  Validator catches RecursionError
   for deeply nested JSON, consistent with automation_profile
   deserialization hardening.  Validator error message uses
   length-only to avoid potential information disclosure.
   Documented that the default "{}" exists for backward
   compatibility; new plans should explicitly set the snapshot.

2. Made root_plan_id NOT NULL — root plans self-reference their
   own plan_id, child plans reference the root ancestor.  Added
   explicit ondelete="RESTRICT" FK policy for consistency with
   other FKs in the model.  Documented known FK policy drift
   between ORM model (RESTRICT) and migrated databases (retained
   SET NULL) in the migration; data integrity is preserved by
   the NOT NULL constraint regardless.  Moved root_plan_id
   self-reference resolution into a PlanIdentity model_validator
   so the domain model is consistent with the DB NOT NULL
   constraint before and after persistence (previously the
   resolution only happened in from_domain(), creating an
   asymmetry where root_plan_id was None in-memory but non-null
   after round-tripping through the database).

3. Made automation_profile NOT NULL with default "balanced".

4. Documented intentional deviation: phase default is "action"
   (code) vs "strategize" (spec) because the Action phase was
   added as a pre-Strategize setup step.

5. Created Alembic migration with backfill logic for existing
   rows.  Root-ancestor backfill uses level-by-level propagation
   with a parent-readiness guard to correctly resolve plans at
   arbitrary hierarchy depth (3+ levels).  Added safety bound
   (max 100 iterations) with logged error on exhaustion to guard
   against cycles in parent_plan_id.  Merged batch_alter_table
   operations to avoid redundant full-table copies in SQLite
   batch mode.  Migration backfill also handles empty-string
   automation_profile values.  Documented downgrade limitation
   (backfill is not reversible).  Orphan-row fallback now logs
   affected row count at WARNING level.  Migration cycle-detection
   now logs affected plan_id values before the orphan fallback
   overwrites them.  All migration SQL uses sa.text() for
   consistency with SQLAlchemy best practices.

6. Hardened automation_profile deserialization in to_domain() to
   catch ValueError (invalid StrEnum provenance), Pydantic
   ValidationError, and RecursionError (deeply nested JSON) in
   addition to JSONDecodeError and KeyError, preventing
   unreadable plans from corrupted DB rows.  Applied the same
   defensive deserialization pattern to effective_profile_snapshot
   in to_domain(): corrupted JSON falls back to '{}' with a
   WARNING log instead of crashing the read path.  Added TypeError
   to the effective_profile_snapshot exception list in to_domain()
   for consistency with the Pydantic validator.  Logging of
   unparseable values uses length only to avoid potential
   information disclosure.

7. Used explicit None check (is not None) instead of truthiness
   for root_plan_id resolution in from_domain(), for
   effective_profile_snapshot in to_domain(), and in
   _serialize_automation_profile() for consistency.

8. Documented intentional column naming conventions vs spec DDL
   (e.g. automation_profile vs automation_profile_name, *_actor
   vs *_actor_name, processing_state vs state, v3_plans vs
   plans).  Documented the semantic difference: automation_profile
   stores either a bare name or structured JSON with provenance,
   whereas the spec automation_profile_name stores a plain name.

9. Fixed benchmark plan constructors
   (plan_phase_migration_bench.py) that were missing the now-
   required root_plan_id and effective_profile_snapshot fields.

10. Replaced defensive getattr() with direct attribute access for
    effective_profile_snapshot in from_domain() and update(),
    since the field is now defined on the Plan domain model.

11. Fixed Any type annotation in test helper _make_plan() to use
    AutomationProfileRef | None for proper type safety.

12. Added BDD scenarios for PlanIdentity self-reference
    resolution, NULL effective_profile_snapshot constraint
    enforcement, valid-JSON-missing-profile_name-key
    deserialization, invalid-JSON and empty-string snapshot
    rejection by Pydantic validator, and corrupted
    effective_profile_snapshot DB fallback in to_domain().

13. Extracted default automation profile name to a module-level
    constant (DEFAULT_AUTOMATION_PROFILE) to reduce sentinel
    duplication across models.py and repositories.py.

14. Centralised automation-profile serialisation into
    LifecyclePlanModel._serialize_automation_profile() to
    eliminate duplication between from_domain() and
    LifecyclePlanRepository.update().

15. Fixed to_domain() root_plan_id type cast from str | None
    to str, reflecting the NOT NULL column constraint.

16. Added PlanIdentity model_validator that resolves None
    root_plan_id to plan_id at domain construction time, ensuring
    the domain model honours the spec DDL NOT NULL constraint
    regardless of persistence state.  Simplified from_domain()
    root resolution accordingly.

ISSUES CLOSED: #921
2026-03-30 23:40:36 +01:00
hamza.khyari 49015c6bee fix(cli): implement --execution-env-priority on project context set
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 18s
CI / helm (pull_request) Successful in 23s
CI / lint (pull_request) Successful in 3m19s
CI / quality (pull_request) Successful in 3m43s
CI / typecheck (pull_request) Successful in 3m57s
CI / security (pull_request) Successful in 4m6s
CI / integration_tests (pull_request) Successful in 7m5s
CI / unit_tests (pull_request) Successful in 7m10s
CI / docker (pull_request) Successful in 1m18s
CI / coverage (pull_request) Successful in 11m47s
CI / e2e_tests (pull_request) Successful in 20m22s
CI / status-check (pull_request) Successful in 2s
CI / benchmark-regression (pull_request) Successful in 1h0m10s
Add --execution-env-priority flag to 'project context set' command,
enabling project-level execution environment priority per spec WF17.

- Add execution_env_priority field to ContextConfig domain model
- Validate flag value against ExecutionEnvPriority enum (fallback/override)
- Persist in context_policy_json, preserving existing execution_environment
- Display in 'project context show' Execution Environment section
- Merge with existing blob to avoid overwriting previously set fields

Tests: 9 Behave scenarios, 26 steps.

ISSUES CLOSED: #1079
2026-03-30 14:33:28 +00:00
CoreRasurae 007af498b8 refactor(autonomy): rename automation profile task flags to spec names
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 17s
CI / helm (pull_request) Successful in 33s
CI / lint (pull_request) Successful in 3m42s
CI / security (pull_request) Successful in 4m8s
CI / quality (pull_request) Successful in 4m9s
CI / typecheck (pull_request) Successful in 4m20s
CI / integration_tests (pull_request) Successful in 7m2s
CI / unit_tests (pull_request) Successful in 7m55s
CI / docker (pull_request) Successful in 1m19s
CI / coverage (pull_request) Successful in 8m46s
CI / e2e_tests (pull_request) Successful in 16m1s
CI / status-check (pull_request) Successful in 1s
CI / build (push) Successful in 17s
CI / helm (push) Successful in 22s
CI / quality (push) Successful in 31s
CI / lint (push) Successful in 3m28s
CI / typecheck (push) Successful in 3m54s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 4m5s
CI / integration_tests (push) Successful in 6m13s
CI / unit_tests (push) Successful in 6m28s
CI / docker (push) Successful in 1m34s
CI / coverage (push) Successful in 12m5s
CI / e2e_tests (push) Successful in 18m47s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Successful in 28m0s
CI / benchmark-regression (pull_request) Successful in 59m48s
Renamed all 11 task-type confidence threshold fields in AutomationProfile
from phase-transition semantics to spec-defined task-type semantics.
Updated all 8 built-in profiles, CLI formatting, YAML schema, services,
and all Behave/Robot tests referencing the old field names.

Post-review fixes:
- Fixed 24 stale old field names in M6 fixture files
  (automation_profiles.json, autonomy_guardrails.json)
- Added model_validator(mode='before') to detect legacy field names
  and raise actionable ValueError with rename mapping
- Added semantic bridge comments in PlanLifecycleService mapping
  task-type thresholds to phase-transition gates
- Added threshold_field to structured log messages for observability
- Restored categorised CLI automation-profile show output to match
  spec (Phase Transitions / Decision Automation / Self-Repair /
  Execution Controls) instead of flat list
- Added missing access_network field to spec show output examples
  (Rich, Plain, JSON, YAML variants)
- Aligned ADR-017 profile fields table to all 11 fields with
  descriptions matching spec Automatable Tasks table
- Aligned automation_profiles.md threshold descriptions with spec
- Added spec section references in phase_reversion.md, error_recovery.md,
  and plan_execute.md for field naming context
- Extended repository roundtrip test to assert all 11 threshold fields
- Fixed benchmark _make_profile() passing safety fields as top-level
  kwargs instead of via SafetyProfile sub-model (incompatible with
  extra="forbid")
- Aligned CLI JSON/YAML output structure for automation-profile show
  with the specification grouped format (phase_transitions,
  decision_automation, self_repair, execution_controls)
- Moved safety boolean fields into the Execution Controls section
  of Rich output per spec examples
- Reverted auto profile description to "Fully automatic except apply"
  per specification (line 16703, line 28406)
- Improved bridge comments in test steps with semantic context for
  threshold-to-gate mappings

ISSUES CLOSED: #902
2026-03-30 13:18:07 +01:00
hamza.khyari c97ec273a9 feat(lsp): add missing LspServerConfig model fields
CI / build (pull_request) Successful in 21s
CI / helm (pull_request) Successful in 23s
CI / lint (pull_request) Successful in 26s
CI / quality (pull_request) Successful in 56s
CI / typecheck (pull_request) Successful in 1m2s
CI / security (pull_request) Successful in 1m7s
CI / integration_tests (pull_request) Successful in 5m51s
CI / unit_tests (pull_request) Successful in 7m29s
CI / docker (pull_request) Successful in 2m13s
CI / coverage (pull_request) Successful in 8m50s
CI / benchmark-publish (pull_request) Has been skipped
CI / e2e_tests (pull_request) Successful in 15m34s
CI / status-check (pull_request) Successful in 2s
CI / benchmark-regression (pull_request) Successful in 59m14s
Add specification-required fields to LspServerConfig:

- description: str (max_length=1000, default='')
- transport: LspTransport enum (stdio/tcp/pipe, default=stdio)
- initialization: dict[str, Any] (LSP initializationOptions, default={})
- workspace_settings: dict[str, Any] (workspace/didChangeConfiguration, default={})

All fields have defaults for backward compatibility with existing
configs. LspTransport enum exported from lsp package.

Tests: 17 Behave scenarios, 5 Robot integration tests.
Existing LSP tests: 250/250 pass unchanged.

ISSUES CLOSED: #835
2026-03-30 11:51:27 +00:00
freemo 9cace15d6e test(e2e): workflow example 18 — container with remote repo clone (trusted profile)
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 20s
CI / typecheck (pull_request) Successful in 47s
CI / quality (pull_request) Successful in 48s
CI / build (pull_request) Successful in 15s
CI / helm (pull_request) Successful in 22s
CI / security (pull_request) Successful in 4m18s
CI / integration_tests (pull_request) Successful in 6m19s
CI / unit_tests (pull_request) Successful in 6m39s
CI / docker (pull_request) Successful in 1m32s
CI / coverage (pull_request) Successful in 12m6s
CI / e2e_tests (pull_request) Successful in 19m6s
CI / status-check (pull_request) Successful in 2s
CI / quality (push) Successful in 45s
CI / build (push) Successful in 17s
CI / helm (push) Successful in 23s
CI / lint (push) Successful in 3m16s
CI / integration_tests (push) Successful in 3m50s
CI / typecheck (push) Successful in 3m54s
CI / security (push) Successful in 4m4s
CI / unit_tests (push) Successful in 8m31s
CI / docker (push) Successful in 1m22s
CI / coverage (push) Successful in 12m12s
CI / benchmark-regression (push) Has been skipped
CI / e2e_tests (push) Successful in 21m14s
CI / status-check (push) Successful in 2s
CI / benchmark-publish (push) Has been cancelled
CI / benchmark-regression (pull_request) Successful in 59m1s
E2E test for Specification Workflow Example 18: Container with Remote
Repo Clone using the trusted automation profile.  Exercises the full
container-instance workflow per the spec:

- Registers a container-instance resource with --clone-into flag (new
  CLI flag added to resource add for REPO_URL:CONTAINER_PATH).
- Two-step project creation: project create + project link-resource.
- Dynamic LLM actor selection (Anthropic/OpenAI) matching available
  API keys.
- Plan use with --execution-environment container,
  --execution-env-priority fallback, and --automation-profile trusted.
- Full plan lifecycle: strategize, execute, diff, apply, status.
- Positive assertions: non-empty output, plan ID presence, terminal
  state verification, container/clone evidence logging.
- Negative assertions: Traceback and INTERNAL error checks.
- ULID regex uses Crockford base32 character set.
- Unique suffix for resource/project names (parallel CI safe).
- Skip If No LLM Keys guard for graceful degradation.
- CHANGELOG.md updated.

ISSUES CLOSED: #764
2026-03-30 19:17:41 +08:00
hurui200320 b6c3169634 test(e2e): workflow example 16 — devcontainer-driven development (supervised profile)
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 28s
CI / quality (pull_request) Successful in 32s
CI / security (pull_request) Successful in 58s
CI / build (pull_request) Successful in 14s
CI / helm (pull_request) Successful in 22s
CI / typecheck (pull_request) Successful in 3m54s
CI / unit_tests (pull_request) Successful in 4m9s
CI / integration_tests (pull_request) Successful in 7m12s
CI / docker (pull_request) Successful in 22s
CI / e2e_tests (pull_request) Successful in 14m37s
CI / coverage (pull_request) Successful in 10m11s
CI / status-check (pull_request) Successful in 1s
CI / lint (push) Successful in 16s
CI / build (push) Successful in 15s
CI / helm (push) Successful in 22s
CI / typecheck (push) Successful in 3m53s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 4m5s
CI / quality (push) Successful in 3m41s
CI / unit_tests (push) Successful in 7m15s
CI / integration_tests (push) Successful in 7m34s
CI / docker (push) Successful in 1m41s
CI / e2e_tests (push) Successful in 16m45s
CI / coverage (push) Successful in 11m54s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Has been cancelled
CI / benchmark-regression (pull_request) Successful in 1h5m26s
Implements E2E test for devcontainer-driven development workflow.
Tests project setup with .devcontainer config, resource registration,
and full plan lifecycle with supervised automation profile.

Changes from Cycle 5 review:

1. Replaced custom WF16_ALLOW_XFAIL_SKIP escape hatch with the project
   standard tdd_expected_fail tag system. Test is now tagged
   [Tags] tdd_expected_fail tdd_bug tdd_bug_762 and the listener
   inverts failures in CI until devcontainer features are fully wired.

2. Added diagnostic WF16 Test Teardown keyword that captures plan
   status JSON on failure, mirroring the WF05 teardown pattern.

3. Added stderr checks to all Traceback/INTERNAL guard assertions
   so tracebacks appearing only in stderr are also detected.

4. Rebased branch onto latest master (e4c01492).

5. Documented timeout budget: added comment explaining theoretical
   worst-case (~46min) vs realistic execution under the 35min limit.

6. Added fail-fast warning in AC-3 check noting that AC-4, AC-5, and
   AC-6 are dependent on AC-3 and are likely to also fail.

7. Reordered plan apply arguments to --yes --format json <plan_id>
   for spec consistency.

8. Decomposed long ready_for_apply Evaluate expression into three
   intermediate booleans (is_apply_phase, is_execute_complete,
   is_already_applied) for readability.

9. Added shared_session.close() calls in resource_dag.robot before
   each final print() to ensure explicit session cleanup.

10. Cleaned up stale xfail/skip classification references in log
    messages.

Changes from earlier cycles (3-4) retained in this commit:

- Terminal state validation, AC output combination, JSON format flags,
  suite-level init, Force Tags, automation profile fallback, ULID regex
  IGNORECASE, AC-5 Evaluate decomposition, defensive re-check pattern.

ISSUES CLOSED: #762
2026-03-30 18:45:10 +08:00
aditya 4e64544aae feat(acms): projects with 10,000+ files index without timeout
CI / benchmark-publish (pull_request) Has been skipped
CI / quality (pull_request) Successful in 48s
CI / build (pull_request) Successful in 31s
CI / helm (pull_request) Successful in 21s
CI / lint (pull_request) Successful in 3m15s
CI / typecheck (pull_request) Successful in 4m4s
CI / security (pull_request) Successful in 4m13s
CI / unit_tests (pull_request) Successful in 4m28s
CI / docker (pull_request) Successful in 1m52s
CI / integration_tests (pull_request) Successful in 7m14s
CI / coverage (pull_request) Successful in 12m49s
CI / e2e_tests (pull_request) Successful in 22m8s
CI / status-check (pull_request) Successful in 2s
CI / benchmark-regression (pull_request) Successful in 57m27s
Add explicit indexing timeout bounds and propagate timeout_seconds through the repo indexing service, utility walker, and CLI entrypoint so large repositories fail predictably instead of hanging.

Add 10K-scale Behave/Robot verification and a dedicated benchmark path to validate that large-project indexing completes, persists status correctly, and remains measurable for regressions.

Address review feedback by splitting oversized Behave and Robot support files into focused modules, trimming repo_indexing_service.py back under the 500-line limit, and rebasing the branch onto current master.

ISSUES CLOSED: #851

# Conflicts:
#	CHANGELOG.md
#	robot/helper_m5_e2e_verification.py
2026-03-30 10:18:19 +00:00
aditya ef8f9640fa feat(acms): context analysis produces meaningful summaries
CI / lint (pull_request) Successful in 30s
CI / typecheck (pull_request) Successful in 1m7s
CI / quality (pull_request) Successful in 46s
CI / security (pull_request) Successful in 1m0s
CI / build (pull_request) Successful in 23s
CI / helm (pull_request) Successful in 41s
CI / integration_tests (pull_request) Successful in 4m11s
CI / unit_tests (pull_request) Successful in 4m38s
CI / docker (pull_request) Successful in 1m22s
CI / coverage (pull_request) Successful in 11m26s
CI / e2e_tests (pull_request) Successful in 18m21s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 58m2s
Add phase-wise context analysis summaries for strategize, execute, and apply, and integrate them into `agents project context inspect` and `agents project context simulate` with per-phase resource counts, size and token utilization, and narrowing diagnostics.\n\nAdd Behave and Robot coverage for empty, single-resource, multi-resource, and budget-constrained context analysis, and tighten the M5 smoke coverage after review feedback with exact summary assertions and a missing-path regression scenario for `agents context add`.\n\nISSUES CLOSED: #849
2026-03-30 08:42:48 +00:00
hurui200320 5ddc04bcc7 test(e2e): workflow example 17 — explicit container with directory mount (trusted profile)
CI / lint (pull_request) Successful in 25s
CI / typecheck (pull_request) Successful in 54s
CI / quality (pull_request) Successful in 58s
CI / security (pull_request) Successful in 1m4s
CI / build (pull_request) Successful in 38s
CI / helm (pull_request) Successful in 38s
CI / integration_tests (pull_request) Successful in 4m5s
CI / unit_tests (pull_request) Successful in 4m51s
CI / docker (pull_request) Successful in 21s
CI / coverage (pull_request) Successful in 9m53s
CI / e2e_tests (pull_request) Successful in 16m45s
CI / status-check (pull_request) Successful in 2s
CI / benchmark-publish (pull_request) Has been skipped
CI / security (push) Successful in 59s
CI / lint (push) Successful in 3m17s
CI / typecheck (push) Successful in 3m57s
CI / build (push) Successful in 19s
CI / helm (push) Successful in 38s
CI / quality (push) Successful in 3m52s
CI / unit_tests (push) Successful in 4m31s
CI / integration_tests (push) Successful in 3m57s
CI / docker (push) Successful in 11s
CI / coverage (push) Successful in 8m55s
CI / e2e_tests (push) Successful in 16m11s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Has been cancelled
CI / benchmark-regression (push) Has been cancelled
CI / benchmark-regression (pull_request) Successful in 1h0m36s
Implements E2E test for Specification WF17: Explicit Container with
Directory Mount.  The test exercises the full workflow from the spec:

- Registers git-checkout resource and container-instance resource
  (with --image flag; --mount not yet available on CLI)
- Creates project, links both resources via project link-resource
- Sets execution environment to container via project context set
- Uses --execution-env-priority override on plan use (per ADR-043)
- Creates action with dynamically selected actor (Anthropic or OpenAI)
- Runs full plan lifecycle: use → strategize → execute → diff → apply → status
- Uses trusted automation profile for auto-execution of tool invocations

Quality improvements over initial implementation:
- Custom suite setup with workspace init (agents init --force --yes)
- UUID-based unique suffix for resource/project names (CI parallelism)
- Dynamic actor selection matching available API keys (M6 pattern)
- Skip If No LLM Keys guard for graceful degradation
- Crockford Base32 ULID regex ([0-9A-HJ-NP-Z]{26})
- Checked return codes on all git subprocess calls
- INTERNAL error checks alongside Traceback checks
- --format json on all CLI commands for deterministic output
- Domain-specific assertions for plan output verification
- Diff output non-empty assertion
- Security note documenting trusted profile auto-execution decision
- CHANGELOG entry added

ISSUES CLOSED: #763
2026-03-30 08:05:41 +00:00
hurui200320 d24959e961 test(e2e): workflow example 12 — large-scale hierarchical feature implementation (supervised profile)
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 30s
CI / typecheck (pull_request) Successful in 1m9s
CI / security (pull_request) Successful in 1m27s
CI / quality (pull_request) Successful in 43s
CI / build (pull_request) Successful in 26s
CI / helm (pull_request) Successful in 36s
CI / integration_tests (pull_request) Successful in 4m18s
CI / unit_tests (pull_request) Successful in 4m25s
CI / coverage (pull_request) Successful in 11m47s
CI / e2e_tests (pull_request) Successful in 13m21s
CI / docker (pull_request) Successful in 16s
CI / status-check (pull_request) Successful in 2s
CI / lint (push) Successful in 22s
CI / security (push) Successful in 50s
CI / build (push) Successful in 18s
CI / helm (push) Successful in 40s
CI / quality (push) Successful in 3m41s
CI / typecheck (push) Successful in 4m0s
CI / integration_tests (push) Successful in 4m19s
CI / unit_tests (push) Successful in 4m31s
CI / docker (push) Successful in 11s
CI / e2e_tests (push) Successful in 14m3s
CI / coverage (push) Successful in 11m50s
CI / status-check (push) Successful in 1s
CI / benchmark-regression (pull_request) Successful in 1h3m16s
CI / benchmark-regression (push) Has been skipped
CI / benchmark-publish (push) Successful in 32m26s
Implements E2E test for Workflow Example 12: large-scale hierarchical
feature implementation with the supervised automation profile.

Key test behaviors:
- Sets up 4 projects (protos, api, worker, frontend) with per-project
  invariants, matching the specification.
- Creates action YAML with spec-required fields: estimation_actor,
  invariant_actor, automation_profile: cautious, and action-level
  invariants.
- Passes all 4 projects to plan use (spec Step 3).
- Dynamically selects actor based on available API key (Anthropic or
  OpenAI) for flexible CI/local execution.
- Uses Skip If No LLM Keys for graceful degradation in keyless CI.
- Verifies hierarchical decomposition via plan tree (decision_id count,
  children field check).
- Selects a non-root decision for plan correct --mode append to
  exercise targeted correction rather than root invalidation.
- Verifies correction acknowledgment via output content assertions.
- Verifies phased lifecycle-apply with --yes flag and phase field
  parsing.
- Final status uses --format json with Safe Parse Json Field to verify
  terminal state (phase and processing_state populated).
- UUID-suffixed names prevent UNIQUE constraint collisions in parallel CI.
- Crockford Base32 ULID regex (excludes I, L, O, U) consistent with
  m1_acceptance.robot.
- All commands check for Traceback and INTERNAL error markers.
- Force Tags E2E in Settings (m6 convention).
- Timeout set to 35 minutes for real LLM execution headroom.

Note: plan prompt (spec Step 4 — supervised-profile user intervention)
is not yet implemented as a CLI command. A documentation note in the
test indicates this should be added once the command is available.

ISSUES CLOSED: #758
2026-03-30 13:46:21 +08:00
hurui200320 2651e15854 fix(cli): replace non-existent Container.resolve() with named provider calls
CI / benchmark-publish (pull_request) Has been skipped
CI / security (pull_request) Successful in 59s
CI / quality (pull_request) Successful in 37s
CI / lint (pull_request) Successful in 3m35s
CI / build (pull_request) Successful in 22s
CI / helm (pull_request) Successful in 35s
CI / typecheck (pull_request) Successful in 4m25s
CI / unit_tests (pull_request) Successful in 4m19s
CI / integration_tests (pull_request) Successful in 4m1s
CI / docker (pull_request) Successful in 11s
CI / e2e_tests (pull_request) Successful in 10m42s
CI / coverage (pull_request) Successful in 9m42s
CI / status-check (pull_request) Successful in 2s
CI / lint (push) Successful in 23s
CI / typecheck (push) Successful in 50s
CI / quality (push) Successful in 53s
CI / security (push) Successful in 1m2s
CI / benchmark-regression (push) Has been skipped
CI / build (push) Successful in 40s
CI / helm (push) Successful in 43s
CI / integration_tests (push) Successful in 4m29s
CI / unit_tests (push) Successful in 5m7s
CI / docker (push) Successful in 1m20s
CI / e2e_tests (push) Successful in 11m58s
CI / coverage (push) Successful in 14m35s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Successful in 33m38s
CI / benchmark-regression (pull_request) Successful in 1h2m19s
The three plan.py call sites (tree, explain, correct) that originally used
container.resolve(DecisionService) were already fixed in master. This commit
completes the fix by aligning the Robot Framework test mocks to match the
corrected production code:

- robot/helper_m3_decision_validation_smoke.py: mock_container.resolve →
  mock_container.decision_service (plan correct dry-run path)
- robot/helper_m4_correction_subplan_smoke.py: container.resolve →
  container.decision_service (correction subplan path)

Both helpers previously passed silently because MagicMock auto-creates any
attribute, masking the mismatch between mock setup and actual code. Added
spec=Container to both mock containers so that accessing non-existent
attributes raises AttributeError, matching real container behavior.

Updated comment wording in features/container_resolve_crash.feature to
clarify that the bug is fixed and the scenarios serve as permanent
regression guards. The @tdd_expected_fail tag was already removed by the
TDD branch before this fix branch was created; the permanent @tdd_issue
and @tdd_issue_647 tags remain per TDD tag lifecycle rules.

Added CHANGELOG.md entry describing the fix.

ISSUES CLOSED: #647
2026-03-30 04:45:56 +00:00
freemo 845cf61b47 test(e2e): workflow example 4 — multi-project dependency update (supervised profile)
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 38s
CI / security (pull_request) Successful in 1m17s
CI / build (pull_request) Successful in 25s
CI / helm (pull_request) Successful in 37s
CI / quality (pull_request) Successful in 3m43s
CI / typecheck (pull_request) Successful in 3m58s
CI / integration_tests (pull_request) Successful in 6m4s
CI / unit_tests (pull_request) Successful in 6m22s
CI / docker (pull_request) Successful in 21s
CI / e2e_tests (pull_request) Successful in 9m29s
CI / coverage (pull_request) Successful in 9m12s
CI / status-check (pull_request) Successful in 1s
CI / lint (push) Successful in 31s
CI / security (push) Successful in 55s
CI / build (push) Successful in 21s
CI / helm (push) Successful in 22s
CI / quality (push) Successful in 3m45s
CI / typecheck (push) Successful in 3m56s
CI / benchmark-regression (push) Has been skipped
CI / unit_tests (push) Successful in 6m46s
CI / integration_tests (push) Successful in 6m25s
CI / docker (push) Successful in 1m20s
CI / e2e_tests (push) Successful in 9m57s
CI / coverage (push) Successful in 10m50s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Successful in 29m50s
CI / benchmark-regression (pull_request) Successful in 56m29s
Implement WF04 E2E test coverage for multi-project dependency update
using the supervised automation profile. A parent plan targets four
projects (common-lib + 3 services), spawns child subplans per project,
executes in dependency order, validates per project, and applies in
dependency order.

Key components:
- Robot test (robot/e2e/wf04_multi_project.robot): full supervised
  workflow exercising plan use, strategize, execute, validate, apply,
  and final status. JSON output parsing via raw_decode for resilience.
  Test-level guard skips the entire test (visible SKIPPED in CI) when
  the LLM produces zero subplans, preventing silent AC-4/5/6/7 bypass.
  Count Decision Nodes keyword delegates to the Python helper to avoid
  duplicating recursive tree-walking logic.
- Snapshot helper (robot/e2e/wf04_snapshot_helper.py): collects
  deterministic parent/subplan metadata from the lifecycle service.
  Timestamps normalised to UTC. Depth-guarded count_decision_nodes()
  function (max_depth=50) for safe reuse from Robot keywords.
  sys.path.append (not insert) to avoid shadowing the standard library.
- Behave unit tests (features/wf04_snapshot_helper.feature + steps):
  17 scenarios covering _iso(), _enum_value(), count_decision_nodes(),
  and _build_snapshot() with mocked lifecycle service. Includes tests
  for no-subplans (verifies plan_id, project_scopes, validation_summary),
  with-subplans (verifies concrete mapped project names and subplan_count),
  child-plan-is-None (verifies empty-string defaults), unmapped resources,
  and exact-match aware-datetime UTC normalisation.

ISSUES CLOSED: #750
2026-03-30 11:47:37 +08:00
Luis Mendes 7f078f75a5 fix(sandbox): make commit_all atomic per specification
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 28s
CI / security (pull_request) Successful in 1m8s
CI / build (pull_request) Successful in 20s
CI / helm (pull_request) Successful in 34s
CI / quality (pull_request) Successful in 3m53s
CI / integration_tests (pull_request) Successful in 4m2s
CI / typecheck (pull_request) Successful in 4m9s
CI / unit_tests (pull_request) Successful in 4m48s
CI / docker (pull_request) Successful in 1m19s
CI / e2e_tests (pull_request) Successful in 9m47s
CI / coverage (pull_request) Successful in 11m41s
CI / status-check (pull_request) Successful in 1s
CI / quality (push) Successful in 52s
CI / lint (push) Successful in 3m18s
CI / build (push) Successful in 20s
CI / typecheck (push) Successful in 3m56s
CI / helm (push) Successful in 22s
CI / security (push) Successful in 4m15s
CI / unit_tests (push) Successful in 4m39s
CI / docker (push) Successful in 18s
CI / integration_tests (push) Successful in 6m56s
CI / e2e_tests (push) Successful in 12m34s
CI / coverage (push) Successful in 11m39s
CI / status-check (push) Successful in 1s
CI / benchmark-regression (push) Has been skipped
CI / benchmark-publish (push) Successful in 30m10s
CI / benchmark-regression (pull_request) Successful in 57m33s
Changed SandboxManager.commit_all() from partial-commit semantics to
all-or-nothing atomic operation per specification requirement. On
partial failure, already-committed sandboxes are rolled back. Error
reporting indicates which sandbox failed and what was rolled back.
Added Behave scenarios verifying atomicity guarantee.

Hardened atomicity guarantees after code review:

- commit_all and _rollback_committed catch Exception (not just
  SandboxError) so unexpected errors cannot bypass rollback.
  Non-SandboxError exceptions are wrapped in a new AtomicCommitError
  (chaining the original as __cause__) that carries rolled_back_ids
  and failed_rollback_ids attributes so callers can programmatically
  determine rollback outcomes.

- _rollback_committed returns both rolled_back_ids and
  failed_rollback_ids; the error result metadata now carries
  both "rolled_back" and "rollback_failed" keys.

- _rollback_committed iterates in reverse (LIFO) order following
  the standard transaction-log undo pattern.  Clarified in
  docstring that this is distinct from the specification DAG-based
  "top-down" rollback ordering (line 24632).

- TransactionSandbox.rollback() from COMMITTED now raises
  SandboxRollbackError (database commits are irreversible)
  instead of silently transitioning to ROLLED_BACK.

- TransactionSandbox is now classified as non-rollbackable in
  commit_all alongside NoSandbox and committed last in the batch,
  since database COMMIT is irreversible.  Docstring corrected to
  match the raising behavior.

- CopyOnWriteSandbox and OverlaySandbox rollback-from-COMMITTED
  uses rename-based safe_restore() to prevent data loss when
  the copytree step fails after the original was removed.

- CopyOnWriteSandbox and OverlaySandbox rollback() now catches
  Exception (not just OSError), matching the broader catch used
  in _rollback_committed, so non-OSError exceptions from
  safe_restore set the status to ERRORED correctly.

- Extracted shared _fs_utils module (backup_directory,
  safe_restore, compute_diff) with symlink, permission, and
  timestamp preservation (including directory timestamps),
  replacing duplicated per-class _backup_directory and
  _compute_diff methods.

- backup_directory defers directory permissions and timestamps
  to a bottom-up post-walk pass, fixing incorrect mtime
  preservation (POSIX file creation inside a directory overwrites
  its mtime) and preventing restrictive source permissions from
  blocking backup writes.

- backup_directory skips non-regular files (FIFOs, sockets,
  device files) with a warning to prevent hangs on special files.

- CopyOnWriteSandbox and OverlaySandbox commit() now attempts
  to restore the original from the pre-commit backup when the
  file-copy phase fails midway, preventing partial corruption.
  If the restore itself fails the backup is preserved for manual
  recovery (cleanup() still removes it).

- CopyOnWriteSandbox and OverlaySandbox commit() error handler
  now catches Exception (not just OSError) so that unexpected
  errors during the file-copy phase also trigger pre-commit
  backup restoration, preventing partial corruption of the
  original directory.

- Pre-commit backup exception handler catches Exception (not
  just OSError) preventing temp directory leaks on non-OSError
  failures from backup_directory.

- Fixed _pre_commit_backup assignment timing: the backup
  reference is now assigned only AFTER backup_directory()
  succeeds, preventing safe_restore() from corrupting an intact
  original with a partial backup when backup_directory() fails
  (e.g. disk full).

- Rollback from COMMITTED with no pre-commit backup (no changes
  were applied) is now a no-op instead of raising
  SandboxRollbackError, preventing false rollback-failure
  reports in commit_all error metadata.

- commit_all logs a warning when NoSandbox or TransactionSandbox
  instances are present in the batch since their changes cannot
  be rolled back, which breaks the atomicity guarantee.

- Pre-commit backup is skipped when compute_diff returns no
  changes, avoiding a full directory copy for no-op commits.

- GitWorktreeSandbox clears _pre_merge_commit on commit failure
  so the stale value cannot be used by future code.

- commit_all docstring documents Raises clause for AtomicCommitError
  exception wrapping behavior.

- GitWorktreeSandbox.rollback() docstring warns about
  multi-worktree safety when rolling back from COMMITTED.

- Updated SandboxStatus transition diagram in protocol.py to
  clearly show the COMMITTED -> ROLLED_BACK path.

- Added spec-contradiction note (line 45938 vs 19193) in
  commit_all docstring.

- OverlaySandbox rollback from COMMITTED now properly remounts
  OverlayFS for real overlay (unmount, clean upper/work dirs,
  remount) and uses dirs_exist_ok=True for userspace fallback
  to prevent FileExistsError if rmtree silently fails.  The
  merged directory is reset from the restored original,
  preventing stale pre-rollback data from being exposed on
  re-activation via get_path() (which allows ROLLED_BACK status).

- OverlaySandbox rollback from COMMITTED now raises
  SandboxRollbackError if the OverlayFS unmount fails,
  preventing a double-mount attempt that would leave the
  sandbox in an inconsistent state.

- OverlaySandbox rollback from ACTIVE now uses dirs_exist_ok=True
  for userspace fallback to prevent FileExistsError when rmtree
  with ignore_errors=True silently fails.

- CopyOnWriteSandbox rollback from ACTIVE now uses
  dirs_exist_ok=True in copytree to prevent FileExistsError
  when rmtree with ignore_errors=True silently fails, matching
  the fix already applied to OverlaySandbox.

- Non-rollbackable sandboxes (NoSandbox, TransactionSandbox) are
  committed last in the batch so that all rollbackable sandboxes
  commit first; if any rollbackable sandbox fails, none of the
  non-rollbackable sandboxes will have committed yet.

- Moved NoSandbox and TransactionSandbox imports to module level
  in manager.py (no circular dependency exists).

- Pre-commit backups are now created on the same filesystem as
  the original directory (using dir= argument to mkdtemp),
  avoiding cross-device copy overhead and ensuring os.rename
  compatibility.

- safe_restore now renames the target into the mkdtemp directory
  instead of removing the mkdtemp dir first, eliminating the
  residual TOCTOU window between rmdir and rename.

- safe_restore catches BaseException (not just OSError) to
  ensure the original directory is always renamed back on
  unexpected errors, preventing the original from being left
  in the renamed-aside state.

- Added AtomicCommitError exception class to protocol.py
  carrying rolled_back_ids and failed_rollback_ids attributes.

- Exported AtomicCommitError from sandbox package __init__.py
  so callers can import it from the public API.

- Added BDD scenarios: LIFO rollback order, AtomicCommitError
  wrapping with RuntimeError cause and rollback metadata,
  _fs_utils backup/restore coverage, no-change commit rollback
  success, directory timestamp preservation, OverlaySandbox
  merged dir reset after COMMITTED rollback,
  CopyOnWriteSandbox rollback from COMMITTED restores original,
  GitWorktreeSandbox rollback from COMMITTED undoes merge,
  TransactionSandbox rollback from COMMITTED raises
  SandboxRollbackError about irreversible commit.

ISSUES CLOSED: #925

Post-review hardening (PR #1146 review findings):

- OverlaySandbox rollback from COMMITTED with no backup (no-op)
  now skips the merged directory reset entirely, preventing
  unnecessary unmount/remount or re-copy that could fail and
  turn a harmless no-op rollback into a SandboxRollbackError
  during commit_all atomic recovery.

- OverlaySandbox rollback no longer double-wraps
  SandboxRollbackError: the outer except Exception handler
  now has a preceding except SandboxRollbackError clause that
  re-raises directly, avoiding a confusing double-wrapped
  error chain.

- CopyOnWriteSandbox.get_path() now accepts ROLLED_BACK status
  for consistency with OverlaySandbox and the protocol status
  transition table (ROLLED_BACK -> ACTIVE).

- CopyOnWriteSandbox rollback from COMMITTED now resets the
  sandbox copy from the restored original via rmtree+copytree,
  preventing stale pre-rollback modifications from being
  exposed on re-activation.

- rollback_all now catches Exception (not just SandboxError)
  so that unexpected rollback errors do not prevent remaining
  sandboxes from being rolled back, consistent with the pattern
  already used in _rollback_committed.

- commit_all docstring now documents a thread-safety warning:
  the method is not safe for concurrent calls on the same
  plan_id since sandbox commit/rollback runs outside the lock.

- Fixed CHANGELOG.md whitespace inconsistencies (double leading
  spaces on two lines).

Post-review hardening round 2 (PR #1146 automated review):

- safe_restore now uses os.rename (O(1) atomic rename) instead
  of shutil.copytree (O(n) recursive copy) for the main restore
  path, since backup and target are always on the same
  filesystem.  This eliminates the ENOTEMPTY bug where a partial
  copytree failure left target_path partially populated, causing
  the recovery os.rename to fail and strand the original in the
  stale temp directory.

- OverlaySandbox.get_path() now transitions ROLLED_BACK to
  ACTIVE, matching CopyOnWriteSandbox and the protocol
  transition table (ROLLED_BACK -> ACTIVE).

- GitWorktreeSandbox.get_path() now accepts ROLLED_BACK status
  for consistency with all other sandbox implementations and
  the protocol transition table (ROLLED_BACK -> ACTIVE).

- rollback_all now also handles sandboxes in COMMITTED status
  (not just ACTIVE), consistent with the state machine allowing
  COMMITTED -> ROLLED_BACK.

- cleanup_all now catches Exception (not just SandboxError) so
  a single unexpected error does not abort cleanup of remaining
  sandboxes, consistent with _rollback_committed and
  rollback_all.

- Restructured CHANGELOG entry from a single ~90-line paragraph
  into structured sub-bullets for readability.

- Added BDD scenarios: no-op rollback from COMMITTED for
  CopyOnWriteSandbox and OverlaySandbox (zero-change commit),
  commit ordering verification (rollbackable before
  non-rollbackable).

Post-review hardening round 3 (PR #1146 deep automated review):

- cleanup_abandoned now catches Exception (not just SandboxError)
  so that unexpected errors (e.g. raw OSError, PermissionError)
  do not crash the loop and prevent remaining abandoned sandboxes
  from being cleaned up, consistent with cleanup_all,
  rollback_all, and _rollback_committed.

- OverlaySandbox._mount_overlay() now catches
  subprocess.TimeoutExpired (in addition to CalledProcessError
  and OSError), preventing create() from leaving the sandbox in
  PENDING status when mount hangs beyond the timeout.

- OverlaySandbox._unmount_overlay() now catches
  subprocess.TimeoutExpired (in addition to CalledProcessError
  and OSError), preventing cleanup() from leaving the sandbox
  in a zombie state when umount hangs beyond the timeout.

- OverlaySandbox._mount_overlay() validates that overlay paths
  do not contain commas, which would corrupt the OverlayFS mount
  options string (comma is the mount option delimiter).

- GitWorktreeSandbox.commit() now checks git diff return code
  so that a failed diff command raises CalledProcessError instead
  of silently concluding there are no changes and skipping the
  merge.

- safe_restore cleanup of the temporary rollback container now
  runs in a finally block, preventing a temp directory leak
  when the rename fails and the exception is re-raised.

- Fixed misleading BDD step name: "backup path that will cause
  copytree to fail" renamed to "backup path that will cause
  rename to fail" since safe_restore now uses os.rename.
2026-03-29 18:57:15 +01:00
Luis Mendes f678d611bb feat(db): add correction_attempts table per specification DDL
CI / benchmark-publish (pull_request) Has been skipped
CI / typecheck (pull_request) Successful in 58s
CI / quality (pull_request) Successful in 57s
CI / security (pull_request) Successful in 1m3s
CI / build (pull_request) Successful in 25s
CI / helm (pull_request) Successful in 34s
CI / lint (pull_request) Successful in 3m20s
CI / integration_tests (pull_request) Successful in 4m2s
CI / unit_tests (pull_request) Successful in 4m27s
CI / docker (pull_request) Successful in 1m18s
CI / coverage (pull_request) Successful in 8m39s
CI / e2e_tests (pull_request) Successful in 12m37s
CI / status-check (pull_request) Successful in 1s
CI / typecheck (push) Successful in 47s
CI / lint (push) Successful in 3m16s
CI / security (push) Successful in 4m7s
CI / quality (push) Successful in 3m46s
CI / build (push) Successful in 21s
CI / helm (push) Successful in 24s
CI / unit_tests (push) Successful in 4m19s
CI / integration_tests (push) Successful in 3m55s
CI / docker (push) Successful in 1m19s
CI / e2e_tests (push) Successful in 12m30s
CI / coverage (push) Successful in 11m48s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Successful in 29m36s
CI / benchmark-regression (push) Has been skipped
CI / benchmark-regression (pull_request) Successful in 56m32s
Added CorrectionAttemptModel SQLAlchemy model with all spec-defined columns
(correction_attempt_id, plan_id, original_decision_id, new_decision_id,
mode, guidance, archived_artifacts_path, state, created_at, completed_at).
Added FK constraints to v3_plans and decisions tables. Created Alembic
migration and idx_corrections_plan index. Added repository layer for
CRUD operations.

Addressed code review feedback (rounds 1-12):
- Replaced Any type annotations with typed CorrectionAttemptRecord
  signatures using TYPE_CHECKING imports.
- Replaced fragile time.sleep with deterministic timestamps.
- Added cascade deletion test with PRAGMA foreign_keys=ON.
- Changed update_state() to accept typed enum and datetime params.
- Added guidance non-empty validator with max_length=10_000.
- Added spec-aligned server_default for created_at column.
- Fixed timezone handling in to_domain() and from_domain().
- Added spec-defined lifecycle state transition validation via
  validate_correction_state_transition() domain function.
- Improved FK-violation error messages in create() and update_state().
- Normalised timestamp to millisecond precision matching SQLite
  server_default strftime('%f') output.
- Added auto-set completed_at on terminal transitions.
- Added CorrectionAttemptRecord field validators (strip, non-empty).
- Changed original_decision_id FK from CASCADE to RESTRICT matching
  spec DDL default, preserving correction audit trail.
- Added input validation in update_state() for new_decision_id and
  archived_artifacts_path (empty/whitespace rejection).
- Fixed dirty-session bug by moving validation before ORM mutations.
- Extracted _SQLITE_TIMESTAMP_MS_LEN constant for timestamp truncation.

Addressed thirteenth code review feedback:
- Changed InvalidCorrectionStateTransitionError base class from
  DatabaseError to BusinessRuleViolation per CONTRIBUTING.md exception
  semantics (state transition is a business rule, not a database error;
  prevents incorrect retries by @database_retry decorator).
- Changed new_decision_id FK from SET NULL to RESTRICT matching the
  spec DDL default (no ON DELETE clause) and consistent with the
  RESTRICT approach used for original_decision_id.
- Changed update_state() input validation for new_decision_id and
  archived_artifacts_path from DatabaseError to ValueError per
  CONTRIBUTING.md argument validation guidelines.
- Defensive to_domain() coercion now defaults corrupted state to
  'failed' (terminal) instead of 'pending', preventing re-execution
  of completed/failed corrections with corrupted DB values.
- Extracted format_sqlite_timestamp() helper and SQLITE_TIMESTAMP_MS_LEN
  public constant, removing duplicated timestamp formatting logic
  between from_domain() and update_state().
- Added code comment explaining CASCADE on plan_id FK as a codebase
  convention deviation from spec DDL default.
- Added BDD scenario verifying RESTRICT FK on original_decision_id
  blocks decision deletion.
- Replaced weak cross-plan isolation test with stronger two-plan
  scenario verifying list_by_plan returns only each plan's attempts.
- Fixed hardcoded assertion in step_check_archived_path to use
  context variable.
- 45 BDD scenarios and 5 Robot integration tests.

Addressed fourteenth code review feedback:
- Added ORM-level relationship(cascade="all, delete-orphan") on
  LifecyclePlanModel for CorrectionAttemptModel, consistent with all
  other v3_plans child tables, ensuring ORM-level cascade deletes
  work even when SQLite FK enforcement is disabled.
- Added defensive to_domain() coercion for corrupted guidance column
  (defaults to "[corrupted]" with warning log), consistent with
  existing mode/state coercion pattern.
- Added ValueError guard in format_sqlite_timestamp() rejecting naive
  datetimes per CONTRIBUTING.md fail-fast argument validation.
- Fixed stale spec DDL line reference in CorrectionAttemptModel
  docstring.
- Fixed duplicated docstring on SQLITE_TIMESTAMP_MS_LEN constant.

Addressed fifteenth code review feedback:
- Fixed update_state() to defensively handle corrupted DB state values
  via try/except ValueError coercion to FAILED terminal state with
  warning log, consistent with to_domain() defensive coercion pattern.
- Strengthened RESTRICT FK BDD assertion to verify exception type
  (IntegrityError/DatabaseError) instead of only checking presence.
- Split multi-When/Then cross-plan isolation BDD scenario into
  idiomatic single-When/Then scenarios per Gherkin best practice.
- 53 BDD scenarios (was 45) and 5 Robot integration tests.

ISSUES CLOSED: #920
2026-03-29 16:23:04 +01:00
brent.edwards 3abf25f17f test: add TDD bug-capture test for #1038 — validation add --required flag (#1133)
CI / lint (push) Successful in 3m28s
CI / typecheck (push) Successful in 3m57s
CI / security (push) Successful in 4m16s
CI / build (push) Successful in 28s
CI / helm (push) Successful in 35s
CI / quality (push) Successful in 3m43s
CI / unit_tests (push) Successful in 7m23s
CI / integration_tests (push) Successful in 7m5s
CI / docker (push) Successful in 1m33s
CI / e2e_tests (push) Successful in 12m39s
CI / coverage (push) Successful in 11m56s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Successful in 33m10s
CI / benchmark-regression (push) Has been skipped
## Summary

Adds TDD bug-capture tests for bug #1038 — the `agents validation add` command is missing `--required`/`--informational` flags that the specification describes at line 22334 and in numerous walkthrough examples.

### Behave BDD Tests

Four Behave BDD scenarios verify the correct expected behavior:

1. **`--required` flag is accepted** — invokes `validation add --config <file> --required` and asserts exit code 0 and mode `"required"` in output.
2. **`--informational` flag is accepted** — same pattern with `--informational`.
3. **`--required` overrides YAML config mode** — creates a YAML config with `mode: informational`, invokes with `--required`, and asserts the CLI output and service layer both reflect `mode: "required"`.
4. **`--informational` overrides YAML config mode** — creates a YAML config with `mode: required`, invokes with `--informational`, and asserts the CLI output and service layer both reflect `mode: "informational"`.

### Robot Framework Integration Tests

Four Robot Framework integration tests exercise the same CLI paths as the Behave scenarios via a subprocess helper script:

1. **TDD Validation Add Required Flag Accepted** — verifies `--required` is recognised by the CLI.
2. **TDD Validation Add Informational Flag Accepted** — verifies `--informational` is recognised.
3. **TDD Validation Add Required Flag Overrides YAML Config** — verifies `--required` overrides a YAML config with `mode: informational`.
4. **TDD Validation Add Informational Flag Overrides YAML Config** — verifies `--informational` overrides a YAML config with `mode: required`.

The helper script (`robot/helper_tdd_validation_required_flag.py`) uses `typer.testing.CliRunner` with mocked services, following the same pattern as other TDD Robot helpers (e.g., `helper_tdd_plan_apply_yes_flag.py`).

### Tags

All scenarios (Behave and Robot) are tagged `@tdd_bug @tdd_bug_1038 @tdd_expected_fail`. Because the bug is still present, the underlying assertions fail (proving the bug exists) and the `@tdd_expected_fail` tag inverts the result so CI passes. Once bug #1038 is fixed, the tag must be removed.

### Spec Contradiction Note

Rui Hu's investigation (issue #1038 comment #70755) found that the formal CLI reference (specification.md lines 9279–9290) does NOT include `--required`/`--informational` flags — they appear only in walkthrough examples and specification.md line 22334. Additionally, specification.md line 30761 states: "For entity registration commands (`actor add`, `skill add`, `tool add`, `validation add`, …), the YAML configuration file is the sole source of truth — the `--config` file fully defines the entity and no CLI override flags are accepted." The resolution may be to add the flags to the CLI OR to clean up the spec. This is documented in both the feature file header and step definition module docstring.

### Key Design Decisions

- **YAML configs use flat `mode` key** — matches what `Validation.from_config()` actually reads (`config.get("mode", "required")`). The specification's Validation Configuration schema (specification.md line 34109) nests mode under a `validation` key, but the current `from_config()` reads a flat top-level `mode` key. A comment in the step definitions documents this discrepancy.
- **Mock uses `side_effect = lambda v: v`** — the `register_tool` mock returns the actual Validation object passed by the CLI, so the CLI output reflects real CLI processing rather than hard-coded mock configuration. This prevents false positives where the mock masks an incomplete fix.
- **False-positive guard** — the Then step verifying mode checks both CLI output (via `f"mode: {expected_mode}"` prefix match) AND `register_tool` call args to prevent the mock from masking an incomplete fix.
- **Robot helper follows established pattern** — uses `typer.testing.CliRunner` with mocked `_get_tool_registry_service`, matching the pattern from `helper_tdd_plan_apply_yes_flag.py`. Reports real outcome (exit 0 + sentinel on bug fixed, exit 1 on bug present) and relies on `tdd_expected_fail_listener` for result inversion.
- **Symmetric override scenarios** — both directions are tested: `--required` overriding informational YAML config, and `--informational` overriding required YAML config.
- **Positional NAME omitted** — the bug report includes a positional NAME argument, but that is a separate spec inconsistency not under test here.
- **Mutual exclusivity deferred** — testing what happens when both `--required` and `--informational` are passed simultaneously is deferred to the bug-fix PR for #1038.

Closes #1102

Reviewed-on: #1133
Reviewed-by: Jeffrey Phillips Freeman <jeffrey.freeman@cleverthis.com>
Co-authored-by: Brent E. Edwards <brent.edwards@cleverthis.com>
Co-committed-by: Brent E. Edwards <brent.edwards@cleverthis.com>
2026-03-28 18:09:27 +00:00
brent.edwards b59100cc6c test: add TDD bug-capture test for #1141 — session create persistence (#1144)
CI / build (push) Successful in 16s
CI / helm (push) Successful in 28s
CI / lint (push) Successful in 3m20s
CI / quality (push) Successful in 3m53s
CI / security (push) Successful in 4m9s
CI / typecheck (push) Successful in 4m15s
CI / benchmark-regression (push) Has been skipped
CI / integration_tests (push) Successful in 6m57s
CI / unit_tests (push) Successful in 7m3s
CI / docker (push) Successful in 1m30s
CI / e2e_tests (push) Successful in 11m37s
CI / coverage (push) Successful in 11m27s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Successful in 27m7s
## Summary

Adds TDD bug-capture coverage for bug #1141 (`session create` -> `session list` lifecycle) on metadata branch `tdd/m3-session-create-persist`.

### What changed

- Added Behave bug-capture feature: `features/tdd_session_create_persist.feature`
  - Required tags: `@tdd_bug @tdd_bug_1141 @tdd_expected_fail`
  - Scenario path: `init --force --yes` -> `session list --format json` -> `session create` -> `session list --format json`
- Added Behave step definitions: `features/steps/tdd_session_create_persist_steps.py`
  - Uses root CLI app (`cleveragents.cli.main:app`) for realistic command routing
  - Asserts expected list totals; underlying assertion intentionally fails while bug is present
- Added Robot E2E bug-capture test: `robot/e2e/e2e_session_create_persist.robot`
  - Required tags: `E2E`, `tdd_expected_fail`, `tdd_bug`, `tdd_bug_1141`
  - Includes explicit in-file note to remove `tdd_expected_fail` when #1141 is fixed
- Updated changelog (`CHANGELOG.md`, Unreleased)

### Notes

- The issue subtask referenced `robot/e2e/e2e_session_lifecycle.robot`, which is not present on current `master`; equivalent E2E coverage is implemented in `robot/e2e/e2e_session_create_persist.robot`.
- The branch was force-updated to remove stale merge-based history and keep an atomic, rebase-clean commit for this issue.

## Quality gates

| Gate | Result |
|---|---|
| `nox -s lint` |  pass |
| `nox -s typecheck` |  pass |
| `nox -s unit_tests -- features/tdd_session_create_persist.feature` |  pass (TDD inversion active; underlying assert fails) |
| `nox -s integration_tests -- robot/e2e/e2e_session_create_persist.robot` |  pass |
| `nox -s e2e_tests` |  pass |
| `nox -s coverage_report` |  pass (97.66173849218832%) |
| `nox` (full default suite) |  pass |

## Related issue

Closes #1142

Reviewed-on: #1144
Reviewed-by: Jeffrey Phillips Freeman <jeffrey.freeman@cleverthis.com>
Co-authored-by: Brent Edwards <brent.edwards@cleverthis.com>
Co-committed-by: Brent Edwards <brent.edwards@cleverthis.com>
2026-03-28 04:34:47 +00:00
brent.edwards 26632f79e9 test: add TDD bug-capture test for #1079 — project context set missing flag (#1130)
CI / build (push) Successful in 18s
CI / helm (push) Successful in 21s
CI / lint (push) Successful in 3m17s
CI / quality (push) Successful in 3m41s
CI / typecheck (push) Successful in 4m3s
CI / security (push) Successful in 4m4s
CI / benchmark-regression (push) Has been skipped
CI / integration_tests (push) Successful in 7m7s
CI / unit_tests (push) Successful in 7m15s
CI / docker (push) Successful in 1m31s
CI / e2e_tests (push) Successful in 12m39s
CI / coverage (push) Successful in 11m32s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Successful in 29m36s
## Summary

This PR adds TDD bug-capture tests for bug #1079 (`project context set` missing `--execution-env-priority` flag). Per the Bug Fix Workflow in CONTRIBUTING.md, the first step in fixing any bug is to write a test that proves the bug exists.

### What was done

- **Behave unit tests** (6 scenarios in `features/project_context_set_exec_env_priority.feature`):
  - `project context set --execution-env-priority override` with `--execution-environment` should succeed and persist
  - `project context set --execution-env-priority fallback` with `--execution-environment` should succeed and persist
  - `--execution-env-priority` without `--execution-environment` should be rejected
  - Default to `fallback` when only `--execution-environment` is specified
  - Invalid `--execution-env-priority` value should be rejected
  - `project context show` should reflect persisted `execution_env_priority` in JSON output

- **Robot integration tests** (3 test cases in `robot/project_context_set_exec_env_priority.robot`):
  - Override acceptance with persistence verification
  - Fallback acceptance with persistence verification
  - Full round-trip persistence check

All tests are tagged `@tdd_bug @tdd_bug_1079 @tdd_expected_fail`. The underlying assertions fail (confirming the bug exists — `--execution-env-priority` is "No such option"), and the `@tdd_expected_fail` tag inverts the result so CI passes.

### Bug confirmed

The `context_set()` function in `cleveragents.cli.commands.project_context` does not accept `execution_env_priority` as a parameter. The specification (§Execution Environment Routing, precedence table) requires this flag at precedence level 2 for project-level execution environment priority control.

### Quality gates

| Gate | Result |
|------|--------|
| `nox -s lint` | PASS |
| `nox -s typecheck` | PASS (0 errors) |
| `nox -s unit_tests` | PASS (12236 scenarios, 0 failed) |
| `nox -s integration_tests` | My 3 tests pass (13 pre-existing failures) |
| `nox -s coverage_report` | PASS (98%, threshold 97%) |

Closes #1100

Reviewed-on: #1130
Reviewed-by: Jeffrey Phillips Freeman <jeffrey.freeman@cleverthis.com>
Co-authored-by: Brent E. Edwards <brent.edwards@cleverthis.com>
Co-committed-by: Brent E. Edwards <brent.edwards@cleverthis.com>
2026-03-28 02:14:55 +00:00
brent.edwards b46a0e6102 feat(plan): implement real revert-mode re-execution from decision point (#1153)
CI / status-check (push) Blocked by required conditions
CI / build (push) Successful in 18s
CI / helm (push) Successful in 31s
CI / lint (push) Successful in 3m29s
CI / typecheck (push) Successful in 3m56s
CI / benchmark-regression (push) Has been skipped
CI / quality (push) Successful in 3m41s
CI / unit_tests (push) Successful in 4m11s
CI / integration_tests (push) Failing after 4m12s
CI / security (push) Successful in 4m38s
CI / docker (push) Successful in 1m32s
CI / coverage (push) Successful in 11m33s
CI / e2e_tests (push) Failing after 23m17s
CI / benchmark-publish (push) Failing after 38m50s
## Summary

Implements the full revert-mode re-execution pipeline from the specification (§ Correction Flow, Revert Mode), enabling `agents plan correct --mode=revert` to truly re-execute from the targeted decision point rather than only logically marking decisions as superseded.

### Changes

- **Resource rollback**: `CorrectionService.execute_revert` now delegates to `CheckpointService.rollback_to_checkpoint` when a decision-aligned checkpoint exists, performing real `git reset --hard` in the sandbox. Gracefully degrades when checkpointing is unavailable.
- **Reasoning rollback**: Extracts `actor_state_ref` from the target decision's `ContextSnapshot` for downstream LangGraph actor restoration.
- **Guidance injection**: Generates a `user_intervention` decision ID for callers to record correction guidance in the decision tree.
- **Phase transition**: Signals that the plan should re-enter Strategize via `phase_transition_target="strategize"` on the result.
- **Model extension**: Added `checkpoint_restored`, `actor_state_ref`, `user_intervention_decision_id`, and `phase_transition_target` fields to `CorrectionResult` with backward-compatible defaults.
- **Dispatch update**: `execute_correction` now accepts and forwards a `decisions` parameter.

### Design Approach

Uses a signal-based architecture: rather than having `CorrectionService` directly manipulate plan state or LangGraph actors, the enhanced `execute_revert` returns signal fields on `CorrectionResult` that downstream consumers use for the full pipeline. This preserves separation of concerns.

### Tests

- **Behave**: 16 new BDD scenarios in `features/revert_re_execution.feature`
- **Robot**: 7 integration tests in `robot/revert_re_execution.robot`
- **Coverage**: 98% (above 97% threshold)

### Quality Gates

| Gate | Status |
|------|--------|
| `nox -s lint` | Pass |
| `nox -s typecheck` | Pass (0 errors) |
| `nox -s unit_tests` | Pass (12376 scenarios, 0 failed) |
| `nox -s integration_tests` | Pass (1631 passed, 3 pre-existing failures #647) |
| `nox -s e2e_tests` | Pass (37 passed) |
| `nox -s coverage_report` | Pass (98%) |

Closes #844

Reviewed-on: #1153
Co-authored-by: Brent E. Edwards <brent.edwards@cleverthis.com>
Co-committed-by: Brent E. Edwards <brent.edwards@cleverthis.com>
2026-03-28 00:57:51 +00:00
brent.edwards efacfd61c3 test: add TDD bug-capture test for #1023 — implicit init requirement (#1113)
CI / build (push) Successful in 17s
CI / helm (push) Successful in 21s
CI / lint (push) Successful in 3m19s
CI / quality (push) Successful in 3m44s
CI / typecheck (push) Successful in 3m56s
CI / benchmark-regression (push) Has been skipped
CI / integration_tests (push) Failing after 3m56s
CI / security (push) Successful in 4m7s
CI / unit_tests (push) Successful in 6m59s
CI / docker (push) Successful in 1m32s
CI / e2e_tests (push) Successful in 12m56s
CI / coverage (push) Successful in 11m39s
CI / status-check (push) Failing after 1s
CI / benchmark-publish (push) Has been cancelled
## Summary

Adds TDD bug-capture tests proving that CLI commands (`resource add`, `project create`) fail in a fresh environment without explicit `agents init`, even when `CLEVERAGENTS_AUTO_APPLY_MIGRATIONS=true` is set.

Bug #1023 reports that `CLEVERAGENTS_AUTO_APPLY_MIGRATIONS=true` triggers schema migrations on an existing database but does NOT create the database file or its parent directory structure, causing `sqlite3.OperationalError: unable to open database file`.

## Changes

### Behave Tests
- `features/tdd_e2e_implicit_init.feature` — Two scenarios tagged `@tdd_expected_fail @tdd_bug @tdd_bug_1023`:
  - `resource add` in a fresh environment without prior init
  - `project create` in a fresh environment without prior init
  - Both scenarios include output content assertions
- `features/steps/tdd_e2e_implicit_init_steps.py` — Step definitions using Typer's CliRunner with real CLI invocation in a pristine temp directory.
  - Env isolation: saves/removes `CLEVERAGENTS_AUTO_APPLY_MIGRATIONS`, `CLEVERAGENTS_DATABASE_URL`, `CLEVERAGENTS_TEST_DATABASE_URL`, `CLEVERAGENTS_HOME`, `BEHAVE_TESTING`, `CLEVERAGENTS_TEMPLATE_DB`, `CLEVERAGENTS_TESTING_USE_MOCK_AI`
  - CliRunner invoked without `catch_exceptions=False` to ensure proper `@tdd_expected_fail` inversion

### Robot Tests
- `robot/tdd_e2e_implicit_init.robot` — Two test cases tagged `tdd_bug tdd_bug_1023 tdd_expected_fail` (listener inverts results while bug is unfixed).
- `robot/helper_tdd_e2e_implicit_init.py` — Helper script exercising CLI in a fresh environment.
  - Env isolation includes `ROBOT_TESTING`, `CLEVERAGENTS_TEMPLATE_DB`, `CLEVERAGENTS_TESTING_USE_MOCK_AI`
  - Env restoration in `finally` block ensures cleanup even on exceptions
  - CliRunner invoked without `catch_exceptions=False` for correct inversion

### Changelog
- Updated `CHANGELOG.md` with entry for this TDD test addition.

## Quality Gates

| Gate | Result |
|------|--------|
| `nox -s lint` | PASS |
| `nox -s typecheck` | PASS (0 errors) |
| `nox -s unit_tests` | PASS (462 features, 12232 scenarios, 0 failed) |
| `nox -s integration_tests` | PASS (pre-existing failures only; our suite correct) |
| `nox -s e2e_tests` | N/A (TDD test only, no E2E suite changes) |
| `nox -s coverage_report` | PASS (98% coverage, threshold 97%) |

Closes #1033

Reviewed-on: #1113
Reviewed-by: Jeffrey Phillips Freeman <jeffrey.freeman@cleverthis.com>
Co-authored-by: Brent Edwards <brent.edwards@cleverthis.com>
Co-committed-by: Brent Edwards <brent.edwards@cleverthis.com>
2026-03-28 00:30:26 +00:00
brent.edwards b51df2ee0f feat(server): add Kubernetes Helm chart for server deployment (#1085)
CI / docker (push) Blocked by required conditions
CI / status-check (push) Blocked by required conditions
CI / build (push) Successful in 20s
CI / helm (push) Successful in 23s
CI / lint (push) Successful in 3m19s
CI / typecheck (push) Successful in 3m57s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 4m5s
CI / integration_tests (push) Successful in 7m25s
CI / unit_tests (push) Failing after 13m18s
CI / quality (push) Failing after 13m19s
CI / e2e_tests (push) Failing after 18m16s
CI / coverage (push) Failing after 19m20s
CI / benchmark-publish (push) Failing after 28m16s
## Summary

This PR adds Kubernetes Helm deployment support for the CleverAgents server.

Closes #928

### What this PR includes

- Helm chart under `k8s/` with Deployment, Service, optional Ingress, ConfigMap,
  ServiceAccount, Secrets, NOTES, and optional Redis subchart configuration.
- Multi-stage `Dockerfile.server` for server runtime deployment.
- Deployment-focused docs in `k8s/README.md`.
- Behave + Robot + benchmark coverage for chart/deployment wiring.

### Review fixes applied (cycle 11 — hurui200320 review #2687)

**Critical fix:**

1. **CI SHA256 checksum verification fixed** — All 3 Helm install blocks (`unit_tests`, `integration_tests`, `helm` jobs) now save the tarball using its original filename (`helm-v3.16.4-linux-amd64.tar.gz`) instead of `helm.tgz`, so the `.sha256sum` file can correctly locate and verify it. This was causing all 3 CI Helm jobs to fail with "No such file or directory".

**Major fixes (test coverage gaps):**

2. **405 Allow header now tested** — The existing "POST to known path returns method not allowed" scenario now asserts that the `Allow: GET` header is present. Added a second 405 scenario testing `POST /live` for broader `_KNOWN_PATHS` coverage (review item #11).
3. **Security-hardening headers now tested** — New scenario "HTTP responses include security-hardening headers" verifies `content-length`, `x-content-type-options: nosniff`, and `cache-control: no-store` headers are present on HTTP responses.
4. **Lifespan warning logging now tested** — New scenario "Unrecognised lifespan message type logs warning and continues" queues `lifespan.startup` → `lifespan.bogus` → `lifespan.shutdown` and verifies: (a) the app completes the lifespan cycle cleanly, (b) a warning is logged mentioning the unrecognised type.

### Review fixes applied (cycle 10)

**Critical/Major fixes (from hurui200320's prior REQUEST_CHANGES):**

1. **Rebased branch onto master** — Removed merge commit per CONTRIBUTING.md rebase-only policy. Clean linear history restored.
2. **Fixed commit message body** — Replaced literal `\n` sequences with actual newlines. `ISSUES CLOSED: #928` footer is now on its own line after a blank separator.
3. **Moved uvicorn import to module top level** — `from uvicorn import run as uvicorn_run` is now at the top of `src/cleveragents/cli/commands/server.py` per Import Guidelines. Updated test mock target from `uvicorn.run` to `cleveragents.cli.commands.server.uvicorn_run`.
4. **Added SHA256 checksum verification** — All three Helm CLI install blocks in `.forgejo/workflows/ci.yml` now download and verify `helm.sha256sum` before extracting the binary.

**Minor fixes:**

5. **Added `Dockerfile.server` build to CI** — New "Build Docker image (Server)" step in the `docker` job validates the server Dockerfile.
6. **ASGI 405 Method Not Allowed** — Known paths (`/`, `/live`, `/ready`, `/health`) now return 405 with `Allow: GET` header for non-GET methods, per RFC 9110 §15.5.6. Added `_KNOWN_PATHS` frozenset.
7. **WebSocket close protocol fix** — App now calls `await receive()` to consume the `websocket.connect` event before closing. Changed close code from 1000 (Normal Closure) to 1008 (Policy Violation).
8. **Lifespan handler logging** — Unrecognised lifespan message types are now logged as warnings instead of silently consumed.
9. **Security-hardening headers** — `_send_response` now includes `content-length`, `x-content-type-options: nosniff`, and `cache-control: no-store` on all HTTP responses.
10. **`.dockerignore` credential patterns** — Added `*.pem`, `*.key`, `*.p12`, `*.pfx`, `credentials*.json`.
11. **`--log-level` validation** — Constrained to `click.Choice(["critical", "error", "warning", "info", "debug", "trace"])` for clean CLI validation errors.
12. **Reverted unrelated semgrep pre-commit change** — `pass_filenames` and `entry` restored to original values per atomic commit hygiene.
13. **Removed unused `ReceiveCallable` type alias** and `Callable`/`Awaitable` imports from `asgi_app_steps.py`.
14. **Fixed redundant `shutil.which("helm")` check** — `_skip_if_helm_missing` now returns `bool` to eliminate the duplicate check in `_render_chart`.
15. **Improved test deque error handling** — Lifespan test receive mock now raises descriptive `AssertionError` instead of opaque `IndexError`.
16. **Scope type dispatch** — Changed `if/if/if` to `if/elif/elif` for mutually exclusive ASGI scope types.
17. **Dockerfile.server base image** — Standardised to `python:3.13-slim` (floating minor) consistent with CLI Dockerfile.
18. **Dockerfile layer caching** — Split `uv pip install build` and `python -m build` into separate `RUN` instructions.
19. **Removed extraneous double blank line** in Dockerfile.server.

### Deferred items (acknowledged, not in scope)

- PodDisruptionBudget, HorizontalPodAutoscaler, NetworkPolicy — Follow-up for production hardening.
- `appVersion: "1.0.0"` placeholder — Needs tracking issue for release versioning alignment.
- Readiness probe with downstream dependency checks — Documented limitation.
- Cross-system test for probe paths matching ASGI routes — Test enhancement.
- Improved benchmarks (helm template timing vs PyYAML parsing) — Benchmark quality improvement.
- CI DRY violation (Helm install 3×) — Code quality improvement, consider composite action.
- File length limits exceeded (`k8s_helm_chart_steps.py` 551 lines, `helper_k8s_helm_chart.py` 678 lines) — Non-blocking, can be split in follow-up.
- `runAsGroup: 1000` in pod security context — Defense-in-depth improvement.
- HEAD method support on known paths — RFC compliance, does not affect K8s probes.
- `click.Choice` log-level validation via CLI runner test — Test gap.

### Scope note: status-check CI gate

The `status-check` job now includes `integration_tests`, `e2e_tests`, and `helm` in its `needs` list. The `helm` job is new in this PR. The `integration_tests` and `e2e_tests` additions fix previously-missing gate checks — included here since this PR modifies both of those jobs to install Helm.

### Quality gates

- `nox -e lint` 
- `nox -e typecheck` 
- `nox -e unit_tests`  (12,321 scenarios passed, 4 skipped)
- `nox -e integration_tests` — 3 pre-existing failures in unrelated areas (plan correction, resource types)
- `nox -e e2e_tests` — pre-existing failures (LLM API keys not available in local env)
- `nox -e coverage_report`  (**97.7%**)

Reviewed-on: #1085
Reviewed-by: Jeffrey Phillips Freeman <jeffrey.freeman@cleverthis.com>
Co-authored-by: Brent E. Edwards <brent.edwards@cleverthis.com>
Co-committed-by: Brent E. Edwards <brent.edwards@cleverthis.com>
2026-03-27 23:53:22 +00:00
brent.edwards 5ac1e4eeb3 test: add TDD bug-capture test for #1080 — execution env resolution precedence
Write a Behave feature (features/tdd_exec_env_resolution_precedence.feature)
with three scenarios that capture bug #1080: the ExecutionEnvironmentResolver
does not honour the 6-level execution environment precedence chain defined in
the spec (§Execution Environment Routing).

The critical scenario ("Project-level override beats plan-level fallback")
demonstrates the bug by calling resolve() with plan_env="host" and
project_env="container", where the project has priority "override" and the
plan has priority "fallback".  Per the spec, project override (level 2)
should beat plan fallback (level 4), but the current flat resolver chain
returns "host" (plan always wins).  The @tdd_expected_fail tag inverts
this assertion failure to a CI pass.

Two regression-guard scenarios (without @tdd_expected_fail) verify:
(1) Plan-level override still beats project-level override (level 1 vs 2).
(2) Project-level override beats host default (level 2 vs 6).
Both pass both competing environments to the resolver to ensure the
resolver sees the full context and must choose correctly.

Files added:
- features/tdd_exec_env_resolution_precedence.feature — tagged with
  @tdd_bug @tdd_bug_1080 @mock_only and one @tdd_expected_fail scenario
- features/steps/tdd_exec_env_resolution_precedence_steps.py — step
  definitions with priority validation, TODO markers for #1080 cleanup,
  and module-level imports

Robot test: N/A — ExecutionEnvironmentResolver is a pure domain service
with no I/O or integration boundaries.

ISSUES CLOSED: #1101
2026-03-27 22:53:33 +00:00
brent.edwards a5888a08b7 test: add TDD bug-capture test for #987 — AutomationProfileRepository session leak
Add a Behave feature with four scenarios that capture the session leak
bug in AutomationProfileRepository.  The upsert() and delete() methods
commit when auto_commit is True but never call session.close() in a
finally block, leaking database sessions.  SessionRepository correctly
uses finally: if self._auto_commit: db_session.close() in every method
— AutomationProfileRepository does not.

The test uses a _TrackingSession subclass of sqlalchemy.orm.Session that
records whether close() was called, providing direct assertion of the bug.
Four scenarios cover: (1) upsert success path, (2) delete success path,
(3) upsert error path, (4) delete error path.  All scenarios are tagged
@tdd_expected_fail @tdd_bug @tdd_bug_987 so CI passes while the bug
remains unfixed.

Fixes from review:
- M1: Added 4th scenario for delete() error path
- M2: Registered engine.dispose() in _cleanup_handlers for all scenarios
- M3: Registered session.close() in _cleanup_handlers; explicitly close
  setup session in step_given_persisted_profile
- M4: Replaced type: ignore annotations with proper subclass pattern
  (_TrackingSession uses **kwargs: Any; _FailingFlushTrackingSession
  overrides flush() instead of monkey-patching)
- M5: Moved OperationalError import from function body to module level

Robot integration tests are N/A — this is purely a unit-level session
lifecycle bug within a single repository class.

ISSUES CLOSED: #1092
2026-03-27 22:01:03 +00:00
brent.edwards 8b8942817c feat(wf03): add plan prompt test coverage and confidence-threshold pausing verification
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 44s
CI / docker (pull_request) Successful in 1m12s
CI / status-check (pull_request) Successful in 9s
CI / lint (pull_request) Successful in 3m17s
CI / typecheck (pull_request) Successful in 3m54s
CI / quality (pull_request) Successful in 4m6s
CI / security (pull_request) Successful in 4m29s
CI / unit_tests (pull_request) Successful in 6m58s
CI / integration_tests (pull_request) Successful in 7m30s
CI / e2e_tests (pull_request) Successful in 11m39s
CI / coverage (pull_request) Successful in 11m52s
CI / build (push) Successful in 17s
CI / lint (push) Successful in 3m18s
CI / quality (push) Successful in 3m51s
CI / typecheck (push) Successful in 3m55s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 4m2s
CI / integration_tests (push) Successful in 8m57s
CI / unit_tests (push) Successful in 9m9s
CI / docker (push) Successful in 1m7s
CI / e2e_tests (push) Successful in 11m24s
CI / coverage (push) Successful in 11m41s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Successful in 27m28s
CI / benchmark-regression (pull_request) Successful in 59m17s
2026-03-27 13:35:17 -07:00
brent.edwards 3c6b6b54b2 Merge remote-tracking branch 'origin/master' into tdd/m5-container-mount-flag
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 23s
CI / lint (pull_request) Successful in 3m17s
CI / typecheck (pull_request) Successful in 3m55s
CI / security (pull_request) Successful in 4m21s
CI / quality (pull_request) Successful in 4m18s
CI / integration_tests (pull_request) Successful in 9m20s
CI / unit_tests (pull_request) Successful in 9m34s
CI / docker (pull_request) Successful in 1m11s
CI / e2e_tests (pull_request) Successful in 12m3s
CI / coverage (pull_request) Successful in 12m16s
CI / status-check (pull_request) Successful in 1s
CI / build (push) Successful in 20s
CI / lint (push) Successful in 3m16s
CI / quality (push) Successful in 3m44s
CI / typecheck (push) Successful in 4m11s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 4m25s
CI / integration_tests (push) Successful in 6m55s
CI / unit_tests (push) Successful in 7m23s
CI / docker (push) Successful in 1m9s
CI / e2e_tests (push) Successful in 11m37s
CI / coverage (push) Successful in 12m9s
CI / status-check (push) Successful in 3s
CI / benchmark-publish (push) Failing after 23m24s
CI / benchmark-regression (pull_request) Failing after 35m42s
2026-03-27 20:16:41 +00:00
hamza.khyari 0569aaa51c test(integration): workflow example 4 — multi-project dependency update (supervised profile)
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 17s
CI / lint (pull_request) Successful in 3m18s
CI / typecheck (pull_request) Successful in 3m55s
CI / quality (pull_request) Successful in 4m2s
CI / security (pull_request) Successful in 4m16s
CI / integration_tests (pull_request) Successful in 9m11s
CI / unit_tests (pull_request) Successful in 9m30s
CI / docker (pull_request) Successful in 1m23s
CI / e2e_tests (pull_request) Successful in 13m30s
CI / coverage (pull_request) Successful in 11m29s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-regression (pull_request) Successful in 53m38s
Robot Framework integration test suite for Specification Workflow Example 4:
Multi-Project Dependency Update.  Exercises the supervised automation profile
with 4 projects (common-lib + 3 microservices), child plan spawning,
dependency-ordered execution, and coordinated apply.

- 8 test cases covering: project registration, action creation, plan use
  with supervised profile, strategize with DEPENDENCY_ORDERED config,
  child plan spawning (4 children), dependency-ordered execution
  (common-lib first), coordinated apply, and full end-to-end lifecycle
- Multi-project scope initialization, changeset recording, and
  cross-project validation via MultiProjectService
- Shared validation (local/pytest-mypy) registered and attached to all
  4 projects per spec §Workflow Example 4
- Uses mocked LLM providers (CLEVERAGENTS_TESTING_USE_MOCK_AI=true)
- All Run Process calls have timeout=60s on_timeout=kill
  (120s for full lifecycle)
- _NoClose wrapper calls rollback() to match established _SafeSession
  pattern; child IDs generated via ULID() instead of hardcoded

ISSUES CLOSED: #768
2026-03-27 14:50:11 +00:00
hamza.khyari ebafe8cddd fix(cli): implement --mount flag on resource add container-instance
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 28s
CI / build (pull_request) Successful in 26s
CI / typecheck (pull_request) Successful in 3m57s
CI / security (pull_request) Successful in 4m3s
CI / quality (pull_request) Successful in 4m6s
CI / integration_tests (pull_request) Successful in 9m11s
CI / unit_tests (pull_request) Successful in 9m22s
CI / docker (pull_request) Successful in 1m0s
CI / coverage (pull_request) Successful in 12m22s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-regression (pull_request) Has been cancelled
CI / e2e_tests (pull_request) Successful in 11m40s
Add --mount flag to 'resource add container-instance' supporting both
resource-reference mounts (--mount local/api-repo:/workspace) and
host-path mounts (--mount /var/config:/config:ro).

- _parse_mount_spec() parses SOURCE:TARGET and SOURCE:TARGET:MODE formats
- Resource-reference mounts (containing /) get type='resource', mode='rw'
- Host-path mounts support explicit rw/ro mode
- Mounts stored as JSON string in resource properties['mounts']
- _format_properties() renders mounts in human-readable format for 'resource show'
- Added mount to container-instance cli_args metadata
- 6 Behave scenarios testing single mount, dual mount, persistence, and error paths
- Updated CHANGELOG

ISSUES CLOSED: #1078
2026-03-27 12:57:03 +00:00
hamza.khyari 6a8f724299 feat(lsp): add missing LspCapability enum values
CI / build (pull_request) Successful in 18s
CI / security (pull_request) Successful in 58s
CI / lint (pull_request) Successful in 3m19s
CI / typecheck (pull_request) Successful in 3m54s
CI / quality (pull_request) Successful in 3m55s
CI / integration_tests (pull_request) Successful in 6m49s
CI / unit_tests (pull_request) Successful in 7m3s
CI / docker (pull_request) Successful in 1m6s
CI / e2e_tests (pull_request) Successful in 11m45s
CI / benchmark-publish (pull_request) Has been skipped
CI / coverage (pull_request) Successful in 12m52s
CI / status-check (pull_request) Successful in 2s
CI / benchmark-regression (pull_request) Successful in 58m46s
Align LspCapability enum with the spec's 11-capability set
(docs/specification.md lines 20705-20717):

Renamed: TYPE_INFO -> HOVER, SYMBOLS -> DOCUMENT_SYMBOLS,
         FORMAT -> FORMATTING
Added:   DEFINITIONS, SIGNATURE_HELP, WORKSPACE_SYMBOLS

Updated LspToolAdapter._CAPABILITY_TOOL_MAP (11 entries):
- code_actions suffix -> code-actions (hyphen per spec)
- RENAME gets dedicated schema with new_name parameter
- workspace_symbols gets query-based schema

Updated _input_schema_for() with 4 schema categories extracted
to module-level constants: file-only, position-based, rename
(with new_name), and query-based. Added defensive ValueError for
unmapped capabilities. Added additionalProperties: false.

Extended LspClient.initialize() to advertise all 11 capabilities
in the initialize request (hover, definition, references, rename,
codeAction, formatting, signatureHelp, documentSymbol, workspace
symbol).

Fixed _make_runtime_handler() to handle workspace_symbols as
query-only input (no file_path required), resolving the
schema/handler contract mismatch.

Fixed stale references: type_info -> hover, symbols ->
document_symbols in test fixtures, feature files, CLI docstring.

Updated docs/reference/lsp.md and CHANGELOG.md.

Behave tests (38 scenarios): enum completeness, tool spec generation
with structural validation, input schema per category, all 11
stubbed provider keys, negative tests for invalid capability and
defensive ValueError branch.

ISSUES CLOSED: #834
2026-03-27 11:10:56 +00:00
hamza.khyari 7bb77aee5c feat(resource): implement ResourceHandler sandbox and checkpoint methods
CI / build (pull_request) Successful in 14s
CI / lint (pull_request) Successful in 4m3s
CI / quality (pull_request) Successful in 4m1s
CI / typecheck (pull_request) Successful in 4m30s
CI / security (pull_request) Successful in 5m12s
CI / unit_tests (pull_request) Successful in 8m45s
CI / integration_tests (pull_request) Successful in 8m43s
CI / docker (pull_request) Successful in 1m13s
CI / e2e_tests (pull_request) Successful in 13m7s
CI / coverage (pull_request) Successful in 12m43s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 1h9m12s
Extend the ResourceHandler protocol with four sandbox/lifecycle methods:
create_sandbox (idempotent), create_checkpoint, rollback_to, project_access.

Fixes from self-review:
- Instance-level checkpoint dict instead of ClassVar (no shared state)
- Git rollback uses 'git reset --hard' + 'git clean -fd' (not just checkout)
- FsDirectory rollback skips .git to preserve git metadata
- project_access separates ImportError (local mode) from ValueError (reject)
- Added discard_checkpoints() cleanup method
- Git rollback test verifies file content restored

ISSUES CLOSED: #836
2026-03-27 10:50:15 +00:00
Luis Mendes d196e90779 test(integration): workflow example 14 — server mode team collaboration (supervised profile)
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 25s
CI / lint (pull_request) Successful in 3m20s
CI / typecheck (pull_request) Successful in 3m55s
CI / security (pull_request) Successful in 4m3s
CI / quality (pull_request) Successful in 4m10s
CI / integration_tests (pull_request) Successful in 7m23s
CI / unit_tests (pull_request) Successful in 7m41s
CI / docker (pull_request) Successful in 1m9s
CI / e2e_tests (pull_request) Successful in 12m39s
CI / coverage (pull_request) Successful in 11m17s
CI / status-check (pull_request) Successful in 1s
CI / build (push) Successful in 21s
CI / lint (push) Successful in 3m17s
CI / quality (push) Successful in 3m46s
CI / typecheck (push) Successful in 3m53s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 4m1s
CI / unit_tests (push) Successful in 7m13s
CI / docker (push) Successful in 1m8s
CI / e2e_tests (push) Failing after 16m44s
CI / integration_tests (push) Failing after 16m44s
CI / coverage (push) Failing after 17m50s
CI / benchmark-publish (push) Successful in 34m0s
CI / status-check (push) Failing after 1s
CI / benchmark-regression (pull_request) Successful in 59m37s
Implemented Robot Framework integration test suite validating the server
mode team collaboration workflow (Specification Example 14) with mocked
LLM providers and in-memory domain services. Tests cover server mode
configuration, config-registry diagnostics, namespace management, action
publishing to team namespaces with namespaced actor references, shared
action consumption via use_action(), and namespace-filtered plan monitoring
across namespaces. Uses standard integration test infrastructure with
mock AI.

Post-review fixes applied:
- F1: plan_namespace() now creates actions, calls use_action() to instantiate
  plans, and verifies namespace-filtered listing with non-empty results
- F2: Renamed actor_namespace() to action_actor_refs() with accurate
  docstring (tests action actor field references, not ActorService)
- F3: Added use_shared_action() subcommand covering spec Step 3 (use a
  shared action to create a plan and verify namespace inheritance)
- F5: Updated diagnostics() docstring to accurately describe scope (config
  registry verification, not full diagnostic operations)
- F7: Fixed _COMMANDS type from dict[str, object] to dict[str, Callable]
  removing type: ignore suppression
- F9: Extracted _make_config_service() factory to remove duplicated tempdir
  creation pattern
- F10: Added [Tags] to all Robot test cases for filtering support
- F11: Added automation_profile="supervised" to all create_action() calls
  for spec consistency
- M1: Fixed CHANGELOG wording from "mocked server backend" to "in-memory
  domain services" to accurately describe the test approach
- M5: Added symmetric phase and action_name assertions for beta plan in
  plan_namespace() to match alpha plan verification depth
- M6: Added strategy_actor and review_actor assertions after get_action()
  in action_actor_refs() for complete actor field persistence verification
- M8: Added core.namespace default value verification ("local") in
  diagnostics() subcommand
- L2: Added total unfiltered action count verification in shared_actions()
- L3: Added distinguishing tags (publish/shared) to disambiguate Robot
  test cases with previously identical tag sets
- L4: Added ActionState.AVAILABLE assertion for all actions in
  shared_actions() for consistency with action_namespace()

ISSUES CLOSED: #778
2026-03-26 22:33:19 +00:00
CoreRasurae 80f1664a0d test(integration): workflow example 7 — CI/CD integration, automated PR review and fix (ci profile)
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 23s
CI / lint (pull_request) Successful in 3m20s
CI / typecheck (pull_request) Successful in 3m54s
CI / security (pull_request) Successful in 4m13s
CI / quality (pull_request) Successful in 4m17s
CI / integration_tests (pull_request) Successful in 9m21s
CI / unit_tests (pull_request) Successful in 9m42s
CI / docker (pull_request) Successful in 14s
CI / e2e_tests (pull_request) Successful in 12m1s
CI / coverage (pull_request) Successful in 11m41s
CI / status-check (pull_request) Successful in 1s
CI / build (push) Successful in 26s
CI / lint (push) Successful in 3m19s
CI / quality (push) Successful in 3m41s
CI / typecheck (push) Successful in 3m56s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 4m2s
CI / integration_tests (push) Successful in 9m3s
CI / unit_tests (push) Successful in 9m24s
CI / docker (push) Successful in 1m9s
CI / e2e_tests (push) Successful in 13m51s
CI / coverage (push) Successful in 11m25s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Failing after 24m52s
CI / benchmark-regression (pull_request) Failing after 37m6s
Implemented Robot Framework integration test suite validating the CI/CD
workflow (Specification Example 7). Tests cover ci-profile configuration
(automation-profile, format, log level), idempotent resource and project
registration with duplicate-detection assertions, three validation tools
(ci-lint, ci-typecheck, ci-tests) registration and resource attachment
via ToolRegistryService, action creation with typed arguments and
invariants per spec Step 2, plan lifecycle with phase-by-phase completion
through all phases (strategize, execute, apply) until terminal applied
state, and JSON output structure verification including plan_id, phase,
state, action, projects, and arguments fields.

Post-review fixes applied (round 1):
- H1: Fix truncated invariant #2 text to match spec line 39051
- H2: Fix definition_of_done to match spec's 5-bullet-point format
- M1: Register all 3 spec validations (ci-lint, ci-typecheck, ci-tests)
- M3: Add branch property to resource registration per spec Step 3
- M4: Replace phantom resource_id with real registered resource
- M5: Add projects and arguments field assertions to JSON output test
- M7: Replace 'polling-based' with 'phase-by-phase' in docs/comments
- L1: Use timezone-aware datetime (timezone.utc)
- L2: Use tempfile for resource path instead of hardcoded /tmp
- L3: Clarify json_output() docstring to reflect as_cli_dict() scope
- L4: Tighten attachment count assertion from >= 1 to == 1 (now == 3)

Post-review fixes applied (round 2):
- M2: Use Setup Test Environment With Database Isolation for pabot safety
- L1: Replace remaining hardcoded /tmp paths with tempfile (validation_attach,
  resource_idempotent duplicate registration)
- L2: Fix stale 'Polling-based' comment missed in round 1
- L5: Align action description with spec line 39027
- M1/L3/L6: Document automation_profile propagation gap in use_action()
  with TODO for when production code wires the field onto Plan
- L4: Add comment explaining local actor name deviation from spec

Includes CHANGELOG update describing the integration test scope.

ISSUES CLOSED: #771
2026-03-26 21:42:37 +00:00
CoreRasurae d2c70bd489 test(e2e): workflow example 14 — server mode team collaboration (supervised profile)
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 29s
CI / quality (pull_request) Successful in 33s
CI / security (pull_request) Successful in 59s
CI / lint (pull_request) Successful in 3m40s
CI / typecheck (pull_request) Successful in 3m57s
CI / unit_tests (pull_request) Successful in 5m55s
CI / docker (pull_request) Successful in 1m11s
CI / integration_tests (pull_request) Successful in 7m21s
CI / coverage (pull_request) Successful in 11m34s
CI / status-check (pull_request) Successful in 1s
CI / e2e_tests (pull_request) Successful in 11m30s
CI / build (push) Successful in 24s
CI / lint (push) Successful in 3m18s
CI / quality (push) Successful in 3m41s
CI / typecheck (push) Successful in 4m16s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 4m25s
CI / unit_tests (push) Successful in 7m15s
CI / integration_tests (push) Successful in 7m22s
CI / docker (push) Successful in 1m16s
CI / e2e_tests (push) Successful in 12m3s
CI / coverage (push) Successful in 12m2s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Failing after 22m16s
CI / benchmark-regression (pull_request) Successful in 51m52s
Implemented Robot Framework E2E test suite validating Specification
Workflow Example 14 (Server Mode Team Collaboration). Tests exercise
the real CleverAgents CLI with zero mocking, covering server mode
configuration (server.url, server.token, core.namespace), diagnostics,
action publishing to team namespace with namespace-scoped listing,
actor registration, plan list graceful handling, and supervised
automation profile verification.

Review fixes applied:
- Added WF14 Suite Setup with agents init and uuid4 suffix generation
- Added WF14 Suite Teardown to reset config state (server.url,
  server.token, core.namespace)
- Added server.token config round-trip per spec Example 14 Step 1
- Changed action name to myteam/ namespace prefix per spec Step 2
- Added action list --namespace myteam test per issue AC
- Replaced epoch-based name uniqueness with uuid4 for CI safety
- Updated diagnostics test documentation (no server connectivity check)
- Changed to Force Tags E2E at suite level for consistency
- Added description field to actor YAML configuration
- Updated plan list test documentation to reflect actual behavior
- Reverted unrelated cls->klass rename from strategy_registry.py
  (CONTRIBUTING.md: do not mix cosmetic changes with functional changes)
- Updated CHANGELOG to accurately reflect test coverage

ISSUES CLOSED: #760
2026-03-26 18:56:16 +00:00
CoreRasurae 7cf03f03f4 fix(action): query persisted actions from database in list_actions
list_actions() previously merged in-memory cache with the database but
used the cache as the primary source.  Actions created by previous CLI
invocations were only stored in the database and were invisible to the
current process.

When persistence is enabled and a Unit of Work is available, the method
now queries the database first — using get_by_namespace() when a
namespace filter is given, or the new list_all() otherwise — and
refreshes the in-memory cache with any newly-discovered entries.  Falls
back to the in-memory cache on DatabaseError or when no UoW is wired.

Added ActionRepository.list_all() to retrieve all persisted actions
ordered by namespace and name.

Refs: #760
2026-03-26 18:51:43 +00:00
CoreRasurae cefbca73c2 test(e2e): workflow example 7 — CI/CD integration, automated PR review and fix (ci profile)
CI / lint (pull_request) Successful in 3m18s
CI / build (pull_request) Successful in 45s
CI / typecheck (pull_request) Successful in 3m49s
CI / security (pull_request) Successful in 4m7s
CI / quality (pull_request) Successful in 4m9s
CI / benchmark-publish (pull_request) Has been skipped
CI / integration_tests (pull_request) Successful in 7m11s
CI / unit_tests (pull_request) Successful in 7m53s
CI / docker (pull_request) Successful in 1m2s
CI / e2e_tests (pull_request) Successful in 12m13s
CI / coverage (pull_request) Successful in 11m54s
CI / status-check (pull_request) Successful in 1s
CI / build (push) Successful in 20s
CI / lint (push) Successful in 3m15s
CI / quality (push) Successful in 3m39s
CI / typecheck (push) Successful in 3m56s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 4m24s
CI / unit_tests (push) Successful in 6m7s
CI / integration_tests (push) Successful in 6m53s
CI / docker (push) Successful in 1m49s
CI / e2e_tests (push) Successful in 12m4s
CI / coverage (push) Successful in 10m14s
CI / status-check (push) Successful in 3s
CI / benchmark-publish (push) Successful in 28m31s
CI / benchmark-regression (pull_request) Successful in 53m11s
Implemented Robot Framework E2E test suite validating Specification
Workflow Example 7 (CI/CD Integration).  Tests exercise the real
CleverAgents CLI with zero mocking, covering:

- ci-profile configuration with JSON output format and WARN log level
  (spec Step 1)
- Idempotent resource and project registration with resource linking,
  verified via strict occurrence-count assertions
- Three-validation registration (lint, typecheck, tests) with project
  attachment and tool-list verification
- CI plan launch with action args (pr_branch, base_branch), explicit
  plan execute for lifecycle progression, and terminal-state assertion
- JSON output verification via json.loads() with raw_decode fallback
  for mixed log/JSON CLI output
- Graceful degradation via Skip If No LLM Keys when API keys are
  unavailable

Resource/project naming follows spec convention (local/ci-workspace
project, local/ci-main resource).  Entity creation commands tolerate
"already exists" for CI re-runnability.  Config assertions use
stdout-only matching and exact equality.  Validation naming aligned
with spec (local/ci-lint per §Example 7, line 39130).

Added robot/common_vars.py module placeholder for shared Robot
Framework variables.

ISSUES CLOSED: #753
2026-03-26 18:10:14 +00:00
Luis Mendes 59be111e1d fix(plan): complete apply phase inline in auto_progress and lifecycle-apply CLI
Modified auto_progress() to complete the Apply phase immediately after
transitioning from Execute to Apply, since Apply is a metadata transition
with no LLM processing.  This ensures `plan execute` drives the plan to
the terminal `applied` state when the automation profile permits (ci,
full-auto profiles with auto_apply < 1.0).

Extracted `_complete_apply_if_queued()` helper that consolidates the
Apply-completion pattern (start_apply + complete_apply) into a single
method with error recovery (calls `fail_apply` on failure) and async-job
guard (skips inline completion when async execution is enabled to avoid
orphaning enqueued jobs).  Used by `auto_progress()`,
`lifecycle_apply_plan()`, and `try_auto_run()`.

Added PlanLifecycleService.try_auto_run() that drives plans through all
lifecycle phases (strategize → execute → apply) when automation-profile
thresholds allow automatic progression.  Each phase checks the profile's
auto_* threshold before proceeding; a threshold of 1.0 stops the plan at
that phase boundary for human approval.

Fixed `lifecycle-apply` CLI leaving plans stuck in `apply/queued` without
completing.  The command now calls `_complete_apply_if_queued()` when the
plan is in Apply/queued, driving it to the terminal `applied` state.

Fixed stale RICH output in `lifecycle_apply_plan` that printed
"Plan is now in Apply phase (queued)" after the plan had already reached
terminal `applied` state; now branches on `plan.is_terminal`.

Additional fixes:
- SQLite UNIQUE constraint violation in LifecyclePlanRepository.update():
  added session.flush() after clear() on child collections (project_links,
  arguments, invariants) before re-inserting rows
- Added 'state' alias in _plan_spec_dict() JSON output for spec §Example 7
  jq compatibility
- Updated plan execute and lifecycle-apply reference documentation

Refs: #753
2026-03-26 17:35:24 +00:00
CoreRasurae e4c01492d5 refactor(cli): align actor run signature with spec positional args
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 15s
CI / lint (pull_request) Successful in 3m18s
CI / quality (pull_request) Successful in 3m47s
CI / typecheck (pull_request) Successful in 3m52s
CI / security (pull_request) Successful in 4m1s
CI / integration_tests (pull_request) Successful in 6m53s
CI / unit_tests (pull_request) Successful in 7m9s
CI / docker (pull_request) Successful in 1m9s
CI / e2e_tests (pull_request) Successful in 11m5s
CI / coverage (pull_request) Successful in 11m15s
CI / status-check (pull_request) Successful in 1s
CI / lint (push) Successful in 3m16s
CI / build (push) Successful in 31s
CI / typecheck (push) Successful in 4m0s
CI / security (push) Successful in 4m1s
CI / benchmark-regression (push) Has been skipped
CI / quality (push) Successful in 4m8s
CI / integration_tests (push) Successful in 6m10s
CI / unit_tests (push) Successful in 7m35s
CI / docker (push) Successful in 1m9s
CI / e2e_tests (push) Successful in 9m58s
CI / coverage (push) Successful in 11m7s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Failing after 17m22s
CI / benchmark-regression (pull_request) Successful in 56m7s
Aligned the `agents actor run` command signature with the
specification by introducing positional NAME and PROMPT arguments.
The --config/-c option is preserved as an optional fallback for
direct YAML invocation. When NAME is provided without --config,
the actor is resolved from the Actor Registry.

Updated both actor_run.py and actor.py run commands. Added backward
compatibility: if --config is provided, it takes precedence over
name-based resolution.

Review fixes applied (code review round 1):
- P1-1: Narrowed bare `except Exception` to `except NotFoundError`
  in _resolve_config_files to avoid masking infrastructure errors.
- P1-2: Moved _resolve_config_files call inside the try block in
  run() so container/registry init errors get user-friendly messages.
  Added `except click.exceptions.Exit: raise` to let typer.Exit
  propagate through the broadened try scope.
- P1-3: Added atexit.register cleanup for temp files created by
  _resolve_config_files (resource leak fix).
- P1-4: Added CHANGELOG.md entry for the breaking CLI change.
- P2-1: Extracted duplicated _resolve_config_files to shared module
  `_resolve_actor.py`; both actor.py and actor_run.py now import it.
- P2-2: Added guard for actors with no configuration data
  (config_blob=None) to produce a clear error instead of invalid YAML.
- P2-3/P2-4: Added 5 BDD scenarios exercising the real
  resolve_config_files function (registry path, yaml_text path,
  config_blob fallback, no-config-data error, not-found error).
- P2-5: Added @coverage tags to all new BDD scenarios.
- P3-1: Added timeout=120s and on_timeout=kill to Robot tests.
- Fixed rxpy_route_validation.robot tests that used the removed
  --prompt/-p option (replaced with positional NAME + PROMPT args).

Review fixes applied (code review round 2):
- P2-1: Aligned actor_run.py exception handler from
  `CleverAgentsException` to `CleverAgentsError`, matching actor.py
  so infrastructure errors from registry resolution get user-friendly
  messages instead of falling through to the generic handler.
- P2-2: Changed `yaml.dump` to `yaml.safe_dump` in _resolve_actor.py
  for fail-fast behavior on unexpected types, consistent with the
  codebase's dominant pattern.
- P3-6: Replaced defensive `getattr(actor, ...)` calls with direct
  Pydantic model attribute access (`actor.yaml_text`, `actor.config_blob`)
  for type-checker coverage.
- P3-1: Switched BDD temp file cleanup from post-assertion
  `unlink()` to `context.add_cleanup()` for leak-proof teardown.
- P2-3/P3-2/P3-3/P3-4: Added 3 BDD edge-case scenarios
  (empty config_blob dict, infrastructure error propagation, empty
  string name) and 1 Robot test case (actor_app registry resolution).

Review fixes applied (code review round 3):
- P1-1: Migrated 48 remaining `-p` invocations across 9 Robot test
  files to the new positional `NAME PROMPT` pattern (context_delete_all_yes,
  load_context_test, scientific_paper_e2e_test, routing_prefix_stripping,
  scientific_paper_basic, scientific_paper_writer_test,
  context_management_test, initial_next_command_test,
  system_prompt_template_rendering).
- P2-1: Documented `--config/-c` as a spec deviation in
  `_resolve_actor.py` module docstring (spec lines 4562-4566 define
  `actor run` with no --config option; issue #901 AC accepts keeping
  it as optional).
- P2-2: Corrected `--config` help text from "fallback" to "overrides
  registry-based name resolution" — the option takes precedence, not
  the other way around.
- P3-1: Added `.strip()` to `yaml_text` emptiness check in
  `_resolve_actor.py` to handle whitespace-only values that would
  otherwise bypass the `config_blob` fallback.
- P3-2: Added `from None` to the no-configuration-data
  `typer.Exit(code=2)` for consistency with the not-found path.
- P3-3: Added BDD scenario testing `--config` precedence for
  `actor_run_app` (was only tested for `actor_app`).
- P3-4: Strengthened config_blob BDD scenario to verify generated
  YAML is parseable via `yaml.safe_load` round-trip.
- P3-7: Replaced hardcoded `/tmp/dummy.yaml` with
  `tempfile.gettempdir()` for portability.
- P3-8: Moved 5 inline imports to module level per CONTRIBUTING.md
  §1292-1294 (3x `import click`, 1x InfrastructureError in steps;
  1x `import typer` in robot helper).
- P3-9: Added `encoding="utf-8"` to `_write_yaml` in Robot helper
  for consistency with production code.

Review fixes applied (code review round 4):
- P2-1: Wrapped `yaml.safe_dump` in `_resolve_actor.py` with
  `try/except yaml.YAMLError` so non-serialisable config_blob values
  produce a user-friendly error message instead of a raw traceback.
- P2-2: Moved remaining inline `import yaml` to module level in
  `actor_run_signature_steps.py` per CONTRIBUTING.md §1292-1294.
- P2-3: Replaced 3 bare `assert` statements in Robot helper
  `helper_actor_run_signature.py` with diagnostic `if/print/sys.exit`
  pattern matching the rest of the file, improving failure diagnostics.

Review fixes applied (code review round 5):
- P3-4: Replaced per-call `atexit.register(lambda)` in
  `_resolve_actor.py` with a module-level `_temp_files` set and a
  single `atexit` handler (`_cleanup_temp_files`) to prevent
  unbounded handler accumulation in same-process usage (e.g. test
  suites running multiple CliRunner invocations).
- P3-1/P3-2/P3-3: Added 4 BDD scenarios: whitespace-only
  `yaml_text` fallback to config_blob, config-precedence
  registry-not-consulted assertion for both `actor_app` and
  `actor_run_app`, multiple `--config` files with positional NAME.
- P4-1: Strengthened error-path BDD assertions to verify error
  message content (not-found, no-config-data, serialisation-error)
  alongside exit codes via captured stderr.
- P4-2: Added Robot test case for `actor_app` unknown-name error
  path and corresponding helper function.

ISSUES CLOSED: #901
2026-03-26 13:41:31 +00:00