@agentplat/mesh-sim 0.3.0-beta.2 → 0.3.0-beta.5

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 (185) hide show
  1. package/README.md +447 -2
  2. package/dist/collective-closed-loop-action.d.ts +80 -0
  3. package/dist/collective-closed-loop-action.d.ts.map +1 -0
  4. package/dist/collective-closed-loop-action.js +471 -0
  5. package/dist/collective-closed-loop-action.js.map +1 -0
  6. package/dist/collective-closed-loop-contracts.d.ts +75 -0
  7. package/dist/collective-closed-loop-contracts.d.ts.map +1 -0
  8. package/dist/collective-closed-loop-contracts.js +420 -0
  9. package/dist/collective-closed-loop-contracts.js.map +1 -0
  10. package/dist/collective-closed-loop-fault-matrix.d.ts +101 -0
  11. package/dist/collective-closed-loop-fault-matrix.d.ts.map +1 -0
  12. package/dist/collective-closed-loop-fault-matrix.js +253 -0
  13. package/dist/collective-closed-loop-fault-matrix.js.map +1 -0
  14. package/dist/collective-closed-loop-recovery.d.ts +70 -0
  15. package/dist/collective-closed-loop-recovery.d.ts.map +1 -0
  16. package/dist/collective-closed-loop-recovery.js +823 -0
  17. package/dist/collective-closed-loop-recovery.js.map +1 -0
  18. package/dist/collective-closed-loop-reference.d.ts +54 -0
  19. package/dist/collective-closed-loop-reference.d.ts.map +1 -0
  20. package/dist/collective-closed-loop-reference.js +1696 -0
  21. package/dist/collective-closed-loop-reference.js.map +1 -0
  22. package/dist/collective-closed-loop-replanning.d.ts +27 -0
  23. package/dist/collective-closed-loop-replanning.d.ts.map +1 -0
  24. package/dist/collective-closed-loop-replanning.js +151 -0
  25. package/dist/collective-closed-loop-replanning.js.map +1 -0
  26. package/dist/collective-closed-loop-resilience-campaign.d.ts +22 -0
  27. package/dist/collective-closed-loop-resilience-campaign.d.ts.map +1 -0
  28. package/dist/collective-closed-loop-resilience-campaign.js +196 -0
  29. package/dist/collective-closed-loop-resilience-campaign.js.map +1 -0
  30. package/dist/collective-closed-loop-resilience-contracts.d.ts +138 -0
  31. package/dist/collective-closed-loop-resilience-contracts.d.ts.map +1 -0
  32. package/dist/collective-closed-loop-resilience-contracts.js +677 -0
  33. package/dist/collective-closed-loop-resilience-contracts.js.map +1 -0
  34. package/dist/collective-closed-loop-runner.d.ts +133 -0
  35. package/dist/collective-closed-loop-runner.d.ts.map +1 -0
  36. package/dist/collective-closed-loop-runner.js +1429 -0
  37. package/dist/collective-closed-loop-runner.js.map +1 -0
  38. package/dist/collective-closed-loop-runtime.d.ts +95 -0
  39. package/dist/collective-closed-loop-runtime.d.ts.map +1 -0
  40. package/dist/collective-closed-loop-runtime.js +1192 -0
  41. package/dist/collective-closed-loop-runtime.js.map +1 -0
  42. package/dist/collective-effect-provenance.d.ts +5 -0
  43. package/dist/collective-effect-provenance.d.ts.map +1 -0
  44. package/dist/collective-effect-provenance.js +32 -0
  45. package/dist/collective-effect-provenance.js.map +1 -0
  46. package/dist/collective-environment.d.ts +49 -0
  47. package/dist/collective-environment.d.ts.map +1 -0
  48. package/dist/collective-environment.js +907 -0
  49. package/dist/collective-environment.js.map +1 -0
  50. package/dist/collective-progressive-scale-overlay.d.ts +39 -0
  51. package/dist/collective-progressive-scale-overlay.d.ts.map +1 -0
  52. package/dist/collective-progressive-scale-overlay.js +147 -0
  53. package/dist/collective-progressive-scale-overlay.js.map +1 -0
  54. package/dist/collective-progressive-scale.d.ts +202 -0
  55. package/dist/collective-progressive-scale.d.ts.map +1 -0
  56. package/dist/collective-progressive-scale.js +755 -0
  57. package/dist/collective-progressive-scale.js.map +1 -0
  58. package/dist/collective-statistical-campaign-aggregation.d.ts +97 -0
  59. package/dist/collective-statistical-campaign-aggregation.d.ts.map +1 -0
  60. package/dist/collective-statistical-campaign-aggregation.js +446 -0
  61. package/dist/collective-statistical-campaign-aggregation.js.map +1 -0
  62. package/dist/collective-statistical-campaign-artifact-stream.d.ts +66 -0
  63. package/dist/collective-statistical-campaign-artifact-stream.d.ts.map +1 -0
  64. package/dist/collective-statistical-campaign-artifact-stream.js +207 -0
  65. package/dist/collective-statistical-campaign-artifact-stream.js.map +1 -0
  66. package/dist/collective-statistical-campaign-bundle.d.ts +151 -0
  67. package/dist/collective-statistical-campaign-bundle.d.ts.map +1 -0
  68. package/dist/collective-statistical-campaign-bundle.js +885 -0
  69. package/dist/collective-statistical-campaign-bundle.js.map +1 -0
  70. package/dist/collective-statistical-campaign-executor.d.ts +131 -0
  71. package/dist/collective-statistical-campaign-executor.d.ts.map +1 -0
  72. package/dist/collective-statistical-campaign-executor.js +856 -0
  73. package/dist/collective-statistical-campaign-executor.js.map +1 -0
  74. package/dist/collective-statistical-campaign-normative-analysis.d.ts +85 -0
  75. package/dist/collective-statistical-campaign-normative-analysis.d.ts.map +1 -0
  76. package/dist/collective-statistical-campaign-normative-analysis.js +483 -0
  77. package/dist/collective-statistical-campaign-normative-analysis.js.map +1 -0
  78. package/dist/collective-statistical-campaign-normative-operation.d.ts +89 -0
  79. package/dist/collective-statistical-campaign-normative-operation.d.ts.map +1 -0
  80. package/dist/collective-statistical-campaign-normative-operation.js +266 -0
  81. package/dist/collective-statistical-campaign-normative-operation.js.map +1 -0
  82. package/dist/collective-statistical-campaign-normative-registry.d.ts +24 -0
  83. package/dist/collective-statistical-campaign-normative-registry.d.ts.map +1 -0
  84. package/dist/collective-statistical-campaign-normative-registry.js +163 -0
  85. package/dist/collective-statistical-campaign-normative-registry.js.map +1 -0
  86. package/dist/collective-statistical-campaign-registered-adapter.d.ts +16 -0
  87. package/dist/collective-statistical-campaign-registered-adapter.d.ts.map +1 -0
  88. package/dist/collective-statistical-campaign-registered-adapter.js +518 -0
  89. package/dist/collective-statistical-campaign-registered-adapter.js.map +1 -0
  90. package/dist/collective-statistical-campaign-scale.d.ts +85 -0
  91. package/dist/collective-statistical-campaign-scale.d.ts.map +1 -0
  92. package/dist/collective-statistical-campaign-scale.js +349 -0
  93. package/dist/collective-statistical-campaign-scale.js.map +1 -0
  94. package/dist/collective-trace-journal.d.ts +20 -0
  95. package/dist/collective-trace-journal.d.ts.map +1 -0
  96. package/dist/collective-trace-journal.js +105 -0
  97. package/dist/collective-trace-journal.js.map +1 -0
  98. package/dist/index.d.ts +25 -0
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/index.js +25 -0
  101. package/dist/index.js.map +1 -1
  102. package/dist/multi-domain-environment-contracts.d.ts +122 -0
  103. package/dist/multi-domain-environment-contracts.d.ts.map +1 -0
  104. package/dist/multi-domain-environment-contracts.js +14 -0
  105. package/dist/multi-domain-environment-contracts.js.map +1 -0
  106. package/dist/multi-domain-environment-runtime.d.ts +25 -0
  107. package/dist/multi-domain-environment-runtime.d.ts.map +1 -0
  108. package/dist/multi-domain-environment-runtime.js +493 -0
  109. package/dist/multi-domain-environment-runtime.js.map +1 -0
  110. package/dist/multi-domain-environment-validation.d.ts +33 -0
  111. package/dist/multi-domain-environment-validation.d.ts.map +1 -0
  112. package/dist/multi-domain-environment-validation.js +415 -0
  113. package/dist/multi-domain-environment-validation.js.map +1 -0
  114. package/dist/multi-domain-environment.d.ts +4 -0
  115. package/dist/multi-domain-environment.d.ts.map +1 -0
  116. package/dist/multi-domain-environment.js +4 -0
  117. package/dist/multi-domain-environment.js.map +1 -0
  118. package/dist/reducer-scenario.d.ts.map +1 -1
  119. package/dist/reducer-scenario.js +67 -19
  120. package/dist/reducer-scenario.js.map +1 -1
  121. package/dist/scalable-evaluation-contracts.d.ts +835 -0
  122. package/dist/scalable-evaluation-contracts.d.ts.map +1 -0
  123. package/dist/scalable-evaluation-contracts.js +22 -0
  124. package/dist/scalable-evaluation-contracts.js.map +1 -0
  125. package/dist/scalable-evaluation-durability.d.ts +16 -0
  126. package/dist/scalable-evaluation-durability.d.ts.map +1 -0
  127. package/dist/scalable-evaluation-durability.js +339 -0
  128. package/dist/scalable-evaluation-durability.js.map +1 -0
  129. package/dist/scalable-evaluation-evidence.d.ts +93 -0
  130. package/dist/scalable-evaluation-evidence.d.ts.map +1 -0
  131. package/dist/scalable-evaluation-evidence.js +470 -0
  132. package/dist/scalable-evaluation-evidence.js.map +1 -0
  133. package/dist/scalable-evaluation-reference-integrated.d.ts +87 -0
  134. package/dist/scalable-evaluation-reference-integrated.d.ts.map +1 -0
  135. package/dist/scalable-evaluation-reference-integrated.js +1318 -0
  136. package/dist/scalable-evaluation-reference-integrated.js.map +1 -0
  137. package/dist/scalable-evaluation-runner.d.ts +8 -0
  138. package/dist/scalable-evaluation-runner.d.ts.map +1 -0
  139. package/dist/scalable-evaluation-runner.js +1810 -0
  140. package/dist/scalable-evaluation-runner.js.map +1 -0
  141. package/dist/scalable-evaluation-runtime.d.ts +86 -0
  142. package/dist/scalable-evaluation-runtime.d.ts.map +1 -0
  143. package/dist/scalable-evaluation-runtime.js +1310 -0
  144. package/dist/scalable-evaluation-runtime.js.map +1 -0
  145. package/dist/scalable-evaluation-validation.d.ts +59 -0
  146. package/dist/scalable-evaluation-validation.d.ts.map +1 -0
  147. package/dist/scalable-evaluation-validation.js +377 -0
  148. package/dist/scalable-evaluation-validation.js.map +1 -0
  149. package/dist/scalable-evaluation.d.ts +8 -0
  150. package/dist/scalable-evaluation.d.ts.map +1 -0
  151. package/dist/scalable-evaluation.js +8 -0
  152. package/dist/scalable-evaluation.js.map +1 -0
  153. package/dist/sharded-simulation-contracts.d.ts +240 -0
  154. package/dist/sharded-simulation-contracts.d.ts.map +1 -0
  155. package/dist/sharded-simulation-contracts.js +199 -0
  156. package/dist/sharded-simulation-contracts.js.map +1 -0
  157. package/dist/sharded-simulation-runtime.d.ts +64 -0
  158. package/dist/sharded-simulation-runtime.d.ts.map +1 -0
  159. package/dist/sharded-simulation-runtime.js +755 -0
  160. package/dist/sharded-simulation-runtime.js.map +1 -0
  161. package/dist/sharded-simulation-validation.d.ts +10 -0
  162. package/dist/sharded-simulation-validation.d.ts.map +1 -0
  163. package/dist/sharded-simulation-validation.js +250 -0
  164. package/dist/sharded-simulation-validation.js.map +1 -0
  165. package/dist/sharded-simulation.d.ts +46 -0
  166. package/dist/sharded-simulation.d.ts.map +1 -0
  167. package/dist/sharded-simulation.js +32 -0
  168. package/dist/sharded-simulation.js.map +1 -0
  169. package/dist/verified-benchmark-contracts.d.ts +132 -0
  170. package/dist/verified-benchmark-contracts.d.ts.map +1 -0
  171. package/dist/verified-benchmark-contracts.js +2 -0
  172. package/dist/verified-benchmark-contracts.js.map +1 -0
  173. package/dist/verified-benchmark-runtime.d.ts +20 -0
  174. package/dist/verified-benchmark-runtime.d.ts.map +1 -0
  175. package/dist/verified-benchmark-runtime.js +199 -0
  176. package/dist/verified-benchmark-runtime.js.map +1 -0
  177. package/dist/verified-benchmark-validation.d.ts +64 -0
  178. package/dist/verified-benchmark-validation.d.ts.map +1 -0
  179. package/dist/verified-benchmark-validation.js +481 -0
  180. package/dist/verified-benchmark-validation.js.map +1 -0
  181. package/dist/verified-benchmark.d.ts +4 -0
  182. package/dist/verified-benchmark.d.ts.map +1 -0
  183. package/dist/verified-benchmark.js +4 -0
  184. package/dist/verified-benchmark.js.map +1 -0
  185. package/package.json +18 -8
@@ -0,0 +1,240 @@
1
+ import { type PlanningDigestV1, type PlanningJson } from "@agentplat/collective-planning";
2
+ import { type CollectiveProgressiveScaleTierV1 } from "./collective-progressive-scale.js";
3
+ /** Closed interoperability envelopes, deliberately aligned with sparse overlay scale tiers. */
4
+ export declare const SHARDED_SIMULATION_SCALE_PROFILE_IDS_V1: readonly ["peers-500-interactions-5000", "peers-5000-interactions-50000", "peers-100000-interactions-1000000"];
5
+ export type ShardedSimulationScaleProfileIdV1 = (typeof SHARDED_SIMULATION_SCALE_PROFILE_IDS_V1)[number];
6
+ /** Hard protocol limits. Adapters must reject excess input before allocating state. */
7
+ export declare const SHARDED_SIMULATION_LIMITS_V1: Readonly<{
8
+ readonly maximumFaults: 4096;
9
+ readonly maximumTargetsPerFault: 4096;
10
+ readonly maximumTotalTargetsAcrossSchedule: 16384;
11
+ readonly maximumMessagesPerBatch: 4096;
12
+ readonly maximumObservationsPerDelivery: 1024;
13
+ readonly maximumIdentifierLength: 256;
14
+ }>;
15
+ export interface ShardedSimulationScaleProfileV1 {
16
+ readonly schemaVersion: 1;
17
+ readonly profileId: ShardedSimulationScaleProfileIdV1;
18
+ readonly tier: CollectiveProgressiveScaleTierV1;
19
+ readonly logicalPeerCount: 500 | 5_000 | 100_000;
20
+ readonly interactionCeiling: 5_000 | 50_000 | 1_000_000;
21
+ readonly overlayProfileId: "standard-500" | "large-5000" | "frontier-100000";
22
+ readonly profileDigest: PlanningDigestV1;
23
+ }
24
+ export interface ShardedSimulationEnvironmentSessionV1 {
25
+ readonly schemaVersion: 1;
26
+ readonly sessionId: string;
27
+ readonly environmentId: string;
28
+ readonly createdAtLogicalTime: number;
29
+ readonly sessionDigest: PlanningDigestV1;
30
+ }
31
+ export interface ShardedSimulationEpisodeV1 {
32
+ readonly schemaVersion: 1;
33
+ readonly sessionId: string;
34
+ readonly episodeId: string;
35
+ readonly seed: number;
36
+ readonly startedAtLogicalTime: number;
37
+ readonly episodeDigest: PlanningDigestV1;
38
+ }
39
+ /** This is an explicit public projection. The bridge must never attach private environment state. */
40
+ export interface ShardedSimulationPartialObservationPullV1 {
41
+ readonly schemaVersion: 1;
42
+ readonly sessionId: string;
43
+ readonly episodeId: string;
44
+ readonly peerIndex: number;
45
+ readonly logicalTime: number;
46
+ readonly cursor: string | null;
47
+ readonly requestId: string;
48
+ }
49
+ export interface ShardedSimulationPartialObservationDeliveryV1 {
50
+ readonly schemaVersion: 1;
51
+ readonly requestId: string;
52
+ readonly peerIndex: number;
53
+ readonly logicalTime: number;
54
+ readonly observations: readonly PlanningJson[];
55
+ readonly nextCursor: string | null;
56
+ readonly deliveryDigest: PlanningDigestV1;
57
+ }
58
+ export interface ShardedSimulationFencedActionRequestV1 {
59
+ readonly schemaVersion: 1;
60
+ readonly actionId: string;
61
+ readonly sessionId: string;
62
+ readonly episodeId: string;
63
+ readonly peerIndex: number;
64
+ readonly logicalTime: number;
65
+ readonly executionEpoch: number;
66
+ readonly fenceToken: string;
67
+ readonly action: PlanningJson;
68
+ readonly actionDigest: PlanningDigestV1;
69
+ }
70
+ export interface ShardedSimulationEffectReceiptV1 {
71
+ readonly schemaVersion: 1;
72
+ readonly actionId: string;
73
+ readonly accepted: boolean;
74
+ readonly logicalTime: number;
75
+ readonly executionEpoch: number;
76
+ readonly fenceToken: string;
77
+ readonly effectDigest: PlanningDigestV1;
78
+ readonly receiptDigest: PlanningDigestV1;
79
+ }
80
+ export interface ShardedSimulationDurableAnchorV1 {
81
+ readonly schemaVersion: 1;
82
+ readonly anchorId: string;
83
+ readonly revision: number;
84
+ readonly previousAnchorDigest: PlanningDigestV1 | null;
85
+ readonly anchorDigest: PlanningDigestV1;
86
+ }
87
+ export interface ShardedSimulationCheckpointV1 {
88
+ readonly schemaVersion: 1;
89
+ readonly checkpointId: string;
90
+ readonly sessionId: string;
91
+ readonly episodeId: string;
92
+ readonly revision: number;
93
+ readonly logicalTime: number;
94
+ /** Opaque evaluator-owned snapshot reference; snapshot contents never cross this contract. */
95
+ readonly snapshotHandle: string;
96
+ readonly snapshotDigest: PlanningDigestV1;
97
+ readonly anchor: ShardedSimulationDurableAnchorV1;
98
+ readonly checkpointDigest: PlanningDigestV1;
99
+ }
100
+ export interface ShardedSimulationRestoreRequestV1 {
101
+ readonly schemaVersion: 1;
102
+ readonly checkpoint: ShardedSimulationCheckpointV1;
103
+ readonly expectedAnchorDigest: PlanningDigestV1;
104
+ }
105
+ export interface ShardedSimulationRestoreReceiptV1 {
106
+ readonly schemaVersion: 1;
107
+ readonly checkpointId: string;
108
+ readonly restoredRevision: number;
109
+ readonly restoredLogicalTime: number;
110
+ readonly receiptDigest: PlanningDigestV1;
111
+ }
112
+ export interface ShardedSimulationShardAssignmentV1 {
113
+ readonly schemaVersion: 1;
114
+ readonly shardId: string;
115
+ readonly shardIndex: number;
116
+ readonly shardCount: number;
117
+ readonly peerStartInclusive: number;
118
+ readonly peerEndExclusive: number;
119
+ readonly interactionStartInclusive: number;
120
+ readonly interactionEndExclusive: number;
121
+ readonly assignmentDigest: PlanningDigestV1;
122
+ }
123
+ export interface ShardedSimulationCrossShardMessageV1 {
124
+ readonly schemaVersion: 1;
125
+ readonly eventId: string;
126
+ readonly sourcePeerIndex: number;
127
+ readonly targetPeerIndex: number;
128
+ readonly logicalTime: number;
129
+ readonly payloadDigest: PlanningDigestV1;
130
+ }
131
+ export interface ShardedSimulationCrossShardMessageBatchV1 {
132
+ readonly schemaVersion: 1;
133
+ readonly batchId: string;
134
+ readonly sessionId: string;
135
+ readonly episodeId: string;
136
+ readonly sourceShardId: string;
137
+ readonly targetShardId: string;
138
+ readonly logicalTime: number;
139
+ readonly messages: readonly ShardedSimulationCrossShardMessageV1[];
140
+ readonly batchDigest: PlanningDigestV1;
141
+ }
142
+ export interface ShardedSimulationCrossShardMessageAckV1 {
143
+ readonly schemaVersion: 1;
144
+ readonly batchId: string;
145
+ readonly batchDigest: PlanningDigestV1;
146
+ readonly accepted: boolean;
147
+ readonly duplicate: boolean;
148
+ readonly deliveredEventIds: readonly string[];
149
+ readonly ackDigest: PlanningDigestV1;
150
+ }
151
+ export type ShardedSimulationFaultKindV1 = "failure" | "restart" | "partition" | "heal" | "compromised-actor" | "rogue-actor" | "misleading-observation" | "conflicting-observation";
152
+ export interface ShardedSimulationFaultScheduleEntryV1 {
153
+ readonly schemaVersion: 1;
154
+ readonly faultId: string;
155
+ readonly kind: ShardedSimulationFaultKindV1;
156
+ readonly logicalTime: number;
157
+ readonly targetPeerIndexes: readonly number[];
158
+ readonly faultDigest: PlanningDigestV1;
159
+ }
160
+ export interface ShardedSimulationFaultObservationV1 {
161
+ readonly schemaVersion: 1;
162
+ readonly faultId: string;
163
+ readonly kind: ShardedSimulationFaultKindV1;
164
+ readonly observedAtLogicalTime: number;
165
+ readonly observationDigest: PlanningDigestV1;
166
+ }
167
+ /** Evaluators aggregate these content-free counters; neither runner nor peers receive a verdict. */
168
+ export interface ShardedSimulationMetricSampleV1 {
169
+ readonly schemaVersion: 1;
170
+ readonly interactionCount: number;
171
+ readonly missionSuccessCount: number;
172
+ readonly recoveryToBaselineCount: number;
173
+ readonly roleCoherenceLength: number;
174
+ }
175
+ export interface ShardedSimulationMetricAggregateV1 extends ShardedSimulationMetricSampleV1 {
176
+ readonly metricDigest: PlanningDigestV1;
177
+ }
178
+ /** Transport-neutral boundary. HTTP and gRPC adapters can implement this without SDK coupling. */
179
+ export interface ShardedSimulationEnvironmentBridgeV1 {
180
+ createSession(input: {
181
+ readonly environmentId: string;
182
+ readonly logicalTime: number;
183
+ }): ShardedSimulationEnvironmentSessionV1 | Promise<ShardedSimulationEnvironmentSessionV1>;
184
+ startEpisode(input: {
185
+ readonly session: ShardedSimulationEnvironmentSessionV1;
186
+ readonly episodeId: string;
187
+ readonly seed: number;
188
+ readonly logicalTime: number;
189
+ }): ShardedSimulationEpisodeV1 | Promise<ShardedSimulationEpisodeV1>;
190
+ bindShardAssignments(input: {
191
+ readonly session: ShardedSimulationEnvironmentSessionV1;
192
+ readonly episode: ShardedSimulationEpisodeV1;
193
+ readonly profile: ShardedSimulationScaleProfileV1;
194
+ readonly assignments: readonly ShardedSimulationShardAssignmentV1[];
195
+ }): void | Promise<void>;
196
+ pullPartialObservation(input: ShardedSimulationPartialObservationPullV1): ShardedSimulationPartialObservationDeliveryV1 | Promise<ShardedSimulationPartialObservationDeliveryV1>;
197
+ requestEffect(input: ShardedSimulationFencedActionRequestV1): ShardedSimulationEffectReceiptV1 | Promise<ShardedSimulationEffectReceiptV1>;
198
+ deliverCrossShardBatch(input: ShardedSimulationCrossShardMessageBatchV1): ShardedSimulationCrossShardMessageAckV1 | Promise<ShardedSimulationCrossShardMessageAckV1>;
199
+ checkpoint(input: {
200
+ readonly session: ShardedSimulationEnvironmentSessionV1;
201
+ readonly episode: ShardedSimulationEpisodeV1;
202
+ readonly expectedRevision: number;
203
+ readonly logicalTime: number;
204
+ }): ShardedSimulationCheckpointV1 | Promise<ShardedSimulationCheckpointV1>;
205
+ restore(input: ShardedSimulationRestoreRequestV1): ShardedSimulationRestoreReceiptV1 | Promise<ShardedSimulationRestoreReceiptV1>;
206
+ }
207
+ /** Evaluator authority is separate from the runner-visible environment bridge. */
208
+ export interface ShardedSimulationEvaluatorPortV1 {
209
+ finalizeMetrics(input: {
210
+ readonly session: ShardedSimulationEnvironmentSessionV1;
211
+ readonly episode: ShardedSimulationEpisodeV1;
212
+ readonly interactionCount: number;
213
+ }): ShardedSimulationMetricAggregateV1 | Promise<ShardedSimulationMetricAggregateV1>;
214
+ }
215
+ export declare function shardedSimulationScaleProfileV1(profileId: ShardedSimulationScaleProfileIdV1): ShardedSimulationScaleProfileV1;
216
+ export declare const SHARDED_SIMULATION_SCALE_PROFILES_V1: readonly ShardedSimulationScaleProfileV1[];
217
+ export declare function createShardedSimulationAssignmentsV1(input: {
218
+ readonly profile: ShardedSimulationScaleProfileV1;
219
+ readonly shardCount: number;
220
+ }): readonly ShardedSimulationShardAssignmentV1[];
221
+ export declare function shardedSimulationAssignmentForPeerV1(assignments: readonly ShardedSimulationShardAssignmentV1[], peerIndex: number): ShardedSimulationShardAssignmentV1;
222
+ /** Binds an action's intent to its session, episode, ownership fence, and payload. */
223
+ export declare function shardedSimulationFencedActionDigestV1(input: Omit<ShardedSimulationFencedActionRequestV1, "actionDigest">): PlanningDigestV1;
224
+ /**
225
+ * Produces the one wire representation of a batch. Message order and digest
226
+ * deliberately do not depend on the transport's iteration order.
227
+ */
228
+ export declare function createShardedSimulationCrossShardMessageBatchV1(input: {
229
+ readonly batchId: string;
230
+ readonly sessionId: string;
231
+ readonly episodeId: string;
232
+ readonly sourceShardId: string;
233
+ readonly targetShardId: string;
234
+ readonly logicalTime: number;
235
+ readonly messages: readonly ShardedSimulationCrossShardMessageV1[];
236
+ }): ShardedSimulationCrossShardMessageBatchV1;
237
+ export declare function canonicalShardedSimulationMessagesV1(messages: readonly ShardedSimulationCrossShardMessageV1[]): readonly ShardedSimulationCrossShardMessageV1[];
238
+ export declare function aggregateShardedSimulationMetricsV1(samples: readonly ShardedSimulationMetricSampleV1[]): ShardedSimulationMetricAggregateV1;
239
+ export declare function shardedSimulationDigestV1(domain: string, value: unknown): PlanningDigestV1;
240
+ //# sourceMappingURL=sharded-simulation-contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharded-simulation-contracts.d.ts","sourceRoot":"","sources":["../src/sharded-simulation-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,KAAK,gCAAgC,EACtC,MAAM,mCAAmC,CAAC;AAE3C,+FAA+F;AAC/F,eAAO,MAAM,uCAAuC,gHAIzC,CAAC;AACZ,MAAM,MAAM,iCAAiC,GAC3C,CAAC,OAAO,uCAAuC,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D,uFAAuF;AACvF,eAAO,MAAM,4BAA4B;;;;;;;EAO9B,CAAC;AAEZ,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,iCAAiC,CAAC;IACtD,QAAQ,CAAC,IAAI,EAAE,gCAAgC,CAAC;IAChD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,GAAG,KAAK,GAAG,OAAO,CAAC;IACjD,QAAQ,CAAC,kBAAkB,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;IACxD,QAAQ,CAAC,gBAAgB,EAAE,cAAc,GAAG,YAAY,GAAG,iBAAiB,CAAC;IAC7E,QAAQ,CAAC,aAAa,EAAE,gBAAgB,CAAC;CAC1C;AAED,MAAM,WAAW,qCAAqC;IACpD,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;I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AAK,EAAE,OAAO,GACb,gBAAgB,CAElB"}
@@ -0,0 +1,199 @@
1
+ import { deepFreezePlanning, digestPlanningJsonV1, } from "@agentplat/collective-planning";
2
+ import { collectiveProgressiveScaleProfileV1, } from "./collective-progressive-scale.js";
3
+ /** Closed interoperability envelopes, deliberately aligned with sparse overlay scale tiers. */
4
+ export const SHARDED_SIMULATION_SCALE_PROFILE_IDS_V1 = Object.freeze([
5
+ "peers-500-interactions-5000",
6
+ "peers-5000-interactions-50000",
7
+ "peers-100000-interactions-1000000",
8
+ ]);
9
+ /** Hard protocol limits. Adapters must reject excess input before allocating state. */
10
+ export const SHARDED_SIMULATION_LIMITS_V1 = Object.freeze({
11
+ maximumFaults: 4_096,
12
+ maximumTargetsPerFault: 4_096,
13
+ maximumTotalTargetsAcrossSchedule: 16_384,
14
+ maximumMessagesPerBatch: 4_096,
15
+ maximumObservationsPerDelivery: 1_024,
16
+ maximumIdentifierLength: 256,
17
+ });
18
+ export function shardedSimulationScaleProfileV1(profileId) {
19
+ const record = profileRecord(profileId);
20
+ const progressive = collectiveProgressiveScaleProfileV1(record.tier);
21
+ const body = {
22
+ schemaVersion: 1,
23
+ profileId,
24
+ tier: record.tier,
25
+ logicalPeerCount: progressive.agentCount,
26
+ interactionCeiling: progressive.maximumInteractions,
27
+ overlayProfileId: record.overlayProfileId,
28
+ };
29
+ return freeze({
30
+ ...body,
31
+ profileDigest: digest("sharded-simulation-scale-profile-v1", body),
32
+ });
33
+ }
34
+ export const SHARDED_SIMULATION_SCALE_PROFILES_V1 = Object.freeze(SHARDED_SIMULATION_SCALE_PROFILE_IDS_V1.map(shardedSimulationScaleProfileV1));
35
+ export function createShardedSimulationAssignmentsV1(input) {
36
+ positiveInteger(input.shardCount, "shardCount");
37
+ if (input.shardCount > input.profile.logicalPeerCount)
38
+ throw new RangeError("sharded_simulation_shard_count_exceeds_peers");
39
+ const width = String(input.shardCount - 1).length;
40
+ return Object.freeze(Array.from({ length: input.shardCount }, (_, shardIndex) => {
41
+ const body = {
42
+ schemaVersion: 1,
43
+ shardId: `shard-${String(shardIndex).padStart(width, "0")}`,
44
+ shardIndex,
45
+ shardCount: input.shardCount,
46
+ peerStartInclusive: partition(input.profile.logicalPeerCount, shardIndex, input.shardCount),
47
+ peerEndExclusive: partition(input.profile.logicalPeerCount, shardIndex + 1, input.shardCount),
48
+ interactionStartInclusive: partition(input.profile.interactionCeiling, shardIndex, input.shardCount),
49
+ interactionEndExclusive: partition(input.profile.interactionCeiling, shardIndex + 1, input.shardCount),
50
+ };
51
+ return freeze({
52
+ ...body,
53
+ assignmentDigest: digest("sharded-simulation-assignment-v1", body),
54
+ });
55
+ }));
56
+ }
57
+ export function shardedSimulationAssignmentForPeerV1(assignments, peerIndex) {
58
+ positiveInteger(peerIndex, "peerIndex", true);
59
+ const first = assignments[0];
60
+ if (!first || assignments.length !== first.shardCount)
61
+ throw new TypeError("sharded_simulation_assignments_invalid");
62
+ const totalPeers = assignments[assignments.length - 1].peerEndExclusive;
63
+ if (peerIndex >= totalPeers)
64
+ throw new RangeError("sharded_simulation_peer_not_assigned");
65
+ // For ranges floor(N*i/S)..floor(N*(i+1)/S), this locates i in constant time.
66
+ const shardIndex = Math.floor(((peerIndex + 1) * first.shardCount - 1) / totalPeers);
67
+ const assignment = assignments[shardIndex];
68
+ if (!assignment ||
69
+ peerIndex < assignment.peerStartInclusive ||
70
+ peerIndex >= assignment.peerEndExclusive)
71
+ throw new RangeError("sharded_simulation_peer_not_assigned");
72
+ return assignment;
73
+ }
74
+ /** Binds an action's intent to its session, episode, ownership fence, and payload. */
75
+ export function shardedSimulationFencedActionDigestV1(input) {
76
+ return digest("sharded-simulation-fenced-action-v1", input);
77
+ }
78
+ /**
79
+ * Produces the one wire representation of a batch. Message order and digest
80
+ * deliberately do not depend on the transport's iteration order.
81
+ */
82
+ export function createShardedSimulationCrossShardMessageBatchV1(input) {
83
+ for (const identifier of [
84
+ input.batchId,
85
+ input.sessionId,
86
+ input.episodeId,
87
+ input.sourceShardId,
88
+ input.targetShardId,
89
+ ])
90
+ boundedIdentifier(identifier, "sharded_simulation_batch_identifier_invalid");
91
+ positiveInteger(input.logicalTime, "logicalTime", true);
92
+ const messages = canonicalShardedSimulationMessagesV1(input.messages);
93
+ const body = {
94
+ schemaVersion: 1,
95
+ batchId: input.batchId,
96
+ sessionId: input.sessionId,
97
+ episodeId: input.episodeId,
98
+ sourceShardId: input.sourceShardId,
99
+ targetShardId: input.targetShardId,
100
+ logicalTime: input.logicalTime,
101
+ messages,
102
+ };
103
+ return freeze({
104
+ ...body,
105
+ batchDigest: digest("sharded-simulation-cross-shard-batch-v1", body),
106
+ });
107
+ }
108
+ export function canonicalShardedSimulationMessagesV1(messages) {
109
+ if (messages.length > SHARDED_SIMULATION_LIMITS_V1.maximumMessagesPerBatch)
110
+ throw new RangeError("sharded_simulation_batch_message_limit_exceeded");
111
+ for (const message of messages) {
112
+ if (message.schemaVersion !== 1 ||
113
+ !Number.isSafeInteger(message.sourcePeerIndex) ||
114
+ message.sourcePeerIndex < 0 ||
115
+ !Number.isSafeInteger(message.targetPeerIndex) ||
116
+ message.targetPeerIndex < 0 ||
117
+ !Number.isSafeInteger(message.logicalTime) ||
118
+ message.logicalTime < 0 ||
119
+ !/^sha256:[0-9a-f]{64}$/u.test(message.payloadDigest))
120
+ throw new TypeError("sharded_simulation_message_invalid");
121
+ boundedIdentifier(message.eventId, "sharded_simulation_message_identifier_invalid");
122
+ }
123
+ const sorted = [...messages].sort((left, right) => left.eventId.localeCompare(right.eventId));
124
+ if (new Set(sorted.map((message) => message.eventId)).size !== sorted.length)
125
+ throw new TypeError("sharded_simulation_message_duplicate");
126
+ return Object.freeze(sorted.map((message) => freeze({ ...message })));
127
+ }
128
+ export function aggregateShardedSimulationMetricsV1(samples) {
129
+ const body = samples.reduce((total, sample) => {
130
+ for (const value of [
131
+ sample.interactionCount,
132
+ sample.missionSuccessCount,
133
+ sample.recoveryToBaselineCount,
134
+ sample.roleCoherenceLength,
135
+ ])
136
+ if (!Number.isSafeInteger(value) || value < 0 || value > 1_000_000_000)
137
+ throw new RangeError("sharded_simulation_metric_sample_invalid");
138
+ const next = {
139
+ schemaVersion: 1,
140
+ interactionCount: total.interactionCount + sample.interactionCount,
141
+ missionSuccessCount: total.missionSuccessCount + sample.missionSuccessCount,
142
+ recoveryToBaselineCount: total.recoveryToBaselineCount + sample.recoveryToBaselineCount,
143
+ roleCoherenceLength: total.roleCoherenceLength + sample.roleCoherenceLength,
144
+ };
145
+ if (!Number.isSafeInteger(next.interactionCount) ||
146
+ !Number.isSafeInteger(next.missionSuccessCount) ||
147
+ !Number.isSafeInteger(next.recoveryToBaselineCount) ||
148
+ !Number.isSafeInteger(next.roleCoherenceLength))
149
+ throw new RangeError("sharded_simulation_metric_sum_overflow");
150
+ return next;
151
+ }, {
152
+ schemaVersion: 1,
153
+ interactionCount: 0,
154
+ missionSuccessCount: 0,
155
+ recoveryToBaselineCount: 0,
156
+ roleCoherenceLength: 0,
157
+ });
158
+ return freeze({
159
+ ...body,
160
+ metricDigest: digest("sharded-simulation-metrics-v1", body),
161
+ });
162
+ }
163
+ export function shardedSimulationDigestV1(domain, value) {
164
+ return digest(domain, value);
165
+ }
166
+ function profileRecord(profileId) {
167
+ switch (profileId) {
168
+ case "peers-500-interactions-5000":
169
+ return { tier: "baseline", overlayProfileId: "standard-500" };
170
+ case "peers-5000-interactions-50000":
171
+ return { tier: "resilient", overlayProfileId: "large-5000" };
172
+ case "peers-100000-interactions-1000000":
173
+ return { tier: "frontier", overlayProfileId: "frontier-100000" };
174
+ }
175
+ }
176
+ function partition(total, index, count) {
177
+ return Math.floor((total * index) / count);
178
+ }
179
+ function positiveInteger(value, label, allowZero = false) {
180
+ if (!Number.isSafeInteger(value) || value < (allowZero ? 0 : 1))
181
+ throw new TypeError(`${label} must be a safe integer`);
182
+ }
183
+ function boundedIdentifier(value, code) {
184
+ if (typeof value !== "string" ||
185
+ value.length === 0 ||
186
+ value.length > SHARDED_SIMULATION_LIMITS_V1.maximumIdentifierLength)
187
+ throw new TypeError(code);
188
+ }
189
+ /** The shared canonical digest registry is closed; preserve this module's domain inside its canonical payload. */
190
+ function digest(domain, value) {
191
+ return digestPlanningJsonV1("environment-state-v1", {
192
+ domain,
193
+ value,
194
+ });
195
+ }
196
+ function freeze(value) {
197
+ return deepFreezePlanning(value);
198
+ }
199
+ //# sourceMappingURL=sharded-simulation-contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharded-simulation-contracts.js","sourceRoot":"","sources":["../src/sharded-simulation-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,oBAAoB,GAGrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,mCAAmC,GAEpC,MAAM,mCAAmC,CAAC;AAE3C,+FAA+F;AAC/F,MAAM,CAAC,MAAM,uCAAuC,GAAG,MAAM,CAAC,MAAM,CAAC;IACnE,6BAA6B;IAC7B,+BAA+B;IAC/B,mCAAmC;CAC3B,CAAC,CAAC;AAIZ,uFAAuF;AACvF,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,CAAC;IACxD,aAAa,EAAE,KAAK;IACpB,sBAAsB,EAAE,KAAK;IAC7B,iCAAiC,EAAE,MAAM;IACzC,uBAAuB,EAAE,KAAK;IAC9B,8BAA8B,EAAE,KAAK;IACrC,uBAAuB,EAAE,GAAG;CACpB,CAAC,CAAC;AA4PZ,MAAM,UAAU,+BAA+B,CAC7C,SAA4C;IAE5C,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,mCAAmC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACrE,MAAM,IAAI,GAAG;QACX,aAAa,EAAE,CAAU;QACzB,SAAS;QACT,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,gBAAgB,EAAE,WAAW,CAAC,UAAU;QACxC,kBAAkB,EAAE,WAAW,CAAC,mBAAmB;QACnD,gBA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AAC9E,CAAC"}
@@ -0,0 +1,64 @@
1
+ import type { PlanningDigestV1 } from "@agentplat/collective-planning";
2
+ import { type ShardedSimulationCheckpointV1, type ShardedSimulationCrossShardMessageAckV1, type ShardedSimulationCrossShardMessageBatchV1, type ShardedSimulationEffectReceiptV1, type ShardedSimulationEnvironmentBridgeV1, type ShardedSimulationEnvironmentSessionV1, type ShardedSimulationEpisodeV1, type ShardedSimulationEvaluatorPortV1, type ShardedSimulationFaultObservationV1, type ShardedSimulationFaultScheduleEntryV1, type ShardedSimulationMetricAggregateV1, type ShardedSimulationPartialObservationDeliveryV1, type ShardedSimulationRestoreReceiptV1, type ShardedSimulationRestoreRequestV1, type ShardedSimulationScaleProfileV1, type ShardedSimulationShardAssignmentV1 } from "./sharded-simulation-contracts.js";
3
+ /** Local composition only. Snapshots stay private to this instance and are never serialized to a runner. */
4
+ export declare class InMemoryShardedSimulationBridgeV1 implements ShardedSimulationEnvironmentBridgeV1, ShardedSimulationEvaluatorPortV1 {
5
+ #private;
6
+ createSession(input: {
7
+ readonly environmentId: string;
8
+ readonly logicalTime: number;
9
+ }): ShardedSimulationEnvironmentSessionV1;
10
+ startEpisode(input: {
11
+ readonly session: ShardedSimulationEnvironmentSessionV1;
12
+ readonly episodeId: string;
13
+ readonly seed: number;
14
+ readonly logicalTime: number;
15
+ }): ShardedSimulationEpisodeV1;
16
+ bindShardAssignments(input: {
17
+ readonly session: ShardedSimulationEnvironmentSessionV1;
18
+ readonly episode: ShardedSimulationEpisodeV1;
19
+ readonly profile: ShardedSimulationScaleProfileV1;
20
+ readonly assignments: readonly ShardedSimulationShardAssignmentV1[];
21
+ }): void;
22
+ pullPartialObservation(input: Parameters<ShardedSimulationEnvironmentBridgeV1["pullPartialObservation"]>[0]): ShardedSimulationPartialObservationDeliveryV1;
23
+ requestEffect(input: Parameters<ShardedSimulationEnvironmentBridgeV1["requestEffect"]>[0]): ShardedSimulationEffectReceiptV1;
24
+ deliverCrossShardBatch(input: ShardedSimulationCrossShardMessageBatchV1): ShardedSimulationCrossShardMessageAckV1;
25
+ checkpoint(input: {
26
+ readonly session: ShardedSimulationEnvironmentSessionV1;
27
+ readonly episode: ShardedSimulationEpisodeV1;
28
+ readonly expectedRevision: number;
29
+ readonly logicalTime: number;
30
+ }): ShardedSimulationCheckpointV1;
31
+ restore(input: ShardedSimulationRestoreRequestV1): ShardedSimulationRestoreReceiptV1;
32
+ finalizeMetrics(input: {
33
+ readonly session: ShardedSimulationEnvironmentSessionV1;
34
+ readonly episode: ShardedSimulationEpisodeV1;
35
+ readonly interactionCount: number;
36
+ }): ShardedSimulationMetricAggregateV1;
37
+ }
38
+ export interface ShardedSimulationLogicalRunInputV1 {
39
+ readonly schemaVersion: 1;
40
+ readonly profile: ShardedSimulationScaleProfileV1;
41
+ readonly shardCount: number;
42
+ readonly interactionCount: number;
43
+ readonly seed: number;
44
+ readonly bridge?: ShardedSimulationEnvironmentBridgeV1;
45
+ readonly faults?: readonly ShardedSimulationFaultScheduleEntryV1[];
46
+ }
47
+ export interface ShardedSimulationLogicalRunResultV1 {
48
+ readonly schemaVersion: 1;
49
+ readonly traceDigest: PlanningDigestV1;
50
+ readonly interactionCount: number;
51
+ readonly faultObservations: readonly ShardedSimulationFaultObservationV1[];
52
+ readonly processedInteractions: number;
53
+ }
54
+ /** Streams logical interactions; only an evaluator port may derive success or coherence metrics. */
55
+ export declare function runShardedSimulationLogicalPeersV1(input: ShardedSimulationLogicalRunInputV1): Promise<ShardedSimulationLogicalRunResultV1>;
56
+ export declare function validateShardedSimulationEffectReceiptV1(value: unknown, request: {
57
+ readonly actionId: string;
58
+ readonly logicalTime: number;
59
+ readonly executionEpoch: number;
60
+ readonly fenceToken: string;
61
+ readonly actionDigest: PlanningDigestV1;
62
+ }): ShardedSimulationEffectReceiptV1;
63
+ export declare function validateShardedSimulationCrossShardMessageAckV1(value: unknown, batchId: string, batchDigest: PlanningDigestV1, expectedDeliveredEventIds: readonly string[]): void;
64
+ //# sourceMappingURL=sharded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