Skip to content

Commit d9d5d2b

Browse files
committed
fix: design-artifact probe uses real fs; update implement-start fixtures
probeDesignArtifacts defaulted to empty fs when omitted, breaking lifecycle/tests that only pass taskRoot. Align with probeProcessTriad and require 00/01/02 in intent implement-start fixtures.
1 parent 32fa1cb commit d9d5d2b

3 files changed

Lines changed: 32 additions & 14 deletions

File tree

‎scripts/lib/process-enforcement.js‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -278,19 +278,6 @@ function probeProcessTriad (taskRoot, fsys = null) {
278278
return { hasPlan, hasProgress, hasChecklist, missing }
279279
}
280280

281-
/**
282-
* Implement-start / control-plane mutation gate (pre-coding, not only completion).
283-
* When mutating protected control-plane paths for an active task, 04+05+checklist must exist.
284-
*
285-
* @param {{
286-
* controlPlaneMutation?: boolean,
287-
* implementStart?: boolean,
288-
* taskRoot?: string|null,
289-
* fs?: { existsSync?: Function, readdirSync?: Function },
290-
* skip?: boolean
291-
* }} input
292-
* @returns {{ ok: boolean, code: string|null, missing: string[], triad: object|null }}
293-
*/
294281
function listDirNames (root, fsImpl) {
295282
try {
296283
if (!fsImpl || typeof fsImpl.readdirSync !== 'function') return []
@@ -301,7 +288,8 @@ function listDirNames (root, fsImpl) {
301288
}
302289

303290
function probeDesignArtifacts (taskRoot, fsImpl) {
304-
const fsx = fsImpl || { existsSync: () => false, readdirSync: () => [] }
291+
// Match probeProcessTriad: default to real fs when caller omits fs (tests + lifecycle)
292+
const fsx = fsImpl || require('fs')
305293
const names = listDirNames(taskRoot, fsx)
306294
const has01 = names.some(n =>
307295
/^01-.*需求确认/i.test(n) ||
@@ -328,6 +316,20 @@ function probeDesignArtifacts (taskRoot, fsImpl) {
328316
return { has00, has01, has02 }
329317
}
330318

319+
/**
320+
* Implement-start / control-plane mutation gate (pre-coding, not only completion).
321+
* Requires bound task + 04/05/checklist triad + design artifacts (00/01 + 02) for control-plane.
322+
*
323+
* @param {{
324+
* controlPlaneMutation?: boolean,
325+
* implementStart?: boolean,
326+
* taskRoot?: string|null,
327+
* fs?: { existsSync?: Function, readdirSync?: Function },
328+
* skip?: boolean,
329+
* requireDesignArtifacts?: boolean
330+
* }} input
331+
* @returns {{ ok: boolean, code: string|null, missing: string[], triad: object|null, unbound?: boolean, design?: object }}
332+
*/
331333
function classifyImplementStartGate (input = {}) {
332334
if (input.skip === true) {
333335
return { ok: true, code: null, missing: [], triad: null }

‎scripts/test-workspace-skill-intent-e2e.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ function makeFixture () {
9191
writeSkill(gRoot, 'workspace-skill-author', fs.readFileSync(AUTHOR_SRC, 'utf8'))
9292

9393
// triad for implement gate positive
94+
fs.writeFileSync(path.join(taskRoot, '00-需求概况.md'), '# overview\n')
95+
fs.writeFileSync(path.join(taskRoot, '01-需求确认.md'), '# cp1\n')
96+
fs.writeFileSync(path.join(taskRoot, '02-技术方案.md'), '# design\n')
9497
fs.writeFileSync(path.join(taskRoot, '04-实施计划.md'), '# plan\n')
9598
fs.writeFileSync(path.join(taskRoot, '05-实施进度.md'), '# progress\n')
9699
fs.writeFileSync(path.join(taskRoot, '03-复审清单-e2e.md'), '# checklist\n')
@@ -375,6 +378,9 @@ function runLifecycle (fx, payload) {
375378
const bad = classifyImplementStartGate({ controlPlaneMutation: true, taskRoot: empty })
376379
assert.strictEqual(bad.ok, false)
377380
assert.strictEqual(bad.code, ERROR_CODES.IMPLEMENT_START_WITHOUT_PROCESS)
381+
const unbound = classifyImplementStartGate({ controlPlaneMutation: true, taskRoot: null })
382+
assert.strictEqual(unbound.ok, false)
383+
assert.strictEqual(unbound.code, ERROR_CODES.IMPLEMENT_START_WITHOUT_TASK_BINDING)
378384
const good = classifyImplementStartGate({ controlPlaneMutation: true, taskRoot: fx.taskRoot })
379385
assert.strictEqual(good.ok, true)
380386
console.log('E2E-K PASS (implement-start gate)')

‎scripts/test-workspace-skill-intent.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,18 @@ function testImplementStartGate() {
264264
fs.writeFileSync(path.join(root, '04-实施计划.md'), '#')
265265
fs.writeFileSync(path.join(root, '05-实施进度.md'), '#')
266266
fs.writeFileSync(path.join(root, '03-复审清单-t.md'), '#')
267+
// triad alone is not enough for control-plane: need 00/01 + 02 design artifacts
268+
const triadOnly = classifyImplementStartGate({ controlPlaneMutation: true, taskRoot: root })
269+
assert.strictEqual(triadOnly.ok, false)
270+
assert.strictEqual(triadOnly.code, ERROR_CODES.IMPLEMENT_START_WITHOUT_DESIGN)
271+
fs.writeFileSync(path.join(root, '00-需求概况.md'), '#')
272+
fs.writeFileSync(path.join(root, '01-需求确认.md'), '#')
273+
fs.writeFileSync(path.join(root, '02-技术方案.md'), '#')
267274
const ok = classifyImplementStartGate({ controlPlaneMutation: true, taskRoot: root })
268275
assert.strictEqual(ok.ok, true)
276+
const unbound = classifyImplementStartGate({ controlPlaneMutation: true, taskRoot: null })
277+
assert.strictEqual(unbound.ok, false)
278+
assert.strictEqual(unbound.code, ERROR_CODES.IMPLEMENT_START_WITHOUT_TASK_BINDING)
269279
const skip = classifyImplementStartGate({ controlPlaneMutation: false, taskRoot: root })
270280
assert.strictEqual(skip.ok, true)
271281
} finally {

0 commit comments

Comments
 (0)