Cover the composable helpers extracted from deriveStateFromDb:
reconcileDiskToDb, buildCompletenessSet, buildRegistryAndFindActive,
handleNoActiveMilestone, resolveSliceDependencies, reconcileSliceTasks,
detectBlockers, checkReplanTrigger, checkInterruptedWork, and queue
order sorting.
Extracts the monolithic deriveStateFromDb function into distinct,
composable helper functions (reconcileDiskToDb, resolveSliceDependencies,
detectBlockers, etc.) inside state.ts.
Resolves technical debt identified during the code quality audit by
drastically reducing cyclomatic complexity while preserving the exact
type signature and logical behavior.
Also removes duplicate disk->DB reconciliation that could overwrite
milestone statuses.
Implements file-level advisory locking via proper-lockfile to ensure
atomic read-modify-write sequences in:
- compactMilestoneEvents (event-log.jsonl)
- custom-workflow-engine reconcile (GRAPH.yaml)
Fixes silent data loss when concurrent auto-mode or dashboard
sessions overlap in these operations.
This fixes an issue where MCP workflow tools (e.g. gsd_plan_slice) would return error details in their JSON response, but without setting the 'isError: true' flag at the top level of the tool response payload. This caused MCP clients (like Claude Code) to interpret failed validations (like empty tasks arrays) as successes and get stuck in infinite validation failure loops.
The depth verification gate and multi-milestone readiness gate
unconditionally referenced ask_user_questions. On transports where
structuredQuestionsAvailable is false, this would trap the flow in
re-ask loops.
Add {{structuredQuestionsAvailable}} conditionals to:
- Depth verification (true: ask_user_questions, false: plain text)
- Multi-milestone Phase 3 readiness gate
- Per-milestone technical assumption verification
The discuss.md prompt (used for /gsd new project creation) only asked
"What's the vision?" once and relied on LLM judgment for follow-ups.
This led to the agent asking a single question then jumping straight
to planning without gathering enough context.
Add explicit Question Rounds section with:
- 1-3 questions per round structure
- Conditional ask_user_questions vs plain text support
- Incremental persistence (CONTEXT-DRAFT save every 2 rounds)
- Depth-matching rule (1-2 rounds for simple, 4+ for large visions)
- Round cadence that drives toward the depth enforcement checklist
Thread structuredQuestionsAvailable through buildDiscussPrompt() and
prepareAndBuildDiscussPrompt() so the template variable resolves
correctly at runtime.
Closes#3976
resolvePreferredModelConfig now skips routing-ceiling synthesis when
isAutoMode=false, preventing interactive dispatches from silently switching
to the tier_models.heavy model. The auto-start banner now reflects
effective routing state by checking flat-rate provider suppression and
using the actual ceiling from tier_models.heavy when configured.
Dynamic routing silently downgraded models in interactive commands (guided-flow),
overriding the user's /model selection. Now routing only applies in auto-mode where
cost optimization is expected. Model downgrade notifications always fire regardless
of verbose setting, and auto-mode shows routing status upfront on start.
Convert resource-loader import path to file URL via pathToFileURL() to
fix Windows ERR_UNSUPPORTED_ESM_URL_SCHEME. Update existing regression
test to validate the GSD_PKG_ROOT + pathToFileURL contract.
Auto-mode resume crashed with "Cannot find module" because the relative
import ../../../resource-loader.js only works from the source tree, not
from the deployed path at ~/.gsd/agent/extensions/gsd/auto.js.
Expose GSD_PKG_ROOT from loader.ts and use it in auto.ts to construct
an absolute path to dist/resource-loader.js that works in both contexts.