@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.
Files changed (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +231 -0
  3. package/dist/adapters/agent-sdk-passthrough/index.d.ts +8 -0
  4. package/dist/adapters/agent-sdk-passthrough/index.d.ts.map +1 -0
  5. package/dist/adapters/agent-sdk-passthrough/index.js +25 -0
  6. package/dist/adapters/clock-system/index.d.ts +9 -0
  7. package/dist/adapters/clock-system/index.d.ts.map +1 -0
  8. package/dist/adapters/clock-system/index.js +39 -0
  9. package/dist/adapters/connector-static/index.d.ts +11 -0
  10. package/dist/adapters/connector-static/index.d.ts.map +1 -0
  11. package/dist/adapters/connector-static/index.js +35 -0
  12. package/dist/adapters/event-sink-memory/index.d.ts +10 -0
  13. package/dist/adapters/event-sink-memory/index.d.ts.map +1 -0
  14. package/dist/adapters/event-sink-memory/index.js +20 -0
  15. package/dist/adapters/index.d.ts +10 -0
  16. package/dist/adapters/index.d.ts.map +1 -0
  17. package/dist/adapters/index.js +25 -0
  18. package/dist/adapters/json.d.ts +3 -0
  19. package/dist/adapters/json.d.ts.map +1 -0
  20. package/dist/adapters/json.js +61 -0
  21. package/dist/adapters/model-gateway-record-replay/index.d.ts +24 -0
  22. package/dist/adapters/model-gateway-record-replay/index.d.ts.map +1 -0
  23. package/dist/adapters/model-gateway-record-replay/index.js +55 -0
  24. package/dist/adapters/sandbox-null/index.d.ts +3 -0
  25. package/dist/adapters/sandbox-null/index.d.ts.map +1 -0
  26. package/dist/adapters/sandbox-null/index.js +8 -0
  27. package/dist/adapters/storage-fs/index.d.ts +14 -0
  28. package/dist/adapters/storage-fs/index.d.ts.map +1 -0
  29. package/dist/adapters/storage-fs/index.js +65 -0
  30. package/dist/adapters/storage-memory/index.d.ts +11 -0
  31. package/dist/adapters/storage-memory/index.d.ts.map +1 -0
  32. package/dist/adapters/storage-memory/index.js +34 -0
  33. package/dist/adapters/types.d.ts +22 -0
  34. package/dist/adapters/types.d.ts.map +1 -0
  35. package/dist/adapters/types.js +97 -0
  36. package/dist/composition/index.d.ts +79 -0
  37. package/dist/composition/index.d.ts.map +1 -0
  38. package/dist/composition/index.js +280 -0
  39. package/dist/cost/index.d.ts +49 -0
  40. package/dist/cost/index.d.ts.map +1 -0
  41. package/dist/cost/index.js +206 -0
  42. package/dist/evidence-plan/index.d.ts +57 -0
  43. package/dist/evidence-plan/index.d.ts.map +1 -0
  44. package/dist/evidence-plan/index.js +164 -0
  45. package/dist/forecast/index.d.ts +39 -0
  46. package/dist/forecast/index.d.ts.map +1 -0
  47. package/dist/forecast/index.js +119 -0
  48. package/dist/index.d.ts +14 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +29 -0
  51. package/dist/judge/index.d.ts +29 -0
  52. package/dist/judge/index.d.ts.map +1 -0
  53. package/dist/judge/index.js +138 -0
  54. package/dist/kernel/index.d.ts +170 -0
  55. package/dist/kernel/index.d.ts.map +1 -0
  56. package/dist/kernel/index.js +637 -0
  57. package/dist/memo/index.d.ts +59 -0
  58. package/dist/memo/index.d.ts.map +1 -0
  59. package/dist/memo/index.js +189 -0
  60. package/dist/policy/index.d.ts +249 -0
  61. package/dist/policy/index.d.ts.map +1 -0
  62. package/dist/policy/index.js +1463 -0
  63. package/dist/projection/index.d.ts +119 -0
  64. package/dist/projection/index.d.ts.map +1 -0
  65. package/dist/projection/index.js +506 -0
  66. package/dist/reactor/index.d.ts +54 -0
  67. package/dist/reactor/index.d.ts.map +1 -0
  68. package/dist/reactor/index.js +1861 -0
  69. package/dist/receipt/index.d.ts +190 -0
  70. package/dist/receipt/index.d.ts.map +1 -0
  71. package/dist/receipt/index.js +646 -0
  72. package/dist/sdk/exit-bundle.d.ts +144 -0
  73. package/dist/sdk/exit-bundle.d.ts.map +1 -0
  74. package/dist/sdk/exit-bundle.js +1034 -0
  75. package/dist/sdk/index.d.ts +201 -0
  76. package/dist/sdk/index.d.ts.map +1 -0
  77. package/dist/sdk/index.js +418 -0
  78. package/package.json +89 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./receipt"), exports);
18
+ __exportStar(require("./cost"), exports);
19
+ __exportStar(require("./kernel"), exports);
20
+ __exportStar(require("./evidence-plan"), exports);
21
+ __exportStar(require("./memo"), exports);
22
+ __exportStar(require("./forecast"), exports);
23
+ __exportStar(require("./sdk"), exports);
24
+ __exportStar(require("./reactor"), exports);
25
+ __exportStar(require("./judge"), exports);
26
+ __exportStar(require("./adapters"), exports);
27
+ __exportStar(require("./policy"), exports);
28
+ __exportStar(require("./composition"), exports);
29
+ __exportStar(require("./projection"), exports);
@@ -0,0 +1,29 @@
1
+ import type { ContentHashV0, ReceiptEventCauseV0, ReceiptRecheckKindV0, ReceiptVerdictV0 } from "../receipt";
2
+ import type { ReactorModelGatewayAdapterV0, ReactorModelGatewayUsageV0 } from "../sdk";
3
+ export type ReactorJudgeDepthV0 = "shallow" | "ensemble";
4
+ export interface ReactorJudgeEvidenceInputV0 {
5
+ readonly source_id: string;
6
+ readonly content_hash: ContentHashV0;
7
+ }
8
+ export interface ShallowJudgeV0Input {
9
+ readonly responsibility_id: string;
10
+ readonly contract_revision: ContentHashV0;
11
+ readonly policy_artifact_namespace: string;
12
+ readonly policy_artifact_revision: string;
13
+ readonly policy_artifact_content_hash?: ContentHashV0;
14
+ readonly evidence: readonly ReactorJudgeEvidenceInputV0[];
15
+ readonly as_of: string;
16
+ readonly event_cause: ReceiptEventCauseV0;
17
+ readonly recheck_kind?: ReceiptRecheckKindV0;
18
+ readonly depth: ReactorJudgeDepthV0;
19
+ readonly modelGateway: Pick<ReactorModelGatewayAdapterV0, "invoke">;
20
+ }
21
+ export interface ShallowJudgeV0Result {
22
+ readonly verdict: ReceiptVerdictV0;
23
+ readonly cost_tags: {
24
+ readonly tags: readonly string[];
25
+ };
26
+ readonly model_usage: ReactorModelGatewayUsageV0;
27
+ }
28
+ export declare function runShallowJudgeV0(input: ShallowJudgeV0Input): ShallowJudgeV0Result;
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/judge/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,mBAAmB,EACnB,oBAAoB,EAEpB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACV,4BAA4B,EAE5B,0BAA0B,EAC3B,MAAM,QAAQ,CAAC;AAEhB,MAAM,MAAM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]);
10
+ const INTERRUPT_CAUSES = new Set([
11
+ "needs-judgment",
12
+ "needs-input",
13
+ "contract-declared",
14
+ ]);
15
+ function runShallowJudgeV0(input) {
16
+ if (input.depth === "ensemble") {
17
+ throw new Error("not-implemented-in-v0.1");
18
+ }
19
+ if (input.depth !== "shallow") {
20
+ throw new Error("judge depth must be shallow or ensemble");
21
+ }
22
+ const response = input.modelGateway.invoke({
23
+ kind: "judge",
24
+ payload: {
25
+ schema: "openprose.reactor.judge.request",
26
+ v: 0,
27
+ responsibility_id: input.responsibility_id,
28
+ contract_revision: input.contract_revision,
29
+ policy_artifact_namespace: input.policy_artifact_namespace,
30
+ policy_artifact_revision: input.policy_artifact_revision,
31
+ ...(input.policy_artifact_content_hash === undefined
32
+ ? {}
33
+ : { policy_artifact_content_hash: input.policy_artifact_content_hash }),
34
+ evidence: input.evidence,
35
+ as_of: input.as_of,
36
+ event_cause: input.event_cause,
37
+ ...(input.recheck_kind === undefined
38
+ ? {}
39
+ : { recheck_kind: input.recheck_kind }),
40
+ depth: input.depth,
41
+ },
42
+ });
43
+ return {
44
+ verdict: readVerdict(response.payload),
45
+ cost_tags: {
46
+ tags: readCostTags(response.payload),
47
+ },
48
+ model_usage: readUsage(response),
49
+ };
50
+ }
51
+ function readVerdict(payload) {
52
+ const record = isRecord(payload) ? payload : {};
53
+ const status = readStatus(record["status"]);
54
+ const confidenceRecord = isRecord(record["confidence"])
55
+ ? record["confidence"]
56
+ : {};
57
+ const confidenceValue = readUnitInterval(confidenceRecord["value"]) ?? 0;
58
+ const derivationMethod = readNonEmptyString(confidenceRecord["derivation_method"]) ??
59
+ "shallow-model-gateway";
60
+ const labelSource = readNonEmptyString(confidenceRecord["label_source"]) ?? "no-anchor-v0.1";
61
+ const blocked = readBlocked(status, record["blocked"]);
62
+ return {
63
+ status,
64
+ confidence: {
65
+ value: confidenceValue,
66
+ derivation_method: derivationMethod,
67
+ calibration_grade: "none",
68
+ label_source: labelSource,
69
+ },
70
+ ...(blocked === undefined ? {} : { blocked }),
71
+ };
72
+ }
73
+ function readStatus(value) {
74
+ return typeof value === "string" && VERDICT_STATUSES.has(value)
75
+ ? value
76
+ : "blocked";
77
+ }
78
+ function readBlocked(status, value) {
79
+ if (status !== "blocked") {
80
+ return undefined;
81
+ }
82
+ const record = isRecord(value) ? value : {};
83
+ const interruptCause = record["interrupt_cause"];
84
+ return {
85
+ reason: readNonEmptyString(record["reason"]) ??
86
+ "shallow judge returned blocked without a reason",
87
+ fix_target: readNonEmptyString(record["fix_target"]) ?? "author",
88
+ interrupt_cause: typeof interruptCause === "string" &&
89
+ INTERRUPT_CAUSES.has(interruptCause)
90
+ ? interruptCause
91
+ : "needs-judgment",
92
+ };
93
+ }
94
+ function readCostTags(payload) {
95
+ const record = isRecord(payload) ? payload : {};
96
+ const costTags = isRecord(record["cost_tags"]) ? record["cost_tags"] : {};
97
+ const tags = costTags["tags"];
98
+ const normalized = Array.isArray(tags)
99
+ ? tags.filter((tag) => typeof tag === "string" && tag.length > 0)
100
+ : [];
101
+ return ["shallow-judge", ...normalized];
102
+ }
103
+ function readUsage(response) {
104
+ const usage = response.usage;
105
+ if (usage === undefined) {
106
+ throw new Error("modelGateway.invoke usage is required for shallow judge token truth");
107
+ }
108
+ if (usage.provider.length === 0 ||
109
+ usage.model.length === 0 ||
110
+ !Number.isSafeInteger(usage.tokens.fresh) ||
111
+ usage.tokens.fresh < 0 ||
112
+ !Number.isSafeInteger(usage.tokens.reused) ||
113
+ usage.tokens.reused < 0) {
114
+ throw new Error("modelGateway.invoke usage must carry provider, model, and token counts");
115
+ }
116
+ if (usage.tokens.fresh + usage.tokens.reused <= 0) {
117
+ throw new Error("modelGateway.invoke usage must record token work on a judge miss");
118
+ }
119
+ return usage;
120
+ }
121
+ function readUnitInterval(value) {
122
+ return typeof value === "number" &&
123
+ Number.isFinite(value) &&
124
+ value >= 0 &&
125
+ value <= 1
126
+ ? value
127
+ : undefined;
128
+ }
129
+ function readNonEmptyString(value) {
130
+ return typeof value === "string" && value.length > 0 ? value : undefined;
131
+ }
132
+ function isRecord(value) {
133
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
134
+ return false;
135
+ }
136
+ const prototype = Object.getPrototypeOf(value);
137
+ return prototype === Object.prototype || prototype === null;
138
+ }
@@ -0,0 +1,170 @@
1
+ import { type ContentHashV0, type ReceiptEventCauseV0, type ReceiptRoleV0, type ReceiptV0 } from "../receipt";
2
+ export declare const KERNEL_DAY_MS: number;
3
+ export declare const KERNEL_HOUR_MS: number;
4
+ export declare const KERNEL_BACKSTOPS: {
5
+ readonly maxPolicyAgeMs: number;
6
+ readonly maxPolicyAgeNoAnchorMs: number;
7
+ readonly minRecompileIntervalMs: number;
8
+ readonly maxCalibrationDivergenceMultiplier: 2;
9
+ readonly maxUnforcedDeepIntervalMs: number;
10
+ };
11
+ declare const VALIDATED_KERNEL_POLICY_ARTIFACT_TOKEN_BRAND: unique symbol;
12
+ declare const JUDGED_ACTIVATIONS_BRAND: unique symbol;
13
+ export declare const KERNEL_MAY_NEVER: readonly ["author judgment, policy, cadence, thresholds, or freshness functions", "call a model, agent SDK, or policy author to decide whether a backstop fired", "interpret *.prose.md or add new source syntax", "lengthen, disable, or silently reinterpret a fixed backstop", "quiesce on missing, stale, conflicting, or malformed safety-critical inputs", "let indeterminate persist silently past a backstop interval", "mutate the world or perform fulfillment side effects", "discover new evidence dependencies during shallow judging", "patch a memo key in place after deep roaming finds a new dependency", "treat a null signer as a cryptographic signature", "use wall-clock duration for rollback comparisons", "make cost.provider_norm part of a kernel decision", "emit fail-safe, indeterminate, or blocked outcomes as droppable annotations", "hide uncertainty by emitting confident up when calibration is degraded"];
14
+ export type KernelFactValue = string | number | boolean | null;
15
+ export type KernelFacts = Readonly<Record<string, KernelFactValue>>;
16
+ export type PredicateOutcome = "not-tripped" | "tripped" | "indeterminate";
17
+ export type IntervalBasis = "elapsed-time";
18
+ export type JudgedActivations = number & {
19
+ readonly [JUDGED_ACTIVATIONS_BRAND]: true;
20
+ };
21
+ export type KernelPredicateExpression = {
22
+ readonly kind: "equals";
23
+ readonly fact: string;
24
+ readonly value: KernelFactValue;
25
+ } | {
26
+ readonly kind: "not-equals";
27
+ readonly fact: string;
28
+ readonly value: KernelFactValue;
29
+ } | {
30
+ readonly kind: "greater-than-or-equal";
31
+ readonly fact: string;
32
+ readonly value: number;
33
+ } | {
34
+ readonly kind: "less-than";
35
+ readonly fact: string;
36
+ readonly value: number;
37
+ } | {
38
+ readonly kind: "and";
39
+ readonly predicates: readonly KernelPredicateExpression[];
40
+ } | {
41
+ readonly kind: "or";
42
+ readonly predicates: readonly KernelPredicateExpression[];
43
+ } | {
44
+ readonly kind: "not";
45
+ readonly predicate: KernelPredicateExpression;
46
+ };
47
+ export interface PredicateEvaluation {
48
+ readonly outcome: PredicateOutcome;
49
+ readonly reason?: string;
50
+ }
51
+ export type KernelBackstopName = "max_policy_age" | "max_policy_age_no_anchor" | "min_recompile_interval" | "max_calibration_divergence" | "max_calibration_evidence_age" | "warmup_length" | "max_unforced_deep_interval";
52
+ export type KernelBackstopAction = "force-policy-revalidation" | "force-policy-recompile" | "delay-recompile-for-min-interval" | "enter-degraded-calibration" | "no-last-known-good" | "force-deep-revalidation";
53
+ export interface KernelBackstopOutcome {
54
+ readonly backstop: KernelBackstopName;
55
+ readonly action: KernelBackstopAction;
56
+ readonly reason: string;
57
+ }
58
+ export interface KernelBackstopInput {
59
+ readonly token: ValidatedKernelPolicyArtifactToken;
60
+ readonly as_of: string;
61
+ readonly last_policy_revalidated_at: string;
62
+ readonly last_recompile_at: string;
63
+ readonly recompile_requested: boolean;
64
+ readonly observed_calibration_divergence_multiplier?: number;
65
+ readonly calibration_evidence_as_of?: string;
66
+ readonly max_calibration_evidence_age_ms?: number;
67
+ readonly warmup_length?: JudgedActivations;
68
+ readonly policy_warmup_judged_activations: JudgedActivations;
69
+ readonly last_unforced_deep_at?: string;
70
+ }
71
+ export interface KernelBackstopEvaluation {
72
+ readonly outcomes: readonly KernelBackstopOutcome[];
73
+ }
74
+ export interface RollbackComparisonInput {
75
+ readonly fresh_policy_revision: string;
76
+ readonly fresh_policy_judged_activations_before_trip: JudgedActivations;
77
+ readonly last_known_good_revision?: string;
78
+ readonly last_known_good_judged_activations_before_trip?: JudgedActivations;
79
+ }
80
+ export type RollbackOutcome = "rollback" | "keep-current" | "no-last-known-good";
81
+ export interface RollbackComparison {
82
+ readonly outcome: RollbackOutcome;
83
+ readonly reason: string;
84
+ readonly target_policy_revision?: string;
85
+ }
86
+ export interface ConsumedReceiptEdge {
87
+ readonly from: ContentHashV0;
88
+ readonly to: ContentHashV0;
89
+ }
90
+ export interface CycleDetectionResult {
91
+ readonly cycle_checked: true;
92
+ readonly has_cycle: boolean;
93
+ readonly cycle: readonly ContentHashV0[];
94
+ }
95
+ export interface KernelSafetyReceiptInput {
96
+ readonly responsibility_id: string;
97
+ readonly contract_revision: ContentHashV0;
98
+ readonly memo_key: string;
99
+ readonly evidence_input_ids: readonly ContentHashV0[];
100
+ readonly as_of: string;
101
+ readonly reason: string;
102
+ readonly fix_target: string;
103
+ readonly interrupt_cause: "needs-judgment" | "needs-input" | "contract-declared";
104
+ readonly role?: ReceiptRoleV0;
105
+ readonly event_cause?: ReceiptEventCauseV0;
106
+ readonly next_forecast_recheck?: string;
107
+ readonly cycle_checked?: boolean;
108
+ }
109
+ export interface KernelPolicyArtifactValidationInput {
110
+ readonly no_anchor: boolean;
111
+ readonly falsification_predicate: KernelPredicateExpression;
112
+ readonly backstop_divergence_predicate?: KernelPredicateExpression;
113
+ readonly live_observables: readonly string[];
114
+ }
115
+ export interface ValidatedKernelPolicyArtifactToken {
116
+ readonly [VALIDATED_KERNEL_POLICY_ARTIFACT_TOKEN_BRAND]: true;
117
+ readonly no_anchor: boolean;
118
+ readonly live_observable_refs: readonly string[];
119
+ readonly backstop_divergence_predicate?: KernelPredicateExpression;
120
+ }
121
+ export type KernelPolicyArtifactValidation = {
122
+ readonly ok: true;
123
+ readonly live_observable_refs: readonly string[];
124
+ readonly token: ValidatedKernelPolicyArtifactToken;
125
+ } | {
126
+ readonly ok: false;
127
+ readonly errors: readonly string[];
128
+ readonly live_observable_refs: readonly string[];
129
+ };
130
+ export interface BackstopDivergenceEvaluationInput {
131
+ readonly token: ValidatedKernelPolicyArtifactToken;
132
+ readonly facts: KernelFacts;
133
+ readonly receipt_input: Omit<KernelSafetyReceiptInput, "reason" | "fix_target" | "interrupt_cause">;
134
+ }
135
+ export type BackstopDivergenceEvaluation = {
136
+ readonly outcome: "not-tripped";
137
+ readonly predicate: PredicateEvaluation;
138
+ } | {
139
+ readonly outcome: "indeterminate";
140
+ readonly predicate: PredicateEvaluation;
141
+ } | {
142
+ readonly outcome: "force-policy-recompile";
143
+ readonly predicate: PredicateEvaluation;
144
+ readonly receipt: ReceiptV0;
145
+ };
146
+ export interface PersistentIndeterminateInput {
147
+ readonly interval_basis: IntervalBasis;
148
+ readonly first_indeterminate_at: string;
149
+ readonly as_of: string;
150
+ readonly backstop_interval_ms: number;
151
+ readonly receipt_input: Omit<KernelSafetyReceiptInput, "as_of" | "reason" | "fix_target" | "interrupt_cause">;
152
+ }
153
+ export type PersistentIndeterminateResolution = {
154
+ readonly outcome: "pending";
155
+ readonly remaining_ms: number;
156
+ } | {
157
+ readonly outcome: "needs-judgment";
158
+ readonly receipt: ReceiptV0;
159
+ };
160
+ export declare function judgedActivations(value: number, name?: string): JudgedActivations;
161
+ export declare function evaluatePredicate(expression: unknown, facts: KernelFacts): PredicateEvaluation;
162
+ export declare function evaluateBackstops(input: KernelBackstopInput): KernelBackstopEvaluation;
163
+ export declare function validateKernelPolicyArtifact(input: KernelPolicyArtifactValidationInput): KernelPolicyArtifactValidation;
164
+ export declare function evaluateBackstopDivergencePredicate(input: BackstopDivergenceEvaluationInput): BackstopDivergenceEvaluation;
165
+ export declare function resolvePersistentIndeterminate(input: PersistentIndeterminateInput): PersistentIndeterminateResolution;
166
+ export declare function compareRollback(input: RollbackComparisonInput): RollbackComparison;
167
+ export declare function detectReceiptCycles(edges: readonly ConsumedReceiptEdge[]): CycleDetectionResult;
168
+ export declare function createKernelSafetyReceipt(input: KernelSafetyReceiptInput): ReceiptV0;
169
+ export {};
170
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/kernel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,SAAS,EAGf,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,aAAa,QAAsB,CAAC;AACjD,eAAO,MAAM,cAAc,QAAiB,CAAC;AAE7C,eAAO,MAAM,gBAAgB;;;;;;CAMnB,CAAC;AAEX,QAAA,MAAM,4CAA4C,EAAE,OAAO,MAE1D,CAAC;AACF,QAAA,MAAM,wBAAwB,EAAE,OAAO,MAAoC,CAAC;AAG5E,eAAO,MAAM,gBAAgB,m5BAenB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC/D,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;AACpE,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,SAAS,GAAG,eAAe,CAAC;AAC3E,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC;AAC3C,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG;IACvC,QAAQ,CAAC,CAAC,wBAAwB,CAAC,EAAE,IAAI,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,yBAAyB,GACjC;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;CACjC,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B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