Files
cleveragents-core/features/session_cli_coverage_boost.feature
T
hurui200320 2005b8ef82
CI / push-validation (push) Successful in 18s
CI / build (push) Successful in 19s
CI / helm (push) Successful in 24s
CI / lint (push) Successful in 29s
CI / security (push) Successful in 1m11s
CI / e2e_tests (push) Successful in 2m56s
CI / quality (push) Successful in 3m40s
CI / typecheck (push) Successful in 3m59s
CI / integration_tests (push) Successful in 4m3s
CI / unit_tests (push) Successful in 4m55s
CI / docker (push) Successful in 10s
CI / coverage (push) Successful in 10m44s
CI / status-check (push) Successful in 1s
CI / benchmark-regression (push) Has been skipped
CI / benchmark-publish (push) Successful in 1h13m28s
feat(tests): replace all @skip tags with proper @tdd_expected_fail tags or remove them across the entire codebase (#7221)
## Summary

Replaces all 234 bare `@skip` occurrences across 82 Behave feature files with the correct TDD issue-capture tagging system described in CONTRIBUTING.md § Bug Fix Workflow.

Previously, the noxfile ran Behave with `--tags=not @skip`, silently excluding all `@skip`-tagged scenarios from every CI run. These tests never ran, never inverted results via the `@tdd_expected_fail` mechanism, and never contributed to coverage — defeating the purpose of TDD issue-capture testing. Every `@skip` occurrence had a commented-out hint line immediately above it showing the intended proper tags (e.g., `# @tdd_issue @tdd_issue_4272 @tdd_expected_fail @skip`), confirming they were all intended for conversion.

## Changes

### Mechanical conversion (234 replacements across 82 files)
- Extracted the proper TDD tags from the comment hint above each `@skip` line, removed `@skip` from the tag set, and replaced the `@skip` line with those tags.
- Removed the now-redundant comment hint lines alongside each replacement.

### Bug-fixed scenarios — `@tdd_expected_fail` removed (84 scenarios)
- After conversion, ran `nox -s unit_tests` to identify which newly-enabled `@tdd_expected_fail` scenarios now **pass** (their referenced bugs have already been fixed). Removed `@tdd_expected_fail` from those 84 scenarios and their corresponding feature-level tags, leaving only the permanent `@tdd_issue @tdd_issue_<N>` regression-guard tags.
- Affected features include: `tdd_tool_runner_env_precedence`, `tdd_automation_profile_session_leak`, `tls_certificate_check`, `project_create_persist`, `resource_type_bootstrap_*`, and 18 others.

### Noxfile cleanup
- Removed all four `--tags=not @skip` arguments from `noxfile.py` (unit_tests and coverage sessions). With zero `@skip` tags remaining in the codebase, this filter was dead code and its presence would mislead future maintainers into thinking `@skip` is still a supported escape mechanism.

### Regression guard files
- Split the regression guards into two focused files:
  - `tdd_regression_guards_exec_env.feature` for bug #4281 (exec-env precedence)
  - `tdd_regression_guards_session_list.feature` for bug #4271 (session list summary)
- Each file carries only its own `@tdd_issue` tags at the feature level, avoiding cross-contamination via Behave tag inheritance. The `Background` step (`session-list-summary mock`) only appears in the session-list file where it is actually needed.

### Duplicate tag cleanup
- Removed duplicate `@tdd_issue @tdd_issue_4287` tag lines in `tdd_skill_add_regression.feature` (lines 20 and 29).

### Inline comment for retained `@tdd_expected_fail`
- Added inline comment in `ci_workflow_validation.feature:134` explaining why this specific #4227 scenario retains `@tdd_expected_fail` despite #4227 being closed (CI YAML does not encode threshold as a machine-readable value).

### Known edge cases — `@tdd_expected_fail` retained (closed issues, fix on master, scenarios still fail)
The following issues are **closed** and their fixes **are on master**, but the specific test assertions still fail because the fixes address other aspects of the bugs. The `@tdd_expected_fail` tags are functionally correct and must remain until the specific scenario assertions pass:
- `tdd_exec_env_resolution_precedence.feature` — bug #1080 (closed 2026-03-31). The precedence-level-2-vs-4 scenario still fails.
- `session_list_summary_dedup.feature` — bug #3046 (closed 2026-04-05). The dedup-consistency scenarios still fail.
- `actor_add_update_enforcement.feature` — bug #2609 (closed 2026-04-05). The enforcement scenarios still fail.
- `ci_workflow_validation.feature:134` — #4227 (closed 2026-04-08). The CI YAML threshold assertion still fails.

## Verification

- `grep -r "@skip" features/ --include="*.feature"` → **zero results** ✓
- `grep -n "tags=not @skip" noxfile.py` → **zero results** ✓
- `nox -s unit_tests` → **629 features passed, 0 failed** ✓ (up from ~545 before this PR)
- CI all green (coverage ≥ 97%) ✓
- Integration tests (Robot Framework) do not use `@skip` — confirmed no action needed ✓
- E2E tests (Robot Framework) do not use `@skip` — confirmed no action needed ✓
- `CHANGELOG.md` updated with entry for this change ✓
- `CONTRIBUTORS.md` — Rui Hu already listed ✓

## Issues Addressed

Closes #7025

Co-authored-by: CleverThis <hal9000@cleverthis.com>
Reviewed-on: #7221
Reviewed-by: HAL 9000 <HAL9000@cleverthis.com>
Reviewed-by: HAL9001 <hal9001@cleverthis.com>
Co-authored-by: Rui Hu <rui.hu@cleverthis.com>
Co-committed-by: Rui Hu <rui.hu@cleverthis.com>
2026-04-13 04:56:01 +00:00

266 lines
14 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
@tdd_issue @tdd_issue_4268 @tdd_expected_fail
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"
Scenario: export command DatabaseError handler emits debug log
Given session coverage boost a mock service that raises DatabaseError on export
When session coverage boost I invoke the export command to stdout with log capture
Then session coverage boost the debug log "session export failed" was emitted
# ---------------------------------------------------------------
# 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 Import"
And session coverage boost the output contains "Import completed"
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"
Scenario: import command DatabaseError handler emits debug log
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 with log capture
Then session coverage boost the debug log "session import failed" was emitted
# ---------------------------------------------------------------
# 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"
Scenario: tell command DatabaseError handler emits debug log
Given session coverage boost a mock service that raises DatabaseError on append
When session coverage boost I invoke the tell command without stream with log capture
Then session coverage boost the debug log "session tell failed" was emitted
# ---------------------------------------------------------------
# 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