peaks-loop 4.0.0-beta.12 → 4.0.0-beta.15

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 (212) hide show
  1. package/CHANGELOG.md +282 -147
  2. package/README-en.md +1 -1
  3. package/README.md +32 -1
  4. package/bin/peaks.js +0 -0
  5. package/dist/cli/cli-helpers.d.ts +1 -1
  6. package/dist/cli/cli-helpers.js +1 -1
  7. package/dist/cli/commands/adapter-commands-s2a.js +1 -1
  8. package/dist/cli/commands/asset-commands.js +33 -16
  9. package/dist/cli/commands/audit-commands.js +1 -1
  10. package/dist/cli/commands/bee-commands.js +1 -1
  11. package/dist/cli/commands/capability-commands.js +1 -1
  12. package/dist/cli/commands/classify-classify-commands.js +1 -1
  13. package/dist/cli/commands/code-commands.js +1 -1
  14. package/dist/cli/commands/code-review-commands.js +1 -1
  15. package/dist/cli/commands/codegraph-commands.js +1 -1
  16. package/dist/cli/commands/compact-command.js +1 -1
  17. package/dist/cli/commands/complexity-commands.js +1 -1
  18. package/dist/cli/commands/config-commands.js +1 -1
  19. package/dist/cli/commands/context-commands.js +1 -1
  20. package/dist/cli/commands/contract-commands.js +1 -1
  21. package/dist/cli/commands/core/artifacts-command.js +1 -1
  22. package/dist/cli/commands/core/binding-commands.js +1 -1
  23. package/dist/cli/commands/core/doctor-command.js +63 -3
  24. package/dist/cli/commands/core/memory-command.js +1 -1
  25. package/dist/cli/commands/core/profile-command.js +1 -1
  26. package/dist/cli/commands/core/proxy-command.js +1 -1
  27. package/dist/cli/commands/core/session-command.js +1 -1
  28. package/dist/cli/commands/core/skill-command.js +2 -2
  29. package/dist/cli/commands/core/standards-command.js +1 -1
  30. package/dist/cli/commands/dispatch-commands.js +2 -2
  31. package/dist/cli/commands/dispatch-from-dag.js +1 -1
  32. package/dist/cli/commands/doc-commands.js +1 -1
  33. package/dist/cli/commands/ecc-commands.js +2 -2
  34. package/dist/cli/commands/evolution-commands.js +1 -1
  35. package/dist/cli/commands/feedback-commands.js +1 -1
  36. package/dist/cli/commands/final-review-commands.js +1 -1
  37. package/dist/cli/commands/fixture-commands.js +1 -1
  38. package/dist/cli/commands/fork-commands.js +1 -1
  39. package/dist/cli/commands/gate-commands.js +1 -1
  40. package/dist/cli/commands/heartbeat-commands.js +1 -1
  41. package/dist/cli/commands/hook-handle.js +1 -1
  42. package/dist/cli/commands/hooks-commands.js +1 -1
  43. package/dist/cli/commands/ide-commands.js +1 -1
  44. package/dist/cli/commands/impact-commands.js +1 -1
  45. package/dist/cli/commands/job-commands.js +1 -1
  46. package/dist/cli/commands/legacy-commands.js +1 -1
  47. package/dist/cli/commands/log-commands.js +1 -1
  48. package/dist/cli/commands/loop-commands.js +1 -1
  49. package/dist/cli/commands/loop-eval-commands.js +1 -1
  50. package/dist/cli/commands/memory-commands.js +1 -1
  51. package/dist/cli/commands/migrate-1-4-1-command.js +1 -1
  52. package/dist/cli/commands/migrate-v2-10-to-v2-11-command.js +1 -1
  53. package/dist/cli/commands/mut-commands.d.ts +1 -1
  54. package/dist/cli/commands/mut-commands.js +1 -5
  55. package/dist/cli/commands/observability-commands.js +1 -1
  56. package/dist/cli/commands/openspec-commands.js +2 -2
  57. package/dist/cli/commands/perf-audit-commands.js +2 -2
  58. package/dist/cli/commands/perf-commands.js +1 -1
  59. package/dist/cli/commands/polyrepo-commands.js +1 -1
  60. package/dist/cli/commands/prd-blocks-commands.js +1 -1
  61. package/dist/cli/commands/prd-commands.js +1 -1
  62. package/dist/cli/commands/project-commands.js +1 -1
  63. package/dist/cli/commands/qa-business-review-commands.js +1 -1
  64. package/dist/cli/commands/qa-commands.d.ts +1 -1
  65. package/dist/cli/commands/qa-commands.js +2 -2
  66. package/dist/cli/commands/release-commands.js +1 -1
  67. package/dist/cli/commands/request-commands.js +1 -1
  68. package/dist/cli/commands/retrospective-commands.js +1 -1
  69. package/dist/cli/commands/reviewer-commands.js +1 -1
  70. package/dist/cli/commands/role-commands.js +1 -1
  71. package/dist/cli/commands/runtime-commands.js +1 -2
  72. package/dist/cli/commands/sc-commands.js +1 -1
  73. package/dist/cli/commands/scan-commands.js +1 -1
  74. package/dist/cli/commands/security-audit-commands.js +2 -2
  75. package/dist/cli/commands/sediment-commands.js +10 -1
  76. package/dist/cli/commands/share-commands.d.ts +19 -0
  77. package/dist/cli/commands/share-commands.js +121 -2
  78. package/dist/cli/commands/skill-conformance-commands.js +1 -1
  79. package/dist/cli/commands/skill-loop-engineering-readiness-commands.js +1 -1
  80. package/dist/cli/commands/skill-search-commands.js +1 -1
  81. package/dist/cli/commands/slice-commands.js +1 -1
  82. package/dist/cli/commands/slice-integrate-commands.js +1 -1
  83. package/dist/cli/commands/slice-review-commands.js +1 -1
  84. package/dist/cli/commands/smoke-commands.js +1 -1
  85. package/dist/cli/commands/sop-commands.js +1 -1
  86. package/dist/cli/commands/statusline-commands.js +1 -1
  87. package/dist/cli/commands/sub-agent-commands.js +2 -1
  88. package/dist/cli/commands/understand-commands.js +1 -1
  89. package/dist/cli/commands/upgrade-commands.js +1 -1
  90. package/dist/cli/commands/user-touchpoint-commands.js +1 -1
  91. package/dist/cli/commands/verdict-aggregate-command.js +1 -1
  92. package/dist/cli/commands/workflow-commands.js +1 -1
  93. package/dist/cli/commands/workflow-plan-commands.js +1 -1
  94. package/dist/cli/commands/workspace/init-command.js +1 -1
  95. package/dist/cli/commands/workspace/migrate-command.js +1 -1
  96. package/dist/cli/commands/workspace/reconcile-command.js +1 -1
  97. package/dist/cli/index.js +1 -1
  98. package/dist/cli/program.js +2 -2
  99. package/dist/services/artifacts/artifact-prerequisites.js +1 -1
  100. package/dist/services/artifacts/request-artifact-service.js +1 -1
  101. package/dist/services/artifacts/workspace-service.js +1 -1
  102. package/dist/services/code/auto-compact-orchestrator.js +5 -2
  103. package/dist/services/code-review/ocr-service.d.ts +1 -1
  104. package/dist/services/code-review/ocr-service.js +6 -3
  105. package/dist/services/config/config-types.js +1 -1
  106. package/dist/services/dashboard/project-dashboard-service.js +2 -2
  107. package/dist/services/dispatch/batch-counter.js +1 -1
  108. package/dist/services/dispatch/dispatch-record-writer.js +1 -1
  109. package/dist/services/job/job-progress-store.d.ts +2 -2
  110. package/dist/services/job/job-types.d.ts +27 -27
  111. package/dist/services/log/retention.js +1 -1
  112. package/dist/services/openspec/openspec-archive-service.js +1 -1
  113. package/dist/services/openspec/openspec-bridge-service.js +1 -1
  114. package/dist/services/openspec/openspec-init-service.js +1 -1
  115. package/dist/services/openspec/openspec-propose-from-doctor-service.js +1 -1
  116. package/dist/services/openspec/openspec-render-service.js +1 -1
  117. package/dist/services/openspec/openspec-scan-service.js +1 -1
  118. package/dist/services/openspec/openspec-validate-service.js +1 -1
  119. package/dist/services/scan/acceptance-coverage-service.js +1 -1
  120. package/dist/services/scan/archetype-service.js +1 -1
  121. package/dist/services/scan/existing-system-service.js +1 -1
  122. package/dist/services/scan/libraries-service.js +1 -1
  123. package/dist/services/skill/skill-search-service.d.ts +5 -5
  124. package/dist/services/skill/skill-search-service.js +2 -2
  125. package/dist/services/skillhub/migrations/001-initial.sql +71 -0
  126. package/dist/services/skillhub/migrations/002-loop-release.sql +32 -0
  127. package/dist/services/skillhub/migrations/003-loop-bee-relation.sql +35 -0
  128. package/dist/services/skillhub/migrations/004-loop-bee-extension.sql +65 -0
  129. package/dist/services/skillhub/migrations/005-evolution-evaluation.sql +81 -0
  130. package/dist/services/skillhub/migrations/006-crystallization-event.sql +92 -0
  131. package/dist/services/skills/skill-registry.js +2 -2
  132. package/dist/services/skills/skill-runbook-service.js +1 -1
  133. package/dist/services/slice/slice-check-service.js +1 -1
  134. package/dist/services/understand/understand-hybrid-service.js +1 -1
  135. package/dist/services/understand/understand-scan-service.js +2 -2
  136. package/dist/services/upgrade/upgrade-service.js +4 -3
  137. package/dist/services/verdict/envelopes.d.ts +2 -2
  138. package/dist/services/verdict/envelopes.js +2 -2
  139. package/dist/services/verdict/verdict-aggregator.d.ts +3 -3
  140. package/dist/services/workflow/autonomous-resume-writer.js +1 -1
  141. package/dist/services/workflow/plan-reader.d.ts +1 -1
  142. package/dist/services/workflow/plan-reader.js +1 -1
  143. package/dist/services/workflow/plan-refresher.d.ts +1 -1
  144. package/dist/services/workflow/plan-refresher.js +1 -1
  145. package/dist/services/workflow/plan-trigger-detector.d.ts +1 -1
  146. package/dist/services/workflow/plan-trigger-detector.js +1 -1
  147. package/dist/services/workflow/workflow-router-service.js +11 -9
  148. package/dist/services/workspace/migrate-service.js +1 -1
  149. package/dist/services/workspace/workspace-service.js +1 -1
  150. package/package.json +14 -8
  151. package/scripts/copy-templates.mjs +16 -0
  152. package/scripts/sync-version.mjs +8 -1
  153. package/skills/bee/peaks-rd/SKILL.md +14 -1
  154. package/skills/peaks-code/SKILL.md +44 -0
  155. package/skills/peaks-code/references/sub-agent-dispatch.md +30 -0
  156. package/dist/services/agent/ecc-cache-service.d.ts +0 -97
  157. package/dist/services/agent/ecc-cache-service.js +0 -491
  158. package/dist/services/audit-independent/perf-audit-service.d.ts +0 -151
  159. package/dist/services/audit-independent/perf-audit-service.js +0 -316
  160. package/dist/services/audit-independent/security-audit-service.d.ts +0 -155
  161. package/dist/services/audit-independent/security-audit-service.js +0 -316
  162. package/dist/services/context/dispatch-context-guard.d.ts +0 -27
  163. package/dist/services/context/dispatch-context-guard.js +0 -192
  164. package/dist/services/context/shared-channel.d.ts +0 -93
  165. package/dist/services/context/shared-channel.js +0 -308
  166. package/dist/services/crystallization/crystallization-service.d.ts +0 -239
  167. package/dist/services/crystallization/crystallization-service.js +0 -397
  168. package/dist/services/crystallization/crystallization-store.d.ts +0 -75
  169. package/dist/services/crystallization/crystallization-store.js +0 -193
  170. package/dist/services/crystallization/crystallization-types.d.ts +0 -313
  171. package/dist/services/crystallization/crystallization-types.js +0 -299
  172. package/dist/services/crystallization/evidence-brief-builder.d.ts +0 -237
  173. package/dist/services/crystallization/evidence-brief-builder.js +0 -240
  174. package/dist/services/doctor/doctor-service.d.ts +0 -149
  175. package/dist/services/doctor/doctor-service.js +0 -929
  176. package/dist/services/filesystem/file-lock.d.ts +0 -11
  177. package/dist/services/filesystem/file-lock.js +0 -152
  178. package/dist/services/final-review/final-review-service.d.ts +0 -12
  179. package/dist/services/final-review/final-review-service.js +0 -52
  180. package/dist/services/final-review/final-review-types.d.ts +0 -42
  181. package/dist/services/final-review/final-review-types.js +0 -18
  182. package/dist/services/job/job-resource-snapshot.d.ts +0 -7
  183. package/dist/services/job/job-resource-snapshot.js +0 -75
  184. package/dist/services/mut/assert-scanner.d.ts +0 -6
  185. package/dist/services/mut/assert-scanner.js +0 -116
  186. package/dist/services/mut/index.d.ts +0 -8
  187. package/dist/services/mut/index.js +0 -7
  188. package/dist/services/mut/mut-runner.d.ts +0 -39
  189. package/dist/services/mut/mut-runner.js +0 -29
  190. package/dist/services/mut/production-stryker.d.ts +0 -2
  191. package/dist/services/mut/production-stryker.js +0 -75
  192. package/dist/services/mut/report-builder.d.ts +0 -11
  193. package/dist/services/mut/report-builder.js +0 -110
  194. package/dist/services/mut/report-loader.d.ts +0 -31
  195. package/dist/services/mut/report-loader.js +0 -78
  196. package/dist/services/mut/thresholds.d.ts +0 -21
  197. package/dist/services/mut/thresholds.js +0 -22
  198. package/dist/services/mut/types.d.ts +0 -336
  199. package/dist/services/mut/types.js +0 -59
  200. package/dist/shared/fs.d.ts +0 -4
  201. package/dist/shared/fs.js +0 -26
  202. package/dist/shared/paths.d.ts +0 -6
  203. package/dist/shared/paths.js +0 -50
  204. package/dist/shared/result.d.ts +0 -22
  205. package/dist/shared/result.js +0 -46
  206. package/dist/shared/version.d.ts +0 -1
  207. package/dist/shared/version.js +0 -1
  208. package/examples/video-demo/README.md +0 -142
  209. package/examples/video-demo/out/en-closing-960.png +0 -0
  210. package/examples/video-demo/out/zh-closing-960.png +0 -0
  211. package/examples/video-demo/preview/peaks-loop-demo-en.mp4 +0 -0
  212. package/examples/video-demo/preview/peaks-loop-demo.mp4 +0 -0
@@ -1,11 +0,0 @@
1
- import { type AssertionsReport, type MutationReport, type MutReportJson } from './types.js';
2
- import { type Thresholds } from './thresholds.js';
3
- export interface BuildMutInput {
4
- readonly mutation: MutationReport;
5
- readonly assertions: AssertionsReport;
6
- readonly inputSig: string;
7
- readonly out: string;
8
- readonly thresholds?: Thresholds;
9
- readonly now?: () => Date;
10
- }
11
- export declare function buildMutReport(input: BuildMutInput): Promise<MutReportJson>;
@@ -1,110 +0,0 @@
1
- /**
2
- * Combines MutationReport + AssertionsReport into MutReportJson, computes
3
- * thresholds, derives followups, computes MUT.sig, writes file atomically.
4
- *
5
- * Hard constraints:
6
- * H8 (audit trail hashable): MUT.sig is sha256 of normalized content;
7
- * generatedAt + sha256 are excluded from the digest to make the
8
- * signature deterministic across runs.
9
- * H6 (CLI裁决): passed boolean + followups computed by CLI, not LLM.
10
- * KISS: keep composition narrow — input, thresholds, output file path.
11
- */
12
- import { createHash } from 'node:crypto';
13
- import { mkdir, rename, unlink, writeFile } from 'node:fs/promises';
14
- import { dirname } from 'node:path';
15
- import { MutReportSchema, } from './types.js';
16
- import { DEFAULT_THRESHOLDS, evaluateThresholds, } from './thresholds.js';
17
- function deriveFollowups(m, a, t) {
18
- const out = [];
19
- if (m.killRate < t.mutationKillRateMin) {
20
- for (const f of m.byFile) {
21
- if (f.killRate < t.mutationKillRateMin) {
22
- out.push({
23
- file: f.file,
24
- issue: 'low_kill_rate',
25
- severity: 'soft',
26
- suggestion: `Add tests for ${f.survived.length} survived mutants in ${f.file}`,
27
- });
28
- }
29
- }
30
- }
31
- if (a.weakRate > t.weakAssertionRateMax) {
32
- for (const p of a.weakPatterns) {
33
- if (p.count > 0) {
34
- const exampleFile = p.examples[0]?.file ?? '<unknown>';
35
- out.push({
36
- file: exampleFile,
37
- issue: 'high_weak_assertions',
38
- severity: 'hard',
39
- suggestion: `Replace ${p.count} weak assertions of type "${p.pattern}" with concrete value checks`,
40
- });
41
- }
42
- }
43
- }
44
- return out;
45
- }
46
- /**
47
- * Recursively sort object keys to produce a canonical JSON string.
48
- * Arrays preserve order; only object keys are sorted.
49
- */
50
- function canonicalize(value) {
51
- if (value === null || typeof value !== 'object') {
52
- return value;
53
- }
54
- if (Array.isArray(value)) {
55
- return value.map((v) => canonicalize(v));
56
- }
57
- const obj = value;
58
- const sorted = {};
59
- for (const key of Object.keys(obj).sort()) {
60
- sorted[key] = canonicalize(obj[key]);
61
- }
62
- return sorted;
63
- }
64
- function sha256OfCanonical(value) {
65
- const canonical = JSON.stringify(canonicalize(value));
66
- return createHash('sha256').update(canonical).digest('hex');
67
- }
68
- /**
69
- * Compute MUT.sig: sha256 of the report content excluding generatedAt and
70
- * sha256 itself. Both fields are removed before canonicalization so the
71
- * digest is stable across runs that differ only in timestamp.
72
- */
73
- function computeMutSig(report) {
74
- const { generatedAt: _g, ...rest } = report;
75
- void _g;
76
- return sha256OfCanonical(rest);
77
- }
78
- export async function buildMutReport(input) {
79
- const thresholds = input.thresholds ?? DEFAULT_THRESHOLDS;
80
- const now = input.now ?? (() => new Date());
81
- const evalResult = evaluateThresholds(thresholds, input.mutation.killRate, input.assertions.weakRate);
82
- const followups = deriveFollowups(input.mutation, input.assertions, thresholds);
83
- const partial = {
84
- version: '1.0',
85
- generatedAt: now().toISOString(),
86
- inputSig: input.inputSig,
87
- mutation: input.mutation,
88
- assertions: input.assertions,
89
- thresholds: {
90
- mutationKillRateMin: thresholds.mutationKillRateMin,
91
- weakAssertionRateMax: thresholds.weakAssertionRateMax,
92
- passed: evalResult.passed,
93
- },
94
- followups,
95
- };
96
- const sha256 = computeMutSig(partial);
97
- const final = { ...partial, sha256 };
98
- MutReportSchema.parse(final);
99
- await mkdir(dirname(input.out), { recursive: true });
100
- const tmp = `${input.out}.tmp`;
101
- try {
102
- await writeFile(tmp, JSON.stringify(final, null, 2), 'utf8');
103
- await rename(tmp, input.out);
104
- }
105
- catch (err) {
106
- await unlink(tmp).catch(() => undefined);
107
- throw err;
108
- }
109
- return final;
110
- }
@@ -1,31 +0,0 @@
1
- import { type MutReportJson } from './types.js';
2
- export declare const MUT_REPORT_RELATIVE_PATH = "mut/mut-report.json";
3
- /**
4
- * Build the canonical absolute path of a session's mut-report.json.
5
- * Exported so the CLI surface in qa-commands can reuse the same
6
- * constant for diagnostic messages.
7
- *
8
- * Uses POSIX separators intentionally: the one-axis envelope is
9
- * documented as `.peaks/_runtime/<sid>/mut/mut-report.json` (forward
10
- * slashes) and that path is what the hotfix 81f00ce audit-trail
11
- * contract guarantees. `node:path` would produce backslashes on
12
- * Windows, breaking the cross-platform invariant. POSIX join is
13
- * correct here because the result is a logical path stored in JSON
14
- * artifacts and CLI diagnostics — it never gets passed to OS
15
- * syscalls directly (readFile / writeFile accept both forms).
16
- */
17
- export declare function mutReportPath(sessionId: string): string;
18
- /**
19
- * Read and validate a session's mut-report.json.
20
- *
21
- * Returns `null` for any of these cases:
22
- * - file does not exist (ENOENT)
23
- * - file exists but JSON is malformed
24
- * - file exists and parses but does not satisfy `MutReportSchema`
25
- *
26
- * Never throws. Never logs to stdout (per "no console.log in src/").
27
- * Schema-parse failures are reported via `process.stderr` so the
28
- * qa-runner operator can see why their report is being treated as
29
- * absent.
30
- */
31
- export declare function loadMutReport(sessionId: string): Promise<MutReportJson | null>;
@@ -1,78 +0,0 @@
1
- /**
2
- * Plan 2 — Task 8: peaks-qa consumes MUT.sig from peaks-mut.
3
- *
4
- * `loadMutReport` is the read-side counterpart of `buildMutReport`
5
- * (which is the write-side). Both share the canonical path:
6
- * `.peaks/_runtime/<sessionId>/mut/mut-report.json` (per hotfix 81f00ce
7
- * one-axis envelope — no `.peaks/_runtime/<sessionId>/` fallback).
8
- *
9
- * Design contract (per spec lines 1292-1341):
10
- * - Missing file → `null` (gate is skipped, NOT failed)
11
- * - Schema-invalid → `null` (log via stderr; do not throw — qa is a
12
- * pre-step, not a precondition)
13
- * - Schema-valid → the parsed `MutReportJson`
14
- *
15
- * Returning `null` instead of throwing is what lets peaks-qa treat
16
- * "peaks mut was not run" as a no-op. If we threw, the qa gate would
17
- * crash on every session that hasn't run peaks-mut yet.
18
- */
19
- import { readFile } from 'node:fs/promises';
20
- import { posix as pathPosix } from 'node:path';
21
- import { MutReportSchema } from './types.js';
22
- export const MUT_REPORT_RELATIVE_PATH = 'mut/mut-report.json';
23
- /**
24
- * Build the canonical absolute path of a session's mut-report.json.
25
- * Exported so the CLI surface in qa-commands can reuse the same
26
- * constant for diagnostic messages.
27
- *
28
- * Uses POSIX separators intentionally: the one-axis envelope is
29
- * documented as `.peaks/_runtime/<sid>/mut/mut-report.json` (forward
30
- * slashes) and that path is what the hotfix 81f00ce audit-trail
31
- * contract guarantees. `node:path` would produce backslashes on
32
- * Windows, breaking the cross-platform invariant. POSIX join is
33
- * correct here because the result is a logical path stored in JSON
34
- * artifacts and CLI diagnostics — it never gets passed to OS
35
- * syscalls directly (readFile / writeFile accept both forms).
36
- */
37
- export function mutReportPath(sessionId) {
38
- return pathPosix.join('.peaks', '_runtime', sessionId, MUT_REPORT_RELATIVE_PATH);
39
- }
40
- /**
41
- * Read and validate a session's mut-report.json.
42
- *
43
- * Returns `null` for any of these cases:
44
- * - file does not exist (ENOENT)
45
- * - file exists but JSON is malformed
46
- * - file exists and parses but does not satisfy `MutReportSchema`
47
- *
48
- * Never throws. Never logs to stdout (per "no console.log in src/").
49
- * Schema-parse failures are reported via `process.stderr` so the
50
- * qa-runner operator can see why their report is being treated as
51
- * absent.
52
- */
53
- export async function loadMutReport(sessionId) {
54
- const path = mutReportPath(sessionId);
55
- let raw;
56
- try {
57
- raw = await readFile(path, 'utf8');
58
- }
59
- catch { // TODO(g2): legacy silent catch — grace: 1 minor release (v2.14.0)
60
- // ENOENT or permission denied — both treated as "not run".
61
- return null;
62
- }
63
- let parsedJson;
64
- try {
65
- parsedJson = JSON.parse(raw);
66
- }
67
- catch (err) {
68
- const message = err instanceof Error ? err.message : String(err);
69
- process.stderr.write(`[peaks-qa] mut-report at ${path} is not valid JSON; treating as absent: ${message}\n`);
70
- return null;
71
- }
72
- const parsed = MutReportSchema.safeParse(parsedJson);
73
- if (!parsed.success) {
74
- process.stderr.write(`[peaks-qa] mut-report at ${path} failed schema validation; treating as absent: ${parsed.error.message}\n`);
75
- return null;
76
- }
77
- return parsed.data;
78
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Per spec §4.2 验收审计 — Default thresholds + evaluator.
3
- *
4
- * Override via `peaks-mut.config.json` at project root.
5
- */
6
- export interface Thresholds {
7
- readonly mutationKillRateMin: number;
8
- readonly weakAssertionRateMax: number;
9
- }
10
- export declare const DEFAULT_THRESHOLDS: Thresholds;
11
- export type ThresholdViolationKind = 'mutationKillRateMin' | 'weakAssertionRateMax';
12
- export interface ThresholdViolation {
13
- readonly kind: ThresholdViolationKind;
14
- readonly actual: number;
15
- readonly threshold: number;
16
- }
17
- export interface ThresholdEvaluation {
18
- readonly passed: boolean;
19
- readonly violations: ReadonlyArray<ThresholdViolation>;
20
- }
21
- export declare function evaluateThresholds(t: Thresholds, actualKillRate: number, actualWeakRate: number): ThresholdEvaluation;
@@ -1,22 +0,0 @@
1
- export const DEFAULT_THRESHOLDS = Object.freeze({
2
- mutationKillRateMin: 0.80,
3
- weakAssertionRateMax: 0.05,
4
- });
5
- export function evaluateThresholds(t, actualKillRate, actualWeakRate) {
6
- const violations = [];
7
- if (actualKillRate < t.mutationKillRateMin) {
8
- violations.push({
9
- kind: 'mutationKillRateMin',
10
- actual: actualKillRate,
11
- threshold: t.mutationKillRateMin,
12
- });
13
- }
14
- if (actualWeakRate > t.weakAssertionRateMax) {
15
- violations.push({
16
- kind: 'weakAssertionRateMax',
17
- actual: actualWeakRate,
18
- threshold: t.weakAssertionRateMax,
19
- });
20
- }
21
- return { passed: violations.length === 0, violations };
22
- }
@@ -1,336 +0,0 @@
1
- /**
2
- * Per spec §4.2 验收审计 + §7 阶段二 — MutReportJson v1.0.
3
- *
4
- * Hard constraints:
5
- * H8 (audit trail hashable): sha256 + inputSig (chain to TACT.sig)
6
- * H6 (CLI裁决, not LLM): passed boolean is computed by CLI, not LLM
7
- */
8
- import { z } from 'zod';
9
- export type MutVersion = '1.0';
10
- export type MutTool = 'stryker' | 'mutmut' | 'go-mutesting';
11
- export type WeakPattern = 'toBeDefined' | 'toBeTruthy' | 'toEqual-self' | 'expect-anything' | 'toBe-self';
12
- export interface SurvivedMutant {
13
- readonly line: number;
14
- readonly mutation: string;
15
- readonly survivedBecause: string;
16
- }
17
- export interface FileMutationReport {
18
- readonly file: string;
19
- readonly killRate: number;
20
- readonly survived: ReadonlyArray<SurvivedMutant>;
21
- }
22
- export interface MutationReport {
23
- readonly tool: MutTool;
24
- readonly mutantsTotal: number;
25
- readonly mutantsKilled: number;
26
- readonly mutantsSurvived: number;
27
- readonly mutantsTimeout: number;
28
- readonly killRate: number;
29
- readonly byFile: ReadonlyArray<FileMutationReport>;
30
- }
31
- export interface WeakExample {
32
- readonly file: string;
33
- readonly line: number;
34
- readonly code: string;
35
- }
36
- export interface WeakPatternCount {
37
- readonly pattern: WeakPattern;
38
- readonly count: number;
39
- readonly examples: ReadonlyArray<WeakExample>;
40
- }
41
- export interface AssertionsReport {
42
- readonly totalAssertions: number;
43
- readonly weakAssertions: number;
44
- readonly weakRate: number;
45
- readonly weakPatterns: ReadonlyArray<WeakPatternCount>;
46
- }
47
- export interface ThresholdsConfig {
48
- readonly mutationKillRateMin: number;
49
- readonly weakAssertionRateMax: number;
50
- readonly passed: boolean;
51
- }
52
- export type FollowupSeverity = 'soft' | 'hard';
53
- export type FollowupIssue = 'low_kill_rate' | 'high_weak_assertions';
54
- export interface Followup {
55
- readonly file: string;
56
- readonly issue: FollowupIssue;
57
- readonly severity: FollowupSeverity;
58
- readonly suggestion: string;
59
- }
60
- export interface MutReportJson {
61
- readonly version: MutVersion;
62
- readonly sha256: string;
63
- readonly generatedAt: string;
64
- readonly inputSig: string;
65
- readonly mutation: MutationReport;
66
- readonly assertions: AssertionsReport;
67
- readonly thresholds: ThresholdsConfig;
68
- readonly followups: ReadonlyArray<Followup>;
69
- }
70
- export declare const WeakPatternSchema: z.ZodEnum<["toBeDefined", "toBeTruthy", "toEqual-self", "expect-anything", "toBe-self"]>;
71
- export declare const MutReportSchema: z.ZodObject<{
72
- version: z.ZodLiteral<"1.0">;
73
- sha256: z.ZodString;
74
- generatedAt: z.ZodString;
75
- inputSig: z.ZodString;
76
- mutation: z.ZodObject<{
77
- tool: z.ZodEnum<["stryker", "mutmut", "go-mutesting"]>;
78
- mutantsTotal: z.ZodNumber;
79
- mutantsKilled: z.ZodNumber;
80
- mutantsSurvived: z.ZodNumber;
81
- mutantsTimeout: z.ZodNumber;
82
- killRate: z.ZodNumber;
83
- byFile: z.ZodArray<z.ZodObject<{
84
- file: z.ZodString;
85
- killRate: z.ZodNumber;
86
- survived: z.ZodArray<z.ZodObject<{
87
- line: z.ZodNumber;
88
- mutation: z.ZodString;
89
- survivedBecause: z.ZodString;
90
- }, "strip", z.ZodTypeAny, {
91
- line: number;
92
- mutation: string;
93
- survivedBecause: string;
94
- }, {
95
- line: number;
96
- mutation: string;
97
- survivedBecause: string;
98
- }>, "many">;
99
- }, "strip", z.ZodTypeAny, {
100
- file: string;
101
- killRate: number;
102
- survived: {
103
- line: number;
104
- mutation: string;
105
- survivedBecause: string;
106
- }[];
107
- }, {
108
- file: string;
109
- killRate: number;
110
- survived: {
111
- line: number;
112
- mutation: string;
113
- survivedBecause: string;
114
- }[];
115
- }>, "many">;
116
- }, "strip", z.ZodTypeAny, {
117
- tool: "stryker" | "mutmut" | "go-mutesting";
118
- killRate: number;
119
- mutantsTotal: number;
120
- mutantsKilled: number;
121
- mutantsSurvived: number;
122
- mutantsTimeout: number;
123
- byFile: {
124
- file: string;
125
- killRate: number;
126
- survived: {
127
- line: number;
128
- mutation: string;
129
- survivedBecause: string;
130
- }[];
131
- }[];
132
- }, {
133
- tool: "stryker" | "mutmut" | "go-mutesting";
134
- killRate: number;
135
- mutantsTotal: number;
136
- mutantsKilled: number;
137
- mutantsSurvived: number;
138
- mutantsTimeout: number;
139
- byFile: {
140
- file: string;
141
- killRate: number;
142
- survived: {
143
- line: number;
144
- mutation: string;
145
- survivedBecause: string;
146
- }[];
147
- }[];
148
- }>;
149
- assertions: z.ZodObject<{
150
- totalAssertions: z.ZodNumber;
151
- weakAssertions: z.ZodNumber;
152
- weakRate: z.ZodNumber;
153
- weakPatterns: z.ZodArray<z.ZodObject<{
154
- pattern: z.ZodEnum<["toBeDefined", "toBeTruthy", "toEqual-self", "expect-anything", "toBe-self"]>;
155
- count: z.ZodNumber;
156
- examples: z.ZodArray<z.ZodObject<{
157
- file: z.ZodString;
158
- line: z.ZodNumber;
159
- code: z.ZodString;
160
- }, "strip", z.ZodTypeAny, {
161
- code: string;
162
- file: string;
163
- line: number;
164
- }, {
165
- code: string;
166
- file: string;
167
- line: number;
168
- }>, "many">;
169
- }, "strip", z.ZodTypeAny, {
170
- count: number;
171
- examples: {
172
- code: string;
173
- file: string;
174
- line: number;
175
- }[];
176
- pattern: "toBeDefined" | "toBeTruthy" | "toEqual-self" | "expect-anything" | "toBe-self";
177
- }, {
178
- count: number;
179
- examples: {
180
- code: string;
181
- file: string;
182
- line: number;
183
- }[];
184
- pattern: "toBeDefined" | "toBeTruthy" | "toEqual-self" | "expect-anything" | "toBe-self";
185
- }>, "many">;
186
- }, "strip", z.ZodTypeAny, {
187
- weakRate: number;
188
- totalAssertions: number;
189
- weakAssertions: number;
190
- weakPatterns: {
191
- count: number;
192
- examples: {
193
- code: string;
194
- file: string;
195
- line: number;
196
- }[];
197
- pattern: "toBeDefined" | "toBeTruthy" | "toEqual-self" | "expect-anything" | "toBe-self";
198
- }[];
199
- }, {
200
- weakRate: number;
201
- totalAssertions: number;
202
- weakAssertions: number;
203
- weakPatterns: {
204
- count: number;
205
- examples: {
206
- code: string;
207
- file: string;
208
- line: number;
209
- }[];
210
- pattern: "toBeDefined" | "toBeTruthy" | "toEqual-self" | "expect-anything" | "toBe-self";
211
- }[];
212
- }>;
213
- thresholds: z.ZodObject<{
214
- mutationKillRateMin: z.ZodNumber;
215
- weakAssertionRateMax: z.ZodNumber;
216
- passed: z.ZodBoolean;
217
- }, "strip", z.ZodTypeAny, {
218
- passed: boolean;
219
- mutationKillRateMin: number;
220
- weakAssertionRateMax: number;
221
- }, {
222
- passed: boolean;
223
- mutationKillRateMin: number;
224
- weakAssertionRateMax: number;
225
- }>;
226
- followups: z.ZodArray<z.ZodObject<{
227
- file: z.ZodString;
228
- issue: z.ZodEnum<["low_kill_rate", "high_weak_assertions"]>;
229
- severity: z.ZodEnum<["soft", "hard"]>;
230
- suggestion: z.ZodString;
231
- }, "strip", z.ZodTypeAny, {
232
- file: string;
233
- severity: "soft" | "hard";
234
- issue: "low_kill_rate" | "high_weak_assertions";
235
- suggestion: string;
236
- }, {
237
- file: string;
238
- severity: "soft" | "hard";
239
- issue: "low_kill_rate" | "high_weak_assertions";
240
- suggestion: string;
241
- }>, "many">;
242
- }, "strip", z.ZodTypeAny, {
243
- version: "1.0";
244
- sha256: string;
245
- generatedAt: string;
246
- inputSig: string;
247
- mutation: {
248
- tool: "stryker" | "mutmut" | "go-mutesting";
249
- killRate: number;
250
- mutantsTotal: number;
251
- mutantsKilled: number;
252
- mutantsSurvived: number;
253
- mutantsTimeout: number;
254
- byFile: {
255
- file: string;
256
- killRate: number;
257
- survived: {
258
- line: number;
259
- mutation: string;
260
- survivedBecause: string;
261
- }[];
262
- }[];
263
- };
264
- assertions: {
265
- weakRate: number;
266
- totalAssertions: number;
267
- weakAssertions: number;
268
- weakPatterns: {
269
- count: number;
270
- examples: {
271
- code: string;
272
- file: string;
273
- line: number;
274
- }[];
275
- pattern: "toBeDefined" | "toBeTruthy" | "toEqual-self" | "expect-anything" | "toBe-self";
276
- }[];
277
- };
278
- thresholds: {
279
- passed: boolean;
280
- mutationKillRateMin: number;
281
- weakAssertionRateMax: number;
282
- };
283
- followups: {
284
- file: string;
285
- severity: "soft" | "hard";
286
- issue: "low_kill_rate" | "high_weak_assertions";
287
- suggestion: string;
288
- }[];
289
- }, {
290
- version: "1.0";
291
- sha256: string;
292
- generatedAt: string;
293
- inputSig: string;
294
- mutation: {
295
- tool: "stryker" | "mutmut" | "go-mutesting";
296
- killRate: number;
297
- mutantsTotal: number;
298
- mutantsKilled: number;
299
- mutantsSurvived: number;
300
- mutantsTimeout: number;
301
- byFile: {
302
- file: string;
303
- killRate: number;
304
- survived: {
305
- line: number;
306
- mutation: string;
307
- survivedBecause: string;
308
- }[];
309
- }[];
310
- };
311
- assertions: {
312
- weakRate: number;
313
- totalAssertions: number;
314
- weakAssertions: number;
315
- weakPatterns: {
316
- count: number;
317
- examples: {
318
- code: string;
319
- file: string;
320
- line: number;
321
- }[];
322
- pattern: "toBeDefined" | "toBeTruthy" | "toEqual-self" | "expect-anything" | "toBe-self";
323
- }[];
324
- };
325
- thresholds: {
326
- passed: boolean;
327
- mutationKillRateMin: number;
328
- weakAssertionRateMax: number;
329
- };
330
- followups: {
331
- file: string;
332
- severity: "soft" | "hard";
333
- issue: "low_kill_rate" | "high_weak_assertions";
334
- suggestion: string;
335
- }[];
336
- }>;
@@ -1,59 +0,0 @@
1
- /**
2
- * Per spec §4.2 验收审计 + §7 阶段二 — MutReportJson v1.0.
3
- *
4
- * Hard constraints:
5
- * H8 (audit trail hashable): sha256 + inputSig (chain to TACT.sig)
6
- * H6 (CLI裁决, not LLM): passed boolean is computed by CLI, not LLM
7
- */
8
- import { z } from 'zod';
9
- export const WeakPatternSchema = z.enum([
10
- 'toBeDefined', 'toBeTruthy', 'toEqual-self', 'expect-anything', 'toBe-self',
11
- ]);
12
- export const MutReportSchema = z.object({
13
- version: z.literal('1.0'),
14
- sha256: z.string().regex(/^[a-f0-9]{64}$/),
15
- generatedAt: z.string().datetime(),
16
- inputSig: z.string().regex(/^[a-f0-9]{64}$/),
17
- mutation: z.object({
18
- tool: z.enum(['stryker', 'mutmut', 'go-mutesting']),
19
- mutantsTotal: z.number().int().nonnegative(),
20
- mutantsKilled: z.number().int().nonnegative(),
21
- mutantsSurvived: z.number().int().nonnegative(),
22
- mutantsTimeout: z.number().int().nonnegative(),
23
- killRate: z.number().min(0).max(1),
24
- byFile: z.array(z.object({
25
- file: z.string(),
26
- killRate: z.number().min(0).max(1),
27
- survived: z.array(z.object({
28
- line: z.number().int(),
29
- mutation: z.string(),
30
- survivedBecause: z.string(),
31
- })),
32
- })),
33
- }),
34
- assertions: z.object({
35
- totalAssertions: z.number().int().nonnegative(),
36
- weakAssertions: z.number().int().nonnegative(),
37
- weakRate: z.number().min(0).max(1),
38
- weakPatterns: z.array(z.object({
39
- pattern: WeakPatternSchema,
40
- count: z.number().int().nonnegative(),
41
- examples: z.array(z.object({
42
- file: z.string(),
43
- line: z.number().int(),
44
- code: z.string(),
45
- })),
46
- })),
47
- }),
48
- thresholds: z.object({
49
- mutationKillRateMin: z.number().min(0).max(1),
50
- weakAssertionRateMax: z.number().min(0).max(1),
51
- passed: z.boolean(),
52
- }),
53
- followups: z.array(z.object({
54
- file: z.string(),
55
- issue: z.enum(['low_kill_rate', 'high_weak_assertions']),
56
- severity: z.enum(['soft', 'hard']),
57
- suggestion: z.string(),
58
- })),
59
- });
@@ -1,4 +0,0 @@
1
- export declare function pathExists(path: string): Promise<boolean>;
2
- export declare function readText(path: string): Promise<string>;
3
- export declare function listDirectories(path: string): Promise<string[]>;
4
- export declare function isDirectory(path: string): Promise<boolean>;