@almadar/core 2.7.0 → 2.9.0

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.
@@ -1239,6 +1239,41 @@ type LogEffect = ['log', ...unknown[]];
1239
1239
  * @example ['wait', 1000] - wait 1 second
1240
1240
  */
1241
1241
  type WaitEffect = ['wait', number];
1242
+ /**
1243
+ * Ref effect - creates a reactive entity subscription.
1244
+ * Returns a reactive reference that auto-updates when the entity changes.
1245
+ * @example ['ref', '@entity.health'] - reactive subscription to health
1246
+ * @example ['ref', 'User', { id: '@payload.userId' }] - reactive ref to specific user
1247
+ */
1248
+ type RefEffect = ['ref', string] | ['ref', string, Record<string, unknown>];
1249
+ /**
1250
+ * Deref effect - snapshot read of an entity value.
1251
+ * Returns the current value without subscribing to changes.
1252
+ * @example ['deref', '@entity.health'] - read current health value
1253
+ * @example ['deref', 'User', { id: '@payload.userId' }] - read specific user snapshot
1254
+ */
1255
+ type DerefEffect = ['deref', string] | ['deref', string, Record<string, unknown>];
1256
+ /**
1257
+ * Swap! effect - atomic compare-and-swap on an entity field.
1258
+ * Only updates if the current value matches the expected value.
1259
+ * @example ['swap!', '@entity.health', ['fn', ['old'], ['-', 'old', '@payload.damage']]]
1260
+ * @example ['swap!', '@entity.counter', ['+', '@entity.counter', 1]]
1261
+ */
1262
+ type SwapEffect = ['swap!', string, SExpr];
1263
+ /**
1264
+ * Watch effect - registers a callback for entity changes.
1265
+ * Emits an event whenever the watched binding changes.
1266
+ * @example ['watch', '@entity.health', 'HEALTH_CHANGED']
1267
+ * @example ['watch', '@entity.status', 'STATUS_UPDATED', { debounce: 100 }]
1268
+ */
1269
+ type WatchEffect = ['watch', string, string] | ['watch', string, string, Record<string, unknown>];
1270
+ /**
1271
+ * Atomic effect - groups multiple effects into an atomic transaction.
1272
+ * All effects either succeed together or are rolled back.
1273
+ * @example ['atomic', ['set', '@entity.x', 10], ['set', '@entity.y', 20]]
1274
+ * @example ['atomic', ['persist', 'update', 'User', { balance: 100 }], ['emit', 'BALANCE_UPDATED']]
1275
+ */
1276
+ type AtomicEffect = ['atomic', ...SExpr[]];
1242
1277
  /**
1243
1278
  * Forward effect - runs a neural network forward pass (Python backend).
1244
1279
  * @example ['forward', 'primary', { architecture: [...], input: '@payload.input', 'on-complete': 'PREDICTION_READY' }]
@@ -1306,7 +1341,7 @@ type AsyncSequenceEffect = ['async/sequence', ...Effect[]];
1306
1341
  * Union of all typed effects.
1307
1342
  * Provides compile-time validation for common effect types.
1308
1343
  */
1309
- type TypedEffect = RenderUIEffect | NavigateEffect | EmitEffect | SetEffect | PersistEffect | CallServiceEffect | SpawnEffect | DespawnEffect | DoEffect | NotifyEffect | FetchEffect | IfEffect | WhenEffect | LetEffect | LogEffect | WaitEffect | AsyncDelayEffect | AsyncDebounceEffect | AsyncThrottleEffect | AsyncIntervalEffect | AsyncRaceEffect | AsyncAllEffect | AsyncSequenceEffect | ForwardEffect | TrainEffect | EvaluateEffect | CheckpointSaveEffect | CheckpointLoadEffect;
1344
+ type TypedEffect = RenderUIEffect | NavigateEffect | EmitEffect | SetEffect | PersistEffect | CallServiceEffect | SpawnEffect | DespawnEffect | DoEffect | NotifyEffect | FetchEffect | IfEffect | WhenEffect | LetEffect | LogEffect | WaitEffect | RefEffect | DerefEffect | SwapEffect | WatchEffect | AtomicEffect | AsyncDelayEffect | AsyncDebounceEffect | AsyncThrottleEffect | AsyncIntervalEffect | AsyncRaceEffect | AsyncAllEffect | AsyncSequenceEffect | ForwardEffect | TrainEffect | EvaluateEffect | CheckpointSaveEffect | CheckpointLoadEffect;
1310
1345
  /**
1311
1346
  * Effect type - typed S-expression format.
1312
1347
  *
@@ -1447,6 +1482,81 @@ declare function doEffects(...effects: SExpr[]): DoEffect;
1447
1482
  */
1448
1483
  declare function notify(channel: 'email' | 'push' | 'sms' | 'in_app', message: string): NotifyEffect;
1449
1484
  declare function notify(channel: 'email' | 'push' | 'sms' | 'in_app', message: string, recipient: string): NotifyEffect;
1485
+ /**
1486
+ * Create a ref effect (reactive entity subscription).
1487
+ *
1488
+ * @param {string} binding - Binding or entity name to subscribe to
1489
+ * @param {Record<string, unknown>} [selector] - Optional selector for specific entity
1490
+ * @returns {RefEffect} Ref effect array
1491
+ *
1492
+ * @example
1493
+ * ref('@entity.health'); // returns ["ref", "@entity.health"]
1494
+ * ref('User', { id: '@payload.userId' }); // returns ["ref", "User", { id: "@payload.userId" }]
1495
+ */
1496
+ declare function ref(binding: string): RefEffect;
1497
+ declare function ref(binding: string, selector: Record<string, unknown>): RefEffect;
1498
+ /**
1499
+ * Create a deref effect (snapshot read).
1500
+ *
1501
+ * @param {string} binding - Binding or entity name to read
1502
+ * @param {Record<string, unknown>} [selector] - Optional selector for specific entity
1503
+ * @returns {DerefEffect} Deref effect array
1504
+ *
1505
+ * @example
1506
+ * deref('@entity.health'); // returns ["deref", "@entity.health"]
1507
+ * deref('User', { id: '@payload.userId' }); // returns ["deref", "User", { id: "@payload.userId" }]
1508
+ */
1509
+ declare function deref(binding: string): DerefEffect;
1510
+ declare function deref(binding: string, selector: Record<string, unknown>): DerefEffect;
1511
+ /**
1512
+ * Create a swap! effect (atomic compare-and-swap).
1513
+ *
1514
+ * @param {string} binding - Binding to atomically update
1515
+ * @param {SExpr} transform - Transformation expression applied to the current value
1516
+ * @returns {SwapEffect} Swap effect array
1517
+ *
1518
+ * @example
1519
+ * swap('@entity.counter', ['+', '@entity.counter', 1]);
1520
+ * // returns ["swap!", "@entity.counter", ["+", "@entity.counter", 1]]
1521
+ */
1522
+ declare function swap(binding: string, transform: SExpr): SwapEffect;
1523
+ /**
1524
+ * Options for watch effect
1525
+ */
1526
+ interface WatchOptions {
1527
+ /** Debounce duration in milliseconds */
1528
+ debounce?: number;
1529
+ /** Allow additional properties */
1530
+ [key: string]: unknown;
1531
+ }
1532
+ /**
1533
+ * Create a watch effect (entity change callback).
1534
+ *
1535
+ * @param {string} binding - Binding to watch for changes
1536
+ * @param {string} event - Event name to emit on change
1537
+ * @param {WatchOptions} [options] - Optional watch configuration
1538
+ * @returns {WatchEffect} Watch effect array
1539
+ *
1540
+ * @example
1541
+ * watch('@entity.health', 'HEALTH_CHANGED');
1542
+ * // returns ["watch", "@entity.health", "HEALTH_CHANGED"]
1543
+ *
1544
+ * watch('@entity.status', 'STATUS_UPDATED', { debounce: 100 });
1545
+ * // returns ["watch", "@entity.status", "STATUS_UPDATED", { debounce: 100 }]
1546
+ */
1547
+ declare function watch(binding: string, event: string): WatchEffect;
1548
+ declare function watch(binding: string, event: string, options: WatchOptions): WatchEffect;
1549
+ /**
1550
+ * Create an atomic effect (transaction group).
1551
+ *
1552
+ * @param {...SExpr[]} effects - Effects to execute atomically
1553
+ * @returns {AtomicEffect} Atomic effect array
1554
+ *
1555
+ * @example
1556
+ * atomic(['set', '@entity.x', 10], ['set', '@entity.y', 20]);
1557
+ * // returns ["atomic", ["set", "@entity.x", 10], ["set", "@entity.y", 20]]
1558
+ */
1559
+ declare function atomic(...effects: SExpr[]): AtomicEffect;
1450
1560
 
1451
1561
  /**
1452
1562
  * Represents a state in the state machine
@@ -14446,4 +14556,4 @@ declare function safeParseOrbitalSchema(data: unknown): z.SafeParseReturnType<{
14446
14556
  type OrbitalSchemaInput = z.input<typeof OrbitalSchemaSchema>;
14447
14557
  type OrbitalConfigInput = z.input<typeof OrbitalConfigSchema>;
14448
14558
 
14449
- export { type EntityFieldInput as $, AGENT_DOMAIN_CATEGORIES as A, type CustomPatternMap as B, CORE_BINDINGS as C, type CustomPatternMapInput as D, type EntityField as E, CustomPatternMapSchema as F, type DesignPreferences as G, type DesignPreferencesInput as H, DesignPreferencesSchema as I, type DesignTokens as J, type DesignTokensInput as K, DesignTokensSchema as L, type DomainCategory as M, DomainCategorySchema as N, type OrbitalDefinition as O, type Page as P, type DomainContext as Q, type DomainContextInput as R, type State as S, type TraitEventContract as T, DomainContextSchema as U, type DomainVocabulary as V, DomainVocabularySchema as W, ENTITY_ROLES as X, type Effect as Y, type EffectInput as Z, EffectSchema as _, type EntityPersistence as a, OrbitalUnitSchema as a$, EntityFieldSchema as a0, EntityPersistenceSchema as a1, type EntityRef as a2, EntityRefSchema as a3, EntityRefStringSchema as a4, type EntityRole as a5, EntityRoleSchema as a6, EntitySchema as a7, type EntitySemanticRole as a8, EntitySemanticRoleSchema as a9, type GameType as aA, GameTypeSchema as aB, type Guard as aC, type GuardInput as aD, GuardSchema as aE, type McpServiceDef as aF, McpServiceDefSchema as aG, type NodeClassification as aH, NodeClassificationSchema as aI, type OrbitalConfig as aJ, type OrbitalConfigInput as aK, OrbitalConfigSchema as aL, OrbitalDefinitionSchema as aM, type OrbitalEntity as aN, type OrbitalEntityInput as aO, OrbitalEntitySchema as aP, type OrbitalInput as aQ, type OrbitalPage as aR, type OrbitalPageInput as aS, OrbitalPageSchema as aT, type OrbitalPageStrictInput as aU, OrbitalPageStrictSchema as aV, type OrbitalSchemaInput as aW, OrbitalSchemaSchema as aX, type OrbitalTraitRef as aY, OrbitalTraitRefSchema as aZ, type OrbitalUnit as a_, type Event as aa, type EventInput as ab, type EventListener as ac, EventListenerSchema as ad, type EventPayloadField as ae, EventPayloadFieldSchema as af, EventSchema as ag, type EventScope as ah, EventScopeSchema as ai, type EventSemanticRole as aj, EventSemanticRoleSchema as ak, type EventSource as al, EventSourceSchema as am, type Expression as an, type ExpressionInput as ao, ExpressionSchema as ap, type Field as aq, type FieldFormat as ar, FieldFormatSchema as as, FieldSchema as at, type FieldType as au, FieldTypeSchema as av, type Orbital as aw, GAME_TYPES as ax, type GameSubCategory as ay, GameSubCategorySchema as az, type OrbitalSchema as b, type ThemeVariant as b$, OrbitalSchema$1 as b0, type PageRef as b1, type PageRefObject as b2, PageRefObjectSchema as b3, PageRefSchema as b4, PageRefStringSchema as b5, PageSchema as b6, type PageTraitRef as b7, PageTraitRefSchema as b8, type ParsedBinding as b9, type ServiceDefinition as bA, ServiceDefinitionSchema as bB, type ServiceRef as bC, ServiceRefSchema as bD, ServiceRefStringSchema as bE, type ServiceType as bF, ServiceTypeSchema as bG, type SocketEvents as bH, SocketEventsSchema as bI, type SocketServiceDef as bJ, SocketServiceDefSchema as bK, type StateInput as bL, type StateMachine as bM, type StateMachineInput as bN, StateMachineSchema as bO, StateSchema as bP, type StateSemanticRole as bQ, StateSemanticRoleSchema as bR, type SuggestedGuard as bS, SuggestedGuardSchema as bT, type ThemeDefinition as bU, ThemeDefinitionSchema as bV, type ThemeRef as bW, ThemeRefSchema as bX, ThemeRefStringSchema as bY, type ThemeTokens as bZ, ThemeTokensSchema as b_, type PayloadField as ba, PayloadFieldSchema as bb, type PresentationType as bc, type RelatedLink as bd, RelatedLinkSchema as be, type RelationConfig as bf, RelationConfigSchema as bg, type RenderUIConfig as bh, type RequiredField as bi, RequiredFieldSchema as bj, type ResolvedAsset as bk, type ResolvedAssetInput as bl, ResolvedAssetSchema as bm, type RestAuthConfig as bn, RestAuthConfigSchema as bo, type RestServiceDef as bp, RestServiceDefSchema as bq, SERVICE_TYPES as br, type SExpr as bs, type SExprAtom as bt, SExprAtomSchema as bu, type SExprInput as bv, SExprSchema as bw, type SemanticAssetRef as bx, type SemanticAssetRefInput as by, SemanticAssetRefSchema as bz, type Trait as c, isPageReferenceString as c$, ThemeVariantSchema as c0, type TraitCategory as c1, TraitCategorySchema as c2, type TraitDataEntity as c3, TraitDataEntitySchema as c4, type TraitEntityField as c5, TraitEntityFieldSchema as c6, TraitEventContractSchema as c7, type TraitEventListener as c8, TraitEventListenerSchema as c9, type VisualStyle as cA, VisualStyleSchema as cB, callService as cC, collectBindings as cD, createAssetKey as cE, deriveCollection as cF, despawn as cG, doEffects as cH, emit as cI, findService as cJ, getArgs as cK, getDefaultAnimationsForRole as cL, getOperator as cM, getServiceNames as cN, getTraitConfig as cO, getTraitName as cP, hasService as cQ, isBinding as cR, isCircuitEvent as cS, isEffect as cT, isEntityReference as cU, isImportedTraitRef as cV, isInlineTrait as cW, isMcpService as cX, isOrbitalDefinition as cY, isPageReference as cZ, isPageReferenceObject as c_, type TraitInput as ca, type TraitRef as cb, TraitRefSchema as cc, type TraitReference as cd, type TraitReferenceInput as ce, TraitReferenceSchema as cf, TraitSchema as cg, type TraitTick as ch, TraitTickSchema as ci, type TraitUIBinding as cj, type Transition as ck, type TransitionInput as cl, TransitionSchema as cm, type UISlot as cn, UISlotSchema as co, UI_SLOTS as cp, type UXHints as cq, UXHintsSchema as cr, type UseDeclaration as cs, UseDeclarationSchema as ct, type UserPersona as cu, type UserPersonaInput as cv, UserPersonaSchema as cw, VISUAL_STYLES as cx, type ViewType as cy, ViewTypeSchema as cz, type Entity as d, isRestService as d0, isRuntimeEntity as d1, isSExpr as d2, isSExprAtom as d3, isSExprCall as d4, isSExprEffect as d5, isServiceReference as d6, isSingletonEntity as d7, isSocketService as d8, isThemeReference as d9, isValidBinding as da, navigate as db, normalizeTraitRef as dc, notify as dd, parseAssetKey as de, parseBinding as df, parseEntityRef as dg, parseImportedTraitRef as dh, parseOrbitalSchema as di, parsePageRef as dj, parseServiceRef as dk, persist as dl, renderUI as dm, safeParseOrbitalSchema as dn, set as dp, sexpr as dq, spawn as dr, validateAssetAnimations as ds, walkSExpr as dt, ALLOWED_CUSTOM_COMPONENTS as e, type AgentDomainCategory as f, AgentDomainCategorySchema as g, type AllowedCustomComponent as h, type AnimationDef as i, type AnimationDefInput as j, AnimationDefSchema as k, type AssetMap as l, type AssetMapInput as m, AssetMapSchema as n, type AssetMapping as o, type AssetMappingInput as p, AssetMappingSchema as q, type CallServiceConfig as r, type ComputedEventContract as s, ComputedEventContractSchema as t, type ComputedEventListener as u, ComputedEventListenerSchema as v, type CoreBinding as w, type CustomPatternDefinition as x, type CustomPatternDefinitionInput as y, CustomPatternDefinitionSchema as z };
14559
+ export { type EffectInput as $, AGENT_DOMAIN_CATEGORIES as A, CustomPatternDefinitionSchema as B, CORE_BINDINGS as C, type CustomPatternMap as D, type EntityField as E, type CustomPatternMapInput as F, CustomPatternMapSchema as G, type DerefEffect as H, type DesignPreferences as I, type DesignPreferencesInput as J, DesignPreferencesSchema as K, type DesignTokens as L, type DesignTokensInput as M, DesignTokensSchema as N, type OrbitalDefinition as O, type Page as P, type DomainCategory as Q, DomainCategorySchema as R, type State as S, type TraitEventContract as T, type DomainContext as U, type DomainContextInput as V, DomainContextSchema as W, type DomainVocabulary as X, DomainVocabularySchema as Y, ENTITY_ROLES as Z, type Effect as _, type EntityPersistence as a, OrbitalTraitRefSchema as a$, EffectSchema as a0, type EntityFieldInput as a1, EntityFieldSchema as a2, EntityPersistenceSchema as a3, type EntityRef as a4, EntityRefSchema as a5, EntityRefStringSchema as a6, type EntityRole as a7, EntityRoleSchema as a8, EntitySchema as a9, type GameSubCategory as aA, GameSubCategorySchema as aB, type GameType as aC, GameTypeSchema as aD, type Guard as aE, type GuardInput as aF, GuardSchema as aG, type McpServiceDef as aH, McpServiceDefSchema as aI, type NodeClassification as aJ, NodeClassificationSchema as aK, type OrbitalConfig as aL, type OrbitalConfigInput as aM, OrbitalConfigSchema as aN, OrbitalDefinitionSchema as aO, type OrbitalEntity as aP, type OrbitalEntityInput as aQ, OrbitalEntitySchema as aR, type OrbitalInput as aS, type OrbitalPage as aT, type OrbitalPageInput as aU, OrbitalPageSchema as aV, type OrbitalPageStrictInput as aW, OrbitalPageStrictSchema as aX, type OrbitalSchemaInput as aY, OrbitalSchemaSchema as aZ, type OrbitalTraitRef as a_, type EntitySemanticRole as aa, EntitySemanticRoleSchema as ab, type Event as ac, type EventInput as ad, type EventListener as ae, EventListenerSchema as af, type EventPayloadField as ag, EventPayloadFieldSchema as ah, EventSchema as ai, type EventScope as aj, EventScopeSchema as ak, type EventSemanticRole as al, EventSemanticRoleSchema as am, type EventSource as an, EventSourceSchema as ao, type Expression as ap, type ExpressionInput as aq, ExpressionSchema as ar, type Field as as, type FieldFormat as at, FieldFormatSchema as au, FieldSchema as av, type FieldType as aw, FieldTypeSchema as ax, type Orbital as ay, GAME_TYPES as az, type OrbitalSchema as b, ThemeRefSchema as b$, type OrbitalUnit as b0, OrbitalUnitSchema as b1, OrbitalSchema$1 as b2, type PageRef as b3, type PageRefObject as b4, PageRefObjectSchema as b5, PageRefSchema as b6, PageRefStringSchema as b7, PageSchema as b8, type PageTraitRef as b9, type SemanticAssetRef as bA, type SemanticAssetRefInput as bB, SemanticAssetRefSchema as bC, type ServiceDefinition as bD, ServiceDefinitionSchema as bE, type ServiceRef as bF, ServiceRefSchema as bG, ServiceRefStringSchema as bH, type ServiceType as bI, ServiceTypeSchema as bJ, type SocketEvents as bK, SocketEventsSchema as bL, type SocketServiceDef as bM, SocketServiceDefSchema as bN, type StateInput as bO, type StateMachine as bP, type StateMachineInput as bQ, StateMachineSchema as bR, StateSchema as bS, type StateSemanticRole as bT, StateSemanticRoleSchema as bU, type SuggestedGuard as bV, SuggestedGuardSchema as bW, type SwapEffect as bX, type ThemeDefinition as bY, ThemeDefinitionSchema as bZ, type ThemeRef as b_, PageTraitRefSchema as ba, type ParsedBinding as bb, type PayloadField as bc, PayloadFieldSchema as bd, type PresentationType as be, type RefEffect as bf, type RelatedLink as bg, RelatedLinkSchema as bh, type RelationConfig as bi, RelationConfigSchema as bj, type RenderUIConfig as bk, type RequiredField as bl, RequiredFieldSchema as bm, type ResolvedAsset as bn, type ResolvedAssetInput as bo, ResolvedAssetSchema as bp, type RestAuthConfig as bq, RestAuthConfigSchema as br, type RestServiceDef as bs, RestServiceDefSchema as bt, SERVICE_TYPES as bu, type SExpr as bv, type SExprAtom as bw, SExprAtomSchema as bx, type SExprInput as by, SExprSchema as bz, type Trait as c, isEffect as c$, ThemeRefStringSchema as c0, type ThemeTokens as c1, ThemeTokensSchema as c2, type ThemeVariant as c3, ThemeVariantSchema as c4, type TraitCategory as c5, TraitCategorySchema as c6, type TraitDataEntity as c7, TraitDataEntitySchema as c8, type TraitEntityField as c9, UserPersonaSchema as cA, VISUAL_STYLES as cB, type ViewType as cC, ViewTypeSchema as cD, type VisualStyle as cE, VisualStyleSchema as cF, type WatchEffect as cG, type WatchOptions as cH, atomic as cI, callService as cJ, collectBindings as cK, createAssetKey as cL, deref as cM, deriveCollection as cN, despawn as cO, doEffects as cP, emit as cQ, findService as cR, getArgs as cS, getDefaultAnimationsForRole as cT, getOperator as cU, getServiceNames as cV, getTraitConfig as cW, getTraitName as cX, hasService as cY, isBinding as cZ, isCircuitEvent as c_, TraitEntityFieldSchema as ca, TraitEventContractSchema as cb, type TraitEventListener as cc, TraitEventListenerSchema as cd, type TraitInput as ce, type TraitRef as cf, TraitRefSchema as cg, type TraitReference as ch, type TraitReferenceInput as ci, TraitReferenceSchema as cj, TraitSchema as ck, type TraitTick as cl, TraitTickSchema as cm, type TraitUIBinding as cn, type Transition as co, type TransitionInput as cp, TransitionSchema as cq, type UISlot as cr, UISlotSchema as cs, UI_SLOTS as ct, type UXHints as cu, UXHintsSchema as cv, type UseDeclaration as cw, UseDeclarationSchema as cx, type UserPersona as cy, type UserPersonaInput as cz, type Entity as d, isEntityReference as d0, isImportedTraitRef as d1, isInlineTrait as d2, isMcpService as d3, isOrbitalDefinition as d4, isPageReference as d5, isPageReferenceObject as d6, isPageReferenceString as d7, isRestService as d8, isRuntimeEntity as d9, spawn as dA, swap as dB, validateAssetAnimations as dC, walkSExpr as dD, watch as dE, isSExpr as da, isSExprAtom as db, isSExprCall as dc, isSExprEffect as dd, isServiceReference as de, isSingletonEntity as df, isSocketService as dg, isThemeReference as dh, isValidBinding as di, navigate as dj, normalizeTraitRef as dk, notify as dl, parseAssetKey as dm, parseBinding as dn, parseEntityRef as dp, parseImportedTraitRef as dq, parseOrbitalSchema as dr, parsePageRef as ds, parseServiceRef as dt, persist as du, ref as dv, renderUI as dw, safeParseOrbitalSchema as dx, set as dy, sexpr as dz, ALLOWED_CUSTOM_COMPONENTS as e, type AgentDomainCategory as f, AgentDomainCategorySchema as g, type AllowedCustomComponent as h, type AnimationDef as i, type AnimationDefInput as j, AnimationDefSchema as k, type AssetMap as l, type AssetMapInput as m, AssetMapSchema as n, type AssetMapping as o, type AssetMappingInput as p, AssetMappingSchema as q, type AtomicEffect as r, type CallServiceConfig as s, type ComputedEventContract as t, ComputedEventContractSchema as u, type ComputedEventListener as v, ComputedEventListenerSchema as w, type CoreBinding as x, type CustomPatternDefinition as y, type CustomPatternDefinitionInput as z };
@@ -60,6 +60,32 @@ interface GraphTransition {
60
60
  event: string;
61
61
  to: string;
62
62
  }
63
+ /**
64
+ * Transition input for the edge-covering walk algorithm.
65
+ * Extends GraphTransition with guard metadata for generating pass/fail walk steps.
66
+ */
67
+ interface EdgeWalkTransition extends GraphTransition {
68
+ hasGuard: boolean;
69
+ guard?: unknown[];
70
+ }
71
+ /**
72
+ * A single step in an edge-covering walk.
73
+ * The walk visits every transition (edge) in the state graph at least once.
74
+ */
75
+ interface WalkStep {
76
+ /** Source state */
77
+ from: string;
78
+ /** Event to fire */
79
+ event: string;
80
+ /** Target state */
81
+ to: string;
82
+ /** Guard branch: null for unguarded, 'pass' or 'fail' for guarded */
83
+ guardCase: 'pass' | 'fail' | null;
84
+ /** Payload to send with the event */
85
+ payload: Record<string, unknown>;
86
+ /** True if this step is a repositioning step (navigating to reach a source state with uncovered edges) */
87
+ isRepositioning: boolean;
88
+ }
63
89
 
64
90
  /**
65
91
  * State Graph Construction
@@ -248,4 +274,33 @@ interface ReplayTransition extends GraphTransition {
248
274
  */
249
275
  declare function buildReplayPaths(transitions: ReplayTransition[], initialState: string, maxDepth?: number): Map<string, ReplayStep[]>;
250
276
 
251
- export { type BFSNode, type BFSPathNode, type GraphTransition, type GuardPayload, type PayloadFieldSchema, type ReplayStep, type ReplayTransition, type StateEdge, buildGuardPayloads, buildReplayPaths, buildStateGraph, collectReachableStates, extractPayloadFieldRef, walkStatePairs };
277
+ /**
278
+ * Edge-Covering Walk Algorithm
279
+ *
280
+ * Computes an ordered sequence of events (WalkStep[]) that covers every
281
+ * transition (edge) in a state machine graph at least once. This guarantees
282
+ * 100% transition coverage regardless of graph topology.
283
+ *
284
+ * Algorithm:
285
+ * 1. Build adjacency list and edge universe (guarded transitions produce two edges)
286
+ * 2. Precompute BFS shortest paths between all state pairs (for repositioning)
287
+ * 3. Greedy DFS: at each state, prefer uncovered outgoing edges
288
+ * 4. When stuck, insert repositioning steps to nearest state with uncovered edges
289
+ * 5. Guard-fail steps don't advance state (guard blocks transition)
290
+ *
291
+ * Used by StateWalkEngine in @almadar-io/verify. Both orbital-verify and
292
+ * runtime-verify share this algorithm for consistent coverage.
293
+ *
294
+ * @packageDocumentation
295
+ */
296
+
297
+ /**
298
+ * Build an ordered walk that covers every edge in the state machine.
299
+ *
300
+ * @param transitions - All transitions in the state machine
301
+ * @param initialState - Starting state
302
+ * @returns Ordered walk steps covering every edge
303
+ */
304
+ declare function buildEdgeCoveringWalk(transitions: EdgeWalkTransition[], initialState: string): WalkStep[];
305
+
306
+ export { type BFSNode, type BFSPathNode, type EdgeWalkTransition, type GraphTransition, type GuardPayload, type PayloadFieldSchema, type ReplayStep, type ReplayTransition, type StateEdge, type WalkStep, buildEdgeCoveringWalk, buildGuardPayloads, buildReplayPaths, buildStateGraph, collectReachableStates, extractPayloadFieldRef, walkStatePairs };
@@ -166,6 +166,154 @@ function buildReplayPaths(transitions, initialState, maxDepth = 3) {
166
166
  return replayPaths;
167
167
  }
168
168
 
169
- export { buildGuardPayloads, buildReplayPaths, buildStateGraph, collectReachableStates, extractPayloadFieldRef, walkStatePairs };
169
+ // src/state-machine/edge-walk.ts
170
+ function buildEdgeCoveringWalk(transitions, initialState) {
171
+ const filtered = transitions.filter(
172
+ (t) => t.from !== "*" && t.event !== "INIT"
173
+ );
174
+ const graph = /* @__PURE__ */ new Map();
175
+ const allStates = /* @__PURE__ */ new Set();
176
+ for (const t of filtered) {
177
+ allStates.add(t.from);
178
+ allStates.add(t.to);
179
+ if (!graph.has(t.from)) graph.set(t.from, []);
180
+ graph.get(t.from).push({ event: t.event, to: t.to, transition: t });
181
+ }
182
+ allStates.add(initialState);
183
+ const uncovered = /* @__PURE__ */ new Set();
184
+ const edgeMeta = /* @__PURE__ */ new Map();
185
+ for (const t of filtered) {
186
+ if (t.hasGuard) {
187
+ const keyPass = `${t.from}+${t.event}->${t.to}[pass]`;
188
+ const keyFail = `${t.from}+${t.event}->${t.to}[fail]`;
189
+ uncovered.add(keyPass);
190
+ uncovered.add(keyFail);
191
+ edgeMeta.set(keyPass, { transition: t, guardCase: "pass" });
192
+ edgeMeta.set(keyFail, { transition: t, guardCase: "fail" });
193
+ } else {
194
+ const key = `${t.from}+${t.event}->${t.to}`;
195
+ uncovered.add(key);
196
+ edgeMeta.set(key, { transition: t, guardCase: null });
197
+ }
198
+ }
199
+ if (uncovered.size === 0) return [];
200
+ const shortestPaths = /* @__PURE__ */ new Map();
201
+ for (const state of allStates) {
202
+ shortestPaths.set(state, bfsShortestPaths(state, graph));
203
+ }
204
+ const walk = [];
205
+ let currentState = initialState;
206
+ const maxIterations = uncovered.size * allStates.size * 2;
207
+ let iterations = 0;
208
+ while (uncovered.size > 0 && iterations < maxIterations) {
209
+ iterations++;
210
+ const outgoing = findUncoveredEdges(currentState, graph, uncovered);
211
+ if (outgoing.length > 0) {
212
+ const pick = outgoing[0];
213
+ const payload = buildPayloadForEdge(pick.transition, pick.guardCase);
214
+ walk.push({
215
+ from: currentState,
216
+ event: pick.transition.event,
217
+ to: pick.transition.to,
218
+ guardCase: pick.guardCase,
219
+ payload,
220
+ isRepositioning: false
221
+ });
222
+ uncovered.delete(pick.key);
223
+ if (pick.guardCase !== "fail") {
224
+ currentState = pick.transition.to;
225
+ }
226
+ } else {
227
+ const target = findNearestUncoveredState(currentState, graph, uncovered, shortestPaths);
228
+ if (!target) {
229
+ break;
230
+ }
231
+ const repoPath = shortestPaths.get(currentState)?.get(target);
232
+ if (!repoPath || repoPath.length === 0) break;
233
+ for (const step of repoPath) {
234
+ walk.push({
235
+ from: currentState,
236
+ event: step.event,
237
+ to: step.to,
238
+ guardCase: null,
239
+ payload: {},
240
+ isRepositioning: true
241
+ });
242
+ currentState = step.to;
243
+ }
244
+ }
245
+ }
246
+ return walk;
247
+ }
248
+ function bfsShortestPaths(source, graph) {
249
+ const paths = /* @__PURE__ */ new Map();
250
+ const visited = /* @__PURE__ */ new Set([source]);
251
+ const queue = [
252
+ { state: source, path: [] }
253
+ ];
254
+ while (queue.length > 0) {
255
+ const { state, path } = queue.shift();
256
+ const edges = graph.get(state) ?? [];
257
+ for (const edge of edges) {
258
+ if (visited.has(edge.to)) continue;
259
+ visited.add(edge.to);
260
+ const newPath = [...path, { event: edge.event, to: edge.to }];
261
+ paths.set(edge.to, newPath);
262
+ queue.push({ state: edge.to, path: newPath });
263
+ }
264
+ }
265
+ return paths;
266
+ }
267
+ function findUncoveredEdges(state, graph, uncovered) {
268
+ const edges = graph.get(state) ?? [];
269
+ const result = [];
270
+ for (const edge of edges) {
271
+ if (edge.transition.hasGuard) {
272
+ const keyPass = `${state}+${edge.event}->${edge.to}[pass]`;
273
+ const keyFail = `${state}+${edge.event}->${edge.to}[fail]`;
274
+ if (uncovered.has(keyPass)) {
275
+ result.push({ key: keyPass, transition: edge.transition, guardCase: "pass" });
276
+ }
277
+ if (uncovered.has(keyFail)) {
278
+ result.push({ key: keyFail, transition: edge.transition, guardCase: "fail" });
279
+ }
280
+ } else {
281
+ const key = `${state}+${edge.event}->${edge.to}`;
282
+ if (uncovered.has(key)) {
283
+ result.push({ key, transition: edge.transition, guardCase: null });
284
+ }
285
+ }
286
+ }
287
+ return result;
288
+ }
289
+ function findNearestUncoveredState(currentState, graph, uncovered, shortestPaths) {
290
+ const statesWithUncovered = /* @__PURE__ */ new Set();
291
+ for (const key of uncovered) {
292
+ const fromState = key.split("+")[0];
293
+ statesWithUncovered.add(fromState);
294
+ }
295
+ if (statesWithUncovered.has(currentState)) return currentState;
296
+ const paths = shortestPaths.get(currentState);
297
+ if (!paths) return null;
298
+ let nearestState = null;
299
+ let nearestDist = Infinity;
300
+ for (const target of statesWithUncovered) {
301
+ const path = paths.get(target);
302
+ if (path && path.length < nearestDist) {
303
+ nearestDist = path.length;
304
+ nearestState = target;
305
+ }
306
+ }
307
+ return nearestState;
308
+ }
309
+ function buildPayloadForEdge(transition, guardCase) {
310
+ if (!transition.hasGuard || !transition.guard || !guardCase) {
311
+ return {};
312
+ }
313
+ const payloads = buildGuardPayloads(transition.guard);
314
+ return guardCase === "pass" ? payloads.pass : payloads.fail;
315
+ }
316
+
317
+ export { buildEdgeCoveringWalk, buildGuardPayloads, buildReplayPaths, buildStateGraph, collectReachableStates, extractPayloadFieldRef, walkStatePairs };
170
318
  //# sourceMappingURL=index.js.map
171
319
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/state-machine/graph.ts","../../src/state-machine/bfs.ts","../../src/state-machine/guard-payloads.ts","../../src/state-machine/replay-paths.ts"],"names":[],"mappings":";AA2BO,SAAS,gBACd,WAAA,EAC0B;AAC1B,EAAA,MAAM,KAAA,uBAAY,GAAA,EAAyB;AAC3C,EAAA,KAAA,MAAW,KAAK,WAAA,EAAa;AAC3B,IAAA,IAAI,CAAA,CAAE,SAAS,GAAA,EAAK;AACpB,IAAA,IAAI,CAAC,KAAA,CAAM,GAAA,CAAI,CAAA,CAAE,IAAI,CAAA,EAAG,KAAA,CAAM,GAAA,CAAI,CAAA,CAAE,IAAA,EAAM,EAAE,CAAA;AAC5C,IAAA,KAAA,CAAM,GAAA,CAAI,CAAA,CAAE,IAAI,CAAA,CAAG,IAAA,CAAK,EAAE,KAAA,EAAO,CAAA,CAAE,KAAA,EAAO,EAAA,EAAI,CAAA,CAAE,EAAA,EAAI,CAAA;AAAA,EACtD;AACA,EAAA,OAAO,KAAA;AACT;;;ACRO,SAAS,sBAAA,CACd,WAAA,EACA,YAAA,EACA,QAAA,GAAW,CAAA,EACE;AACb,EAAA,MAAM,KAAA,GAAQ,gBAAgB,WAAW,CAAA;AACzC,EAAA,MAAM,OAAA,mBAAU,IAAI,GAAA,CAAY,CAAC,YAAY,CAAC,CAAA;AAC9C,EAAA,MAAM,QAAmB,CAAC,EAAE,OAAO,YA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,QAC9C,eAAA,EAAiB,mBAAA;AAAA,QACjB,eAAe,UAAA,CAAW,aAAA,CAAc,MAAA,GAAS,CAAA,GAAI,WAAW,aAAA,GAAgB;AAAA,OAClF;AAEA,MAAA,MAAM,OAAA,GAAU,CAAC,GAAG,IAAA,EAAM,IAAI,CAAA;AAC9B,MAAA,WAAA,CAAY,GAAA,CAAI,UAAA,CAAW,EAAA,EAAI,OAAO,CAAA;AACtC,MAAA,KAAA,CAAM,KAAK,EAAE,KAAA,EAAO,WAAW,EAAA,EAAI,IAAA,EAAM,SAAS,CAAA;AAAA,IACpD;AAAA,EACF;AAEA,EAAA,OAAO,WAAA;AACT","file":"index.js","sourcesContent":["/**\n * State Graph Construction\n *\n * Build an adjacency list from state machine transitions.\n * Extracted from orbital-verify-unified/src/analyze.ts.\n *\n * @packageDocumentation\n */\n\nimport type { GraphTransition, StateEdge } from './types.js';\n\n/**\n * Builds an adjacency list from state machine transitions.\n * \n * Constructs a state transition graph where each state maps to an array\n * of outgoing edges (events and target states). Wildcard transitions\n * (from === '*') are excluded since they don't represent fixed edges.\n * Used as the foundation for state machine analysis, traversal, and verification.\n * \n * @param {GraphTransition[]} transitions - Array of state transitions\n * @returns {Map<string, StateEdge[]>} State transition graph\n * \n * @example\n * const graph = buildStateGraph(transitions);\n * const edgesFromInitial = graph.get('initial'); // Array of outgoing edges\n * console.log(`Initial state has ${edgesFromInitial?.length} transitions`);\n */\nexport function buildStateGraph(\n transitions: GraphTransition[]\n): Map<string, StateEdge[]> {\n const graph = new Map<string, StateEdge[]>();\n for (const t of transitions) {\n if (t.from === '*') continue;\n if (!graph.has(t.from)) graph.set(t.from, []);\n graph.get(t.from)!.push({ event: t.event, to: t.to });\n }\n return graph;\n}\n","/**\n * BFS Reachability Algorithms\n *\n * Breadth-first search over state machine graphs.\n * Extracted from orbital-verify-unified/src/analyze.ts and phase3-server.ts.\n *\n * @packageDocumentation\n */\n\nimport type { BFSNode, StateEdge } from './types.js';\nimport { buildStateGraph } from './graph.js';\nimport type { GraphTransition } from './types.js';\n\n/**\n * Collects all reachable states from an initial state using breadth-first search.\n * \n * Performs BFS traversal of the state machine to find all states reachable\n * from the initial state, up to the specified maximum depth. Used for\n * state machine analysis, verification, and test coverage assessment.\n * \n * @param {GraphTransition[]} transitions - Array of state transitions\n * @param {string} initialState - Starting state name\n * @param {number} [maxDepth=5] - Maximum search depth\n * @returns {Set<string>} Set of reachable state names\n * \n * @example\n * const reachable = collectReachableStates(transitions, 'initial', 10);\n * console.log('Reachable states:', Array.from(reachable));\n */\nexport function collectReachableStates(\n transitions: GraphTransition[],\n initialState: string,\n maxDepth = 5\n): Set<string> {\n const graph = buildStateGraph(transitions);\n const visited = new Set<string>([initialState]);\n const queue: BFSNode[] = [{ state: initialState, depth: 0 }];\n\n while (queue.length > 0) {\n const current = queue.shift()!;\n if (current.depth >= maxDepth) continue;\n\n const edges = graph.get(current.state) ?? [];\n for (const edge of edges) {\n if (!visited.has(edge.to)) {\n visited.add(edge.to);\n queue.push({ state: edge.to, depth: current.depth + 1 });\n }\n }\n }\n\n return visited;\n}\n\n/**\n * Walks all reachable (state, event) pairs using BFS and invokes callback for each.\n * \n * Traverses the state machine using breadth-first search and calls the visitor\n * function for each (state, edge) pair encountered. Used by server verification\n * to test transitions by POSTing to endpoints and checking responses.\n * \n * @param {GraphTransition[]} transitions - Array of state transitions\n * @param {string} initialState - Starting state name\n * @param {number} maxDepth - Maximum BFS depth\n * @param {(state: string, edge: StateEdge, depth: number) => Promise<boolean>} visitor - Callback for each pair\n * @returns {Promise<{ visitedPairs: Set<string>; walkedEdges: number }>} Traversal statistics\n * \n * @example\n * const result = await walkStatePairs(transitions, 'initial', 5, async (state, edge) => {\n * console.log(`Transition: ${state} --${edge.event}--> ${edge.to}`);\n * return true; // Continue exploration\n * });\n * console.log(`Visited ${result.visitedPairs.size} state-event pairs`);\n */\nexport async function walkStatePairs(\n transitions: GraphTransition[],\n initialState: string,\n maxDepth: number,\n visitor: (state: string, edge: StateEdge, depth: number) => Promise<boolean>\n): Promise<{ visitedPairs: Set<string>; walkedEdges: number }> {\n const graph = buildStateGraph(transitions);\n const visitedPairs = new Set<string>();\n const queue: BFSNode[] = [{ state: initialState, depth: 0 }];\n let walkedEdges = 0;\n\n while (queue.length > 0) {\n const current = queue.shift()!;\n if (current.depth >= maxDepth) continue;\n\n const edges = graph.get(current.state) ?? [];\n for (const edge of edges) {\n const pairKey = `${current.state}:${edge.event}`;\n if (visitedPairs.has(pairKey)) continue;\n visitedPairs.add(pairKey);\n\n const shouldEnqueue = await visitor(current.state, edge, current.depth);\n walkedEdges++;\n\n if (shouldEnqueue) {\n const stateVisited = [...visitedPairs].some((k) => k.startsWith(`${edge.to}:`));\n if (!stateVisited) {\n queue.push({ state: edge.to, depth: current.depth + 1 });\n }\n }\n }\n }\n\n return { visitedPairs, walkedEdges };\n}\n","/**\n * Guard Payload Builder\n *\n * Derive pass and fail payloads from guard s-expressions.\n * Extracted from orbital-verify-unified/src/analyze.ts.\n *\n * @packageDocumentation\n */\n\nimport type { GuardPayload } from './types.js';\n\n/**\n * Extracts the first segment of a payload field reference.\n * \n * Parses binding references in the format \"@payload.field\" and extracts\n * the first field name segment. Used for identifying payload fields in\n * guard conditions for test data generation.\n * \n * @param {unknown} ref - Binding reference to extract from\n * @returns {string | null} First field segment or null for non-payload references\n * \n * @example\n * extractPayloadFieldRef('@payload.item'); // returns 'item'\n * extractPayloadFieldRef('@payload.data.weight'); // returns 'data'\n * extractPayloadFieldRef('@entity.id'); // returns null\n * extractPayloadFieldRef('@user.name'); // returns null\n */\nexport function extractPayloadFieldRef(ref: unknown): string | null {\n if (typeof ref !== 'string') return null;\n const match = ref.match(/^@payload\\.([A-Za-z0-9_]+)/);\n return match ? match[1] : null;\n}\n\n/**\n * Builds test payloads that satisfy or violate guard conditions.\n * \n * Generates pass/fail test data for guard s-expressions used in state machine\n * transitions. Pass payloads satisfy the guard condition (allowing transition),\n * fail payloads violate it (blocking transition). Used for automated testing\n * and validation of state machine behavior.\n * \n * Supports operators: not-nil, nil, eq, not-eq, gt, gte, lt, lte, and, or, not\n * \n * @param {unknown} guard - Guard s-expression to analyze\n * @returns {GuardPayload} Object with pass and fail payloads\n * \n * @example\n * // Guard: ['not-nil', '@payload.completed']\n * buildGuardPayloads(['not-nil', '@payload.completed']);\n * // Returns: { pass: { completed: 'mock-test-value' }, fail: { completed: null } }\n * \n * @example\n * // Guard: ['eq', '@payload.status', 'active']\n * buildGuardPayloads(['eq', '@payload.status', 'active']);\n * // Returns: { pass: { status: 'active' }, fail: { status: 'not-active' } }\n * \n * @example\n * // Guard: ['and', ['not-nil', '@payload.id'], ['eq', '@payload.status', 'ready']]\n * buildGuardPayloads(['and', ['not-nil', '@payload.id'], ['eq', '@payload.status', 'ready']]);\n * // Returns: { pass: { id: 'mock-test-value', status: 'ready' }, fail: { id: null } }\n */\nexport function buildGuardPayloads(guard: unknown): GuardPayload {\n if (!Array.isArray(guard) || guard.length === 0) {\n return { pass: {}, fail: {} };\n }\n\n const op = String(guard[0]);\n\n if (op === 'not-nil' || op === 'not_nil') {\n const field = extractPayloadFieldRef(guard[1]);\n if (field) return { pass: { [field]: 'mock-test-value' }, fail: { [field]: null } };\n }\n\n if (op === 'nil') {\n const field = extractPayloadFieldRef(guard[1]);\n if (field) return { pass: {}, fail: { [field]: 'mock-test-value' } };\n }\n\n if (op === 'eq' || op === '==' || op === '=') {\n const field = extractPayloadFieldRef(guard[1]);\n const val = guard[2];\n if (field && val !== undefined) {\n const failVal =\n typeof val === 'number' ? val + 1\n : typeof val === 'string' ? `not-${val}`\n : null;\n return { pass: { [field]: val }, fail: { [field]: failVal } };\n }\n }\n\n if (op === 'not-eq' || op === '!=' || op === 'neq') {\n const field = extractPayloadFieldRef(guard[1]);\n const val = guard[2];\n if (field && val !== undefined) {\n const passVal =\n typeof val === 'number' ? val + 1\n : typeof val === 'string' ? `not-${val}`\n : 'other';\n return { pass: { [field]: passVal }, fail: { [field]: val } };\n }\n }\n\n if (op === 'gt' || op === '>') {\n const field = extractPayloadFieldRef(guard[1]);\n const n = typeof guard[2] === 'number' ? guard[2] : 0;\n if (field) return { pass: { [field]: n + 1 }, fail: { [field]: n - 1 } };\n }\n\n if (op === 'gte' || op === '>=') {\n const field = extractPayloadFieldRef(guard[1]);\n const n = typeof guard[2] === 'number' ? guard[2] : 0;\n if (field) return { pass: { [field]: n }, fail: { [field]: n - 1 } };\n }\n\n if (op === 'lt' || op === '<') {\n const field = extractPayloadFieldRef(guard[1]);\n const n = typeof guard[2] === 'number' ? guard[2] : 0;\n if (field) return { pass: { [field]: n - 1 }, fail: { [field]: n + 1 } };\n }\n\n if (op === 'lte' || op === '<=') {\n const field = extractPayloadFieldRef(guard[1]);\n const n = typeof guard[2] === 'number' ? guard[2] : 0;\n if (field) return { pass: { [field]: n }, fail: { [field]: n + 1 } };\n }\n\n if (op === 'and') {\n const subs = (guard.slice(1) as unknown[]).filter(Array.isArray);\n if (subs.length >= 2) {\n const s1 = buildGuardPayloads(subs[0]);\n const s2 = buildGuardPayloads(subs[1]);\n return { pass: { ...s1.pass, ...s2.pass }, fail: s1.fail };\n }\n if (subs.length === 1) return buildGuardPayloads(subs[0]);\n }\n\n if (op === 'or') {\n const subs = (guard.slice(1) as unknown[]).filter(Array.isArray);\n if (subs.length >= 2) {\n const s1 = buildGuardPayloads(subs[0]);\n const s2 = buildGuardPayloads(subs[1]);\n return { pass: s1.pass, fail: { ...s1.fail, ...s2.fail } };\n }\n if (subs.length === 1) return buildGuardPayloads(subs[0]);\n }\n\n if (op === 'not') {\n const inner = buildGuardPayloads(guard[1]);\n return { pass: inner.fail, fail: inner.pass };\n }\n\n return { pass: {}, fail: {} };\n}\n","/**\n * Replay Path Builder\n *\n * Compute the shortest path (replay steps) from an initial state\n * to every reachable state in a state machine. Used by browser\n * verification to navigate through states before running assertions.\n *\n * Extracted from orbital-verify-unified/src/analyze.ts (collectDataMutationTests).\n *\n * @packageDocumentation\n */\n\nimport type { GraphTransition, ReplayStep, PayloadFieldSchema } from './types.js';\n\n/** Entity-data sentinel payload fields: presence means transition needs a selected row */\nconst ENTITY_PAYLOAD_FIELDS = new Set(['data', 'row', 'item', 'id']);\n\n/**\n * Extended transition with render and payload info needed for replay path building.\n * Compatible with orbital-verify's UnifiedTransition.\n */\nexport interface ReplayTransition extends GraphTransition {\n hasGuard: boolean;\n guard?: unknown[];\n payloadFields: string[];\n payloadSchema: PayloadFieldSchema[];\n renderEffects: Array<{\n slot: string;\n patternType: string | null;\n }>;\n}\n\n/**\n * Builds the shortest replay paths from initial state to all reachable states.\n * \n * Computes step-by-step navigation paths for state machine testing and verification.\n * Uses breadth-first search to find shortest paths up to specified depth limit.\n * Each path contains replay steps with event, state, and payload information\n * needed to reproduce state transitions in tests.\n * \n * @param {ReplayTransition[]} transitions - Transitions with render/payload information\n * @param {string} initialState - Starting state name\n * @param {number} [maxDepth=3] - Maximum path length (default: 3)\n * @returns {Map<string, ReplayStep[]>} Map of state names to replay step arrays\n * \n * @example\n * // Build paths from 'initial' state\n * const paths = buildReplayPaths(transitions, 'initial', 5);\n * \n * // Get steps to reach 'completed' state\n * const stepsToComplete = paths.get('completed');\n * \n * // Execute replay steps\n * for (const step of stepsToComplete) {\n * await dispatchEvent(step.event, step.payload);\n * }\n */\nexport function buildReplayPaths(\n transitions: ReplayTransition[],\n initialState: string,\n maxDepth = 3\n): Map<string, ReplayStep[]> {\n type QueueNode = { state: string; path: ReplayStep[] };\n\n const queue: QueueNode[] = [{ state: initialState, path: [] }];\n const replayPaths = new Map<string, ReplayStep[]>();\n replayPaths.set(initialState, []);\n\n while (queue.length > 0) {\n const { state, path } = queue.shift()!;\n if (path.length >= maxDepth) continue;\n\n const fromHere = transitions.filter(\n (t) => t.from === state && t.event !== 'INIT',\n );\n\n for (const transition of fromHere) {\n if (replayPaths.has(transition.to)) continue;\n\n const renderEffect = transition.renderEffects.find((re) => re.patternType !== null);\n const stepNeedsEntityData =\n transition.hasGuard ||\n transition.payloadFields.some((f) => ENTITY_PAYLOAD_FIELDS.has(f));\n\n const step: ReplayStep = {\n event: transition.event,\n fromState: state,\n toState: transition.to,\n slot: renderEffect?.slot ?? 'main',\n expectedPattern: renderEffect?.patternType ?? undefined,\n needsEntityData: stepNeedsEntityData,\n payloadSchema: transition.payloadSchema.length > 0 ? transition.payloadSchema : undefined,\n };\n\n const newPath = [...path, step];\n replayPaths.set(transition.to, newPath);\n queue.push({ state: transition.to, path: newPath });\n }\n }\n\n return replayPaths;\n}\n"]}
1
+ {"version":3,"sources":["../../src/state-machine/graph.ts","../../src/state-machine/bfs.ts","../../src/state-machine/guard-payloads.ts","../../src/state-machine/replay-paths.ts","../../src/state-machine/edge-walk.ts"],"names":[],"mappings":";AA2BO,SAAS,gBACd,WAAA,EAC0B;AAC1B,EAAA,MAAM,KAAA,uBAAY,GAAA,EAAyB;AAC3C,EAAA,KAAA,MAAW,KAAK,WAAA,EAAa;AAC3B,IAAA,IAAI,CAAA,CAAE,SAAS,GAAA,EAAK;AACpB,IAAA,IAAI,CAAC,KAAA,CAAM,GAAA,CAAI,CAAA,CAAE,IAAI,CAAA,EAAG,KAAA,CAAM,GAAA,CAAI,CAAA,CAAE,IAAA,EAAM,EAAE,CAAA;AAC5C,IAAA,KAAA,CAAM,GAAA,CAAI,CAAA,CAAE,IAAI,CAAA,CAAG,IAAA,CAAK,EAAE,KAAA,EAAO,CAAA,CAAE,KAAA,EAAO,EAAA,EAAI,CAAA,CAAE,EAAA,EAAI,CAAA;AAAA,EACtD;AACA,EAAA,OAAO,KAAA;AACT;;;ACRO,SAAS,sBAAA,CACd,WAAA,EACA,YAAA,EACA,QAAA,GAAW,CAAA,EACE;AACb,EAAA,MAAM,KAAA,GAAQ,gBAAgB,WAAW,CAAA;AACzC,EAAA,MAAM,OAAA,mBAAU,IAAI,GAAA,CAAY,CAAC,YAAY,CAAC,CAAA;AAC9C,EAAA,MAAM,QAAmB,CAAC,EAAE,OAAO,YAAA,EAAc,KAAA,EAAO,GAAG,CAAA;A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,EAAC;AAAA,EACV;AAEA,EAAA,MAAM,QAAA,GAAW,kBAAA,CAAmB,UAAA,CAAW,KAAK,CAAA;AACpD,EAAA,OAAO,SAAA,KAAc,MAAA,GAAS,QAAA,CAAS,IAAA,GAAO,QAAA,CAAS,IAAA;AACzD","file":"index.js","sourcesContent":["/**\n * State Graph Construction\n *\n * Build an adjacency list from state machine transitions.\n * Extracted from orbital-verify-unified/src/analyze.ts.\n *\n * @packageDocumentation\n */\n\nimport type { GraphTransition, StateEdge } from './types.js';\n\n/**\n * Builds an adjacency list from state machine transitions.\n * \n * Constructs a state transition graph where each state maps to an array\n * of outgoing edges (events and target states). Wildcard transitions\n * (from === '*') are excluded since they don't represent fixed edges.\n * Used as the foundation for state machine analysis, traversal, and verification.\n * \n * @param {GraphTransition[]} transitions - Array of state transitions\n * @returns {Map<string, StateEdge[]>} State transition graph\n * \n * @example\n * const graph = buildStateGraph(transitions);\n * const edgesFromInitial = graph.get('initial'); // Array of outgoing edges\n * console.log(`Initial state has ${edgesFromInitial?.length} transitions`);\n */\nexport function buildStateGraph(\n transitions: GraphTransition[]\n): Map<string, StateEdge[]> {\n const graph = new Map<string, StateEdge[]>();\n for (const t of transitions) {\n if (t.from === '*') continue;\n if (!graph.has(t.from)) graph.set(t.from, []);\n graph.get(t.from)!.push({ event: t.event, to: t.to });\n }\n return graph;\n}\n","/**\n * BFS Reachability Algorithms\n *\n * Breadth-first search over state machine graphs.\n * Extracted from orbital-verify-unified/src/analyze.ts and phase3-server.ts.\n *\n * @packageDocumentation\n */\n\nimport type { BFSNode, StateEdge } from './types.js';\nimport { buildStateGraph } from './graph.js';\nimport type { GraphTransition } from './types.js';\n\n/**\n * Collects all reachable states from an initial state using breadth-first search.\n * \n * Performs BFS traversal of the state machine to find all states reachable\n * from the initial state, up to the specified maximum depth. Used for\n * state machine analysis, verification, and test coverage assessment.\n * \n * @param {GraphTransition[]} transitions - Array of state transitions\n * @param {string} initialState - Starting state name\n * @param {number} [maxDepth=5] - Maximum search depth\n * @returns {Set<string>} Set of reachable state names\n * \n * @example\n * const reachable = collectReachableStates(transitions, 'initial', 10);\n * console.log('Reachable states:', Array.from(reachable));\n */\nexport function collectReachableStates(\n transitions: GraphTransition[],\n initialState: string,\n maxDepth = 5\n): Set<string> {\n const graph = buildStateGraph(transitions);\n const visited = new Set<string>([initialState]);\n const queue: BFSNode[] = [{ state: initialState, depth: 0 }];\n\n while (queue.length > 0) {\n const current = queue.shift()!;\n if (current.depth >= maxDepth) continue;\n\n const edges = graph.get(current.state) ?? [];\n for (const edge of edges) {\n if (!visited.has(edge.to)) {\n visited.add(edge.to);\n queue.push({ state: edge.to, depth: current.depth + 1 });\n }\n }\n }\n\n return visited;\n}\n\n/**\n * Walks all reachable (state, event) pairs using BFS and invokes callback for each.\n * \n * Traverses the state machine using breadth-first search and calls the visitor\n * function for each (state, edge) pair encountered. Used by server verification\n * to test transitions by POSTing to endpoints and checking responses.\n * \n * @param {GraphTransition[]} transitions - Array of state transitions\n * @param {string} initialState - Starting state name\n * @param {number} maxDepth - Maximum BFS depth\n * @param {(state: string, edge: StateEdge, depth: number) => Promise<boolean>} visitor - Callback for each pair\n * @returns {Promise<{ visitedPairs: Set<string>; walkedEdges: number }>} Traversal statistics\n * \n * @example\n * const result = await walkStatePairs(transitions, 'initial', 5, async (state, edge) => {\n * console.log(`Transition: ${state} --${edge.event}--> ${edge.to}`);\n * return true; // Continue exploration\n * });\n * console.log(`Visited ${result.visitedPairs.size} state-event pairs`);\n */\nexport async function walkStatePairs(\n transitions: GraphTransition[],\n initialState: string,\n maxDepth: number,\n visitor: (state: string, edge: StateEdge, depth: number) => Promise<boolean>\n): Promise<{ visitedPairs: Set<string>; walkedEdges: number }> {\n const graph = buildStateGraph(transitions);\n const visitedPairs = new Set<string>();\n const queue: BFSNode[] = [{ state: initialState, depth: 0 }];\n let walkedEdges = 0;\n\n while (queue.length > 0) {\n const current = queue.shift()!;\n if (current.depth >= maxDepth) continue;\n\n const edges = graph.get(current.state) ?? [];\n for (const edge of edges) {\n const pairKey = `${current.state}:${edge.event}`;\n if (visitedPairs.has(pairKey)) continue;\n visitedPairs.add(pairKey);\n\n const shouldEnqueue = await visitor(current.state, edge, current.depth);\n walkedEdges++;\n\n if (shouldEnqueue) {\n const stateVisited = [...visitedPairs].some((k) => k.startsWith(`${edge.to}:`));\n if (!stateVisited) {\n queue.push({ state: edge.to, depth: current.depth + 1 });\n }\n }\n }\n }\n\n return { visitedPairs, walkedEdges };\n}\n","/**\n * Guard Payload Builder\n *\n * Derive pass and fail payloads from guard s-expressions.\n * Extracted from orbital-verify-unified/src/analyze.ts.\n *\n * @packageDocumentation\n */\n\nimport type { GuardPayload } from './types.js';\n\n/**\n * Extracts the first segment of a payload field reference.\n * \n * Parses binding references in the format \"@payload.field\" and extracts\n * the first field name segment. Used for identifying payload fields in\n * guard conditions for test data generation.\n * \n * @param {unknown} ref - Binding reference to extract from\n * @returns {string | null} First field segment or null for non-payload references\n * \n * @example\n * extractPayloadFieldRef('@payload.item'); // returns 'item'\n * extractPayloadFieldRef('@payload.data.weight'); // returns 'data'\n * extractPayloadFieldRef('@entity.id'); // returns null\n * extractPayloadFieldRef('@user.name'); // returns null\n */\nexport function extractPayloadFieldRef(ref: unknown): string | null {\n if (typeof ref !== 'string') return null;\n const match = ref.match(/^@payload\\.([A-Za-z0-9_]+)/);\n return match ? match[1] : null;\n}\n\n/**\n * Builds test payloads that satisfy or violate guard conditions.\n * \n * Generates pass/fail test data for guard s-expressions used in state machine\n * transitions. Pass payloads satisfy the guard condition (allowing transition),\n * fail payloads violate it (blocking transition). Used for automated testing\n * and validation of state machine behavior.\n * \n * Supports operators: not-nil, nil, eq, not-eq, gt, gte, lt, lte, and, or, not\n * \n * @param {unknown} guard - Guard s-expression to analyze\n * @returns {GuardPayload} Object with pass and fail payloads\n * \n * @example\n * // Guard: ['not-nil', '@payload.completed']\n * buildGuardPayloads(['not-nil', '@payload.completed']);\n * // Returns: { pass: { completed: 'mock-test-value' }, fail: { completed: null } }\n * \n * @example\n * // Guard: ['eq', '@payload.status', 'active']\n * buildGuardPayloads(['eq', '@payload.status', 'active']);\n * // Returns: { pass: { status: 'active' }, fail: { status: 'not-active' } }\n * \n * @example\n * // Guard: ['and', ['not-nil', '@payload.id'], ['eq', '@payload.status', 'ready']]\n * buildGuardPayloads(['and', ['not-nil', '@payload.id'], ['eq', '@payload.status', 'ready']]);\n * // Returns: { pass: { id: 'mock-test-value', status: 'ready' }, fail: { id: null } }\n */\nexport function buildGuardPayloads(guard: unknown): GuardPayload {\n if (!Array.isArray(guard) || guard.length === 0) {\n return { pass: {}, fail: {} };\n }\n\n const op = String(guard[0]);\n\n if (op === 'not-nil' || op === 'not_nil') {\n const field = extractPayloadFieldRef(guard[1]);\n if (field) return { pass: { [field]: 'mock-test-value' }, fail: { [field]: null } };\n }\n\n if (op === 'nil') {\n const field = extractPayloadFieldRef(guard[1]);\n if (field) return { pass: {}, fail: { [field]: 'mock-test-value' } };\n }\n\n if (op === 'eq' || op === '==' || op === '=') {\n const field = extractPayloadFieldRef(guard[1]);\n const val = guard[2];\n if (field && val !== undefined) {\n const failVal =\n typeof val === 'number' ? val + 1\n : typeof val === 'string' ? `not-${val}`\n : null;\n return { pass: { [field]: val }, fail: { [field]: failVal } };\n }\n }\n\n if (op === 'not-eq' || op === '!=' || op === 'neq') {\n const field = extractPayloadFieldRef(guard[1]);\n const val = guard[2];\n if (field && val !== undefined) {\n const passVal =\n typeof val === 'number' ? val + 1\n : typeof val === 'string' ? `not-${val}`\n : 'other';\n return { pass: { [field]: passVal }, fail: { [field]: val } };\n }\n }\n\n if (op === 'gt' || op === '>') {\n const field = extractPayloadFieldRef(guard[1]);\n const n = typeof guard[2] === 'number' ? guard[2] : 0;\n if (field) return { pass: { [field]: n + 1 }, fail: { [field]: n - 1 } };\n }\n\n if (op === 'gte' || op === '>=') {\n const field = extractPayloadFieldRef(guard[1]);\n const n = typeof guard[2] === 'number' ? guard[2] : 0;\n if (field) return { pass: { [field]: n }, fail: { [field]: n - 1 } };\n }\n\n if (op === 'lt' || op === '<') {\n const field = extractPayloadFieldRef(guard[1]);\n const n = typeof guard[2] === 'number' ? guard[2] : 0;\n if (field) return { pass: { [field]: n - 1 }, fail: { [field]: n + 1 } };\n }\n\n if (op === 'lte' || op === '<=') {\n const field = extractPayloadFieldRef(guard[1]);\n const n = typeof guard[2] === 'number' ? guard[2] : 0;\n if (field) return { pass: { [field]: n }, fail: { [field]: n + 1 } };\n }\n\n if (op === 'and') {\n const subs = (guard.slice(1) as unknown[]).filter(Array.isArray);\n if (subs.length >= 2) {\n const s1 = buildGuardPayloads(subs[0]);\n const s2 = buildGuardPayloads(subs[1]);\n return { pass: { ...s1.pass, ...s2.pass }, fail: s1.fail };\n }\n if (subs.length === 1) return buildGuardPayloads(subs[0]);\n }\n\n if (op === 'or') {\n const subs = (guard.slice(1) as unknown[]).filter(Array.isArray);\n if (subs.length >= 2) {\n const s1 = buildGuardPayloads(subs[0]);\n const s2 = buildGuardPayloads(subs[1]);\n return { pass: s1.pass, fail: { ...s1.fail, ...s2.fail } };\n }\n if (subs.length === 1) return buildGuardPayloads(subs[0]);\n }\n\n if (op === 'not') {\n const inner = buildGuardPayloads(guard[1]);\n return { pass: inner.fail, fail: inner.pass };\n }\n\n return { pass: {}, fail: {} };\n}\n","/**\n * Replay Path Builder\n *\n * Compute the shortest path (replay steps) from an initial state\n * to every reachable state in a state machine. Used by browser\n * verification to navigate through states before running assertions.\n *\n * Extracted from orbital-verify-unified/src/analyze.ts (collectDataMutationTests).\n *\n * @packageDocumentation\n */\n\nimport type { GraphTransition, ReplayStep, PayloadFieldSchema } from './types.js';\n\n/** Entity-data sentinel payload fields: presence means transition needs a selected row */\nconst ENTITY_PAYLOAD_FIELDS = new Set(['data', 'row', 'item', 'id']);\n\n/**\n * Extended transition with render and payload info needed for replay path building.\n * Compatible with orbital-verify's UnifiedTransition.\n */\nexport interface ReplayTransition extends GraphTransition {\n hasGuard: boolean;\n guard?: unknown[];\n payloadFields: string[];\n payloadSchema: PayloadFieldSchema[];\n renderEffects: Array<{\n slot: string;\n patternType: string | null;\n }>;\n}\n\n/**\n * Builds the shortest replay paths from initial state to all reachable states.\n * \n * Computes step-by-step navigation paths for state machine testing and verification.\n * Uses breadth-first search to find shortest paths up to specified depth limit.\n * Each path contains replay steps with event, state, and payload information\n * needed to reproduce state transitions in tests.\n * \n * @param {ReplayTransition[]} transitions - Transitions with render/payload information\n * @param {string} initialState - Starting state name\n * @param {number} [maxDepth=3] - Maximum path length (default: 3)\n * @returns {Map<string, ReplayStep[]>} Map of state names to replay step arrays\n * \n * @example\n * // Build paths from 'initial' state\n * const paths = buildReplayPaths(transitions, 'initial', 5);\n * \n * // Get steps to reach 'completed' state\n * const stepsToComplete = paths.get('completed');\n * \n * // Execute replay steps\n * for (const step of stepsToComplete) {\n * await dispatchEvent(step.event, step.payload);\n * }\n */\nexport function buildReplayPaths(\n transitions: ReplayTransition[],\n initialState: string,\n maxDepth = 3\n): Map<string, ReplayStep[]> {\n type QueueNode = { state: string; path: ReplayStep[] };\n\n const queue: QueueNode[] = [{ state: initialState, path: [] }];\n const replayPaths = new Map<string, ReplayStep[]>();\n replayPaths.set(initialState, []);\n\n while (queue.length > 0) {\n const { state, path } = queue.shift()!;\n if (path.length >= maxDepth) continue;\n\n const fromHere = transitions.filter(\n (t) => t.from === state && t.event !== 'INIT',\n );\n\n for (const transition of fromHere) {\n if (replayPaths.has(transition.to)) continue;\n\n const renderEffect = transition.renderEffects.find((re) => re.patternType !== null);\n const stepNeedsEntityData =\n transition.hasGuard ||\n transition.payloadFields.some((f) => ENTITY_PAYLOAD_FIELDS.has(f));\n\n const step: ReplayStep = {\n event: transition.event,\n fromState: state,\n toState: transition.to,\n slot: renderEffect?.slot ?? 'main',\n expectedPattern: renderEffect?.patternType ?? undefined,\n needsEntityData: stepNeedsEntityData,\n payloadSchema: transition.payloadSchema.length > 0 ? transition.payloadSchema : undefined,\n };\n\n const newPath = [...path, step];\n replayPaths.set(transition.to, newPath);\n queue.push({ state: transition.to, path: newPath });\n }\n }\n\n return replayPaths;\n}\n","/**\n * Edge-Covering Walk Algorithm\n *\n * Computes an ordered sequence of events (WalkStep[]) that covers every\n * transition (edge) in a state machine graph at least once. This guarantees\n * 100% transition coverage regardless of graph topology.\n *\n * Algorithm:\n * 1. Build adjacency list and edge universe (guarded transitions produce two edges)\n * 2. Precompute BFS shortest paths between all state pairs (for repositioning)\n * 3. Greedy DFS: at each state, prefer uncovered outgoing edges\n * 4. When stuck, insert repositioning steps to nearest state with uncovered edges\n * 5. Guard-fail steps don't advance state (guard blocks transition)\n *\n * Used by StateWalkEngine in @almadar-io/verify. Both orbital-verify and\n * runtime-verify share this algorithm for consistent coverage.\n *\n * @packageDocumentation\n */\n\nimport type { EdgeWalkTransition, WalkStep, StateEdge } from './types.js';\nimport { buildGuardPayloads } from './guard-payloads.js';\n\n/**\n * Build an ordered walk that covers every edge in the state machine.\n *\n * @param transitions - All transitions in the state machine\n * @param initialState - Starting state\n * @returns Ordered walk steps covering every edge\n */\nexport function buildEdgeCoveringWalk(\n transitions: EdgeWalkTransition[],\n initialState: string,\n): WalkStep[] {\n // 1. Build adjacency list, skip wildcards and INIT\n const filtered = transitions.filter(\n (t) => t.from !== '*' && t.event !== 'INIT',\n );\n\n const graph = new Map<string, Array<{ event: string; to: string; transition: EdgeWalkTransition }>>();\n const allStates = new Set<string>();\n\n for (const t of filtered) {\n allStates.add(t.from);\n allStates.add(t.to);\n if (!graph.has(t.from)) graph.set(t.from, []);\n graph.get(t.from)!.push({ event: t.event, to: t.to, transition: t });\n }\n\n // Ensure initial state is in the set\n allStates.add(initialState);\n\n // 2. Build edge universe. Guarded transitions produce pass + fail edges.\n const uncovered = new Set<string>();\n const edgeMeta = new Map<string, { transition: EdgeWalkTransition; guardCase: 'pass' | 'fail' | null }>();\n\n for (const t of filtered) {\n if (t.hasGuard) {\n const keyPass = `${t.from}+${t.event}->${t.to}[pass]`;\n const keyFail = `${t.from}+${t.event}->${t.to}[fail]`;\n uncovered.add(keyPass);\n uncovered.add(keyFail);\n edgeMeta.set(keyPass, { transition: t, guardCase: 'pass' });\n edgeMeta.set(keyFail, { transition: t, guardCase: 'fail' });\n } else {\n const key = `${t.from}+${t.event}->${t.to}`;\n uncovered.add(key);\n edgeMeta.set(key, { transition: t, guardCase: null });\n }\n }\n\n if (uncovered.size === 0) return [];\n\n // 3. Precompute BFS shortest paths between all state pairs\n const shortestPaths = new Map<string, Map<string, Array<{ event: string; to: string }>>>();\n for (const state of allStates) {\n shortestPaths.set(state, bfsShortestPaths(state, graph));\n }\n\n // 4. Greedy walk\n const walk: WalkStep[] = [];\n let currentState = initialState;\n const maxIterations = uncovered.size * allStates.size * 2; // safety bound\n let iterations = 0;\n\n while (uncovered.size > 0 && iterations < maxIterations) {\n iterations++;\n\n // Find uncovered edges from currentState\n const outgoing = findUncoveredEdges(currentState, graph, uncovered);\n\n if (outgoing.length > 0) {\n // Pick first uncovered edge\n const pick = outgoing[0];\n const payload = buildPayloadForEdge(pick.transition, pick.guardCase);\n\n walk.push({\n from: currentState,\n event: pick.transition.event,\n to: pick.transition.to,\n guardCase: pick.guardCase,\n payload,\n isRepositioning: false,\n });\n\n uncovered.delete(pick.key);\n\n // Guard-fail doesn't advance state\n if (pick.guardCase !== 'fail') {\n currentState = pick.transition.to;\n }\n } else {\n // Stuck: find nearest state with uncovered edges\n const target = findNearestUncoveredState(currentState, graph, uncovered, shortestPaths);\n\n if (!target) {\n // No reachable state with uncovered edges. Remaining edges are unreachable.\n break;\n }\n\n // Insert repositioning steps\n const repoPath = shortestPaths.get(currentState)?.get(target);\n if (!repoPath || repoPath.length === 0) break;\n\n for (const step of repoPath) {\n walk.push({\n from: currentState,\n event: step.event,\n to: step.to,\n guardCase: null,\n payload: {},\n isRepositioning: true,\n });\n currentState = step.to;\n }\n }\n }\n\n return walk;\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\n/**\n * BFS from a source state, returning shortest paths to all reachable states.\n * Each path is an array of {event, to} steps.\n */\nfunction bfsShortestPaths(\n source: string,\n graph: Map<string, Array<{ event: string; to: string; transition: EdgeWalkTransition }>>,\n): Map<string, Array<{ event: string; to: string }>> {\n const paths = new Map<string, Array<{ event: string; to: string }>>();\n const visited = new Set<string>([source]);\n const queue: Array<{ state: string; path: Array<{ event: string; to: string }> }> = [\n { state: source, path: [] },\n ];\n\n while (queue.length > 0) {\n const { state, path } = queue.shift()!;\n const edges = graph.get(state) ?? [];\n\n for (const edge of edges) {\n if (visited.has(edge.to)) continue;\n visited.add(edge.to);\n const newPath = [...path, { event: edge.event, to: edge.to }];\n paths.set(edge.to, newPath);\n queue.push({ state: edge.to, path: newPath });\n }\n }\n\n return paths;\n}\n\n/**\n * Find uncovered edges from a given state.\n */\nfunction findUncoveredEdges(\n state: string,\n graph: Map<string, Array<{ event: string; to: string; transition: EdgeWalkTransition }>>,\n uncovered: Set<string>,\n): Array<{ key: string; transition: EdgeWalkTransition; guardCase: 'pass' | 'fail' | null }> {\n const edges = graph.get(state) ?? [];\n const result: Array<{ key: string; transition: EdgeWalkTransition; guardCase: 'pass' | 'fail' | null }> = [];\n\n for (const edge of edges) {\n if (edge.transition.hasGuard) {\n const keyPass = `${state}+${edge.event}->${edge.to}[pass]`;\n const keyFail = `${state}+${edge.event}->${edge.to}[fail]`;\n // Prefer pass first (advances state), then fail\n if (uncovered.has(keyPass)) {\n result.push({ key: keyPass, transition: edge.transition, guardCase: 'pass' });\n }\n if (uncovered.has(keyFail)) {\n result.push({ key: keyFail, transition: edge.transition, guardCase: 'fail' });\n }\n } else {\n const key = `${state}+${edge.event}->${edge.to}`;\n if (uncovered.has(key)) {\n result.push({ key, transition: edge.transition, guardCase: null });\n }\n }\n }\n\n return result;\n}\n\n/**\n * Find the nearest state (from currentState) that has uncovered outgoing edges.\n */\nfunction findNearestUncoveredState(\n currentState: string,\n graph: Map<string, Array<{ event: string; to: string; transition: EdgeWalkTransition }>>,\n uncovered: Set<string>,\n shortestPaths: Map<string, Map<string, Array<{ event: string; to: string }>>>,\n): string | null {\n // Collect states that have uncovered edges\n const statesWithUncovered = new Set<string>();\n for (const key of uncovered) {\n // Key format: \"state+EVENT->target\" or \"state+EVENT->target[pass]\"\n const fromState = key.split('+')[0];\n statesWithUncovered.add(fromState);\n }\n\n // If current state has uncovered edges, return it (shouldn't happen, but handle it)\n if (statesWithUncovered.has(currentState)) return currentState;\n\n // Find nearest reachable state with uncovered edges\n const paths = shortestPaths.get(currentState);\n if (!paths) return null;\n\n let nearestState: string | null = null;\n let nearestDist = Infinity;\n\n for (const target of statesWithUncovered) {\n const path = paths.get(target);\n if (path && path.length < nearestDist) {\n nearestDist = path.length;\n nearestState = target;\n }\n }\n\n return nearestState;\n}\n\n/**\n * Build a payload for a given edge based on its guard case.\n */\nfunction buildPayloadForEdge(\n transition: EdgeWalkTransition,\n guardCase: 'pass' | 'fail' | null,\n): Record<string, unknown> {\n if (!transition.hasGuard || !transition.guard || !guardCase) {\n return {};\n }\n\n const payloads = buildGuardPayloads(transition.guard);\n return guardCase === 'pass' ? payloads.pass : payloads.fail;\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { bs as SExpr } from '../schema-Cm63mgSP.js';
2
- export { A as AGENT_DOMAIN_CATEGORIES, e as ALLOWED_CUSTOM_COMPONENTS, f as AgentDomainCategory, g as AgentDomainCategorySchema, h as AllowedCustomComponent, i as AnimationDef, j as AnimationDefInput, k as AnimationDefSchema, b as AppSchema, l as AssetMap, m as AssetMapInput, n as AssetMapSchema, o as AssetMapping, p as AssetMappingInput, q as AssetMappingSchema, C as CORE_BINDINGS, r as CallServiceConfig, s as ComputedEventContract, t as ComputedEventContractSchema, u as ComputedEventListener, v as ComputedEventListenerSchema, w as CoreBinding, x as CustomPatternDefinition, y as CustomPatternDefinitionInput, z as CustomPatternDefinitionSchema, B as CustomPatternMap, D as CustomPatternMapInput, F as CustomPatternMapSchema, G as DesignPreferences, H as DesignPreferencesInput, I as DesignPreferencesSchema, J as DesignTokens, K as DesignTokensInput, L as DesignTokensSchema, M as DomainCategory, N as DomainCategorySchema, Q as DomainContext, R as DomainContextInput, U as DomainContextSchema, V as DomainVocabulary, W as DomainVocabularySchema, X as ENTITY_ROLES, Y as Effect, Z as EffectInput, _ as EffectSchema, d as Entity, E as EntityField, $ as EntityFieldInput, a0 as EntityFieldSchema, a as EntityPersistence, a1 as EntityPersistenceSchema, a2 as EntityRef, a3 as EntityRefSchema, a4 as EntityRefStringSchema, a5 as EntityRole, a6 as EntityRoleSchema, a7 as EntitySchema, a8 as EntitySemanticRole, a9 as EntitySemanticRoleSchema, aa as Event, ab as EventInput, ac as EventListener, ad as EventListenerSchema, ae as EventPayloadField, af as EventPayloadFieldSchema, ag as EventSchema, ah as EventScope, ai as EventScopeSchema, aj as EventSemanticRole, ak as EventSemanticRoleSchema, al as EventSource, am as EventSourceSchema, an as Expression, ao as ExpressionInput, ap as ExpressionSchema, aq as Field, ar as FieldFormat, as as FieldFormatSchema, at as FieldSchema, au as FieldType, av as FieldTypeSchema, aw as FullOrbitalUnit, ax as GAME_TYPES, ay as GameSubCategory, az as GameSubCategorySchema, aA as GameType, aB as GameTypeSchema, aC as Guard, aD as GuardInput, aE as GuardSchema, aF as McpServiceDef, aG as McpServiceDefSchema, aH as NodeClassification, aI as NodeClassificationSchema, aw as Orbital, aJ as OrbitalConfig, aK as OrbitalConfigInput, aL as OrbitalConfigSchema, O as OrbitalDefinition, aM as OrbitalDefinitionSchema, aN as OrbitalEntity, aO as OrbitalEntityInput, aP as OrbitalEntitySchema, aQ as OrbitalInput, aR as OrbitalPage, aS as OrbitalPageInput, aT as OrbitalPageSchema, aU as OrbitalPageStrictInput, aV as OrbitalPageStrictSchema, b as OrbitalSchema, aW as OrbitalSchemaInput, aX as OrbitalSchemaSchema, aY as OrbitalTraitRef, aZ as OrbitalTraitRefSchema, a_ as OrbitalUnit, a$ as OrbitalUnitSchema, b0 as OrbitalZodSchema, P as Page, b1 as PageRef, b2 as PageRefObject, b3 as PageRefObjectSchema, b4 as PageRefSchema, b5 as PageRefStringSchema, b6 as PageSchema, b7 as PageTraitRef, b8 as PageTraitRefSchema, b9 as ParsedBinding, ba as PayloadField, bb as PayloadFieldSchema, bc as PresentationType, bd as RelatedLink, be as RelatedLinkSchema, bf as RelationConfig, bg as RelationConfigSchema, bh as RenderUIConfig, bi as RequiredField, bj as RequiredFieldSchema, bk as ResolvedAsset, bl as ResolvedAssetInput, bm as ResolvedAssetSchema, bn as RestAuthConfig, bo as RestAuthConfigSchema, bp as RestServiceDef, bq as RestServiceDefSchema, br as SERVICE_TYPES, bt as SExprAtom, bu as SExprAtomSchema, bv as SExprInput, bw as SExprSchema, bx as SemanticAssetRef, by as SemanticAssetRefInput, bz as SemanticAssetRefSchema, bA as ServiceDefinition, bB as ServiceDefinitionSchema, bC as ServiceRef, bD as ServiceRefSchema, bE as ServiceRefStringSchema, bF as ServiceType, bG as ServiceTypeSchema, bH as SocketEvents, bI as SocketEventsSchema, bJ as SocketServiceDef, bK as SocketServiceDefSchema, S as State, bL as StateInput, bM as StateMachine, bN as StateMachineInput, bO as StateMachineSchema, bP as StateSchema, bQ as StateSemanticRole, bR as StateSemanticRoleSchema, bS as SuggestedGuard, bT as SuggestedGuardSchema, bU as ThemeDefinition, bV as ThemeDefinitionSchema, bW as ThemeRef, bX as ThemeRefSchema, bY as ThemeRefStringSchema, bZ as ThemeTokens, b_ as ThemeTokensSchema, b$ as ThemeVariant, c0 as ThemeVariantSchema, c as Trait, c1 as TraitCategory, c2 as TraitCategorySchema, c3 as TraitDataEntity, c4 as TraitDataEntitySchema, c5 as TraitEntityField, c6 as TraitEntityFieldSchema, T as TraitEventContract, c7 as TraitEventContractSchema, c8 as TraitEventListener, c9 as TraitEventListenerSchema, ca as TraitInput, cb as TraitRef, cc as TraitRefSchema, cd as TraitReference, ce as TraitReferenceInput, cf as TraitReferenceSchema, cg as TraitSchema, ch as TraitTick, ci as TraitTickSchema, cj as TraitUIBinding, ck as Transition, cl as TransitionInput, cm as TransitionSchema, cn as UISlot, co as UISlotSchema, cp as UI_SLOTS, cq as UXHints, cr as UXHintsSchema, cs as UseDeclaration, ct as UseDeclarationSchema, cu as UserPersona, cv as UserPersonaInput, cw as UserPersonaSchema, cx as VISUAL_STYLES, cy as ViewType, cz as ViewTypeSchema, cA as VisualStyle, cB as VisualStyleSchema, cC as callService, cD as collectBindings, cE as createAssetKey, cF as deriveCollection, cG as despawn, cH as doEffects, cI as emit, cJ as findService, cK as getArgs, cL as getDefaultAnimationsForRole, cM as getOperator, cN as getServiceNames, cO as getTraitConfig, cP as getTraitName, cQ as hasService, cR as isBinding, cS as isCircuitEvent, cT as isEffect, cU as isEntityReference, cV as isImportedTraitRef, cW as isInlineTrait, cX as isMcpService, cY as isOrbitalDefinition, cZ as isPageReference, c_ as isPageReferenceObject, c$ as isPageReferenceString, d0 as isRestService, d1 as isRuntimeEntity, d2 as isSExpr, d3 as isSExprAtom, d4 as isSExprCall, d5 as isSExprEffect, d6 as isServiceReference, d7 as isSingletonEntity, d8 as isSocketService, d9 as isThemeReference, da as isValidBinding, db as navigate, dc as normalizeTraitRef, dd as notify, de as parseAssetKey, df as parseBinding, dg as parseEntityRef, dh as parseImportedTraitRef, di as parseOrbitalSchema, dj as parsePageRef, dk as parseServiceRef, dl as persist, dm as renderUI, dn as safeParseOrbitalSchema, dp as set, dq as sexpr, dr as spawn, ds as validateAssetAnimations, dt as walkSExpr } from '../schema-Cm63mgSP.js';
1
+ import { bv as SExpr } from '../schema-BNBpNxGb.js';
2
+ export { A as AGENT_DOMAIN_CATEGORIES, e as ALLOWED_CUSTOM_COMPONENTS, f as AgentDomainCategory, g as AgentDomainCategorySchema, h as AllowedCustomComponent, i as AnimationDef, j as AnimationDefInput, k as AnimationDefSchema, b as AppSchema, l as AssetMap, m as AssetMapInput, n as AssetMapSchema, o as AssetMapping, p as AssetMappingInput, q as AssetMappingSchema, r as AtomicEffect, C as CORE_BINDINGS, s as CallServiceConfig, t as ComputedEventContract, u as ComputedEventContractSchema, v as ComputedEventListener, w as ComputedEventListenerSchema, x as CoreBinding, y as CustomPatternDefinition, z as CustomPatternDefinitionInput, B as CustomPatternDefinitionSchema, D as CustomPatternMap, F as CustomPatternMapInput, G as CustomPatternMapSchema, H as DerefEffect, I as DesignPreferences, J as DesignPreferencesInput, K as DesignPreferencesSchema, L as DesignTokens, M as DesignTokensInput, N as DesignTokensSchema, Q as DomainCategory, R as DomainCategorySchema, U as DomainContext, V as DomainContextInput, W as DomainContextSchema, X as DomainVocabulary, Y as DomainVocabularySchema, Z as ENTITY_ROLES, _ as Effect, $ as EffectInput, a0 as EffectSchema, d as Entity, E as EntityField, a1 as EntityFieldInput, a2 as EntityFieldSchema, a as EntityPersistence, a3 as EntityPersistenceSchema, a4 as EntityRef, a5 as EntityRefSchema, a6 as EntityRefStringSchema, a7 as EntityRole, a8 as EntityRoleSchema, a9 as EntitySchema, aa as EntitySemanticRole, ab as EntitySemanticRoleSchema, ac as Event, ad as EventInput, ae as EventListener, af as EventListenerSchema, ag as EventPayloadField, ah as EventPayloadFieldSchema, ai as EventSchema, aj as EventScope, ak as EventScopeSchema, al as EventSemanticRole, am as EventSemanticRoleSchema, an as EventSource, ao as EventSourceSchema, ap as Expression, aq as ExpressionInput, ar as ExpressionSchema, as as Field, at as FieldFormat, au as FieldFormatSchema, av as FieldSchema, aw as FieldType, ax as FieldTypeSchema, ay as FullOrbitalUnit, az as GAME_TYPES, aA as GameSubCategory, aB as GameSubCategorySchema, aC as GameType, aD as GameTypeSchema, aE as Guard, aF as GuardInput, aG as GuardSchema, aH as McpServiceDef, aI as McpServiceDefSchema, aJ as NodeClassification, aK as NodeClassificationSchema, ay as Orbital, aL as OrbitalConfig, aM as OrbitalConfigInput, aN as OrbitalConfigSchema, O as OrbitalDefinition, aO as OrbitalDefinitionSchema, aP as OrbitalEntity, aQ as OrbitalEntityInput, aR as OrbitalEntitySchema, aS as OrbitalInput, aT as OrbitalPage, aU as OrbitalPageInput, aV as OrbitalPageSchema, aW as OrbitalPageStrictInput, aX as OrbitalPageStrictSchema, b as OrbitalSchema, aY as OrbitalSchemaInput, aZ as OrbitalSchemaSchema, a_ as OrbitalTraitRef, a$ as OrbitalTraitRefSchema, b0 as OrbitalUnit, b1 as OrbitalUnitSchema, b2 as OrbitalZodSchema, P as Page, b3 as PageRef, b4 as PageRefObject, b5 as PageRefObjectSchema, b6 as PageRefSchema, b7 as PageRefStringSchema, b8 as PageSchema, b9 as PageTraitRef, ba as PageTraitRefSchema, bb as ParsedBinding, bc as PayloadField, bd as PayloadFieldSchema, be as PresentationType, bf as RefEffect, bg as RelatedLink, bh as RelatedLinkSchema, bi as RelationConfig, bj as RelationConfigSchema, bk as RenderUIConfig, bl as RequiredField, bm as RequiredFieldSchema, bn as ResolvedAsset, bo as ResolvedAssetInput, bp as ResolvedAssetSchema, bq as RestAuthConfig, br as RestAuthConfigSchema, bs as RestServiceDef, bt as RestServiceDefSchema, bu as SERVICE_TYPES, bw as SExprAtom, bx as SExprAtomSchema, by as SExprInput, bz as SExprSchema, bA as SemanticAssetRef, bB as SemanticAssetRefInput, bC as SemanticAssetRefSchema, bD as ServiceDefinition, bE as ServiceDefinitionSchema, bF as ServiceRef, bG as ServiceRefSchema, bH as ServiceRefStringSchema, bI as ServiceType, bJ as ServiceTypeSchema, bK as SocketEvents, bL as SocketEventsSchema, bM as SocketServiceDef, bN as SocketServiceDefSchema, S as State, bO as StateInput, bP as StateMachine, bQ as StateMachineInput, bR as StateMachineSchema, bS as StateSchema, bT as StateSemanticRole, bU as StateSemanticRoleSchema, bV as SuggestedGuard, bW as SuggestedGuardSchema, bX as SwapEffect, bY as ThemeDefinition, bZ as ThemeDefinitionSchema, b_ as ThemeRef, b$ as ThemeRefSchema, c0 as ThemeRefStringSchema, c1 as ThemeTokens, c2 as ThemeTokensSchema, c3 as ThemeVariant, c4 as ThemeVariantSchema, c as Trait, c5 as TraitCategory, c6 as TraitCategorySchema, c7 as TraitDataEntity, c8 as TraitDataEntitySchema, c9 as TraitEntityField, ca as TraitEntityFieldSchema, T as TraitEventContract, cb as TraitEventContractSchema, cc as TraitEventListener, cd as TraitEventListenerSchema, ce as TraitInput, cf as TraitRef, cg as TraitRefSchema, ch as TraitReference, ci as TraitReferenceInput, cj as TraitReferenceSchema, ck as TraitSchema, cl as TraitTick, cm as TraitTickSchema, cn as TraitUIBinding, co as Transition, cp as TransitionInput, cq as TransitionSchema, cr as UISlot, cs as UISlotSchema, ct as UI_SLOTS, cu as UXHints, cv as UXHintsSchema, cw as UseDeclaration, cx as UseDeclarationSchema, cy as UserPersona, cz as UserPersonaInput, cA as UserPersonaSchema, cB as VISUAL_STYLES, cC as ViewType, cD as ViewTypeSchema, cE as VisualStyle, cF as VisualStyleSchema, cG as WatchEffect, cH as WatchOptions, cI as atomic, cJ as callService, cK as collectBindings, cL as createAssetKey, cM as deref, cN as deriveCollection, cO as despawn, cP as doEffects, cQ as emit, cR as findService, cS as getArgs, cT as getDefaultAnimationsForRole, cU as getOperator, cV as getServiceNames, cW as getTraitConfig, cX as getTraitName, cY as hasService, cZ as isBinding, c_ as isCircuitEvent, c$ as isEffect, d0 as isEntityReference, d1 as isImportedTraitRef, d2 as isInlineTrait, d3 as isMcpService, d4 as isOrbitalDefinition, d5 as isPageReference, d6 as isPageReferenceObject, d7 as isPageReferenceString, d8 as isRestService, d9 as isRuntimeEntity, da as isSExpr, db as isSExprAtom, dc as isSExprCall, dd as isSExprEffect, de as isServiceReference, df as isSingletonEntity, dg as isSocketService, dh as isThemeReference, di as isValidBinding, dj as navigate, dk as normalizeTraitRef, dl as notify, dm as parseAssetKey, dn as parseBinding, dp as parseEntityRef, dq as parseImportedTraitRef, dr as parseOrbitalSchema, ds as parsePageRef, dt as parseServiceRef, du as persist, dv as ref, dw as renderUI, dx as safeParseOrbitalSchema, dy as set, dz as sexpr, dA as spawn, dB as swap, dC as validateAssetAnimations, dD as walkSExpr, dE as watch } from '../schema-BNBpNxGb.js';
3
3
  import { z } from 'zod';
4
4
  export { CATEGORIES, CategoryMeta, OPERATORS, OPERATORS_SCHEMA, OPERATOR_NAMES, OperatorCategory, OperatorMeta, OperatorStats, OperatorsSchema, TargetPlatform, getOperatorMeta, getOperatorStats, getOperatorsByCategory, getOperatorsForTarget, isEffectOperator, isGuardOperator, isKnownOperator, validateOperatorArity } from '@almadar/operators';
5
5
  export { PATTERN_TYPES, PatternConfig, PatternType, isValidPatternType } from '@almadar/patterns';