Skip to content

Preserve auto-report compatibility and doctor draft handoff#145

Merged
CoreyRDean merged 1 commit into
mainfrom
fix/auto-report-compat-handoff
May 21, 2026
Merged

Preserve auto-report compatibility and doctor draft handoff#145
CoreyRDean merged 1 commit into
mainfrom
fix/auto-report-compat-handoff

Conversation

@CoreyRDean
Copy link
Copy Markdown
Owner

Non-technical summary

This fixes a reliability bug in clauck's auto-report surface. Older installs that still have "auto_report": "draft" in config no longer crash the CLI, and clauck doctor --dry now queues the background draft before handing off to doctor --fix when you accept the suggested fix.

Why this matters now: issue #125 is still open on main, and both failure modes undermine clauck's inspectability. One bricks routine CLI usage after a legacy config write; the other silently drops the durable report on the most common interactive fix path.

The system is better afterward because report compatibility is preserved across config shape changes, and doctor no longer loses the auto-draft during an immediate fix handoff.

Technical summary

  • Added a shared auto-report mode normalizer in lib/clauck that accepts both legacy scalar config ({"auto_report": "draft"}) and the nested auto_report.mode shape.
  • Routed _notify_pending_auto_reports(), _write_auto_draft(), and cmd_status() through that normalizer so CLI entry, status output, and draft writes all stay compatible.
  • Refactored the dry-run doctor auto-report decision into a single precomputed branch and write the draft before os.execvp() when the user accepts the queued fix.
  • Added regression coverage in tests/test_clauck_report.py for:
    • legacy scalar config on CLI entry
    • legacy scalar config in cmd_status()
    • legacy scalar config in _write_auto_draft() and _notify_pending_auto_reports()
    • doctor dry-run draft ordering before the fix handoff

Relevant intent: this preserves inspectability and trust-via-proof by keeping report surfaces usable across config evolution and by ensuring doctor findings are durably recorded even when the operator immediately opts into the fix path.

Tests:

  • python3 -m unittest -v tests.test_clauck_report
  • python3 -m unittest discover tests -v

Breaking changes: none intended.

Additional notes

Trade-off: invalid non-string/non-mapping auto_report values now normalize to off instead of raising. That favors CLI survivability over surfacing malformed config as a hard crash.

Deferred follow-up: this does not rewrite old config files in place; it preserves compatibility at read time only.

Remaining gap: if we later want stricter config validation, that should happen as an explicit migration or clauck config repair path rather than by breaking reads again.

@CoreyRDean CoreyRDean marked this pull request as ready for review May 21, 2026 13:08
@CoreyRDean CoreyRDean merged commit 79e826c into main May 21, 2026
2 checks passed
@CoreyRDean CoreyRDean deleted the fix/auto-report-compat-handoff branch May 21, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant