Skip to content

refactor(agent): extract settings conflict planner from bootstrap#759

Open
jojosenthusiast wants to merge 1 commit into
PostHog:mainfrom
jojosenthusiast:refactor/settings-conflict-planner
Open

refactor(agent): extract settings conflict planner from bootstrap#759
jojosenthusiast wants to merge 1 commit into
PostHog:mainfrom
jojosenthusiast:refactor/settings-conflict-planner

Conversation

@jojosenthusiast

Copy link
Copy Markdown

Fixes #756

Summary

  • Moves settings-conflict decision logic into a pure planner.
  • Keeps bootstrap as the side-effect executor for logging, analytics, backup, and UI flow.
  • Adds focused unit coverage for conflict logging, analytics events, auto-fix, and fail-closed behavior.

Verification

  • node_modules\.bin\vitest.cmd run src/lib/agent/__tests__/settings-conflict-planner.test.ts
  • git diff --check main...HEAD

Risk

Low. This is intended to be behavior-preserving refactoring with focused planner coverage.

Move the settings-conflict orchestration out of the runner bootstrap into a
pure planner module so the log/analytics/fail-closed decisions are unit-
testable in isolation. Behavior preserving: the executor performs the exact
same logToFile + analytics.wizardCapture calls (and in the same order) the
inline orchestration used to perform, plus the same showSettingsOverride
fail-closed list.

- src/lib/agent/settings-conflict-planner.ts: pure planner returning a list
  of log/analytics actions plus the auto-fix decision and final unfixable
  classification; no I/O, no analytics, no logging.
- src/lib/agent/__tests__/settings-conflict-planner.test.ts: 9 tests covering
  the none/managed/user/project-local/writable branches plus the auto-fix
  success and failure outcomes.
- src/lib/agent/runner/shared/bootstrap.ts: thin executor loop that runs the
  plan's actions and feeds the backupAndFixClaudeSettings boolean back into
  planAutoFixOutcome.

Refs: PostHog#756
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.

refactor: move settings-conflict orchestration out of the runner into a pure planner

1 participant