@almadar/core 10.28.0 → 10.30.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,6 +1,151 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  // src/types/orbital.ts
4
+ var ID_PREFIXES = {
5
+ orbital: "orb_",
6
+ entity: "ent_",
7
+ trait: "trt_",
8
+ event: "evt_",
9
+ page: "pag_",
10
+ service: "svc_",
11
+ theme: "thm_",
12
+ palette: "pal_"
13
+ };
14
+ function brand(value) {
15
+ return value;
16
+ }
17
+ function makeIdKind(kind) {
18
+ const prefix = ID_PREFIXES[kind];
19
+ const is = (value) => value.startsWith(prefix) && value.length > prefix.length;
20
+ const as = (value) => {
21
+ if (!is(value)) {
22
+ throw new Error(
23
+ `Expected ${kind} id (prefix "${prefix}"), got: ${JSON.stringify(value)}`
24
+ );
25
+ }
26
+ return brand(value);
27
+ };
28
+ return { prefix, is, as };
29
+ }
30
+ var orbitalKind = makeIdKind("orbital");
31
+ var entityKind = makeIdKind("entity");
32
+ var traitKind = makeIdKind("trait");
33
+ var eventKind = makeIdKind("event");
34
+ var pageKind = makeIdKind("page");
35
+ var serviceKind = makeIdKind("service");
36
+ var themeKind = makeIdKind("theme");
37
+ var paletteKind = makeIdKind("palette");
38
+ var isOrbitalId = orbitalKind.is;
39
+ var asOrbitalId = orbitalKind.as;
40
+ var isEntityId = entityKind.is;
41
+ var asEntityId = entityKind.as;
42
+ var isTraitId = traitKind.is;
43
+ var asTraitId = traitKind.as;
44
+ var isEventId = eventKind.is;
45
+ var asEventId = eventKind.as;
46
+ var isPageId = pageKind.is;
47
+ var asPageId = pageKind.as;
48
+ var isServiceId = serviceKind.is;
49
+ var asServiceId = serviceKind.as;
50
+ var isThemeId = themeKind.is;
51
+ var asThemeId = themeKind.as;
52
+ var isPaletteEntryId = paletteKind.is;
53
+ var asPaletteEntryId = paletteKind.as;
54
+ function idPrefix(kind) {
55
+ return ID_PREFIXES[kind];
56
+ }
57
+ function idKindOf(id) {
58
+ for (const kind of Object.keys(ID_PREFIXES)) {
59
+ const prefix = ID_PREFIXES[kind];
60
+ if (id.startsWith(prefix) && id.length > prefix.length) return kind;
61
+ }
62
+ return null;
63
+ }
64
+ var CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
65
+ var TIME_LEN = 10;
66
+ var RANDOM_LEN = 16;
67
+ function randomBytes(len) {
68
+ const g = globalThis;
69
+ if (g.crypto?.getRandomValues) {
70
+ return g.crypto.getRandomValues(new Uint8Array(len));
71
+ }
72
+ throw new Error("mintId: no crypto.getRandomValues available in this runtime");
73
+ }
74
+ function encodeTime(now) {
75
+ let value = now;
76
+ let out = "";
77
+ for (let i = 0; i < TIME_LEN; i++) {
78
+ const mod = value % 32;
79
+ out = CROCKFORD[mod] + out;
80
+ value = (value - mod) / 32;
81
+ }
82
+ return out;
83
+ }
84
+ function encodeRandom() {
85
+ const bytes = randomBytes(RANDOM_LEN);
86
+ let out = "";
87
+ for (let i = 0; i < RANDOM_LEN; i++) {
88
+ out += CROCKFORD[bytes[i] & 31];
89
+ }
90
+ return out;
91
+ }
92
+ function ulid() {
93
+ return encodeTime(Date.now()) + encodeRandom();
94
+ }
95
+ function mintId(kind) {
96
+ return brand(ID_PREFIXES[kind] + ulid());
97
+ }
98
+ function ledgerResolveName(ledger, kind, name) {
99
+ for (const [id, entry] of Object.entries(ledger.entries)) {
100
+ if (entry.kind === kind && entry.curName === name) return id;
101
+ }
102
+ return null;
103
+ }
104
+ function ledgerRename(ledger, id, to, at) {
105
+ const entry = ledger.entries[id];
106
+ if (entry === void 0) return ledger;
107
+ const updated = {
108
+ ...entry,
109
+ curName: to,
110
+ renames: [...entry.renames, { from: entry.curName, to, at }]
111
+ };
112
+ return { ...ledger, entries: { ...ledger.entries, [id]: updated } };
113
+ }
114
+ function ledgerCurName(ledger, id) {
115
+ return ledger.entries[id]?.curName ?? null;
116
+ }
117
+ var OrbitalIdSchema = z.string().refine(isOrbitalId, { message: `Expected an orbital id (prefix "${ID_PREFIXES.orbital}")` });
118
+ var EntityIdSchema = z.string().refine(isEntityId, { message: `Expected an entity id (prefix "${ID_PREFIXES.entity}")` });
119
+ var TraitIdSchema = z.string().refine(isTraitId, { message: `Expected a trait id (prefix "${ID_PREFIXES.trait}")` });
120
+ var EventIdSchema = z.string().refine(isEventId, { message: `Expected an event id (prefix "${ID_PREFIXES.event}")` });
121
+ var PageIdSchema = z.string().refine(isPageId, { message: `Expected a page id (prefix "${ID_PREFIXES.page}")` });
122
+ var ServiceIdSchema = z.string().refine(isServiceId, { message: `Expected a service id (prefix "${ID_PREFIXES.service}")` });
123
+ var ThemeIdSchema = z.string().refine(isThemeId, { message: `Expected a theme id (prefix "${ID_PREFIXES.theme}")` });
124
+ var PaletteEntryIdSchema = z.string().refine(isPaletteEntryId, { message: `Expected a palette-entry id (prefix "${ID_PREFIXES.palette}")` });
125
+ var LedgerKindSchema = z.enum([
126
+ "orbital",
127
+ "entity",
128
+ "trait",
129
+ "event",
130
+ "page",
131
+ "service",
132
+ "theme"
133
+ ]);
134
+ var LedgerEntrySchema = z.object({
135
+ id: z.string(),
136
+ kind: LedgerKindSchema,
137
+ bakedName: z.string(),
138
+ curName: z.string(),
139
+ renames: z.array(
140
+ z.object({ from: z.string(), to: z.string(), at: z.string() })
141
+ ),
142
+ owner: z.enum(["std", "io", "workspace"]),
143
+ parent: TraitIdSchema.optional()
144
+ });
145
+ var IdentityLedgerSchema = z.object({
146
+ schemaVersion: z.literal(1),
147
+ entries: z.record(LedgerEntrySchema)
148
+ });
4
149
  var FieldTypeSchema = z.enum([
5
150
  "string",
6
151
  "number",
@@ -25,6 +170,7 @@ var RelationCardinalitySchema = z.enum([
25
170
  ]);
26
171
  var RelationConfigSchema = z.object({
27
172
  entity: z.string().min(1, "Target entity is required"),
173
+ entityId: EntityIdSchema.optional(),
28
174
  field: z.string().optional(),
29
175
  cardinality: RelationCardinalitySchema.optional(),
30
176
  onDelete: z.enum(["cascade", "nullify", "restrict"]).optional(),
@@ -35,6 +181,7 @@ var RelationConfigSchema = z.object({
35
181
  }).transform((data) => {
36
182
  const normalized = {
37
183
  entity: data.entity || data.target || "",
184
+ entityId: data.entityId,
38
185
  cardinality: data.cardinality || data.type,
39
186
  field: data.field,
40
187
  onDelete: data.onDelete
@@ -437,7 +584,7 @@ function isBinding(value) {
437
584
  function isSExprCall(value) {
438
585
  return isSExpr(value);
439
586
  }
440
- var CORE_BINDINGS = ["entity", "payload", "state", "now", "config", "computed", "trait", "user"];
587
+ var CORE_BINDINGS = ["entity", "payload", "state", "now", "config", "computed", "trait", "user", "callsitePayload"];
441
588
  function parseBinding(binding) {
442
589
  if (!binding.startsWith("@")) {
443
590
  return null;
@@ -521,10 +668,12 @@ var StateSchema = z.object({
521
668
  var PayloadFieldSchema = z.object({
522
669
  name: z.string().min(1),
523
670
  type: z.string().min(1),
524
- required: z.boolean().optional()
671
+ required: z.boolean().optional(),
672
+ properties: z.lazy(() => z.array(PayloadFieldSchema)).optional()
525
673
  });
526
674
  var EventSchema = z.object({
527
675
  key: z.string().min(1, "Event key is required"),
676
+ id: EventIdSchema.optional(),
528
677
  name: z.string().min(1, "Event name is required"),
529
678
  description: z.string().optional(),
530
679
  synonyms: z.string().optional(),
@@ -542,6 +691,7 @@ var TransitionSchema = z.object({
542
691
  from: z.string().min(1, "Transition source state is required"),
543
692
  to: z.string().min(1, "Transition target state is required"),
544
693
  event: z.string().min(1, "Transition event is required"),
694
+ eventId: EventIdSchema.optional(),
545
695
  guard: ExpressionSchema.nullish(),
546
696
  effects: z.array(EffectSchema).optional(),
547
697
  description: z.string().nullish()
@@ -571,14 +721,50 @@ var TraitConfigSchema = z.record(TraitConfigValueSchema);
571
721
  function isCallSiteConfigDeclaration(entry) {
572
722
  return typeof entry === "object" && entry !== null && !Array.isArray(entry) && "type" in entry && typeof entry.type === "string" && "default" in entry;
573
723
  }
724
+ var CONFIG_DECLARATION_META_KEYS = ["label", "description", "tier", "synonyms", "values"];
725
+ function isConfigFieldSchema(entry) {
726
+ if (typeof entry !== "object" || entry === null || Array.isArray(entry)) return false;
727
+ if (!("type" in entry) || typeof entry.type !== "string") return false;
728
+ return "default" in entry || CONFIG_DECLARATION_META_KEYS.some((k) => k in entry);
729
+ }
730
+ function normalizeCallSiteConfigToValues(config) {
731
+ if (config === void 0) {
732
+ return void 0;
733
+ }
734
+ const out = {};
735
+ let hasAny = false;
736
+ for (const [key, entry] of Object.entries(config)) {
737
+ const value = isConfigFieldSchema(entry) ? entry.default : entry;
738
+ if (value !== void 0) {
739
+ out[key] = value;
740
+ hasAny = true;
741
+ }
742
+ }
743
+ return hasAny ? out : void 0;
744
+ }
745
+ var REFERENCE_CONFIG_TYPES = ["entity", "trait", "event"];
746
+ function isReferenceConfigType(type) {
747
+ return REFERENCE_CONFIG_TYPES.includes(type);
748
+ }
749
+ var ConfigFieldItemsDeclarationSchema = z.lazy(
750
+ () => z.object({
751
+ type: z.string().optional(),
752
+ properties: z.record(TraitEntityFieldSchema).optional(),
753
+ items: ConfigFieldItemsDeclarationSchema.optional()
754
+ })
755
+ );
574
756
  var ConfigFieldDeclarationSchema = z.object({
575
757
  type: z.string(),
576
758
  default: TraitConfigValueSchema.optional(),
759
+ refId: z.string().optional(),
760
+ required: z.boolean().optional(),
577
761
  label: z.string().optional(),
578
762
  description: z.string().optional(),
579
763
  tier: z.string().optional(),
580
764
  values: z.array(z.string()).optional(),
581
- synonyms: z.string().optional()
765
+ synonyms: z.string().optional(),
766
+ items: ConfigFieldItemsDeclarationSchema.optional(),
767
+ properties: z.lazy(() => z.record(TraitEntityFieldSchema)).optional()
582
768
  });
583
769
  var DeclaredTraitConfigSchema = z.record(
584
770
  ConfigFieldDeclarationSchema
@@ -615,7 +801,9 @@ var TraitEntityFieldSchema = z.object({
615
801
  ]),
616
802
  required: z.boolean().optional(),
617
803
  default: z.unknown().optional(),
618
- values: z.array(z.string()).optional()
804
+ values: z.array(z.string()).optional(),
805
+ items: ConfigFieldItemsDeclarationSchema.optional(),
806
+ properties: z.lazy(() => z.record(TraitEntityFieldSchema)).optional()
619
807
  });
620
808
  var TraitDataEntitySchema = z.object({
621
809
  name: z.string().min(1),
@@ -634,9 +822,11 @@ var TraitTickSchema = z.object({
634
822
  interval: z.union([z.literal("frame"), z.number().positive()]),
635
823
  appliesTo: z.array(z.string()).optional(),
636
824
  pages: z.array(z.string()).optional(),
825
+ pageIds: z.array(PageIdSchema).optional(),
637
826
  guard: ExpressionSchema.optional(),
638
827
  effects: z.array(EffectSchema).min(1),
639
- emits: z.array(z.string()).optional()
828
+ emits: z.array(z.string()).optional(),
829
+ emitIds: z.array(EventIdSchema).optional()
640
830
  });
641
831
  var EventScopeSchema = z.enum(["internal", "external"]);
642
832
  var EventPayloadFieldSchema = z.object({
@@ -654,20 +844,39 @@ var EventPayloadFieldSchema = z.object({
654
844
  type: z.string().min(1),
655
845
  required: z.boolean().optional(),
656
846
  description: z.string().optional(),
657
- entityType: z.string().optional()
658
- });
847
+ entityType: z.string().optional(),
848
+ properties: z.lazy(() => z.array(EventPayloadFieldSchema)).optional()
849
+ });
850
+ var CONFIG_REF_EVENT_PATTERN = /^@config\.[A-Za-z_][A-Za-z0-9_]*$/;
851
+ function configRefEventKnob(event) {
852
+ return CONFIG_REF_EVENT_PATTERN.test(event) ? event.slice("@config.".length) : void 0;
853
+ }
854
+ function resolveConfigRefEventName(event, declaredConfig, effectiveConfig) {
855
+ const knob = configRefEventKnob(event);
856
+ if (knob === void 0) return { ok: false, error: "unknown-knob" };
857
+ const field = declaredConfig?.[knob];
858
+ if (field === void 0) return { ok: false, error: "unknown-knob" };
859
+ if (field.type !== "string") return { ok: false, error: "not-string" };
860
+ if (field.default === void 0) return { ok: false, error: "no-default" };
861
+ const value = effectiveConfig[knob];
862
+ if (typeof value !== "string") return { ok: false, error: "not-string" };
863
+ return { ok: true, value };
864
+ }
659
865
  var TraitEventContractSchema = z.object({
660
866
  /**
661
867
  * Event name. Mirrors the Rust validator's `is_valid_event_identifier`:
662
868
  * starts with a letter, then any letters / digits / underscores. Both
663
869
  * UPPER_SNAKE_CASE and PascalCase shapes are valid identifiers in the
664
870
  * post-Phase 2.5 nominal-event type system (events declared via
665
- * `type X = Event<T>`).
871
+ * `type X = Event<T>`). A pre-resolution `@config.<knob>` reference
872
+ * (Option B) is also legal — inline/resolve substitutes it with the
873
+ * knob's effective literal before codegen/runtime consume it.
666
874
  */
667
875
  event: z.string().min(1).regex(
668
- /^[A-Za-z][A-Za-z0-9_]*$/,
669
- "Event name must start with a letter and contain only letters, digits, and underscores"
876
+ /^([A-Za-z][A-Za-z0-9_]*|@config\.[A-Za-z_][A-Za-z0-9_]*)$/,
877
+ "Event name must start with a letter and contain only letters, digits, and underscores, or be a `@config.<knob>` reference"
670
878
  ),
879
+ eventId: EventIdSchema.optional(),
671
880
  description: z.string().optional(),
672
881
  synonyms: z.string().optional(),
673
882
  tier: z.string().optional(),
@@ -676,16 +885,24 @@ var TraitEventContractSchema = z.object({
676
885
  });
677
886
  var ListenSourceSchema = z.union([
678
887
  z.object({ kind: z.literal("any") }),
679
- z.object({ kind: z.literal("trait"), trait: z.string().min(1) }),
888
+ z.object({
889
+ kind: z.literal("trait"),
890
+ trait: z.string().min(1),
891
+ traitId: TraitIdSchema.optional()
892
+ }),
680
893
  z.object({
681
894
  kind: z.literal("orbital"),
682
895
  orbital: z.string().min(1),
683
- trait: z.string().min(1)
896
+ trait: z.string().min(1),
897
+ orbitalId: OrbitalIdSchema.optional(),
898
+ traitId: TraitIdSchema.optional()
684
899
  })
685
900
  ]);
686
901
  var TraitEventListenerSchema = z.object({
687
902
  event: z.string().min(1),
903
+ eventId: EventIdSchema.optional(),
688
904
  triggers: z.string().min(1),
905
+ triggersId: EventIdSchema.optional(),
689
906
  description: z.string().optional(),
690
907
  synonyms: z.string().optional(),
691
908
  tier: z.string().optional(),
@@ -701,14 +918,20 @@ var RequiredFieldSchema = z.object({
701
918
  });
702
919
  var TraitReferenceSchema = z.object({
703
920
  ref: z.string().min(1),
921
+ refId: TraitIdSchema.optional(),
922
+ // V4 local declaration id (see the interface doc) — declared so the
923
+ // strip-mode zod gate carries it through instead of dropping it.
924
+ id: TraitIdSchema.optional(),
704
925
  // Phase 1.2: optional registry path disambiguator, pairs with `ref`.
705
926
  from: z.string().optional(),
706
927
  linkedEntity: z.string().optional(),
928
+ linkedEntityId: EntityIdSchema.optional(),
707
929
  name: z.string().optional(),
708
930
  events: z.record(
709
931
  z.string().min(1, "events key (atom event name) must be non-empty"),
710
932
  z.string().min(1, "events value (caller event name) must be non-empty")
711
933
  ).optional(),
934
+ eventIds: z.record(z.string().min(1), EventIdSchema).optional(),
712
935
  fields: z.record(
713
936
  z.string().min(1, "fields key (canonical field name) must be non-empty"),
714
937
  z.string().min(1, "fields value (consumer field name) must be non-empty")
@@ -758,6 +981,7 @@ var SourceBehaviorMetadataSchema = z.object({
758
981
  originalName: z.string().min(1)
759
982
  });
760
983
  var TraitSchema = z.object({
984
+ id: TraitIdSchema.optional(),
761
985
  name: z.string().min(1),
762
986
  description: z.string().optional(),
763
987
  description_visual_prompt: z.string().optional(),
@@ -769,6 +993,9 @@ var TraitSchema = z.object({
769
993
  capabilities: z.array(z.string()).optional(),
770
994
  scope: TraitScopeSchema,
771
995
  linkedEntity: z.string().optional(),
996
+ linkedEntityId: EntityIdSchema.optional(),
997
+ entityRefIds: z.record(z.string().min(1), EntityIdSchema).optional(),
998
+ traitEmbedIds: z.record(z.string().min(1), TraitIdSchema).optional(),
772
999
  requiredFields: z.array(RequiredFieldSchema).optional(),
773
1000
  dataEntities: z.array(TraitDataEntitySchema).optional(),
774
1001
  stateMachine: StateMachineSchema.optional(),
@@ -842,10 +1069,13 @@ var ViewTypeSchema = z.enum([
842
1069
  ]);
843
1070
  var PageTraitRefSchema = z.object({
844
1071
  ref: z.string().min(1, "Trait ref is required"),
1072
+ refId: TraitIdSchema.optional(),
845
1073
  linkedEntity: z.string().optional(),
1074
+ linkedEntityId: EntityIdSchema.optional(),
846
1075
  config: TraitConfigSchema.optional()
847
1076
  });
848
1077
  var OrbitalPageStrictSchema = z.object({
1078
+ id: PageIdSchema.optional(),
849
1079
  name: z.string().min(1, "Page name is required"),
850
1080
  path: z.string().min(1, "Page path is required").startsWith("/", "Path must start with /"),
851
1081
  primaryEntity: z.string().min(1, "Primary entity is required"),
@@ -853,6 +1083,7 @@ var OrbitalPageStrictSchema = z.object({
853
1083
  title: z.string().optional()
854
1084
  }).strict();
855
1085
  var OrbitalPageSchema = z.object({
1086
+ id: PageIdSchema.optional(),
856
1087
  name: z.string().min(1, "Page name is required"),
857
1088
  path: z.string().min(1, "Page path is required").startsWith("/", "Path must start with /"),
858
1089
  viewType: ViewTypeSchema.optional(),
@@ -1429,11 +1660,14 @@ var PageRefStringSchema = z.string().regex(
1429
1660
  );
1430
1661
  var PageRefObjectSchema = z.object({
1431
1662
  ref: PageRefStringSchema,
1663
+ refId: PageIdSchema.optional(),
1432
1664
  // Phase 1.2: optional registry path disambiguator, pairs with `ref`.
1433
1665
  from: z.string().optional(),
1434
1666
  path: z.string().startsWith("/").optional(),
1435
1667
  linkedEntity: z.string().optional(),
1436
- traits: z.array(TraitRefSchema).optional()
1668
+ linkedEntityId: EntityIdSchema.optional(),
1669
+ traits: z.array(TraitRefSchema).optional(),
1670
+ traitRefIds: z.array(TraitIdSchema).optional()
1437
1671
  });
1438
1672
  var PageRefSchema = z.union([
1439
1673
  PageSchema,
@@ -1487,6 +1721,7 @@ var ComputedEventListenerSchema = z.object({
1487
1721
  payloadMapping: z.record(z.string()).optional()
1488
1722
  });
1489
1723
  var OrbitalDefinitionSchema = z.object({
1724
+ id: OrbitalIdSchema.optional(),
1490
1725
  name: z.string().min(1, "Orbital name is required"),
1491
1726
  description: z.string().optional(),
1492
1727
  visual_prompt: z.string().optional(),
@@ -1551,7 +1786,12 @@ var OrbitalSchemaSchema = z.object({
1551
1786
  orbitals: z.array(OrbitalSchema).min(1, "At least one orbital is required"),
1552
1787
  services: z.array(ServiceDefinitionSchema).optional(),
1553
1788
  config: OrbitalConfigSchema.optional(),
1554
- _metadata: SchemaMetadataSchema.optional()
1789
+ _metadata: SchemaMetadataSchema.optional(),
1790
+ // V4 identity — optional/dual-carry until the Phase-7 flip. Present on
1791
+ // id-carrying `.orb` files so `parseOrbitalSchema` preserves them instead
1792
+ // of stripping unknown keys.
1793
+ schemaVersion: z.number().optional(),
1794
+ ledger: IdentityLedgerSchema.optional()
1555
1795
  });
1556
1796
  function parseOrbitalSchema(data) {
1557
1797
  return OrbitalSchemaSchema.parse(data);
@@ -1608,6 +1848,11 @@ var BINDING_DOCS = {
1608
1848
  description: "Authenticated user / agent context for ownership and role-based gating",
1609
1849
  examples: ["@user.id", "@user.role"],
1610
1850
  requiresPath: true
1851
+ },
1852
+ callsitePayload: {
1853
+ description: "Call-site-captured event payload \u2014 emitted by the compiler's inline-trait hoisting when an extracted render block captured @payload; resolved at the composing effect by the runtime BindingResolver",
1854
+ examples: ["@callsitePayload.error", "@callsitePayload.row"],
1855
+ requiresPath: true
1611
1856
  }
1612
1857
  };
1613
1858
  var BINDING_CONTEXT_RULES = {
@@ -1616,8 +1861,8 @@ var BINDING_CONTEXT_RULES = {
1616
1861
  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.`
1617
1862
  },
1618
1863
  effect: {
1619
- allowed: ["entity", "payload", "state", "now", "trait", "config", "user"],
1620
- 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."
1864
+ allowed: ["entity", "payload", "state", "now", "trait", "config", "user", "callsitePayload"],
1865
+ 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. @callsitePayload.X is the call-site-captured event payload emitted by the compiler's inline-trait hoisting (a hoisted render block that captured @payload); it is resolved at the composing effect by the runtime BindingResolver."
1621
1866
  },
1622
1867
  tick: {
1623
1868
  allowed: ["entity", "state", "now", "config", "user"],
@@ -1995,6 +2240,17 @@ function isValidPatternType(type) {
1995
2240
  return PATTERN_TYPES.includes(type);
1996
2241
  }
1997
2242
 
2243
+ // src/types/json.ts
2244
+ function isJsonPrimitive(value) {
2245
+ return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
2246
+ }
2247
+ function isJsonObject(value) {
2248
+ return value !== null && typeof value === "object" && !Array.isArray(value);
2249
+ }
2250
+ function isJsonArray(value) {
2251
+ return Array.isArray(value);
2252
+ }
2253
+
1998
2254
  // src/types/pattern.ts
1999
2255
  var PatternTypeSchema = z.string();
2000
2256
 
@@ -2095,17 +2351,6 @@ function isResolvedIR(ir) {
2095
2351
  return typeof r.appName === "string" && r.traits instanceof Map && r.pages instanceof Map;
2096
2352
  }
2097
2353
 
2098
- // src/types/json.ts
2099
- function isJsonPrimitive(value) {
2100
- return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
2101
- }
2102
- function isJsonObject(value) {
2103
- return value !== null && typeof value === "object" && !Array.isArray(value);
2104
- }
2105
- function isJsonArray(value) {
2106
- return Array.isArray(value);
2107
- }
2108
-
2109
2354
  // src/types/validation.ts
2110
2355
  var KNOWN_VALIDATION_ERROR_CODES = {
2111
2356
  // Binding (`@entity.X`, `@payload.Y`, `@state.Z`, `@now`, ...)
@@ -2270,7 +2515,13 @@ var KNOWN_VALIDATION_ERROR_CODES = {
2270
2515
  ORB_X_PAYLOAD_MISMATCH: "ORB_X_PAYLOAD_MISMATCH",
2271
2516
  ORB_X_RENDER_UI_EVENT_LITERAL_STALE: "ORB_X_RENDER_UI_EVENT_LITERAL_STALE",
2272
2517
  ORB_X_UNRESOLVED_PATTERN_FIELD_REF: "ORB_X_UNRESOLVED_PATTERN_FIELD_REF",
2273
- ORB_X_UNUSED_EMISSION: "ORB_X_UNUSED_EMISSION"
2518
+ ORB_X_UNUSED_EMISSION: "ORB_X_UNUSED_EMISSION",
2519
+ // Identity — V4 dual-carry id integrity (`ORB_ID_*`). Mirrors
2520
+ // `orbital-compiler/src/phases/validation/id_integrity.rs`.
2521
+ ORB_ID_UNKNOWN_REF: "ORB_ID_UNKNOWN_REF",
2522
+ ORB_ID_NAME_MISMATCH: "ORB_ID_NAME_MISMATCH",
2523
+ ORB_ID_KIND_MISMATCH: "ORB_ID_KIND_MISMATCH",
2524
+ ORB_ID_LEDGER_ORPHAN: "ORB_ID_LEDGER_ORPHAN"
2274
2525
  };
2275
2526
  function isKnownValidationErrorCode(code) {
2276
2527
  return code in KNOWN_VALIDATION_ERROR_CODES;
@@ -2281,6 +2532,6 @@ function widenTier(tier) {
2281
2532
  return tier;
2282
2533
  }
2283
2534
 
2284
- export { AGENT_DOMAIN_CATEGORIES, ALLOWED_CUSTOM_COMPONENTS, ANIMATION_NAMES, ASSET_ASPECTS, ASSET_DIMENSIONS, AgentDomainCategorySchema, AnimationDefSchema, AnimationNameSchema, AssetAspectSchema, AssetCatalogEntrySchema, AssetCatalogSchema, AssetDimensionSchema, AssetSchema, BINDING_CONTEXT_RULES, BINDING_DOCS, BINDING_ROOTS, BindingSchema, CAMERA_MODES, CORE_BINDINGS, CameraModeSchema, CameraSchema, ColorSliceSchema, ColorTokensSchema, ComputedEventContractSchema, ComputedEventListenerSchema, ConfigFieldDeclarationSchema, ConfigProvenanceRecordSchema, CustomPatternDefinitionSchema, CustomPatternMapSchema, DEFAULT_INTERACTION_MODELS, DeclaredTraitConfigSchema, DensitySliceSchema, DensityTokensSchema, DesignPreferencesSchema, DesignTokensSchema, DomainCategorySchema, DomainContextSchema, DomainVocabularySchema, ENTITY_ROLES, EffectSchema, ElevationSliceSchema, ElevationTokensSchema, EntityCallSchema, EntityFieldContractSchema, EntityFieldSchema, EntityPersistenceSchema, EntityRefSchema, EntityRefStringSchema, EntityRoleSchema, EntitySchema, EntitySemanticRoleSchema, EventListenerSchema, EventPayloadFieldSchema, EventSchema, EventScopeSchema, EventSemanticRoleSchema, EventSourceSchema, ExpressionSchema, FieldFormatSchema, FieldSchema, FieldTypeSchema, GameSubCategorySchema, GeometrySliceSchema, GeometryTokensSchema, GuardSchema, IconFamilySchema, IconographySliceSchema, IconographyTokensSchema, IllustrationSliceSchema, IllustrationStyleSchema, IllustrationTokensSchema, InteractionModelSchema, KNOWN_VALIDATION_ERROR_CODES, ListenSourceSchema, McpServiceDefSchema, MotionDurationKeySchema, MotionDurationPaletteSchema, MotionEasingKeySchema, MotionEasingPaletteSchema, MotionIntentMapSchema, MotionIntentSchema, MotionSliceSchema, MotionTokensSchema, NodeClassificationSchema, OrbitalConfigSchema, OrbitalDefinitionSchema, OrbitalEntitySchema, OrbitalPageSchema, OrbitalPageStrictSchema, OrbitalSchemaSchema, OrbitalTraitRefSchema, OrbitalUnitSchema, OrbitalSchema as OrbitalZodSchema, PATTERN_TYPES, PageRefObjectSchema, PageRefSchema, PageRefStringSchema, PageSchema, PageTraitRefSchema, PatternTypeSchema, PayloadFieldSchema, RelatedLinkSchema, RelationConfigSchema, RequiredFieldSchema, RestAuthConfigSchema, RestServiceDefSchema, SERVICE_TYPES, SExprAtomSchema, SExprSchema, SPRITE_DIRECTIONS, ScenePosSchema, SchemaMetadataSchema, SemanticAssetRefSchema, ServiceDefinitionSchema, ServiceRefObjectSchema, ServiceRefSchema, ServiceRefStringSchema, ServiceTypeSchema, SkinSpecSchema, SocketEventsSchema, SocketServiceDefSchema, SpacingScaleSchema, SpriteDirectionSchema, SpriteSheetAtlasSchema, StateMachineSchema, StateSchema, StateSemanticRoleSchema, SubTextureSchema, SuggestedGuardSchema, TextureAtlasSchema, ThemeDefinitionSchema, ThemeRefSchema, ThemeRefStringSchema, ThemeTokensSchema, ThemeVariantSchema, TilesheetSchema, TraitCategorySchema, TraitConfigSchema, TraitConfigValueSchema, TraitDataEntitySchema, TraitEntityFieldSchema, TraitEventContractSchema, TraitEventListenerSchema, TraitFieldRefSchema, TraitRefSchema, TraitReferenceSchema, TraitSchema, TraitTickSchema, TransitionSchema, TypeIntentMapSchema, TypeIntentSchema, TypeScaleEntrySchema, TypeScaleSchema, TypeScaleTokensSchema, TypeSizeKeySchema, TypeSliceSchema, TypeSlotSchema, TypeWeightSchema, UISlotSchema, UI_SLOTS, UXHintsSchema, UseDeclarationSchema, UserPersonaSchema, VISUAL_STYLES, ViewTypeSchema, VisualStyleSchema, atomic, callService, collectBindings, createAssetKey, createEmptyResolvedPage, createEmptyResolvedTrait, createLazyService, createResolvedField, createTypedEventBus, deref, deriveCollection, despawn, doEffects, emit, findService, getArgs, getBindingExamples, getDefaultAnimationsForRole, getInteractionModelForDomain, getOperator, getServiceNames, getTraitConfig, getTraitName, hasService, inferTsType, isBinding, isCallSiteConfigDeclaration, isCircuitEvent, isEffect, isEntityCall, isEntityReference, isEntityReferenceAny, isEventPayloadValue, isFieldValue, isImportedTraitRef, isInlineTrait, isJsonArray, isJsonObject, isJsonPrimitive, isKnownValidationErrorCode, isMcpService, isOrbitalDefinition, isPageReference, isPageReferenceObject, isPageReferenceString, isPlanSnapshot, isResolvedIR, isRestService, isRuntimeEntity, isSExpr, isSExprAtom, isSExprCall, isSExprEffect, isServiceReference, isServiceReferenceObject, isSessionHistoryEntry, isSocketService, isThemeReference, isTraitFieldRef, isValidBinding, isValidPatternType, navigate, normalizeTraitRef, notify, parseAssetKey, parseBinding, parseEntityRef, parseImportedTraitRef, parseOrbitalSchema, parsePageRef, parseServiceRef, persist, persistenceModeAllowsOverrides, ref, renderUI, safeParseOrbitalSchema, set, sexpr, spawn, swap, toBindingRoot, validateAssetAnimations, validateBindingInContext, walkSExpr, watch, widenTier };
2535
+ export { AGENT_DOMAIN_CATEGORIES, ALLOWED_CUSTOM_COMPONENTS, ANIMATION_NAMES, ASSET_ASPECTS, ASSET_DIMENSIONS, AgentDomainCategorySchema, AnimationDefSchema, AnimationNameSchema, AssetAspectSchema, AssetCatalogEntrySchema, AssetCatalogSchema, AssetDimensionSchema, AssetSchema, BINDING_CONTEXT_RULES, BINDING_DOCS, BINDING_ROOTS, BindingSchema, CAMERA_MODES, CONFIG_REF_EVENT_PATTERN, CORE_BINDINGS, CameraModeSchema, CameraSchema, ColorSliceSchema, ColorTokensSchema, ComputedEventContractSchema, ComputedEventListenerSchema, ConfigFieldDeclarationSchema, ConfigProvenanceRecordSchema, CustomPatternDefinitionSchema, CustomPatternMapSchema, DEFAULT_INTERACTION_MODELS, DeclaredTraitConfigSchema, DensitySliceSchema, DensityTokensSchema, DesignPreferencesSchema, DesignTokensSchema, DomainCategorySchema, DomainContextSchema, DomainVocabularySchema, ENTITY_ROLES, EffectSchema, ElevationSliceSchema, ElevationTokensSchema, EntityCallSchema, EntityFieldContractSchema, EntityFieldSchema, EntityIdSchema, EntityPersistenceSchema, EntityRefSchema, EntityRefStringSchema, EntityRoleSchema, EntitySchema, EntitySemanticRoleSchema, EventIdSchema, EventListenerSchema, EventPayloadFieldSchema, EventSchema, EventScopeSchema, EventSemanticRoleSchema, EventSourceSchema, ExpressionSchema, FieldFormatSchema, FieldSchema, FieldTypeSchema, GameSubCategorySchema, GeometrySliceSchema, GeometryTokensSchema, GuardSchema, IconFamilySchema, IconographySliceSchema, IconographyTokensSchema, IdentityLedgerSchema, IllustrationSliceSchema, IllustrationStyleSchema, IllustrationTokensSchema, InteractionModelSchema, KNOWN_VALIDATION_ERROR_CODES, LedgerEntrySchema, LedgerKindSchema, ListenSourceSchema, McpServiceDefSchema, MotionDurationKeySchema, MotionDurationPaletteSchema, MotionEasingKeySchema, MotionEasingPaletteSchema, MotionIntentMapSchema, MotionIntentSchema, MotionSliceSchema, MotionTokensSchema, NodeClassificationSchema, OrbitalConfigSchema, OrbitalDefinitionSchema, OrbitalEntitySchema, OrbitalIdSchema, OrbitalPageSchema, OrbitalPageStrictSchema, OrbitalSchemaSchema, OrbitalTraitRefSchema, OrbitalUnitSchema, OrbitalSchema as OrbitalZodSchema, PATTERN_TYPES, PageIdSchema, PageRefObjectSchema, PageRefSchema, PageRefStringSchema, PageSchema, PageTraitRefSchema, PaletteEntryIdSchema, PatternTypeSchema, PayloadFieldSchema, REFERENCE_CONFIG_TYPES, RelatedLinkSchema, RelationConfigSchema, RequiredFieldSchema, RestAuthConfigSchema, RestServiceDefSchema, SERVICE_TYPES, SExprAtomSchema, SExprSchema, SPRITE_DIRECTIONS, ScenePosSchema, SchemaMetadataSchema, SemanticAssetRefSchema, ServiceDefinitionSchema, ServiceIdSchema, ServiceRefObjectSchema, ServiceRefSchema, ServiceRefStringSchema, ServiceTypeSchema, SkinSpecSchema, SocketEventsSchema, SocketServiceDefSchema, SpacingScaleSchema, SpriteDirectionSchema, SpriteSheetAtlasSchema, StateMachineSchema, StateSchema, StateSemanticRoleSchema, SubTextureSchema, SuggestedGuardSchema, TextureAtlasSchema, ThemeDefinitionSchema, ThemeIdSchema, ThemeRefSchema, ThemeRefStringSchema, ThemeTokensSchema, ThemeVariantSchema, TilesheetSchema, TraitCategorySchema, TraitConfigSchema, TraitConfigValueSchema, TraitDataEntitySchema, TraitEntityFieldSchema, TraitEventContractSchema, TraitEventListenerSchema, TraitFieldRefSchema, TraitIdSchema, TraitRefSchema, TraitReferenceSchema, TraitSchema, TraitTickSchema, TransitionSchema, TypeIntentMapSchema, TypeIntentSchema, TypeScaleEntrySchema, TypeScaleSchema, TypeScaleTokensSchema, TypeSizeKeySchema, TypeSliceSchema, TypeSlotSchema, TypeWeightSchema, UISlotSchema, UI_SLOTS, UXHintsSchema, UseDeclarationSchema, UserPersonaSchema, VISUAL_STYLES, ViewTypeSchema, VisualStyleSchema, asEntityId, asEventId, asOrbitalId, asPageId, asPaletteEntryId, asServiceId, asThemeId, asTraitId, atomic, callService, collectBindings, configRefEventKnob, createAssetKey, createEmptyResolvedPage, createEmptyResolvedTrait, createLazyService, createResolvedField, createTypedEventBus, deref, deriveCollection, despawn, doEffects, emit, findService, getArgs, getBindingExamples, getDefaultAnimationsForRole, getInteractionModelForDomain, getOperator, getServiceNames, getTraitConfig, getTraitName, hasService, idKindOf, idPrefix, inferTsType, isBinding, isCallSiteConfigDeclaration, isCircuitEvent, isEffect, isEntityCall, isEntityId, isEntityReference, isEntityReferenceAny, isEventId, isEventPayloadValue, isFieldValue, isImportedTraitRef, isInlineTrait, isJsonArray, isJsonObject, isJsonPrimitive, isKnownValidationErrorCode, isMcpService, isOrbitalDefinition, isOrbitalId, isPageId, isPageReference, isPageReferenceObject, isPageReferenceString, isPaletteEntryId, isPlanSnapshot, isReferenceConfigType, isResolvedIR, isRestService, isRuntimeEntity, isSExpr, isSExprAtom, isSExprCall, isSExprEffect, isServiceId, isServiceReference, isServiceReferenceObject, isSessionHistoryEntry, isSocketService, isThemeId, isThemeReference, isTraitFieldRef, isTraitId, isValidBinding, isValidPatternType, ledgerCurName, ledgerRename, ledgerResolveName, mintId, navigate, normalizeCallSiteConfigToValues, normalizeTraitRef, notify, parseAssetKey, parseBinding, parseEntityRef, parseImportedTraitRef, parseOrbitalSchema, parsePageRef, parseServiceRef, persist, persistenceModeAllowsOverrides, ref, renderUI, resolveConfigRefEventName, safeParseOrbitalSchema, set, sexpr, spawn, swap, toBindingRoot, validateAssetAnimations, validateBindingInContext, walkSExpr, watch, widenTier };
2285
2536
  //# sourceMappingURL=index.js.map
2286
2537
  //# sourceMappingURL=index.js.map