@aldus-runtime/gate-engine 0.2.0-next.11 → 0.2.0-next.13
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/definition.d.ts +16 -24
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +23 -22
- package/dist/definition.js.map +1 -1
- package/package.json +3 -3
- package/src/definition.ts +33 -35
package/dist/definition.d.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* because the engine knows their names.
|
|
15
15
|
*/
|
|
16
16
|
import type { ActorKind } from "@aldus-runtime/core";
|
|
17
|
+
import { type PromotionEvidence, type QualityEnforcement, type QualityLevel } from "@aldus-runtime/core";
|
|
17
18
|
/**
|
|
18
19
|
* The four quality levels of contract §12.
|
|
19
20
|
*
|
|
@@ -22,28 +23,26 @@ import type { ActorKind } from "@aldus-runtime/core";
|
|
|
22
23
|
* does not, and a model-assisted review may do either depending on whether it has been
|
|
23
24
|
* calibrated (§12.1).
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"human_oracle"];
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated in name only — the concept moved to Core (#115) and this is the gate-shaped alias.
|
|
28
|
+
*
|
|
29
|
+
* §12's levels are a property of any quality mechanism, not of gates. They lived here alone until
|
|
30
|
+
* an adopter's blocking evaluator turned out to be a Stage, which could declare none of this. The
|
|
31
|
+
* canonical definition is `QUALITY_LEVELS`; this name is kept because published code consumes it.
|
|
32
|
+
*/
|
|
33
|
+
export declare const GATE_LEVELS: readonly ["hard_gate", "advisory_signal", "model_assisted", "human_oracle"];
|
|
34
34
|
/** @see GATE_LEVELS */
|
|
35
|
-
export type GateLevel =
|
|
35
|
+
export type GateLevel = QualityLevel;
|
|
36
36
|
/**
|
|
37
|
-
* Whether a gate stops work or merely reports.
|
|
37
|
+
* Whether a gate stops work or merely reports. The gate-shaped alias of `QUALITY_ENFORCEMENTS`.
|
|
38
38
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* config file without producing any.
|
|
39
|
+
* Still a two-state enumeration rather than a boolean, for the reason Core records: §12.1 makes
|
|
40
|
+
* blocking a promotion with evidence behind it, and `blocking: boolean` invites someone to flip it
|
|
41
|
+
* in a config file without producing any.
|
|
43
42
|
*/
|
|
44
43
|
export declare const GATE_ENFORCEMENTS: readonly ["blocking", "advisory"];
|
|
45
44
|
/** @see GATE_ENFORCEMENTS */
|
|
46
|
-
export type GateEnforcement =
|
|
45
|
+
export type GateEnforcement = QualityEnforcement;
|
|
47
46
|
/**
|
|
48
47
|
* Evidence that a model-assisted evaluator was calibrated before it was allowed to block.
|
|
49
48
|
*
|
|
@@ -56,14 +55,7 @@ export type GateEnforcement = (typeof GATE_ENFORCEMENTS)[number];
|
|
|
56
55
|
* scope among what promotion must consider, because an evaluator calibrated on one host says
|
|
57
56
|
* nothing about another. Dimensions are caller-supplied (§4.2), consistent with WP-09's packs.
|
|
58
57
|
*/
|
|
59
|
-
export
|
|
60
|
-
/** Identifier of the calibration report that justified promotion (WP-10). */
|
|
61
|
-
reportRef: string;
|
|
62
|
-
/** Scope the calibration covers, e.g. `{ host: "example-host", voice: "voice-a" }`. */
|
|
63
|
-
scope: Record<string, string>;
|
|
64
|
-
/** Known blind spots recorded at promotion time (§12.1, §9.3). */
|
|
65
|
-
knownBlindSpots?: string[];
|
|
66
|
-
}
|
|
58
|
+
export type { PromotionEvidence };
|
|
67
59
|
/**
|
|
68
60
|
* One configured gate.
|
|
69
61
|
*
|
package/dist/definition.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB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cAAc;IAC5D,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,mBAAmB,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAUD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,cAAc,GAAG,sBAAsB,CA8DzF;AAED;;;;;;GAMG;AACH,qBAAa,YAAY;;IAGvB,OAAO,eAEN;IAED;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,GAAG,YAAY,CAsChE;IAED,uCAAuC;IACvC,IAAI,IAAI,sBAAsB,EAAE,CAE/B;IAED,sCAAsC;IACtC,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE3B;IAED,iEAAiE;IACjE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS,CAEtD;IAED;;;;OAIG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,sBAAsB,CAU9C;IAED,8CAA8C;IAC9C,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,sBAAsB,EAAE,CAErD;IAED;;;;;OAKG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAiBrC;CACF"}
|
package/dist/definition.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* adopter is most likely to write. The tests construct them to show the model expresses §13, not
|
|
14
14
|
* because the engine knows their names.
|
|
15
15
|
*/
|
|
16
|
+
import { QUALITY_ENFORCEMENTS, QUALITY_LEVELS, validateQualityClaim, } from "@aldus-runtime/core";
|
|
16
17
|
import { GateEngineErrorCodes, gateEngineError } from "./errors.js";
|
|
17
18
|
/**
|
|
18
19
|
* The four quality levels of contract §12.
|
|
@@ -22,25 +23,22 @@ import { GateEngineErrorCodes, gateEngineError } from "./errors.js";
|
|
|
22
23
|
* does not, and a model-assisted review may do either depending on whether it has been
|
|
23
24
|
* calibrated (§12.1).
|
|
24
25
|
*/
|
|
25
|
-
export const GATE_LEVELS = [
|
|
26
|
-
/** Blocks on an objectively testable failure (§12 level 1). */
|
|
27
|
-
"hard_gate",
|
|
28
|
-
/** Reports a possible issue without blocking (§12 level 2). */
|
|
29
|
-
"advisory_signal",
|
|
30
|
-
/** Evaluates meaning, stance, style, or claims under uncertainty (§12 level 3). */
|
|
31
|
-
"model_assisted",
|
|
32
|
-
/** A human owns the judgement, because it is subjective or asymmetric-risk (§12 level 4). */
|
|
33
|
-
"human_oracle",
|
|
34
|
-
];
|
|
35
26
|
/**
|
|
36
|
-
*
|
|
27
|
+
* @deprecated in name only — the concept moved to Core (#115) and this is the gate-shaped alias.
|
|
37
28
|
*
|
|
38
|
-
*
|
|
39
|
-
* evaluator
|
|
40
|
-
*
|
|
41
|
-
* config file without producing any.
|
|
29
|
+
* §12's levels are a property of any quality mechanism, not of gates. They lived here alone until
|
|
30
|
+
* an adopter's blocking evaluator turned out to be a Stage, which could declare none of this. The
|
|
31
|
+
* canonical definition is `QUALITY_LEVELS`; this name is kept because published code consumes it.
|
|
42
32
|
*/
|
|
43
|
-
export const
|
|
33
|
+
export const GATE_LEVELS = QUALITY_LEVELS;
|
|
34
|
+
/**
|
|
35
|
+
* Whether a gate stops work or merely reports. The gate-shaped alias of `QUALITY_ENFORCEMENTS`.
|
|
36
|
+
*
|
|
37
|
+
* Still a two-state enumeration rather than a boolean, for the reason Core records: §12.1 makes
|
|
38
|
+
* blocking a promotion with evidence behind it, and `blocking: boolean` invites someone to flip it
|
|
39
|
+
* in a config file without producing any.
|
|
40
|
+
*/
|
|
41
|
+
export const GATE_ENFORCEMENTS = QUALITY_ENFORCEMENTS;
|
|
44
42
|
/** Actor kinds a gate accepts when the definition does not say. */
|
|
45
43
|
function defaultPermittedActorKinds(level) {
|
|
46
44
|
// §12 level 4 is "human oracle — owns subjective judgment or asymmetric-risk decisions", and
|
|
@@ -78,12 +76,15 @@ export function validateGateDefinition(definition) {
|
|
|
78
76
|
if (definition.dependsOn?.includes(definition.gateId) === true) {
|
|
79
77
|
fail("A gate cannot depend on itself.");
|
|
80
78
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
// The shared rule, not a second copy of it (#115). A gate and an evaluator Stage making the same
|
|
80
|
+
// claim are refused for the same reasons in the same words; two implementations of one clause
|
|
81
|
+
// is how §12 came to be enforced in one place and not the other.
|
|
82
|
+
for (const problem of validateQualityClaim({
|
|
83
|
+
level: definition.level,
|
|
84
|
+
enforcement: definition.enforcement,
|
|
85
|
+
promotionEvidence: definition.promotionEvidence,
|
|
86
|
+
})) {
|
|
87
|
+
fail(problem.message, { level: definition.level, enforcement: definition.enforcement });
|
|
87
88
|
}
|
|
88
89
|
const permittedActorKinds = definition.permittedActorKinds ?? defaultPermittedActorKinds(definition.level);
|
|
89
90
|
if (permittedActorKinds.length === 0) {
|
package/dist/definition.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,oBAAoB,GAIrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEpE;;;;;;;GAOG;AACH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC;AAK1C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AA+FtD,mEAAmE;AACnE,SAAS,0BAA0B,CAAC,KAAgB;IAClD,6FAA6F;I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AAC,MAAM,CAAC,CAAC;QAClB,KAAK,MAAM,UAAU,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,SAAS,IAAI,EAAE,EAAE,CAAC;YAC5D,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;YAC/B,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAO,KAAK,CAAC;QACxC,CAAC;QACD,IAAI,CAAC,GAAG,EAAE,CAAC;QACX,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACxB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACjB,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;IACxC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aldus-runtime/gate-engine",
|
|
3
|
-
"version": "0.2.0-next.
|
|
3
|
+
"version": "0.2.0-next.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Aldus Gate Engine — hash-bound human gates, cascading invalidation, and spend authorization.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"typecheck:test": "tsc -p tsconfig.test.json"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@aldus-runtime/core": "0.2.0-next.
|
|
36
|
+
"@aldus-runtime/core": "0.2.0-next.13"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@aldus-runtime/testkit": "0.2.0-next.
|
|
39
|
+
"@aldus-runtime/testkit": "0.2.0-next.13",
|
|
40
40
|
"@types/node": "^26.2.0",
|
|
41
41
|
"typescript": "^7.0.2",
|
|
42
42
|
"vitest": "^4.1.10"
|
package/src/definition.ts
CHANGED
|
@@ -15,6 +15,14 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import type { ActorKind } from "@aldus-runtime/core";
|
|
18
|
+
import {
|
|
19
|
+
QUALITY_ENFORCEMENTS,
|
|
20
|
+
QUALITY_LEVELS,
|
|
21
|
+
validateQualityClaim,
|
|
22
|
+
type PromotionEvidence,
|
|
23
|
+
type QualityEnforcement,
|
|
24
|
+
type QualityLevel,
|
|
25
|
+
} from "@aldus-runtime/core";
|
|
18
26
|
|
|
19
27
|
import { GateEngineErrorCodes, gateEngineError } from "./errors.js";
|
|
20
28
|
|
|
@@ -26,32 +34,29 @@ import { GateEngineErrorCodes, gateEngineError } from "./errors.js";
|
|
|
26
34
|
* does not, and a model-assisted review may do either depending on whether it has been
|
|
27
35
|
* calibrated (§12.1).
|
|
28
36
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"human_oracle",
|
|
38
|
-
] as const;
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated in name only — the concept moved to Core (#115) and this is the gate-shaped alias.
|
|
39
|
+
*
|
|
40
|
+
* §12's levels are a property of any quality mechanism, not of gates. They lived here alone until
|
|
41
|
+
* an adopter's blocking evaluator turned out to be a Stage, which could declare none of this. The
|
|
42
|
+
* canonical definition is `QUALITY_LEVELS`; this name is kept because published code consumes it.
|
|
43
|
+
*/
|
|
44
|
+
export const GATE_LEVELS = QUALITY_LEVELS;
|
|
39
45
|
|
|
40
46
|
/** @see GATE_LEVELS */
|
|
41
|
-
export type GateLevel =
|
|
47
|
+
export type GateLevel = QualityLevel;
|
|
42
48
|
|
|
43
49
|
/**
|
|
44
|
-
* Whether a gate stops work or merely reports.
|
|
50
|
+
* Whether a gate stops work or merely reports. The gate-shaped alias of `QUALITY_ENFORCEMENTS`.
|
|
45
51
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* config file without producing any.
|
|
52
|
+
* Still a two-state enumeration rather than a boolean, for the reason Core records: §12.1 makes
|
|
53
|
+
* blocking a promotion with evidence behind it, and `blocking: boolean` invites someone to flip it
|
|
54
|
+
* in a config file without producing any.
|
|
50
55
|
*/
|
|
51
|
-
export const GATE_ENFORCEMENTS =
|
|
56
|
+
export const GATE_ENFORCEMENTS = QUALITY_ENFORCEMENTS;
|
|
52
57
|
|
|
53
58
|
/** @see GATE_ENFORCEMENTS */
|
|
54
|
-
export type GateEnforcement =
|
|
59
|
+
export type GateEnforcement = QualityEnforcement;
|
|
55
60
|
|
|
56
61
|
/**
|
|
57
62
|
* Evidence that a model-assisted evaluator was calibrated before it was allowed to block.
|
|
@@ -65,14 +70,7 @@ export type GateEnforcement = (typeof GATE_ENFORCEMENTS)[number];
|
|
|
65
70
|
* scope among what promotion must consider, because an evaluator calibrated on one host says
|
|
66
71
|
* nothing about another. Dimensions are caller-supplied (§4.2), consistent with WP-09's packs.
|
|
67
72
|
*/
|
|
68
|
-
export
|
|
69
|
-
/** Identifier of the calibration report that justified promotion (WP-10). */
|
|
70
|
-
reportRef: string;
|
|
71
|
-
/** Scope the calibration covers, e.g. `{ host: "example-host", voice: "voice-a" }`. */
|
|
72
|
-
scope: Record<string, string>;
|
|
73
|
-
/** Known blind spots recorded at promotion time (§12.1, §9.3). */
|
|
74
|
-
knownBlindSpots?: string[];
|
|
75
|
-
}
|
|
73
|
+
export type { PromotionEvidence };
|
|
76
74
|
|
|
77
75
|
/**
|
|
78
76
|
* One configured gate.
|
|
@@ -196,15 +194,15 @@ export function validateGateDefinition(definition: GateDefinition): ResolvedGate
|
|
|
196
194
|
fail("A gate cannot depend on itself.");
|
|
197
195
|
}
|
|
198
196
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
197
|
+
// The shared rule, not a second copy of it (#115). A gate and an evaluator Stage making the same
|
|
198
|
+
// claim are refused for the same reasons in the same words; two implementations of one clause
|
|
199
|
+
// is how §12 came to be enforced in one place and not the other.
|
|
200
|
+
for (const problem of validateQualityClaim({
|
|
201
|
+
level: definition.level,
|
|
202
|
+
enforcement: definition.enforcement,
|
|
203
|
+
promotionEvidence: definition.promotionEvidence,
|
|
204
|
+
})) {
|
|
205
|
+
fail(problem.message, { level: definition.level, enforcement: definition.enforcement });
|
|
208
206
|
}
|
|
209
207
|
|
|
210
208
|
const permittedActorKinds =
|