@agentplat/mesh-sim 0.3.0-alpha.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 +202 -0
- package/README.md +23 -0
- package/dist/index.d.ts +136 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +427 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# `@agentplat/mesh-sim`
|
|
2
|
+
|
|
3
|
+
Deterministic simulation kernel for AgentPlat Mesh peers.
|
|
4
|
+
|
|
5
|
+
The kernel uses the production `reduceMeshPeer` function for local commands and
|
|
6
|
+
the production `processMeshEnvelope` boundary for every remote delivery. There
|
|
7
|
+
is no simulation-only accepted-message path.
|
|
8
|
+
|
|
9
|
+
Alpha 1 provides:
|
|
10
|
+
|
|
11
|
+
- integer logical time and a total-order priority queue;
|
|
12
|
+
- versioned `xorshift32-v1` random substreams scoped by caller-defined names;
|
|
13
|
+
- explicit event, queue, logical-time and internal-step limits;
|
|
14
|
+
- signed message preparation and delivery across configured topology links;
|
|
15
|
+
- immutable SHA-256 state and chained trace digests;
|
|
16
|
+
- invariant monitors evaluated after every event;
|
|
17
|
+
- restart snapshots containing queue, PRNG and outbound allocator state; and
|
|
18
|
+
- replay comparison reporting the first semantic divergence.
|
|
19
|
+
|
|
20
|
+
Cryptographic handles, private keys and callbacks are runtime dependencies and
|
|
21
|
+
are excluded from configuration digests, snapshots and traces. Replays within
|
|
22
|
+
one test or process may reuse the same generated key handles; private material
|
|
23
|
+
is never serialized.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { type MeshAdmissionPolicy, type MeshLogicalTime, type MeshPeerEffect, type MeshPeerInput, type MeshPeerState } from '@agentplat/mesh';
|
|
2
|
+
import type { MeshCryptoPolicy, MeshEnvelopeSigner, MeshEnvelopeVerifier, MeshKeyResolver } from '@agentplat/mesh-crypto';
|
|
3
|
+
import { type MeshProtocolOptions, type SignedMeshEnvelope } from '@agentplat/mesh-protocol';
|
|
4
|
+
export type MeshSimulationPrngVersion = 'xorshift32-v1';
|
|
5
|
+
export type MeshSimulationRecordingMode = 'full' | 'digest' | 'metrics';
|
|
6
|
+
/** Runtime handles are excluded from configuration and trace digests. */
|
|
7
|
+
export interface MeshSimulationPeer {
|
|
8
|
+
readonly peerId: string;
|
|
9
|
+
readonly state: MeshPeerState;
|
|
10
|
+
readonly signer: MeshEnvelopeSigner;
|
|
11
|
+
readonly verifier: MeshEnvelopeVerifier;
|
|
12
|
+
readonly resolver: MeshKeyResolver;
|
|
13
|
+
readonly cryptoPolicy: MeshCryptoPolicy;
|
|
14
|
+
readonly admissionPolicy: MeshAdmissionPolicy;
|
|
15
|
+
readonly privateKey: CryptoKey;
|
|
16
|
+
readonly outboundSequence?: number;
|
|
17
|
+
readonly crypto?: Crypto;
|
|
18
|
+
readonly protocolOptions?: MeshProtocolOptions;
|
|
19
|
+
}
|
|
20
|
+
export interface MeshSimulationLink {
|
|
21
|
+
readonly fromPeerId: string;
|
|
22
|
+
readonly toPeerId: string;
|
|
23
|
+
readonly latency: number;
|
|
24
|
+
readonly enabled: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface MeshSimulationLimits {
|
|
27
|
+
readonly maximumEvents: number;
|
|
28
|
+
readonly maximumLogicalTime: MeshLogicalTime;
|
|
29
|
+
readonly maximumQueuedEvents: number;
|
|
30
|
+
readonly maximumInternalSteps: number;
|
|
31
|
+
}
|
|
32
|
+
export interface MeshSimulationConfig {
|
|
33
|
+
readonly seed: number;
|
|
34
|
+
readonly prngVersion: MeshSimulationPrngVersion;
|
|
35
|
+
readonly recordingMode: MeshSimulationRecordingMode;
|
|
36
|
+
readonly startTime: string;
|
|
37
|
+
readonly peers: readonly MeshSimulationPeer[];
|
|
38
|
+
readonly links: readonly MeshSimulationLink[];
|
|
39
|
+
readonly limits: MeshSimulationLimits;
|
|
40
|
+
readonly invariants?: readonly MeshSimulationInvariant[];
|
|
41
|
+
}
|
|
42
|
+
export type MeshSimulationAction = {
|
|
43
|
+
readonly kind: 'peer.input';
|
|
44
|
+
readonly input: Exclude<MeshPeerInput, {
|
|
45
|
+
readonly kind: 'effect.result';
|
|
46
|
+
}>;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: 'message.delivery';
|
|
49
|
+
readonly envelope: SignedMeshEnvelope;
|
|
50
|
+
};
|
|
51
|
+
export interface MeshSimulationEventInput {
|
|
52
|
+
readonly eventId: string;
|
|
53
|
+
readonly targetPeerId: string;
|
|
54
|
+
readonly logicalTime: MeshLogicalTime;
|
|
55
|
+
readonly priority: number;
|
|
56
|
+
readonly action: MeshSimulationAction;
|
|
57
|
+
}
|
|
58
|
+
export interface MeshSimulationOrder {
|
|
59
|
+
readonly logicalTime: MeshLogicalTime;
|
|
60
|
+
readonly priority: number;
|
|
61
|
+
readonly insertionSequence: number;
|
|
62
|
+
}
|
|
63
|
+
export interface MeshSimulationEvent {
|
|
64
|
+
readonly eventId: string;
|
|
65
|
+
readonly targetPeerId: string;
|
|
66
|
+
readonly order: MeshSimulationOrder;
|
|
67
|
+
readonly action: MeshSimulationAction;
|
|
68
|
+
}
|
|
69
|
+
export interface MeshSimulationRecord {
|
|
70
|
+
readonly eventId: string;
|
|
71
|
+
readonly peerId: string;
|
|
72
|
+
readonly order: MeshSimulationOrder;
|
|
73
|
+
readonly inputKind: MeshSimulationAction['kind'];
|
|
74
|
+
readonly actionDigest: string;
|
|
75
|
+
readonly accepted?: boolean;
|
|
76
|
+
readonly rejectionCode?: string;
|
|
77
|
+
readonly effectKinds: readonly MeshPeerEffect['kind'][];
|
|
78
|
+
readonly effectsDigest: string;
|
|
79
|
+
readonly stateDigest: string;
|
|
80
|
+
readonly chainDigest: string;
|
|
81
|
+
}
|
|
82
|
+
export interface MeshSimulationMetrics {
|
|
83
|
+
readonly processedEvents: number;
|
|
84
|
+
readonly emittedEffects: number;
|
|
85
|
+
readonly deliveredMessages: number;
|
|
86
|
+
readonly rejectedMessages: number;
|
|
87
|
+
readonly finalLogicalTime: MeshLogicalTime;
|
|
88
|
+
}
|
|
89
|
+
export interface MeshSimulationTrace {
|
|
90
|
+
readonly seed: number;
|
|
91
|
+
readonly prngVersion: MeshSimulationPrngVersion;
|
|
92
|
+
readonly configurationDigest: string;
|
|
93
|
+
readonly chainDigest: string;
|
|
94
|
+
readonly metrics: MeshSimulationMetrics;
|
|
95
|
+
readonly records?: readonly MeshSimulationRecord[];
|
|
96
|
+
readonly peerStates: Readonly<Record<string, MeshPeerState>>;
|
|
97
|
+
}
|
|
98
|
+
export interface MeshSimulationInvariant {
|
|
99
|
+
readonly name: string;
|
|
100
|
+
evaluate(context: {
|
|
101
|
+
event: MeshSimulationEvent;
|
|
102
|
+
peerStates: Readonly<Record<string, MeshPeerState>>;
|
|
103
|
+
queuedEvents: number;
|
|
104
|
+
}): void;
|
|
105
|
+
}
|
|
106
|
+
export interface MeshSimulationSnapshot {
|
|
107
|
+
readonly schemaVersion: 1;
|
|
108
|
+
readonly logicalTime: MeshLogicalTime;
|
|
109
|
+
readonly insertionSequence: number;
|
|
110
|
+
readonly peerStates: Readonly<Record<string, MeshPeerState>>;
|
|
111
|
+
readonly outboundSequences: Readonly<Record<string, number>>;
|
|
112
|
+
readonly prngStates: Readonly<Record<string, number>>;
|
|
113
|
+
readonly queuedEvents: readonly MeshSimulationEvent[];
|
|
114
|
+
readonly chainDigest: string;
|
|
115
|
+
}
|
|
116
|
+
export interface MeshSimulationReplayResult {
|
|
117
|
+
readonly matches: boolean;
|
|
118
|
+
readonly expectedChainDigest: string;
|
|
119
|
+
readonly actualChainDigest: string;
|
|
120
|
+
readonly firstDivergence?: number;
|
|
121
|
+
}
|
|
122
|
+
export interface MeshSimulationKernel {
|
|
123
|
+
readonly config: MeshSimulationConfig;
|
|
124
|
+
readonly configurationDigest: string;
|
|
125
|
+
enqueue(event: MeshSimulationEventInput): void;
|
|
126
|
+
random(scope: string): number;
|
|
127
|
+
step(): Promise<MeshSimulationRecord | undefined>;
|
|
128
|
+
runUntilIdle(): Promise<MeshSimulationTrace>;
|
|
129
|
+
snapshot(): MeshSimulationSnapshot;
|
|
130
|
+
}
|
|
131
|
+
/** Creates a bounded kernel after hashing its serializable configuration. */
|
|
132
|
+
export declare function createMeshSimulationKernel(config: MeshSimulationConfig): Promise<MeshSimulationKernel>;
|
|
133
|
+
export declare function runMeshSimulation(config: MeshSimulationConfig, events: readonly MeshSimulationEventInput[]): Promise<MeshSimulationTrace>;
|
|
134
|
+
export declare function replayMeshSimulation(config: MeshSimulationConfig, events: readonly MeshSimulationEventInput[], expected: MeshSimulationTrace): Promise<MeshSimulationReplayResult>;
|
|
135
|
+
export declare const THREE_PEER_SCENARIO_IDS: readonly ["peer-a", "peer-b", "peer-c"];
|
|
136
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAKL,KAAK,mBAAmB,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C;IACrC,OAAO,CAAC,KAAK,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAC/C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,IAAI,IAAI,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAAC;IAClD,YAAY,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC7C,QAAQ,IAAI,sBAAsB,CAAC;CACpC;AAQD,6EAA6E;AAC7E,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CAI/B;AAED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,SAAS,wBAAwB,EAAE,GAC1C,OAAO,CAAC,mBAAmB,CAAC,CAI9B;AAED,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,SAAS,wBAAwB,EAAE,EAC3C,QAAQ,EAAE,mBAAmB,GAC5B,OAAO,CAAC,0BAA0B,CAAC,CA0BrC;AAwbD,eAAO,MAAM,uBAAuB,yCAIzB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
import { processMeshEnvelope, reduceMeshPeer, } from '@agentplat/mesh';
|
|
2
|
+
import { MESH_PROTOCOL, MESH_SIGNATURE_ALGORITHM, MESH_WIRE_VERSION, canonicalizeMeshJsonBytes, } from '@agentplat/mesh-protocol';
|
|
3
|
+
/** Creates a bounded kernel after hashing its serializable configuration. */
|
|
4
|
+
export async function createMeshSimulationKernel(config) {
|
|
5
|
+
validateConfig(config);
|
|
6
|
+
const configurationDigest = await digest(configurationProjection(config));
|
|
7
|
+
return new DeterministicMeshSimulationKernel(config, configurationDigest);
|
|
8
|
+
}
|
|
9
|
+
export async function runMeshSimulation(config, events) {
|
|
10
|
+
const kernel = await createMeshSimulationKernel(config);
|
|
11
|
+
for (const event of events)
|
|
12
|
+
kernel.enqueue(event);
|
|
13
|
+
return kernel.runUntilIdle();
|
|
14
|
+
}
|
|
15
|
+
export async function replayMeshSimulation(config, events, expected) {
|
|
16
|
+
const actual = await runMeshSimulation(config, events);
|
|
17
|
+
const expectedRecords = expected.records ?? [];
|
|
18
|
+
const actualRecords = actual.records ?? [];
|
|
19
|
+
let firstDivergence;
|
|
20
|
+
const count = Math.max(expectedRecords.length, actualRecords.length);
|
|
21
|
+
for (let index = 0; index < count; index += 1) {
|
|
22
|
+
if (expectedRecords[index]?.chainDigest !==
|
|
23
|
+
actualRecords[index]?.chainDigest) {
|
|
24
|
+
firstDivergence = index;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const matches = expected.configurationDigest === actual.configurationDigest &&
|
|
29
|
+
expected.chainDigest === actual.chainDigest;
|
|
30
|
+
return Object.freeze({
|
|
31
|
+
matches,
|
|
32
|
+
expectedChainDigest: expected.chainDigest,
|
|
33
|
+
actualChainDigest: actual.chainDigest,
|
|
34
|
+
...(matches
|
|
35
|
+
? {}
|
|
36
|
+
: { firstDivergence: firstDivergence ?? Math.min(count, 0) }),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
class DeterministicMeshSimulationKernel {
|
|
40
|
+
config;
|
|
41
|
+
configurationDigest;
|
|
42
|
+
#peers = new Map();
|
|
43
|
+
#queue = [];
|
|
44
|
+
#eventIds = new Set();
|
|
45
|
+
#prngStates = new Map();
|
|
46
|
+
#records = [];
|
|
47
|
+
#insertionSequence = 0;
|
|
48
|
+
#logicalTime = 0;
|
|
49
|
+
#processedEvents = 0;
|
|
50
|
+
#emittedEffects = 0;
|
|
51
|
+
#deliveredMessages = 0;
|
|
52
|
+
#rejectedMessages = 0;
|
|
53
|
+
#chainDigest;
|
|
54
|
+
constructor(config, configurationDigest) {
|
|
55
|
+
this.config = config;
|
|
56
|
+
this.configurationDigest = configurationDigest;
|
|
57
|
+
this.#chainDigest = configurationDigest;
|
|
58
|
+
for (const peer of config.peers) {
|
|
59
|
+
this.#peers.set(peer.peerId, {
|
|
60
|
+
config: peer,
|
|
61
|
+
state: peer.state,
|
|
62
|
+
outboundSequence: peer.outboundSequence ?? 0,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
enqueue(input) {
|
|
67
|
+
if (!input || typeof input !== 'object' || this.#eventIds.has(input.eventId)) {
|
|
68
|
+
throw new TypeError('Invalid or duplicate Mesh simulation event');
|
|
69
|
+
}
|
|
70
|
+
if (!this.#peers.has(input.targetPeerId) ||
|
|
71
|
+
!Number.isSafeInteger(input.logicalTime) ||
|
|
72
|
+
input.logicalTime < this.#logicalTime ||
|
|
73
|
+
input.logicalTime > this.config.limits.maximumLogicalTime ||
|
|
74
|
+
!Number.isSafeInteger(input.priority)) {
|
|
75
|
+
throw new RangeError('Mesh simulation event is outside configured bounds');
|
|
76
|
+
}
|
|
77
|
+
if (this.#queue.length >= this.config.limits.maximumQueuedEvents) {
|
|
78
|
+
throw new RangeError('Mesh simulation queue limit exceeded');
|
|
79
|
+
}
|
|
80
|
+
this.#insertionSequence += 1;
|
|
81
|
+
const event = Object.freeze({
|
|
82
|
+
eventId: input.eventId,
|
|
83
|
+
targetPeerId: input.targetPeerId,
|
|
84
|
+
order: Object.freeze({
|
|
85
|
+
logicalTime: input.logicalTime,
|
|
86
|
+
priority: input.priority,
|
|
87
|
+
insertionSequence: this.#insertionSequence,
|
|
88
|
+
}),
|
|
89
|
+
action: freezeAction(input.action),
|
|
90
|
+
});
|
|
91
|
+
this.#eventIds.add(input.eventId);
|
|
92
|
+
this.#queue.push(event);
|
|
93
|
+
this.#queue.sort(compareEvents);
|
|
94
|
+
}
|
|
95
|
+
random(scope) {
|
|
96
|
+
if (typeof scope !== 'string' || scope.length === 0) {
|
|
97
|
+
throw new TypeError('Mesh simulation random scope is required');
|
|
98
|
+
}
|
|
99
|
+
let state = this.#prngStates.get(scope) ??
|
|
100
|
+
mixSeed(this.config.seed >>> 0, scope);
|
|
101
|
+
state = xorshift32(state);
|
|
102
|
+
this.#prngStates.set(scope, state);
|
|
103
|
+
return state / 0x1_0000_0000;
|
|
104
|
+
}
|
|
105
|
+
async step() {
|
|
106
|
+
if (this.#queue.length === 0)
|
|
107
|
+
return undefined;
|
|
108
|
+
if (this.#processedEvents >= this.config.limits.maximumEvents) {
|
|
109
|
+
throw new RangeError('Mesh simulation event limit exceeded');
|
|
110
|
+
}
|
|
111
|
+
const event = this.#queue.shift();
|
|
112
|
+
if (!event)
|
|
113
|
+
throw new TypeError('Mesh simulation queue became inconsistent');
|
|
114
|
+
this.#logicalTime = event.order.logicalTime;
|
|
115
|
+
const peer = this.#peers.get(event.targetPeerId);
|
|
116
|
+
if (!peer)
|
|
117
|
+
throw new TypeError('Mesh simulation target disappeared');
|
|
118
|
+
let effects = Object.freeze([]);
|
|
119
|
+
let accepted;
|
|
120
|
+
let rejectionCode;
|
|
121
|
+
if (event.action.kind === 'peer.input') {
|
|
122
|
+
const transition = reduceMeshPeer(peer.state, event.action.input, this.#logicalTime);
|
|
123
|
+
peer.state = transition.state;
|
|
124
|
+
effects = await this.#interpret(peer, transition.effects, event);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
const decision = await processMeshEnvelope(peer.state, {
|
|
128
|
+
envelope: event.action.envelope,
|
|
129
|
+
verifiedAt: timestampAt(this.config.startTime, this.#logicalTime),
|
|
130
|
+
receivedAt: this.#logicalTime,
|
|
131
|
+
verifier: peer.config.verifier,
|
|
132
|
+
resolver: peer.config.resolver,
|
|
133
|
+
cryptoPolicy: peer.config.cryptoPolicy,
|
|
134
|
+
admissionPolicy: peer.config.admissionPolicy,
|
|
135
|
+
crypto: peer.config.crypto,
|
|
136
|
+
protocolOptions: peer.config.protocolOptions,
|
|
137
|
+
});
|
|
138
|
+
accepted = decision.accepted;
|
|
139
|
+
if (decision.accepted) {
|
|
140
|
+
peer.state = decision.state;
|
|
141
|
+
effects = await this.#interpret(peer, decision.effects, event);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
rejectionCode = decision.code;
|
|
145
|
+
this.#rejectedMessages += 1;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
this.#processedEvents += 1;
|
|
149
|
+
this.#emittedEffects += effects.length;
|
|
150
|
+
const peerStates = this.#peerStates();
|
|
151
|
+
for (const invariant of this.config.invariants ?? []) {
|
|
152
|
+
invariant.evaluate({
|
|
153
|
+
event,
|
|
154
|
+
peerStates,
|
|
155
|
+
queuedEvents: this.#queue.length,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
const [actionDigest, effectsDigest, stateDigest] = await Promise.all([
|
|
159
|
+
digest(event.action),
|
|
160
|
+
digest(effects),
|
|
161
|
+
digest(peerStates),
|
|
162
|
+
]);
|
|
163
|
+
const recordBase = {
|
|
164
|
+
eventId: event.eventId,
|
|
165
|
+
peerId: event.targetPeerId,
|
|
166
|
+
order: event.order,
|
|
167
|
+
inputKind: event.action.kind,
|
|
168
|
+
actionDigest,
|
|
169
|
+
...(accepted === undefined ? {} : { accepted }),
|
|
170
|
+
...(rejectionCode === undefined ? {} : { rejectionCode }),
|
|
171
|
+
effectKinds: Object.freeze(effects.map((effect) => effect.kind)),
|
|
172
|
+
effectsDigest,
|
|
173
|
+
stateDigest,
|
|
174
|
+
};
|
|
175
|
+
this.#chainDigest = await digest({
|
|
176
|
+
previous: this.#chainDigest,
|
|
177
|
+
record: recordBase,
|
|
178
|
+
});
|
|
179
|
+
const record = Object.freeze({
|
|
180
|
+
...recordBase,
|
|
181
|
+
chainDigest: this.#chainDigest,
|
|
182
|
+
});
|
|
183
|
+
if (this.config.recordingMode === 'full')
|
|
184
|
+
this.#records.push(record);
|
|
185
|
+
return record;
|
|
186
|
+
}
|
|
187
|
+
async runUntilIdle() {
|
|
188
|
+
while (this.#queue.length > 0)
|
|
189
|
+
await this.step();
|
|
190
|
+
return Object.freeze({
|
|
191
|
+
seed: this.config.seed,
|
|
192
|
+
prngVersion: this.config.prngVersion,
|
|
193
|
+
configurationDigest: this.configurationDigest,
|
|
194
|
+
chainDigest: this.#chainDigest,
|
|
195
|
+
metrics: Object.freeze({
|
|
196
|
+
processedEvents: this.#processedEvents,
|
|
197
|
+
emittedEffects: this.#emittedEffects,
|
|
198
|
+
deliveredMessages: this.#deliveredMessages,
|
|
199
|
+
rejectedMessages: this.#rejectedMessages,
|
|
200
|
+
finalLogicalTime: this.#logicalTime,
|
|
201
|
+
}),
|
|
202
|
+
...(this.config.recordingMode === 'full'
|
|
203
|
+
? { records: Object.freeze([...this.#records]) }
|
|
204
|
+
: {}),
|
|
205
|
+
peerStates: this.#peerStates(),
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
snapshot() {
|
|
209
|
+
return Object.freeze({
|
|
210
|
+
schemaVersion: 1,
|
|
211
|
+
logicalTime: this.#logicalTime,
|
|
212
|
+
insertionSequence: this.#insertionSequence,
|
|
213
|
+
peerStates: this.#peerStates(),
|
|
214
|
+
outboundSequences: frozenRecord([...this.#peers].map(([peerId, peer]) => [
|
|
215
|
+
peerId,
|
|
216
|
+
peer.outboundSequence,
|
|
217
|
+
])),
|
|
218
|
+
prngStates: frozenRecord([...this.#prngStates]),
|
|
219
|
+
queuedEvents: Object.freeze([...this.#queue]),
|
|
220
|
+
chainDigest: this.#chainDigest,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
async #interpret(peer, initial, root) {
|
|
224
|
+
const effects = [...initial];
|
|
225
|
+
const prepared = new Map();
|
|
226
|
+
for (let index = 0; index < effects.length; index += 1) {
|
|
227
|
+
if (index >= this.config.limits.maximumInternalSteps) {
|
|
228
|
+
throw new RangeError('Mesh simulation internal step limit exceeded');
|
|
229
|
+
}
|
|
230
|
+
const effect = effects[index];
|
|
231
|
+
if (effect.kind === 'message.prepare') {
|
|
232
|
+
peer.outboundSequence += 1;
|
|
233
|
+
const envelope = await this.#prepare(peer, effect);
|
|
234
|
+
prepared.set(effect.effectId, envelope);
|
|
235
|
+
const transition = reduceMeshPeer(peer.state, {
|
|
236
|
+
kind: 'effect.result',
|
|
237
|
+
effectId: effect.effectId,
|
|
238
|
+
status: 'succeeded',
|
|
239
|
+
preparedMessage: {
|
|
240
|
+
messageId: envelope.messageId,
|
|
241
|
+
type: envelope.type,
|
|
242
|
+
audiencePeerId: effect.intent.audiencePeerId,
|
|
243
|
+
expiresAt: this.#logicalTime + effect.intent.maximumLifetimeMs,
|
|
244
|
+
},
|
|
245
|
+
}, this.#logicalTime);
|
|
246
|
+
peer.state = transition.state;
|
|
247
|
+
effects.push(...transition.effects);
|
|
248
|
+
}
|
|
249
|
+
else if (effect.kind === 'message.deliver') {
|
|
250
|
+
const envelope = prepared.get(effect.preparationEffectId);
|
|
251
|
+
if (!envelope || envelope.messageId !== effect.messageId) {
|
|
252
|
+
throw new TypeError('Mesh simulation lacks prepared delivery');
|
|
253
|
+
}
|
|
254
|
+
const link = this.config.links.find((candidate) => candidate.fromPeerId === peer.config.peerId &&
|
|
255
|
+
candidate.toPeerId === effect.audiencePeerId);
|
|
256
|
+
if (!link?.enabled) {
|
|
257
|
+
this.#rejectedMessages += 1;
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
this.enqueue({
|
|
261
|
+
eventId: `delivery:${envelope.messageId}`,
|
|
262
|
+
targetPeerId: effect.audiencePeerId,
|
|
263
|
+
logicalTime: this.#logicalTime + link.latency,
|
|
264
|
+
priority: root.order.priority,
|
|
265
|
+
action: { kind: 'message.delivery', envelope },
|
|
266
|
+
});
|
|
267
|
+
this.#deliveredMessages += 1;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return Object.freeze(effects);
|
|
271
|
+
}
|
|
272
|
+
async #prepare(peer, effect) {
|
|
273
|
+
const sentAt = timestampAt(this.config.startTime, this.#logicalTime);
|
|
274
|
+
const unsigned = {
|
|
275
|
+
protocol: MESH_PROTOCOL,
|
|
276
|
+
wireVersion: MESH_WIRE_VERSION,
|
|
277
|
+
messageId: deterministicMessageId(() => this.random(`message:${peer.config.peerId}`)),
|
|
278
|
+
tenantId: peer.state.identity.tenantId,
|
|
279
|
+
meshId: peer.state.identity.meshId,
|
|
280
|
+
type: effect.intent.type,
|
|
281
|
+
sender: {
|
|
282
|
+
peerId: peer.state.identity.peerId,
|
|
283
|
+
instanceId: peer.state.identity.instanceId,
|
|
284
|
+
},
|
|
285
|
+
audience: {
|
|
286
|
+
kind: 'peer',
|
|
287
|
+
peerId: effect.intent.audiencePeerId,
|
|
288
|
+
},
|
|
289
|
+
sequence: peer.outboundSequence,
|
|
290
|
+
sentAt,
|
|
291
|
+
expiresAt: timestampAt(this.config.startTime, this.#logicalTime + effect.intent.maximumLifetimeMs),
|
|
292
|
+
payload: effect.intent.payload,
|
|
293
|
+
proof: {
|
|
294
|
+
algorithm: MESH_SIGNATURE_ALGORITHM,
|
|
295
|
+
keyId: peer.state.identity.keyId,
|
|
296
|
+
},
|
|
297
|
+
...(effect.intent.causationId === undefined
|
|
298
|
+
? {}
|
|
299
|
+
: { causationId: effect.intent.causationId }),
|
|
300
|
+
...(effect.intent.correlationId === undefined
|
|
301
|
+
? {}
|
|
302
|
+
: { correlationId: effect.intent.correlationId }),
|
|
303
|
+
};
|
|
304
|
+
return peer.config.signer.sign({
|
|
305
|
+
envelope: unsigned,
|
|
306
|
+
privateKey: peer.config.privateKey,
|
|
307
|
+
crypto: peer.config.crypto,
|
|
308
|
+
protocolOptions: peer.config.protocolOptions,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
#peerStates() {
|
|
312
|
+
return frozenRecord([...this.#peers].map(([peerId, peer]) => [peerId, peer.state]));
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function validateConfig(config) {
|
|
316
|
+
if (!config ||
|
|
317
|
+
config.prngVersion !== 'xorshift32-v1' ||
|
|
318
|
+
!Number.isSafeInteger(config.seed) ||
|
|
319
|
+
!Number.isFinite(Date.parse(config.startTime)) ||
|
|
320
|
+
!Array.isArray(config.peers) ||
|
|
321
|
+
config.peers.length < 1) {
|
|
322
|
+
throw new TypeError('Invalid Mesh simulation configuration');
|
|
323
|
+
}
|
|
324
|
+
const ids = config.peers.map((peer) => peer.peerId);
|
|
325
|
+
if (new Set(ids).size !== ids.length) {
|
|
326
|
+
throw new TypeError('Duplicate Mesh simulation peer');
|
|
327
|
+
}
|
|
328
|
+
for (const value of Object.values(config.limits)) {
|
|
329
|
+
if (!Number.isSafeInteger(value) || value < 1) {
|
|
330
|
+
throw new RangeError('Invalid Mesh simulation limit');
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function configurationProjection(config) {
|
|
335
|
+
return {
|
|
336
|
+
seed: config.seed,
|
|
337
|
+
prngVersion: config.prngVersion,
|
|
338
|
+
recordingMode: config.recordingMode,
|
|
339
|
+
startTime: config.startTime,
|
|
340
|
+
peers: config.peers.map((peer) => ({
|
|
341
|
+
peerId: peer.peerId,
|
|
342
|
+
state: peer.state,
|
|
343
|
+
outboundSequence: peer.outboundSequence ?? 0,
|
|
344
|
+
})),
|
|
345
|
+
links: config.links,
|
|
346
|
+
limits: config.limits,
|
|
347
|
+
invariants: (config.invariants ?? []).map((invariant) => invariant.name),
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function freezeAction(action) {
|
|
351
|
+
if (action?.kind === 'peer.input') {
|
|
352
|
+
return Object.freeze({
|
|
353
|
+
kind: 'peer.input',
|
|
354
|
+
input: Object.freeze({ ...action.input }),
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
if (action?.kind === 'message.delivery') {
|
|
358
|
+
return Object.freeze({ kind: 'message.delivery', envelope: action.envelope });
|
|
359
|
+
}
|
|
360
|
+
throw new TypeError('Invalid Mesh simulation action');
|
|
361
|
+
}
|
|
362
|
+
function compareEvents(left, right) {
|
|
363
|
+
return (left.order.logicalTime - right.order.logicalTime ||
|
|
364
|
+
left.order.priority - right.order.priority ||
|
|
365
|
+
left.order.insertionSequence - right.order.insertionSequence);
|
|
366
|
+
}
|
|
367
|
+
function timestampAt(startTime, logicalTime) {
|
|
368
|
+
return new Date(Date.parse(startTime) + logicalTime).toISOString();
|
|
369
|
+
}
|
|
370
|
+
function xorshift32(input) {
|
|
371
|
+
let value = input || 0x6d2b79f5;
|
|
372
|
+
value ^= value << 13;
|
|
373
|
+
value ^= value >>> 17;
|
|
374
|
+
value ^= value << 5;
|
|
375
|
+
return value >>> 0;
|
|
376
|
+
}
|
|
377
|
+
function mixSeed(seed, scope) {
|
|
378
|
+
let value = seed ^ 0x811c9dc5;
|
|
379
|
+
for (let index = 0; index < scope.length; index += 1) {
|
|
380
|
+
value = Math.imul(value ^ scope.charCodeAt(index), 0x01000193);
|
|
381
|
+
}
|
|
382
|
+
return value >>> 0 || 1;
|
|
383
|
+
}
|
|
384
|
+
function deterministicMessageId(random) {
|
|
385
|
+
const bytes = new Uint8Array(16);
|
|
386
|
+
for (let index = 0; index < bytes.length; index += 1) {
|
|
387
|
+
bytes[index] = Math.floor(random() * 256);
|
|
388
|
+
}
|
|
389
|
+
return base64url(bytes);
|
|
390
|
+
}
|
|
391
|
+
function base64url(bytes) {
|
|
392
|
+
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
|
|
393
|
+
let output = '';
|
|
394
|
+
for (let index = 0; index < bytes.length; index += 3) {
|
|
395
|
+
const value = (bytes[index] << 16) |
|
|
396
|
+
((bytes[index + 1] ?? 0) << 8) |
|
|
397
|
+
(bytes[index + 2] ?? 0);
|
|
398
|
+
output += alphabet[(value >>> 18) & 63];
|
|
399
|
+
output += alphabet[(value >>> 12) & 63];
|
|
400
|
+
if (index + 1 < bytes.length)
|
|
401
|
+
output += alphabet[(value >>> 6) & 63];
|
|
402
|
+
if (index + 2 < bytes.length)
|
|
403
|
+
output += alphabet[value & 63];
|
|
404
|
+
}
|
|
405
|
+
return output;
|
|
406
|
+
}
|
|
407
|
+
async function digest(value) {
|
|
408
|
+
const canonical = canonicalizeMeshJsonBytes(value);
|
|
409
|
+
if (!canonical.ok)
|
|
410
|
+
throw new TypeError('Mesh simulation value is not canonical');
|
|
411
|
+
const bytes = canonical.value;
|
|
412
|
+
const source = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
413
|
+
const result = new Uint8Array(await globalThis.crypto.subtle.digest('SHA-256', source));
|
|
414
|
+
return [...result].map((byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
415
|
+
}
|
|
416
|
+
function frozenRecord(entries) {
|
|
417
|
+
const record = Object.create(null);
|
|
418
|
+
for (const [key, value] of entries)
|
|
419
|
+
record[key] = value;
|
|
420
|
+
return Object.freeze(record);
|
|
421
|
+
}
|
|
422
|
+
export const THREE_PEER_SCENARIO_IDS = Object.freeze([
|
|
423
|
+
'peer-a',
|
|
424
|
+
'peer-b',
|
|
425
|
+
'peer-c',
|
|
426
|
+
]);
|
|
427
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,cAAc,GAMf,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EACjB,yBAAyB,GAI1B,MAAM,0BAA0B,CAAC;AAuJlC,6EAA6E;AAC7E,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,MAA4B;IAE5B,cAAc,CAAC,MAAM,CAAC,CAAC;IACvB,MAAM,mBAAmB,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1E,OAAO,IAAI,iCAAiC,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,MAA2C;IAE3C,MAAM,MAAM,GAAG,MAAM,0BAA0B,CAAC,MAAM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CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CACzD,CAAC;IACF,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,YAAY,CACnB,OAA0C;IAE1C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAsB,CAAC;IACxD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO;QAAE,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACxD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC;IACnD,QAAQ;IACR,QAAQ;IACR,QAAQ;CACA,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentplat/mesh-sim",
|
|
3
|
+
"version": "0.3.0-alpha.1",
|
|
4
|
+
"description": "Deterministic simulation contracts for AgentPlat Mesh peer state machines.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@agentplat/mesh": "^0.3.0-alpha.1",
|
|
22
|
+
"@agentplat/mesh-protocol": "^0.3.0-alpha.1",
|
|
23
|
+
"@agentplat/mesh-crypto": "^0.3.0-alpha.1"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=20.19.3"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/Agentplat/agentplat.git",
|
|
34
|
+
"directory": "packages/mesh-sim"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc -p tsconfig.json",
|
|
38
|
+
"type-check": "tsc -p tsconfig.json --noEmit",
|
|
39
|
+
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\""
|
|
40
|
+
}
|
|
41
|
+
}
|