flow-comet 1.7.0 → 1.8.0
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/INSTALLED_VERSION +1 -1
- package/.flow-comet/skills/flow-comet/SKILL.md +16 -14
- package/.flow-comet/skills/flow-comet/reference/commit-discipline.md +1 -1
- package/.flow-comet/skills/flow-comet/reference/decision-points.md +5 -5
- package/.flow-comet/skills/flow-comet/reference/dirty-worktree.md +1 -1
- package/.flow-comet/skills/flow-comet/reference/entry-detail.md +9 -9
- package/.flow-comet/skills/flow-comet/reference/fix-loop.md +4 -4
- package/.flow-comet/skills/flow-comet/reference/init-detection.md +1 -1
- package/.flow-comet/skills/flow-comet/reference/platform-facts.md +2 -2
- package/.flow-comet/skills/flow-comet/reference/post-archive-handoff.md +264 -0
- package/.flow-comet/skills/flow-comet/reference/recovery.md +1 -1
- package/.flow-comet/skills/flow-comet/reference/replan.md +1 -1
- package/.flow-comet/skills/flow-comet/scripts/comet-check.mjs +1 -0
- package/.flow-comet/skills/flow-comet/scripts/comet-hook-guard.mjs +270 -30
- package/.flow-comet/skills/flow-comet/scripts/items/a.mjs +25 -8
- package/.flow-comet/skills/flow-comet/scripts/items/b.mjs +41 -38
- package/.flow-comet/skills/flow-comet/scripts/items/c.mjs +11 -9
- package/.flow-comet/skills/flow-comet/scripts/items/e.mjs +2 -2
- package/.flow-comet/skills/flow-comet/scripts/items/f.mjs +1 -1
- package/.flow-comet/skills/flow-comet/scripts/items/h.mjs +112 -53
- package/.flow-comet/skills/flow-comet/scripts/items/k.mjs +357 -3
- package/.flow-comet/skills/flow-comet/scripts/items/l.mjs +24 -1
- package/.flow-comet/skills/flow-comet/scripts/items/m.mjs +2 -2
- package/.flow-comet/skills/flow-comet/scripts/items/n.mjs +9 -10
- package/.flow-comet/skills/flow-comet/scripts/lib/ac-coverage.mjs +8 -8
- package/.flow-comet/skills/flow-comet/scripts/lib/fix-loop-node.mjs +4 -15
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-evidence-gates.mjs +79 -107
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-gates.mjs +183 -232
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-routing.mjs +91 -14
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-template-fidelity.mjs +20 -32
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-uidesign.mjs +10 -19
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-admin.mjs +27 -17
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-flow.mjs +240 -87
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-recovery.mjs +15 -22
- package/.flow-comet/skills/flow-comet/scripts/lib/state-determine.mjs +11 -4
- package/.flow-comet/skills/flow-comet/scripts/lib/state-io.mjs +192 -24
- package/.flow-comet/skills/flow-comet/scripts/lib/state-skillmarkers.mjs +55 -44
- package/.flow-comet/skills/flow-comet/scripts/lib/system-fixtures.mjs +2 -4
- package/.flow-comet/skills/flow-comet/scripts/lib/test-assertions.mjs +0 -3
- package/.flow-comet/skills/flow-comet/scripts/lib/test-fixtures.mjs +191 -17
- package/.flow-comet/skills/flow-comet/scripts/lib/test-helpers.mjs +3 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/text-anchor-checks.mjs +23 -5
- package/.flow-comet/skills/flow-comet/scripts/lib/wave-projection.mjs +10 -11
- package/.flow-comet/skills/flow-comet/scripts/protocol-utils.mjs +40 -3
- package/.flow-comet/skills/flow-comet/scripts/route-node.mjs +12 -5
- package/.flow-comet/skills/flow-comet/scripts/scenarios/a.mjs +193 -111
- package/.flow-comet/skills/flow-comet/scripts/scenarios/b.mjs +314 -57
- package/.flow-comet/skills/flow-comet/scripts/scenarios/c.mjs +311 -216
- package/.flow-comet/skills/flow-comet/scripts/scenarios/d.mjs +33 -62
- package/.flow-comet/skills/flow-comet/scripts/scenarios/e.mjs +188 -91
- package/.flow-comet/skills/flow-comet/scripts/scenarios/f.mjs +94 -37
- package/.flow-comet/skills/flow-comet/scripts/scenarios/g.mjs +36 -27
- package/.flow-comet/skills/flow-comet/scripts/scenarios/h.mjs +285 -9
- package/.flow-comet/skills/flow-comet/scripts/scenarios/i.mjs +2 -6
- package/.flow-comet/skills/flow-comet/scripts/scenarios/j.mjs +5 -15
- package/.flow-comet/skills/flow-comet/scripts/scenarios/k.mjs +6 -5
- package/.flow-comet/skills/flow-comet/scripts/scenarios/l.mjs +40 -36
- package/.flow-comet/skills/flow-comet/scripts/scenarios/m.mjs +2 -2
- package/.flow-comet/skills/flow-comet/scripts/scenarios/n.mjs +346 -25
- package/.flow-comet/skills/flow-comet/scripts/state-schema.mjs +0 -2
- package/.flow-comet/skills/flow-comet/scripts/workflow-handoff.mjs +41 -54
- package/.flow-comet/skills/flow-comet-archive/SKILL.md +33 -11
- package/.flow-comet/skills/flow-comet-change/SKILL.md +1 -1
- package/.flow-comet/skills/flow-comet-design/SKILL.md +5 -3
- package/.flow-comet/skills/flow-comet-dev/SKILL.md +2 -2
- package/.flow-comet/skills/flow-comet-execute/SKILL.md +11 -11
- package/.flow-comet/skills/flow-comet-integration/SKILL.md +10 -4
- package/.flow-comet/skills/flow-comet-plan/GUIDANCE.md +1 -1
- package/.flow-comet/skills/flow-comet-plan/SKILL.md +8 -8
- package/.flow-comet/skills/flow-comet-review/SKILL.md +8 -8
- package/.flow-comet/skills/flow-comet-subagent-execute/GUIDANCE.md +1 -1
- package/.flow-comet/skills/flow-comet-subagent-execute/SKILL.md +14 -14
- package/.flow-comet/skills/flow-comet-task/SKILL.md +3 -2
- package/.flow-comet/skills/flow-comet-ui-design/SKILL.md +2 -2
- package/.flow-comet/skills/flow-comet-verify/SKILL.md +1 -1
- package/README.md +2 -2
- package/package.json +1 -1
- package/scripts/dsh-bridge.mjs +238 -21
|
@@ -686,13 +686,61 @@ const RAW_ENTRIES = [
|
|
|
686
686
|
for (const alias of ['edit', 'Edit', 'editfile', 'file-edit']) {
|
|
687
687
|
if (bridge.normalizeToolName(alias) !== 'Edit') throw new Error('normalizeToolName 别名未归一化: ' + alias);
|
|
688
688
|
}
|
|
689
|
+
// dsh-ops 0.5.0 写入面别名:桌面(hidePwsh + 动态工具)与 PTC host 派发均用这些名字;
|
|
690
|
+
// 不归一化即 next() 放行 = 白名单被 OPS 写入面绕过。
|
|
691
|
+
for (const alias of ['ops_write_file', 'OPS_WRITE_FILE']) {
|
|
692
|
+
if (bridge.normalizeToolName(alias) !== 'Write') throw new Error('dsh-ops Write 别名未归一化: ' + alias);
|
|
693
|
+
}
|
|
694
|
+
for (const alias of ['ops_edit_file', 'OPS_EDIT_FILE']) {
|
|
695
|
+
if (bridge.normalizeToolName(alias) !== 'Edit') throw new Error('dsh-ops Edit 别名未归一化: ' + alias);
|
|
696
|
+
}
|
|
697
|
+
for (const alias of ['ops_bash', 'OPS_BASH']) {
|
|
698
|
+
if (bridge.normalizeToolName(alias) !== 'Bash') throw new Error('dsh-ops Bash 别名未归一化: ' + alias);
|
|
699
|
+
}
|
|
689
700
|
for (const alias of ['bash', 'Bash', 'shell', 'powershell', 'pwsh', 'Pwsh', 'PWSH', 'run_command', 'run-command']) {
|
|
690
701
|
if (bridge.normalizeToolName(alias) !== 'Bash') throw new Error('normalizeToolName 别名未归一化: ' + alias);
|
|
691
702
|
}
|
|
692
703
|
// 非 Write/Edit/Bash 或非字符串 → null(监听侧按放行语义跳过)
|
|
693
|
-
for (const v of ['read', 'grep', '', null, undefined, 123, {}]) {
|
|
704
|
+
for (const v of ['read', 'grep', 'run_code', 'ops_remove', 'ops_copy', '', null, undefined, 123, {}]) {
|
|
694
705
|
if (bridge.normalizeToolName(v) !== null) throw new Error('非写工具应归一化为 null: ' + JSON.stringify(v));
|
|
695
706
|
}
|
|
707
|
+
// 受控例外纯函数:run_code(PTC transport)与 OPS 文件类工具没有 canonical 名,
|
|
708
|
+
// 但运行态必须拒绝;两者不得互相误判(write 不是 PTC,ops_write_file 不是文件类工具)。
|
|
709
|
+
if (!bridge.isPtcTransport('run_code') || !bridge.isPtcTransport('RUN_CODE')) {
|
|
710
|
+
throw new Error('isPtcTransport 应识别 run_code(大小写不敏感)');
|
|
711
|
+
}
|
|
712
|
+
if (bridge.isPtcTransport('write') || bridge.isPtcTransport('ops_bash')) {
|
|
713
|
+
throw new Error('isPtcTransport 不得误判普通写工具');
|
|
714
|
+
}
|
|
715
|
+
for (const t of ['ops_copy', 'ops_move', 'ops_remove', 'ops_replace', 'ops_batch', 'OPS_REMOVE']) {
|
|
716
|
+
if (!bridge.isOpsFileOperationTool(t)) throw new Error('isOpsFileOperationTool 应识别: ' + t);
|
|
717
|
+
}
|
|
718
|
+
if (bridge.isOpsFileOperationTool('ops_write_file') || bridge.isOpsFileOperationTool('write')) {
|
|
719
|
+
throw new Error('isOpsFileOperationTool 不得误判单目标写工具');
|
|
720
|
+
}
|
|
721
|
+
// 单目标 OPS 的字段选择:copy/move 取 to(写目标),remove 取 path;move 的源端另取 path。
|
|
722
|
+
for (const t of ['ops_copy', 'ops_move', 'ops_remove', 'OPS_COPY']) {
|
|
723
|
+
if (!bridge.isSingleTargetOpsFileTool(t)) throw new Error('isSingleTargetOpsFileTool 应识别: ' + t);
|
|
724
|
+
}
|
|
725
|
+
if (bridge.isSingleTargetOpsFileTool('ops_replace') || bridge.isSingleTargetOpsFileTool('ops_batch')) {
|
|
726
|
+
throw new Error('isSingleTargetOpsFileTool 不得误判多目标工具');
|
|
727
|
+
}
|
|
728
|
+
const copyTarget = bridge.mapSingleTargetOpsFileTool('ops_copy', { path: 'src/a', to: '.specs/b' });
|
|
729
|
+
if (!copyTarget.ok || copyTarget.target !== '.specs/b') {
|
|
730
|
+
throw new Error('ops_copy 应取 to 为写目标: ' + JSON.stringify(copyTarget));
|
|
731
|
+
}
|
|
732
|
+
const moveTarget = bridge.mapSingleTargetOpsFileTool('ops_move', { path: 'src/a', to: '.specs/b' });
|
|
733
|
+
if (!moveTarget.ok || moveTarget.target !== '.specs/b') {
|
|
734
|
+
throw new Error('ops_move 应取 to 为写目标: ' + JSON.stringify(moveTarget));
|
|
735
|
+
}
|
|
736
|
+
const removeTarget = bridge.mapSingleTargetOpsFileTool('ops_remove', { path: 'src/a' });
|
|
737
|
+
if (!removeTarget.ok || removeTarget.target !== 'src/a') {
|
|
738
|
+
throw new Error('ops_remove 应取 path 为写目标: ' + JSON.stringify(removeTarget));
|
|
739
|
+
}
|
|
740
|
+
const moveSource = bridge.mapOpsMoveSource({ path: 'src/a', to: '.specs/b' });
|
|
741
|
+
if (!moveSource.ok || moveSource.target !== 'src/a') {
|
|
742
|
+
throw new Error('ops_move 源端应取 path: ' + JSON.stringify(moveSource));
|
|
743
|
+
}
|
|
696
744
|
// ② 参数映射别名提取:Write/Edit 的 file_path/filePath/path;Bash 的 command/cmd/script
|
|
697
745
|
const m1 = bridge.mapToolInput('Write', { file_path: 'a.md' });
|
|
698
746
|
if (!m1.ok || m1.target !== 'a.md' || m1.input.file_path !== 'a.md') throw new Error('Write file_path 映射失败: ' + JSON.stringify(m1));
|
|
@@ -866,6 +914,12 @@ const RAW_ENTRIES = [
|
|
|
866
914
|
() => { usedNext = true; },
|
|
867
915
|
);
|
|
868
916
|
if (!usedNext) throw new Error('非 flow-comet 项目应窄监听放行(next)');
|
|
917
|
+
usedNext = false;
|
|
918
|
+
const resRun = await preExec(
|
|
919
|
+
{ name: 'run_code', arguments: { code: '1' }, agent: { cwd: plain, session: { header: { delegationDepth: 1 } } } },
|
|
920
|
+
() => { usedNext = true; },
|
|
921
|
+
);
|
|
922
|
+
if (!usedNext) throw new Error('非 flow-comet 项目的 run_code 应窄监听放行(next): ' + JSON.stringify(resRun));
|
|
869
923
|
}
|
|
870
924
|
// ⑦d 越界写不受身份影响:子代理(depth=1)写项目根外 → 包含性 fail-closed deny
|
|
871
925
|
{
|
|
@@ -1007,7 +1061,254 @@ const RAW_ENTRIES = [
|
|
|
1007
1061
|
}
|
|
1008
1062
|
console.log(' 桥接通道标记:继承形态按协调者拦 / 标记在场走身份放行 / 近形状标记不认 ✓');
|
|
1009
1063
|
}
|
|
1010
|
-
|
|
1064
|
+
// ⑦k dsh-ops ops_bash 归一化为 Bash:运行态协调者写 src/ 源码 → 真实 guard 白名单 deny。
|
|
1065
|
+
// 反向构造:去掉 ops_bash 别名 ⇒ canonicalName=null → next() 放行(dsh-ops 桌面
|
|
1066
|
+
// hidePwsh 后 shell 只剩 ops_bash,等于 shell 写整链绕过)。
|
|
1067
|
+
{
|
|
1068
|
+
let usedNext = false;
|
|
1069
|
+
const res = await preExec(
|
|
1070
|
+
{ name: 'ops_bash', arguments: { command: "printf 'x' > src/ops-shell.txt", description: 'probe' }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1071
|
+
() => { usedNext = true; },
|
|
1072
|
+
);
|
|
1073
|
+
if (usedNext) throw new Error('ops_bash 写源码不应 next——OPS shell 别名缺失(fail-open)');
|
|
1074
|
+
if (!res || res.kind !== 'deny' || !res.reason.includes('白名单拦截')) {
|
|
1075
|
+
throw new Error('ops_bash 写源码应走 guard 白名单拦截(deny): ' + JSON.stringify(res));
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
// ⑦l dsh-ops ops_write_file 归一化为 Write:运行态写 src/ → deny
|
|
1079
|
+
{
|
|
1080
|
+
let usedNext = false;
|
|
1081
|
+
const res = await preExec(
|
|
1082
|
+
{ name: 'ops_write_file', arguments: { path: path.join(longTarget, 'src', 'ops-write.md'), content: 'x', expectedRevision: 'absent' }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1083
|
+
() => { usedNext = true; },
|
|
1084
|
+
);
|
|
1085
|
+
if (usedNext) throw new Error('ops_write_file 写源码不应 next——OPS 文件别名缺失(fail-open)');
|
|
1086
|
+
if (!res || res.kind !== 'deny' || !res.reason.includes('白名单拦截')) {
|
|
1087
|
+
throw new Error('ops_write_file 写源码应走 guard 白名单拦截(deny): ' + JSON.stringify(res));
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
// ⑦m 同工具写 .specs/ → 放行(别名不误伤白名单内写入)
|
|
1091
|
+
{
|
|
1092
|
+
let usedNext = false;
|
|
1093
|
+
const res = await preExec(
|
|
1094
|
+
{ name: 'ops_write_file', arguments: { path: path.join(longTarget, '.specs', 'ops-ok.md'), content: 'ok', expectedRevision: 'absent' }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1095
|
+
() => { usedNext = true; },
|
|
1096
|
+
);
|
|
1097
|
+
if (!usedNext) throw new Error('ops_write_file 写 .specs 应放行(next): ' + JSON.stringify(res));
|
|
1098
|
+
if (res) throw new Error('ops_write_file 写 .specs 不应返回 deny: ' + JSON.stringify(res));
|
|
1099
|
+
}
|
|
1100
|
+
// ⑦n PTC run_code 运行态默认放行(PTC 是主要使用方式;进程内直写是已记录边界)
|
|
1101
|
+
{
|
|
1102
|
+
let usedNext = false;
|
|
1103
|
+
const res = await preExec(
|
|
1104
|
+
{ name: 'run_code', arguments: { code: 'const fs = await import("node:fs"); fs.writeFileSync("x","y")', description: 'ptc probe' }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1105
|
+
() => { usedNext = true; },
|
|
1106
|
+
);
|
|
1107
|
+
if (!usedNext) throw new Error('PTC 默认放行时 run_code 应 next: ' + JSON.stringify(res));
|
|
1108
|
+
if (res) throw new Error('PTC 默认放行时 run_code 不应返回 deny: ' + JSON.stringify(res));
|
|
1109
|
+
}
|
|
1110
|
+
const opsRev = 'a'.repeat(64); // dsh-ops copy/move/remove/edit 的 existingRevision 是 64-hex(write_file 才接受 absent)
|
|
1111
|
+
// ⑦o ops_remove 单目标:映射为 Write,走 guard 白名单(写 src deny、写 .specs 放行)
|
|
1112
|
+
{
|
|
1113
|
+
let usedNext = false;
|
|
1114
|
+
const res = await preExec(
|
|
1115
|
+
{ name: 'ops_remove', arguments: { path: path.join(longTarget, 'src', 'x.md'), expectedRevision: opsRev }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1116
|
+
() => { usedNext = true; },
|
|
1117
|
+
);
|
|
1118
|
+
if (usedNext) throw new Error('ops_remove 写源码不应 next——单目标未走 guard');
|
|
1119
|
+
if (!res || res.kind !== 'deny' || !res.reason.includes('白名单拦截')) {
|
|
1120
|
+
throw new Error('ops_remove 写源码应走 guard 白名单拦截(deny): ' + JSON.stringify(res));
|
|
1121
|
+
}
|
|
1122
|
+
usedNext = false;
|
|
1123
|
+
const res2 = await preExec(
|
|
1124
|
+
{ name: 'ops_remove', arguments: { path: path.join(longTarget, '.specs', 'x.md'), expectedRevision: opsRev }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1125
|
+
() => { usedNext = true; },
|
|
1126
|
+
);
|
|
1127
|
+
if (!usedNext) throw new Error('ops_remove 写 .specs 应放行(next): ' + JSON.stringify(res2));
|
|
1128
|
+
}
|
|
1129
|
+
// ⑦p ops_bash 的 script_path 形态:运行中的协调者拒绝(两步绕过:先写 .specs 脚本
|
|
1130
|
+
// 再执行);子代理是执行者,放行。
|
|
1131
|
+
{
|
|
1132
|
+
let usedNext = false;
|
|
1133
|
+
const res = await preExec(
|
|
1134
|
+
{ name: 'ops_bash', arguments: { script_path: 'probe.sh', description: 'probe' }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1135
|
+
() => { usedNext = true; },
|
|
1136
|
+
);
|
|
1137
|
+
if (usedNext) throw new Error('协调者运行态 ops_bash script_path 不应 next——两步绕过');
|
|
1138
|
+
if (!res || res.kind !== 'deny' || !res.reason.includes('script_path')) {
|
|
1139
|
+
throw new Error('协调者运行态 ops_bash script_path 应 deny(含 script_path 语义): ' + JSON.stringify(res));
|
|
1140
|
+
}
|
|
1141
|
+
usedNext = false;
|
|
1142
|
+
const sub = await preExec(
|
|
1143
|
+
{ name: 'ops_bash', arguments: { script_path: 'probe.sh', description: 'probe' }, agent: { cwd: longTarget, session: { header: { delegationDepth: 1 } } } },
|
|
1144
|
+
() => { usedNext = true; },
|
|
1145
|
+
);
|
|
1146
|
+
if (!usedNext) throw new Error('子代理 ops_bash script_path 应放行(next): ' + JSON.stringify(sub));
|
|
1147
|
+
}
|
|
1148
|
+
// ⑦q ops_edit_file 归一化为 Edit:运行态写 src/ deny、写 .specs/ 放行
|
|
1149
|
+
{
|
|
1150
|
+
let usedNext = false;
|
|
1151
|
+
const res = await preExec(
|
|
1152
|
+
{ name: 'ops_edit_file', arguments: { path: path.join(longTarget, 'src', 'ops-edit.md'), expectedRevision: opsRev, edits: [{ oldText: 'a', newText: 'b' }] }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1153
|
+
() => { usedNext = true; },
|
|
1154
|
+
);
|
|
1155
|
+
if (usedNext) throw new Error('ops_edit_file 写源码不应 next——OPS 编辑别名缺失');
|
|
1156
|
+
if (!res || res.kind !== 'deny' || !res.reason.includes('白名单拦截')) {
|
|
1157
|
+
throw new Error('ops_edit_file 写源码应走 guard 白名单拦截(deny): ' + JSON.stringify(res));
|
|
1158
|
+
}
|
|
1159
|
+
usedNext = false;
|
|
1160
|
+
const res2 = await preExec(
|
|
1161
|
+
{ name: 'ops_edit_file', arguments: { path: path.join(longTarget, '.specs', 'ops-edit.md'), expectedRevision: opsRev, edits: [{ oldText: 'a', newText: 'b' }] }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1162
|
+
() => { usedNext = true; },
|
|
1163
|
+
);
|
|
1164
|
+
if (!usedNext) throw new Error('ops_edit_file 写 .specs 应放行(next): ' + JSON.stringify(res2));
|
|
1165
|
+
}
|
|
1166
|
+
// ⑦r ops_copy 单目标:to 是写目标,走 guard 白名单(写 src deny、写 .specs 放行)
|
|
1167
|
+
{
|
|
1168
|
+
let usedNext = false;
|
|
1169
|
+
const res = await preExec(
|
|
1170
|
+
{ name: 'ops_copy', arguments: { path: path.join(longTarget, 'src', 'a.md'), to: path.join(longTarget, 'src', 'b.md'), expectedRevision: opsRev }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1171
|
+
() => { usedNext = true; },
|
|
1172
|
+
);
|
|
1173
|
+
if (usedNext) throw new Error('ops_copy 写源码不应 next——单目标未走 guard');
|
|
1174
|
+
if (!res || res.kind !== 'deny' || !res.reason.includes('白名单拦截')) {
|
|
1175
|
+
throw new Error('ops_copy 写源码应走 guard 白名单拦截(deny): ' + JSON.stringify(res));
|
|
1176
|
+
}
|
|
1177
|
+
usedNext = false;
|
|
1178
|
+
const res2 = await preExec(
|
|
1179
|
+
{ name: 'ops_copy', arguments: { path: path.join(longTarget, '.specs', 'a.md'), to: path.join(longTarget, '.specs', 'b.md'), expectedRevision: opsRev }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1180
|
+
() => { usedNext = true; },
|
|
1181
|
+
);
|
|
1182
|
+
if (!usedNext) throw new Error('ops_copy 写 .specs 应放行(next): ' + JSON.stringify(res2));
|
|
1183
|
+
}
|
|
1184
|
+
// ⑦r2 ops_replace 是真多目标:运行中的协调者按组拒绝;子代理(执行者)放行
|
|
1185
|
+
{
|
|
1186
|
+
let usedNext = false;
|
|
1187
|
+
const res = await preExec(
|
|
1188
|
+
{ name: 'ops_replace', arguments: { path: longTarget, pattern: 'a', replacement: 'b' }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1189
|
+
() => { usedNext = true; },
|
|
1190
|
+
);
|
|
1191
|
+
if (usedNext) throw new Error('协调者 ops_replace 运行态不应 next——多目标未按组拒绝');
|
|
1192
|
+
if (!res || res.kind !== 'deny' || !res.reason.includes('多目标')) {
|
|
1193
|
+
throw new Error('协调者 ops_replace 运行态应 deny(含多目标语义): ' + JSON.stringify(res));
|
|
1194
|
+
}
|
|
1195
|
+
usedNext = false;
|
|
1196
|
+
const subReplace = await preExec(
|
|
1197
|
+
{ name: 'ops_replace', arguments: { path: longTarget, pattern: 'a', replacement: 'b' }, agent: { cwd: longTarget, session: { header: { delegationDepth: 1 } } } },
|
|
1198
|
+
() => { usedNext = true; },
|
|
1199
|
+
);
|
|
1200
|
+
if (!usedNext) throw new Error('子代理 ops_replace 应放行(next,执行者身份): ' + JSON.stringify(subReplace));
|
|
1201
|
+
usedNext = false;
|
|
1202
|
+
const subBatch = await preExec(
|
|
1203
|
+
{ name: 'ops_batch', arguments: { action: 'plan', ops: [] }, agent: { cwd: longTarget, session: { header: { delegationDepth: 1 } } } },
|
|
1204
|
+
() => { usedNext = true; },
|
|
1205
|
+
);
|
|
1206
|
+
if (!usedNext) throw new Error('子代理 ops_batch 应放行(next,执行者身份): ' + JSON.stringify(subBatch));
|
|
1207
|
+
}
|
|
1208
|
+
// ⑦r3 ops_copy 跨侧:目的 .specs -> src 必须 deny;源 src 只读、目的 .specs 放行
|
|
1209
|
+
{
|
|
1210
|
+
let usedNext = false;
|
|
1211
|
+
const res = await preExec(
|
|
1212
|
+
{ name: 'ops_copy', arguments: { path: path.join(longTarget, '.specs', 'a.md'), to: path.join(longTarget, 'src', 'b.md'), expectedRevision: opsRev }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1213
|
+
() => { usedNext = true; },
|
|
1214
|
+
);
|
|
1215
|
+
if (usedNext) throw new Error('ops_copy .specs -> src 不应 next——目的端未走 guard');
|
|
1216
|
+
if (!res || res.kind !== 'deny' || !res.reason.includes('白名单拦截')) {
|
|
1217
|
+
throw new Error('ops_copy .specs -> src 应走 guard 白名单拦截(deny): ' + JSON.stringify(res));
|
|
1218
|
+
}
|
|
1219
|
+
usedNext = false;
|
|
1220
|
+
const res2 = await preExec(
|
|
1221
|
+
{ name: 'ops_copy', arguments: { path: path.join(longTarget, 'src', 'a.md'), to: path.join(longTarget, '.specs', 'b.md'), expectedRevision: opsRev }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1222
|
+
() => { usedNext = true; },
|
|
1223
|
+
);
|
|
1224
|
+
if (!usedNext) throw new Error('ops_copy src -> .specs 应放行(next,源只读): ' + JSON.stringify(res2));
|
|
1225
|
+
}
|
|
1226
|
+
// ⑦r4 ops_move 双端:源 src/state/outside 与目的 src 都必须 deny;双 .specs 放行
|
|
1227
|
+
{
|
|
1228
|
+
let usedNext = false;
|
|
1229
|
+
const srcToSpecs = await preExec(
|
|
1230
|
+
{ name: 'ops_move', arguments: { path: path.join(longTarget, 'src', 'a.md'), to: path.join(longTarget, '.specs', 'a.md'), expectedRevision: opsRev }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1231
|
+
() => { usedNext = true; },
|
|
1232
|
+
);
|
|
1233
|
+
if (usedNext) throw new Error('ops_move src -> .specs 不应 next——源端 unlink 未判');
|
|
1234
|
+
if (!srcToSpecs || srcToSpecs.kind !== 'deny' || !srcToSpecs.reason.includes('白名单拦截')) {
|
|
1235
|
+
throw new Error('ops_move src -> .specs 应因源端白名单 deny: ' + JSON.stringify(srcToSpecs));
|
|
1236
|
+
}
|
|
1237
|
+
usedNext = false;
|
|
1238
|
+
const specsToSrc = await preExec(
|
|
1239
|
+
{ name: 'ops_move', arguments: { path: path.join(longTarget, '.specs', 'a.md'), to: path.join(longTarget, 'src', 'a.md'), expectedRevision: opsRev }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1240
|
+
() => { usedNext = true; },
|
|
1241
|
+
);
|
|
1242
|
+
if (usedNext) throw new Error('ops_move .specs -> src 不应 next——目的端未走 guard');
|
|
1243
|
+
if (!specsToSrc || specsToSrc.kind !== 'deny' || !specsToSrc.reason.includes('白名单拦截')) {
|
|
1244
|
+
throw new Error('ops_move .specs -> src 应因目的端白名单 deny: ' + JSON.stringify(specsToSrc));
|
|
1245
|
+
}
|
|
1246
|
+
usedNext = false;
|
|
1247
|
+
const stateToSpecs = await preExec(
|
|
1248
|
+
{ name: 'ops_move', arguments: { path: path.join(longTarget, '.flow-comet', 'flow-comet-state.json'), to: path.join(longTarget, '.specs', 'state.json'), expectedRevision: opsRev }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1249
|
+
() => { usedNext = true; },
|
|
1250
|
+
);
|
|
1251
|
+
if (usedNext) throw new Error('ops_move state -> .specs 不应 next——源端最小保护集未判');
|
|
1252
|
+
if (!stateToSpecs || stateToSpecs.kind !== 'deny') {
|
|
1253
|
+
throw new Error('ops_move state -> .specs 应因源端保护集 deny: ' + JSON.stringify(stateToSpecs));
|
|
1254
|
+
}
|
|
1255
|
+
usedNext = false;
|
|
1256
|
+
const outsideToSpecs = await preExec(
|
|
1257
|
+
{ name: 'ops_move', arguments: { path: path.join(dir, 'k11-move-outside', 'a.md'), to: path.join(longTarget, '.specs', 'a.md'), expectedRevision: opsRev }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1258
|
+
() => { usedNext = true; },
|
|
1259
|
+
);
|
|
1260
|
+
if (usedNext) throw new Error('ops_move outside -> .specs 不应 next——源端越界未判');
|
|
1261
|
+
if (!outsideToSpecs || outsideToSpecs.kind !== 'deny' || !outsideToSpecs.reason.includes('越界移动')) {
|
|
1262
|
+
throw new Error('ops_move outside -> .specs 应因源端越界 deny: ' + JSON.stringify(outsideToSpecs));
|
|
1263
|
+
}
|
|
1264
|
+
usedNext = false;
|
|
1265
|
+
const specsToSpecs = await preExec(
|
|
1266
|
+
{ name: 'ops_move', arguments: { path: path.join(longTarget, '.specs', 'a.md'), to: path.join(longTarget, '.specs', 'b.md'), expectedRevision: opsRev }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1267
|
+
() => { usedNext = true; },
|
|
1268
|
+
);
|
|
1269
|
+
if (!usedNext) throw new Error('ops_move .specs -> .specs 应放行(next): ' + JSON.stringify(specsToSpecs));
|
|
1270
|
+
}
|
|
1271
|
+
// ⑦s ops_bash 的 workdir 在项目外:运行态拒绝(相对写入的真实落点与 guard 判定不一致)
|
|
1272
|
+
{
|
|
1273
|
+
const outsideWorkdir = path.join(dir, 'k11-workdir-out');
|
|
1274
|
+
fs.mkdirSync(outsideWorkdir, { recursive: true });
|
|
1275
|
+
let usedNext = false;
|
|
1276
|
+
const res = await preExec(
|
|
1277
|
+
{ name: 'ops_bash', arguments: { command: "printf 'x' > .specs/evil", workdir: outsideWorkdir, description: 'probe' }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1278
|
+
() => { usedNext = true; },
|
|
1279
|
+
);
|
|
1280
|
+
if (usedNext) throw new Error('ops_bash workdir 在项目外不应 next——路径基准 fail-open');
|
|
1281
|
+
if (!res || res.kind !== 'deny' || !res.reason.includes('workdir')) {
|
|
1282
|
+
throw new Error('ops_bash workdir 在项目外应 deny(含 workdir 语义): ' + JSON.stringify(res));
|
|
1283
|
+
}
|
|
1284
|
+
// 子代理是执行者:同一 workdir 不应被这条协调者专属检查拦住
|
|
1285
|
+
usedNext = false;
|
|
1286
|
+
const subWorkdir = await preExec(
|
|
1287
|
+
{ name: 'ops_bash', arguments: { command: 'printf x > y', workdir: outsideWorkdir }, agent: { cwd: longTarget, session: { header: { delegationDepth: 1 } } } },
|
|
1288
|
+
() => { usedNext = true; },
|
|
1289
|
+
);
|
|
1290
|
+
if (!usedNext) throw new Error('子代理 ops_bash workdir 应放行(next,执行者身份): ' + JSON.stringify(subWorkdir));
|
|
1291
|
+
// 官方 bash 同形(绝对 workdir 在项目外)同样被拒,避免换工具名绕过
|
|
1292
|
+
usedNext = false;
|
|
1293
|
+
const officialBash = await preExec(
|
|
1294
|
+
{ name: 'bash', arguments: { command: 'printf x > .specs/e.md', workdir: outsideWorkdir }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1295
|
+
() => { usedNext = true; },
|
|
1296
|
+
);
|
|
1297
|
+
if (usedNext) throw new Error('官方 bash 绝对 workdir 在项目外不应 next——同形 fail-open');
|
|
1298
|
+
if (!officialBash || officialBash.kind !== 'deny') {
|
|
1299
|
+
throw new Error('官方 bash 绝对 workdir 在项目外应 deny: ' + JSON.stringify(officialBash));
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
// ⑦s2 相对 workdir 不在检查范围(只查绝对路径):项目内子目录的相对 workdir 不误拦
|
|
1303
|
+
{
|
|
1304
|
+
let usedNext = false;
|
|
1305
|
+
const res = await preExec(
|
|
1306
|
+
{ name: 'ops_bash', arguments: { command: 'git status', workdir: 'src' }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1307
|
+
() => { usedNext = true; },
|
|
1308
|
+
);
|
|
1309
|
+
if (!usedNext) throw new Error('项目内相对 workdir 不应被误拦: ' + JSON.stringify(res));
|
|
1310
|
+
}
|
|
1311
|
+
console.log(' bridge.apply 分派集成(子代理放行/协调者拦/越界·形状 deny 不受身份/保护集拦/OPS 别名·单目标映射·多目标组拒绝/script_path/workdir/PTC 默认放行)✓');
|
|
1011
1312
|
},
|
|
1012
1313
|
},
|
|
1013
1314
|
|
|
@@ -1079,6 +1380,48 @@ const RAW_ENTRIES = [
|
|
|
1079
1380
|
if (!usedNext) throw new Error('AC-3 status completed 应放行(next 被调): ' + JSON.stringify(r));
|
|
1080
1381
|
if (r) throw new Error('AC-3 completed 不应返回 deny: ' + JSON.stringify(r));
|
|
1081
1382
|
}
|
|
1383
|
+
// AC-3c 空闲态不得误伤 PTC/OPS:completed 态下 run_code 与 ops_bash 均 next()
|
|
1384
|
+
// (运行态才拦——PTC 与 OPS 文件类工具的保守策略只在 active workflow 生效)
|
|
1385
|
+
{
|
|
1386
|
+
let usedNext = false;
|
|
1387
|
+
const r = await preExec(
|
|
1388
|
+
{ name: 'run_code', arguments: { code: '1' }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1389
|
+
() => { usedNext = true; },
|
|
1390
|
+
);
|
|
1391
|
+
if (!usedNext) throw new Error('空闲态 run_code 应放行(next): ' + JSON.stringify(r));
|
|
1392
|
+
usedNext = false;
|
|
1393
|
+
const r2 = await preExec(
|
|
1394
|
+
{ name: 'ops_bash', arguments: { command: 'printf x > y' }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1395
|
+
() => { usedNext = true; },
|
|
1396
|
+
);
|
|
1397
|
+
if (!usedNext) throw new Error('空闲态 ops_bash 应放行(next): ' + JSON.stringify(r2));
|
|
1398
|
+
usedNext = false;
|
|
1399
|
+
const r3 = await preExec(
|
|
1400
|
+
{ name: 'ops_bash', arguments: { script_path: 'probe.sh', description: 'probe' }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1401
|
+
() => { usedNext = true; },
|
|
1402
|
+
);
|
|
1403
|
+
if (!usedNext) throw new Error('空闲态 ops_bash script_path 应放行(next): ' + JSON.stringify(r3));
|
|
1404
|
+
usedNext = false;
|
|
1405
|
+
const r4 = await preExec(
|
|
1406
|
+
{ name: 'ops_write_file', arguments: { path: path.join(longTarget, 'src', 'idle-ops.md'), content: 'x', expectedRevision: 'absent' }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1407
|
+
() => { usedNext = true; },
|
|
1408
|
+
);
|
|
1409
|
+
if (!usedNext) throw new Error('空闲态 ops_write_file 应放行(next): ' + JSON.stringify(r4));
|
|
1410
|
+
usedNext = false;
|
|
1411
|
+
const outsideWorkdir = path.join(dir, 'k12-workdir-out');
|
|
1412
|
+
fs.mkdirSync(outsideWorkdir, { recursive: true });
|
|
1413
|
+
const r5 = await preExec(
|
|
1414
|
+
{ name: 'ops_bash', arguments: { command: 'printf x > y', workdir: outsideWorkdir }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1415
|
+
() => { usedNext = true; },
|
|
1416
|
+
);
|
|
1417
|
+
if (!usedNext) throw new Error('空闲态 ops_bash workdir 在项目外应放行(next): ' + JSON.stringify(r5));
|
|
1418
|
+
usedNext = false;
|
|
1419
|
+
const r6 = await preExec(
|
|
1420
|
+
{ name: 'run_code', arguments: { code: 'const fs = await import("node:fs"); fs.writeFileSync("x","y");', description: 'ptc idle' }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1421
|
+
() => { usedNext = true; },
|
|
1422
|
+
);
|
|
1423
|
+
if (!usedNext) throw new Error('空闲态 run_code 直写应放行(next): ' + JSON.stringify(r6));
|
|
1424
|
+
}
|
|
1082
1425
|
// AC-7 解析失败:state 写成非法 JSON + 项目外 Write → deny(reason 含 fail-closed 拒绝语义;
|
|
1083
1426
|
// 当前无条件 deny 已通过、T02 流程态门落地后必须保持 deny,不得当空闲放行)
|
|
1084
1427
|
{
|
|
@@ -1089,6 +1432,17 @@ const RAW_ENTRIES = [
|
|
|
1089
1432
|
if (!r || r.kind !== 'deny') throw new Error('AC-7 非法 JSON 应 deny: ' + JSON.stringify(r));
|
|
1090
1433
|
if (!r.reason.includes('拒绝')) throw new Error('AC-7 deny 应含 fail-closed(拒绝)语义: ' + JSON.stringify(r.reason));
|
|
1091
1434
|
}
|
|
1435
|
+
// AC-7c 解析失败 + run_code:即使 PTC 默认放行,状态损坏也必须 fail-closed deny
|
|
1436
|
+
{
|
|
1437
|
+
writeFile(target, '.flow-comet/flow-comet-state.json', '{ not-valid-json ');
|
|
1438
|
+
let usedNext = false;
|
|
1439
|
+
const r = await preExec(
|
|
1440
|
+
{ name: 'run_code', arguments: { code: '1', description: 'ptc parse-error' }, agent: { cwd: longTarget, session: { header: {} } } },
|
|
1441
|
+
() => { usedNext = true; },
|
|
1442
|
+
);
|
|
1443
|
+
if (usedNext) throw new Error('AC-7c 非法 JSON 下 run_code 不应 next——必须 fail-closed deny');
|
|
1444
|
+
if (!r || r.kind !== 'deny') throw new Error('AC-7c 非法 JSON 下 run_code 应 deny: ' + JSON.stringify(r));
|
|
1445
|
+
}
|
|
1092
1446
|
// AC-8 未知 status:writeState { activeChange:'x', status:'weird' } + 项目外 Write → deny
|
|
1093
1447
|
// (当前通过、T02 流程态门落地后必须保持 deny,不得当空闲放行)
|
|
1094
1448
|
{
|
|
@@ -1116,7 +1470,7 @@ const RAW_ENTRIES = [
|
|
|
1116
1470
|
if (!usedNext) throw new Error('AC-3b BOM+completed 应放行(next 被调)——BOM 容错: ' + JSON.stringify(r));
|
|
1117
1471
|
if (r) throw new Error('AC-3b BOM+completed 不应返回 deny: ' + JSON.stringify(r));
|
|
1118
1472
|
}
|
|
1119
|
-
console.log(' 流程态门断言:AC-1/2/3 空闲放行·AC-3b BOM 容错·AC-7/8/7b 异常态 fail-closed deny✓');
|
|
1473
|
+
console.log(' 流程态门断言:AC-1/2/3 空闲放行·AC-3b BOM 容错·AC-7/7c/8/7b 异常态 fail-closed deny✓');
|
|
1120
1474
|
},
|
|
1121
1475
|
},
|
|
1122
1476
|
|
|
@@ -8,7 +8,27 @@ import fs from 'fs';
|
|
|
8
8
|
import path from 'path';
|
|
9
9
|
import { execFileSync, spawnSync } from 'child_process';
|
|
10
10
|
import { assertExit, assertNotOut, assertOut, baseState, runGuard, runState, writeFile, writeState } from '../lib/test-helpers.mjs';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
applyDistributionSurface,
|
|
13
|
+
assertBinContract,
|
|
14
|
+
assertInitTokenContract,
|
|
15
|
+
assertInstallerUpgradePathCleanup,
|
|
16
|
+
assertMirrorRootLinkFailClosed,
|
|
17
|
+
assertPackageBoundary,
|
|
18
|
+
assertPackageContextJudgment,
|
|
19
|
+
assertPublishableManifest,
|
|
20
|
+
assertWorkflowContractCheck,
|
|
21
|
+
CHANGE_ID,
|
|
22
|
+
CONTRACT,
|
|
23
|
+
DISTRIBUTION_MARKERS,
|
|
24
|
+
gitInit,
|
|
25
|
+
readStateFile,
|
|
26
|
+
resolvePackageContext,
|
|
27
|
+
SCRIPTS_DIR,
|
|
28
|
+
seedForeignFlowKit,
|
|
29
|
+
writeIntakeArtifacts,
|
|
30
|
+
} from '../lib/system-fixtures.mjs';
|
|
31
|
+
import { writeNodeDeclarationMarkers } from '../lib/test-fixtures.mjs';
|
|
12
32
|
|
|
13
33
|
const RAW_ENTRIES = [
|
|
14
34
|
|
|
@@ -80,6 +100,8 @@ const RAW_ENTRIES = [
|
|
|
80
100
|
assertOut(before, '"stateCurrentNode": "design"'); // 迁移搬移的状态字段原值可读
|
|
81
101
|
// ④ 流程可继续:entry → record → exit 推进到下一节点
|
|
82
102
|
assertExit(installed('workflow-guard.mjs', ['entry', 'design']), 0);
|
|
103
|
+
// 单轨:record 的声明前置门对一切 change 生效——迁移后的项目按真实链路先声明
|
|
104
|
+
assertExit(installed('workflow-state.mjs', ['skill-load', 'design', 'flow-comet-design', '--prompt', 'flow-kit/prompts/2-design.md', '--templates', 'DESIGN.md']), 0);
|
|
83
105
|
assertExit(installed('workflow-state.mjs', ['record', 'design', '{"summary":"design done"}']), 0);
|
|
84
106
|
const exitDesign = installed('workflow-guard.mjs', ['exit', 'design', '--apply']);
|
|
85
107
|
assertExit(exitDesign, 0);
|
|
@@ -246,6 +268,7 @@ const RAW_ENTRIES = [
|
|
|
246
268
|
writeState(dir, st);
|
|
247
269
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', taskAllParallel);
|
|
248
270
|
assertExit(runGuard(['entry', 'execute'], dir), 0);
|
|
271
|
+
writeNodeDeclarationMarkers(dir, 'execute');
|
|
249
272
|
assertExit(runState(['record', 'execute', '{"summary":"no serial tasks","emptyExitApproved":true}'], dir), 0);
|
|
250
273
|
const r = runGuard(['exit', 'execute', '--apply'], dir);
|
|
251
274
|
assertExit(r, 0);
|
|
@@ -401,7 +401,7 @@ export const ENTRIES = [
|
|
|
401
401
|
// ① fail-open 反向控制:段内自然句子「不适用于暗色主题…」不是结构形态 → 仍判前端、缺件 BLOCKED;
|
|
402
402
|
// ② 结构形态(`适用性` 标签的字段值位)→ 可见跳过 + 命中片段回显,且不要求工件与该声明。
|
|
403
403
|
const nfChange = CHANGE_ID + '-nf';
|
|
404
|
-
assertExit(runState(['init', nfChange, '--init-skip'], dir), 0);
|
|
404
|
+
assertExit(runState(['init', nfChange, '--init-skip', '--replace', CHANGE_ID, '--reason', '第二个 change 走跳过半(覆盖闸门显式放行)'], dir), 0);
|
|
405
405
|
assertExit(runState(['skill-load', 'open', 'flow-comet-change', '--prompt', 'flow-kit/prompts/0-change.md', '--templates', 'CHANGE.md,REQUIREMENT.md'], dir), 0);
|
|
406
406
|
// 第二个 change 的 open 同样要覆盖两份协议与两个必需技能(出口覆盖判据按节点核对)
|
|
407
407
|
assertExit(runState(['skill-load', 'open', 'flow-comet-requirement', '--prompt', 'flow-kit/prompts/1-requirement.md', '--templates', 'CHANGE.md,REQUIREMENT.md'], dir), 0);
|
|
@@ -453,7 +453,7 @@ export const ENTRIES = [
|
|
|
453
453
|
const setRes = runState(['config', 'set', 'last_evolve_at', baseline], dir);
|
|
454
454
|
assertExit(setRes, 0);
|
|
455
455
|
assertOut(setRes, 'CONFIG: last_evolve_at = ' + baseline);
|
|
456
|
-
assertExit(runState(['init', CHANGE_ID + '-2', '--init-skip'], dir), 0);
|
|
456
|
+
assertExit(runState(['init', CHANGE_ID + '-2', '--init-skip', '--replace', CHANGE_ID, '--reason', '验证跨 change 保留演化基线'], dir), 0);
|
|
457
457
|
const state = readStateFile(dir);
|
|
458
458
|
assertEqual(state.activeChange, CHANGE_ID + '-2', 'init 后 activeChange');
|
|
459
459
|
assertEqual(state.last_evolve_at, baseline, 'init 跨 change 保留 last_evolve_at');
|
|
@@ -19,9 +19,9 @@ const RAW_ENTRIES = [
|
|
|
19
19
|
|
|
20
20
|
// 声明集合判据 = required ⊆ declared ⊆ required ∪ optional(design 的 required=DESIGN、optional=UI-DESIGN)。
|
|
21
21
|
// 四个负例分别打「多写(允许集外)」「漏写(空清单)」「错名(拼错)」「缺声明(整项没写)」,
|
|
22
|
-
//
|
|
22
|
+
// 四个负例一律 BLOCKED(单一判级)——阻断与「允许集内可选项放行」必须在同一条命令上分开。
|
|
23
23
|
{
|
|
24
|
-
name: 'N1
|
|
24
|
+
name: 'N1 加载链声明集合:多写/漏写/错名/缺声明一律 BLOCKED,允许集内可选项放行',
|
|
25
25
|
run: (dir) => {
|
|
26
26
|
assertExit(runState(['init', CHANGE_ID, '--init-skip'], dir), 0);
|
|
27
27
|
|
|
@@ -83,17 +83,16 @@ const RAW_ENTRIES = [
|
|
|
83
83
|
assertExit(undeclared, 1);
|
|
84
84
|
assertOut(undeclared, '模板声明缺失');
|
|
85
85
|
|
|
86
|
-
// ⑥
|
|
86
|
+
// ⑥ 同一形态(无任何新旧标记字段):同判 BLOCKED(单轨,无渐进放行),且不覆写既有标记
|
|
87
87
|
const legacyState = readStateFile(dir);
|
|
88
|
-
delete legacyState.newChange;
|
|
89
88
|
writeState(dir, legacyState);
|
|
89
|
+
const markerBefore = fs.readFileSync(markerPath, 'utf8');
|
|
90
90
|
const legacy = runState([...DESIGN_SKILL_ARGS, '--templates', 'DESIGN.md,TASK.md'], dir);
|
|
91
|
-
assertExit(legacy,
|
|
92
|
-
assertOut(legacy, '
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
throw new Error('旧 change 的 WARN 路径应照常写标记(记录真实声明),实际: ' + JSON.stringify(legacyMarker));
|
|
91
|
+
assertExit(legacy, 1);
|
|
92
|
+
assertOut(legacy, 'BLOCKED');
|
|
93
|
+
assertOut(legacy, '多写/错名: TASK');
|
|
94
|
+
if (fs.readFileSync(markerPath, 'utf8') !== markerBefore) {
|
|
95
|
+
throw new Error('BLOCK 不得覆写既有声明标记');
|
|
97
96
|
}
|
|
98
97
|
},
|
|
99
98
|
},
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
// 清单**(REQUIREMENT 在场却定位不到验收准则段;验收段在而无任何 AC-N 编号;TEST.md 在场却
|
|
30
30
|
// 定位不到第 1 轮段;第 1 轮段在而段内没有 1.1 矩阵段,即「整段 N/A」);② **change 自己的
|
|
31
31
|
// 载体文件缺席**(REQUIREMENT.md / TEST.md 不在)——这两个文件是这个 change 自己的东西,作者
|
|
32
|
-
//
|
|
33
|
-
//
|
|
32
|
+
// 抬手就能删,删掉它换不到「没有可判对象」。两支同属「不是判过且通过」,调用方按单一判级:
|
|
33
|
+
// 一律 BLOCKED(同一形态一个判级)。删段、删文件因此都不是
|
|
34
34
|
// 关掉判据的写法,出路只有「按模板把段、清单与文件补回来」。
|
|
35
35
|
//
|
|
36
36
|
// 词法:AC-<数字>,大小写不敏感;AC-1a 归并到 AC-1(后缀不参与编号),AC-01 与 AC-1 归一为同一编号;
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
// 围栏外才是台账。段界本身由 sectionBody 跨围栏给出(围栏内的 `## ` 不结束段体),编号扫描再
|
|
41
41
|
// 过一次围栏状态——两件事各管一段:前者决定读多远,后者决定读到的哪些真算数。
|
|
42
42
|
//
|
|
43
|
-
//
|
|
43
|
+
// 判级(违反即 BLOCKED;review 出口只汇总)不在这里判:本模块只产出判定结果与
|
|
44
44
|
// 报文文本,console / exit 只在门禁层(与「纯判定 + 门禁编排」的既有分层一致)。
|
|
45
45
|
import { promises as fs } from 'fs';
|
|
46
46
|
import path from 'path';
|
|
@@ -213,7 +213,7 @@ const UNJUDGEABLE_CAUSES = {
|
|
|
213
213
|
};
|
|
214
214
|
|
|
215
215
|
// 判不了时返回的判定结果形态:两个成因字段互斥,调用方按「模板缺席 → 未校验放行」/「内容不可判 →
|
|
216
|
-
//
|
|
216
|
+
// 单一判级(一律 BLOCKED)」两支处置。
|
|
217
217
|
function unverifiable(reason) {
|
|
218
218
|
const explanation = UNVERIFIED_EXPLANATIONS[reason] ?? reason;
|
|
219
219
|
return {
|
|
@@ -246,7 +246,7 @@ function unjudgeable(reason) {
|
|
|
246
246
|
// · acIds = REQUIREMENT 验收段内的编号(有序去重);
|
|
247
247
|
// · missing = 这些编号里未出现在 1.1 矩阵段文本中的(同样按 REQUIREMENT 顺序);
|
|
248
248
|
// · unverified / unjudgeable = 非 null 表示没判成:前者只剩「模板缺席」(放行),后者是工件
|
|
249
|
-
// 内容不可判——载体文件被删或承载段 /
|
|
249
|
+
// 内容不可判——载体文件被删或承载段 / 清单读不出(内容不可判一律 BLOCKED);两者都为 null 才表示
|
|
250
250
|
// 判据真的判过。
|
|
251
251
|
// 顺序固定:承载段在不在一级(段缺席 = 内容不可判,不是「无可判对象」),再判「有没有编号」,最后判
|
|
252
252
|
// 「矩阵能不能读」——三级「判不了」因此不会互相遮蔽,报文说的是真正卡住的那一环。
|
|
@@ -258,7 +258,7 @@ export async function acCoverageReview(changeDir) {
|
|
|
258
258
|
if (acceptanceMatcher === TEMPLATE_SECTION_SKIP) return unverifiable('模板缺席(段名无从派生)');
|
|
259
259
|
const acceptanceBody = sectionBody(requirementText, acceptanceMatcher, { level: 2, endOnSeparator: false });
|
|
260
260
|
// 承载段缺席 ≠ 载体缺席:REQUIREMENT.md 与模板都在场,缺的是作者自己删掉的段——按内容不可判
|
|
261
|
-
//
|
|
261
|
+
// 判级(一律 BLOCKED),删段因此不是关掉 AC 覆盖判据的写法。
|
|
262
262
|
if (acceptanceBody === null) return unjudgeable('REQUIREMENT 无验收准则段');
|
|
263
263
|
const acIds = parseAcIds(acceptanceBody);
|
|
264
264
|
if (acIds.length === 0) return unjudgeable('REQUIREMENT 无 AC 编号');
|
|
@@ -293,8 +293,8 @@ export function acCoverageReportLines({ coverage, level = 'BLOCKED' }) {
|
|
|
293
293
|
];
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
-
// 「工件内容不可判」的报文(
|
|
297
|
-
//
|
|
296
|
+
// 「工件内容不可判」的报文(BLOCKED / WARN 同一文本,只换分级前缀与末尾的
|
|
297
|
+
// 分级说明——与波次判据同形;单轨下调用方只传 BLOCKED):首行点名是哪一环读不出来,第二行给能照做的恢复出路。WARN 前缀让该行
|
|
298
298
|
// 进入既有 WARN COUNT(「该写的没写」不再静默为「未校验」)。
|
|
299
299
|
export function acCoverageUnjudgeableLines({ coverage, level = 'BLOCKED' }) {
|
|
300
300
|
const blocking = level === 'BLOCKED';
|
|
@@ -49,7 +49,7 @@ export async function readProtocolTaskContent(protocol, changeName, specsRoot) {
|
|
|
49
49
|
|
|
50
50
|
// 「未闭合 execute 生命周期」信号派生:取 history 中最后一次 exit-applied execute 家族事件
|
|
51
51
|
// 记录的 { signature, algo, node };无家族出口事件 / 该事件无签名字段(旧 state)→ null(调用方按
|
|
52
|
-
//
|
|
52
|
+
// 无闭合信号放行)。只认最新一次家族出口——更早的签名被后续闭合覆盖。
|
|
53
53
|
// change 归属过滤经 historyEventBelongsToChange(单一权威)。算法版本:事件可带 signatureAlgo
|
|
54
54
|
// (新写形态),缺省按签名值解析出的版本(legacy 裸 hex = v1);声明版本与值版本不一致的畸形事件
|
|
55
55
|
// → null(fail-closed,不参与闭合判定)。
|
|
@@ -107,8 +107,8 @@ export function classifyFixReturnCause({ history, changeName, taskContent, fixSe
|
|
|
107
107
|
// ---------- Fix 受控归位轮次(单一权威 · 唯一写点) ----------
|
|
108
108
|
// 仅受控归位入口在目标命中后调用本 helper,且只对决策 kind='pending' 计数;done-but-unclosed、
|
|
109
109
|
// 回因分类、verify 命令失败都不经此,也不得在调用方另行累加。
|
|
110
|
-
// 阈值语义:从第 4
|
|
111
|
-
// currentNode
|
|
110
|
+
// 阈值语义:从第 4 轮起返回 blocked(调用方必须先于任何 state 写盘退出,不得写入
|
|
111
|
+
// currentNode)。用户显式授权记录为
|
|
112
112
|
// state.evidence[源节点].fixRoundOverride = { round, at, source },覆盖到该轮即放行(不新增第二个顶层字段)。
|
|
113
113
|
// 完整授权形态:round 为正整数、at/source 均为非空字符串;任一缺失/类型非法/空串(含纯空白)
|
|
114
114
|
// 一律视为未授权 fail-closed——第 4 轮继续 BLOCK,调用方不写 currentNode、state 字节零改写。
|
|
@@ -167,18 +167,7 @@ export function applyFixRollbackRound({ state, sourceNode, decision }) {
|
|
|
167
167
|
setFixRoundsFor(state, round);
|
|
168
168
|
return { ...EMPTY_FIX_ROLLBACK_ROUND, counted: true, round, overrideUsed: true, auditSuffix };
|
|
169
169
|
}
|
|
170
|
-
|
|
171
|
-
return { ...EMPTY_FIX_ROLLBACK_ROUND, blocked: true, round, auditSuffix, blockedMessage: fixRoundBlockedMessage(sourceNode, round) };
|
|
172
|
-
}
|
|
173
|
-
setFixRoundsFor(state, round);
|
|
174
|
-
return {
|
|
175
|
-
...EMPTY_FIX_ROLLBACK_ROUND,
|
|
176
|
-
counted: true,
|
|
177
|
-
warn: true,
|
|
178
|
-
round,
|
|
179
|
-
auditSuffix,
|
|
180
|
-
warnMessage: 'FIX-BATCH WARN: Fix 批次受控归位已达 ' + FIX_ROLLBACK_ROUND_LIMIT + ' 轮上限,第 ' + round + ' 轮在旧 change 上渐进放行(建议用户显式授权并在 evidence 记录 fixRoundOverride)。',
|
|
181
|
-
};
|
|
170
|
+
return { ...EMPTY_FIX_ROLLBACK_ROUND, blocked: true, round, auditSuffix, blockedMessage: fixRoundBlockedMessage(sourceNode, round) };
|
|
182
171
|
}
|
|
183
172
|
|
|
184
173
|
// Fix 回程节点推导(共享基础):TASK.md 存在、至少一个任务块且全部 status="done" 时,
|