@almadar/core 7.0.0 → 7.3.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.
@@ -1,224 +1,7 @@
1
+ import { S as SExpr, d as Expression } from './expression-eBO9-SQM.js';
1
2
  import { z } from 'zod';
2
3
  import { AnyPatternConfig } from '@almadar/patterns';
3
4
 
4
- /**
5
- * S-Expression Types
6
- *
7
- * Defines the S-Expression type system for guards, effects, and computed values.
8
- * S-expressions are JSON arrays where the first element is an operator string.
9
- *
10
- * @example
11
- * // Guard: health > 0
12
- * [">", "@entity.health", 0]
13
- *
14
- * // Effect: set x to x + vx
15
- * ["set", "@entity.x", ["+", "@entity.x", "@entity.vx"]]
16
- *
17
- * @packageDocumentation
18
- */
19
-
20
- /**
21
- * S-Expression type - recursive structure representing expressions.
22
- *
23
- * An S-expression is either:
24
- * - A literal value (string, number, boolean, null)
25
- * - An object literal (for payload data, props, etc.)
26
- * - A binding reference (string starting with @)
27
- * - A call expression (array with operator as first element)
28
- */
29
- type SExprAtom = string | number | boolean | null | Record<string, unknown>;
30
- type SExpr = SExprAtom | SExpr[];
31
- /**
32
- * Expression type - S-expressions only.
33
- * Used for guards, computed values, and effect expressions.
34
- *
35
- * NOTE: Legacy string format is no longer supported.
36
- * All expressions must be S-expression arrays.
37
- */
38
- type Expression = SExpr;
39
- /**
40
- * Schema for atomic S-expression values (non-array)
41
- * Includes objects for payload data, props, etc.
42
- */
43
- declare const SExprAtomSchema: z.ZodType<SExprAtom>;
44
- /**
45
- * Recursive schema for S-expressions.
46
- * Validates that arrays have at least one element and first element is a string (operator).
47
- */
48
- declare const SExprSchema: z.ZodType<SExpr>;
49
- /**
50
- * Schema for Expression type - S-expressions only.
51
- * S-expressions are arrays with operator as first element.
52
- *
53
- * NOTE: Legacy string format is no longer supported.
54
- */
55
- declare const ExpressionSchema: z.ZodType<Expression>;
56
- /**
57
- * Type guard for S-expression detection.
58
- * 100% reliable - structural check, no regex or keyword matching.
59
- *
60
- * @param value - Value to check
61
- * @returns true if value is an S-expression (array with string operator)
62
- */
63
- declare function isSExpr(value: unknown): value is SExpr[];
64
- /**
65
- * Type guard for S-expression atoms (non-array values).
66
- *
67
- * Validates that a value is an S-expression atom (literal value).
68
- * Includes null, strings, numbers, booleans, and objects. Used to
69
- * distinguish atomic values from S-expression calls (arrays).
70
- *
71
- * @param {unknown} value - Value to check
72
- * @returns {boolean} True if value is an S-expression atom, false otherwise
73
- *
74
- * @example
75
- * isSExprAtom('hello'); // returns true
76
- * isSExprAtom(42); // returns true
77
- * isSExprAtom(null); // returns true
78
- * isSExprAtom({ key: 'value' }); // returns true
79
- * isSExprAtom(['+', 1, 2]); // returns false
80
- */
81
- declare function isSExprAtom(value: unknown): value is SExprAtom;
82
- /**
83
- * Checks if a value is a binding reference.
84
- *
85
- * Validates that a string is a binding reference (starts with @).
86
- * Bindings reference runtime values like @entity.health, @payload.amount, @now.
87
- * Used for identifying bindings in S-expressions and validation.
88
- *
89
- * @param {unknown} value - Value to check
90
- * @returns {boolean} True if value is a binding reference, false otherwise
91
- *
92
- * @example
93
- * isBinding('@entity.health'); // returns true
94
- * isBinding('@payload.amount'); // returns true
95
- * isBinding('not-a-binding'); // returns false
96
- * isBinding(123); // returns false
97
- */
98
- declare function isBinding(value: unknown): value is string;
99
- /**
100
- * Checks if a value is a valid S-expression call (array with operator).
101
- *
102
- * Alias for isSExpr() - validates S-expression call structure.
103
- * Used to distinguish between S-expression calls and atom values.
104
- *
105
- * @param {unknown} value - Value to check
106
- * @returns {boolean} True if value is a valid S-expression call, false otherwise
107
- *
108
- * @example
109
- * isSExprCall(['+', 1, 2]); // returns true
110
- * isSExprCall(['set', '@entity.health', 100]); // returns true
111
- * isSExprCall('not-a-call'); // returns false
112
- */
113
- declare function isSExprCall(value: unknown): value is SExpr[];
114
- /**
115
- * Parsed binding reference
116
- */
117
- interface ParsedBinding {
118
- /** Type of binding: core (@entity, @payload, @state, @now) or entity (@EntityName) */
119
- type: 'core' | 'entity';
120
- /** The root binding name (entity, payload, state, now, or EntityName) */
121
- root: string;
122
- /** Path segments after the root (e.g., ['health'] for @entity.health) */
123
- path: string[];
124
- /** Full original binding string */
125
- original: string;
126
- }
127
- /**
128
- * Core bindings that are always available.
129
- * Phase 4.5 adds: config, computed, trait (for behavior support)
130
- */
131
- declare const CORE_BINDINGS: readonly ["entity", "payload", "state", "now", "config", "computed", "trait"];
132
- type CoreBinding = (typeof CORE_BINDINGS)[number];
133
- /**
134
- * Parses a binding reference into its components.
135
- *
136
- * Deconstructs a binding string (e.g., '@entity.health') into its constituent
137
- * parts: type, root, path, and original string. Does NOT use regex - uses
138
- * structured string operations for reliability and maintainability.
139
- *
140
- * @param {string} binding - Binding string starting with @
141
- * @returns {ParsedBinding | null} Parsed binding object or null if invalid
142
- *
143
- * @example
144
- * parseBinding('@entity.health'); // returns { type: 'core', root: 'entity', path: ['health'], original: '@entity.health' }
145
- * parseBinding('@User.name'); // returns { type: 'entity', root: 'User', path: ['name'], original: '@User.name' }
146
- * parseBinding('not-a-binding'); // returns null
147
- */
148
- declare function parseBinding(binding: string): ParsedBinding | null;
149
- /**
150
- * Validate a binding reference format.
151
- *
152
- * @param binding - Binding string to validate
153
- * @returns true if valid binding format
154
- */
155
- declare function isValidBinding(binding: string): boolean;
156
- /**
157
- * Get the operator from an S-expression call.
158
- *
159
- * @param expr - S-expression array
160
- * @returns The operator string or null if not a valid call
161
- */
162
- declare function getOperator(expr: SExpr): string | null;
163
- /**
164
- * Get the arguments from an S-expression call.
165
- *
166
- * @param expr - S-expression array
167
- * @returns Array of arguments (empty if not a valid call)
168
- */
169
- declare function getArgs(expr: SExpr): SExpr[];
170
- /**
171
- * Create an S-expression call.
172
- *
173
- * @param operator - The operator string
174
- * @param args - Arguments to the operator
175
- * @returns S-expression array
176
- */
177
- declare function sexpr(operator: string, ...args: SExpr[]): SExpr[];
178
- /**
179
- * Walk an S-expression tree and apply a visitor function to each node.
180
- *
181
- * @param expr - S-expression to walk
182
- * @param visitor - Function to call on each node
183
- */
184
- declare function walkSExpr(expr: SExpr, visitor: (node: SExpr, parent: SExpr[] | null, index: number) => void, parent?: SExpr[] | null, index?: number): void;
185
- /**
186
- * Collect all bindings referenced in an S-expression.
187
- *
188
- * @param expr - S-expression to analyze
189
- * @returns Array of binding strings found
190
- */
191
- declare function collectBindings(expr: SExpr): string[];
192
- type SExprInput = z.input<typeof SExprSchema>;
193
- type ExpressionInput = z.input<typeof ExpressionSchema>;
194
- /** Evaluation context for guards and s-expressions. Recursive. */
195
- interface EvalContext {
196
- [key: string]: string | number | boolean | Date | null | string[] | EvalContext | undefined;
197
- }
198
- /**
199
- * A single value carried by an event payload field. The top-level payload
200
- * is always an object; the VALUES in that object can be primitives, nested
201
- * objects, or arrays of the same. Arrays are allowed so real-world emits
202
- * like `{ files: [{ name, size, type }, ...] }` or `{ selected: string[] }`
203
- * are typed natively instead of forcing consumers to wrap at every call.
204
- *
205
- * `Date` is included so `EntityRow` (whose values are `FieldValue`, which
206
- * includes `Date`) is assignable to a payload field without a cast —
207
- * emitted entity rows flow through the bus without boundary widening.
208
- */
209
- type EventPayloadValue = string | number | boolean | Date | null | undefined | EventPayload | readonly EventPayloadValue[];
210
- /**
211
- * Typed event payload. Object-shaped so it's assignable to the bus's
212
- * `EventPayload` parameter without casts.
213
- */
214
- interface EventPayload {
215
- [key: string]: EventPayloadValue;
216
- }
217
- /** Structured log/event metadata. Recursive to support nested log data. */
218
- interface LogMeta {
219
- [key: string]: string | number | boolean | null | undefined | Error | LogMeta;
220
- }
221
-
222
5
  /**
223
6
  * Service Types for Orbital Schema
224
7
  *
@@ -22871,4 +22654,4 @@ declare function safeParseOrbitalSchema(data: unknown): z.SafeParseReturnType<{
22871
22654
  type OrbitalSchemaInput = z.input<typeof OrbitalSchemaSchema>;
22872
22655
  type OrbitalConfigInput = z.input<typeof OrbitalConfigSchema>;
22873
22656
 
22874
- export { type DesignTokens as $, AGENT_DOMAIN_CATEGORIES as A, AssetMappingSchema as B, type AtomicEffect as C, CORE_BINDINGS as D, type Entity as E, type CallServiceConfig as F, type CallServiceEffect as G, type ComputedEventContract as H, ComputedEventContractSchema as I, type ComputedEventListener as J, ComputedEventListenerSchema as K, type CoreBinding as L, type CustomPatternDefinition as M, type CustomPatternDefinitionInput as N, type OrbitalDefinition as O, type PageRef as P, CustomPatternDefinitionSchema as Q, type CustomPatternMap as R, type SExpr as S, type TraitEventContract as T, type UseDeclaration as U, type CustomPatternMapInput as V, CustomPatternMapSchema as W, type DerefEffect as X, type DesignPreferences as Y, type DesignPreferencesInput as Z, DesignPreferencesSchema as _, type TraitEventListener as a, type Guard as a$, type DesignTokensInput as a0, DesignTokensSchema as a1, type DespawnEffect as a2, type DoEffect as a3, type DomainCategory as a4, DomainCategorySchema as a5, type DomainContext as a6, type DomainContextInput as a7, DomainContextSchema as a8, type DomainVocabulary as a9, type EventPayloadField as aA, EventPayloadFieldSchema as aB, type EventPayloadValue as aC, EventSchema as aD, type EventScope as aE, EventScopeSchema as aF, type EventSemanticRole as aG, EventSemanticRoleSchema as aH, type EventSource as aI, EventSourceSchema as aJ, type Expression as aK, type ExpressionInput as aL, ExpressionSchema as aM, type FetchEffect as aN, type Field as aO, type FieldFormat as aP, FieldFormatSchema as aQ, FieldSchema as aR, type FieldType as aS, FieldTypeSchema as aT, type FieldValue as aU, type Orbital as aV, GAME_TYPES as aW, type GameSubCategory as aX, GameSubCategorySchema as aY, type GameType as aZ, GameTypeSchema as a_, DomainVocabularySchema as aa, ENTITY_ROLES as ab, type Effect as ac, type EffectInput as ad, EffectSchema as ae, type EmitConfig as af, type EmitEffect as ag, type EntityCall as ah, EntityCallSchema as ai, type EntityData as aj, type EntityFieldInput as ak, EntityFieldSchema as al, EntityPersistenceSchema as am, EntityRefSchema as an, EntityRefStringSchema as ao, type EntityRole as ap, EntityRoleSchema as aq, EntitySchema as ar, type EntitySemanticRole as as, EntitySemanticRoleSchema as at, type EvalContext as au, type Event as av, type EventInput as aw, type EventListener as ax, EventListenerSchema as ay, type EventPayload as az, type TraitConfig as b, type SExprAtom as b$, type GuardInput as b0, GuardSchema as b1, type ListenSource as b2, ListenSourceSchema as b3, type LogEffect as b4, type LogMeta as b5, type McpServiceDef as b6, McpServiceDefSchema as b7, type NavigateEffect as b8, type NodeClassification as b9, type PageTraitRef as bA, PageTraitRefSchema as bB, type ParsedBinding as bC, type PayloadField as bD, PayloadFieldSchema as bE, type PersistEffect as bF, type PresentationType as bG, type RefEffect as bH, type RelatedLink as bI, RelatedLinkSchema as bJ, type RelationConfig as bK, RelationConfigSchema as bL, type RenderItemLambda as bM, type RenderUIConfig as bN, type RenderUIEffect as bO, type RenderUINode as bP, type RequiredField as bQ, RequiredFieldSchema as bR, type ResolvedAsset as bS, type ResolvedAssetInput as bT, ResolvedAssetSchema as bU, type ResolvedPatternProps as bV, type RestAuthConfig as bW, RestAuthConfigSchema as bX, type RestServiceDef as bY, RestServiceDefSchema as bZ, SERVICE_TYPES as b_, NodeClassificationSchema as ba, type NotifyEffect as bb, type OrbitalConfig as bc, type OrbitalConfigInput as bd, OrbitalConfigSchema as be, OrbitalDefinitionSchema as bf, type OrbitalEntity as bg, type OrbitalEntityInput as bh, OrbitalEntitySchema as bi, type OrbitalInput as bj, type OrbitalPage as bk, type OrbitalPageInput as bl, OrbitalPageSchema as bm, type OrbitalPageStrictInput as bn, OrbitalPageStrictSchema as bo, type OrbitalSchemaInput as bp, OrbitalSchemaSchema as bq, type OrbitalTraitRef as br, OrbitalTraitRefSchema as bs, type OrbitalUnit as bt, OrbitalUnitSchema as bu, OrbitalSchema$1 as bv, PageRefObjectSchema as bw, PageRefSchema as bx, PageRefStringSchema as by, PageSchema as bz, type EntityField as c, TransitionSchema as c$, SExprAtomSchema as c0, type SExprInput as c1, SExprSchema as c2, type SemanticAssetRef as c3, type SemanticAssetRefInput as c4, SemanticAssetRefSchema as c5, type ServiceDefinition as c6, ServiceDefinitionSchema as c7, type ServiceParams as c8, type ServiceRef as c9, ThemeRefStringSchema as cA, type ThemeTokens as cB, ThemeTokensSchema as cC, type ThemeVariant as cD, ThemeVariantSchema as cE, type TraitCategory as cF, TraitCategorySchema as cG, type TraitConfigObject as cH, TraitConfigSchema as cI, type TraitConfigValue as cJ, TraitConfigValueSchema as cK, type TraitDataEntity as cL, TraitDataEntitySchema as cM, type TraitEntityField as cN, TraitEntityFieldSchema as cO, TraitEventContractSchema as cP, TraitEventListenerSchema as cQ, type TraitInput as cR, TraitRefSchema as cS, type TraitReferenceInput as cT, TraitReferenceSchema as cU, TraitSchema as cV, type TraitTick as cW, TraitTickSchema as cX, type TraitUIBinding as cY, type Transition as cZ, type TransitionInput as c_, type ServiceRefObject as ca, ServiceRefObjectSchema as cb, ServiceRefSchema as cc, ServiceRefStringSchema as cd, type ServiceType as ce, ServiceTypeSchema as cf, type SetEffect as cg, type SocketEvents as ch, SocketEventsSchema as ci, type SocketServiceDef as cj, SocketServiceDefSchema as ck, type SpawnEffect as cl, type StateInput as cm, type StateMachine as cn, type StateMachineInput as co, StateMachineSchema as cp, StateSchema as cq, type StateSemanticRole as cr, StateSemanticRoleSchema as cs, type SuggestedGuard as ct, SuggestedGuardSchema as cu, type SwapEffect as cv, type ThemeDefinition as cw, ThemeDefinitionSchema as cx, type ThemeRef as cy, ThemeRefSchema as cz, type EntityPersistence as d, parseAssetKey as d$, type TypedEffect as d0, type UISlot as d1, UISlotSchema as d2, UI_SLOTS as d3, type UXHints as d4, UXHintsSchema as d5, UseDeclarationSchema as d6, type UserPersona as d7, type UserPersonaInput as d8, UserPersonaSchema as d9, isCircuitEvent as dA, isEffect as dB, isEntityCall as dC, isEntityReference as dD, isEntityReferenceAny as dE, isImportedTraitRef as dF, isInlineTrait as dG, isMcpService as dH, isOrbitalDefinition as dI, isPageReference as dJ, isPageReferenceObject as dK, isPageReferenceString as dL, isRestService as dM, isRuntimeEntity as dN, isSExpr as dO, isSExprAtom as dP, isSExprCall as dQ, isSExprEffect as dR, isServiceReference as dS, isServiceReferenceObject as dT, isSingletonEntity as dU, isSocketService as dV, isThemeReference as dW, isValidBinding as dX, navigate as dY, normalizeTraitRef as dZ, notify as d_, VISUAL_STYLES as da, type ViewType as db, ViewTypeSchema as dc, type VisualStyle as dd, VisualStyleSchema as de, type WatchEffect as df, type WatchOptions as dg, atomic as dh, callService as di, collectBindings as dj, createAssetKey as dk, deref as dl, deriveCollection as dm, despawn as dn, doEffects as dp, emit as dq, findService as dr, getArgs as ds, getDefaultAnimationsForRole as dt, getOperator as du, getServiceNames as dv, getTraitConfig as dw, getTraitName as dx, hasService as dy, isBinding as dz, type EntityRow as e, parseBinding as e0, parseEntityRef as e1, parseImportedTraitRef as e2, parseOrbitalSchema as e3, parsePageRef as e4, parseServiceRef as e5, persist as e6, ref as e7, renderUI as e8, safeParseOrbitalSchema as e9, set as ea, sexpr as eb, spawn as ec, swap as ed, validateAssetAnimations as ee, walkSExpr as ef, watch as eg, type EntityRef as f, type TraitRef as g, type OrbitalSchema as h, type Trait as i, type Page as j, type PageRefObject as k, type TraitReference as l, type State as m, ALLOWED_CUSTOM_COMPONENTS as n, type AgentDomainCategory as o, AgentDomainCategorySchema as p, type AgentEffect as q, type AllowedCustomComponent as r, type AnimationDef as s, type AnimationDefInput as t, AnimationDefSchema as u, type AssetMap as v, type AssetMapInput as w, AssetMapSchema as x, type AssetMapping as y, type AssetMappingInput as z };
22657
+ export { type DespawnEffect as $, AGENT_DOMAIN_CATEGORIES as A, type AtomicEffect as B, type CallServiceConfig as C, type CallServiceEffect as D, type Entity as E, type ComputedEventContract as F, ComputedEventContractSchema as G, type ComputedEventListener as H, ComputedEventListenerSchema as I, type CustomPatternDefinition as J, type CustomPatternDefinitionInput as K, CustomPatternDefinitionSchema as L, type CustomPatternMap as M, type CustomPatternMapInput as N, type OrbitalDefinition as O, type PageRef as P, CustomPatternMapSchema as Q, type DerefEffect as R, type State as S, type TraitEventContract as T, type UseDeclaration as U, type DesignPreferences as V, type DesignPreferencesInput as W, DesignPreferencesSchema as X, type DesignTokens as Y, type DesignTokensInput as Z, DesignTokensSchema as _, type TraitEventListener as a, type NodeClassification as a$, type DoEffect as a0, type DomainCategory as a1, DomainCategorySchema as a2, type DomainContext as a3, type DomainContextInput as a4, DomainContextSchema as a5, type DomainVocabulary as a6, DomainVocabularySchema as a7, ENTITY_ROLES as a8, type Effect as a9, type EventSemanticRole as aA, EventSemanticRoleSchema as aB, type EventSource as aC, EventSourceSchema as aD, type FetchEffect as aE, type Field as aF, type FieldFormat as aG, FieldFormatSchema as aH, FieldSchema as aI, type FieldType as aJ, FieldTypeSchema as aK, type FieldValue as aL, type Orbital as aM, GAME_TYPES as aN, type GameSubCategory as aO, GameSubCategorySchema as aP, type GameType as aQ, GameTypeSchema as aR, type Guard as aS, type GuardInput as aT, GuardSchema as aU, type ListenSource as aV, ListenSourceSchema as aW, type LogEffect as aX, type McpServiceDef as aY, McpServiceDefSchema as aZ, type NavigateEffect as a_, type EffectInput as aa, EffectSchema as ab, type EmitConfig as ac, type EmitEffect as ad, type EntityCall as ae, EntityCallSchema as af, type EntityData as ag, type EntityFieldInput as ah, EntityFieldSchema as ai, EntityPersistenceSchema as aj, EntityRefSchema as ak, EntityRefStringSchema as al, type EntityRole as am, EntityRoleSchema as an, EntitySchema as ao, type EntitySemanticRole as ap, EntitySemanticRoleSchema as aq, type Event as ar, type EventInput as as, type EventListener as at, EventListenerSchema as au, type EventPayloadField as av, EventPayloadFieldSchema as aw, EventSchema as ax, type EventScope as ay, EventScopeSchema as az, type TraitConfig as b, type ServiceType as b$, NodeClassificationSchema as b0, type NotifyEffect as b1, type OrbitalConfig as b2, type OrbitalConfigInput as b3, OrbitalConfigSchema as b4, OrbitalDefinitionSchema as b5, type OrbitalEntity as b6, type OrbitalEntityInput as b7, OrbitalEntitySchema as b8, type OrbitalInput as b9, RelationConfigSchema as bA, type RenderItemLambda as bB, type RenderUIConfig as bC, type RenderUIEffect as bD, type RenderUINode as bE, type RequiredField as bF, RequiredFieldSchema as bG, type ResolvedAsset as bH, type ResolvedAssetInput as bI, ResolvedAssetSchema as bJ, type ResolvedPatternProps as bK, type RestAuthConfig as bL, RestAuthConfigSchema as bM, type RestServiceDef as bN, RestServiceDefSchema as bO, SERVICE_TYPES as bP, type SemanticAssetRef as bQ, type SemanticAssetRefInput as bR, SemanticAssetRefSchema as bS, type ServiceDefinition as bT, ServiceDefinitionSchema as bU, type ServiceParams as bV, type ServiceRef as bW, type ServiceRefObject as bX, ServiceRefObjectSchema as bY, ServiceRefSchema as bZ, ServiceRefStringSchema as b_, type OrbitalPage as ba, type OrbitalPageInput as bb, OrbitalPageSchema as bc, type OrbitalPageStrictInput as bd, OrbitalPageStrictSchema as be, type OrbitalSchemaInput as bf, OrbitalSchemaSchema as bg, type OrbitalTraitRef as bh, OrbitalTraitRefSchema as bi, type OrbitalUnit as bj, OrbitalUnitSchema as bk, OrbitalSchema$1 as bl, PageRefObjectSchema as bm, PageRefSchema as bn, PageRefStringSchema as bo, PageSchema as bp, type PageTraitRef as bq, PageTraitRefSchema as br, type PayloadField as bs, PayloadFieldSchema as bt, type PersistEffect as bu, type PresentationType as bv, type RefEffect as bw, type RelatedLink as bx, RelatedLinkSchema as by, type RelationConfig as bz, type EntityField as c, VisualStyleSchema as c$, ServiceTypeSchema as c0, type SetEffect as c1, type SocketEvents as c2, SocketEventsSchema as c3, type SocketServiceDef as c4, SocketServiceDefSchema as c5, type SpawnEffect as c6, type StateInput as c7, type StateMachine as c8, type StateMachineInput as c9, TraitEventContractSchema as cA, TraitEventListenerSchema as cB, type TraitInput as cC, TraitRefSchema 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 TypedEffect as cN, type UISlot as cO, UISlotSchema as cP, UI_SLOTS as cQ, type UXHints as cR, UXHintsSchema 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 VisualStyle as c_, StateMachineSchema as ca, StateSchema as cb, type StateSemanticRole as cc, StateSemanticRoleSchema as cd, type SuggestedGuard as ce, SuggestedGuardSchema as cf, type SwapEffect as cg, type ThemeDefinition as ch, ThemeDefinitionSchema as ci, type ThemeRef as cj, ThemeRefSchema as ck, ThemeRefStringSchema as cl, type ThemeTokens as cm, ThemeTokensSchema as cn, type ThemeVariant as co, ThemeVariantSchema as cp, type TraitCategory as cq, TraitCategorySchema as cr, type TraitConfigObject as cs, TraitConfigSchema as ct, type TraitConfigValue as cu, TraitConfigValueSchema as cv, type TraitDataEntity as cw, TraitDataEntitySchema as cx, type TraitEntityField as cy, TraitEntityFieldSchema as cz, type EntityPersistence as d, type WatchEffect as d0, type WatchOptions as d1, atomic as d2, callService as d3, createAssetKey as d4, deref as d5, deriveCollection as d6, despawn as d7, doEffects as d8, emit as d9, isThemeReference as dA, navigate as dB, normalizeTraitRef as dC, notify as dD, parseAssetKey as dE, parseEntityRef as dF, parseImportedTraitRef as dG, parseOrbitalSchema as dH, parsePageRef as dI, parseServiceRef as dJ, persist as dK, ref as dL, renderUI as dM, safeParseOrbitalSchema as dN, set as dO, spawn as dP, swap as dQ, validateAssetAnimations as dR, watch as dS, findService as da, getDefaultAnimationsForRole as db, getServiceNames as dc, getTraitConfig as dd, getTraitName as de, hasService as df, isCircuitEvent as dg, isEffect as dh, isEntityCall as di, isEntityReference as dj, isEntityReferenceAny as dk, isImportedTraitRef as dl, isInlineTrait as dm, isMcpService as dn, isOrbitalDefinition as dp, isPageReference as dq, isPageReferenceObject as dr, isPageReferenceString as ds, isRestService as dt, isRuntimeEntity as du, isSExprEffect as dv, isServiceReference as dw, isServiceReferenceObject as dx, isSingletonEntity as dy, isSocketService as dz, type EntityRow as e, type EntityRef as f, type TraitRef as g, type OrbitalSchema as h, type Trait as i, type Page as j, type PageRefObject as k, type TraitReference as l, ALLOWED_CUSTOM_COMPONENTS as m, type AgentDomainCategory as n, AgentDomainCategorySchema as o, type AgentEffect as p, type AllowedCustomComponent as q, type AnimationDef as r, type AnimationDefInput as s, AnimationDefSchema as t, type AssetMap as u, type AssetMapInput as v, AssetMapSchema as w, type AssetMapping as x, type AssetMappingInput as y, AssetMappingSchema as z };
@@ -1,3 +1,6 @@
1
+ import { S as SExpr } from '../expression-eBO9-SQM.js';
2
+ import 'zod';
3
+
1
4
  /**
2
5
  * State Machine Graph Algorithm Types
3
6
  *
@@ -6,6 +9,7 @@
6
9
  *
7
10
  * @packageDocumentation
8
11
  */
12
+
9
13
  /** An edge in the state graph adjacency list */
10
14
  interface StateEdge {
11
15
  event: string;
@@ -66,7 +70,19 @@ interface GraphTransition {
66
70
  */
67
71
  interface EdgeWalkTransition extends GraphTransition {
68
72
  hasGuard: boolean;
69
- guard?: unknown[];
73
+ /**
74
+ * Guard expression (when present). Mirrors `@almadar/core`'s `SExpr`
75
+ * union — a string atom (e.g. `"@payload.row"` for bare-binding
76
+ * existence guards declared by std-confirmation) OR an array
77
+ * (`["or", ...]`, `["=", ...]`). Pre-fix, the type was `unknown[]`
78
+ * which rejected the string form and `toEdgeWalkTransition`
79
+ * silently dropped it; downstream `buildGuardPayloads` then saw no
80
+ * guard and synthesized `{}` for the verifier's pass-case bus
81
+ * replay, leaving the modal closed and the portal observer
82
+ * reporting "slot not mounted" for every single-binding-guarded
83
+ * event.
84
+ */
85
+ guard?: SExpr;
70
86
  /** Event payload field declarations (e.g., [{ name: "id", type: "string", mockValue: "mock-products-1" }]).
71
87
  * Used to generate mock payloads for events that require data (VIEW, EDIT).
72
88
  * Callers should set mockValue for id fields using their entity context. */
@@ -60,6 +60,10 @@ function extractPayloadFieldRef(ref) {
60
60
  return match ? match[1] : null;
61
61
  }
62
62
  function buildGuardPayloads(guard) {
63
+ if (typeof guard === "string") {
64
+ const field = extractPayloadFieldRef(guard);
65
+ if (field) return { pass: { [field]: { id: "mock-test-id", name: "mock-test-name" } }, fail: { [field]: null } };
66
+ }
63
67
  if (!Array.isArray(guard) || guard.length === 0) {
64
68
  return { pass: {}, fail: {} };
65
69
  }
@@ -118,11 +122,12 @@ function buildGuardPayloads(guard) {
118
122
  if (subs.length === 1) return buildGuardPayloads(subs[0]);
119
123
  }
120
124
  if (op === "or") {
121
- const subs = guard.slice(1).filter(Array.isArray);
125
+ const subs = guard.slice(1);
122
126
  if (subs.length >= 2) {
123
127
  const s1 = buildGuardPayloads(subs[0]);
124
128
  const s2 = buildGuardPayloads(subs[1]);
125
- return { pass: s1.pass, fail: { ...s1.fail, ...s2.fail } };
129
+ const combinedPass = Object.keys(s1.pass).length > 0 ? s1.pass : s2.pass;
130
+ return { pass: combinedPass, fail: { ...s1.fail, ...s2.fail } };
126
131
  }
127
132
  if (subs.length === 1) return buildGuardPayloads(subs[0]);
128
133
  }
@@ -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","../../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,G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A,IAAS,WAAW,aAAA,EAAe;AAE5C,MAAA,IAAI,KAAA,CAAM,cAAc,MAAA,EAAW;AACjC,QAAA,OAAA,CAAQ,KAAA,CAAM,IAAI,CAAA,GAAI,KAAA,CAAM,SAAA;AAAA,MAC9B,CAAA,MAAA,IAAW,KAAA,CAAM,IAAA,KAAS,QAAA,EAAU;AAClC,QAAA,OAAA,CAAQ,KAAA,CAAM,IAAI,CAAA,GAAI,CAAA,KAAA,EAAQ,MAAM,IAAI,CAAA,CAAA;AAAA,MAC1C,CAAA,MAAA,IAAW,KAAA,CAAM,IAAA,KAAS,QAAA,EAAU;AAClC,QAAA,OAAA,CAAQ,KAAA,CAAM,IAAI,CAAA,GAAI,CAAA;AAAA,MACxB,CAAA,MAAA,IAAW,KAAA,CAAM,IAAA,KAAS,SAAA,EAAW;AACnC,QAAA,OAAA,CAAQ,KAAA,CAAM,IAAI,CAAA,GAAI,IAAA;AAAA,MACxB,WAAW,KAAA,CAAM,IAAA,KAAS,QAAA,IAAY,KAAA,CAAM,SAAS,KAAA,EAAO;AAQ1D,QAAA,OAAA,CAAQ,KAAA,CAAM,IAAI,CAAA,GAAI,EAAC;AAAA,MACzB,CAAA,MAAO;AACL,QAAA,OAAA,CAAQ,KAAA,CAAM,IAAI,CAAA,GAAI,CAAA,KAAA,EAAQ,MAAM,IAAI,CAAA,CAAA;AAAA,MAC1C;AAAA,IACF;AACA,IAAA,OAAO,OAAA;AAAA,EACT;AAEA,EAAA,OAAO,EAAC;AACV","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 // Agent pure operators used in guards\n if (op === 'agent/is-pinned') {\n const field = extractPayloadFieldRef(guard[1]);\n if (field) return { pass: { [field]: 'mem_test_unpinned' }, fail: { [field]: 'mem_test_pinned' } };\n }\n\n if (op === 'agent/memory-strength') {\n const field = extractPayloadFieldRef(guard[1]);\n if (field) return { pass: { [field]: 'mem_test_id' }, fail: { [field]: 'mem_nonexistent' } };\n }\n\n // Agent operators in comparison contexts (e.g., [\">=\", [\"agent/context-usage\"], 0.85])\n // These don't use @payload, they query agent state directly. Return empty payloads\n // since the guard result depends on agent context, not event payload.\n if (op.startsWith('agent/')) {\n return { pass: {}, fail: {} };\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 (pseudostates) and skip the\n // boot INIT (the runtime auto-fires INIT from the initial state on\n // mount, so the walker doesn't need to fire it). User-triggered INITs\n // from non-initial states (refresh, retry) ARE walkable edges and\n // stay in the graph so coverage can reach them.\n const filtered = transitions.filter(\n (t) => t.from !== '*' && !(t.event === 'INIT' && t.from === initialState),\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 and payload schema.\n * For guarded transitions, uses guard expressions to generate pass/fail payloads.\n * For unguarded transitions with payload schemas (e.g., EDIT/VIEW with { id }),\n * generates mock values so fetch-by-ID effects can resolve entity data.\n */\nfunction buildPayloadForEdge(\n transition: EdgeWalkTransition,\n guardCase: 'pass' | 'fail' | null,\n// eslint-disable-next-line almadar/no-record-string-unknown -- Payloads are dynamically typed per event schema\n): Record<string, unknown> {\n // Guard-based payload generation (existing behavior)\n if (transition.hasGuard && transition.guard && guardCase) {\n const payloads = buildGuardPayloads(transition.guard);\n return guardCase === 'pass' ? payloads.pass : payloads.fail;\n }\n\n // Schema-based payload generation for events that declare required fields\n // (e.g., EDIT/VIEW declare { name: \"id\", type: \"string\", required: true })\n if (transition.payloadSchema && transition.payloadSchema.length > 0) {\n // eslint-disable-next-line almadar/no-record-string-unknown -- Mock payloads are dynamically typed per event schema\n const payload: Record<string, unknown> = {};\n for (const field of transition.payloadSchema) {\n // Use caller-provided mockValue if available (set from entity context)\n if (field.mockValue !== undefined) {\n payload[field.name] = field.mockValue;\n } else if (field.type === 'string') {\n payload[field.name] = `mock-${field.name}`;\n } else if (field.type === 'number') {\n payload[field.name] = 1;\n } else if (field.type === 'boolean') {\n payload[field.name] = true;\n } else if (field.type === 'object' || field.type === 'any') {\n // `mock-<name>` is a plain string; persisting that for an object\n // field (e.g. SAVE's `data: object` carrying a form row) spreads\n // the string's characters across numeric keys server-side and\n // the downstream grid renders blank cards. An empty object is a\n // safer default — callers that need entity-shaped mocks should\n // set `mockValue` at the call site (see orbital-verify-unified's\n // phase4-browser TraitWalkConfig builder).\n payload[field.name] = {};\n } else {\n payload[field.name] = `mock-${field.name}`;\n }\n }\n return payload;\n }\n\n return {};\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,CAA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ph 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 // Bare-binding existence guard: e.g. `when @payload.row` lowers to\n // the string `\"@payload.row\"`. The transition fires iff that field is\n // truthy. Synthesize pass with a truthy mock and fail with null so\n // the verifier can drive both branches. Without this, std-confirmation\n // and std-modal's existence guards (REQUEST/EDIT requiring @payload.row)\n // get empty payloads in both cases — the pass case then fails the\n // server-side guard and the portal observer flags \"slot not mounted\".\n if (typeof guard === 'string') {\n const field = extractPayloadFieldRef(guard);\n if (field) return { pass: { [field]: { id: 'mock-test-id', name: 'mock-test-name' } }, fail: { [field]: null } };\n }\n\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 // Accept BOTH array sub-guards and bare-binding string sub-guards\n // (post-substitution mode-aware guards like\n // `(or (= \"edit\" \"create\") \"@payload.row\")` mix array + string children).\n const subs = guard.slice(1) as unknown[];\n if (subs.length >= 2) {\n const s1 = buildGuardPayloads(subs[0]);\n const s2 = buildGuardPayloads(subs[1]);\n // For OR: pass if EITHER branch passes. Prefer the second branch's\n // pass payload if the first yields nothing useful — the literal-fold\n // case `(= \"edit\" \"create\") || @payload.row` has the first branch\n // return `{}` and the row-payload comes from the second.\n const combinedPass = Object.keys(s1.pass).length > 0 ? s1.pass : s2.pass;\n return { pass: combinedPass, 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 // Agent pure operators used in guards\n if (op === 'agent/is-pinned') {\n const field = extractPayloadFieldRef(guard[1]);\n if (field) return { pass: { [field]: 'mem_test_unpinned' }, fail: { [field]: 'mem_test_pinned' } };\n }\n\n if (op === 'agent/memory-strength') {\n const field = extractPayloadFieldRef(guard[1]);\n if (field) return { pass: { [field]: 'mem_test_id' }, fail: { [field]: 'mem_nonexistent' } };\n }\n\n // Agent operators in comparison contexts (e.g., [\">=\", [\"agent/context-usage\"], 0.85])\n // These don't use @payload, they query agent state directly. Return empty payloads\n // since the guard result depends on agent context, not event payload.\n if (op.startsWith('agent/')) {\n return { pass: {}, fail: {} };\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 (pseudostates) and skip the\n // boot INIT (the runtime auto-fires INIT from the initial state on\n // mount, so the walker doesn't need to fire it). User-triggered INITs\n // from non-initial states (refresh, retry) ARE walkable edges and\n // stay in the graph so coverage can reach them.\n const filtered = transitions.filter(\n (t) => t.from !== '*' && !(t.event === 'INIT' && t.from === initialState),\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 and payload schema.\n * For guarded transitions, uses guard expressions to generate pass/fail payloads.\n * For unguarded transitions with payload schemas (e.g., EDIT/VIEW with { id }),\n * generates mock values so fetch-by-ID effects can resolve entity data.\n */\nfunction buildPayloadForEdge(\n transition: EdgeWalkTransition,\n guardCase: 'pass' | 'fail' | null,\n// eslint-disable-next-line almadar/no-record-string-unknown -- Payloads are dynamically typed per event schema\n): Record<string, unknown> {\n // Guard-based payload generation (existing behavior)\n if (transition.hasGuard && transition.guard && guardCase) {\n const payloads = buildGuardPayloads(transition.guard);\n return guardCase === 'pass' ? payloads.pass : payloads.fail;\n }\n\n // Schema-based payload generation for events that declare required fields\n // (e.g., EDIT/VIEW declare { name: \"id\", type: \"string\", required: true })\n if (transition.payloadSchema && transition.payloadSchema.length > 0) {\n // eslint-disable-next-line almadar/no-record-string-unknown -- Mock payloads are dynamically typed per event schema\n const payload: Record<string, unknown> = {};\n for (const field of transition.payloadSchema) {\n // Use caller-provided mockValue if available (set from entity context)\n if (field.mockValue !== undefined) {\n payload[field.name] = field.mockValue;\n } else if (field.type === 'string') {\n payload[field.name] = `mock-${field.name}`;\n } else if (field.type === 'number') {\n payload[field.name] = 1;\n } else if (field.type === 'boolean') {\n payload[field.name] = true;\n } else if (field.type === 'object' || field.type === 'any') {\n // `mock-<name>` is a plain string; persisting that for an object\n // field (e.g. SAVE's `data: object` carrying a form row) spreads\n // the string's characters across numeric keys server-side and\n // the downstream grid renders blank cards. An empty object is a\n // safer default — callers that need entity-shaped mocks should\n // set `mockValue` at the call site (see orbital-verify-unified's\n // phase4-browser TraitWalkConfig builder).\n payload[field.name] = {};\n } else {\n payload[field.name] = `mock-${field.name}`;\n }\n }\n return payload;\n }\n\n return {};\n}\n"]}