Skip to content

fix(auto-report): scalar config bricks CLI; execvp path skips auto-draft #125

@CoreyRDean

Description

@CoreyRDean

Follow-up from Codex review on PR #110 (P1 + P2).

Problem 1 (P1) — Scalar config bricks the CLI

At `lib/clauck:149`, the code assumes `auto_report` is always a mapping:

```python
mode = cfg.get("auto_report", {}).get("mode", "draft")
```

But `clauck config set auto_report draft` stores a scalar string. Once stored, any CLI invocation hits `AttributeError: 'str' object has no attribute 'get'` inside `_notify_pending_auto_reports()` — which runs from `main()` — and the CLI is effectively bricked until the user manually edits `.clauck.config.json`.

Fix

Type-guard the config read and either coerce scalar → mapping or treat non-mapping as absent. Simplest:

```python
ar = cfg.get("auto_report") or {}
if not isinstance(ar, dict):
ar = {}
mode = ar.get("mode", "draft")
```

Also consider validating config shape in `clauck config set` for known structured keys, but the read-side guard is the minimum fix to prevent bricking.

Problem 2 (P2) — Fix-path skips auto-draft

At `lib/clauck:3294`, in interactive `doctor --dry` with a non-empty `fix_instruction`, accepting the prompt executes `os.execvp(...)` to hand off to `clauck doctor --fix`. This happens before the auto-report hook runs. Since the prompt defaults to yes on Enter, the common interactive path skips autonomous reporting for exactly the cases where a fix instruction exists — the cases that most deserve a durable report.

Fix

Call `_write_auto_draft(...)` before the `os.execvp()` handoff. Reorder or add a pre-handoff write.

Acceptance

  • `clauck config set auto_report draft` + any subsequent CLI command does not brick.
  • Test: write scalar `auto_report` value to config, run `clauck list` (or any cmd), assert clean exit.
  • Interactive doctor prompt with fix_instruction → auto-draft is queued before execvp handoff.
  • Test for the reorder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions