// allow-test-rule: source-text-is-the-product (see #1526) // execute-phase.md and transition.md are shipped workflows whose deployed text IS what the // runtime loads — asserting their cross-workflow delegation tests the deployed contract. /** * #1526 — auto-chain completion must delegate post-processing to the transition workflow. * * Previously execute-phase's completion called `phase.complete` then a LIGHT inline set * (a partial PROJECT.md update + offer-next) and never invoked the transition workflow, * silently skipping graduation scan, session-continuity, project-reference, accumulated- * context, and the current-position/progress update. The normal transition path ran all of * those, so the two paths left different project state behind. * * Chosen fix (user decision, 2026-08-13): delegate — execute-phase invokes transition.md in * a post-completion mode that skips `verify_completion` + `update_roadmap_and_state` * (phase.complete already ran; avoids double-write) and begins at `evolve_project`. */ 'use strict'; const { describe, test } = require('node:test'); const assert = require('node:assert/strict'); const fs = require('node:fs'); const path = require('node:path'); const EXEC = path.join(__dirname, '..', 'gsd-core', 'workflows', 'execute-phase.md'); const TRANS = path.join(__dirname, '..', 'gsd-core', 'workflows', 'transition.md'); describe('#1526: auto-chain completion delegates post-processing to transition', () => { const exec = fs.readFileSync(EXEC, 'utf8'); const trans = fs.readFileSync(TRANS, 'utf8'); test('execute-phase delegates to transition.md after phase.complete (post-completion)', () => { // The delegation step must include the transition workflow and name post-completion mode. const delegateIdx = exec.indexOf('delegate_post_completion_to_transition'); const includeIdx = exec.indexOf('@~/.claude/gsd-core/workflows/transition.md'); assert.notEqual(delegateIdx, -1, 'execute-phase must have a delegation step'); assert.notEqual(includeIdx, -1, 'execute-phase must @-include transition.md'); assert.ok(includeIdx > delegateIdx, 'the transition include must be inside the delegation step'); }); test('the delegation skips re-running phase.complete (no double-write) and re-verification', () => { // Slice the delegation step and assert it names the skip set. const start = exec.indexOf(' { const modeIdx = trans.indexOf('', modeIdx); const mode = trans.slice(modeIdx, modeEnd); assert.match(mode, /SKIP\s+`verify_completion`\s+and\s+`update_roadmap_and_state`/i, 'mode must name the exact skip set'); assert.match(mode, /evolve_project/, 'mode must begin at evolve_project'); }); test('transition.md still documents standalone mode (full verify → complete → post-process)', () => { // Negative space: the normal transition path must remain a full run. const modeIdx = trans.indexOf('', modeIdx); const mode = trans.slice(modeIdx, modeEnd); assert.match(mode, /Standalone transition/i, 'standalone (mode 1) must still be documented'); }); });