Repository navigation
Conversation
Replace the scattered `PHASE_PROMPTS` / `AIDER_PHASE_PROMPTS` / `ISOLATED_PHASES` / `UI_LABELS` / `SECURITY_LABELS` constants with a uniform `PhaseDefinition` record per phase, registered against a single `phaseRegistry` singleton at module load. All 9 built-in phases register through the same mechanism — no special-casing inside consumer code. Per-driver prompts (Aider) move into `PhaseDefinition.driverOverrides`, worktree-isolation moves into `PhaseDefinition.requiresWorktree`, and label-based auto-detection moves into `PhaseDefinition.detect.labels`. `PhaseSchema` switches from `z.enum([...])` to `z.string().refine(...)` so registry membership becomes the source of truth at runtime. The `Phase` type widens from a string-literal union to `string`; the four `.options` call sites (state-schema `WORKFLOW_PHASES`, phase-types tests, assess-skill test) move to a new `getPhaseNames()` helper. The `--phases` CLI flag now validates each name against the registry and exits with `Unknown phase 'X'. Available: ...` on miss. User-defined phases (`.sequant/phases/` filesystem discovery) and the `sequant phases` command are deliberately deferred per the 2026-04-09 descoping comment on #505.
9 tasks
QA flagged that `docs/features/phase-type-definitions.md` still described the pre-registry workflow (z.enum, PHASE_PROMPTS, AIDER_PHASE_PROMPTS, PhaseSchema.options). Rewrite to reflect the registry pattern: phases are registered via phaseRegistry.register(...) in phase-registry.ts, PhaseSchema is a Zod string refinement, and getPhaseNames() replaces the removed PhaseSchema.options.
Two non-blocking QA observations from the prior review: 1. `retryStrategy` was registered as metadata in `phase-registry.ts` but `phase-executor.ts` still used hardcoded `SPEC_RETRY_BACKOFF_MS` / `SPEC_EXTRA_RETRIES` literals and a `phase === "loop"` string equality check. Wire the constants to the registry's `spec.retryStrategy` fields (with legacy literals as misconfiguration fallbacks) and replace the loop literal with `retryStrategy.maxRetries === 0` — any future phase registered with that setting inherits the skip-cold-start-retries behavior without a code change here. 2. `bin/cli.ts:validatePhasesFlag` used `console.error + process.exit(1)`. Throwing Commander's `InvalidArgumentError` from an option validator is idiomatic and produces a clearer message (Commander prefixes with the offending flag name). The existing integration test still passes — its assertions match against the preserved message substrings.
PR #504 (typed workflow event system, commit b4e8814) merged to main during this session and touches several of the same files. Both PRs' type/import additions in types.ts are independent (registry import vs. event-emitter re-exports) — kept both. CHANGELOG entries are also independent (#504 Added, #505 Changed) — kept both, ordered Added before Changed per Keep-a-Changelog convention. Updated the #505 CHANGELOG bullet to reflect the new retryStrategy consumption from the registry. phase-executor.ts, phase-mapper.ts, bin/cli.ts auto-merged. Full workflow test suite (37 files / 878 tests) passes after merge.
admarble
deleted the
feature/505-arch-phase-plugin-registry-user-extensible-workflo
branch
May 14, 2026 07:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the descoped phase plugin registry from #505. Replaces the scattered
PHASE_PROMPTS/AIDER_PHASE_PROMPTS/ISOLATED_PHASES/UI_LABELS/SECURITY_LABELSconstants with a uniformPhaseDefinitionrecord per phase, registered against a singlephaseRegistrysingleton at module load. All 9 built-in phases register through the same mechanism — no special-casing in consumer code.User-defined phases (
.sequant/phases/filesystem discovery) and thesequant phasescommand are deliberately deferred per the 2026-04-09 descoping comment.AC Verification
PhaseDefinitioninterface (name, skill, promptTemplate, requiresWorktree, retryStrategy, detect, driverOverrides, order)src/lib/workflow/phase-registry.ts:53-91PhaseRegistryclass withregister/get/list/hassrc/lib/workflow/phase-registry.ts:93-148+ testsphase-registry.test.tsphase-registry.ts:168-323; tested inphase-registry.test.ts:92-176phase-executor.tsreads from registryPHASE_PROMPTS/AIDER_PHASE_PROMPTS/ISOLATED_PHASES. Prompt lookup atphase-executor.ts:454-462; worktree check atphase-executor.ts:35-44phase-mapper.tsconsumes registry detect rulesUI_LABELS/SECURITY_LABELS; newdetectPhasesFromRegistry()atphase-mapper.ts:46-55--phasesCLI validates against registry at runtimebin/cli.ts:76-100+ integration testphase-registry.integration.test.tsdriverOverridesfielddriverOverrides.aider.promptTemplate; tested atphase-registry.test.ts:141-150Test plan
npm run build— passes (TypeScript clean)npm run lint— passes (no ESLint errors)npm test— 118 files, 3052 tests passphase-registry.integration.test.tscovers--phases bogus(rejected),--phases exec,bogus,qa(rejected),--phases spec,exec,qa(accepted)phase-executor.test.ts's "uses AIDER_PHASE_PROMPTS for non-claude agents" and "uses PHASE_PROMPTS for claude-code agent" both still pass, sourced from the registryphase-mapper.test.tsUI / security / docs / bug label detection tests all passNotes
Phasetype widens from string-literal union tostring. The singleswitch (phase)site inphase-executor.ts(only special-casesqaandexec) keeps working as runtime string comparison.phase-registry.tsrather than a separatebuilt-in-phases.tsto avoid an ESM import cycle (same pattern asdrivers/index.ts).BUG_LABELS/DOCS_LABELS/COMPLEX_LABELSstay inphase-mapper.ts— they are issue-type / quality-loop metadata, not phase-trigger rules. Code comments document the distinction.Closes #505