@agent-ix/quoin 0.17.0 → 0.20.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.
Files changed (113) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/default-modules.yaml +15 -6
  4. package/dist/advisor/advise.d.ts +14 -1
  5. package/dist/advisor/advise.d.ts.map +1 -1
  6. package/dist/{advisor-Dhy9S7PS.js → advisor-B7X0YTVo.js} +1 -1
  7. package/dist/assurance/graph.d.ts +79 -0
  8. package/dist/assurance/graph.d.ts.map +1 -0
  9. package/dist/assurance/index.d.ts +9 -0
  10. package/dist/assurance/index.d.ts.map +1 -0
  11. package/dist/assurance/render.d.ts +3 -0
  12. package/dist/assurance/render.d.ts.map +1 -0
  13. package/dist/auditor/audit.d.ts +23 -2
  14. package/dist/auditor/audit.d.ts.map +1 -1
  15. package/dist/auditor/combinatorial.d.ts +53 -0
  16. package/dist/auditor/combinatorial.d.ts.map +1 -0
  17. package/dist/auditor-C9dLCmDh.js +188 -0
  18. package/dist/{base-D_-Jy4cE.js → base-q8brKRlC.js} +1 -1
  19. package/dist/cli.js +1 -1
  20. package/dist/combinatorial-Cq01XfhV.js +80 -0
  21. package/dist/commands/advise.js +35 -32
  22. package/dist/commands/assurance.d.ts +14 -0
  23. package/dist/commands/assurance.d.ts.map +1 -0
  24. package/dist/commands/assurance.js +179 -0
  25. package/dist/commands/catalog/list.js +2 -2
  26. package/dist/commands/catalog/methods.js +3 -3
  27. package/dist/commands/catalog/show.js +2 -2
  28. package/dist/commands/catalog/validate.js +2 -2
  29. package/dist/commands/completeness.d.ts +16 -0
  30. package/dist/commands/completeness.d.ts.map +1 -0
  31. package/dist/commands/completeness.js +49 -0
  32. package/dist/commands/config/doctor.js +1 -1
  33. package/dist/commands/config/edit.js +1 -1
  34. package/dist/commands/config/get.js +1 -1
  35. package/dist/commands/config/set.js +1 -1
  36. package/dist/commands/evidence/affirm.js +3 -3
  37. package/dist/commands/evidence/audit.d.ts +10 -0
  38. package/dist/commands/evidence/audit.d.ts.map +1 -1
  39. package/dist/commands/evidence/audit.js +54 -36
  40. package/dist/commands/evidence/baseline.js +12 -12
  41. package/dist/commands/evidence/gc.js +2 -2
  42. package/dist/commands/evidence/index.js +1 -1
  43. package/dist/commands/evidence/record.d.ts +2 -0
  44. package/dist/commands/evidence/record.d.ts.map +1 -1
  45. package/dist/commands/evidence/record.js +89 -32
  46. package/dist/commands/matrix.js +1 -1
  47. package/dist/commands/module/ensure-defaults.js +3 -3
  48. package/dist/commands/module/install.js +2 -2
  49. package/dist/commands/module/list.js +2 -2
  50. package/dist/commands/module/remove.js +2 -2
  51. package/dist/commands/review.js +1 -1
  52. package/dist/commands/to-plan.js +1 -1
  53. package/dist/commands/update.js +2 -2
  54. package/dist/commands/write.js +3 -3
  55. package/dist/completeness/assess.d.ts +82 -0
  56. package/dist/completeness/assess.d.ts.map +1 -0
  57. package/dist/completeness/bundle.d.ts +52 -0
  58. package/dist/completeness/bundle.d.ts.map +1 -0
  59. package/dist/completeness/declarations.d.ts +46 -0
  60. package/dist/completeness/declarations.d.ts.map +1 -0
  61. package/dist/completeness/index.d.ts +11 -0
  62. package/dist/completeness/index.d.ts.map +1 -0
  63. package/dist/completeness/run.d.ts +35 -0
  64. package/dist/completeness/run.d.ts.map +1 -0
  65. package/dist/completeness-Bic6298v.js +228 -0
  66. package/dist/evidence/adapters/agent-eval.d.ts +26 -0
  67. package/dist/evidence/adapters/agent-eval.d.ts.map +1 -0
  68. package/dist/evidence/adapters/audit-script.d.ts +25 -0
  69. package/dist/evidence/adapters/audit-script.d.ts.map +1 -0
  70. package/dist/evidence/adapters/cargo-mutants.d.ts +3 -0
  71. package/dist/evidence/adapters/cargo-mutants.d.ts.map +1 -0
  72. package/dist/evidence/adapters/junit.d.ts +17 -0
  73. package/dist/evidence/adapters/junit.d.ts.map +1 -0
  74. package/dist/evidence/adapters/registry.d.ts +63 -0
  75. package/dist/evidence/adapters/registry.d.ts.map +1 -0
  76. package/dist/evidence/adapters/sarif.d.ts +35 -0
  77. package/dist/evidence/adapters/sarif.d.ts.map +1 -0
  78. package/dist/evidence/adapters/sbom.d.ts +35 -0
  79. package/dist/evidence/adapters/sbom.d.ts.map +1 -0
  80. package/dist/evidence/adapters/types.d.ts +55 -0
  81. package/dist/evidence/adapters/types.d.ts.map +1 -0
  82. package/dist/evidence/index.d.ts +10 -0
  83. package/dist/evidence/index.d.ts.map +1 -1
  84. package/dist/evidence/record.d.ts.map +1 -1
  85. package/dist/evidence/store.d.ts +48 -2
  86. package/dist/evidence/store.d.ts.map +1 -1
  87. package/dist/evidence/types.d.ts +84 -0
  88. package/dist/evidence/types.d.ts.map +1 -1
  89. package/dist/evidence-OIkRqQrU.js +599 -0
  90. package/dist/{flow-command-B-ZBn9Sd.js → flow-command-k7eYqzBE.js} +1 -1
  91. package/dist/index.js +6 -6
  92. package/dist/{modules-DSkUXhHn.js → modules-E0AaYTTp.js} +2 -2
  93. package/dist/{plugins-DiS0OXoo.js → plugins-xe5e7dMl.js} +1 -1
  94. package/dist/quire/contract.d.ts +2 -2
  95. package/dist/quire/contract.d.ts.map +1 -1
  96. package/dist/quire/types.d.ts +11 -0
  97. package/dist/quire/types.d.ts.map +1 -1
  98. package/dist/{quire-D7ra5rUF.js → quire-BS-EW-0Y.js} +2 -2
  99. package/dist/schemas/coverage-v1.schema.json +6 -1
  100. package/dist/{version-DmZHxX4n.js → version-0hg-SgVf.js} +1 -1
  101. package/dist/{write-CPdSNIkF.js → write-Dig0zXLM.js} +1 -1
  102. package/package.json +2 -1
  103. package/skills/spec-fuzz/SKILL.md +94 -0
  104. package/skills/spec-fuzz/assets/templates/atheris.py.md +74 -0
  105. package/skills/spec-fuzz/assets/templates/cargo-fuzz.rs.md +83 -0
  106. package/skills/spec-fuzz/assets/templates/fast-check.ts.md +76 -0
  107. package/skills/spec-fuzz/references/step-0-scope-and-harness.md +51 -0
  108. package/skills/spec-fuzz/references/step-1-select-obligations.md +47 -0
  109. package/skills/spec-fuzz/references/step-2-ground-entry-point.md +55 -0
  110. package/skills/spec-fuzz/references/step-3-emit-targets.md +65 -0
  111. package/skills/spec-fuzz/references/step-4-report.md +56 -0
  112. package/dist/audit-CudnEJmh.js +0 -127
  113. package/dist/evidence-QUw0KyMH.js +0 -209
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quoin",
3
- "version": "0.17.0",
3
+ "version": "0.20.0",
4
4
  "description": "Spec authoring, review, matrix, and planning skills for Agent IX.",
5
5
  "author": {
6
6
  "name": "Agent IX"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quoin",
3
- "version": "0.17.0",
3
+ "version": "0.20.0",
4
4
  "description": "Spec authoring, review, matrix, and planning skills for Agent IX.",
5
5
  "author": {
6
6
  "name": "Agent IX",
@@ -10,13 +10,13 @@ schemaVersion: 1
10
10
  name: quoin-default-modules
11
11
  entries:
12
12
  - name: spec-artifacts-iso
13
- version: "0.12.0"
13
+ version: "0.16.0"
14
14
  defaultEnabled: true
15
15
  source:
16
16
  type: git-subdir
17
17
  url: agent-ix/spec-artifacts-iso
18
18
  path: spec_artifacts_iso
19
- ref: v0.12.0
19
+ ref: v0.16.0
20
20
 
21
21
  - name: spec-artifacts-app
22
22
  version: "0.5.0"
@@ -28,13 +28,13 @@ entries:
28
28
  ref: v0.5.0
29
29
 
30
30
  - name: spec-artifacts-process
31
- version: "0.17.0"
31
+ version: "0.19.0"
32
32
  defaultEnabled: true
33
33
  source:
34
34
  type: git-subdir
35
35
  url: agent-ix/spec-artifacts-process
36
36
  path: spec_artifacts_process
37
- ref: v0.17.0
37
+ ref: v0.19.0
38
38
 
39
39
  - name: spec-objects-business
40
40
  version: "0.6.0"
@@ -73,10 +73,19 @@ entries:
73
73
  ref: v0.6.0
74
74
 
75
75
  - name: spec-objects-security
76
- version: "0.5.0"
76
+ version: "0.7.0"
77
77
  defaultEnabled: true
78
78
  source:
79
79
  type: git-subdir
80
80
  url: agent-ix/spec-objects-security
81
81
  path: spec_objects_security
82
- ref: v0.5.0
82
+ ref: v0.7.0
83
+
84
+ - name: spec-objects-safety
85
+ version: "0.4.0"
86
+ defaultEnabled: true
87
+ source:
88
+ type: git-subdir
89
+ url: agent-ix/spec-objects-safety
90
+ path: spec_objects_safety
91
+ ref: v0.4.0
@@ -43,7 +43,20 @@ export interface Advice {
43
43
  */
44
44
  inconclusive: boolean;
45
45
  }
46
- /** Characteristics readable from an obligation's statement. */
46
+ /**
47
+ * Characteristics readable from an obligation's statement.
48
+ *
49
+ * Mostly prose regexes, plus one **structural** signal: a statement that parses
50
+ * as a declared configuration space (quire-rs FR-061) is a configuration matrix
51
+ * by construction, whatever words it happens to contain.
52
+ *
53
+ * The regex alone would miss it. A minted space reads
54
+ * `2-way over features(default|python|wasm) target(linux|wasm32)` — no
55
+ * "configuration", no "feature flag", no "combination of" — so the very
56
+ * obligations that most need the combinatorial method would be the ones it was
57
+ * never advised for. A structural test cannot false-positive on prose either,
58
+ * which a widened regex would.
59
+ */
47
60
  export declare function characteristicsOf(statement: string): string[];
48
61
  /**
49
62
  * Recommend methods for one obligation.
@@ -1 +1 @@
1
- {"version":3,"file":"advise.d.ts","sourceRoot":"","sources":["../../src/advisor/advise.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAsB,MAAM,cAAc,CAAC;AAEtE,iFAAiF;AACjF,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,mEAAmE;IACnE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,EAAE,CA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pE,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,6CAA6C;AAC7C,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAED,gDAAgD;AAChD,MAAM,WAAW,MAAM;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,YAAY,EAAE,OAAO,CAAC;CACvB;AA0DD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAM7D;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,eAAe,GAAG,MAAM,CAmD7E"}
@@ -1,4 +1,4 @@
1
- import { n as e, s as t } from "./base-D_-Jy4cE.js";
1
+ import { n as e, s as t } from "./base-q8brKRlC.js";
2
2
  import { readFileSync as n } from "node:fs";
3
3
  import { join as r } from "node:path";
4
4
  import { parse as i } from "yaml";
@@ -0,0 +1,79 @@
1
+ import { Obligation } from '../quire/index.js';
2
+ import { Finding } from '../auditor/index.js';
3
+ import { BundleDocument } from '../completeness/index.js';
4
+ /** GSN node kinds, in the vocabulary the standard uses. */
5
+ export type NodeKind = "goal" | "strategy" | "solution";
6
+ /**
7
+ * Whether a node's part of the argument holds.
8
+ *
9
+ * `open` is the point of the whole view. An undischarged obligation or a suspect
10
+ * binding stays in the tree as an **undeveloped goal** rather than being
11
+ * dropped: a case that silently narrows to only what it can prove reads as
12
+ * complete, and that is the failure this program exists to catch.
13
+ */
14
+ export type NodeStatus = "supported" | "open";
15
+ export interface CaseNode {
16
+ id: string;
17
+ kind: NodeKind;
18
+ /** What the node asserts, in the spec's own words where it has them. */
19
+ statement: string;
20
+ status: NodeStatus;
21
+ /** Why it is open — the auditor's finding, verbatim. Absent when supported. */
22
+ because?: string;
23
+ children: CaseNode[];
24
+ }
25
+ export interface AssuranceCase {
26
+ /** Top-level claims, one tree each. */
27
+ claims: CaseNode[];
28
+ /**
29
+ * Requirements reachable from no claim.
30
+ *
31
+ * Not an error and not hidden: a bundle whose StRs do not reach its FRs has a
32
+ * traceability gap, and the view's job is to make that visible rather than to
33
+ * render a tidy case over the reachable half.
34
+ */
35
+ unreachable: string[];
36
+ /** Documents whose frontmatter could not be read. */
37
+ unreadable: Array<{
38
+ path: string;
39
+ reason: string;
40
+ }>;
41
+ }
42
+ export interface CaseInput {
43
+ /** Frontmatter of every document in the bundle. */
44
+ documents: BundleDocument[];
45
+ /** Obligations, from `quire coverage --json`. */
46
+ obligations: Obligation[];
47
+ /** The auditor's findings, keyed by obligation elsewhere. */
48
+ findings: Finding[];
49
+ /**
50
+ * Artifact types that are top-level claims.
51
+ *
52
+ * Defaults to `StR`. A safety or security bundle argues from a declared
53
+ * hazard or threat instead, and that vocabulary is module data — so it is a
54
+ * parameter here, never a constant.
55
+ */
56
+ claimTypes?: string[];
57
+ unreadable?: Array<{
58
+ path: string;
59
+ reason: string;
60
+ }>;
61
+ }
62
+ /**
63
+ * Build the case.
64
+ *
65
+ * The decomposition is read from the documents' own `relationships`, in the
66
+ * child→parent direction the corpus actually authors: an FR says it
67
+ * `traces_to` an StR, not the other way round.
68
+ */
69
+ export declare function buildCase(input: CaseInput): AssuranceCase;
70
+ /**
71
+ * The requirement an obligation belongs to.
72
+ *
73
+ * `FR-001-AC-3` → `FR-001`; `NFR-010-M-2` → `NFR-010`. Derived from the id
74
+ * rather than from an edge because obligations are minted from a document's
75
+ * own tables — the ownership is not in question and an edge for it would be a
76
+ * second thing to keep in agreement.
77
+ */
78
+ export declare function requirementOf(obligationId: string): string;
79
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/assurance/graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,2DAA2D;AAC3D,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;AAExD;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,MAAM,CAAC;AAE9C,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,wEAAwE;IACxE,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;IACnB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB;;;;;;OAMG;IACH,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,qDAAqD;IACrD,UAAU,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrD;AAYD,MAAM,WAAW,SAAS;IACxB,mDAAmD;IACnD,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,iDAAiD;IACjD,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,6DAA6D;IAC7D,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACtD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,aAAa,CAmEzD;AAgGD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAG1D"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The assurance-case view (FR-040).
3
+ *
4
+ * ADR-0011 L1: read-only over the evidence store and the spec. It collects
5
+ * nothing and writes nothing.
6
+ */
7
+ export { buildCase, requirementOf, type AssuranceCase, type CaseInput, type CaseNode, type NodeKind, type NodeStatus, } from './graph.js';
8
+ export { renderCase } from './render.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/assurance/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,SAAS,EACT,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { AssuranceCase } from './graph.js';
2
+ export declare function renderCase(assurance: AssuranceCase): string;
3
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/assurance/render.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,YAAY,CAAC;AAQ1D,wBAAgB,UAAU,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,CAmD3D"}
@@ -1,11 +1,11 @@
1
1
  import { Obligation } from '../quire/index.js';
2
- import { Binding, RunRecord } from '../evidence/index.js';
2
+ import { Binding, FindingRecord, RunRecord } from '../evidence/index.js';
3
3
  import { MethodCatalog } from '../advisor/index.js';
4
4
  /** Severity of one finding. Matches the SpecReview vocabulary. */
5
5
  export type Severity = "low" | "medium" | "high";
6
6
  /** One thing wrong with the evidence for one obligation. */
7
7
  export interface Finding {
8
- kind: "suspect-link" | "stale-evidence" | "vacuous-evidence" | "undischarged" | "method-conformance" | "unknown-method" | "insufficient-multiplicity";
8
+ kind: "suspect-link" | "stale-evidence" | "vacuous-evidence" | "combinatorial-gap" | "undischarged" | "method-conformance" | "unknown-method" | "insufficient-multiplicity" | "insufficient-mutation-score" | "unmeasured-mutation-score";
9
9
  obligation: string;
10
10
  severity: Severity;
11
11
  summary: string;
@@ -18,12 +18,33 @@ export interface AuditInput {
18
18
  bindings: Binding[];
19
19
  /** Every run record the store holds, newest per suite. */
20
20
  runs: RunRecord[];
21
+ /**
22
+ * Every finding-shaped scan record the store holds, newest per suite
23
+ * (FR-034).
24
+ *
25
+ * Separate from `runs` because the two answer different questions. A scan
26
+ * has no symbols and no pass/fail, so every check that reasons over
27
+ * `entries` is meaningless against it — and silently folding them together
28
+ * is how a scan would start reading as a run that skipped everything.
29
+ */
30
+ scans?: FindingRecord[];
21
31
  /** The merged verification-method catalog, for method conformance. */
22
32
  catalog?: MethodCatalog;
23
33
  /** Commit being audited, for freshness. */
24
34
  headCommit?: string;
25
35
  /** Criticality values that demand two independent methods. */
26
36
  multiplicityRequires?: string[];
37
+ /**
38
+ * Criticality value → the mutation score its obligations must reach.
39
+ *
40
+ * **Unset by default**, for the reason CR-008 removed the hardcoded
41
+ * `multiplicityRequires: ["P0"]`: a built-in floor is a rule that fires on
42
+ * everything the moment a criticality column appears, and nobody chose it.
43
+ *
44
+ * A score is a ratio in `[0, 1]` — killed mutants over viable ones, as the
45
+ * `cargo-mutants` adapter computes it. Unviable mutants are in neither side.
46
+ */
47
+ mutationFloor?: Record<string, number>;
27
48
  }
28
49
  /** The audit result, ordered so the same input yields the same report. */
29
50
  export interface AuditReport {
@@ -1 +1 @@
1
- {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/auditor/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,kEAAkE;AAClE,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEjD,4DAA4D;AAC5D,MAAM,WAAW,OAAO;IACtB,IAAI,EACA,cAAc,GACd,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,oBAAoB,GACpB,gBAAgB,GAChB,2BAA2B,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,0CAA0C;AAC1C,MAAM,WAAW,UAAU;IACzB,+CAA+C;IAC/C,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,wCAAwC;IACxC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,0DAA0D;IAC1D,IAAI,EAAE,SAAS,EAAE,CAAC;IAClB,sEAAsE;IACtE,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC;AAED,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,OAAO,EA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way over these dimensions"* — and states the
5
+ * space in the obligation's own statement (quire-rs FR-061). This computes what
6
+ * a run actually reached, and names what it did not.
7
+ *
8
+ * **quoin computes; it neither declares nor generates.** The dimensions come
9
+ * from the spec, the executed configurations come from the consumer's CI, and
10
+ * the covering array itself is nobody's job here (ADR-0011 invariant 1).
11
+ */
12
+ /** One dimension parsed back out of an obligation statement. */
13
+ export interface Dimension {
14
+ name: string;
15
+ values: string[];
16
+ }
17
+ /** A forbidden combination: assignments that cannot co-occur. */
18
+ export interface Exclusion {
19
+ assignments: Array<[string, string]>;
20
+ }
21
+ export interface ConfigurationSpace {
22
+ strength: number;
23
+ dimensions: Dimension[];
24
+ exclusions: Exclusion[];
25
+ }
26
+ /**
27
+ * Parse the space out of a combinatorial obligation's statement.
28
+ *
29
+ * Returns `null` for any statement that is not one, which is how a caller tells
30
+ * a combinatorial obligation from every other kind without a second flag to
31
+ * keep in agreement with the first.
32
+ */
33
+ export declare function parseSpace(statement: string): ConfigurationSpace | null;
34
+ /** Every t-way tuple the space demands, as stable keys. */
35
+ export declare function demandedTuples(space: ConfigurationSpace): Set<string>;
36
+ /** Every t-way tuple one executed configuration covers. */
37
+ export declare function coveredBy(space: ConfigurationSpace, config: Record<string, string>): Set<string>;
38
+ export interface CoverageResult {
39
+ strength: number;
40
+ demanded: number;
41
+ covered: number;
42
+ /** Tuples no executed configuration reached, in stable order. */
43
+ gaps: string[];
44
+ }
45
+ /**
46
+ * What a set of executed configurations reached, and what it did not.
47
+ *
48
+ * The gap list is the point. A percentage tells someone how much is missing;
49
+ * the list tells them *which combinations to run*, which is the difference
50
+ * between a number and an action.
51
+ */
52
+ export declare function twayCoverage(space: ConfigurationSpace, configs: Array<Record<string, string>>): CoverageResult;
53
+ //# sourceMappingURL=combinatorial.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combinatorial.d.ts","sourceRoot":"","sources":["../../src/auditor/combinatorial.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,gEAAgE;AAChE,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,iEAAiE;AACjE,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAMD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAuCvE;AAyCD,2DAA2D;AAC3D,wBAAgB,cAAc,CAAC,KAAK,EAAE,kBAAkB,GAAG,GAAG,CAAC,MAAM,CAAC,CAkBrE;AAED,2DAA2D;AAC3D,wBAAgB,SAAS,CACvB,KAAK,EAAE,kBAAkB,EACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,GAAG,CAAC,MAAM,CAAC,CAWb;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,kBAAkB,EACzB,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACrC,cAAc,CAkBhB"}
@@ -0,0 +1,188 @@
1
+ import { n as e, t } from "./combinatorial-Cq01XfhV.js";
2
+ import { h as n } from "./evidence-OIkRqQrU.js";
3
+ //#region src/auditor/audit.ts
4
+ function r(r) {
5
+ let l = [], u = [], d = /* @__PURE__ */ new Map();
6
+ for (let e of r.bindings) {
7
+ let t = d.get(e.obligation) ?? [];
8
+ t.push(e), d.set(e.obligation, t);
9
+ }
10
+ let f = new Map(r.runs.map((e) => [e.suite, e])), p = new Map((r.scans ?? []).map((e) => [e.suite, e]));
11
+ for (let m of [...r.obligations].sort(a)) {
12
+ let a = (d.get(m.id) ?? []).slice().sort((e, t) => i(e.suite, t.suite));
13
+ if (a.length === 0) {
14
+ l.push({
15
+ kind: "undischarged",
16
+ obligation: m.id,
17
+ severity: "medium",
18
+ summary: `no evidence is bound to ${m.id}`
19
+ });
20
+ continue;
21
+ }
22
+ let h = a.filter((e) => e.statementHashAtBinding !== m.statement_hash);
23
+ if (h.length > 0) {
24
+ l.push({
25
+ kind: "suspect-link",
26
+ obligation: m.id,
27
+ severity: "high",
28
+ summary: `${m.id} was reworded after its evidence was bound in ${h.map((e) => e.suite).join(", ")} (bound against ${h[0].statementHashAtBinding.slice(0, 12)}…, now ${m.statement_hash.slice(0, 12)}…). Re-affirm or re-verify.`
29
+ });
30
+ continue;
31
+ }
32
+ let g = a.filter((e) => !f.has(e.suite) && !p.has(e.suite));
33
+ if (g.length > 0) {
34
+ l.push({
35
+ kind: "stale-evidence",
36
+ obligation: m.id,
37
+ severity: "high",
38
+ summary: `${m.id} is bound to ${g.map((e) => e.suite).join(", ")}, which ${g.length === 1 ? "has" : "have"} no recorded run. The binding claims evidence that is not in the store.`
39
+ });
40
+ continue;
41
+ }
42
+ let _ = a.map((e) => p.get(e.suite)).filter((e) => e !== void 0).filter((e) => n(e) === !0);
43
+ if (_.length > 0) {
44
+ l.push({
45
+ kind: "vacuous-evidence",
46
+ obligation: m.id,
47
+ severity: "high",
48
+ summary: `${m.id} rests on a scan that evaluated no rules: ` + _.map((e) => `${e.suite} (${e.tool})`).sort(i).join(", ") + ". It reported no finding because it looked for nothing."
49
+ });
50
+ continue;
51
+ }
52
+ let v = a.filter((e) => f.has(e.suite));
53
+ if (v.length === 0) continue;
54
+ let y = v.map((e) => f.get(e.suite));
55
+ if (r.headCommit) {
56
+ let e = a.filter((e, t) => y[t].commit !== r.headCommit);
57
+ e.length > 0 && l.push({
58
+ kind: "stale-evidence",
59
+ obligation: m.id,
60
+ severity: "medium",
61
+ summary: `${m.id} rests on ` + e.map((e) => `a ${e.suite} run at ${f.get(e.suite).commit.slice(0, 12)}`).join(" and ") + `, not at HEAD (${r.headCommit.slice(0, 12)}).`
62
+ });
63
+ }
64
+ let b = v.flatMap((e, t) => e.symbols.filter((e) => {
65
+ let n = y[t].entries.find((t) => t.symbol === e);
66
+ return !n || n.outcome === "skip";
67
+ }).map((t) => `${e.suite}:${t}`)), x = v.reduce((e, t) => e + t.symbols.length, 0);
68
+ if (b.length > 0 && b.length === x) {
69
+ l.push({
70
+ kind: "vacuous-evidence",
71
+ obligation: m.id,
72
+ severity: "high",
73
+ summary: `every symbol bound to ${m.id} was skipped or absent from its run: ${b.sort(i).join(", ")}. The row reads as covered and nothing was verified.`
74
+ });
75
+ continue;
76
+ }
77
+ let S = t(m.statement ?? "");
78
+ if (S) {
79
+ let t = y.flatMap((e) => e.entries.map((e) => e.config).filter((e) => !!e)), n = e(S, t);
80
+ if (n.covered < n.demanded) {
81
+ l.push({
82
+ kind: "combinatorial-gap",
83
+ obligation: m.id,
84
+ severity: "medium",
85
+ summary: `${m.id} demands ${n.demanded} ${n.strength}-way combinations and its runs reached ${n.covered}. Never run: ${n.gaps.slice(0, 10).join("; ")}` + (n.gaps.length > 10 ? ` (and ${n.gaps.length - 10} more)` : "")
86
+ });
87
+ continue;
88
+ }
89
+ }
90
+ let C = o(m, v, y, r.catalog);
91
+ if (C) {
92
+ l.push(C);
93
+ continue;
94
+ }
95
+ let w = s(m, a, r);
96
+ if (w) {
97
+ l.push(w);
98
+ continue;
99
+ }
100
+ let T = c(m, v, y, r);
101
+ if (T) {
102
+ l.push(T);
103
+ continue;
104
+ }
105
+ u.push(m.id);
106
+ }
107
+ return l.sort((e, t) => i(e.obligation, t.obligation) || i(e.kind, t.kind)), {
108
+ findings: l,
109
+ healthy: u.sort(i)
110
+ };
111
+ }
112
+ function i(e, t) {
113
+ return e === t ? 0 : e < t ? -1 : 1;
114
+ }
115
+ function a(e, t) {
116
+ return i(e.id, t.id);
117
+ }
118
+ function o(e, t, n, r) {
119
+ if (!r || !e.method) return null;
120
+ let a = e.method.trim().toLowerCase(), o = r.methods.filter((e) => e.id.toLowerCase() === a || e.class.toLowerCase() === a);
121
+ if (o.length === 0) return {
122
+ kind: "unknown-method",
123
+ obligation: e.id,
124
+ severity: "medium",
125
+ summary: `${e.id} declares \`${e.method}\`, which is neither a catalog method id nor a catalog class. Nothing can say what discharging it means, so no conformance check can run against it.`
126
+ };
127
+ let s = new Set(o.map((e) => e.evidenceKind).filter((e) => typeof e == "string" && e.length > 0));
128
+ if (s.size === 0) return null;
129
+ let c = t.filter((e, t) => {
130
+ let r = n[t].evidenceKind;
131
+ return typeof r == "string" && r.length > 0 && !s.has(r);
132
+ });
133
+ return c.length === 0 ? null : {
134
+ kind: "method-conformance",
135
+ obligation: e.id,
136
+ severity: "medium",
137
+ summary: `${e.id} declares \`${e.method}\`, whose evidence kind is ${[...s].sort(i).join("/")}, but is discharged by ` + c.map((e) => `a ${n[t.indexOf(e)].evidenceKind} run in ${e.suite}`).join(" and ") + ". A method is not discharged by evidence of another kind."
138
+ };
139
+ }
140
+ function s(e, t, n) {
141
+ let r = n.multiplicityRequires ?? [];
142
+ if (r.length === 0 || !e.criticality || !r.includes(e.criticality)) return null;
143
+ let i = new Set(t.map((e) => e.suite));
144
+ return i.size >= 2 ? null : {
145
+ kind: "insufficient-multiplicity",
146
+ obligation: e.id,
147
+ severity: "medium",
148
+ summary: `${e.id} is criticality ${e.criticality}, which requires two independent methods, but all its evidence comes from ${[...i].join(", ")}.`
149
+ };
150
+ }
151
+ function c(e, t, n, r) {
152
+ let i = r.mutationFloor ?? {};
153
+ if (!e.criticality) return null;
154
+ let a = i[e.criticality];
155
+ if (a === void 0 || !l(r.catalog)) return null;
156
+ let o = u(t, n, r.catalog);
157
+ if (o.length === 0) return {
158
+ kind: "unmeasured-mutation-score",
159
+ obligation: e.id,
160
+ severity: "medium",
161
+ summary: `${e.id} is criticality ${e.criticality}, which demands a mutation score of at least ${a}, and no run bound to it records one.`
162
+ };
163
+ let s = Math.min(...o);
164
+ return s >= a ? null : {
165
+ kind: "insufficient-mutation-score",
166
+ obligation: e.id,
167
+ severity: "medium",
168
+ summary: `${e.id} is criticality ${e.criticality}, which demands a mutation score of at least ${a}; its weakest bound symbol scores ${s}.`
169
+ };
170
+ }
171
+ function l(e) {
172
+ let t = new Set((e?.methods ?? []).filter((e) => e.id === "mutation-testing").flatMap((e) => e.tooling).map((e) => e.toLowerCase()));
173
+ return t.size > 0 ? t : null;
174
+ }
175
+ function u(e, t, n) {
176
+ let r = new Set(e.map((e) => e.suite)), i = l(n) ?? /* @__PURE__ */ new Set(), a = [];
177
+ for (let e of t) if (r.has(e.suite) && [...i].some((t) => e.tool.toLowerCase().startsWith(t))) for (let t of e.entries) t.score !== void 0 && t.outcome !== "skip" && a.push(t.score);
178
+ return a;
179
+ }
180
+ function d(e) {
181
+ return `${e.kind}:${e.obligation}`;
182
+ }
183
+ function f(e, t) {
184
+ let n = new Set(t.accepted);
185
+ return e.findings.filter((e) => !n.has(d(e)));
186
+ }
187
+ //#endregion
188
+ export { d as n, f as r, r as t };
@@ -1,4 +1,4 @@
1
- import { t as e } from "./version-DmZHxX4n.js";
1
+ import { t as e } from "./version-0hg-SgVf.js";
2
2
  import { BaseCommand as t, maybeOfferUpdate as n } from "@agent-ix/ix-cli-core";
3
3
  import { existsSync as r, readFileSync as i, readdirSync as a, statSync as o } from "node:fs";
4
4
  import { basename as s, join as c, resolve as l } from "node:path";
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as e, t } from "./version-DmZHxX4n.js";
1
+ import { n as e, t } from "./version-0hg-SgVf.js";
2
2
  import { run as n } from "@agent-ix/ix-cli-core";
3
3
  //#region src/cli.ts
4
4
  function r(e) {
@@ -0,0 +1,80 @@
1
+ //#region src/auditor/combinatorial.ts
2
+ var e = /^(\d+)-way over\s/, t = /([^\s(]+)\(([^)]*)\)/g, n = /excluding\[([^\]]*)\]/g;
3
+ function r(r) {
4
+ let i = e.exec(r);
5
+ if (!i) return null;
6
+ let a = Number.parseInt(i[1], 10);
7
+ if (!Number.isFinite(a) || a < 1) return null;
8
+ let o = r.split("excluding[")[0], s = [];
9
+ for (let e of o.matchAll(t)) {
10
+ let t = e[2].split("|").map((e) => e.trim()).filter((e) => e !== "");
11
+ t.length < 2 || s.push({
12
+ name: e[1],
13
+ values: t
14
+ });
15
+ }
16
+ if (s.length < 2) return null;
17
+ let c = [];
18
+ for (let e of r.matchAll(n)) {
19
+ let t = e[1].split(",").map((e) => e.trim()).filter((e) => e !== "").map((e) => {
20
+ let t = e.indexOf("=");
21
+ return t === -1 ? null : [e.slice(0, t).trim(), e.slice(t + 1).trim()];
22
+ }).filter((e) => e !== null);
23
+ t.length >= 2 && c.push({ assignments: t });
24
+ }
25
+ return {
26
+ strength: a,
27
+ dimensions: s,
28
+ exclusions: c
29
+ };
30
+ }
31
+ function i(e, t) {
32
+ if (t > e || t < 1) return [];
33
+ let n = [], r = [], i = (a) => {
34
+ if (r.length === t) {
35
+ n.push([...r]);
36
+ return;
37
+ }
38
+ for (let t = a; t < e; t += 1) r.push(t), i(t + 1), r.pop();
39
+ };
40
+ return i(0), n;
41
+ }
42
+ function a(e) {
43
+ return [...e].sort((e, t) => e[0] < t[0] ? -1 : +(e[0] > t[0])).map(([e, t]) => `${e}=${t}`).join(" & ");
44
+ }
45
+ function o(e, t) {
46
+ return e.exclusions.some((e) => e.assignments.every(([e, n]) => t.some(([t, r]) => t === e && r === n)));
47
+ }
48
+ function s(e) {
49
+ let t = /* @__PURE__ */ new Set();
50
+ for (let n of i(e.dimensions.length, e.strength)) {
51
+ let r = (i, s) => {
52
+ if (i === n.length) {
53
+ o(e, s) || t.add(a(s));
54
+ return;
55
+ }
56
+ let c = e.dimensions[n[i]];
57
+ for (let e of c.values) s.push([c.name, e]), r(i + 1, s), s.pop();
58
+ };
59
+ r(0, []);
60
+ }
61
+ return t;
62
+ }
63
+ function c(e, t) {
64
+ let n = e.dimensions.filter((e) => t[e.name] !== void 0 && e.values.includes(t[e.name])), r = /* @__PURE__ */ new Set();
65
+ for (let o of i(n.length, e.strength)) r.add(a(o.map((e) => [n[e].name, t[n[e].name]])));
66
+ return r;
67
+ }
68
+ function l(e, t) {
69
+ let n = s(e), r = /* @__PURE__ */ new Set();
70
+ for (let i of t) for (let t of c(e, i)) n.has(t) && r.add(t);
71
+ let i = [...n].filter((e) => !r.has(e)).sort();
72
+ return {
73
+ strength: e.strength,
74
+ demanded: n.size,
75
+ covered: r.size,
76
+ gaps: i
77
+ };
78
+ }
79
+ //#endregion
80
+ export { l as n, r as t };