6 Commits

Author SHA1 Message Date
HAL9000 dd80d05558 fix(tests): align BDD scenarios with rollback-removal behaviour (PR #8179)
CI / lint (pull_request) Successful in 37s
CI / typecheck (pull_request) Successful in 1m5s
CI / push-validation (pull_request) Successful in 39s
CI / quality (pull_request) Successful in 1m8s
CI / build (pull_request) Successful in 53s
CI / helm (pull_request) Successful in 57s
CI / security (pull_request) Successful in 1m25s
CI / unit_tests (pull_request) Successful in 8m49s
CI / integration_tests (pull_request) Successful in 9m50s
CI / docker (pull_request) Successful in 1m47s
CI / coverage (pull_request) Successful in 12m55s
CI / status-check (pull_request) Successful in 3s
Three CI gates were failing on this PR; this commit addresses the root
causes for each:

* lint (ruff format): drop the blank line between the docstring close
  and first statement in step_pr_create_with_error, and add the missing
  second blank line between step_pr_check_remove_link_persisted and the
  "Data integrity BDD step extensions" section comment block.

* unit_tests: two scenarios were inverted by `@tdd_expected_fail` on
  post-fix assertions, masking unrelated test-logic problems.
  - Remove `@tdd_expected_fail` from both `@tdd_issue_8179` scenarios in
    project_repository.feature - they describe post-fix behaviour and
    must report PASS as PASS, not as inverted-FAIL.
  - Drop the "Given project exists" precondition from the Update-non-
    existent scenario; the Background already initialises the in-memory
    DB and creating the same project being "updated as non-existent" is
    self-contradictory (caused the prior scenario to silently report
    inverted-PASS while actually never raising).
  - Update the OperationalError scenario in database_repository_coverage
    to assert the post-fix invariant: the repository no longer calls
    session.rollback() itself; that responsibility is delegated to the
    outer UnitOfWork.  Step text + assertion both flipped.

ISSUES CLOSED: #8179
2026-06-14 11:36:15 -04:00
HAL9000 f0b374eb5d fix(data-integrity): address PR #10990 review feedback (PR #8179)
- Fix CI lint failure: remove unused IntegrityError import in BDD steps
- Append session.rollback() before session.close() in all NamespacedProjectRepository methods that own the session outside UoW
- Merge duplicate CHANGELOG ### Fixed sections into single header
- Apply @tdd_issue @tdd_issue_8179 @tdd_expected_fail tags to new BDD scenarios
- Consolidate near-duplicate step definitions; fix misleading docstring (NsP operates outside UoW)

ISSUES CLOSED: #8179
2026-06-14 11:36:15 -04:00
HAL9000 022b354359 fix(data-integrity): remove session.rollback() calls from ProjectRepository
Removed unconditional session.rollback() calls within exception handlers in:

- ProjectRepository.create()
- NamespacedProjectRepository.create() (IntegrityError handler)
- NamespacedProjectRepository.create() (OperationalError handler)
- NamespacedProjectRepository.update()
- NamespacedProjectRepository.delete()

The Unit of Work pattern already handles transaction rollback at the outer layer
via its except Exception: session.rollback() handler, making these inner rollbacks
redundant. SQLAlchemy automatically invalidates the transaction state when exceptions
occur after flush(), preventing partial data from being committed.

Removing the redundant rollbacks improves clarity, eliminates potential issues related
to exception chaining across retry boundary layers, and aligns repository implementations
with explicit transaction boundaries.

ISSUES CLOSED: #8179
2026-06-14 11:36:15 -04:00
Dev User a3ba3c3eaf fix(tests): resolve pre-existing AmbiguousStep collisions in step definitions
Rename step texts to avoid case-sensitive conflicts between different step modules:

- edge_case_plan_steps.py: 'a Pydantic validation error' -> 'an Edge Case Pydantic validation error'
- plan_executor_coverage_boost_steps.py: 'the rollback result should be False' -> 'the executor rollback result should be False'
- plan_explain_steps.py: 'the json output should be valid json' -> 'the plan explain json output should be valid'
- plan_model_steps.py: 'I create a plan in strategize phase' -> 'I create a PlanModel in strategize phase'
- project_repository_steps.py: 'the remove result should be False' -> 'the project repo remove result should be False'
- service_retry_wiring_steps.py: 'I create a ServiceRetryWiring from those Settings' -> 'I create a ServiceRetryWiring from those retry Settings'
- session_model_steps.py: 'I get the session CLI dict' -> 'I get the session model CLI dict'

These pre-existing bugs prevented all behave tests from loading.
2026-05-07 20:05:33 +00:00
hurui200320 eb770643c2 test(e2e): validate M5 acceptance criteria for v3.4.0 milestone closure
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 16s
CI / build (pull_request) Successful in 17s
CI / quality (pull_request) Successful in 19s
CI / e2e_tests (pull_request) Successful in 32s
CI / security (pull_request) Successful in 37s
CI / typecheck (pull_request) Successful in 39s
CI / unit_tests (pull_request) Successful in 3m1s
CI / integration_tests (pull_request) Successful in 3m39s
CI / docker (pull_request) Successful in 40s
CI / coverage (pull_request) Successful in 6m49s
CI / lint (push) Successful in 12s
CI / build (push) Successful in 15s
CI / quality (push) Successful in 17s
CI / e2e_tests (push) Successful in 30s
CI / typecheck (push) Successful in 36s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 49s
CI / unit_tests (push) Successful in 3m16s
CI / integration_tests (push) Successful in 3m37s
CI / docker (push) Successful in 51s
CI / coverage (push) Successful in 6m40s
CI / benchmark-publish (push) Successful in 20m12s
CI / benchmark-regression (pull_request) Successful in 37m11s
Add four CLI-based integration test cases to the M5 E2E verification suite
that exercise the exact commands from the v3.4.0 milestone description via
real subprocess calls to `python -m cleveragents`.

CLI test cases:
- CLI Project Create Large Project: `agents project create local/large-project`
- CLI Resource Add Git Checkout: `agents resource add git-checkout ...`
- CLI Project Link Resource: `agents project link-resource ...`
- CLI Project Show Displays Linked Resource: `agents project show ...`

Each test creates an isolated temp directory with its own CLEVERAGENTS_HOME,
initialises a workspace via `agents init`, runs the target CLI command as a
subprocess with `on_timeout=kill`, asserts zero exit code and verifies
expected output, then tears down the temp directory.

Bug fix: ProjectResourceLinkRepository.create_link() and remove_link() only
called session.flush() without session.commit(), causing linked resource data
to be silently lost between sessions. Added session.commit() to both methods,
plus finally: session.close() to match the session-factory lifecycle pattern
used by all other mutating repository methods. Added session.refresh() and
session.expunge() before return in create_link() so the returned ORM instance
is fully loaded and usable in detached state after session close.

Regression guard: Added two cross-session persistence Behave scenarios
(project_repository.feature) that open a new session from the same engine
after create_link/remove_link and verify the operation was durably committed.

Test improvements from review feedback (rounds 1 and 2):
- Per-test CLEVERAGENTS_HOME isolation via env: override on all Run Process
  calls to prevent shared state between tests.
- Stronger ULID-based assertions: CLI tests capture the resource_id ULID from
  resource show output and verify the exact ID in project show output.
- Regex-based branch assertion (branch.*main) instead of generic string match.
- Test 4 differentiated from Test 3 by verifying resource show independently
  after linking and asserting the specific resource ULID.
- Documentation noting context tier and ACMS criteria are validated at the
  Python API level via helper_m5_e2e_verification.py.
- Updated ProjectResourceLinkRepository class docstring documenting commit
  and close behaviour of mutating methods.
- CHANGELOG entry for both test additions and production bug fix.
- Redundant Library imports removed, --format plain on project list, comments
  explaining fake repo directories, standardised Run Process line style.

Context/ACMS CLI coverage is intentionally not added because the CLI does not
yet expose dedicated context/ACMS inspection commands. These criteria are
validated at the Python API level via helper_m5_e2e_verification.py.

ISSUES CLOSED: #496
2026-03-13 13:32:52 +08:00
Jeffrey Phillips Freeman f7d2f63ab8 feat(cli): add resource commands (core)
CI / lint (pull_request) Successful in 15s
CI / typecheck (pull_request) Successful in 28s
CI / security (pull_request) Successful in 23s
CI / quality (pull_request) Successful in 15s
CI / integration_tests (pull_request) Successful in 5m11s
CI / build (pull_request) Successful in 16s
CI / unit_tests (pull_request) Successful in 14m31s
CI / docker (pull_request) Successful in 40s
CI / coverage (pull_request) Successful in 8m18s
CI / lint (push) Successful in 13s
CI / typecheck (push) Successful in 28s
CI / security (push) Successful in 23s
CI / quality (push) Successful in 16s
CI / integration_tests (push) Successful in 4m58s
CI / build (push) Successful in 15s
CI / unit_tests (push) Successful in 15m30s
CI / coverage (push) Has been cancelled
CI / docker (push) Has been cancelled
2026-02-16 16:46:54 -05:00