Skip to content

feat: add move_plan_on_completion config option#307

Merged
umputun merged 10 commits intoumputun:masterfrom
bronislav:move-plan-on-completion-config
Apr 28, 2026
Merged

feat: add move_plan_on_completion config option#307
umputun merged 10 commits intoumputun:masterfrom
bronislav:move-plan-on-completion-config

Conversation

@bronislav
Copy link
Copy Markdown
Contributor

Summary

Adds move_plan_on_completion config option (default true) that controls whether completed plans move to docs/plans/completed/ on success. Set to false for workflows that manage plan lifecycle externally (e.g. spec-driven tooling with separate archive steps).

Part 1 of 2 for #306 (OpenSpec integration). Kept scope tight: no OpenSpec-specific detection here, just a generic toggle that any external workflow can use.

Changes

  • pkg/config/values.goMovePlanOnCompletion + MovePlanOnCompletionSet fields, INI loader, merge block (local overrides global even when explicit false)
  • pkg/config/config.goMovePlanOnCompletion on Config struct, defaults to true
  • pkg/config/defaults/config — commented template entry
  • cmd/ralphex/main.goshouldMovePlan() predicate guards the existing MovePlanToCompleted call; nil-safe against req.Config
  • Tests: values_test.go, config_test.go, main_test.go (including nil_config case)
  • Docs: README.md, CLAUDE.md, llms.txt

Default behavior is unchanged.

Test plan

  • make test passes
  • make lint clean
  • Reviewer: verify existing behavior preserved when option is unset (default true)
  • Reviewer: verify move_plan_on_completion = false in local config takes precedence over global true

@bronislav bronislav requested a review from umputun as a code owner April 27, 2026 20:56
@bronislav bronislav marked this pull request as draft April 27, 2026 20:56
@bronislav bronislav force-pushed the move-plan-on-completion-config branch 2 times, most recently from 1079694 to ed80122 Compare April 27, 2026 21:33
Plans part 1 of 2 for issue umputun#306: a boolean config option (default
true) to suppress the move-to-completed step. Enables workflows that
manage plan lifecycle externally (e.g. spec-driven tooling with
separate archive steps) without coupling ralphex to any specific tool.
Introduces MovePlanOnCompletion and MovePlanOnCompletionSet fields on
the Values struct, mirroring the FinalizeEnabled pattern. Adds an INI
loader block for move_plan_on_completion and a merge block so local
config cleanly overrides global even when the explicit value is false.

Part of issue umputun#306, task 1 of the move_plan_on_completion config plan.
Consolidates the conditions for moving a completed plan file into a single
testable helper. Wires MovePlanOnCompletion into the guard so users who
set move_plan_on_completion=false in config keep the plan file in place.
- guard shouldMovePlan against nil req.Config to prevent latent nil-deref
  panic in the success path of executePlan; add nil_config test case
- extend TestLoad_AllUserValues to cover move_plan_on_completion so the
  'all user values' assertion actually includes the new field
@bronislav bronislav force-pushed the move-plan-on-completion-config branch from ed80122 to 10456b7 Compare April 27, 2026 21:38
@bronislav bronislav marked this pull request as ready for review April 27, 2026 21:39
Copy link
Copy Markdown
Owner

@umputun umputun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few things worth fixing:

  1. shouldMovePlan nil-check exists only for tests (cmd/ralphex/main.go:828-830). No production caller passes a nil Config. Every executePlanRequest literal assigns it, and executePlan already dereferences req.Config at line 540 without a nil check. The req.Config != nil clause is there only so TestShouldMovePlan/nil_config passes. Drop the nil branch and the test case.

  2. MovePlanOnCompletionSet on Config is dead state (pkg/config/config.go:77). Production never reads it; only config_test.go:387,432 assert it. The *Set field is needed on Values for merge logic, but on Config (post-assembly) it's unused. Other existing fields do the same (CodexEnabledSet, FinalizeEnabledSet, etc.) but no reason to perpetuate it for the new one. Drop the field on Config and the matching assertions.

  3. default-true split across layers (pkg/config/config.go:281-285). Default is applied post-assembly in loadConfigFromDirs instead of in the embedded template. Mirrors NotifyOnError/NotifyOnComplete precedent so not strictly wrong, but cleaner to uncomment move_plan_on_completion = true in pkg/config/defaults/config and drop the post-assembly patch. Minor.

  4. redundant test assertions (pkg/config/config_test.go:412,431-432). Dedicated TestLoad_MovePlanOnCompletion already covers default/explicit-true/explicit-false; TestLoad_AllUserValues doesn't need to re-assert the same field. Resolves automatically if you apply #2.

naming: move_plan_on_completion doesn't quite match the project's _enabled / use_ convention (codex_enabled, finalize_enabled, use_worktree). I agreed to it in #306 so it's settled, just noting.

- drop nil-Config branch in shouldMovePlan (no production caller passes
  nil; was only there to satisfy a test case)
- remove MovePlanOnCompletionSet from Config — it's post-assembly state
  that nothing in production reads; *Set is still tracked on Values for
  merge logic where it's actually needed
- uncomment move_plan_on_completion = true in the embedded config
  template so the default flows through normal loader merge instead of
  being patched on in loadConfigFromDirs
- drop redundant assertions from TestLoad_AllUserValues (the field
  already has dedicated coverage in TestLoad_MovePlanOnCompletion)
@bronislav bronislav requested a review from umputun April 28, 2026 05:04
Copy link
Copy Markdown
Owner

@umputun umputun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thx

@umputun umputun merged commit 98c2935 into umputun:master Apr 28, 2026
2 checks passed
@bronislav bronislav deleted the move-plan-on-completion-config branch April 28, 2026 15:57
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.

2 participants