flow-comet 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.flow-comet/skills/flow-comet/GUIDANCE.md +22 -3
- package/.flow-comet/skills/flow-comet/INSTALLED_VERSION +1 -1
- package/.flow-comet/skills/flow-comet/SKILL.md +20 -1
- package/.flow-comet/skills/flow-comet/reference/KNOWN-ISSUES-template.md +3 -3
- package/.flow-comet/skills/flow-comet/reference/TEST-MATRIX.md +15 -15
- package/.flow-comet/skills/flow-comet/reference/dsh-platform.md +19 -11
- package/.flow-comet/skills/flow-comet/reference/recovery.md +1 -7
- package/.flow-comet/skills/flow-comet/reference/worktree-notes.md +21 -3
- package/.flow-comet/skills/flow-comet/scripts/contract-check.mjs +41 -31
- package/.flow-comet/skills/flow-comet/scripts/guard-self-test.mjs +2513 -295
- package/.flow-comet/skills/flow-comet/scripts/protocol-utils.mjs +1 -1
- package/.flow-comet/skills/flow-comet/scripts/route-node.mjs +459 -11
- package/.flow-comet/skills/flow-comet/scripts/state-schema.mjs +3 -3
- package/.flow-comet/skills/flow-comet/scripts/system-test.mjs +422 -10
- package/.flow-comet/skills/flow-comet/scripts/workflow-guard.mjs +140 -226
- package/.flow-comet/skills/flow-comet/scripts/workflow-handoff.mjs +1 -1
- package/.flow-comet/skills/flow-comet/scripts/workflow-state.mjs +362 -4
- package/.flow-comet/skills/flow-comet-archive/SKILL.md +2 -0
- package/.flow-comet/skills/flow-comet-change/SKILL.md +2 -0
- package/.flow-comet/skills/flow-comet-design/SKILL.md +2 -0
- package/.flow-comet/skills/flow-comet-dev/SKILL.md +3 -1
- package/.flow-comet/skills/flow-comet-execute/SKILL.md +6 -4
- package/.flow-comet/skills/flow-comet-integration/SKILL.md +2 -0
- package/.flow-comet/skills/flow-comet-open/SKILL.md +2 -0
- package/.flow-comet/skills/flow-comet-plan/SKILL.md +17 -6
- package/.flow-comet/skills/flow-comet-requirement/SKILL.md +2 -0
- package/.flow-comet/skills/flow-comet-review/SKILL.md +7 -5
- package/.flow-comet/skills/flow-comet-subagent-execute/SKILL.md +12 -9
- package/.flow-comet/skills/flow-comet-task/SKILL.md +7 -3
- package/.flow-comet/skills/flow-comet-test/SKILL.md +2 -0
- package/.flow-comet/skills/flow-comet-verify/SKILL.md +7 -5
- package/README.md +45 -119
- package/package.json +1 -1
- package/scripts/dsh-bridge.mjs +2 -2
|
@@ -13,13 +13,16 @@
|
|
|
13
13
|
// F. 自动初始化(缺失提示/跳过记忆/新鲜静默/生成协作全链路)
|
|
14
14
|
// G. 分支模式(init 建分支/归档入口分支校验/一致性失配警告)
|
|
15
15
|
// H. verify 与归档(验证命令真实执行 + 超时配置/完整归档流程/归档路径声明标记查找/
|
|
16
|
-
//
|
|
16
|
+
// 受控重入真实命令链路:授权门禁·转移·审计·备份指纹·幂等·轮次上限·手工回滚/
|
|
17
|
+
// 受控计划重校重签真实命令链路:修订任务集死锁→重签→出口放行·授权 fail-closed·
|
|
18
|
+
// 轮次上限与显式续轮/强制推进留痕:advance-forced 事件 + status.forcedNodes 派生可见)
|
|
17
19
|
// I. 异常路径(损坏状态/缺工件出口/非法参数/状态字段类型非法)
|
|
18
20
|
// J. 文档一致性(双语健康检查/公开产物零代号检查——调用仓库本地工具)
|
|
19
21
|
// K. 安装器与平台(版本标识/多平台安装与平台化路径/codex hook JSON 契约/平台选择链/
|
|
20
22
|
// purge 语义/描述符驱动/dsh 平台断言/loader 版本戳重装断言/hook 注入形态无关断言与旧条目幂等升级/
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
+
// 旧布局状态迁移后状态可读与流程可继续/契约核对 CLI 参数化目录解析与缺省回退回归锚/
|
|
24
|
+
// 分发面包体边界·可发布性清单与 bin 双入口(权威源真跑·副本回传显式「不适用」结果标记)
|
|
25
|
+
// 与 init 词元红线)
|
|
23
26
|
// L. 执行遗漏防护(entry 进入证据/空退出豁免/空仓库提示)
|
|
24
27
|
//
|
|
25
28
|
// 载体(与 guard-self-test 同构):每项 = 独立临时目录(fs.mkdtemp)+ 内置协议副本复制到
|
|
@@ -47,6 +50,7 @@ const GUARD = path.join(__dirname, 'workflow-guard.mjs');
|
|
|
47
50
|
const STATE = path.join(__dirname, 'workflow-state.mjs');
|
|
48
51
|
const HOOK = path.join(__dirname, 'comet-hook-guard.mjs');
|
|
49
52
|
const HANDOFF = path.join(__dirname, 'workflow-handoff.mjs');
|
|
53
|
+
const CONTRACT = path.join(__dirname, 'contract-check.mjs');
|
|
50
54
|
// 内置协议源文件(脚本所在技能包 reference/):复制到 <tmp>/reference/ 内(受保护路径要求 runRoot 内)
|
|
51
55
|
const BUILTIN_PROTOCOL_SOURCE = path.join(__dirname, '..', 'reference', 'workflow-protocol.json');
|
|
52
56
|
const CHANGE_ID = 'ch';
|
|
@@ -1044,6 +1048,77 @@ function resolveReentryBackupPath(root, changeId, event) {
|
|
|
1044
1048
|
return candidates.find((p) => fs.existsSync(p)) || null;
|
|
1045
1049
|
}
|
|
1046
1050
|
|
|
1051
|
+
// ---------- 受控计划重校重签(replan)与强制推进留痕真实命令链路夹具(H9~H11 共用) ----------
|
|
1052
|
+
|
|
1053
|
+
// 任务集构造:基础串行任务(status 可切)+ 可追加的并行就绪任务(计划外修订用)
|
|
1054
|
+
// + 可选的同文件跨任务对(第三族:两条串行任务写同一路径——并行形态会先被写写强判族命中,
|
|
1055
|
+
// 串行拆分才是「同文件跨任务且无依赖路径」的判据面;crossTaskPair='deps' 时补显式 depends_on)。
|
|
1056
|
+
function replanTaskText(options = {}) {
|
|
1057
|
+
const lines = ['# TASK', '',
|
|
1058
|
+
'<task id="S01" parallel="false" status="' + (options.s01Status || 'pending') + '">'
|
|
1059
|
+
+ '<action>实现 S01</action><write_files>src/s01.mjs</write_files>'
|
|
1060
|
+
+ '<verify>node --check src/s01.mjs</verify></task>'];
|
|
1061
|
+
for (const id of options.parallelPending || []) {
|
|
1062
|
+
lines.push('<task id="' + id + '" parallel="true" status="pending">'
|
|
1063
|
+
+ '<action>实现计划外新增的 ' + id + '</action>'
|
|
1064
|
+
+ '<write_files>src/' + id.toLowerCase() + '.mjs</write_files>'
|
|
1065
|
+
+ '<verify>node --check src/' + id.toLowerCase() + '.mjs</verify></task>');
|
|
1066
|
+
}
|
|
1067
|
+
if (options.crossTaskPair) {
|
|
1068
|
+
const deps = options.crossTaskPair === 'deps' ? '<depends_on>X1</depends_on>' : '';
|
|
1069
|
+
lines.push('<task id="X1" parallel="false" status="pending">'
|
|
1070
|
+
+ '<action>实现 X1</action><write_files>src/shared-cross.mjs</write_files>'
|
|
1071
|
+
+ '<verify>node --check src/shared-cross.mjs</verify></task>');
|
|
1072
|
+
lines.push('<task id="X2" parallel="false" status="pending">'
|
|
1073
|
+
+ '<action>实现 X2</action><write_files>src/shared-cross.mjs</write_files>'
|
|
1074
|
+
+ '<verify>node --check src/shared-cross.mjs</verify>' + deps + '</task>');
|
|
1075
|
+
}
|
|
1076
|
+
return lines.join('\n') + '\n';
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
// execute 已 entry 的真实链路前奏:#init → open/design 出口 → plan 出口 → 任务集 → record +
|
|
1080
|
+
// entry execute(entry 真实记录任务集签名)。返回后调用方可修订任务集触发签名不匹配现场。
|
|
1081
|
+
function seedExecuteEntryState(dir, taskText) {
|
|
1082
|
+
driveThroughDesign(dir);
|
|
1083
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', taskText);
|
|
1084
|
+
assertExit(runState(['skill-load', 'plan', 'flow-comet-plan', '--prompt', 'flow-kit/prompts/3-task.md'], dir), 0);
|
|
1085
|
+
assertExit(runState(['record', 'plan', '{"summary":"plan done"}'], dir), 0);
|
|
1086
|
+
assertExit(runGuard(['entry', 'plan'], dir), 0);
|
|
1087
|
+
const planExit = runGuard(['exit', 'plan', '--apply'], dir);
|
|
1088
|
+
assertExit(planExit, 0);
|
|
1089
|
+
assertNodeLine(planExit, 'execute');
|
|
1090
|
+
assertExit(runState(['skill-load', 'execute', 'flow-comet-dev', '--prompt', 'flow-kit/prompts/4-dev.md'], dir), 0);
|
|
1091
|
+
assertExit(runState(['record', 'execute', '{"summary":"implementation recorded"}'], dir), 0);
|
|
1092
|
+
assertExit(runGuard(['entry', 'execute'], dir), 0);
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
// 串行 pending 任务的真实委托留证(execute 归属:request + result 契约回传)
|
|
1096
|
+
function completeSerialTaskWithHandoff(dir, taskId, writeFilesRel) {
|
|
1097
|
+
assertExit(runHandoff(['request', taskId, taskId + ' 委托', '--write-files', writeFilesRel], dir), 0);
|
|
1098
|
+
assertExit(runHandoff(['result', taskId, fullContract('abcd1234abcd1234abcd1234abcd1234abcd1234', taskId)], dir), 0);
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
// replan 备份清单(.specs/<id>/replan-backups/)
|
|
1102
|
+
function replanBackupFiles(dir, changeId = CHANGE_ID) {
|
|
1103
|
+
const backupDir = path.join(dir, '.specs', changeId, 'replan-backups');
|
|
1104
|
+
return fs.existsSync(backupDir) ? fs.readdirSync(backupDir).sort() : [];
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
// replan-applied 事件过滤(轮次按 change 从 history 派生)
|
|
1108
|
+
function replanEventsOf(state) {
|
|
1109
|
+
return (state.history || []).filter((e) => e && e.event === 'replan-applied');
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
// status 输出的 JSON 块解析(命令行尾巴行不进 JSON)
|
|
1113
|
+
function parseStatusOutput(root) {
|
|
1114
|
+
const res = runState(['status'], root);
|
|
1115
|
+
assertExit(res, 0);
|
|
1116
|
+
const start = res.output.indexOf('{');
|
|
1117
|
+
const end = res.output.lastIndexOf('}');
|
|
1118
|
+
if (start < 0 || end <= start) throw new Error('status 输出缺少 JSON 块:\n' + res.output);
|
|
1119
|
+
return JSON.parse(res.output.slice(start, end + 1));
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1047
1122
|
// ---------- 系统测试项(A~L 十二类) ----------
|
|
1048
1123
|
|
|
1049
1124
|
const TEST_ITEMS = [
|
|
@@ -1629,8 +1704,12 @@ const TEST_ITEMS = [
|
|
|
1629
1704
|
// 并行文件依赖检出(真实命令链路):write∩write 重叠强判前移 plan 出口——同波次并行任务
|
|
1630
1705
|
// 写同一路径(链式重命名的 .txt 事故面)→ 新 change BLOCKED(含重叠路径与 depends_on
|
|
1631
1706
|
// 恢复指引);按指引补显式 depends_on 后同出口恢复通过。read∩write 弱判:无显式关联并行对
|
|
1632
|
-
// 一方读取对方写路径 → WARN 提示不 BLOCK
|
|
1633
|
-
|
|
1707
|
+
// 一方读取对方写路径 → WARN 提示不 BLOCK(渐进)。同一文件跨任务族:两个未完成任务写入面
|
|
1708
|
+
// 重叠且彼此无依赖路径(串行拆分同样拦截)→ 新 change BLOCKED(消息含任务对与重叠文件);
|
|
1709
|
+
// 补显式 depends_on 后放行;旧 change 形态仅 WARN 不阻断;修复任务族(id 带修复前缀)
|
|
1710
|
+
// 不参与该族——其顺序由修复生命周期保证,回修同一文件是必然形态。修复前 plan 出口无这些
|
|
1711
|
+
// 检测 = 预期 RED。
|
|
1712
|
+
name: 'A16 plan 出口文件依赖检出:写写重叠 BLOCK 与恢复 + 读写弱判 WARN + 同文件跨任务无依赖路径(真实命令)',
|
|
1634
1713
|
run: (dir) => {
|
|
1635
1714
|
driveThroughDesign(dir);
|
|
1636
1715
|
const planEnv = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
@@ -1662,17 +1741,78 @@ const TEST_ITEMS = [
|
|
|
1662
1741
|
assertOut(blocked, 'BLOCKED');
|
|
1663
1742
|
assertOut(blocked, 'bak_a.txt');
|
|
1664
1743
|
assertOut(blocked, 'depends_on');
|
|
1744
|
+
// 同一文件跨任务族(负例):两个非修复任务写入同一文件、彼此无依赖路径(串行拆分同样构成
|
|
1745
|
+
// 「未显式排序的同文件多任务」)→ 新 change BLOCKED,消息含任务对与重叠文件 + 恢复指引。
|
|
1746
|
+
// 同夹具并列一对修复任务(id 带修复前缀)写同一文件且无依赖路径——该族不参与判定,
|
|
1747
|
+
// 消息中不得出现它们(其顺序由修复生命周期保证)。
|
|
1748
|
+
const fixPair =
|
|
1749
|
+
'<task id="T-FIX-01" status="pending"><action>修复 F1</action><write_files>src/fix.mjs</write_files><verify>node --check src/fix.mjs</verify></task>\n' +
|
|
1750
|
+
'<task id="T-FIX-02" status="pending"><action>修复 F2</action><write_files>src/fix.mjs</write_files><verify>node --check src/fix.mjs</verify></task>\n';
|
|
1751
|
+
const sameFileTask = (id, depsElement) =>
|
|
1752
|
+
'<task id="' + id + '" status="pending"><action>实现 ' + id + '</action><write_files>src/x.mjs</write_files>' +
|
|
1753
|
+
'<verify>node --check src/x.mjs</verify>' + depsElement + '</task>\n';
|
|
1754
|
+
const sameFilePairNoDeps = sameFileTask('X1', '') + sameFileTask('X2', '');
|
|
1755
|
+
const sameFilePairWithDeps = sameFileTask('X1', '') + sameFileTask('X2', '<depends_on>X1</depends_on>');
|
|
1756
|
+
planTask(C1 + sameFilePairNoDeps + fixPair);
|
|
1757
|
+
const sameFileBlocked = exitPlanNoApply();
|
|
1758
|
+
assertExit(sameFileBlocked, 1);
|
|
1759
|
+
assertOut(sameFileBlocked, 'BLOCKED');
|
|
1760
|
+
assertOut(sameFileBlocked, '同文件跨任务且无依赖路径');
|
|
1761
|
+
assertOut(sameFileBlocked, 'X1×X2');
|
|
1762
|
+
assertOut(sameFileBlocked, 'src/x.mjs');
|
|
1763
|
+
assertOut(sameFileBlocked, 'depends_on');
|
|
1764
|
+
assertNotOut(sameFileBlocked, 'T-FIX-01');
|
|
1765
|
+
assertNotOut(sameFileBlocked, 'src/fix.mjs');
|
|
1766
|
+
// 修复任务族谓词边界(唯一谓词 = id 前缀 + 「位于 Fix 段内」两条边界,只在引擎内表达一次):
|
|
1767
|
+
// ① 形似而非修复编号的 id 不属修复族——「前缀后缺连字符」的形似编号在旧判据的宽松前缀下
|
|
1768
|
+
// 整对被放过;正确判据下它与同文件无依赖路径对一律 BLOCKED。
|
|
1769
|
+
const lookalikeFixPair =
|
|
1770
|
+
'<task id="T-FIXUP-01" status="pending"><action>实现 T-FIXUP-01</action><write_files>src/lookalike.mjs</write_files><verify>node --check src/lookalike.mjs</verify></task>\n' +
|
|
1771
|
+
'<task id="T-FIXUP-02" status="pending"><action>实现 T-FIXUP-02</action><write_files>src/lookalike.mjs</write_files><verify>node --check src/lookalike.mjs</verify></task>\n';
|
|
1772
|
+
planTask(C1 + lookalikeFixPair);
|
|
1773
|
+
const lookalikeBlocked = exitPlanNoApply();
|
|
1774
|
+
assertExit(lookalikeBlocked, 1);
|
|
1775
|
+
assertOut(lookalikeBlocked, 'BLOCKED');
|
|
1776
|
+
assertOut(lookalikeBlocked, '同文件跨任务且无依赖路径');
|
|
1777
|
+
assertOut(lookalikeBlocked, 'T-FIXUP-01×T-FIXUP-02');
|
|
1778
|
+
assertOut(lookalikeBlocked, 'src/lookalike.mjs');
|
|
1779
|
+
// ② Fix 段内、id 不带修复前缀的修复任务同属修复族——旧判据只认 id 前缀,会把段内这对当普通
|
|
1780
|
+
// 参与者误 BLOCK;正确判据下段内任务整体不参与该族 → 出口放行且无该族消息。
|
|
1781
|
+
const fixSectionPair =
|
|
1782
|
+
'<task id="F01" status="pending"><action>修复 F01</action><write_files>src/fix-section.mjs</write_files><verify>node --check src/fix-section.mjs</verify></task>\n' +
|
|
1783
|
+
'<task id="F02" status="pending"><action>修复 F02</action><write_files>src/fix-section.mjs</write_files><verify>node --check src/fix-section.mjs</verify></task>\n';
|
|
1784
|
+
planTask(C1 + '\n## Fix 任务\n\n' + fixSectionPair);
|
|
1785
|
+
const fixSectionRes = exitPlanNoApply();
|
|
1786
|
+
assertExit(fixSectionRes, 0);
|
|
1787
|
+
assertNotOut(fixSectionRes, '同文件跨任务且无依赖路径');
|
|
1788
|
+
assertNotOut(fixSectionRes, 'BLOCKED');
|
|
1789
|
+
// 旧 change 形态(无新 change 标记):同形态仅 WARN 渐进不阻断,恢复指引仍在
|
|
1790
|
+
planTask(C1 + sameFilePairNoDeps + fixPair);
|
|
1791
|
+
const sameFileState = readStateFile(dir);
|
|
1792
|
+
delete sameFileState.newChange;
|
|
1793
|
+
writeState(dir, sameFileState);
|
|
1794
|
+
const sameFileWarn = exitPlanNoApply();
|
|
1795
|
+
assertExit(sameFileWarn, 0);
|
|
1796
|
+
assertOut(sameFileWarn, 'WARN');
|
|
1797
|
+
assertOut(sameFileWarn, '同文件跨任务且无依赖路径');
|
|
1798
|
+
assertOut(sameFileWarn, 'X1×X2');
|
|
1799
|
+
assertNotOut(sameFileWarn, 'BLOCKED');
|
|
1800
|
+
writeState(dir, { ...sameFileState, newChange: true });
|
|
1665
1801
|
// 恢复(CodeRabbit 采纳):按指引补显式 depends_on,且 **P02 保持写原重叠路径 bak_a.txt**
|
|
1666
1802
|
// (不改路径避开重叠)——证明「补 depends_on 解决原重叠」而非「改路径避开重叠」;补依赖后
|
|
1667
1803
|
// P02 跨趟(dep 未满足,不在本趟可运行集合)→ 同波次并行对只剩 P01 → 重叠消失 → 同出口通过。
|
|
1804
|
+
// 同一文件跨任务族同批恢复:X2 补 depends_on X1(重叠路径不改);并列的修复任务对保持无依赖
|
|
1805
|
+
// ——该族不参与判定,故不影响本出口通过。
|
|
1668
1806
|
planTask(
|
|
1669
1807
|
C1 +
|
|
1670
1808
|
'<task id="P01" parallel="true" status="pending"><action>实现 P01</action><write_files>bak_a.txt</write_files><verify>node --check bak_a.txt</verify></task>\n' +
|
|
1671
|
-
'<task id="P02" parallel="true" status="pending"><action>实现 P02</action><write_files>bak_a.txt</write_files><verify>node --check bak_a.txt</verify><depends_on>P01</depends_on></task>\n'
|
|
1809
|
+
'<task id="P02" parallel="true" status="pending"><action>实现 P02</action><write_files>bak_a.txt</write_files><verify>node --check bak_a.txt</verify><depends_on>P01</depends_on></task>\n' +
|
|
1810
|
+
sameFilePairWithDeps + fixPair);
|
|
1672
1811
|
const ok = exitPlanApply();
|
|
1673
1812
|
assertExit(ok, 0);
|
|
1674
1813
|
assertOut(ok, 'ALL CHECKS PASSED');
|
|
1675
1814
|
assertNotOut(ok, 'BLOCKED');
|
|
1815
|
+
assertNotOut(ok, '同文件跨任务且无依赖路径');
|
|
1676
1816
|
},
|
|
1677
1817
|
},
|
|
1678
1818
|
|
|
@@ -2806,7 +2946,7 @@ const TEST_ITEMS = [
|
|
|
2806
2946
|
const status = runHandoff(['status'], dir);
|
|
2807
2947
|
assertExit(status, 0);
|
|
2808
2948
|
assertOut(status, '"handoffRequests"');
|
|
2809
|
-
assertOut(status, '"
|
|
2949
|
+
assertOut(status, '"handoffResult"');
|
|
2810
2950
|
assertOut(status, 'T01');
|
|
2811
2951
|
// ④ 无效提交哈希 → 错误提示但记录不阻断(结果仍入库)
|
|
2812
2952
|
const badHash = runHandoff(['result', 'T02', JSON.stringify({
|
|
@@ -3828,7 +3968,7 @@ const TEST_ITEMS = [
|
|
|
3828
3968
|
if (fs.existsSync(path.join(dir, '.specs', 'arch-m5b'))) {
|
|
3829
3969
|
throw new Error('M5 在双路径皆无时重建了活动目录(残留): .specs/arch-m5b/');
|
|
3830
3970
|
}
|
|
3831
|
-
// 变体:归档后 skill-load 报错须引导 record 自动补路径(
|
|
3971
|
+
// 变体:归档后 skill-load 报错须引导 record 自动补路径(真实会话实证:归档后手动声明
|
|
3832
3972
|
// 不可行,消息须指明 M5 自动补仍可写归档路径标记)
|
|
3833
3973
|
const slArchive = runState(['skill-load', 'archive', 'flow-comet-integration'], dir);
|
|
3834
3974
|
assertExit(slArchive, 1);
|
|
@@ -4128,6 +4268,206 @@ const TEST_ITEMS = [
|
|
|
4128
4268
|
},
|
|
4129
4269
|
},
|
|
4130
4270
|
|
|
4271
|
+
// ---------- H9~H11: 受控计划重校重签(replan)与强制推进留痕真实命令链路 ----------
|
|
4272
|
+
|
|
4273
|
+
{
|
|
4274
|
+
name: 'H9 replan 解死锁:execute 相位修订任务集(含并行就绪任务)→ 重签 → 出口放行 → next 正常路由',
|
|
4275
|
+
run: (dir) => {
|
|
4276
|
+
seedExecuteEntryState(dir, replanTaskText());
|
|
4277
|
+
// 真实委托留证(串行 pending → execute 归属)→ SUMMARY 齐备,出口四类校验可通过
|
|
4278
|
+
completeSerialTaskWithHandoff(dir, 'S01', 'src/s01.mjs');
|
|
4279
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/S01-SUMMARY.md', execSummaryFixture('S01'));
|
|
4280
|
+
// 任务集修订(死锁现场):原任务完成 + 计划外新增的并行就绪任务
|
|
4281
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', replanTaskText({ s01Status: 'done', parallelPending: ['P02'] }));
|
|
4282
|
+
const beforeBytes = readStateBytes(dir);
|
|
4283
|
+
// ① 前进被签名门禁挡住:exit execute → BLOCKED(任务集被修改)+ 零改写
|
|
4284
|
+
const blocked = runGuard(['exit', 'execute', '--apply'], dir);
|
|
4285
|
+
assertExit(blocked, 1);
|
|
4286
|
+
assertOut(blocked, 'BLOCKED');
|
|
4287
|
+
assertOut(blocked, '签名不匹配');
|
|
4288
|
+
if (!readStateBytes(dir).equals(beforeBytes)) throw new Error('签名门禁 BLOCK 改写了 state 字节');
|
|
4289
|
+
// ② 受控重校重签(唯一合规出口):授权 + 原因 + 重签 + 双写留痕 + 备份
|
|
4290
|
+
const replan = runState(['replan', '计划有缺陷:新增并行任务 P02', '--authorized-by', '用户裁决'], dir);
|
|
4291
|
+
assertExit(replan, 0);
|
|
4292
|
+
assertOut(replan, 'REPLAN');
|
|
4293
|
+
const st = readStateFile(dir);
|
|
4294
|
+
const events = replanEventsOf(st);
|
|
4295
|
+
if (events.length !== 1 || events[0].change !== CHANGE_ID || events[0].node !== 'execute') {
|
|
4296
|
+
throw new Error('replan-applied 审计事件不符: ' + JSON.stringify(events));
|
|
4297
|
+
}
|
|
4298
|
+
if (!st.evidence || !st.evidence.execute || !st.evidence.execute.replanAuthorization) {
|
|
4299
|
+
throw new Error('缺 evidence.execute.replanAuthorization 授权留痕: ' + JSON.stringify(st.evidence));
|
|
4300
|
+
}
|
|
4301
|
+
if (replanBackupFiles(dir).length !== 1) {
|
|
4302
|
+
throw new Error('重签应恰产生一份备份: ' + JSON.stringify(replanBackupFiles(dir)));
|
|
4303
|
+
}
|
|
4304
|
+
// ③ 同一出口再跑 → 放行(不再报签名不匹配),路由到委托节点(并行就绪任务)
|
|
4305
|
+
const exitRes = runGuard(['exit', 'execute', '--apply'], dir);
|
|
4306
|
+
assertExit(exitRes, 0);
|
|
4307
|
+
assertOut(exitRes, 'ALL CHECKS PASSED');
|
|
4308
|
+
assertNodeLine(exitRes, 'subagent-execute');
|
|
4309
|
+
// ④ next 正常路由(死锁解除后可继续推进)
|
|
4310
|
+
const next = runState(['next'], dir);
|
|
4311
|
+
assertExit(next, 0);
|
|
4312
|
+
assertNodeLine(next, 'subagent-execute');
|
|
4313
|
+
},
|
|
4314
|
+
},
|
|
4315
|
+
|
|
4316
|
+
{
|
|
4317
|
+
name: 'H10 replan 授权 fail-closed 与轮次上限:未授权零改写 · 同文件跨任务族分级拦截与恢复 · 第 4 次 BLOCK · 显式续轮放行(真实命令)',
|
|
4318
|
+
run: (dir) => {
|
|
4319
|
+
seedExecuteEntryState(dir, replanTaskText());
|
|
4320
|
+
// 修订任务集 → 进入「签名不匹配」的适用现场
|
|
4321
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', replanTaskText({ parallelPending: ['P01'] }));
|
|
4322
|
+
const beforeBytes = readStateBytes(dir);
|
|
4323
|
+
// ① 缺授权 / 空授权 / 纯空白授权 / 缺原因 → BLOCKED 且 state 字节零改写、零备份、零事件
|
|
4324
|
+
const blockedCalls = [
|
|
4325
|
+
['缺 --authorized-by', ['replan', '计划有缺陷:新增并行任务 P01']],
|
|
4326
|
+
['--authorized-by 空串', ['replan', '计划有缺陷:新增并行任务 P01', '--authorized-by', '']],
|
|
4327
|
+
['--authorized-by 纯空白', ['replan', '计划有缺陷:新增并行任务 P01', '--authorized-by', ' ']],
|
|
4328
|
+
['缺位置 reason', ['replan', '--authorized-by', '用户裁决']],
|
|
4329
|
+
];
|
|
4330
|
+
for (const [label, args] of blockedCalls) {
|
|
4331
|
+
const res = runState(args, dir);
|
|
4332
|
+
assertExit(res, 1);
|
|
4333
|
+
assertOut(res, 'BLOCKED');
|
|
4334
|
+
if (!readStateBytes(dir).equals(beforeBytes)) throw new Error(label + ':改写了 state 字节');
|
|
4335
|
+
}
|
|
4336
|
+
if (replanBackupFiles(dir).length !== 0) {
|
|
4337
|
+
throw new Error('未授权调用产生了备份: ' + JSON.stringify(replanBackupFiles(dir)));
|
|
4338
|
+
}
|
|
4339
|
+
if (replanEventsOf(readStateFile(dir)).length !== 0) {
|
|
4340
|
+
throw new Error('未授权调用写入了 replan-applied 事件');
|
|
4341
|
+
}
|
|
4342
|
+
// ② 真实链路跑满 3 轮(每轮重新修订任务集 → 重签;轮次按 change 从事件派生)。第 1 轮以
|
|
4343
|
+
// 「同文件跨任务且无依赖路径」的修订开场,逐档验证 replan 与 plan 出口同族的分级消费:
|
|
4344
|
+
// 旧 change 形态仅 WARN 且照常重签(渐进不卡死)→ 新 change 形态 BLOCK 且状态零改写
|
|
4345
|
+
// (BLOCK 早于备份与任何写盘:零新增备份、零新增事件、state 字节不变)→ 按恢复指引补显式
|
|
4346
|
+
// depends_on 后复签通过(同一通道,不做校验豁免)。
|
|
4347
|
+
const parallelIds = ['P01', 'P02', 'P03', 'P04'];
|
|
4348
|
+
const oldChangeState = readStateFile(dir);
|
|
4349
|
+
delete oldChangeState.newChange;
|
|
4350
|
+
writeState(dir, oldChangeState);
|
|
4351
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md',
|
|
4352
|
+
replanTaskText({ parallelPending: ['P01'], crossTaskPair: 'no-deps' }));
|
|
4353
|
+
const crossWarn = runState(['replan', '计划缺陷重校 1(旧 change 形态)', '--authorized-by', '用户裁决'], dir);
|
|
4354
|
+
assertExit(crossWarn, 0);
|
|
4355
|
+
assertOut(crossWarn, 'REPLAN');
|
|
4356
|
+
assertOut(crossWarn, 'WARN: TASK.md 同文件跨任务且无依赖路径');
|
|
4357
|
+
assertOut(crossWarn, 'X1×X2(src/shared-cross.mjs)');
|
|
4358
|
+
assertNotOut(crossWarn, 'BLOCKED');
|
|
4359
|
+
if (replanEventsOf(readStateFile(dir)).length !== 1) {
|
|
4360
|
+
throw new Error('旧 change 形态应照常重签并写入第 1 条 replan-applied 事件');
|
|
4361
|
+
}
|
|
4362
|
+
const afterWarnState = readStateFile(dir);
|
|
4363
|
+
afterWarnState.newChange = true;
|
|
4364
|
+
writeState(dir, afterWarnState);
|
|
4365
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md',
|
|
4366
|
+
replanTaskText({ parallelPending: ['P01', 'P02'], crossTaskPair: 'no-deps' }));
|
|
4367
|
+
const crossBytes = readStateBytes(dir);
|
|
4368
|
+
const crossBlocked = runState(['replan', '计划缺陷重校(新 change 形态)', '--authorized-by', '用户裁决'], dir);
|
|
4369
|
+
assertExit(crossBlocked, 1);
|
|
4370
|
+
assertOut(crossBlocked, 'BLOCKED');
|
|
4371
|
+
assertOut(crossBlocked, '同文件跨任务且无依赖路径');
|
|
4372
|
+
assertOut(crossBlocked, 'X1×X2(src/shared-cross.mjs)');
|
|
4373
|
+
assertOut(crossBlocked, '补显式 depends_on 或合并为一个任务');
|
|
4374
|
+
assertNotOut(crossBlocked, 'REPLAN:');
|
|
4375
|
+
if (!readStateBytes(dir).equals(crossBytes)) throw new Error('replan 第三族 BLOCK 改写了 state 字节');
|
|
4376
|
+
if (replanBackupFiles(dir).length !== 1) {
|
|
4377
|
+
throw new Error('replan 第三族 BLOCK 不得新增备份(应仍为第 1 轮那一份): ' + JSON.stringify(replanBackupFiles(dir)));
|
|
4378
|
+
}
|
|
4379
|
+
if (replanEventsOf(readStateFile(dir)).length !== 1) {
|
|
4380
|
+
throw new Error('replan 第三族 BLOCK 不得写入 replan-applied 事件');
|
|
4381
|
+
}
|
|
4382
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md',
|
|
4383
|
+
replanTaskText({ parallelPending: ['P01', 'P02'], crossTaskPair: 'deps' }));
|
|
4384
|
+
const crossRecovered = runState(['replan', '计划缺陷重校 2(已补 depends_on)', '--authorized-by', '用户裁决'], dir);
|
|
4385
|
+
assertExit(crossRecovered, 0);
|
|
4386
|
+
assertOut(crossRecovered, 'REPLAN');
|
|
4387
|
+
if (replanEventsOf(readStateFile(dir)).length !== 2) {
|
|
4388
|
+
throw new Error('补显式 depends_on 后复签应写入第 2 条 replan-applied 事件');
|
|
4389
|
+
}
|
|
4390
|
+
// 第 3 轮:常规修订(轮次按 change 从事件累计)
|
|
4391
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', replanTaskText({ parallelPending: parallelIds.slice(0, 3) }));
|
|
4392
|
+
const thirdRound = runState(['replan', '计划缺陷重校 3', '--authorized-by', '用户裁决'], dir);
|
|
4393
|
+
assertExit(thirdRound, 0);
|
|
4394
|
+
assertOut(thirdRound, 'REPLAN');
|
|
4395
|
+
if (replanEventsOf(readStateFile(dir)).length !== 3) {
|
|
4396
|
+
throw new Error('第 3 轮后 replan-applied 事件数应为 3');
|
|
4397
|
+
}
|
|
4398
|
+
if (replanBackupFiles(dir).length !== 3) {
|
|
4399
|
+
throw new Error('三轮应产生三份备份: ' + JSON.stringify(replanBackupFiles(dir)));
|
|
4400
|
+
}
|
|
4401
|
+
// ③ 第 4 次 → BLOCK + 人工裁决指引(继续 / 停止)+ state 字节零改写
|
|
4402
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', replanTaskText({ parallelPending: parallelIds }));
|
|
4403
|
+
const beforeFourth = readStateBytes(dir);
|
|
4404
|
+
const fourth = runState(['replan', '计划缺陷重校(上限后未授权)', '--authorized-by', '用户裁决'], dir);
|
|
4405
|
+
assertExit(fourth, 1);
|
|
4406
|
+
assertOut(fourth, 'BLOCK');
|
|
4407
|
+
assertOut(fourth, '继续');
|
|
4408
|
+
assertOut(fourth, '停止');
|
|
4409
|
+
if (!readStateBytes(dir).equals(beforeFourth)) throw new Error('超上限调用改写了 state 字节');
|
|
4410
|
+
if (replanEventsOf(readStateFile(dir)).length !== 3) throw new Error('超上限调用写入了 replan-applied 事件');
|
|
4411
|
+
if (replanBackupFiles(dir).length !== 3) {
|
|
4412
|
+
throw new Error('超上限调用新增了备份: ' + JSON.stringify(replanBackupFiles(dir)));
|
|
4413
|
+
}
|
|
4414
|
+
// ④ 续轮授权不足(n < 已用 + 1)→ BLOCK 零改写:上限裁决点不可被残缺授权绕过
|
|
4415
|
+
const insufficientBytes = readStateBytes(dir);
|
|
4416
|
+
const insufficient = runState(['replan', '计划缺陷重校(续轮不足)', '--authorized-by', '用户授权', '--continue-round', '3'], dir);
|
|
4417
|
+
assertExit(insufficient, 1);
|
|
4418
|
+
assertOut(insufficient, 'BLOCK');
|
|
4419
|
+
if (!readStateBytes(dir).equals(insufficientBytes)) throw new Error('续轮授权不足改写了 state 字节');
|
|
4420
|
+
// ⑤ 显式授权续轮(n = 已用 + 1)→ 放行并计第 4 轮:审计行标注续轮,事件 / 留痕带续轮标记
|
|
4421
|
+
const continued = runState(['replan', '计划缺陷重校(上限后显式续轮)', '--authorized-by', '用户授权续轮', '--continue-round', '4'], dir);
|
|
4422
|
+
assertExit(continued, 0);
|
|
4423
|
+
assertOut(continued, 'REPLAN');
|
|
4424
|
+
assertOut(continued, '续轮');
|
|
4425
|
+
const continuedState = readStateFile(dir);
|
|
4426
|
+
const continuedEvents = replanEventsOf(continuedState);
|
|
4427
|
+
const continuedEvent = continuedEvents[continuedEvents.length - 1];
|
|
4428
|
+
if (!continuedEvent || continuedEvent.round !== 4 || continuedEvent.change !== CHANGE_ID
|
|
4429
|
+
|| continuedEvent.continuationAuthorized !== true) {
|
|
4430
|
+
throw new Error('续轮审计事件字段不符(round=4 / change / 续轮标记): ' + JSON.stringify(continuedEvent));
|
|
4431
|
+
}
|
|
4432
|
+
if (!continuedState.evidence || !continuedState.evidence.execute
|
|
4433
|
+
|| continuedState.evidence.execute.replanAuthorization.continuationAuthorized !== true) {
|
|
4434
|
+
throw new Error('续轮授权留痕缺失: ' + JSON.stringify(continuedState.evidence && continuedState.evidence.execute));
|
|
4435
|
+
}
|
|
4436
|
+
if (replanBackupFiles(dir).length !== 4) {
|
|
4437
|
+
throw new Error('续轮放行应新增一份备份(共 4 份): ' + JSON.stringify(replanBackupFiles(dir)));
|
|
4438
|
+
}
|
|
4439
|
+
},
|
|
4440
|
+
},
|
|
4441
|
+
|
|
4442
|
+
{
|
|
4443
|
+
name: 'H11 advance 留痕:advance-forced 事件 + status.forcedNodes 派生可见(真实命令)',
|
|
4444
|
+
run: (dir) => {
|
|
4445
|
+
assertExit(runState(['init', CHANGE_ID, '--init-skip'], dir), 0);
|
|
4446
|
+
writeIntakeArtifacts(dir);
|
|
4447
|
+
const res = runState(['advance'], dir);
|
|
4448
|
+
assertExit(res, 0);
|
|
4449
|
+
assertOut(res, 'Advanced to: design');
|
|
4450
|
+
assertOut(res, 'ADVANCE-AUDIT');
|
|
4451
|
+
const st = readStateFile(dir);
|
|
4452
|
+
const events = (st.history || []).filter((e) => e && e.event === 'advance-forced');
|
|
4453
|
+
if (events.length !== 1) {
|
|
4454
|
+
throw new Error('advance 应恰写一条 advance-forced 事件: ' + JSON.stringify(events));
|
|
4455
|
+
}
|
|
4456
|
+
const event = events[0];
|
|
4457
|
+
if (event.node !== 'open' || event.change !== CHANGE_ID || event.reason !== 'advance') {
|
|
4458
|
+
throw new Error('advance-forced 事件字段不符: ' + JSON.stringify(event));
|
|
4459
|
+
}
|
|
4460
|
+
if (JSON.stringify(event.skipped) !== JSON.stringify(['exit:open'])) {
|
|
4461
|
+
throw new Error("advance-forced 事件应记录 skipped: ['exit:open']: " + JSON.stringify(event.skipped));
|
|
4462
|
+
}
|
|
4463
|
+
if (typeof event.at !== 'string' || event.at.trim() === '') throw new Error('advance-forced 缺 at: ' + JSON.stringify(event.at));
|
|
4464
|
+
const status = parseStatusOutput(dir);
|
|
4465
|
+
if (!Array.isArray(status.forcedNodes) || !status.forcedNodes.includes('open')) {
|
|
4466
|
+
throw new Error('status.forcedNodes 应含强制推进且无出口证据的 open: ' + JSON.stringify(status.forcedNodes));
|
|
4467
|
+
}
|
|
4468
|
+
},
|
|
4469
|
+
},
|
|
4470
|
+
|
|
4131
4471
|
// ---------- I. 异常路径 ----------
|
|
4132
4472
|
|
|
4133
4473
|
{
|
|
@@ -4676,7 +5016,7 @@ const TEST_ITEMS = [
|
|
|
4676
5016
|
console.log(' 描述符驱动: ' + ids.length + ' 个平台逐一安装 + purge 冒烟通过✓');
|
|
4677
5017
|
},
|
|
4678
5018
|
},
|
|
4679
|
-
// ---------- K 扩展:dsh 平台断言(1.4.2 deepseek-harness-platform
|
|
5019
|
+
// ---------- K 扩展:dsh 平台断言(1.4.2 deepseek-harness-platform——安装器多平台)(历史) ----------
|
|
4680
5020
|
// 旧 dsh-plugin npm 包已废弃(对象 dsh-plugin/ 目录另行废弃清理)——以下断言覆盖
|
|
4681
5021
|
// prepare-env --platform dsh 的项目级安装/AGENTS.md 托管区/桥接 loader/purge 清理恢复;
|
|
4682
5022
|
// 断言全程 DSH_HOME=临时目录环境变量,禁止污染真实 ~/.dsh(AC-1/AC-4)
|
|
@@ -5006,7 +5346,7 @@ const TEST_ITEMS = [
|
|
|
5006
5346
|
}
|
|
5007
5347
|
}
|
|
5008
5348
|
console.log(' delegationDepth 代理身份分派(子代理=执行者/协调者原链)✓');
|
|
5009
|
-
// ⑦ apply 集成喂测(5.5
|
|
5349
|
+
// ⑦ apply 集成喂测(5.5 分派分支自动化回归——此前仅有真实会话人工覆盖):
|
|
5010
5350
|
// mock ctx 捕获 tools/pre-execute 监听器,构造 exec 断言插件级行为、
|
|
5011
5351
|
// 子代理(agentDepth>0)写源码放行 / 协调者走 guard 白名单 / 越界·形状 deny 不受身份、
|
|
5012
5352
|
// 非 flow-comet 项目窄监听放行。复用 ⑤ 安装产物(target 为真实 dsh flow-comet 项目):
|
|
@@ -5622,6 +5962,78 @@ const TEST_ITEMS = [
|
|
|
5622
5962
|
},
|
|
5623
5963
|
},
|
|
5624
5964
|
|
|
5965
|
+
// K19: 契约核对脚本 CLI 契约——五组真实命令断言(临时夹具 app/x.py 含 status 赋值、src/y.ts 含 status 比较):
|
|
5966
|
+
// ① 显式 --backend/--frontend → exit 0 且输出含两个实际解析路径与两侧真实命中;
|
|
5967
|
+
// ② 缺省回退(cwd=夹具、无目录参数)→ exit 0 且两侧命中;
|
|
5968
|
+
// ③ 悬空 --backend(缺值)→ exit 1 + 用法错误;
|
|
5969
|
+
// ④ --project <夹具>(从夹具外运行)→ exit 0 且两侧命中(证明显式根优先于 cwd);
|
|
5970
|
+
// ⑤ 单横线操作数(--backend -bad-dir / --project -x / --frontend -y)→ exit 1 + 用法与非法操作数提示
|
|
5971
|
+
// (此前被当作目录接受、零命中仍 exit 0——fail-closed 缺口回归锚)。
|
|
5972
|
+
// 夹具随所在项临时目录由运行器统一清理,不留残留。
|
|
5973
|
+
{
|
|
5974
|
+
name: 'K19 契约核对:显式目录解析与缺省回退·悬空参数用法错误·单横线操作数拒绝·--project 形态(真实命令序列)',
|
|
5975
|
+
run: (dir) => {
|
|
5976
|
+
if (!fs.existsSync(CONTRACT)) throw new Error('缺少 contract-check.mjs: ' + CONTRACT);
|
|
5977
|
+
writeFile(dir, 'app/x.py', 'status = 3\n');
|
|
5978
|
+
writeFile(dir, 'src/y.ts', 'status === 3\n');
|
|
5979
|
+
const runContract = (args, cwd = dir) => {
|
|
5980
|
+
const res = spawnSync(process.execPath, [CONTRACT, ...args], { cwd, encoding: 'utf8', timeout: 60000 });
|
|
5981
|
+
return { status: res.status ?? 1, output: String(res.stdout || '') + String(res.stderr || '') };
|
|
5982
|
+
};
|
|
5983
|
+
// 输出头 `# <label>: <路径>` 取实际解析路径(断言脚本打印的是真实落点,而非回显参数)
|
|
5984
|
+
const resolvedPath = (res, label) => {
|
|
5985
|
+
const line = res.output.split(/\r?\n/).find((l) => l.startsWith('# ' + label + ': '));
|
|
5986
|
+
if (!line) throw new Error('输出缺少 ' + label + ' 解析路径头:\n' + res.output);
|
|
5987
|
+
return line.slice(('# ' + label + ': ').length).trim();
|
|
5988
|
+
};
|
|
5989
|
+
// ① 显式目录参数:exit 0 + 两个实际解析路径 + 两侧真实命中
|
|
5990
|
+
const explicit = runContract(['status', '--backend', 'app', '--frontend', 'src']);
|
|
5991
|
+
assertExit(explicit, 0);
|
|
5992
|
+
assertOut(explicit, 'status = 3');
|
|
5993
|
+
assertOut(explicit, 'status === 3');
|
|
5994
|
+
const backendPath = resolvedPath(explicit, 'backend');
|
|
5995
|
+
const frontendPath = resolvedPath(explicit, 'frontend');
|
|
5996
|
+
if (path.basename(backendPath) !== 'app' || path.basename(frontendPath) !== 'src') {
|
|
5997
|
+
throw new Error('解析路径落点错误: backend=' + backendPath + ' / frontend=' + frontendPath);
|
|
5998
|
+
}
|
|
5999
|
+
if (!fs.readFileSync(path.join(backendPath, 'x.py'), 'utf8').includes('status = 3')) {
|
|
6000
|
+
throw new Error('backend 实际解析路径未指向夹具: ' + backendPath);
|
|
6001
|
+
}
|
|
6002
|
+
if (!fs.readFileSync(path.join(frontendPath, 'y.ts'), 'utf8').includes('status === 3')) {
|
|
6003
|
+
throw new Error('frontend 实际解析路径未指向夹具: ' + frontendPath);
|
|
6004
|
+
}
|
|
6005
|
+
// ② 缺省回退:无目录参数时默认 <root>/app 与 <root>/src(root = cwd)
|
|
6006
|
+
const fallback = runContract(['status']);
|
|
6007
|
+
assertExit(fallback, 0);
|
|
6008
|
+
assertOut(fallback, 'status = 3');
|
|
6009
|
+
assertOut(fallback, 'status === 3');
|
|
6010
|
+
// ③ 悬空 --backend:缺值即用法错误 + 非零退出
|
|
6011
|
+
const dangling = runContract(['status', '--backend']);
|
|
6012
|
+
assertExit(dangling, 1);
|
|
6013
|
+
assertOut(dangling, '用法: node contract-check.mjs');
|
|
6014
|
+
assertOut(dangling, '--backend 后缺少后端目录值');
|
|
6015
|
+
// ④ --project 形态:从夹具外运行,显式项目根优先于 cwd(若被忽略则两侧都不命中)
|
|
6016
|
+
const elsewhere = path.join(dir, 'elsewhere');
|
|
6017
|
+
fs.mkdirSync(elsewhere, { recursive: true });
|
|
6018
|
+
const viaProject = runContract(['status', '--project', dir], elsewhere);
|
|
6019
|
+
assertExit(viaProject, 0);
|
|
6020
|
+
assertOut(viaProject, 'status = 3');
|
|
6021
|
+
assertOut(viaProject, 'status === 3');
|
|
6022
|
+
// ⑤ 单横线操作数:取值以 '-' 开头(含单横线形态)→ 用法错误 + 非零退出,不被当作目录
|
|
6023
|
+
// (判据含选项名与非法操作数提示——只查 exit 1 无判别力,须证明拒绝理由在场)
|
|
6024
|
+
const assertDashOperandRejected = (opt, bad) => {
|
|
6025
|
+
const r = runContract(['status', opt, bad]);
|
|
6026
|
+
assertExit(r, 1);
|
|
6027
|
+
assertOut(r, '用法: node contract-check.mjs');
|
|
6028
|
+
assertOut(r, opt + ' 的目录操作数不得以 - 开头');
|
|
6029
|
+
};
|
|
6030
|
+
assertDashOperandRejected('--backend', '-bad-dir');
|
|
6031
|
+
assertDashOperandRejected('--project', '-x');
|
|
6032
|
+
assertDashOperandRejected('--frontend', '-y');
|
|
6033
|
+
console.log(' 契约核对 CLI: 显式解析 + 缺省回退 + 悬空参数用法错误 + 单横线操作数拒绝 + --project 优先于 cwd ✓');
|
|
6034
|
+
},
|
|
6035
|
+
},
|
|
6036
|
+
|
|
5625
6037
|
// ---------- L. 执行遗漏防护(M1~M8 真实链路) ----------
|
|
5626
6038
|
|
|
5627
6039
|
{
|