@almadar/core 7.14.3 → 7.16.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,4 +1,4 @@
1
- import { b as EventPayload, S as SExpr } from '../expression-CkBbMSmB.js';
1
+ import { b as EventPayload, S as SExpr } from '../expression-BVRFm0sV.js';
2
2
  import 'zod';
3
3
 
4
4
  /**
@@ -1,7 +1,7 @@
1
- import { c3 as ServiceParams, bh as OrbitalSchema, b2 as Orbital, cE as Trait, a2 as Entity, br as Page, T as DomainContext, ag as EntityRow, aI as FieldValue, G as DeclaredTraitConfig, cH as TraitConfig } from '../schema-CgNnvuCR.js';
2
- export { A as AGENT_DOMAIN_CATEGORIES, a as ALLOWED_CUSTOM_COMPONENTS, b as AgentDomainCategory, c as AgentDomainCategorySchema, d as AgentEffect, e as AllowedCustomComponent, f as AnimationDef, g as AnimationDefInput, h as AnimationDefSchema, i as AssetMap, j as AssetMapInput, k as AssetMapSchema, l as AssetMapping, m as AssetMappingInput, n as AssetMappingSchema, o as AtomicEffect, C as CallServiceConfig, p as CallServiceEffect, q as CheckpointLoadEffect, r as CheckpointSaveEffect, s as ComputedEventContract, t as ComputedEventContractSchema, u as ComputedEventListener, v as ComputedEventListenerSchema, w as ConfigFieldDeclaration, x as ConfigFieldDeclarationSchema, y as CustomPatternDefinition, z as CustomPatternDefinitionInput, B as CustomPatternDefinitionSchema, D as CustomPatternMap, E as CustomPatternMapInput, F as CustomPatternMapSchema, H as DeclaredTraitConfigSchema, I as DerefEffect, J as DesignPreferences, K as DesignPreferencesInput, L as DesignPreferencesSchema, M as DesignTokens, N as DesignTokensInput, O as DesignTokensSchema, P as DespawnEffect, Q as DoEffect, R as DomainCategory, S as DomainCategorySchema, U as DomainContextInput, V as DomainContextSchema, W as DomainVocabulary, X as DomainVocabularySchema, Y as ENTITY_ROLES, Z as Effect, _ as EffectInput, $ as EffectSchema, a0 as EmitConfig, a1 as EmitEffect, a3 as EntityCall, a4 as EntityCallSchema, a5 as EntityData, a6 as EntityField, a7 as EntityFieldInput, a8 as EntityFieldSchema, a9 as EntityPersistence, aa as EntityPersistenceSchema, ab as EntityRef, ac as EntityRefSchema, ad as EntityRefStringSchema, ae as EntityRole, af as EntityRoleSchema, ah as EntitySchema, ai as EntitySemanticRole, aj as EntitySemanticRoleSchema, ak as EvaluateConfig, al as EvaluateEffect, am as Event, an as EventInput, ao as EventListener, ap as EventListenerSchema, aq as EventPayloadField, ar as EventPayloadFieldSchema, as as EventSchema, at as EventScope, au as EventScopeSchema, av as EventSemanticRole, aw as EventSemanticRoleSchema, ax as EventSource, ay as EventSourceSchema, az as FetchEffect, aA as FetchOptions, aB as FetchResult, aC as Field, aD as FieldFormat, aE as FieldFormatSchema, aF as FieldSchema, aG as FieldType, aH as FieldTypeSchema, aJ as ForwardConfig, aK as ForwardEffect, aL as GAME_TYPES, aM as GameSubCategory, aN as GameSubCategorySchema, aO as GameType, aP as GameTypeSchema, aQ as Guard, aR as GuardInput, aS as GuardSchema, aT as ListenSource, aU as ListenSourceSchema, aV as LogEffect, aW as McpServiceDef, aX as McpServiceDefSchema, aY as NavigateEffect, aZ as NnConfig, a_ as NnLayer, a$ as NodeClassification, b0 as NodeClassificationSchema, b1 as NotifyEffect, b3 as OrbitalConfig, b4 as OrbitalConfigInput, b5 as OrbitalConfigSchema, b6 as OrbitalDefinition, b7 as OrbitalDefinitionSchema, b8 as OrbitalEntity, b9 as OrbitalEntityInput, ba as OrbitalEntitySchema, bb as OrbitalInput, bc as OrbitalPage, bd as OrbitalPageInput, be as OrbitalPageSchema, bf as OrbitalPageStrictInput, bg as OrbitalPageStrictSchema, bj as OrbitalSchemaInput, bk as OrbitalSchemaSchema, bl as OrbitalSchemaWithTraits, bm as OrbitalTraitRef, bn as OrbitalTraitRefSchema, bo as OrbitalUnit, bp as OrbitalUnitSchema, bi as OrbitalZodSchema, bq as OsEffect, bs as PageRef, bt as PageRefObject, bu as PageRefObjectSchema, bv as PageRefSchema, bw as PageRefStringSchema, bx as PageSchema, by as PageTraitRef, bz as PageTraitRefSchema, bA as PayloadField, bB as PayloadFieldSchema, bC as PersistData, bD as PersistEffect, bE as PersistEmitConfig, bF as PresentationType, bG as RefEffect, bH as RelatedLink, bI as RelatedLinkSchema, bJ as RelationConfig, bK as RelationConfigSchema, bL as RenderItemLambda, bM as RenderUIConfig, bN as RenderUIEffect, bO as RenderUINode, bP as RequiredField, bQ as RequiredFieldSchema, bR as ResolvedAsset, bS as ResolvedAssetInput, bT as ResolvedAssetSchema, bU as ResolvedPatternProps, bV as RestAuthConfig, bW as RestAuthConfigSchema, bX as RestServiceDef, bY as RestServiceDefSchema, bZ as SERVICE_TYPES, b_ as SemanticAssetRef, b$ as SemanticAssetRefInput, c0 as SemanticAssetRefSchema, c1 as ServiceDefinition, c2 as ServiceDefinitionSchema, c4 as ServiceParamsValue, c5 as ServiceRef, c6 as ServiceRefObject, c7 as ServiceRefObjectSchema, c8 as ServiceRefSchema, c9 as ServiceRefStringSchema, ca as ServiceType, cb as ServiceTypeSchema, cc as SetEffect, cd as SocketEvents, ce as SocketEventsSchema, cf as SocketServiceDef, cg as SocketServiceDefSchema, ch as SpawnEffect, ci as State, cj as StateInput, ck as StateMachine, cl as StateMachineInput, cm as StateMachineSchema, cn as StateSchema, co as StateSemanticRole, cp as StateSemanticRoleSchema, cq as SuggestedGuard, cr as SuggestedGuardSchema, cs as SwapEffect, ct as ThemeDefinition, cu as ThemeDefinitionSchema, cv as ThemeRef, cw as ThemeRefSchema, cx as ThemeRefStringSchema, cy as ThemeTokens, cz as ThemeTokensSchema, cA as ThemeVariant, cB as ThemeVariantSchema, cC as TrainConfig, cD as TrainEffect, cF as TraitCategory, cG as TraitCategorySchema, cI as TraitConfigObject, cJ as TraitConfigSchema, cK as TraitConfigValue, cL as TraitConfigValueSchema, cM as TraitDataEntity, cN as TraitDataEntitySchema, cO as TraitEntityField, cP as TraitEntityFieldSchema, cQ as TraitEventContract, cR as TraitEventContractSchema, cS as TraitEventListener, cT as TraitEventListenerSchema, cU as TraitInput, cV as TraitRef, cW as TraitRefSchema, cX as TraitReference, cY as TraitReferenceInput, cZ as TraitReferenceSchema, c_ as TraitSchema, c$ as TraitTick, d0 as TraitTickSchema, d1 as TraitUIBinding, d2 as Transition, d3 as TransitionInput, d4 as TransitionSchema, d5 as TypedEffect, d6 as UISlot, d7 as UISlotSchema, d8 as UI_SLOTS, d9 as UXHints, da as UXHintsSchema, db as UseDeclaration, dc as UseDeclarationSchema, dd as UserPersona, de as UserPersonaInput, df as UserPersonaSchema, dg as VISUAL_STYLES, dh as ViewType, di as ViewTypeSchema, dj as VisualStyle, dk as VisualStyleSchema, dl as WatchEffect, dm as WatchOptions, dn as atomic, dp as callService, dq as createAssetKey, dr as deref, ds as deriveCollection, dt as despawn, du as doEffects, dv as emit, dw as findService, dx as getDefaultAnimationsForRole, dy as getServiceNames, dz as getTraitConfig, dA as getTraitName, dB as hasService, dC as isCircuitEvent, dD as isEffect, dE as isEntityCall, dF as isEntityReference, dG as isEntityReferenceAny, dH as isImportedTraitRef, dI as isInlineTrait, dJ as isMcpService, dK as isOrbitalDefinition, dL as isPageReference, dM as isPageReferenceObject, dN as isPageReferenceString, dO as isRestService, dP as isRuntimeEntity, dQ as isSExprEffect, dR as isServiceReference, dS as isServiceReferenceObject, dT as isSingletonEntity, dU as isSocketService, dV as isThemeReference, dW as navigate, dX as normalizeTraitRef, dY as notify, dZ as parseAssetKey, d_ as parseEntityRef, d$ as parseImportedTraitRef, e0 as parseOrbitalSchema, e1 as parsePageRef, e2 as parseServiceRef, e3 as persist, e4 as ref, e5 as renderUI, e6 as safeParseOrbitalSchema, e7 as set, e8 as spawn, e9 as swap, ea as validateAssetAnimations, eb as watch } from '../schema-CgNnvuCR.js';
3
- import { c as EventPayloadValue, b as EventPayload, L as LogMeta, S as SExpr } from '../expression-CkBbMSmB.js';
4
- export { C as CORE_BINDINGS, a as CoreBinding, E as EvalContext, d as Expression, e as ExpressionInput, f as ExpressionSchema, P as ParsedBinding, g as SExprAtom, h as SExprAtomSchema, i as SExprInput, j as SExprSchema, k as collectBindings, l as getArgs, m as getOperator, n as isBinding, o as isSExpr, p as isSExprAtom, q as isSExprCall, r as isValidBinding, s as parseBinding, t as sexpr, w as walkSExpr } from '../expression-CkBbMSmB.js';
1
+ import { c3 as ServiceParams, bh as OrbitalSchema, b2 as Orbital, cE as Trait, a2 as Entity, br as Page, T as DomainContext, ag as EntityRow, aI as FieldValue, G as DeclaredTraitConfig, cH as TraitConfig } from '../schema-DJzXvJHi.js';
2
+ export { A as AGENT_DOMAIN_CATEGORIES, a as ALLOWED_CUSTOM_COMPONENTS, b as AgentDomainCategory, c as AgentDomainCategorySchema, d as AgentEffect, e as AllowedCustomComponent, f as AnimationDef, g as AnimationDefInput, h as AnimationDefSchema, i as AssetMap, j as AssetMapInput, k as AssetMapSchema, l as AssetMapping, m as AssetMappingInput, n as AssetMappingSchema, o as AtomicEffect, C as CallServiceConfig, p as CallServiceEffect, q as CheckpointLoadEffect, r as CheckpointSaveEffect, s as ComputedEventContract, t as ComputedEventContractSchema, u as ComputedEventListener, v as ComputedEventListenerSchema, w as ConfigFieldDeclaration, x as ConfigFieldDeclarationSchema, y as CustomPatternDefinition, z as CustomPatternDefinitionInput, B as CustomPatternDefinitionSchema, D as CustomPatternMap, E as CustomPatternMapInput, F as CustomPatternMapSchema, H as DeclaredTraitConfigSchema, I as DerefEffect, J as DesignPreferences, K as DesignPreferencesInput, L as DesignPreferencesSchema, M as DesignTokens, N as DesignTokensInput, O as DesignTokensSchema, P as DespawnEffect, Q as DoEffect, R as DomainCategory, S as DomainCategorySchema, U as DomainContextInput, V as DomainContextSchema, W as DomainVocabulary, X as DomainVocabularySchema, Y as ENTITY_ROLES, Z as Effect, _ as EffectInput, $ as EffectSchema, a0 as EmitConfig, a1 as EmitEffect, a3 as EntityCall, a4 as EntityCallSchema, a5 as EntityData, a6 as EntityField, a7 as EntityFieldInput, a8 as EntityFieldSchema, a9 as EntityPersistence, aa as EntityPersistenceSchema, ab as EntityRef, ac as EntityRefSchema, ad as EntityRefStringSchema, ae as EntityRole, af as EntityRoleSchema, ah as EntitySchema, ai as EntitySemanticRole, aj as EntitySemanticRoleSchema, ak as EvaluateConfig, al as EvaluateEffect, am as Event, an as EventInput, ao as EventListener, ap as EventListenerSchema, aq as EventPayloadField, ar as EventPayloadFieldSchema, as as EventSchema, at as EventScope, au as EventScopeSchema, av as EventSemanticRole, aw as EventSemanticRoleSchema, ax as EventSource, ay as EventSourceSchema, az as FetchEffect, aA as FetchOptions, aB as FetchResult, aC as Field, aD as FieldFormat, aE as FieldFormatSchema, aF as FieldSchema, aG as FieldType, aH as FieldTypeSchema, aJ as ForwardConfig, aK as ForwardEffect, aL as GAME_TYPES, aM as GameSubCategory, aN as GameSubCategorySchema, aO as GameType, aP as GameTypeSchema, aQ as Guard, aR as GuardInput, aS as GuardSchema, aT as ListenSource, aU as ListenSourceSchema, aV as LogEffect, aW as McpServiceDef, aX as McpServiceDefSchema, aY as NavigateEffect, aZ as NnConfig, a_ as NnLayer, a$ as NodeClassification, b0 as NodeClassificationSchema, b1 as NotifyEffect, b3 as OrbitalConfig, b4 as OrbitalConfigInput, b5 as OrbitalConfigSchema, b6 as OrbitalDefinition, b7 as OrbitalDefinitionSchema, b8 as OrbitalEntity, b9 as OrbitalEntityInput, ba as OrbitalEntitySchema, bb as OrbitalInput, bc as OrbitalPage, bd as OrbitalPageInput, be as OrbitalPageSchema, bf as OrbitalPageStrictInput, bg as OrbitalPageStrictSchema, bj as OrbitalSchemaInput, bk as OrbitalSchemaSchema, bl as OrbitalSchemaWithTraits, bm as OrbitalTraitRef, bn as OrbitalTraitRefSchema, bo as OrbitalUnit, bp as OrbitalUnitSchema, bi as OrbitalZodSchema, bq as OsEffect, bs as PageRef, bt as PageRefObject, bu as PageRefObjectSchema, bv as PageRefSchema, bw as PageRefStringSchema, bx as PageSchema, by as PageTraitRef, bz as PageTraitRefSchema, bA as PayloadField, bB as PayloadFieldSchema, bC as PersistData, bD as PersistEffect, bE as PersistEmitConfig, bF as PresentationType, bG as RefEffect, bH as RelatedLink, bI as RelatedLinkSchema, bJ as RelationConfig, bK as RelationConfigSchema, bL as RenderItemLambda, bM as RenderUIConfig, bN as RenderUIEffect, bO as RenderUINode, bP as RequiredField, bQ as RequiredFieldSchema, bR as ResolvedAsset, bS as ResolvedAssetInput, bT as ResolvedAssetSchema, bU as ResolvedPatternProps, bV as RestAuthConfig, bW as RestAuthConfigSchema, bX as RestServiceDef, bY as RestServiceDefSchema, bZ as SERVICE_TYPES, b_ as SemanticAssetRef, b$ as SemanticAssetRefInput, c0 as SemanticAssetRefSchema, c1 as ServiceDefinition, c2 as ServiceDefinitionSchema, c4 as ServiceParamsValue, c5 as ServiceRef, c6 as ServiceRefObject, c7 as ServiceRefObjectSchema, c8 as ServiceRefSchema, c9 as ServiceRefStringSchema, ca as ServiceType, cb as ServiceTypeSchema, cc as SetEffect, cd as SocketEvents, ce as SocketEventsSchema, cf as SocketServiceDef, cg as SocketServiceDefSchema, ch as SpawnEffect, ci as State, cj as StateInput, ck as StateMachine, cl as StateMachineInput, cm as StateMachineSchema, cn as StateSchema, co as StateSemanticRole, cp as StateSemanticRoleSchema, cq as SuggestedGuard, cr as SuggestedGuardSchema, cs as SwapEffect, ct as ThemeDefinition, cu as ThemeDefinitionSchema, cv as ThemeRef, cw as ThemeRefSchema, cx as ThemeRefStringSchema, cy as ThemeTokens, cz as ThemeTokensSchema, cA as ThemeVariant, cB as ThemeVariantSchema, cC as TrainConfig, cD as TrainEffect, cF as TraitCategory, cG as TraitCategorySchema, cI as TraitConfigObject, cJ as TraitConfigSchema, cK as TraitConfigValue, cL as TraitConfigValueSchema, cM as TraitDataEntity, cN as TraitDataEntitySchema, cO as TraitEntityField, cP as TraitEntityFieldSchema, cQ as TraitEventContract, cR as TraitEventContractSchema, cS as TraitEventListener, cT as TraitEventListenerSchema, cU as TraitInput, cV as TraitRef, cW as TraitRefSchema, cX as TraitReference, cY as TraitReferenceInput, cZ as TraitReferenceSchema, c_ as TraitSchema, c$ as TraitTick, d0 as TraitTickSchema, d1 as TraitUIBinding, d2 as Transition, d3 as TransitionInput, d4 as TransitionSchema, d5 as TypedEffect, d6 as UISlot, d7 as UISlotSchema, d8 as UI_SLOTS, d9 as UXHints, da as UXHintsSchema, db as UseDeclaration, dc as UseDeclarationSchema, dd as UserPersona, de as UserPersonaInput, df as UserPersonaSchema, dg as VISUAL_STYLES, dh as ViewType, di as ViewTypeSchema, dj as VisualStyle, dk as VisualStyleSchema, dl as WatchEffect, dm as WatchOptions, dn as atomic, dp as callService, dq as createAssetKey, dr as deref, ds as deriveCollection, dt as despawn, du as doEffects, dv as emit, dw as findService, dx as getDefaultAnimationsForRole, dy as getServiceNames, dz as getTraitConfig, dA as getTraitName, dB as hasService, dC as isCircuitEvent, dD as isEffect, dE as isEntityCall, dF as isEntityReference, dG as isEntityReferenceAny, dH as isImportedTraitRef, dI as isInlineTrait, dJ as isMcpService, dK as isOrbitalDefinition, dL as isPageReference, dM as isPageReferenceObject, dN as isPageReferenceString, dO as isRestService, dP as isRuntimeEntity, dQ as isSExprEffect, dR as isServiceReference, dS as isServiceReferenceObject, dT as isSingletonEntity, dU as isSocketService, dV as isThemeReference, dW as navigate, dX as normalizeTraitRef, dY as notify, dZ as parseAssetKey, d_ as parseEntityRef, d$ as parseImportedTraitRef, e0 as parseOrbitalSchema, e1 as parsePageRef, e2 as parseServiceRef, e3 as persist, e4 as ref, e5 as renderUI, e6 as safeParseOrbitalSchema, e7 as set, e8 as spawn, e9 as swap, ea as validateAssetAnimations, eb as watch } from '../schema-DJzXvJHi.js';
3
+ import { c as EventPayloadValue, b as EventPayload, L as LogMeta, S as SExpr } from '../expression-BVRFm0sV.js';
4
+ export { C as CORE_BINDINGS, a as CoreBinding, E as EvalContext, d as Expression, e as ExpressionInput, f as ExpressionSchema, P as ParsedBinding, g as SExprAtom, h as SExprAtomSchema, i as SExprInput, j as SExprSchema, k as collectBindings, l as getArgs, m as getOperator, n as isBinding, o as isSExpr, p as isSExprAtom, q as isSExprCall, r as isValidBinding, s as parseBinding, t as sexpr, w as walkSExpr } from '../expression-BVRFm0sV.js';
5
5
  import { z } from 'zod';
6
6
  import { AnyPatternConfig } from '@almadar/patterns';
7
7
  export { PATTERN_TYPES, PatternConfig, PatternType, isValidPatternType } from '@almadar/patterns';
@@ -70,22 +70,27 @@ declare const BINDING_DOCS: {
70
70
  readonly examples: readonly ["@trait.name", "@trait.category"];
71
71
  readonly requiresPath: true;
72
72
  };
73
+ readonly user: {
74
+ readonly description: "Authenticated user / agent context for ownership and role-based gating";
75
+ readonly examples: readonly ["@user.id", "@user.role"];
76
+ readonly requiresPath: true;
77
+ };
73
78
  };
74
79
  /**
75
80
  * Validation rules for bindings in different contexts.
76
81
  */
77
82
  declare const BINDING_CONTEXT_RULES: {
78
83
  readonly guard: {
79
- readonly allowed: readonly ["entity", "payload", "state", "now", "config"];
80
- readonly description: "Guards can access entity fields, event payload, current state, time, and the call-site trait config (@config.X). Config access lets atoms write mode-aware guards — e.g. std-modal's OPEN can require @payload.row only when @config.mode equals \"edit\", letting create-mode legitimately fire OPEN with no row. Like effects, @config.X is substituted at molecule/organism inline time with the literal call-site value; at atom-scope validate, @config is allowed-but-unresolved.";
84
+ readonly allowed: readonly ["entity", "payload", "state", "now", "config", "user"];
85
+ readonly description: "Guards can access entity fields, event payload, current state, time, the call-site trait config (@config.X), and the authenticated user context (@user.id, @user.role) for ownership / role gates. Config access lets atoms write mode-aware guards — e.g. std-modal's OPEN can require @payload.row only when @config.mode equals \"edit\", letting create-mode legitimately fire OPEN with no row. Like effects, @config.X is substituted at molecule/organism inline time with the literal call-site value; at atom-scope validate, @config is allowed-but-unresolved.";
81
86
  };
82
87
  readonly effect: {
83
- readonly allowed: readonly ["entity", "payload", "state", "now", "trait", "config"];
84
- readonly description: "Effects can access and modify entity fields, use payload data, embed another trait's live frame via @trait.X inside render-ui children, and read trait config values (@config.X) for atoms parameterized by their call-site. At molecule/organism inline time, @config.X is substituted with the literal value from the call-site config block; at atom-scope validate, @config is allowed-but-unresolved.";
88
+ readonly allowed: readonly ["entity", "payload", "state", "now", "trait", "config", "user"];
89
+ readonly description: "Effects can access and modify entity fields, use payload data, embed another trait's live frame via @trait.X inside render-ui children, read trait config values (@config.X) for atoms parameterized by their call-site, and read the authenticated user context (@user.id, @user.role). At molecule/organism inline time, @config.X is substituted with the literal value from the call-site config block; at atom-scope validate, @config is allowed-but-unresolved.";
85
90
  };
86
91
  readonly tick: {
87
- readonly allowed: readonly ["entity", "state", "now", "config"];
88
- readonly description: "Ticks can access entity fields, current state, time, and trait config (@config.X) for parameterized atoms. Same substitution semantics as guards/effects.";
92
+ readonly allowed: readonly ["entity", "state", "now", "config", "user"];
93
+ readonly description: "Ticks can access entity fields, current state, time, trait config (@config.X) for parameterized atoms, and the authenticated user context (@user.id, @user.role). Same substitution semantics as guards/effects.";
89
94
  };
90
95
  };
91
96
  type BindingContext = keyof typeof BINDING_CONTEXT_RULES;
@@ -358,7 +358,7 @@ function isBinding(value) {
358
358
  function isSExprCall(value) {
359
359
  return isSExpr(value);
360
360
  }
361
- var CORE_BINDINGS = ["entity", "payload", "state", "now", "config", "computed", "trait"];
361
+ var CORE_BINDINGS = ["entity", "payload", "state", "now", "config", "computed", "trait", "user"];
362
362
  function parseBinding(binding) {
363
363
  if (!binding.startsWith("@")) {
364
364
  return null;
@@ -635,6 +635,11 @@ var TraitReferenceSchema = z.object({
635
635
  }
636
636
  );
637
637
  var TraitScopeSchema = z.enum(["instance", "collection"]);
638
+ var SourceBehaviorMetadataSchema = z.object({
639
+ behavior: z.string().min(1),
640
+ alias: z.string().min(1),
641
+ originalName: z.string().min(1)
642
+ });
638
643
  var TraitSchema = z.object({
639
644
  name: z.string().min(1),
640
645
  description: z.string().optional(),
@@ -650,7 +655,9 @@ var TraitSchema = z.object({
650
655
  emits: z.array(TraitEventContractSchema).optional(),
651
656
  listens: z.array(TraitEventListenerSchema).optional(),
652
657
  ui: z.record(z.unknown()).optional(),
653
- config: DeclaredTraitConfigSchema.optional()
658
+ config: DeclaredTraitConfigSchema.optional(),
659
+ sourceBehavior: SourceBehaviorMetadataSchema.optional(),
660
+ sourceEntityDefinition: EntitySchema.optional()
654
661
  });
655
662
  var TraitRefSchema = z.union([
656
663
  z.string().min(1),
@@ -1233,20 +1240,25 @@ var BINDING_DOCS = {
1233
1240
  description: "Trait context data",
1234
1241
  examples: ["@trait.name", "@trait.category"],
1235
1242
  requiresPath: true
1243
+ },
1244
+ user: {
1245
+ description: "Authenticated user / agent context for ownership and role-based gating",
1246
+ examples: ["@user.id", "@user.role"],
1247
+ requiresPath: true
1236
1248
  }
1237
1249
  };
1238
1250
  var BINDING_CONTEXT_RULES = {
1239
1251
  guard: {
1240
- allowed: ["entity", "payload", "state", "now", "config"],
1241
- description: `Guards can access entity fields, event payload, current state, time, and the call-site trait config (@config.X). Config access lets atoms write mode-aware guards \u2014 e.g. std-modal's OPEN can require @payload.row only when @config.mode equals "edit", letting create-mode legitimately fire OPEN with no row. Like effects, @config.X is substituted at molecule/organism inline time with the literal call-site value; at atom-scope validate, @config is allowed-but-unresolved.`
1252
+ allowed: ["entity", "payload", "state", "now", "config", "user"],
1253
+ description: `Guards can access entity fields, event payload, current state, time, the call-site trait config (@config.X), and the authenticated user context (@user.id, @user.role) for ownership / role gates. Config access lets atoms write mode-aware guards \u2014 e.g. std-modal's OPEN can require @payload.row only when @config.mode equals "edit", letting create-mode legitimately fire OPEN with no row. Like effects, @config.X is substituted at molecule/organism inline time with the literal call-site value; at atom-scope validate, @config is allowed-but-unresolved.`
1242
1254
  },
1243
1255
  effect: {
1244
- allowed: ["entity", "payload", "state", "now", "trait", "config"],
1245
- description: "Effects can access and modify entity fields, use payload data, embed another trait's live frame via @trait.X inside render-ui children, and read trait config values (@config.X) for atoms parameterized by their call-site. At molecule/organism inline time, @config.X is substituted with the literal value from the call-site config block; at atom-scope validate, @config is allowed-but-unresolved."
1256
+ allowed: ["entity", "payload", "state", "now", "trait", "config", "user"],
1257
+ description: "Effects can access and modify entity fields, use payload data, embed another trait's live frame via @trait.X inside render-ui children, read trait config values (@config.X) for atoms parameterized by their call-site, and read the authenticated user context (@user.id, @user.role). At molecule/organism inline time, @config.X is substituted with the literal value from the call-site config block; at atom-scope validate, @config is allowed-but-unresolved."
1246
1258
  },
1247
1259
  tick: {
1248
- allowed: ["entity", "state", "now", "config"],
1249
- description: "Ticks can access entity fields, current state, time, and trait config (@config.X) for parameterized atoms. Same substitution semantics as guards/effects."
1260
+ allowed: ["entity", "state", "now", "config", "user"],
1261
+ description: "Ticks can access entity fields, current state, time, trait config (@config.X) for parameterized atoms, and the authenticated user context (@user.id, @user.role). Same substitution semantics as guards/effects."
1250
1262
  }
1251
1263
  };
1252
1264
  function validateBindingInContext(binding, context) {