fault-matrix-cells.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * 故障矩阵的快 / 全两档(apps/zcode-cli/packages/dynamic-workflow/docs/execution-engine.md「Verification」)。
  3. *
  4. * 缺省只跑快档(每行至少一格,默认套件与 CI);`ZCODE_FAULT_MATRIX=full` 展开成 spec 矩阵表
  5. * 的全部格(`pnpm test:fault-matrix`)。两档共用同一组测试文件、同一张格表,只是列表长短不同。
  6. */
  7. import type { WireFormat } from "./fake-provider-server.js";
  8. import type { ScriptShape } from "./fault-matrix-scripts.js";
  9. const FAULT_MATRIX_FULL: boolean = process.env.ZCODE_FAULT_MATRIX === "full";
  10. /** 一格的坐标:形状 + wire 格式(缺省 Anthropic,spec 的主格式)。 */
  11. export interface CellCoordinate {
  12. shape: ScriptShape;
  13. apiFormat?: WireFormat;
  14. }
  15. /** 快档的格 + 全档才有的格;全档 = 两者并集。 */
  16. export function cells(quick: CellCoordinate[], fullOnly: CellCoordinate[] = []): CellCoordinate[] {
  17. return FAULT_MATRIX_FULL ? [...quick, ...fullOnly] : quick;
  18. }
  19. /** `it.each` 的标题用:`W4/anthropic-messages`。 */
  20. export function cellName(cell: CellCoordinate): string {
  21. return `${cell.shape}/${cell.apiFormat ?? "anthropic-messages"}`;
  22. }
  23. /** 每格 `it` 的超时:沙箱子进程 + 重试曲线;spec 的 8 s 是目标,这里给缓冲免得 CI 抖动。 */
  24. export const CELL_TIMEOUT_MS = 30_000;
  25. /** 结算之后再等这么久复查「零请求」(spec 不变式 5)。 */
  26. export const POST_SETTLE_GRACE_MS = 200;