iterate-kernel 0.1.9 → 0.1.12
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/dist/canonical-json.d.ts +45 -0
- package/dist/canonical-json.d.ts.map +1 -1
- package/dist/canonical-json.js +99 -7
- package/dist/canonical-json.js.map +1 -1
- package/dist/convergence.d.ts +36 -44
- package/dist/convergence.d.ts.map +1 -1
- package/dist/decision-log-entry.d.ts +45 -28
- package/dist/decision-log-entry.d.ts.map +1 -1
- package/dist/decision-log-entry.js +71 -1
- package/dist/decision-log-entry.js.map +1 -1
- package/dist/decision-log-transcribe.d.ts.map +1 -1
- package/dist/decision-log-transcribe.js +59 -4
- package/dist/decision-log-transcribe.js.map +1 -1
- package/dist/decision-log.d.ts +13 -30
- package/dist/decision-log.d.ts.map +1 -1
- package/dist/decision-log.js +29 -5
- package/dist/decision-log.js.map +1 -1
- package/dist/dimension-context.d.ts +39 -223
- package/dist/dimension-context.d.ts.map +1 -1
- package/dist/dimension-context.js +37 -5
- package/dist/dimension-context.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +11 -1
- package/dist/errors.js.map +1 -1
- package/dist/evidence-decision.d.ts +1 -35
- package/dist/evidence-decision.d.ts.map +1 -1
- package/dist/evidence-decision.js +28 -8
- package/dist/evidence-decision.js.map +1 -1
- package/dist/evidence-pack.d.ts +256 -1595
- package/dist/evidence-pack.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/invariant-report.d.ts +53 -189
- package/dist/invariant-report.d.ts.map +1 -1
- package/dist/invariant-report.js +18 -0
- package/dist/invariant-report.js.map +1 -1
- package/dist/parse.d.ts.map +1 -1
- package/dist/parse.js +12 -2
- package/dist/parse.js.map +1 -1
- package/dist/provider-registration.d.ts +22 -72
- package/dist/provider-registration.d.ts.map +1 -1
- package/dist/provider-registration.js +22 -2
- package/dist/provider-registration.js.map +1 -1
- package/dist/recipe-config.d.ts +21 -32
- package/dist/recipe-config.d.ts.map +1 -1
- package/dist/run-plan.d.ts +23 -82
- package/dist/run-plan.d.ts.map +1 -1
- package/fixtures/decision-record-transcription.ok-01.json +41 -1
- package/package.json +7 -2
- package/schemas/convergence-round-state.schema.json +7 -4
- package/schemas/decision-log-entry.schema.json +4 -2
- package/schemas/evidence-pack.schema.json +10 -6
- package/schemas/invariant-report.schema.json +5 -3
- package/schemas/provider-registration.schema.json +1 -1
- package/schemas/reverification-request.schema.json +1 -1
- package/schemas/run-plan.schema.json +1 -0
package/dist/errors.js
CHANGED
|
@@ -15,10 +15,20 @@ export class KernelSchemaError extends Error {
|
|
|
15
15
|
this.issues = issues;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* A path segment as text. `PropertyKey` is not pedantry: zod 4 types an issue path that way, and
|
|
20
|
+
* `String(symbol)` throws — a symbol in a path would turn a schema rejection, which is this
|
|
21
|
+
* package's normal way of saying "no", into a crash at the moment it is being reported. The
|
|
22
|
+
* description is the only part of a symbol a schema could have placed there on purpose, so that is
|
|
23
|
+
* what reaches the message; an unnamed symbol says it was unnamed rather than disappearing.
|
|
24
|
+
*/
|
|
25
|
+
function segmentText(segment) {
|
|
26
|
+
return typeof segment === "symbol" ? (segment.description ?? "<symbol>") : String(segment);
|
|
27
|
+
}
|
|
18
28
|
/** One place that turns a validation failure into `KernelSchemaError`. */
|
|
19
29
|
export function schemaErrorFrom(label, error) {
|
|
20
30
|
return new KernelSchemaError(label, error.issues.map((issue) => ({
|
|
21
|
-
path: issue.path.map(
|
|
31
|
+
path: issue.path.map(segmentText).join("."),
|
|
22
32
|
message: issue.message
|
|
23
33
|
})));
|
|
24
34
|
}
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],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AO,EAAE,CAAC;aACpF,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,KAAK,CAAC,WAAW,KAAK,KAAK,MAAM,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAaD;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,OAAoB;IACvC,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC7F,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,KAAsB;IACnE,OAAO,IAAI,iBAAiB,CAC1B,KAAK,EACL,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC3B,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC3C,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC,CAAC,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -1,39 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type EvidencePack } from "./evidence-pack.js";
|
|
2
2
|
import type { DecisionOutcome } from "./decision-log-entry.js";
|
|
3
|
-
/**
|
|
4
|
-
* Transcribing an evidence pack into the decision log's vocabulary.
|
|
5
|
-
*
|
|
6
|
-
* This function deliberately contains **no verification logic of its own**. The
|
|
7
|
-
* three architecture iron laws put "did this change happen because of this
|
|
8
|
-
* operation" inside the Swift engine; the engine already answered that question
|
|
9
|
-
* and wrote it into the pack (`attribution`, `assertion.passed`,
|
|
10
|
-
* `diagnosis.class`, `circuitBreaker.level`). What lives here is only the
|
|
11
|
-
* mapping from those verdicts to the four `DecisionOutcome` values, so that both
|
|
12
|
-
* TypeScript shells log the same words for the same evidence — one of the
|
|
13
|
-
* reasons the mapping is in the kernel instead of in each shell.
|
|
14
|
-
*
|
|
15
|
-
* Order matters, and it is the order of "what actually decides the run":
|
|
16
|
-
*
|
|
17
|
-
* 1. `circuitBreaker.level >= 3` → `blocked`
|
|
18
|
-
* The loop was stopped by policy. Whether the interface is fine is not
|
|
19
|
-
* what this entry is about, and saying `fail` would blame the app for a
|
|
20
|
-
* harness limit.
|
|
21
|
-
* 2. an assertion present → `pass` / `fail` from `assertion.passed`
|
|
22
|
-
* This is the engine's own verdict on the property that was checked.
|
|
23
|
-
* 3. a diagnosis present → `NO_ANOMALY` = pass, `INCONCLUSIVE` =
|
|
24
|
-
* inconclusive, any `T*` class = fail
|
|
25
|
-
* 4. neither → `inconclusive`
|
|
26
|
-
* Nothing was asserted and nothing diagnosed: there is no basis to record
|
|
27
|
-
* a verdict, and an audit log full of unfounded `pass` entries is worse
|
|
28
|
-
* than an empty one.
|
|
29
|
-
*
|
|
30
|
-
* Then, and only as a downgrade, the pack's own contamination fields are
|
|
31
|
-
* honoured: a `pass` whose attribution is `weak`, or which the engine flagged
|
|
32
|
-
* `contaminated`, is recorded as `inconclusive`. A "pass" the engine itself
|
|
33
|
-
* refuses to attribute to this operation must not be logged as if it had been
|
|
34
|
-
* attributed — that is the failure mode the audit chain exists to catch.
|
|
35
|
-
* Nothing here can upgrade a verdict.
|
|
36
|
-
*/
|
|
37
3
|
export declare function decisionOutcomeFromEvidence(evidence: EvidencePack): DecisionOutcome;
|
|
38
4
|
/**
|
|
39
5
|
* Human-readable reason for the entry's `summary`, built from the same fields
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evidence-decision.d.ts","sourceRoot":"","sources":["../src/evidence-decision.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"evidence-decision.d.ts","sourceRoot":"","sources":["../src/evidence-decision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAqD/D,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,YAAY,GAAG,eAAe,CAOnF;AAoBD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAqB1E"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { EvidencePackSchema } from "./evidence-pack.js";
|
|
2
|
+
import { schemaErrorFrom } from "./errors.js";
|
|
1
3
|
/**
|
|
2
4
|
* Transcribing an evidence pack into the decision log's vocabulary.
|
|
3
5
|
*
|
|
@@ -32,13 +34,30 @@
|
|
|
32
34
|
* attributed — that is the failure mode the audit chain exists to catch.
|
|
33
35
|
* Nothing here can upgrade a verdict.
|
|
34
36
|
*/
|
|
37
|
+
/**
|
|
38
|
+
* The one gate both mappings pass through. Reading a field off whatever was handed
|
|
39
|
+
* in would turn a shape error into a `TypeError` at an arbitrary depth — the
|
|
40
|
+
* package's rule is that a refusal names the field and carries a code.
|
|
41
|
+
*
|
|
42
|
+
* The write-side schema is the one to check against, and `parseEvidencePackRead`
|
|
43
|
+
* folds a pack read off disk onto exactly that shape, so an archived pack still
|
|
44
|
+
* transcribes; a pack that never conformed cannot produce a verdict words.
|
|
45
|
+
*/
|
|
46
|
+
function checkedPack(evidence) {
|
|
47
|
+
const checked = EvidencePackSchema.safeParse(evidence);
|
|
48
|
+
if (!checked.success) {
|
|
49
|
+
throw schemaErrorFrom("evidence pack", checked.error);
|
|
50
|
+
}
|
|
51
|
+
return checked.data;
|
|
52
|
+
}
|
|
35
53
|
export function decisionOutcomeFromEvidence(evidence) {
|
|
36
|
-
const
|
|
54
|
+
const pack = checkedPack(evidence);
|
|
55
|
+
const base = baseOutcome(pack);
|
|
37
56
|
if (base !== "pass")
|
|
38
57
|
return base;
|
|
39
|
-
if (
|
|
58
|
+
if (pack.attribution.contaminated)
|
|
40
59
|
return "inconclusive";
|
|
41
|
-
if (
|
|
60
|
+
if (pack.attribution.level === "weak")
|
|
42
61
|
return "inconclusive";
|
|
43
62
|
return "pass";
|
|
44
63
|
}
|
|
@@ -69,19 +88,20 @@ function baseOutcome(evidence) {
|
|
|
69
88
|
* same state; it is a *rendering* of the pack, never a new judgement.
|
|
70
89
|
*/
|
|
71
90
|
export function decisionSummaryFromEvidence(evidence) {
|
|
91
|
+
const pack = checkedPack(evidence);
|
|
72
92
|
const parts = [];
|
|
73
|
-
const assertion =
|
|
93
|
+
const assertion = pack.assertion ?? null;
|
|
74
94
|
if (assertion !== null) {
|
|
75
95
|
parts.push(`assertion ${assertion.property} ${assertion.passed ? "passed" : "failed"}: expected ${JSON.stringify(assertion.expected)}, actual ${JSON.stringify(assertion.actual)}`);
|
|
76
96
|
}
|
|
77
|
-
const diagnosis =
|
|
97
|
+
const diagnosis = pack.diagnosis ?? null;
|
|
78
98
|
if (diagnosis !== null) {
|
|
79
99
|
parts.push(`diagnosis ${diagnosis.class}: ${diagnosis.report.anomaly}`);
|
|
80
100
|
}
|
|
81
|
-
if (
|
|
82
|
-
parts.push(`circuitBreaker level ${
|
|
101
|
+
if (pack.circuitBreaker.level > 0) {
|
|
102
|
+
parts.push(`circuitBreaker level ${pack.circuitBreaker.level}${pack.circuitBreaker.reason ? ` (${pack.circuitBreaker.reason})` : ""}`);
|
|
83
103
|
}
|
|
84
|
-
parts.push(`attribution ${
|
|
104
|
+
parts.push(`attribution ${pack.attribution.level}${pack.attribution.contaminated ? ", contaminated" : ""}`);
|
|
85
105
|
const summary = parts.join("; ");
|
|
86
106
|
return summary.length > 2048 ? `${summary.slice(0, 2045)}...` : summary;
|
|
87
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evidence-decision.js","sourceRoot":"","sources":["../src/evidence-decision.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"evidence-decision.js","sourceRoot":"","sources":["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