fix(cli): add spec-required Validation and Merge panels and correct title/message in agents session import #3460

Merged
freemo merged 2 commits from fix/session-import-missing-validation-merge-panels into master 2026-04-05 18:08:09 +00:00
Owner

Summary

Fixes five spec deviations in the agents session import Rich output rendering (issue #3428).

Changes

Core Fix (src/cleveragents/cli/commands/session.py)

The import_session() CLI function previously rendered a single panel with wrong title and wrong fields. This PR:

  1. Renames panel title from "Session Imported""Session Import" per spec §"agents session import"
  2. Fixes primary panel fields: replaces Actor and Namespace with Input (file path) and Schema (version)
  3. Adds Validation panel with Checksum: verified, Schema: compatible, Actor Ref: resolved/none
  4. Adds Merge panel with Existing: none, Strategy: create new
  5. Fixes success message from "Session imported""Import completed"

Data Sources

  • Input: the --input file path argument
  • Schema: data['schema_version'] from the import JSON (read before calling service)
  • Actor Ref: "resolved" if actor_name present in import data, else "none"
  • Checksum/Schema validation: always "verified"/"compatible" — service raises SessionImportError on failure before reaching this code
  • Merge Existing/Strategy: always "none"/"create new" — import always creates a new session with a fresh ULID

Tests Updated

  • features/session_cli.feature: updated existing scenario + added new scenario verifying all panel fields
  • features/session_cli_coverage_boost.feature: updated assertion from "Session Imported" to "Session Import" + "Import completed"
  • robot/helper_session_cli.py: updated export_import_roundtrip() assertions + added import_rich_panels() test function
  • robot/session_cli.robot: added Session Import Rich Output Panels test case

Before / After

Before:

╭─────────── Session Imported ───────────╮
│ Session ID: 01HXM3D3B2W4CQYQ3P4ZB8A5T1 │
│ Actor: openai/gpt-4                    │
│ Messages: 6                            │
│ Namespace: local                       │
╰────────────────────────────────────────╯
✓ OK Session imported

After (matches spec):

╭─ Session Import ────────────────────────╮
│ Input: /tmp/weekly-planning.json        │
│ Session ID: 01HXM3D3B2W4CQYQ3P4ZB8A5T1  │
│ Messages: 6                             │
│ Schema: 1.0                             │
╰─────────────────────────────────────────╯
╭─ Validation ────────────╮
│ Checksum: verified      │
│ Schema: compatible      │
│ Actor Ref: resolved     │
╰─────────────────────────╯
╭─ Merge ──────────────╮
│ Existing: none       │
│ Strategy: create new │
╰──────────────────────╯
✓ OK Import completed

Closes #3428


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker

## Summary Fixes five spec deviations in the `agents session import` Rich output rendering (issue #3428). ## Changes ### Core Fix (`src/cleveragents/cli/commands/session.py`) The `import_session()` CLI function previously rendered a single panel with wrong title and wrong fields. This PR: 1. **Renames panel title** from `"Session Imported"` → `"Session Import"` per spec §"agents session import" 2. **Fixes primary panel fields**: replaces `Actor` and `Namespace` with `Input` (file path) and `Schema` (version) 3. **Adds `Validation` panel** with `Checksum: verified`, `Schema: compatible`, `Actor Ref: resolved/none` 4. **Adds `Merge` panel** with `Existing: none`, `Strategy: create new` 5. **Fixes success message** from `"Session imported"` → `"Import completed"` ### Data Sources - `Input`: the `--input` file path argument - `Schema`: `data['schema_version']` from the import JSON (read before calling service) - `Actor Ref`: `"resolved"` if `actor_name` present in import data, else `"none"` - `Checksum`/`Schema` validation: always `"verified"`/`"compatible"` — service raises `SessionImportError` on failure before reaching this code - `Merge Existing`/`Strategy`: always `"none"`/`"create new"` — import always creates a new session with a fresh ULID ### Tests Updated - `features/session_cli.feature`: updated existing scenario + added new scenario verifying all panel fields - `features/session_cli_coverage_boost.feature`: updated assertion from `"Session Imported"` to `"Session Import"` + `"Import completed"` - `robot/helper_session_cli.py`: updated `export_import_roundtrip()` assertions + added `import_rich_panels()` test function - `robot/session_cli.robot`: added `Session Import Rich Output Panels` test case ## Before / After **Before:** ``` ╭─────────── Session Imported ───────────╮ │ Session ID: 01HXM3D3B2W4CQYQ3P4ZB8A5T1 │ │ Actor: openai/gpt-4 │ │ Messages: 6 │ │ Namespace: local │ ╰────────────────────────────────────────╯ ✓ OK Session imported ``` **After (matches spec):** ``` ╭─ Session Import ────────────────────────╮ │ Input: /tmp/weekly-planning.json │ │ Session ID: 01HXM3D3B2W4CQYQ3P4ZB8A5T1 │ │ Messages: 6 │ │ Schema: 1.0 │ ╰─────────────────────────────────────────╯ ╭─ Validation ────────────╮ │ Checksum: verified │ │ Schema: compatible │ │ Actor Ref: resolved │ ╰─────────────────────────╯ ╭─ Merge ──────────────╮ │ Existing: none │ │ Strategy: create new │ ╰──────────────────────╯ ✓ OK Import completed ``` Closes #3428 --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-worker
Replace the hardcoded help string in TuiCommandRouter.handle() with a
dynamic lookup against SLASH_COMMAND_SPECS from slash_catalog.py.

Changes:
- Add _help_command(), _help_list_all(), _help_for_command() methods to
  TuiCommandRouter
- /help (no args): iterates SLASH_COMMAND_SPECS, groups commands by
  namespace (sorted alphabetically), renders all 70 commands with
  descriptions in colon-namespaced format (e.g. persona:list)
- /help <command>: looks up the given command in SLASH_COMMAND_SPECS and
  renders its full help (group, description)
- /help <unknown>: returns 'Unknown command: /<cmd>' message
- /help /persona:list (with leading slash): strips the slash and resolves
  correctly
- Import defaultdict and SLASH_COMMAND_SPECS at module level

Tests:
- Update tui_commands_coverage.feature: replace old exact-match scenario
  for help text with new dynamic-listing assertions
- Add tui_commands_coverage_steps.py: new 'should contain' step definition
- Add tui_help_command_full_catalog.feature: 12 BDD scenarios covering
  /help no-args, /help <command>, /help <unknown>, namespace grouping,
  colon-namespaced format, and regression against old hardcoded string
- Add tui_help_command_full_catalog_steps.py: step definitions for the
  new feature (all-commands check, not-equal assertion)
- Add robot/tui_help_command.robot: 5 Robot Framework integration tests
  verifying the help command via direct Python invocation and headless
  TUI startup

Closes #3434

---
**Automated by CleverAgents Bot**
Supervisor: Implementation | Agent: ca-issue-worker
fix(cli): add spec-required Validation and Merge panels and correct title/message in agents session import
Some checks failed
CI / lint (pull_request) Successful in 20s
CI / typecheck (pull_request) Successful in 47s
CI / quality (pull_request) Successful in 30s
CI / security (pull_request) Successful in 1m2s
CI / build (pull_request) Successful in 23s
CI / helm (pull_request) Successful in 24s
CI / unit_tests (pull_request) Successful in 7m10s
CI / e2e_tests (pull_request) Successful in 16m55s
CI / integration_tests (pull_request) Failing after 23m17s
CI / coverage (pull_request) Successful in 10m46s
CI / docker (pull_request) Successful in 1m22s
CI / status-check (pull_request) Failing after 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 57m4s
bffec08f65
Fixes five spec deviations in the agents session import Rich output:

1. Renamed panel title from 'Session Imported' to 'Session Import' per spec
2. Replaced Actor/Namespace fields with Input (file path) and Schema (version)
   in the primary panel
3. Added 'Validation' panel with Checksum, Schema, and Actor Ref fields
4. Added 'Merge' panel with Existing and Strategy fields
5. Fixed success message from 'Session imported' to 'Import completed'

Data sources:
- Input: the --input file path argument
- Schema: data['schema_version'] from the import JSON (available before
  calling service.import_session())
- Actor Ref: 'resolved' if actor_name present in import data, else 'none'
- Checksum/Schema validation: always 'verified'/'compatible' since the
  service raises SessionImportError on failure before reaching this code
- Merge Existing/Strategy: always 'none'/'create new' since import always
  creates a new session with a fresh ULID

Updated tests:
- features/session_cli.feature: updated existing scenario and added new
  scenario verifying all panel fields
- features/session_cli_coverage_boost.feature: updated assertion
- robot/helper_session_cli.py: updated export_import_roundtrip assertions
  and added import_rich_panels() test function
- robot/session_cli.robot: added Session Import Rich Output Panels test case

Closes #3428
freemo left a comment

Code Review — PR #3460

Focus Areas: specification-compliance, behavior-correctness, api-consistency

Reviewed the full diff across all 5 changed files against the linked issue #3428, the spec (§"agents session import"), and CONTRIBUTING.md standards.


What Looks Good

Specification Compliance (Core Fix)

  • Panel title correctly changed from "Session Imported""Session Import" per spec
  • Primary panel fields correctly replaced: Actor/NamespaceInput (file path) / Schema (version)
  • Validation panel added with Checksum, Schema, Actor Ref fields — matches spec layout
  • Merge panel added with Existing, Strategy fields — matches spec layout
  • Success message correctly changed from "Session imported""Import completed"
  • Field ordering in the Session Import panel matches the spec example (Input, Session ID, Messages, Schema)

Behavior Correctness

  • schema_version and actor_name are correctly extracted from the data dict before calling service.import_session(data), ensuring the values are available for panel rendering
  • actor_ref_status logic ("resolved" if actor_name present, else "none") is correct
  • Error handling is preserved — SessionImportError and DatabaseError still propagate properly

Test Quality

  • features/session_cli.feature: Updated existing import scenario + added new "Import session shows correct panel fields" scenario that verifies all 8 field labels across all 3 panels — thorough
  • features/session_cli_coverage_boost.feature: Import scenario assertions updated to match new output
  • robot/helper_session_cli.py: Added import_rich_panels() function with comprehensive assertions for every panel and field
  • robot/session_cli.robot: Added Session Import Rich Output Panels integration test case
  • Tests cover both the happy path and the specific field-level assertions

Commit Message

  • Follows Conventional Changelog format: fix(cli): add spec-required Validation and Merge panels...
  • Includes Closes #3428 footer
  • Detailed body explaining all 5 changes and data sources

⚠️ Issues Found

1. [PROCESS] Unrelated Commit Included in PR — Severity: High

The branch fix/session-import-missing-validation-merge-panels contains two commits ahead of master:

# SHA Issue Description
1 260d54a2 #3434 fix(tui): make /help command list all catalogued slash commands from SLASH_COMMAND_SPECS
2 bffec08f #3428 fix(cli): add spec-required Validation and Merge panels...

Commit 260d54a2 is for an entirely different issue (#3434 — TUI /help command) and is not related to this PR's scope (session import panels). This violates the atomic commit principle from CONTRIBUTING.md: "Each commit should represent a single, complete, and self-contained piece of work that resolves one issue."

Required: Rebase the branch so it only contains the commit for #3428. The #3434 commit should be on its own branch/PR.

2. [PROCESS] Missing Milestone — Severity: Medium

The PR has "milestone": null. Per CONTRIBUTING.md, every PR must be assigned to a milestone. The linked issue #3428 notes it's a backlog item, but the PR still needs a milestone assignment (even if it's a backlog/unscheduled milestone).

3. [CODE] # type: ignore in robot/helper_session_cli.py — Severity: Low

Line at the bottom of robot/helper_session_cli.py:

cmd()  # type: ignore[operator]

This # type: ignore suppression is forbidden by CONTRIBUTING.md. While this line was pre-existing on master, this PR modifies the file (adds import_rich_panels function and updates _COMMANDS dict) and should fix the violation while touching the file. The fix is straightforward — use a proper type annotation for _COMMANDS (e.g., dict[str, Callable[[], None]] instead of dict[str, object]).

4. [DESIGN] Hardcoded Validation/Merge Panel Values — Severity: Informational

The Validation panel always shows Checksum: verified, Schema: compatible and the Merge panel always shows Existing: none, Strategy: create new. The PR description explains this is because service.import_session() raises SessionImportError on validation failure before reaching the panel rendering code, and import always creates new sessions.

This is logically correct but means the panels are purely cosmetic — they can never show any other values. This is worth noting for future consideration:

  • If the service ever adds soft validation warnings (e.g., schema deprecation), the panels won't reflect them
  • If merge strategies are added later, the hardcoded values will need updating

No action required now, but consider adding a # TODO comment noting this coupling.


Summary

Aspect Status
Spec compliance (panels, fields, messages) Correct
Behavior correctness Correct
API consistency Consistent with other commands
Test coverage (Behave + Robot) Thorough
Commit message format Correct
Atomic commit (single issue) Contains unrelated #3434 commit
Milestone assignment Missing
# type: ignore prohibition ⚠️ Pre-existing but should be fixed

Overall: The core implementation is solid and correctly addresses all 5 spec deviations from issue #3428. The test coverage is comprehensive across both Behave and Robot Framework. However, the branch needs to be rebased to remove the unrelated commit for #3434, and the PR needs a milestone assignment before merge.


Automated by CleverAgents Bot
Reviewer: Code Quality | Agent: ca-pr-self-reviewer

## Code Review — PR #3460 **Focus Areas:** specification-compliance, behavior-correctness, api-consistency Reviewed the full diff across all 5 changed files against the linked issue #3428, the spec (§"agents session import"), and CONTRIBUTING.md standards. --- ### ✅ What Looks Good **Specification Compliance (Core Fix)** - Panel title correctly changed from `"Session Imported"` → `"Session Import"` per spec - Primary panel fields correctly replaced: `Actor`/`Namespace` → `Input` (file path) / `Schema` (version) - `Validation` panel added with `Checksum`, `Schema`, `Actor Ref` fields — matches spec layout - `Merge` panel added with `Existing`, `Strategy` fields — matches spec layout - Success message correctly changed from `"Session imported"` → `"Import completed"` - Field ordering in the Session Import panel matches the spec example (`Input`, `Session ID`, `Messages`, `Schema`) **Behavior Correctness** - `schema_version` and `actor_name` are correctly extracted from the `data` dict *before* calling `service.import_session(data)`, ensuring the values are available for panel rendering - `actor_ref_status` logic (`"resolved"` if `actor_name` present, else `"none"`) is correct - Error handling is preserved — `SessionImportError` and `DatabaseError` still propagate properly **Test Quality** - `features/session_cli.feature`: Updated existing import scenario + added new "Import session shows correct panel fields" scenario that verifies all 8 field labels across all 3 panels — thorough - `features/session_cli_coverage_boost.feature`: Import scenario assertions updated to match new output - `robot/helper_session_cli.py`: Added `import_rich_panels()` function with comprehensive assertions for every panel and field - `robot/session_cli.robot`: Added `Session Import Rich Output Panels` integration test case - Tests cover both the happy path and the specific field-level assertions **Commit Message** - ✅ Follows Conventional Changelog format: `fix(cli): add spec-required Validation and Merge panels...` - ✅ Includes `Closes #3428` footer - ✅ Detailed body explaining all 5 changes and data sources --- ### ⚠️ Issues Found #### 1. **[PROCESS] Unrelated Commit Included in PR** — Severity: High The branch `fix/session-import-missing-validation-merge-panels` contains **two commits** ahead of master: | # | SHA | Issue | Description | |---|-----|-------|-------------| | 1 | `260d54a2` | #3434 | `fix(tui): make /help command list all catalogued slash commands from SLASH_COMMAND_SPECS` | | 2 | `bffec08f` | #3428 | `fix(cli): add spec-required Validation and Merge panels...` | Commit `260d54a2` is for an entirely different issue (#3434 — TUI /help command) and is **not related** to this PR's scope (session import panels). This violates the atomic commit principle from CONTRIBUTING.md: *"Each commit should represent a single, complete, and self-contained piece of work that resolves one issue."* **Required:** Rebase the branch so it only contains the commit for #3428. The #3434 commit should be on its own branch/PR. #### 2. **[PROCESS] Missing Milestone** — Severity: Medium The PR has `"milestone": null`. Per CONTRIBUTING.md, every PR must be assigned to a milestone. The linked issue #3428 notes it's a backlog item, but the PR still needs a milestone assignment (even if it's a backlog/unscheduled milestone). #### 3. **[CODE] `# type: ignore` in `robot/helper_session_cli.py`** — Severity: Low Line at the bottom of `robot/helper_session_cli.py`: ```python cmd() # type: ignore[operator] ``` This `# type: ignore` suppression is **forbidden** by CONTRIBUTING.md. While this line was pre-existing on master, this PR modifies the file (adds `import_rich_panels` function and updates `_COMMANDS` dict) and should fix the violation while touching the file. The fix is straightforward — use a proper type annotation for `_COMMANDS` (e.g., `dict[str, Callable[[], None]]` instead of `dict[str, object]`). #### 4. **[DESIGN] Hardcoded Validation/Merge Panel Values** — Severity: Informational The Validation panel always shows `Checksum: verified`, `Schema: compatible` and the Merge panel always shows `Existing: none`, `Strategy: create new`. The PR description explains this is because `service.import_session()` raises `SessionImportError` on validation failure before reaching the panel rendering code, and import always creates new sessions. This is **logically correct** but means the panels are purely cosmetic — they can never show any other values. This is worth noting for future consideration: - If the service ever adds soft validation warnings (e.g., schema deprecation), the panels won't reflect them - If merge strategies are added later, the hardcoded values will need updating No action required now, but consider adding a `# TODO` comment noting this coupling. --- ### Summary | Aspect | Status | |--------|--------| | Spec compliance (panels, fields, messages) | ✅ Correct | | Behavior correctness | ✅ Correct | | API consistency | ✅ Consistent with other commands | | Test coverage (Behave + Robot) | ✅ Thorough | | Commit message format | ✅ Correct | | Atomic commit (single issue) | ❌ Contains unrelated #3434 commit | | Milestone assignment | ❌ Missing | | `# type: ignore` prohibition | ⚠️ Pre-existing but should be fixed | **Overall:** The core implementation is solid and correctly addresses all 5 spec deviations from issue #3428. The test coverage is comprehensive across both Behave and Robot Framework. However, the branch needs to be rebased to remove the unrelated commit for #3434, and the PR needs a milestone assignment before merge. --- **Automated by CleverAgents Bot** Reviewer: Code Quality | Agent: ca-pr-self-reviewer
freemo merged commit b82a9b6962 into master 2026-04-05 18:08:09 +00:00
freemo deleted branch fix/session-import-missing-validation-merge-panels 2026-04-05 18:08:10 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core!3460
No description provided.