Files
msd-core/gsd-core/bin/lib/write-set.cjs
Tom Boucher 8b70db343b fix(#2204): phase-completion writes 'All phases complete' per ADR-2207 (#2259)
* fix(#2204): phase-completion writes 'All phases complete' per ADR-2207

completePhaseCore was writing the overloaded bare 'Milestone complete' on the
last phase — the same string space the milestone-close verb owns for terminal
state. Per ADR-2207, phase-completion now writes the existing intermediate
value 'All phases complete' (already used in gsd2-import.cts). Milestone
termination ('<version> milestone complete' / 'Awaiting next milestone')
remains solely with milestoneCompleteCore.

Status lifecycle: Ready to plan → All phases complete → <version> milestone
complete → Awaiting next milestone.

Changes:
- src/state-transition.cts: completePhaseCore status value
- src/phase.cts: #2028 guard comment
- tests/state-transition.test.cjs: assertion + test name
- tests/phase.test.cjs: 8 assertion updates (positive + negative)
- tests/state.test.cjs: normalizeStateStatus test case + reset regex
- tests/workstream.test.cjs: fixture status to terminal value
- gsd-core/workflows/progress.md: Route D label
- gsd-core/workflows/transition.md: Route B label
- CONTEXT.md: Status lifecycle glossary entry (ADR-2207)
- .changeset/brave-geese-jump.md

* test(#2204): regenerate golden-install-parity fixtures + workflow-size baseline

Workflow file edits (progress.md, transition.md) changed install payload
hashes and pushed past the committed workflow-size baseline. Regenerated
all 17 golden-install-parity fixtures + claude-local via the standalone gen
script (which now also covers the local-scope claude layout). Updated
workflow-size-baseline.json and agent-size-baseline.json via size:baseline.

* fix(#2204): correct claude-local golden hashes + document gen-script limitation

The gen-script's claude-local generation produces macOS-specific hashes
incompatible with Linux CI (local-scope install embeds platform-varying
node-runner paths). Reverted to manual update using Linux FAILURES.md
+actual hashes for the 2 changed workflow files. Added explanatory
comment in the gen script.

* test(#2204): add isCompletedInventory coverage + clarify CONTEXT.md glossary

Addresses orthogonal code-review findings (Medium #1 + #2):
- Add isCompletedInventory test cases for ADR-2207 status lifecycle
  (terminal 'milestone complete' → true; intermediate 'All phases
  complete' → false; archived → true; active statuses → false)
- Clarify CONTEXT.md glossary: note that isCompletedInventory
  intentionally excludes the intermediate value

* docs: backfill changeset PR number (#2259)

* docs(#2204): add Status lifecycle table to state-md reference (ADR-2207)
2026-07-14 14:47:03 -04:00

39 lines
1.9 KiB
JavaScript

"use strict";
/**
* Write-Set — shared fail-loud parse `Result` and per-surface write-set
* contracts (ADR-2143, epic #2143). Pure, Node built-ins only, no I/O.
* Compiled by tsc to gsd-core/bin/lib/write-set.cjs.
*
* ADR-2143 §5 (fail-loud parsing, no null-swallow): seam parse operations
* and document-model accessors return a typed `Result<T>` — never a bare
* `null` a caller can mistake for "empty but fine." This is the same
* `{ ok: true; value: T } | { ok: false; reason: string }` shape
* `markdown-table.cts` already defined for `parseMarkdownTable` /
* `appendQuickTaskRow`; this module is now the single source of truth for
* it and `markdown-table.cjs` re-exports the type so existing importers of
* `Result` from that module keep working unchanged.
*
* NOTE: deliberately distinct from command-routing-hub's dispatch `Result`
* (`{ok,data}|{ok:false,kind}`) — the two never mix (different modules,
* different shapes, different purposes).
*
* ADR-2143 §6 (write-set results for multi-surface commands, no
* OR-into-one-flag): a command that mutates more than one surface returns
* an explicit per-surface write-set — `{ surface, applied }` outcomes — and
* its top-level "did this fully succeed" signal is true only if EVERY
* surface in the set applied. ORing independent surfaces into a single
* boolean is the direct anti-pattern that let a checkbox-only partial
* write (#2140) report full success.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeSetComplete = writeSetComplete;
/**
* True only if the write-set is non-empty AND every surface in it applied.
* An empty write-set is never "complete" — there is nothing to be complete
* about, so treating it as vacuously true would let a no-op masquerade as
* a full success (the same OR-into-one-flag class ADR-2143 §6 prohibits).
*/
function writeSetComplete(ws) {
return ws.length > 0 && ws.every((o) => o.applied);
}