Skip to content

feat(cli): upgrade doctor to interactive resolution queue#51

Merged
JacksonFergusonDev merged 8 commits intomainfrom
feat/active-doctor
Feb 21, 2026
Merged

feat(cli): upgrade doctor to interactive resolution queue#51
JacksonFergusonDev merged 8 commits intomainfrom
feat/active-doctor

Conversation

@JacksonFergusonDev
Copy link
Owner

Summary

This PR transitions git pulsar doctor from a purely read-only diagnostic tool into a two-stage pipeline. To optimize for both safety and UX, the doctor now runs its standard silent diagnostic scans behind spinners (Stage 1), but instead of just printing warnings, it appends actionable fixes to an interactive resolution queue (Stage 2). At the end of the run, the user is explicitly prompted [y/N] to execute safe auto-fixes.

This closes the Phase 1 roadmap item: "Active Doctor".

Key Changes

1. Two-Stage Pipeline Architecture (cli.py)

  • Introduced a DoctorAction dataclass to encapsulate issue descriptions, prompt text, and execution closures.
  • Separated the diagnostic gathering phase from the execution loop to prevent terminal rendering glitches with rich.console.status.

2. Tier 1 Safe Auto-Fixes (Interactive)

The following issues now prompt the user for automatic resolution:

  • Registry Cleanup: Prompts to remove missing/ghost repository paths from ~/.local/state/git-pulsar/registry.
  • Daemon Installation: Prompts to run service.install() if the daemon is stopped.
  • Systemd Linger (Linux): Prompts to execute loginctl enable-linger $USER if background lingering is disabled.
  • Session Drift: Prompts to run git pulsar sync if a newer remote session is detected.
  • Paused Repositories: Prompts to resume backups (removes .git/pulsar_paused).
  • Stale Index Locks [NEW]: Identifies .git/index.lock files older than 2 hours and safely prompts to delete them, resolving a classic git lockup state.

3. Tier 2 Guided Manual Interventions (Read-Only)

For issues that require user context, the doctor now provides explicit, copy-pasteable resolution steps instead of generic warnings:

  • Git Hooks: Outputs the exact bash snippet (if [[ $GIT_REFLOG_ACTION == *"wip/pulsar"* ]]; then exit 0; fi) needed to bypass strict pre-commit or pre-push hooks.
  • Large Files: Outputs the exact command (git pulsar ignore <filename>) needed to bypass size limit blockers.
  • SSH Connectivity: Provides clearer guidance on loading ssh-agent keys.

Testing & Verification (test_cli.py)

  • Added coverage for the interactive execution loop, verifying that closures are executed on y and bypassed on N.
  • Added isolated tests for each Tier 1 auto-fix closure (stale locks, ghost registry, sync triggers).
  • Added regex/stdout assertions to verify the exact formatting of Tier 2 manual intervention snippets.

Documentation Updates

  • README.md: Marked "Active Doctor" as complete in the Phase 1 roadmap and updated the command reference.
  • src/README.md: Updated the module map and added an architecture invariant guaranteeing explicit user confirmation before state-altering auto-fixes.
  • tests/README.md: Documented the new interactive UI testing strategies.

Establishes a two-stage pipeline for `git pulsar doctor` by separating
the diagnostic scanning phase from an interactive resolution phase.
Introduces the `DoctorAction` dataclass to encapsulate actionable fixes
and adds the execution loop at the end of the doctor routine.
Ports elementary system-level checks to the interactive resolution queue.
Modifies registry cleanup to explicitly prompt before removing ghost
directories. Adds prompts to install the background service if stopped,
and to enable systemd user lingering on Linux if it is currently disabled.
Implements interactive resolutions for repository-specific issues during
the diagnostic run. Adds auto-fixes for detected remote session drift
(triggering a sync), resuming paused repositories, and a new check to
identify and safely remove orphaned `.git/index.lock` files older than 2 hours.
Updates diagnostic reporting for Tier 2 issues that cannot be safely
auto-fixed. Enhances warnings for SSH connectivity failures, large file
blockers, and strict git hooks by providing explicit, copy-pasteable
terminal commands and actionable resolution steps directly in the output.
Introduces test coverage for the two-stage interactive doctor pipeline.
Validates that the execution loop respects user prompts (executing confirmed
closures and bypassing declined ones). Adds specific coverage for Tier 1
auto-fixes (stale index lock removal, ghost registry cleanup, session drift
syncing, and unpausing repositories) and verifies the exact stdout formatting
for Tier 2 guided manual interventions (large files and strict git hooks).
Updates the tests/README.md to document the verification strategy for the
new two-stage interactive doctor pipeline. Adds coverage descriptions for
the Interactive Resolution Queue, auto-fix closures, and stdout formatting
for guided manual interventions within `test_cli.py`.
Updates the `src/README.md` module map to document the two-stage interactive
diagnostic pipeline within `cli.py`. Outlines the separation between the
scanning phase and the interactive resolution queue, and introduces a new
invariant guaranteeing explicit user confirmation before state-altering auto-fixes.
Updates the root README to reflect the completion of the "Active Doctor"
roadmap item. Modifies the feature highlight and command reference for
`git pulsar doctor` to note its new interactive auto-fix capabilities,
maintaining a clean diff for surrounding context.
@JacksonFergusonDev JacksonFergusonDev merged commit e137a98 into main Feb 21, 2026
4 checks passed
@JacksonFergusonDev JacksonFergusonDev deleted the feat/active-doctor branch February 21, 2026 04:42
@JacksonFergusonDev JacksonFergusonDev changed the title Feat/active doctor feat(cli): upgrade doctor to interactive resolution queue Feb 21, 2026
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