UAT: agents audit command is inaccessible — missing from valid_cmds list in main.py and _REPL_COMMANDS in repl.py #3978

Open
opened 2026-04-06 08:12:58 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/audit-cmd-missing-valid-cmds-repl
  • Commit Message: fix(cli): add audit to valid_cmds in main.py and _REPL_COMMANDS in repl.py
  • Milestone: None (Backlog)
  • Parent Epic: #400

Backlog note: This issue was discovered during autonomous operation
on milestone v3.6.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.


Bug Report

Feature Area: REPL and Interactive Mode / CLI Command Registration
Severity: High — the audit command is completely inaccessible from the command line and REPL
Found by: UAT tester (runtime testing via main() function)


What Was Tested

Runtime behavior of agents audit list when invoked via the main() entry point (the actual command-line path used by the agents binary).

Expected Behavior

agents audit list should work and display audit log entries.

Actual Behavior

$ agents audit list
Error: Invalid command 'audit'
Try 'cleveragents --help' for help.

Exit code: 2

The audit command is completely inaccessible from the command line.

Root Cause

The audit command is registered in the Typer app (src/cleveragents/cli/main.py, line 176-178) but is missing from the valid_cmds list in the main() function (lines 710-746).

The main() function validates the first argument against valid_cmds before dispatching to Typer. Since audit is not in this list, it is rejected with "Error: Invalid command 'audit'" before Typer ever sees it.

Code Location

Registration (correct):

# src/cleveragents/cli/main.py, line 176-178
app.add_typer(
    audit.app,
    name="audit",
    help="View and manage the audit log for security-relevant operations",
)

Missing from valid_cmds (bug):

# src/cleveragents/cli/main.py, lines 710-746
valid_cmds = [
    "version", "info", "diagnostics", "init", "project", "context",
    "plan", "actor", "action", "db", "resource", "skill", "lsp",
    "cleanup", "config", "session", "tool", "validation", "auto-debug",
    "automation-profile", "invariant", "repl", "tui", "server", "repo",
    "tell", "build", "apply", "context-load", "context-add",
    # "audit" is MISSING here!
]

Also missing from REPL commands (secondary bug):

# src/cleveragents/cli/commands/repl.py, lines 45-72
_REPL_COMMANDS: list[str] = [
    # "audit" is MISSING here too!
]

Steps to Reproduce

from cleveragents.cli.main import main

# This fails with exit code 2
result = main(["audit", "list"])
print(result)  # 2

Or from the command line:

agents audit list
# Error: Invalid command 'audit'
# Try 'cleveragents --help' for help.

Impact

  • agents audit list — completely broken
  • agents audit show — completely broken
  • audit command in REPL — tab completion shows it but dispatching fails
  • Security audit functionality is inaccessible to users

Suggested Fix

  1. Add "audit" to valid_cmds in src/cleveragents/cli/main.py:
valid_cmds = [
    ...
    "audit",  # Add this line
    ...
]
  1. Add "audit" to _REPL_COMMANDS in src/cleveragents/cli/commands/repl.py:
_REPL_COMMANDS: list[str] = [
    ...
    "audit",  # Add this line
    ...
]

Subtasks

  • Add "audit" to valid_cmds list in src/cleveragents/cli/main.py
  • Add "audit" to _REPL_COMMANDS list in src/cleveragents/cli/commands/repl.py
  • Write Behave scenario: agents audit list dispatches correctly via main()
  • Write Behave scenario: audit command is available in REPL command list
  • Verify no other registered sub-commands are missing from valid_cmds or _REPL_COMMANDS

Definition of Done

  • agents audit list exits with code 0 and displays audit log entries
  • agents audit show exits with code 0
  • audit is present in valid_cmds in src/cleveragents/cli/main.py
  • audit is present in _REPL_COMMANDS in src/cleveragents/cli/commands/repl.py
  • Behave scenarios covering the fix are passing
  • All nox stages pass
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/audit-cmd-missing-valid-cmds-repl` - **Commit Message**: `fix(cli): add audit to valid_cmds in main.py and _REPL_COMMANDS in repl.py` - **Milestone**: None (Backlog) - **Parent Epic**: #400 > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.6.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- ## Bug Report **Feature Area:** REPL and Interactive Mode / CLI Command Registration **Severity:** High — the `audit` command is completely inaccessible from the command line and REPL **Found by:** UAT tester (runtime testing via `main()` function) --- ## What Was Tested Runtime behavior of `agents audit list` when invoked via the `main()` entry point (the actual command-line path used by the `agents` binary). ## Expected Behavior `agents audit list` should work and display audit log entries. ## Actual Behavior ``` $ agents audit list Error: Invalid command 'audit' Try 'cleveragents --help' for help. ``` Exit code: 2 The `audit` command is completely inaccessible from the command line. ## Root Cause The `audit` command is registered in the Typer app (`src/cleveragents/cli/main.py`, line 176-178) but is **missing from the `valid_cmds` list** in the `main()` function (lines 710-746). The `main()` function validates the first argument against `valid_cmds` before dispatching to Typer. Since `audit` is not in this list, it is rejected with "Error: Invalid command 'audit'" before Typer ever sees it. ### Code Location **Registration** (correct): ```python # src/cleveragents/cli/main.py, line 176-178 app.add_typer( audit.app, name="audit", help="View and manage the audit log for security-relevant operations", ) ``` **Missing from valid_cmds** (bug): ```python # src/cleveragents/cli/main.py, lines 710-746 valid_cmds = [ "version", "info", "diagnostics", "init", "project", "context", "plan", "actor", "action", "db", "resource", "skill", "lsp", "cleanup", "config", "session", "tool", "validation", "auto-debug", "automation-profile", "invariant", "repl", "tui", "server", "repo", "tell", "build", "apply", "context-load", "context-add", # "audit" is MISSING here! ] ``` **Also missing from REPL commands** (secondary bug): ```python # src/cleveragents/cli/commands/repl.py, lines 45-72 _REPL_COMMANDS: list[str] = [ # "audit" is MISSING here too! ] ``` ## Steps to Reproduce ```python from cleveragents.cli.main import main # This fails with exit code 2 result = main(["audit", "list"]) print(result) # 2 ``` Or from the command line: ```bash agents audit list # Error: Invalid command 'audit' # Try 'cleveragents --help' for help. ``` ## Impact - `agents audit list` — completely broken - `agents audit show` — completely broken - `audit` command in REPL — tab completion shows it but dispatching fails - Security audit functionality is inaccessible to users ## Suggested Fix 1. Add `"audit"` to `valid_cmds` in `src/cleveragents/cli/main.py`: ```python valid_cmds = [ ... "audit", # Add this line ... ] ``` 2. Add `"audit"` to `_REPL_COMMANDS` in `src/cleveragents/cli/commands/repl.py`: ```python _REPL_COMMANDS: list[str] = [ ... "audit", # Add this line ... ] ``` --- ## Subtasks - [ ] Add `"audit"` to `valid_cmds` list in `src/cleveragents/cli/main.py` - [ ] Add `"audit"` to `_REPL_COMMANDS` list in `src/cleveragents/cli/commands/repl.py` - [ ] Write Behave scenario: `agents audit list` dispatches correctly via `main()` - [ ] Write Behave scenario: `audit` command is available in REPL command list - [ ] Verify no other registered sub-commands are missing from `valid_cmds` or `_REPL_COMMANDS` ## Definition of Done - [ ] `agents audit list` exits with code 0 and displays audit log entries - [ ] `agents audit show` exits with code 0 - [ ] `audit` is present in `valid_cmds` in `src/cleveragents/cli/main.py` - [ ] `audit` is present in `_REPL_COMMANDS` in `src/cleveragents/cli/commands/repl.py` - [ ] Behave scenarios covering the fix are passing - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
HAL9000 added this to the v3.5.0 milestone 2026-04-09 03:12:25 +00:00
Sign in to join this conversation.
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.

Blocks
#400 Epic: Post-MVP Security
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3978
No description provided.