Skip to content

fix(#305): add pre-flight state guard and worktree lifecycle management - #306

Merged
admarble merged 4 commits into
mainfrom
feature/305-fix-pre-flight-state-guard-and-worktree-lifecycle-
Feb 20, 2026
Merged

admarble merged 4 commits into
mainfrom
feature/305-fix-pre-flight-state-guard-and-worktree-lifecycle-

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

  • Adds a pre-flight state guard that skips issues with ready_for_merge or merged status to prevent duplicate execution (~140 min API budget wasted per re-run)
  • Adds --force flag to bypass the guard when intentional re-execution is needed
  • Implements stale worktree detection (>5 commits behind main) with automatic recreation
  • Adds startup reconciliation to advance ready_for_merge issues whose PRs have merged
  • Updates merger skill documentation with required state update and cleanup steps

Test Plan

  • Build passes (npm run build)
  • Lint passes (npm run lint)
  • All 1304 tests pass (npm test)
  • Unit tests added for reconciliation functions

Pre-PR AC Verification

AC Description Status Evidence
AC-1 Pre-flight skip for ready_for_merge/merged ✅ Implemented run.ts:286-310
AC-2 --force override flag ✅ Implemented run.ts:117-123, run.ts:289
AC-3 Stale worktree recreation ✅ Implemented run.ts:195-267, run.ts:493-528
AC-4 Chain mode compatibility ✅ Implemented Uses existing baseBranch flow
AC-5 Auto-cleanup at run start ✅ Implemented run.ts:277-285, state-utils.ts:374-454
AC-6 Merger skill docs update ✅ Implemented SKILL.md:148-157,201-219
AC-7 Worktree cleanup after merge ✅ Implemented SKILL.md:143-157
AC-8 Graceful degradation ✅ Implemented try/catch throughout
AC-9 Unit tests ✅ Implemented state-utils.test.ts

Closes #305

🤖 Generated with Claude Code

- Add pre-flight guard to skip issues with ready_for_merge/merged status
- Add --force flag to bypass pre-flight guard
- Add stale worktree detection (>5 commits behind main) with recreation
- Add reconcileStateAtStartup() for auto-cleanup at run start
- Add helper functions: isBranchMergedIntoMain, isIssueMergedIntoMain
- Update merger skill docs with state update steps and worktree cleanup
- Implement graceful degradation (continue on failures)
- Add comprehensive unit tests for reconciliation functions

Closes #305
…302)

* fix(#249): Align ScopeAssessmentSettings with ScopeAssessmentConfig

- Add trivialThresholds (maxACItems, maxDirectories) to ScopeAssessmentSettings
- Add directorySpread threshold to settings thresholds
- Add DEFAULT_TRIVIAL_THRESHOLDS with documented defaults
- Update getSettings() to deep merge trivialThresholds
- Create convertSettingsToConfig() for settings→config conversion
- Export converter from src/lib/scope/index.ts
- Update SKILL.md to read settings before scope assessment
- Add comprehensive unit tests for converter function

Enables users to configure custom scope thresholds via .sequant/settings.json

Closes #249

* test(#249): add integration tests for settings → config flow

Verify the full pipeline: settings.json → getSettings() →
convertSettingsToConfig() → valid ScopeAssessmentConfig.

Covers deep merge of partial trivialThresholds and thresholds,
partial individual thresholds (missing red), invalid JSON
fallback, and default value drift guard.

* docs(#249): add scope assessment settings documentation

Operational docs for customizing scope thresholds via
.sequant/settings.json, including options reference,
common workflows, and troubleshooting.
The --force option was defined in RunOptions and checked at runtime,
but never registered with Commander in bin/cli.ts. Users would see
"use --force to re-run" but the flag was unrecognized by the CLI parser.
@admarble
admarble merged commit cb799d4 into main Feb 20, 2026
6 checks passed
@admarble
admarble deleted the feature/305-fix-pre-flight-state-guard-and-worktree-lifecycle- branch February 20, 2026 15:44
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.

fix: pre-flight state guard and worktree lifecycle management

1 participant