Add _diskScanCache.delete(cwd) at the start of writeStateMd before buildStateFrontmatter is called. This prevents stale reads if multiple state-mutating operations occur within the same Node process — the write may create new PLAN/SUMMARY files that the next frontmatter computation must see. Matters for: - SDK callers that require() gsd-tools.cjs as a module - Future dispatcher extensions handling compound operations - Tests that import state.cjs directly Adds tests/bug-1967-cache-invalidation.test.cjs which exercises two sequential writes in the same process with a new phase directory created between them, asserting the second write sees the new disk state (total_phases: 2, completed_phases: 1) instead of the cached pre-write snapshot (total_phases: 1, completed_phases: 0). Review feedback on #2054 from @trek-e.
3.7 KiB
3.7 KiB