openfeel 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.
Files changed (80) hide show
  1. package/README.en.md +7 -0
  2. package/README.zh-CN.md +7 -0
  3. package/dist/commands/dashboard.d.ts.map +1 -1
  4. package/dist/commands/dashboard.js +10 -1
  5. package/dist/commands/dashboard.js.map +1 -1
  6. package/dist/commands/flow.d.ts.map +1 -1
  7. package/dist/commands/flow.js +19 -12
  8. package/dist/commands/flow.js.map +1 -1
  9. package/dist/commands/lint.d.ts +3 -1
  10. package/dist/commands/lint.d.ts.map +1 -1
  11. package/dist/commands/lint.js +279 -2
  12. package/dist/commands/lint.js.map +1 -1
  13. package/dist/commands/req.d.ts.map +1 -1
  14. package/dist/commands/req.js +470 -95
  15. package/dist/commands/req.js.map +1 -1
  16. package/dist/core/adherence.d.ts +135 -0
  17. package/dist/core/adherence.d.ts.map +1 -0
  18. package/dist/core/adherence.js +221 -0
  19. package/dist/core/adherence.js.map +1 -0
  20. package/dist/core/dashboard/aggregate.d.ts +39 -0
  21. package/dist/core/dashboard/aggregate.d.ts.map +1 -1
  22. package/dist/core/dashboard/aggregate.js +64 -5
  23. package/dist/core/dashboard/aggregate.js.map +1 -1
  24. package/dist/core/dashboard/render.d.ts.map +1 -1
  25. package/dist/core/dashboard/render.js +88 -1
  26. package/dist/core/dashboard/render.js.map +1 -1
  27. package/dist/core/errors.d.ts +27 -2
  28. package/dist/core/errors.d.ts.map +1 -1
  29. package/dist/core/errors.js +15 -2
  30. package/dist/core/errors.js.map +1 -1
  31. package/dist/core/flow/gate-override.d.ts +72 -0
  32. package/dist/core/flow/gate-override.d.ts.map +1 -0
  33. package/dist/core/flow/gate-override.js +71 -0
  34. package/dist/core/flow/gate-override.js.map +1 -0
  35. package/dist/core/flow-manager.d.ts +13 -4
  36. package/dist/core/flow-manager.d.ts.map +1 -1
  37. package/dist/core/flow-manager.js +47 -16
  38. package/dist/core/flow-manager.js.map +1 -1
  39. package/dist/core/i18n-data/en.d.ts.map +1 -1
  40. package/dist/core/i18n-data/en.js +45 -6
  41. package/dist/core/i18n-data/en.js.map +1 -1
  42. package/dist/core/i18n-data/zh-CN.d.ts.map +1 -1
  43. package/dist/core/i18n-data/zh-CN.js +45 -6
  44. package/dist/core/i18n-data/zh-CN.js.map +1 -1
  45. package/dist/core/req/body-file.d.ts +37 -0
  46. package/dist/core/req/body-file.d.ts.map +1 -1
  47. package/dist/core/req/body-file.js +39 -2
  48. package/dist/core/req/body-file.js.map +1 -1
  49. package/dist/core/req/plan-file.d.ts +83 -0
  50. package/dist/core/req/plan-file.d.ts.map +1 -0
  51. package/dist/core/req/plan-file.js +205 -0
  52. package/dist/core/req/plan-file.js.map +1 -0
  53. package/dist/core/req/requirement-ops.d.ts +25 -3
  54. package/dist/core/req/requirement-ops.d.ts.map +1 -1
  55. package/dist/core/req/requirement-ops.js +66 -11
  56. package/dist/core/req/requirement-ops.js.map +1 -1
  57. package/dist/core/req/types.d.ts +8 -2
  58. package/dist/core/req/types.d.ts.map +1 -1
  59. package/dist/core/req/types.js +10 -2
  60. package/dist/core/req/types.js.map +1 -1
  61. package/dist/core/template-loader.d.ts.map +1 -1
  62. package/dist/core/template-loader.js +12 -0
  63. package/dist/core/template-loader.js.map +1 -1
  64. package/dist/core/templates.d.ts +1 -1
  65. package/dist/core/templates.d.ts.map +1 -1
  66. package/dist/core/templates.js +18 -0
  67. package/dist/core/templates.js.map +1 -1
  68. package/dsh/ACTION-GUIDE.md +15 -6
  69. package/dsh/ADAPTER.md +62 -1
  70. package/dsh/README.md +13 -11
  71. package/dsh/docs/compat/persistence.md +13 -0
  72. package/dsh/docs/compat/pipeline.md +12 -0
  73. package/dsh/docs/compat/req.md +15 -0
  74. package/dsh/docs/compat/stage.md +12 -0
  75. package/dsh/lib/adapters/dispatch-ledger.js +149 -10
  76. package/dsh/lib/guard.js +685 -22
  77. package/dsh/lib/surface/prompt.js +4 -0
  78. package/dsh/lib/tools/index.js +113 -22
  79. package/dsh/package.json +2 -2
  80. package/package.json +2 -1
@@ -32,6 +32,8 @@ import { stageRequirementIds } from './req/stage-links.js'; // 阶段↔需求
32
32
  import { getSessionId } from './session.js'; // 会话标识(stage-86 T4;core→core 零环)
33
33
  import { shouldAutoCommit } from './dev/sessions.js'; // 多会话登记 / 自动提交防污染(v1.5.8 / REQ-029)
34
34
  import { maybeSyncDevStatus } from './dev-status.js'; // 开发账本自动同步(v1.6.0 / REQ-059 T8;core→core 零环)
35
+ import { normalizeGateOverride, buildGateOverrideAudit } from './flow/gate-override.js'; // 留痕放行统一审计(v1.6.1 / REQ-062 A62.2—A62.4)
36
+ export { buildGateOverrideAudit, createGateOverride, normalizeGateOverride } from './flow/gate-override.js';
35
37
  /** flow.json.log 保留上限(v1.5.0 日志瘦身:只留简要操作记录) */
36
38
  export const MAX_LOG_ENTRIES = 200;
37
39
  /** flow.json 乐观并发冲突:磁盘 revision 与本次加载时不一致(存在并发写入) */
@@ -1374,8 +1376,10 @@ export class FlowManager {
1374
1376
  * @param triggeredBy 触发者标识(如 'cli' / 'Feel'),默认 'flow-manager'
1375
1377
  * @param opts.reviewTier 本次调用的审查档位(**仅显式声明时写审计键** `review_tier`;缺省不写 ⟹ 既有条目逐字不变)
1376
1378
  * @param opts.reworkReason 审查通过后返工的整改原因(v1.3.3;仅写审计键 `rework_reason`,不参与状态机判定)
1377
- * @param opts.allowGateOverride 计划门留痕放行(v1.6.0 / REQ-056;**仅** `flow advance --force` 显式传入;
1378
- * 缺省 false = 拒绝。`--force` 的相位合法性跳过与此开关是两件事,此处不看 `--force` 本身)
1379
+ * @param opts.gateOverride 留痕放行的统一记录(v1.6.1 / REQ-062 A62.2;**仅**门被拦后显式传入;
1380
+ * 缺省 = 拒绝。`gates` 会与本次实际触发的门取并集,`from`/`to` 由本方法按实际转换补全)
1381
+ * @param opts.allowGateOverride 兼容别名(v1.6.0 / REQ-056 旧调用点;内部归一为缺省 reason 的
1382
+ * GateOverride。新代码请用 `gateOverride`。`--force` 的相位合法性跳过与此开关是两件事,此处不看 `--force` 本身)
1379
1383
  * @returns 是否触发 done 归档(true = 本次推进将阶段变为 done 且之前非 done,需在 save 后执行归档 commit)
1380
1384
  */
1381
1385
  advanceStagePhase(stageName, phase, triggeredBy, opts) {
@@ -1383,6 +1387,9 @@ export class FlowManager {
1383
1387
  return false;
1384
1388
  }
1385
1389
  const actualTrigger = triggeredBy ?? 'flow-manager';
1390
+ // v1.6.1 / REQ-062 A62.2:统一入口 —— 新名 `gateOverride` 与旧别名 `allowGateOverride` 在此归一,
1391
+ // 门判定只看这一个布尔(不再在多个 if 里各认一套开关)。
1392
+ const allowGateOverride = opts?.gateOverride !== undefined || opts?.allowGateOverride === true;
1386
1393
  // 校验 stageName 存在
1387
1394
  // REV-005:归一化 stageId(短名 → 全名);此后函数体内一律使用 key(防半归一化)
1388
1395
  // 双键回退:兼容以短名建键的存量 / 测试数据(归一化键不存在时回退原始键)
@@ -1421,8 +1428,8 @@ export class FlowManager {
1421
1428
  }
1422
1429
  // 保存旧 phase 用于日志
1423
1430
  const fromPhase = stage.phase;
1424
- // 门留痕收集(v1.6.0):仅在被拦后显式 `allowGateOverride` 放行时写入
1425
- // `appendLog.detail.gate_overrides`;正常通过路径零新增键(既有条目字节级不变)。
1431
+ // 门留痕收集(v1.6.0;v1.6.1 / REQ-062 A62.2 起统一写入 GateOverride 审计键集):
1432
+ // 仅在被拦后显式留痕放行时写入 `appendLog.detail`;正常通过路径零新增键(既有条目字节级不变)。
1426
1433
  const gateOverrides = [];
1427
1434
  // v1.5.8 / REQ-027「完成必审验」硬门:**进入** done 要求
1428
1435
  // ① 阶段验证记录 result === 'pass';② 关联需求全部 done(零关联放行——空集守卫)。
@@ -1443,7 +1450,7 @@ export class FlowManager {
1443
1450
  if (targetPhase === 'done' && fromPhase !== 'done') {
1444
1451
  const sync = maybeSyncDevStatus(this.projectPath);
1445
1452
  if (sync.due) {
1446
- if (opts?.allowGateOverride !== true) {
1453
+ if (!allowGateOverride) {
1447
1454
  throw new DevSyncStaleError(key, sync.error ?? null, this.formatDevSyncStale(key, sync.error ?? null));
1448
1455
  }
1449
1456
  gateOverrides.push('dev_sync');
@@ -1467,7 +1474,7 @@ export class FlowManager {
1467
1474
  if (crossesExecRunning(fromPhase, targetPhase)) {
1468
1475
  const planGate = this.describeStagePlanGate(key);
1469
1476
  if (isStagePlanGateBlocked(planGate)) {
1470
- if (opts?.allowGateOverride !== true) {
1477
+ if (!allowGateOverride) {
1471
1478
  throw new StagePlanGateError(key, planGate, this.formatStagePlanGate(key, planGate));
1472
1479
  }
1473
1480
  planGateOverride = planGate;
@@ -1514,6 +1521,16 @@ export class FlowManager {
1514
1521
  // 计算在 appendLog 之前 → 回扫天然排除本次条目
1515
1522
  const sessionId = getSessionId({ projectPath: this.projectPath });
1516
1523
  const resumed = this.computeResumed(this.data.log, key, fromPhase, sessionId);
1524
+ // v1.6.1 / REQ-062 A62.2:审计键集唯一构造点(helper)。仅当本次确有门被留痕放行才写,
1525
+ // 拒绝路径在上方抛错(零写盘零审计),放行但门正常通过时同样零新增键。
1526
+ const gateAudit = gateOverrides.length === 0
1527
+ ? null
1528
+ : buildGateOverrideAudit(normalizeGateOverride(opts?.gateOverride, {
1529
+ gates: gateOverrides,
1530
+ by: actualTrigger,
1531
+ from: fromPhase,
1532
+ to: targetPhase,
1533
+ }), planGateOverride);
1517
1534
  // 追加日志(使用实际触发者名,而非硬编码 'flow-manager')
1518
1535
  // 审查档位留痕(stage-92 D-92-4):review_tier **仅显式声明时**追加(既有键逐字保留,缺省条目字节级不变)
1519
1536
  this.appendLog({
@@ -1525,12 +1542,10 @@ export class FlowManager {
1525
1542
  ...(resumed === null ? {} : { resumed }),
1526
1543
  ...(opts?.reviewTier === undefined ? {} : { review_tier: opts.reviewTier }),
1527
1544
  ...(opts?.reworkReason === undefined ? {} : { rework_reason: opts.reworkReason }),
1528
- // v1.6.0 / REQ-056 T5 + REQ-059 T8:门留痕放行(仅在被拦后显式放行时写;
1529
- // 正常通过零新增键)。`gate_missing` 快照仅计划门有结构化缺项,账本门原因在 error.detail。
1530
- ...(gateOverrides.length === 0 ? {} : {
1531
- gate_overrides: gateOverrides,
1532
- ...(planGateOverride === null ? {} : { gate_missing: planGateOverride }),
1533
- }),
1545
+ // v1.6.0 / REQ-056 T5 + REQ-059 T8;v1.6.1 / REQ-062 A62.2:门留痕放行统一由
1546
+ // buildGateOverrideAudit 构造(含 from/to/by/reason/at;gate_missing 仅计划门有结构化缺项)。
1547
+ // 正常通过零新增键(既有条目字节级不变)。
1548
+ ...(gateAudit === null ? {} : gateAudit),
1534
1549
  },
1535
1550
  });
1536
1551
  // REV-003: advance_stage_phase 改为 endStage 时批量聚合,取消逐条写入
@@ -1854,8 +1869,10 @@ export class FlowManager {
1854
1869
  * @param stageName 阶段 ID(短名/全名)
1855
1870
  * @param to 目标 phase 字符串
1856
1871
  * @param options.dryRun 仅计算不修改内存(命令层不 save)
1857
- * @param options.allowGateOverride 计划门留痕放行(v1.6.0 / REQ-056;**仅** `flow stage reset --force`
1858
- * 显式传入;缺省 false = 拒绝,闭合「复位绕过 exec 门」的后门)
1872
+ * @param options.gateOverride 留痕放行的统一记录(v1.6.1 / REQ-062 A62.2—A62.3;**仅** `flow stage reset --force`
1873
+ * 显式传入;缺省 = 拒绝,闭合「复位绕过 exec 门」的后门。`from`/`to`/`gates` 由本方法按实际转换补全)
1874
+ * @param options.allowGateOverride 兼容别名(v1.6.0 / REQ-056 旧调用点;内部归一为缺省 reason 的
1875
+ * GateOverride;新代码请用 `gateOverride`)
1859
1876
  * @returns 复位结果(from/to/status/changed)
1860
1877
  */
1861
1878
  resetStagePhase(stageName, to, options = {}) {
@@ -1890,16 +1907,20 @@ export class FlowManager {
1890
1907
  }
1891
1908
  // 幂等:phase 与投影 status 均无变化 → no-op(dryRun 与真实路径一致)
1892
1909
  const changed = fromPhase !== targetPhase || stage.status !== projectedStatus;
1910
+ // v1.6.1 / REQ-062 A62.2:与 advanceStagePhase 同一套归一(新名 + 兼容别名)。
1911
+ const allowGateOverride = options.gateOverride !== undefined || options.allowGateOverride === true;
1893
1912
  // v1.6.0 / REQ-056 T5:复位到 exec_running 必须与 exec 门同口径复检计划(否则复位就是绕过口)。
1894
1913
  // 位置:REV 阻塞检查之后、任何内存写入之前(拒绝路径零变更零审计);幂等(from === to)自然不触发。
1914
+ const gateOverrides = [];
1895
1915
  let planGateOverride = null;
1896
1916
  if (targetPhase === 'exec_running' && fromPhase !== 'exec_running') {
1897
1917
  const planGate = this.describeStagePlanGate(key);
1898
1918
  if (isStagePlanGateBlocked(planGate)) {
1899
- if (options.allowGateOverride !== true) {
1919
+ if (!allowGateOverride) {
1900
1920
  throw new StagePlanGateError(key, planGate, this.formatStagePlanGate(key, planGate));
1901
1921
  }
1902
1922
  planGateOverride = planGate;
1923
+ gateOverrides.push('plan');
1903
1924
  }
1904
1925
  }
1905
1926
  if (options.dryRun || !changed) {
@@ -1918,11 +1939,21 @@ export class FlowManager {
1918
1939
  // T4:跨会话恢复标注(与 advanceStagePhase 同款;计算在 appendLog 之前)
1919
1940
  const resetSessionId = getSessionId({ projectPath: this.projectPath });
1920
1941
  const resetResumed = this.computeResumed(this.data.log, key, fromPhase, resetSessionId);
1942
+ // v1.6.1 / REQ-062 A62.2—A62.3:`reset --to <后置相> --force` 与 advance 写同一审计键集
1943
+ // (含 from/to/by/reason/at);无 override 条目时不写任何审计键(零伪造审计)。
1944
+ const resetGateAudit = gateOverrides.length === 0
1945
+ ? null
1946
+ : buildGateOverrideAudit(normalizeGateOverride(options.gateOverride, {
1947
+ gates: gateOverrides,
1948
+ by: 'flow-manager',
1949
+ from: fromPhase,
1950
+ to: targetPhase,
1951
+ }), planGateOverride);
1921
1952
  this.appendLog({
1922
1953
  time: '',
1923
1954
  agent: 'flow-manager',
1924
1955
  action: 'reset_stage_phase',
1925
- detail: { stageName: key, from: fromPhase, to: targetPhase, session_id: resetSessionId, ...(resetResumed === null ? {} : { resumed: resetResumed }), ...(planGateOverride === null ? {} : { gate_overrides: ['plan'], gate_missing: planGateOverride }) },
1956
+ detail: { stageName: key, from: fromPhase, to: targetPhase, session_id: resetSessionId, ...(resetResumed === null ? {} : { resumed: resetResumed }), ...(resetGateAudit === null ? {} : resetGateAudit) },
1926
1957
  });
1927
1958
  // 需求聚合对称回退(T2):聚合视图重算——聚合 ≠ done ∧ 需求 status === done → 回退 in_progress;
1928
1959
  // 纯内存;dryRun / no-op 已在 :1585 早退(本点不可达);不新增写盘点。