Merge pull request #3557 from Tibsfox/fix/rethink-skip-slice-db-sync

fix(gsd): rebuild STATE.md after skip-slice and strengthen rethink prompt
This commit is contained in:
Jeremy McSpadden 2026-04-07 07:15:53 -05:00 committed by GitHub
commit 4dc9fa274c
3 changed files with 43 additions and 1 deletions

View file

@ -1000,6 +1000,16 @@ export function registerDbTools(pi: ExtensionAPI): void {
updateSliceStatus(params.milestoneId, params.sliceId, "skipped");
invalidateStateCache();
// Rebuild STATE.md so it reflects the skip immediately (#3477).
// Without this, /gsd auto reads stale STATE.md and resumes the skipped slice.
try {
const basePath = process.cwd();
const { rebuildState } = await import("../doctor.js");
await rebuildState(basePath);
} catch (err) {
logError("tool", `skip_slice rebuildState failed: ${(err as Error).message}`, { tool: "gsd_skip_slice" });
}
return {
content: [{ type: "text" as const, text: `Skipped slice ${params.sliceId} (${params.milestoneId}). Reason: ${params.reason ?? "User-directed skip"}. Auto-mode will advance past this slice.` }],
details: {

View file

@ -46,11 +46,12 @@ reason: "<reason>"
Remove the `{ID}-PARKED.md` file from the milestone directory to reactivate it.
### Skip a slice
Mark a slice as skipped so auto-mode advances past it without executing. Use the `gsd_skip_slice` tool:
Mark a slice as skipped so auto-mode advances past it without executing. **You MUST call the `gsd_skip_slice` tool** — editing the roadmap markdown alone is NOT sufficient because auto-mode reads slice status from the database, not the roadmap file:
```
gsd_skip_slice({ milestoneId: "M003", sliceId: "S02", reason: "Descoped — feature moved to M005" })
```
Skipped slices are treated as closed by the state machine (like "complete" but distinct). Use when a slice is no longer needed or has been superseded. The slice data is preserved for reference.
**Do NOT** just check the slice checkbox in the roadmap — this does not update the DB and auto-mode will resume the slice.
### Discard a milestone
**Permanently** delete a milestone directory and prune it from QUEUE-ORDER.json. **Always confirm with the user before discarding.** Warn explicitly if the milestone has completed work.

View file

@ -0,0 +1,31 @@
/**
* Regression test for #3477: gsd_skip_slice tool must rebuild STATE.md
* after updating the DB so auto-mode reads the correct state.
*/
import { test } from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { join } from "node:path";
test("gsd_skip_slice tool calls rebuildState after DB update (#3477)", () => {
const src = readFileSync(
join(import.meta.dirname, "..", "bootstrap", "db-tools.ts"),
"utf-8",
);
// The fix adds a rebuildState call after updateSliceStatus in skip_slice
assert.ok(
src.includes("rebuildState"),
"gsd_skip_slice must call rebuildState after updating slice status",
);
});
test("rethink prompt warns against markdown-only edits for skip (#3477)", () => {
const prompt = readFileSync(
join(import.meta.dirname, "..", "prompts", "rethink.md"),
"utf-8",
);
assert.ok(
prompt.includes("MUST") && prompt.includes("gsd_skip_slice"),
"Rethink prompt must emphasize gsd_skip_slice tool requirement",
);
});