Files
cleveragents-core/features/session_cli_coverage_boost.feature
freemo 02250473ad fix(ci): restore all CI quality gates to passing on master
Fix all failing CI quality gates (lint, unit_tests, format) without
suppressing any quality enforcement.

Root causes and fixes:

1. Format: features/steps/plan_namespaced_name_tdd_steps.py had trailing
   whitespace; fixed by running ruff format.

2. Unit tests - A2A JSON-RPC 2.0 migration (commit 9c6d6915) renamed
   A2aRequest fields (operation→method, request_id→id, a2a_version→jsonrpc)
   and A2aResponse fields (status+data→result, request_id→id) but did not
   update all step files and feature files:
   - a2a_jsonrpc_wire_format_steps.py: added use_step_matcher('re') and
     reset to 'parse' at end to prevent parallel test interference
   - a2a_facade_wiring_steps.py: updated operation= to method=, .status/.data
     to .result
   - a2a_facade_steps.py: updated request_id→id, a2a_version→jsonrpc,
     A2aResponse(request_id=..., status=...) to new API
   - m6_facade_steps.py: updated all old API usage
   - devcontainer_cleanup_steps.py: updated A2aRequest(operation=...)
   - plan_prompt_command_steps.py: updated A2aRequest(operation=...)
   - wf03_plan_prompt_confidence_steps.py: updated A2aRequest(operation=...)
   - consolidated_misc.feature: updated old A2aRequest/A2aResponse scenarios

3. Unit tests - Session CLI output changed (commit 0d5d9cf0 and others):
   - 'Session Created' → 'Session created' (lowercase)
   - 'Session Details' → 'Session Summary'
   - 'Sessions (N total)' → 'Sessions'
   - session list JSON: top-level 'total' → nested 'summary.total'
   - Fixed in: session_cli.feature, session_cli_coverage_boost.feature,
     session_cli_uncovered_branches.feature, session_list_error.feature,
     tdd_session_create_persist_steps.py

4. Unit tests - Plan list output changed (commit 1a07a891):
   - 'V3 Lifecycle Plans' → 'Plans'
   - 'Lifecycle Plans' → 'Plans'
   - Name column removed (restored in source)
   - Invariants column removed (restored in source)
   - Project truncation removed (restored in source)
   - Fixed in: plan_cli_cancel_revert_coverage.feature,
     plan_lifecycle_cli_coverage.feature, plan_cli_coverage_boost_steps.py,
     plan.py (source code restored)

5. Unit tests - Plan apply command now requires ULID (commit 300a5d6d):
   - plan_cli_coverage_r3.feature: updated 'PLAN-001' to valid ULID
   - plan_cli_coverage_r3_steps.py: added --yes flag, added new step for
     no-eligible-plans path

6. Unit tests - Various source code bugs:
   - ThoughtBlock: converted from @dataclass to Pydantic BaseModel
     (architecture test requires all dataclasses to use Pydantic)
   - session.py: added DatabaseError handling to export, import, tell commands
   - database.py: fixed rollback_to() to reuse checkpoint connection for writes
   - database.py: added _get_checkpoint_conn() helper
   - check-tls-cert.py: fixed SSLCertVerificationError.reason AttributeError

7. Unit tests - Test step bugs:
   - error_recovery_coverage_boost_steps.py: fixed invalid ULID _PLAN_ID
   - session_service_coverage_steps.py: fixed 'sha256:' prefix bug in checksum
   - database_models_new_coverage_steps.py: added 'name' field to session mock
   - async_audit_recording_steps.py: fixed Settings(audit_async=False) via env var
   - coverage_threshold_config_steps.py: added --coverage-min pattern support
   - m5_acms_smoke_steps.py: updated usage hint text
   - actor_cli_yaml_steps.py: updated 'Removed actor' → 'Actor removed'
   - aimodelscredentials_steps.py: set context.imported_class in import step
   - domain_base_model.feature: added missing 'When I examine model_config' step
   - tui_first_run_steps.py: fixed module reload to restore cleveragents.tui.*
     modules after test (prevented patch interference in subsequent tests)
   - tui_first_run_steps.py: added set_search('') step for empty string
   - resource_handler_base_coverage_r3_steps.py: use _MinimalHandler instead
     of DatabaseResourceHandler for NotImplementedError tests
   - resource_handler_crud.feature: updated to test new DatabaseHandler behavior
   - resource_handler_sandbox.feature: updated to test new DatabaseHandler behavior
   - tdd_json_decode_crash_persistence.feature: fixed @tdd_bug → @tdd_issue tags

8. Parallel test interference:
   - All step files using use_step_matcher('re') now reset to 'parse' at end
     to prevent global matcher state leaking to subsequent step files
2026-04-04 20:38:16 +00:00

248 lines
12 KiB
Gherkin

Feature: Session CLI Coverage Boost
Additional scenarios that exercise previously uncovered code paths
in the session.py CLI commands module.
Background:
Given the session CLI coverage boost module is set up
# ---------------------------------------------------------------
# create command
# ---------------------------------------------------------------
Scenario: create command succeeds with rich format
Given session coverage boost a mock service that creates a session
When session coverage boost I invoke the create command with rich format
Then session coverage boost the exit code is 0
And session coverage boost the output contains "Session created"
Scenario: create command succeeds with JSON format
Given session coverage boost a mock service that creates a session
When session coverage boost I invoke the create command with json format
Then session coverage boost the exit code is 0
Scenario: create command catches DatabaseError
Given session coverage boost a mock service that raises DatabaseError on create
When session coverage boost I invoke the create command with rich format
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Database unavailable"
# ---------------------------------------------------------------
# list command
# ---------------------------------------------------------------
Scenario: list command succeeds with sessions in rich format
Given session coverage boost a mock service that lists sessions
When session coverage boost I invoke the list command with rich format
Then session coverage boost the exit code is 0
And session coverage boost the output contains "Sessions"
Scenario: list command succeeds with sessions in JSON format
Given session coverage boost a mock service that lists sessions
When session coverage boost I invoke the list command with json format
Then session coverage boost the exit code is 0
Scenario: list command with no sessions in rich format
Given session coverage boost a mock service that lists empty sessions
When session coverage boost I invoke the list command with rich format
Then session coverage boost the exit code is 0
And session coverage boost the output contains "No sessions found"
Scenario: list command with no sessions in JSON format
Given session coverage boost a mock service that lists empty sessions
When session coverage boost I invoke the list command with json format
Then session coverage boost the exit code is 0
Scenario: list command catches DatabaseError
Given session coverage boost a mock service that raises DatabaseError on list
When session coverage boost I invoke the list command with rich format
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Database unavailable"
# ---------------------------------------------------------------
# show command
# ---------------------------------------------------------------
Scenario: show command with cost budget having a max cost
Given session coverage boost a mock service returning a session with cost budget max 10
When session coverage boost I invoke the show command
Then session coverage boost the exit code is 0
And session coverage boost the output contains "Cost Budget"
Scenario: show command with cost budget unlimited
Given session coverage boost a mock service returning a session with unlimited cost budget
When session coverage boost I invoke the show command
Then session coverage boost the exit code is 0
And session coverage boost the output contains "unlimited"
Scenario: show command with messages and linked plans in rich format
Given session coverage boost a mock service returning a session with messages and plans
When session coverage boost I invoke the show command
Then session coverage boost the exit code is 0
And session coverage boost the output contains "Recent Messages"
And session coverage boost the output contains "Linked Plans"
Scenario: show command with JSON format
Given session coverage boost a mock service returning a session with messages and plans
When session coverage boost I invoke the show command with json format
Then session coverage boost the exit code is 0
Scenario: show command catches SessionNotFoundError
Given session coverage boost a mock service that raises SessionNotFoundError on get
When session coverage boost I invoke the show command
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Session not found"
Scenario: show command catches DatabaseError
Given session coverage boost a mock service that raises DatabaseError on get
When session coverage boost I invoke the show command
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Database unavailable"
# ---------------------------------------------------------------
# delete command
# ---------------------------------------------------------------
Scenario: delete command succeeds with --yes flag
Given session coverage boost a mock service for delete
When session coverage boost I invoke the delete command with yes
Then session coverage boost the exit code is 0
And session coverage boost the output contains "deleted"
Scenario: delete command aborted by user
Given session coverage boost a mock service for delete
When session coverage boost I invoke the delete command without yes answering no
Then session coverage boost the output contains "Aborted"
Scenario: delete command catches SessionNotFoundError
Given session coverage boost a mock service that raises SessionNotFoundError on get
When session coverage boost I invoke the delete command with yes
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Session not found"
Scenario: delete command catches DatabaseError
Given session coverage boost a mock service that raises DatabaseError on delete
When session coverage boost I invoke the delete command with yes
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Database unavailable"
# ---------------------------------------------------------------
# export command
# ---------------------------------------------------------------
Scenario: export command to stdout
Given session coverage boost a mock service for export
When session coverage boost I invoke the export command to stdout
Then session coverage boost the exit code is 0
Scenario: export command to file
Given session coverage boost a mock service for export
And session coverage boost a temporary directory for export
When session coverage boost I invoke the export command to a file
Then session coverage boost the exit code is 0
And session coverage boost the output contains "exported"
Scenario: export command to existing file without force
Given session coverage boost a mock service for export
And session coverage boost a temporary directory with existing file
When session coverage boost I invoke the export command to existing file without force
Then session coverage boost the exit code is 1
And session coverage boost the output contains "File already exists"
Scenario: export command catches SessionNotFoundError
Given session coverage boost a mock service that raises SessionNotFoundError on export
When session coverage boost I invoke the export command to stdout
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Session not found"
Scenario: export command catches SessionExportError
Given session coverage boost a mock service that raises SessionExportError on export
When session coverage boost I invoke the export command to stdout
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Export error"
Scenario: export command catches DatabaseError
Given session coverage boost a mock service that raises DatabaseError on export
When session coverage boost I invoke the export command to stdout
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Database unavailable"
# ---------------------------------------------------------------
# import command
# ---------------------------------------------------------------
Scenario: import command succeeds
Given session coverage boost a mock service for import
And session coverage boost a temporary import file with valid JSON
When session coverage boost I invoke the import command
Then session coverage boost the exit code is 0
And session coverage boost the output contains "Session Imported"
Scenario: import command with missing file
When session coverage boost I invoke the import command with missing file
Then session coverage boost the exit code is 1
And session coverage boost the output contains "File not found"
Scenario: import command with invalid JSON file
Given session coverage boost a temporary import file with invalid JSON
When session coverage boost I invoke the import command with invalid json
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Invalid JSON"
Scenario: import command catches SessionImportError
Given session coverage boost a mock service that raises SessionImportError on import
And session coverage boost a temporary import file with valid JSON
When session coverage boost I invoke the import command expecting import error
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Import error"
Scenario: import command catches DatabaseError
Given session coverage boost a mock service that raises DatabaseError on import
And session coverage boost a temporary import file with valid JSON
When session coverage boost I invoke the import command expecting database error
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Database unavailable"
# ---------------------------------------------------------------
# tell command
# ---------------------------------------------------------------
Scenario: tell command succeeds without streaming
Given session coverage boost a mock service for tell
When session coverage boost I invoke the tell command without stream
Then session coverage boost the exit code is 0
And session coverage boost the output contains "Acknowledged"
Scenario: tell command succeeds with streaming
Given session coverage boost a mock service for tell
When session coverage boost I invoke the tell command with stream
Then session coverage boost the exit code is 0
And session coverage boost the output contains "Acknowledged"
Scenario: tell command with actor override
Given session coverage boost a mock service for tell
When session coverage boost I invoke the tell command with actor override
Then session coverage boost the exit code is 0
And session coverage boost the output contains "openai/gpt-4"
Scenario: tell command catches SessionNotFoundError
Given session coverage boost a mock service that raises SessionNotFoundError on append
When session coverage boost I invoke the tell command without stream
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Session not found"
Scenario: tell command catches DatabaseError
Given session coverage boost a mock service that raises DatabaseError on append
When session coverage boost I invoke the tell command without stream
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Database unavailable"
# ---------------------------------------------------------------
# show command with long message content truncation
# ---------------------------------------------------------------
Scenario: show command truncates long message content
Given session coverage boost a mock service returning a session with a long message
When session coverage boost I invoke the show command
Then session coverage boost the exit code is 0
And session coverage boost the output contains truncated message indicator