@openprose/reactor 0.1.0-rc.1
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/LICENSE +21 -0
- package/README.md +231 -0
- package/dist/adapters/agent-sdk-passthrough/index.d.ts +8 -0
- package/dist/adapters/agent-sdk-passthrough/index.d.ts.map +1 -0
- package/dist/adapters/agent-sdk-passthrough/index.js +25 -0
- package/dist/adapters/clock-system/index.d.ts +9 -0
- package/dist/adapters/clock-system/index.d.ts.map +1 -0
- package/dist/adapters/clock-system/index.js +39 -0
- package/dist/adapters/connector-static/index.d.ts +11 -0
- package/dist/adapters/connector-static/index.d.ts.map +1 -0
- package/dist/adapters/connector-static/index.js +35 -0
- package/dist/adapters/event-sink-memory/index.d.ts +10 -0
- package/dist/adapters/event-sink-memory/index.d.ts.map +1 -0
- package/dist/adapters/event-sink-memory/index.js +20 -0
- package/dist/adapters/index.d.ts +10 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +25 -0
- package/dist/adapters/json.d.ts +3 -0
- package/dist/adapters/json.d.ts.map +1 -0
- package/dist/adapters/json.js +61 -0
- package/dist/adapters/model-gateway-record-replay/index.d.ts +24 -0
- package/dist/adapters/model-gateway-record-replay/index.d.ts.map +1 -0
- package/dist/adapters/model-gateway-record-replay/index.js +55 -0
- package/dist/adapters/sandbox-null/index.d.ts +3 -0
- package/dist/adapters/sandbox-null/index.d.ts.map +1 -0
- package/dist/adapters/sandbox-null/index.js +8 -0
- package/dist/adapters/storage-fs/index.d.ts +14 -0
- package/dist/adapters/storage-fs/index.d.ts.map +1 -0
- package/dist/adapters/storage-fs/index.js +65 -0
- package/dist/adapters/storage-memory/index.d.ts +11 -0
- package/dist/adapters/storage-memory/index.d.ts.map +1 -0
- package/dist/adapters/storage-memory/index.js +34 -0
- package/dist/adapters/types.d.ts +22 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +97 -0
- package/dist/composition/index.d.ts +79 -0
- package/dist/composition/index.d.ts.map +1 -0
- package/dist/composition/index.js +280 -0
- package/dist/cost/index.d.ts +49 -0
- package/dist/cost/index.d.ts.map +1 -0
- package/dist/cost/index.js +206 -0
- package/dist/evidence-plan/index.d.ts +57 -0
- package/dist/evidence-plan/index.d.ts.map +1 -0
- package/dist/evidence-plan/index.js +164 -0
- package/dist/forecast/index.d.ts +39 -0
- package/dist/forecast/index.d.ts.map +1 -0
- package/dist/forecast/index.js +119 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/judge/index.d.ts +29 -0
- package/dist/judge/index.d.ts.map +1 -0
- package/dist/judge/index.js +138 -0
- package/dist/kernel/index.d.ts +170 -0
- package/dist/kernel/index.d.ts.map +1 -0
- package/dist/kernel/index.js +637 -0
- package/dist/memo/index.d.ts +59 -0
- package/dist/memo/index.d.ts.map +1 -0
- package/dist/memo/index.js +189 -0
- package/dist/policy/index.d.ts +249 -0
- package/dist/policy/index.d.ts.map +1 -0
- package/dist/policy/index.js +1463 -0
- package/dist/projection/index.d.ts +119 -0
- package/dist/projection/index.d.ts.map +1 -0
- package/dist/projection/index.js +506 -0
- package/dist/reactor/index.d.ts +54 -0
- package/dist/reactor/index.d.ts.map +1 -0
- package/dist/reactor/index.js +1861 -0
- package/dist/receipt/index.d.ts +190 -0
- package/dist/receipt/index.d.ts.map +1 -0
- package/dist/receipt/index.js +646 -0
- package/dist/sdk/exit-bundle.d.ts +144 -0
- package/dist/sdk/exit-bundle.d.ts.map +1 -0
- package/dist/sdk/exit-bundle.js +1034 -0
- package/dist/sdk/index.d.ts +201 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +418 -0
- package/package.json +89 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { type ContentHashV0, type ReceiptProofInspectionV0, type ReceiptVerdictStatusV0 } from "../receipt";
|
|
2
|
+
export declare const RECEIPT_PROJECTION_SCHEMA: "openprose.receipt.projection";
|
|
3
|
+
export declare const RECEIPT_PROJECTION_VERSION: 0;
|
|
4
|
+
export declare const RECEIPT_PROJECTION_TIERS_V0: readonly ["owner", "subscriber", "public"];
|
|
5
|
+
export type ReceiptProjectionSchemaV0 = typeof RECEIPT_PROJECTION_SCHEMA;
|
|
6
|
+
export type ReceiptProjectionVersionV0 = typeof RECEIPT_PROJECTION_VERSION;
|
|
7
|
+
export type ReceiptProjectionTierV0 = (typeof RECEIPT_PROJECTION_TIERS_V0)[number];
|
|
8
|
+
export interface ProjectReceiptInputV0 {
|
|
9
|
+
readonly tier: string;
|
|
10
|
+
readonly receipt: unknown;
|
|
11
|
+
}
|
|
12
|
+
export interface ProjectReceiptProofInputV0 {
|
|
13
|
+
readonly tier: string;
|
|
14
|
+
readonly proof: unknown;
|
|
15
|
+
readonly status?: ReceiptVerdictStatusV0 | null;
|
|
16
|
+
}
|
|
17
|
+
export type ReceiptProjectionSignerV0 = {
|
|
18
|
+
readonly kind: "null";
|
|
19
|
+
readonly scheme: "none";
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: "signed";
|
|
22
|
+
readonly scheme: string;
|
|
23
|
+
};
|
|
24
|
+
export interface ReceiptProjectionFreshnessV0 {
|
|
25
|
+
readonly as_of: string;
|
|
26
|
+
readonly next_forecast_recheck: string;
|
|
27
|
+
readonly transitive_freshness_policy_ref: string | null;
|
|
28
|
+
readonly consumed_freshness_evaluated_count: number;
|
|
29
|
+
}
|
|
30
|
+
export interface ReceiptPublicCompositionPinProjectionV0 {
|
|
31
|
+
readonly upstream_content_hash: ContentHashV0;
|
|
32
|
+
readonly contract_revision: ContentHashV0;
|
|
33
|
+
readonly acceptable_signer_set_count: number;
|
|
34
|
+
}
|
|
35
|
+
export interface ReceiptSubscriberCompositionPinProjectionV0 {
|
|
36
|
+
readonly upstream_content_hash: ContentHashV0;
|
|
37
|
+
readonly contract_revision: ContentHashV0;
|
|
38
|
+
readonly acceptable_signer_set: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
export interface ReceiptPublicCompositionProjectionV0 {
|
|
41
|
+
readonly consumed_receipt_count: number;
|
|
42
|
+
readonly consumed_receipts: readonly ReceiptPublicCompositionPinProjectionV0[];
|
|
43
|
+
readonly cycle_checked: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface ReceiptSubscriberCompositionProjectionV0 {
|
|
46
|
+
readonly consumed_receipt_count: number;
|
|
47
|
+
readonly consumed_receipts: readonly ReceiptSubscriberCompositionPinProjectionV0[];
|
|
48
|
+
readonly cycle_checked: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface ReceiptPublicTokenTruthProjectionV0 {
|
|
51
|
+
readonly fresh: number;
|
|
52
|
+
readonly reused: number;
|
|
53
|
+
readonly role: string;
|
|
54
|
+
readonly surprise_cause: string;
|
|
55
|
+
}
|
|
56
|
+
export interface ReceiptSubscriberTokenTruthProjectionV0 extends ReceiptPublicTokenTruthProjectionV0 {
|
|
57
|
+
readonly provider: string;
|
|
58
|
+
readonly model: string;
|
|
59
|
+
}
|
|
60
|
+
export interface ReceiptOwnerVerdictProjectionV0 {
|
|
61
|
+
readonly status: ReceiptVerdictStatusV0 | null;
|
|
62
|
+
readonly confidence: {
|
|
63
|
+
readonly value: number | null;
|
|
64
|
+
readonly derivation_method: string | null;
|
|
65
|
+
readonly calibration_grade: string | null;
|
|
66
|
+
readonly label_source: string | null;
|
|
67
|
+
} | null;
|
|
68
|
+
readonly blocked: {
|
|
69
|
+
readonly reason: string | null;
|
|
70
|
+
readonly fix_target: string | null;
|
|
71
|
+
readonly interrupt_cause: string | null;
|
|
72
|
+
} | null;
|
|
73
|
+
}
|
|
74
|
+
export interface ReceiptProjectionBaseV0 {
|
|
75
|
+
readonly schema: ReceiptProjectionSchemaV0;
|
|
76
|
+
readonly v: ReceiptProjectionVersionV0;
|
|
77
|
+
readonly tier: ReceiptProjectionTierV0;
|
|
78
|
+
readonly receipt_id: ContentHashV0;
|
|
79
|
+
readonly content_hash: ContentHashV0;
|
|
80
|
+
readonly contract_revision: ContentHashV0;
|
|
81
|
+
readonly status: ReceiptVerdictStatusV0 | null;
|
|
82
|
+
readonly signer: ReceiptProjectionSignerV0;
|
|
83
|
+
readonly freshness: ReceiptProjectionFreshnessV0;
|
|
84
|
+
}
|
|
85
|
+
export interface ReceiptOwnerProjectionV0 extends ReceiptProjectionBaseV0 {
|
|
86
|
+
readonly tier: "owner";
|
|
87
|
+
readonly responsibility_id: string;
|
|
88
|
+
readonly role: string;
|
|
89
|
+
readonly composition: ReceiptSubscriberCompositionProjectionV0;
|
|
90
|
+
readonly token_truth: ReceiptSubscriberTokenTruthProjectionV0;
|
|
91
|
+
readonly verdict: ReceiptOwnerVerdictProjectionV0;
|
|
92
|
+
readonly proof: ReceiptProofInspectionV0;
|
|
93
|
+
}
|
|
94
|
+
export interface ReceiptSubscriberProjectionV0 extends ReceiptProjectionBaseV0 {
|
|
95
|
+
readonly tier: "subscriber";
|
|
96
|
+
readonly responsibility_id: string;
|
|
97
|
+
readonly role: string;
|
|
98
|
+
readonly composition: ReceiptSubscriberCompositionProjectionV0;
|
|
99
|
+
readonly token_truth: ReceiptSubscriberTokenTruthProjectionV0;
|
|
100
|
+
}
|
|
101
|
+
export interface ReceiptPublicProjectionV0 extends ReceiptProjectionBaseV0 {
|
|
102
|
+
readonly tier: "public";
|
|
103
|
+
readonly composition: ReceiptPublicCompositionProjectionV0;
|
|
104
|
+
readonly token_truth: ReceiptPublicTokenTruthProjectionV0;
|
|
105
|
+
}
|
|
106
|
+
export type ReceiptProjectionV0 = ReceiptOwnerProjectionV0 | ReceiptSubscriberProjectionV0 | ReceiptPublicProjectionV0;
|
|
107
|
+
export type ReceiptProjectionResultV0 = {
|
|
108
|
+
readonly ok: true;
|
|
109
|
+
readonly tier: ReceiptProjectionTierV0;
|
|
110
|
+
readonly projection: ReceiptProjectionV0;
|
|
111
|
+
} | {
|
|
112
|
+
readonly ok: false;
|
|
113
|
+
readonly tier: ReceiptProjectionTierV0 | null;
|
|
114
|
+
readonly errors: readonly string[];
|
|
115
|
+
readonly projection: null;
|
|
116
|
+
};
|
|
117
|
+
export declare function projectReceiptV0(input: ProjectReceiptInputV0): ReceiptProjectionResultV0;
|
|
118
|
+
export declare function projectReceiptProofV0(input: ProjectReceiptProofInputV0): ReceiptProjectionResultV0;
|
|
119
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/projection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC5B,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,yBAAyB,EACpC,8BAAuC,CAAC;AAC1C,eAAO,MAAM,0BAA0B,EAAG,CAAU,CAAC;AACrD,eAAO,MAAM,2BAA2B,4CAI9B,CAAC;AAEX,MAAM,MAAM,yBAAyB,GAAG,OAAO,yBAAyB,CAAC;AACzE,MAAM,MAAM,0BAA0B,GAAG,OAAO,0BAA0B,CAAC;AAC3E,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAC;CACjD;AAED,MAAM,MAAM,yBAAyB,GACjC;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACx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B,gBAAgB,CAC9B,KAAK,EAAE,qBAAqB,GAC3B,yBAAyB,CA2B3B;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,0BAA0B,GAChC,yBAAyB,CA6B3B"}
|
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RECEIPT_PROJECTION_TIERS_V0 = exports.RECEIPT_PROJECTION_VERSION = exports.RECEIPT_PROJECTION_SCHEMA = void 0;
|
|
4
|
+
exports.projectReceiptV0 = projectReceiptV0;
|
|
5
|
+
exports.projectReceiptProofV0 = projectReceiptProofV0;
|
|
6
|
+
const receipt_1 = require("../receipt");
|
|
7
|
+
exports.RECEIPT_PROJECTION_SCHEMA = "openprose.receipt.projection";
|
|
8
|
+
exports.RECEIPT_PROJECTION_VERSION = 0;
|
|
9
|
+
exports.RECEIPT_PROJECTION_TIERS_V0 = [
|
|
10
|
+
"owner",
|
|
11
|
+
"subscriber",
|
|
12
|
+
"public",
|
|
13
|
+
];
|
|
14
|
+
const CONTENT_HASH_PATTERN = /^sha256:[a-f0-9]{64}$/;
|
|
15
|
+
const ISO_INSTANT_PATTERN = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/;
|
|
16
|
+
const PROJECTION_TIERS = new Set(exports.RECEIPT_PROJECTION_TIERS_V0);
|
|
17
|
+
const RECEIPT_STATUSES = new Set([
|
|
18
|
+
"up",
|
|
19
|
+
"drifting",
|
|
20
|
+
"down",
|
|
21
|
+
"blocked",
|
|
22
|
+
]);
|
|
23
|
+
const OPENROUTER_SECRET_PREFIX = ["sk", "or"].join("-");
|
|
24
|
+
const PRIVATE_OUTPUT_KEYS = new Set([
|
|
25
|
+
"customer_payload",
|
|
26
|
+
"evidence_payload",
|
|
27
|
+
"judge_rationale",
|
|
28
|
+
"memo_key",
|
|
29
|
+
"provider_norm",
|
|
30
|
+
"rationale",
|
|
31
|
+
"raw_evidence",
|
|
32
|
+
"raw_evidence_payload",
|
|
33
|
+
"run_id",
|
|
34
|
+
"tags",
|
|
35
|
+
]);
|
|
36
|
+
const SECRET_SHAPED_PATTERNS = [
|
|
37
|
+
/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i,
|
|
38
|
+
/\bBearer\s+[A-Za-z0-9._-]{8,}\b/i,
|
|
39
|
+
new RegExp(`\\b${escapeRegex(OPENROUTER_SECRET_PREFIX)}-[A-Za-z0-9._-]{8,}\\b`),
|
|
40
|
+
/\bapi[_-]?key[_:/= -]+[A-Za-z0-9._-]{8,}\b/i,
|
|
41
|
+
/\b(?:secret|token|password|credential|authorization)[_:/= -]+[A-Za-z0-9._-]{8,}\b/i,
|
|
42
|
+
/\bhttps?:\/\/(?:localhost|127(?:\.\d{1,3}){3}|10(?:\.\d{1,3}){3}|192\.168(?:\.\d{1,3}){2}|172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2}|[^/\s?#]+(?:\.internal|\.local))(?::\d+)?(?:[/?#][^\s]*)?/i,
|
|
43
|
+
/\bhttps?:\/\/[^\s?#]+[/?#][^\s]*(?:token|secret|signature|credential|password)=/i,
|
|
44
|
+
];
|
|
45
|
+
function projectReceiptV0(input) {
|
|
46
|
+
const tier = normalizeTier(input.tier);
|
|
47
|
+
if (tier === null) {
|
|
48
|
+
return failProjection(null, ["unknown projection tier"]);
|
|
49
|
+
}
|
|
50
|
+
const proof = (0, receipt_1.inspectReceiptProofV0)(input.receipt);
|
|
51
|
+
if (!proof.ok) {
|
|
52
|
+
return failProjection(tier, ["receipt failed verification"]);
|
|
53
|
+
}
|
|
54
|
+
const normalized = normalizeProof(proof);
|
|
55
|
+
if (!normalized.ok) {
|
|
56
|
+
return failProjection(tier, normalized.errors);
|
|
57
|
+
}
|
|
58
|
+
const status = readReceiptStatus(input.receipt);
|
|
59
|
+
if (status === null) {
|
|
60
|
+
return failProjection(tier, ["receipt status is malformed"]);
|
|
61
|
+
}
|
|
62
|
+
return projectNormalizedProof({
|
|
63
|
+
tier,
|
|
64
|
+
proof: normalized.proof,
|
|
65
|
+
status,
|
|
66
|
+
verdict: readOwnerVerdict(input.receipt, status),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function projectReceiptProofV0(input) {
|
|
70
|
+
const tier = normalizeTier(input.tier);
|
|
71
|
+
if (tier === null) {
|
|
72
|
+
return failProjection(null, ["unknown projection tier"]);
|
|
73
|
+
}
|
|
74
|
+
const normalized = normalizeProof(input.proof);
|
|
75
|
+
if (!normalized.ok) {
|
|
76
|
+
return failProjection(tier, normalized.errors);
|
|
77
|
+
}
|
|
78
|
+
const status = input.status === undefined || input.status === null
|
|
79
|
+
? null
|
|
80
|
+
: normalizeStatus(input.status);
|
|
81
|
+
if (input.status !== undefined && input.status !== null && status === null) {
|
|
82
|
+
return failProjection(tier, ["receipt status is malformed"]);
|
|
83
|
+
}
|
|
84
|
+
return projectNormalizedProof({
|
|
85
|
+
tier,
|
|
86
|
+
proof: normalized.proof,
|
|
87
|
+
status,
|
|
88
|
+
verdict: {
|
|
89
|
+
status,
|
|
90
|
+
confidence: null,
|
|
91
|
+
blocked: null,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function projectNormalizedProof(input) {
|
|
96
|
+
const base = {
|
|
97
|
+
schema: exports.RECEIPT_PROJECTION_SCHEMA,
|
|
98
|
+
v: exports.RECEIPT_PROJECTION_VERSION,
|
|
99
|
+
tier: input.tier,
|
|
100
|
+
receipt_id: input.proof.content_hash,
|
|
101
|
+
content_hash: input.proof.content_hash,
|
|
102
|
+
contract_revision: input.proof.contract_revision,
|
|
103
|
+
status: input.status,
|
|
104
|
+
signer: input.proof.signer,
|
|
105
|
+
freshness: input.proof.freshness,
|
|
106
|
+
};
|
|
107
|
+
const projection = buildProjection(input.tier, base, input.proof, input.verdict);
|
|
108
|
+
if ((input.tier === "public" || input.tier === "subscriber") &&
|
|
109
|
+
hasPublicProjectionLeak(projection)) {
|
|
110
|
+
return failProjection(input.tier, ["projection would expose secret-shaped data"]);
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
ok: true,
|
|
114
|
+
tier: input.tier,
|
|
115
|
+
projection,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function buildProjection(tier, base, proof, verdict) {
|
|
119
|
+
switch (tier) {
|
|
120
|
+
case "owner":
|
|
121
|
+
return {
|
|
122
|
+
...base,
|
|
123
|
+
tier,
|
|
124
|
+
responsibility_id: proof.responsibility_id,
|
|
125
|
+
role: proof.role,
|
|
126
|
+
composition: proof.composition,
|
|
127
|
+
token_truth: proof.token_truth,
|
|
128
|
+
verdict,
|
|
129
|
+
proof: proof.inspection,
|
|
130
|
+
};
|
|
131
|
+
case "subscriber":
|
|
132
|
+
return {
|
|
133
|
+
...base,
|
|
134
|
+
tier,
|
|
135
|
+
responsibility_id: proof.responsibility_id,
|
|
136
|
+
role: proof.role,
|
|
137
|
+
composition: proof.composition,
|
|
138
|
+
token_truth: proof.token_truth,
|
|
139
|
+
};
|
|
140
|
+
case "public":
|
|
141
|
+
return {
|
|
142
|
+
...base,
|
|
143
|
+
tier,
|
|
144
|
+
composition: {
|
|
145
|
+
consumed_receipt_count: proof.composition.consumed_receipt_count,
|
|
146
|
+
consumed_receipts: proof.composition.consumed_receipts.map((pin) => ({
|
|
147
|
+
upstream_content_hash: pin.upstream_content_hash,
|
|
148
|
+
contract_revision: pin.contract_revision,
|
|
149
|
+
acceptable_signer_set_count: pin.acceptable_signer_set.length,
|
|
150
|
+
})),
|
|
151
|
+
cycle_checked: proof.composition.cycle_checked,
|
|
152
|
+
},
|
|
153
|
+
token_truth: {
|
|
154
|
+
fresh: proof.token_truth.fresh,
|
|
155
|
+
reused: proof.token_truth.reused,
|
|
156
|
+
role: proof.token_truth.role,
|
|
157
|
+
surprise_cause: proof.token_truth.surprise_cause,
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function normalizeTier(tier) {
|
|
163
|
+
return PROJECTION_TIERS.has(tier) ? tier : null;
|
|
164
|
+
}
|
|
165
|
+
function normalizeProof(value) {
|
|
166
|
+
const errors = [];
|
|
167
|
+
const proof = expectRecord(value, "receipt proof", errors);
|
|
168
|
+
if (proof === undefined) {
|
|
169
|
+
return { ok: false, errors };
|
|
170
|
+
}
|
|
171
|
+
if (proof["ok"] !== true) {
|
|
172
|
+
errors.push("receipt proof must be verified");
|
|
173
|
+
}
|
|
174
|
+
const proofErrors = proof["errors"];
|
|
175
|
+
if (!Array.isArray(proofErrors) ||
|
|
176
|
+
proofErrors.length > 0 ||
|
|
177
|
+
proofErrors.some((item) => typeof item !== "string")) {
|
|
178
|
+
errors.push("receipt proof errors must be empty");
|
|
179
|
+
}
|
|
180
|
+
if (proof["schema"] !== receipt_1.RECEIPT_SCHEMA) {
|
|
181
|
+
errors.push("receipt proof schema is malformed");
|
|
182
|
+
}
|
|
183
|
+
if (proof["v"] !== receipt_1.RECEIPT_VERSION) {
|
|
184
|
+
errors.push("receipt proof version is malformed");
|
|
185
|
+
}
|
|
186
|
+
const contentHash = readContentHash(proof, "content_hash", errors);
|
|
187
|
+
const contractRevision = readContentHash(proof, "contract_revision", errors);
|
|
188
|
+
const responsibilityId = readNonEmptyString(proof, "responsibility_id", errors);
|
|
189
|
+
const role = readNonEmptyString(proof, "role", errors);
|
|
190
|
+
const signer = normalizeSigner(proof["signer"], errors);
|
|
191
|
+
const freshness = normalizeFreshness(proof["freshness"], errors);
|
|
192
|
+
const composition = normalizeComposition(proof["composition"], errors);
|
|
193
|
+
const tokenTruth = normalizeTokenTruth(proof["token_truth"], errors);
|
|
194
|
+
if (errors.length > 0 ||
|
|
195
|
+
contentHash === null ||
|
|
196
|
+
contractRevision === null ||
|
|
197
|
+
responsibilityId === null ||
|
|
198
|
+
role === null ||
|
|
199
|
+
signer === null ||
|
|
200
|
+
freshness === null ||
|
|
201
|
+
composition === null ||
|
|
202
|
+
tokenTruth === null) {
|
|
203
|
+
return { ok: false, errors };
|
|
204
|
+
}
|
|
205
|
+
const inspection = {
|
|
206
|
+
ok: true,
|
|
207
|
+
errors: [],
|
|
208
|
+
schema: receipt_1.RECEIPT_SCHEMA,
|
|
209
|
+
v: receipt_1.RECEIPT_VERSION,
|
|
210
|
+
content_hash: contentHash,
|
|
211
|
+
contract_revision: contractRevision,
|
|
212
|
+
responsibility_id: responsibilityId,
|
|
213
|
+
role,
|
|
214
|
+
signer,
|
|
215
|
+
freshness: {
|
|
216
|
+
as_of: freshness.as_of,
|
|
217
|
+
next_forecast_recheck: freshness.next_forecast_recheck,
|
|
218
|
+
transitive_freshness_policy_ref: freshness.transitive_freshness_policy_ref,
|
|
219
|
+
consumed_freshness_evaluated_count: freshness.consumed_freshness_evaluated_count,
|
|
220
|
+
},
|
|
221
|
+
composition: {
|
|
222
|
+
consumed_receipt_count: composition.consumed_receipt_count,
|
|
223
|
+
consumed_receipts: composition.consumed_receipts,
|
|
224
|
+
cycle_checked: composition.cycle_checked,
|
|
225
|
+
},
|
|
226
|
+
token_truth: {
|
|
227
|
+
fresh: tokenTruth.fresh,
|
|
228
|
+
reused: tokenTruth.reused,
|
|
229
|
+
provider: tokenTruth.provider,
|
|
230
|
+
model: tokenTruth.model,
|
|
231
|
+
role: tokenTruth.role,
|
|
232
|
+
surprise_cause: tokenTruth.surprise_cause,
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
return {
|
|
236
|
+
ok: true,
|
|
237
|
+
proof: {
|
|
238
|
+
inspection,
|
|
239
|
+
content_hash: contentHash,
|
|
240
|
+
contract_revision: contractRevision,
|
|
241
|
+
responsibility_id: responsibilityId,
|
|
242
|
+
role,
|
|
243
|
+
signer,
|
|
244
|
+
freshness,
|
|
245
|
+
composition,
|
|
246
|
+
token_truth: tokenTruth,
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function normalizeSigner(value, errors) {
|
|
251
|
+
const signer = expectRecord(value, "receipt proof signer", errors);
|
|
252
|
+
if (signer === undefined) {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
const kind = readString(signer, "kind");
|
|
256
|
+
const scheme = readNonEmptyString(signer, "scheme", errors);
|
|
257
|
+
if (scheme === null) {
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
if (kind === "null" && scheme === "none") {
|
|
261
|
+
return { kind, scheme };
|
|
262
|
+
}
|
|
263
|
+
if (kind === "signed" && scheme !== "none") {
|
|
264
|
+
return { kind, scheme };
|
|
265
|
+
}
|
|
266
|
+
errors.push("receipt proof signer is malformed");
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
function normalizeFreshness(value, errors) {
|
|
270
|
+
const freshness = expectRecord(value, "receipt proof freshness", errors);
|
|
271
|
+
if (freshness === undefined) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
const asOf = readIsoInstant(freshness, "as_of", errors);
|
|
275
|
+
const nextForecastRecheck = readIsoInstant(freshness, "next_forecast_recheck", errors);
|
|
276
|
+
const transitiveRef = readNullableString(freshness, "transitive_freshness_policy_ref", errors);
|
|
277
|
+
const consumedCount = readNonNegativeInteger(freshness, "consumed_freshness_evaluated_count", errors);
|
|
278
|
+
if (asOf === null || nextForecastRecheck === null || consumedCount === null) {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
as_of: asOf,
|
|
283
|
+
next_forecast_recheck: nextForecastRecheck,
|
|
284
|
+
transitive_freshness_policy_ref: transitiveRef,
|
|
285
|
+
consumed_freshness_evaluated_count: consumedCount,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function normalizeComposition(value, errors) {
|
|
289
|
+
const composition = expectRecord(value, "receipt proof composition", errors);
|
|
290
|
+
if (composition === undefined) {
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
const consumedCount = readNonNegativeInteger(composition, "consumed_receipt_count", errors);
|
|
294
|
+
const cycleChecked = readBoolean(composition, "cycle_checked", errors);
|
|
295
|
+
const consumedReceiptsValue = composition["consumed_receipts"];
|
|
296
|
+
if (!Array.isArray(consumedReceiptsValue)) {
|
|
297
|
+
errors.push("receipt proof composition consumed receipts are malformed");
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
const consumedReceipts = [];
|
|
301
|
+
for (const item of consumedReceiptsValue) {
|
|
302
|
+
const pin = expectRecord(item, "receipt proof composition pin", errors);
|
|
303
|
+
if (pin === undefined) {
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
const upstreamContentHash = readContentHash(pin, "upstream_content_hash", errors);
|
|
307
|
+
const contractRevision = readContentHash(pin, "contract_revision", errors);
|
|
308
|
+
const acceptableSignerSet = readStringArray(pin, "acceptable_signer_set", errors);
|
|
309
|
+
if (upstreamContentHash !== null &&
|
|
310
|
+
contractRevision !== null &&
|
|
311
|
+
acceptableSignerSet !== null) {
|
|
312
|
+
consumedReceipts.push({
|
|
313
|
+
upstream_content_hash: upstreamContentHash,
|
|
314
|
+
contract_revision: contractRevision,
|
|
315
|
+
acceptable_signer_set: acceptableSignerSet,
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (consumedCount === null || cycleChecked === null) {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
if (consumedReceipts.length !== consumedCount) {
|
|
323
|
+
errors.push("receipt proof composition count is malformed");
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
return {
|
|
327
|
+
consumed_receipt_count: consumedCount,
|
|
328
|
+
consumed_receipts: consumedReceipts,
|
|
329
|
+
cycle_checked: cycleChecked,
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
function normalizeTokenTruth(value, errors) {
|
|
333
|
+
const tokenTruth = expectRecord(value, "receipt proof token truth", errors);
|
|
334
|
+
if (tokenTruth === undefined) {
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
const fresh = readNonNegativeInteger(tokenTruth, "fresh", errors);
|
|
338
|
+
const reused = readNonNegativeInteger(tokenTruth, "reused", errors);
|
|
339
|
+
const provider = readNonEmptyString(tokenTruth, "provider", errors);
|
|
340
|
+
const model = readNonEmptyString(tokenTruth, "model", errors);
|
|
341
|
+
const role = readNonEmptyString(tokenTruth, "role", errors);
|
|
342
|
+
const surpriseCause = readNonEmptyString(tokenTruth, "surprise_cause", errors);
|
|
343
|
+
if (fresh === null ||
|
|
344
|
+
reused === null ||
|
|
345
|
+
provider === null ||
|
|
346
|
+
model === null ||
|
|
347
|
+
role === null ||
|
|
348
|
+
surpriseCause === null) {
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
return {
|
|
352
|
+
fresh,
|
|
353
|
+
reused,
|
|
354
|
+
provider,
|
|
355
|
+
model,
|
|
356
|
+
role,
|
|
357
|
+
surprise_cause: surpriseCause,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
function readReceiptStatus(value) {
|
|
361
|
+
const receipt = isRecord(value) ? value : undefined;
|
|
362
|
+
const verdict = readRecord(receipt, "verdict");
|
|
363
|
+
return normalizeStatus(readString(verdict, "status"));
|
|
364
|
+
}
|
|
365
|
+
function normalizeStatus(value) {
|
|
366
|
+
return typeof value === "string" && RECEIPT_STATUSES.has(value)
|
|
367
|
+
? value
|
|
368
|
+
: null;
|
|
369
|
+
}
|
|
370
|
+
function readOwnerVerdict(value, status) {
|
|
371
|
+
const receipt = isRecord(value) ? value : undefined;
|
|
372
|
+
const verdict = readRecord(receipt, "verdict");
|
|
373
|
+
const confidence = readRecord(verdict, "confidence");
|
|
374
|
+
const blocked = readRecord(verdict, "blocked");
|
|
375
|
+
return {
|
|
376
|
+
status,
|
|
377
|
+
confidence: confidence === undefined
|
|
378
|
+
? null
|
|
379
|
+
: {
|
|
380
|
+
value: readNumber(confidence, "value"),
|
|
381
|
+
derivation_method: readString(confidence, "derivation_method"),
|
|
382
|
+
calibration_grade: readString(confidence, "calibration_grade"),
|
|
383
|
+
label_source: readString(confidence, "label_source"),
|
|
384
|
+
},
|
|
385
|
+
blocked: blocked === undefined
|
|
386
|
+
? null
|
|
387
|
+
: {
|
|
388
|
+
reason: readString(blocked, "reason"),
|
|
389
|
+
fix_target: readString(blocked, "fix_target"),
|
|
390
|
+
interrupt_cause: readString(blocked, "interrupt_cause"),
|
|
391
|
+
},
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
function hasPublicProjectionLeak(value) {
|
|
395
|
+
if (Array.isArray(value)) {
|
|
396
|
+
return value.some(hasPublicProjectionLeak);
|
|
397
|
+
}
|
|
398
|
+
if (isRecord(value)) {
|
|
399
|
+
return Object.entries(value).some(([key, item]) => isForbiddenOutputKey(key) || hasPublicProjectionLeak(item));
|
|
400
|
+
}
|
|
401
|
+
return typeof value === "string" && hasSecretShapedText(value);
|
|
402
|
+
}
|
|
403
|
+
function isForbiddenOutputKey(key) {
|
|
404
|
+
return PRIVATE_OUTPUT_KEYS.has(key.toLowerCase());
|
|
405
|
+
}
|
|
406
|
+
function hasSecretShapedText(value) {
|
|
407
|
+
return SECRET_SHAPED_PATTERNS.some((pattern) => pattern.test(value));
|
|
408
|
+
}
|
|
409
|
+
function failProjection(tier, errors) {
|
|
410
|
+
return {
|
|
411
|
+
ok: false,
|
|
412
|
+
tier,
|
|
413
|
+
errors,
|
|
414
|
+
projection: null,
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
function expectRecord(value, label, errors) {
|
|
418
|
+
if (!isRecord(value)) {
|
|
419
|
+
errors.push(`${label} is malformed`);
|
|
420
|
+
return undefined;
|
|
421
|
+
}
|
|
422
|
+
return value;
|
|
423
|
+
}
|
|
424
|
+
function readRecord(record, key) {
|
|
425
|
+
const value = record?.[key];
|
|
426
|
+
return isRecord(value) ? value : undefined;
|
|
427
|
+
}
|
|
428
|
+
function readString(record, key) {
|
|
429
|
+
const value = record?.[key];
|
|
430
|
+
return typeof value === "string" ? value : null;
|
|
431
|
+
}
|
|
432
|
+
function readNonEmptyString(record, key, errors) {
|
|
433
|
+
const value = readString(record, key);
|
|
434
|
+
if (value === null || value.length === 0) {
|
|
435
|
+
errors.push(`${key} is malformed`);
|
|
436
|
+
return null;
|
|
437
|
+
}
|
|
438
|
+
return value;
|
|
439
|
+
}
|
|
440
|
+
function readNullableString(record, key, errors) {
|
|
441
|
+
const value = record[key];
|
|
442
|
+
if (value === null) {
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
if (typeof value === "string" && value.length > 0) {
|
|
446
|
+
return value;
|
|
447
|
+
}
|
|
448
|
+
errors.push(`${key} is malformed`);
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
451
|
+
function readNumber(record, key) {
|
|
452
|
+
const value = record?.[key];
|
|
453
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
454
|
+
}
|
|
455
|
+
function readNonNegativeInteger(record, key, errors) {
|
|
456
|
+
const value = readNumber(record, key);
|
|
457
|
+
if (value === null || !Number.isInteger(value) || value < 0) {
|
|
458
|
+
errors.push(`${key} is malformed`);
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
461
|
+
return value;
|
|
462
|
+
}
|
|
463
|
+
function readBoolean(record, key, errors) {
|
|
464
|
+
const value = record[key];
|
|
465
|
+
if (typeof value !== "boolean") {
|
|
466
|
+
errors.push(`${key} is malformed`);
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
return value;
|
|
470
|
+
}
|
|
471
|
+
function readIsoInstant(record, key, errors) {
|
|
472
|
+
const value = readNonEmptyString(record, key, errors);
|
|
473
|
+
if (value === null) {
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
476
|
+
if (!ISO_INSTANT_PATTERN.test(value)) {
|
|
477
|
+
errors.push(`${key} is malformed`);
|
|
478
|
+
return null;
|
|
479
|
+
}
|
|
480
|
+
return value;
|
|
481
|
+
}
|
|
482
|
+
function readContentHash(record, key, errors) {
|
|
483
|
+
const value = readNonEmptyString(record, key, errors);
|
|
484
|
+
if (value === null) {
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
487
|
+
if (!CONTENT_HASH_PATTERN.test(value)) {
|
|
488
|
+
errors.push(`${key} is malformed`);
|
|
489
|
+
return null;
|
|
490
|
+
}
|
|
491
|
+
return value;
|
|
492
|
+
}
|
|
493
|
+
function readStringArray(record, key, errors) {
|
|
494
|
+
const value = record[key];
|
|
495
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string")) {
|
|
496
|
+
errors.push(`${key} is malformed`);
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
499
|
+
return value;
|
|
500
|
+
}
|
|
501
|
+
function isRecord(value) {
|
|
502
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
503
|
+
}
|
|
504
|
+
function escapeRegex(value) {
|
|
505
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
506
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type ForecastScheduleStateV0 } from "../forecast";
|
|
2
|
+
import { type CompiledEvidencePlan } from "../evidence-plan";
|
|
3
|
+
import { type PolicyLiveObservableV0 } from "../policy";
|
|
4
|
+
import { type ContentHashV0, type ReceiptRecheckKindV0, type ReceiptV0 } from "../receipt";
|
|
5
|
+
import type { ReactorCreateInputV0, ReactorIngestResultV0, ReactorRegistrySnapshotV0, ReactorTickResultV0 } from "../sdk";
|
|
6
|
+
export interface ReactorRuntimeV0 {
|
|
7
|
+
readonly ingest: (event: unknown) => ReactorIngestResultV0;
|
|
8
|
+
readonly tick: (as_of?: string) => ReactorTickResultV0;
|
|
9
|
+
readonly receipts: () => readonly ReceiptV0[];
|
|
10
|
+
readonly registry: () => ReactorRegistrySnapshotV0;
|
|
11
|
+
}
|
|
12
|
+
interface ReactorTurnBaseV0 {
|
|
13
|
+
readonly contract_revision?: ContentHashV0;
|
|
14
|
+
readonly cold_start?: ColdStartPolicyInputV0;
|
|
15
|
+
readonly evidence?: readonly ReactorEvidenceInputV0[];
|
|
16
|
+
readonly dependency_receipts?: readonly ReceiptV0[];
|
|
17
|
+
}
|
|
18
|
+
export interface ContractSummaryProjectionV0 {
|
|
19
|
+
readonly summary: string;
|
|
20
|
+
readonly source_contract_revision: ContentHashV0;
|
|
21
|
+
readonly projection_hash: ContentHashV0;
|
|
22
|
+
}
|
|
23
|
+
export interface ColdStartPolicyInputV0 {
|
|
24
|
+
readonly contract_revision: ContentHashV0;
|
|
25
|
+
readonly contract_summary: ContractSummaryProjectionV0;
|
|
26
|
+
readonly no_anchor: boolean;
|
|
27
|
+
readonly live_observables: readonly PolicyLiveObservableV0[];
|
|
28
|
+
readonly compiled_evidence_plan: CompiledEvidencePlan;
|
|
29
|
+
readonly forecast_schedule: ForecastScheduleStateV0;
|
|
30
|
+
readonly policy_artifact_namespace?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ReactorEvidenceInputV0 {
|
|
33
|
+
readonly source_id: string;
|
|
34
|
+
readonly receipt?: ReceiptV0;
|
|
35
|
+
readonly content_hash?: ContentHashV0;
|
|
36
|
+
readonly payload?: unknown;
|
|
37
|
+
}
|
|
38
|
+
export interface ReactorRealInputTurnV0 extends ReactorTurnBaseV0 {
|
|
39
|
+
readonly kind: "real-input";
|
|
40
|
+
}
|
|
41
|
+
export interface ReactorForecastRecheckTurnV0 extends ReactorTurnBaseV0 {
|
|
42
|
+
readonly kind: "forecast-recheck";
|
|
43
|
+
readonly recheck_kind: ReceiptRecheckKindV0;
|
|
44
|
+
}
|
|
45
|
+
export interface ReactorEscalationTurnV0 extends ReactorTurnBaseV0 {
|
|
46
|
+
readonly kind: "escalation";
|
|
47
|
+
readonly interrupt_cause: "needs-judgment" | "needs-input" | "contract-declared";
|
|
48
|
+
readonly reason: string;
|
|
49
|
+
readonly fix_target: string;
|
|
50
|
+
}
|
|
51
|
+
export type ReactorTurnInputV0 = ReactorRealInputTurnV0 | ReactorForecastRecheckTurnV0 | ReactorEscalationTurnV0;
|
|
52
|
+
export declare function createRuntimeReactorV0(input: ReactorCreateInputV0): ReactorRuntimeV0;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reactor/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,oBAAoB,EAG1B,MAAM,kBAAkB,CAAC;AAM1B,OAAO,EAQL,KAAK,sBAAsB,EAG5B,MAAM,WAAW,CAAC;AACnB,OAAO,EAEL,KAAK,aAAa,EAGlB,KAAK,oBAAoB,EACzB,KAAK,SAAS,EAMf,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAEV,oBAAoB,EAEpB,qBAAqB,EAIrB,yBAAyB,EAEzB,mBAAmB,EACpB,MAAM,QAAQ,CAAC;AAEhB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,qBAAqB,CAAC;IAC3D,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,mBAAmB,CAAC;IACvD,QAAQ,CAAC,QAAQ,EAAE,MAAM,SAAS,SAAS,EAAE,CAAC;IAC9C,QAAQ,CAAC,QAAQ,EAAE,MAAM,yBAAyB,CAAC;CACpD;AAED,UAAU,iBAAiB;IACzB,QAAQ,CAAC,iBAAiB,CAAC,EAAE,aAAa,CAAC;IAC3C,QAAQ,CAAC,UAAU,CAAC,EAAE,sBAAsB,CAAC;IAC7C,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAC;IACtD,QAAQ,CAAC,mBAAmB,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;CACrD;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;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