@stratum-hq/compliance 0.1.1 → 0.1.3

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/README.md CHANGED
@@ -2,11 +2,13 @@
2
2
 
3
3
  A content-free compliance **kernel** for [Stratum](https://github.com/stratum-hq/Stratum): the pure mechanics and type shapes any compliance product needs, with none of the content. Zero runtime dependencies, no database, no network, no provider, and no built-in catalog.
4
4
 
5
+ Read the documentation at [docs.stratum-hq.org/packages/compliance](https://docs.stratum-hq.org/packages/compliance/).
6
+
5
7
  It gives you three things:
6
8
 
7
- 1. **Coverage scoring** — diff a declared baseline against a resolved state and get a per-control breakdown plus a 0 to 100 score.
8
- 2. **A finding state machine** — a pure decision for whether a new evaluation outcome should open, resolve, or leave a finding alone.
9
- 3. **A control type vocabulary** — structural interfaces for describing a catalog of controls.
9
+ 1. **Coverage scoring:** diff a declared baseline against a resolved state and get a per-control breakdown plus a 0 to 100 score.
10
+ 2. **A finding state machine:** a pure decision for whether a new evaluation outcome should open, resolve, or leave a finding alone.
11
+ 3. **A control type vocabulary:** structural interfaces for describing a catalog of controls.
10
12
 
11
13
  > [!NOTE]
12
14
  > This is **not** a batteries-included compliance solution. It ships no frameworks, no controls, no provider mappings, and no thresholds. **Bring your own catalog:** you supply the content and the persistence; this package supplies the arithmetic and the shapes.
@@ -42,7 +44,7 @@ const result = scoreCoverage(baseline, resolved);
42
44
  ```
43
45
 
44
46
  - `status` is `"compliant"` (matches), `"drift"` (present but wrong), or `"missing"` (no own resolved entry for that key).
45
- - `score` is `round(compliant / total * 100)`. An **empty baseline scores 100** — nothing is required, so nothing is out of compliance.
47
+ - `score` is `round(compliant / total * 100)`. An **empty baseline scores 100**. Nothing is required, so nothing is out of compliance.
46
48
 
47
49
  ### Equality
48
50
 
@@ -57,16 +59,16 @@ looseEqual(true, "true"); // => true
57
59
 
58
60
  ## Finding state machine
59
61
 
60
- `reconcileFinding` decides what should happen to a control's finding when a new evaluation outcome arrives. It is a pure decision — you persist the result.
62
+ `reconcileFinding` decides what should happen to a control's finding when a new evaluation outcome arrives. It is a pure decision; you persist the result.
61
63
 
62
64
  ```typescript
63
65
  import { reconcileFinding } from "@stratum-hq/compliance";
64
66
 
65
- reconcileFinding("fail", "none"); // { type: "open" } — new gap
66
- reconcileFinding("fail", "open"); // { type: "noop" } — already tracked
67
- reconcileFinding("pass", "open"); // { type: "resolve" } — gap closed
68
- reconcileFinding("pass", "accepted"); // { type: "noop" } — accepted risk untouched
69
- reconcileFinding("na", "open"); // { type: "noop" } — na/error never change a finding
67
+ reconcileFinding("fail", "none"); // { type: "open" } (new gap)
68
+ reconcileFinding("fail", "open"); // { type: "noop" } (already tracked)
69
+ reconcileFinding("pass", "open"); // { type: "resolve" } (gap closed)
70
+ reconcileFinding("pass", "accepted"); // { type: "noop" } (accepted risk untouched)
71
+ reconcileFinding("na", "open"); // { type: "noop" } (na/error never change a finding)
70
72
  ```
71
73
 
72
74
  The rules:
@@ -74,8 +76,9 @@ The rules:
74
76
  - `fail` **opens** a finding, unless one is already active (`open` / `remediating`) or the risk was formally `accepted`.
75
77
  - `pass` **resolves** an active finding (`open` / `remediating`), and leaves an `accepted` finding untouched; otherwise there is nothing to resolve.
76
78
  - `na` and `error` are always no-ops.
79
+ - Any other outcome throws a `TypeError`.
77
80
 
78
- Map `{ type: "open" }` and `{ type: "resolve" }` onto your own inserts and updates — the state machine has no opinion about storage.
81
+ Map `{ type: "open" }` and `{ type: "resolve" }` onto your own inserts and updates. The state machine has no opinion about storage.
79
82
 
80
83
  ## Type vocabulary
81
84
 
@@ -98,6 +101,7 @@ Everything here is a pure function or a type. No side effects, no IO, no global
98
101
 
99
102
  ## Links
100
103
 
104
+ - Documentation: https://docs.stratum-hq.org/packages/compliance/
101
105
  - GitHub: https://github.com/stratum-hq/Stratum
102
106
 
103
107
  ## License
package/dist/finding.d.ts CHANGED
@@ -19,6 +19,7 @@ export type FindingAction = {
19
19
  * - `pass` resolves an active finding (`open` / `remediating`), and leaves an
20
20
  * `accepted` finding untouched; there is nothing to resolve otherwise.
21
21
  * - `na` and `error` never change a finding.
22
+ * - Any other outcome throws a `TypeError`.
22
23
  */
23
24
  export declare function reconcileFinding(newOutcome: ControlOutcome, currentState: FindingState): FindingAction;
24
25
  //# sourceMappingURL=finding.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"finding.d.ts","sourceRoot":"","sources":["../src/finding.ts"],"names":[],"mappings":"AAQA,kDAAkD;AAClD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC;AAE9D,gFAAgF;AAChF,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,aAAa,GACb,UAAU,GACV,UAAU,GACV,MAAM,CAAC;AAEX,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAErB;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,cAAc,EAC1B,YAAY,EAAE,YAAY,GACzB,aAAa,CAsBf"}
1
+ {"version":3,"file":"finding.d.ts","sourceRoot":"","sources":["../src/finding.ts"],"names":[],"mappings":"AAQA,kDAAkD;AAClD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC;AAE9D,gFAAgF;AAChF,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,aAAa,GACb,UAAU,GACV,UAAU,GACV,MAAM,CAAC;AAEX,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAErB;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,cAAc,EAC1B,YAAY,EAAE,YAAY,GACzB,aAAa,CA4Bf"}
package/dist/finding.js CHANGED
@@ -18,6 +18,7 @@ exports.reconcileFinding = reconcileFinding;
18
18
  * - `pass` resolves an active finding (`open` / `remediating`), and leaves an
19
19
  * `accepted` finding untouched; there is nothing to resolve otherwise.
20
20
  * - `na` and `error` never change a finding.
21
+ * - Any other outcome throws a `TypeError`.
21
22
  */
22
23
  function reconcileFinding(newOutcome, currentState) {
23
24
  switch (newOutcome) {
@@ -36,6 +37,9 @@ function reconcileFinding(newOutcome, currentState) {
36
37
  case "na":
37
38
  case "error":
38
39
  return { type: "noop" };
40
+ default:
41
+ // Unreachable for typed callers; guards untyped input such as parsed JSON.
42
+ throw new TypeError(`reconcileFinding: unknown control outcome ${JSON.stringify(newOutcome)}; expected one of pass, fail, na, error`);
39
43
  }
40
44
  }
41
45
  //# sourceMappingURL=finding.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"finding.js","sourceRoot":"","sources":["../src/finding.ts"],"names":[],"mappings":";AAAA,yBAAyB;AACzB,EAAE;AACF,0EAA0E;AAC1E,yEAAyE;AACzE,+EAA+E;AAC/E,+EAA+E;AAC/E,eAAe;;AA6Bf,4CAyBC;AApCD;;;;;;;;;;GAUG;AACH,SAAgB,gBAAgB,CAC9B,UAA0B,EAC1B,YAA0B;IAE1B,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,MAAM;YACT,IACE,YAAY,KAAK,MAAM;gBACvB,YAAY,KAAK,aAAa;gBAC9B,YAAY,KAAK,UAAU,EAC3B,CAAC;gBACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;YAC1B,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAE1B,KAAK,MAAM;YACT,IAAI,YAAY,KAAK,MAAM,IAAI,YAAY,KAAK,aAAa,EAAE,CAAC;gBAC9D,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;YAC7B,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAE1B,KAAK,IAAI,CAAC;QACV,KAAK,OAAO;YACV,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"finding.js","sourceRoot":"","sources":["../src/finding.ts"],"names":[],"mappings":";AAAA,yBAAyB;AACzB,EAAE;AACF,0EAA0E;AAC1E,yEAAyE;AACzE,+EAA+E;AAC/E,+EAA+E;AAC/E,eAAe;;AA8Bf,4CA+BC;AA3CD;;;;;;;;;;;GAWG;AACH,SAAgB,gBAAgB,CAC9B,UAA0B,EAC1B,YAA0B;IAE1B,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,MAAM;YACT,IACE,YAAY,KAAK,MAAM;gBACvB,YAAY,KAAK,aAAa;gBAC9B,YAAY,KAAK,UAAU,EAC3B,CAAC;gBACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;YAC1B,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAE1B,KAAK,MAAM;YACT,IAAI,YAAY,KAAK,MAAM,IAAI,YAAY,KAAK,aAAa,EAAE,CAAC;gBAC9D,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;YAC7B,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAE1B,KAAK,IAAI,CAAC;QACV,KAAK,OAAO;YACV,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAE1B;YACE,2EAA2E;YAC3E,MAAM,IAAI,SAAS,CACjB,6CAA6C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,yCAAyC,CACjH,CAAC;IACN,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stratum-hq/compliance",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Content-free compliance kernel for Stratum: baseline coverage scoring, a finding state machine, and a control type vocabulary",
5
5
  "keywords": [
6
6
  "compliance",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "license": "MIT",
45
45
  "author": "Christian Crank",
46
- "homepage": "https://github.com/stratum-hq/Stratum/tree/main/packages/compliance#readme",
46
+ "homepage": "https://docs.stratum-hq.org/packages/compliance/",
47
47
  "bugs": "https://github.com/stratum-hq/Stratum/issues",
48
48
  "engines": {
49
49
  "node": ">=20.0.0"