@almadar/core 8.0.0 → 8.1.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,7 +1,7 @@
1
- import { bL as UISlot, t as Effect, bg as Trait, aC as RenderUIEffect, bs as TraitEventContract, y as Entity, bu as TraitEventListener, bj as TraitConfig, B as EntityField, H as EntityPersistence, L as EntityRow, bx as TraitRef, bz as TraitReference } from './trait-BPe356_9.js';
2
- import { aA as UseDeclaration, B as EntityRef, ab as PageRef, X as OrbitalDefinition, a3 as OrbitalSchema, aa as Page, ac as PageRefObject } from './schema-Bg4qX43l.js';
1
+ import { bK as UISlot, t as Effect, bg as Trait, aC as RenderUIEffect, bs as TraitEventContract, y as Entity, bu as TraitEventListener, bj as TraitConfig, B as EntityField, H as EntityPersistence, L as EntityRow, bx as TraitRef, bz as TraitReference } from './trait-g5-2JR48.js';
2
+ import { aA as UseDeclaration, B as EntityRef, ab as PageRef, X as OrbitalDefinition, a3 as OrbitalSchema, aa as Page, ac as PageRefObject } from './schema-Cov1FvVJ.js';
3
3
  import { S as SExpr } from './expression-BVRFm0sV.js';
4
- export { C as ComposeBehaviorsInput, a as ComposeBehaviorsResult, E as EventWiringEntry, L as LayoutStrategy, b as applyEventWiring, c as composeBehaviors, d as detectLayoutStrategy } from './compose-behaviors-Bq8tdeBU.js';
4
+ export { C as ComposeBehaviorsInput, a as ComposeBehaviorsResult, E as EventWiringEntry, L as LayoutStrategy, b as applyEventWiring, c as composeBehaviors, d as detectLayoutStrategy } from './compose-behaviors-DsgVjsAB.js';
5
5
  import { AnyPatternConfig } from '@almadar/patterns';
6
6
  import 'zod';
7
7
 
@@ -1,4 +1,4 @@
1
- import { X as OrbitalDefinition, a3 as OrbitalSchema } from './schema-Bg4qX43l.js';
1
+ import { X as OrbitalDefinition, a3 as OrbitalSchema } from './schema-Cov1FvVJ.js';
2
2
 
3
3
  /**
4
4
  * Event Wiring
@@ -1,27 +1,261 @@
1
- import { v as FactoryParamValue, p as DomainRuleOverlayEntry, N as RuleOverlay } from '../diff-factory-calls-DlBcMWPM.js';
2
- export { C as CallSiteDiff, F as FactoryCallSite, s as FactoryCallSiteParams, t as FactoryEntitySignature, u as FactoryPageSignature, w as FactorySignature, x as FactorySignatureCatalog, y as FactorySignatureEntityField, z as FactoryTraitSignature, O as OwnershipOverlayEntry, K as PresentationNavItem, M as PresentationOverlay, S as SchemaFieldType, V as TraitOverlay, W as TraitOverlayEntry, X as TraitOverlayListener, Y as TranslationBinding, Z as TranslationResult, _ as TranslationWarning, a0 as diffFactoryCalls, a1 as translateDomainToParams, a1 as translateOverlaysToParams } from '../diff-factory-calls-DlBcMWPM.js';
3
- import { B as EntityField, H as EntityPersistence, bz as TraitReference } from '../trait-BPe356_9.js';
1
+ import { B as EntityField, H as EntityPersistence, bz as TraitReference, bu as TraitEventListener } from '../trait-g5-2JR48.js';
4
2
  import 'zod';
5
3
  import '../expression-BVRFm0sV.js';
6
4
  import '@almadar/patterns';
7
5
 
8
6
  /**
9
- * Mutation surface for the factory-call plan.
10
- *
11
- * Replaces the deleted `DomainMutation` + `applyMutation` reducer. The
12
- * studio + questionnaire emit `FactoryCallPlanMutation[]` to express
13
- * incremental edits to the agent's per-orbital params + cross-cutting
14
- * overlays. The planner applies them via `applyFactoryCallPlanMutation`
15
- * and re-projects to `FactoryCallSite[]`.
16
- *
17
- * Initial scope covers per-orbital config edits. Structural ops
18
- * (add-orbital / remove-orbital / rename-orbital) ride the analysis
19
- * surface directly via `analysis.orbitals` / `analysis.deletedOrbitals`
20
- * / `analysis.renames`.
7
+ * OrbitalSchema field type tags. The factory-signature extractor lifts
8
+ * these directly from the resolved `.orb`; consumers narrow further at
9
+ * dispatch time.
10
+ */
11
+ type SchemaFieldType = 'string' | 'number' | 'boolean' | 'date' | 'timestamp' | 'datetime' | 'array' | 'object' | 'enum' | 'relation';
12
+ interface FactorySignatureEntityField {
13
+ name: string;
14
+ type: SchemaFieldType;
15
+ required: boolean;
16
+ }
17
+ /**
18
+ * The canonical entity a factory produces. Almost always one entity
19
+ * per orbital; modeled as an array to keep the door open for orbitals
20
+ * that compose multiple entities.
21
+ */
22
+ interface FactoryEntitySignature {
23
+ /** Canonical entity name the factory's params build (e.g. `"ChatMessage"`). */
24
+ name: string;
25
+ /** Fields the factory emits, post-auto-field stripping. */
26
+ fields: ReadonlyArray<FactorySignatureEntityField>;
27
+ /** Persistence mode declared on the canonical entity in the `.orb`. */
28
+ persistence: EntityPersistence;
29
+ }
30
+ /**
31
+ * One trait the factory composes into the orbital. The projector reads
32
+ * these to determine which factory's trait stack covers a given
33
+ * orbital + which override knobs a presentation overlay can target.
34
+ */
35
+ interface FactoryTraitSignature {
36
+ /** Canonical trait name post-rename (e.g. `"ChatMessageList"`). */
37
+ name: string;
38
+ /** Event keys this trait emits (post-rename). */
39
+ emittedEvents: ReadonlyArray<string>;
40
+ /** Event keys this trait listens for. */
41
+ listenedEvents: ReadonlyArray<string>;
42
+ /** Config keys overridable via `traitOverrides.<name>.config.<key>`. */
43
+ overridableConfigKeys: ReadonlyArray<string>;
44
+ /** Capability tags lifted directly from the source `.lolo` trait's
45
+ * header annotations. Free-form strings — the translator overlay
46
+ * matches rules to traits by exact set membership. */
47
+ capabilities: ReadonlyArray<string>;
48
+ }
49
+ /** One page the factory emits. The path is the factory default; the
50
+ * projector may override via `params.pagePaths`. */
51
+ interface FactoryPageSignature {
52
+ name: string;
53
+ defaultPath: string;
54
+ primaryEntity: string;
55
+ }
56
+ interface FactorySignature {
57
+ /** Organism the factory belongs to (e.g. `"std-realtime-chat"`). */
58
+ organism: string;
59
+ /** Orbital this factory builds within that organism. */
60
+ orbital: string;
61
+ /** Tier the factory sits in (informational). */
62
+ tier: 'atoms' | 'molecules' | 'organisms';
63
+ /** Path of the generated factory source (relative to the std root). */
64
+ factoryPath: string;
65
+ /** Canonical entity surface(s) the factory produces. */
66
+ entities: ReadonlyArray<FactoryEntitySignature>;
67
+ /** Trait stack the factory composes. */
68
+ traits: ReadonlyArray<FactoryTraitSignature>;
69
+ /** Pages the factory emits. */
70
+ pages: ReadonlyArray<FactoryPageSignature>;
71
+ /** Union of all `traits[].emittedEvents`. */
72
+ emittedEvents: ReadonlyArray<string>;
73
+ /** Union of all `traits[].listenedEvents`. */
74
+ listenedEvents: ReadonlyArray<string>;
75
+ }
76
+ /**
77
+ * Aggregate catalog written to
78
+ * `packages/almadar-std/behaviors/registry/factory-signatures.json`.
79
+ * Sorted by organism then orbital.
80
+ */
81
+ interface FactorySignatureCatalog {
82
+ /** Generated-by version stamp (the `@almadar/std` minor it shipped in). */
83
+ generatedFromStdVersion: string;
84
+ /** Sorted list of factory signatures. */
85
+ signatures: ReadonlyArray<FactorySignature>;
86
+ }
87
+ /**
88
+ * A single factory invocation, as the typed result of the translator.
89
+ * Lower into runtime by calling the factory at `factoryPath` with
90
+ * these `params`. Stable identity for downstream diffing is
91
+ * `(organism, orbital)`.
92
+ */
93
+ interface FactoryCallSite {
94
+ organism: string;
95
+ orbital: string;
96
+ factoryPath: string;
97
+ params: FactoryCallSiteParams;
98
+ }
99
+ /**
100
+ * The typed param surface every factory's call site populates. Each
101
+ * field corresponds to one row in the translator's overlay → factory
102
+ * mapping table.
103
+ */
104
+ interface FactoryCallSiteParams {
105
+ /** Override `signature.entities[0].name` (entity rename). */
106
+ entityName?: string;
107
+ /** Additional or overriding entity fields. Caller wins on collision. */
108
+ entityFields?: ReadonlyArray<EntityField>;
109
+ /** Override `signature.entities[0].persistence`. */
110
+ persistence?: EntityPersistence;
111
+ /** Override the entity's storage collection key. */
112
+ collection?: string;
113
+ /** Per-page path overrides keyed by `signature.pages[i].name`. */
114
+ pagePaths?: Readonly<Record<string, string>>;
115
+ /** Trait config overrides keyed by `signature.traits[i].name`. */
116
+ traitOverrides?: Readonly<Record<string, {
117
+ config?: Readonly<Record<string, FactoryParamValue>>;
118
+ }>>;
119
+ /** Extra traits to compose into the orbital that aren't part of the
120
+ * canonical signature trait stack. */
121
+ extraTraits?: ReadonlyArray<TraitReference>;
122
+ }
123
+ /**
124
+ * Allowed leaf values for the typed factory-param surface.
125
+ */
126
+ type FactoryParamValue = string | number | boolean | ReadonlyArray<FactoryParamValue> | {
127
+ readonly [key: string]: FactoryParamValue;
128
+ };
129
+
130
+ /**
131
+ * Cross-cutting presentation knobs that don't live per orbital
132
+ * because they're factory-layer concerns (nav items live on a layout
133
+ * trait; theme is a separate `ThemeRef`). The translator reads these
134
+ * and threads them into the matching factory params.
135
+ */
136
+ interface PresentationOverlay {
137
+ /** Nav items to add to the orbital's layout trait. The translator
138
+ * looks for a `signature.traits[i]` with `overridableConfigKeys`
139
+ * including `navItems` and writes into `traitOverrides[name].config.navItems`. */
140
+ navAdditions?: ReadonlyArray<PresentationNavItem>;
141
+ /** Optional theme ref override for the orbital. */
142
+ themeRef?: string;
143
+ }
144
+ interface PresentationNavItem {
145
+ label: string;
146
+ path: string;
147
+ icon?: string;
148
+ }
149
+ /**
150
+ * LLM-authored trait-level overrides keyed by trait name (matches
151
+ * `signature.traits[].name`). Each entry's `config` keys are validated
152
+ * against `signature.traits[i].overridableConfigKeys`.
153
+ */
154
+ type TraitOverlay = Readonly<Record<string, TraitOverlayEntry>>;
155
+ interface TraitOverlayEntry {
156
+ config?: Readonly<Record<string, FactoryParamValue>>;
157
+ linkedEntity?: string;
158
+ events?: Readonly<Record<string, string>>;
159
+ name?: string;
160
+ emitsScope?: 'internal' | 'external';
161
+ listens?: ReadonlyArray<TraitEventListener>;
162
+ }
163
+ type TraitOverlayListener = TraitEventListener;
164
+ /**
165
+ * Rules carry a free-form `capability: string` that the translator
166
+ * matches against `signature.traits[].capabilities` (source-tagged
167
+ * in `.lolo`).
168
+ */
169
+ interface RuleOverlay {
170
+ rules: ReadonlyArray<RuleOverlayEntry>;
171
+ /** Entity-level ownership signal. The translator threads it into
172
+ * the matched trait's `config.ownerField` (when the matched trait
173
+ * advertises that key in `overridableConfigKeys`). */
174
+ ownership?: ReadonlyArray<OwnershipOverlayEntry>;
175
+ }
176
+ interface RuleOverlayEntry {
177
+ id: string;
178
+ /** Free-form capability label, matched against
179
+ * `signature.traits[].capabilities` by exact set membership. */
180
+ capability: string;
181
+ description: string;
182
+ /** Entity names this rule binds to. Empty array = cross-cutting. */
183
+ appliesTo: ReadonlyArray<string>;
184
+ /** Optional role name (e.g. `"admin"`) when the rule is role-scoped. */
185
+ role?: string;
186
+ /** Optional extra config knobs threaded into the matched trait's
187
+ * `config`. Validated against the trait's `overridableConfigKeys`. */
188
+ config?: Readonly<Record<string, FactoryParamValue>>;
189
+ }
190
+ interface OwnershipOverlayEntry {
191
+ /** Entity name (matches the orbital's bound entity name). */
192
+ entity: string;
193
+ /** Field name on the entity that carries the owner identifier. */
194
+ ownerField: string;
195
+ }
196
+
197
+ /**
198
+ * The per-orbital binding the agent assembles when it picks a
199
+ * signature. Carries the user-authored overrides directly; no shared
200
+ * domain ontology, no DomainDocument.
201
+ */
202
+ interface TranslationBinding {
203
+ /** Entity name override. When equal to `signature.entities[0].name`,
204
+ * no rename is emitted. */
205
+ entityName: string;
206
+ /** Extra fields beyond the signature's canonical entity surface. */
207
+ entityFields?: ReadonlyArray<EntityField>;
208
+ /** Persistence override. */
209
+ persistence?: EntityPersistence;
210
+ /** Collection name override. */
211
+ collection?: string;
212
+ /** Per-page path overrides keyed by `signature.pages[i].name`. */
213
+ pagePaths?: Readonly<Record<string, string>>;
214
+ }
215
+ interface TranslationWarning {
216
+ /** Dotted path of the binding field that couldn't be lowered. */
217
+ field: string;
218
+ /** Human-readable reason. */
219
+ reason: string;
220
+ }
221
+ interface TranslationResult {
222
+ callSite: FactoryCallSite;
223
+ warnings: ReadonlyArray<TranslationWarning>;
224
+ }
225
+ declare function translateOverlaysToParams(binding: TranslationBinding, signature: FactorySignature, presentation?: PresentationOverlay, ruleOverlay?: RuleOverlay, traitOverlay?: TraitOverlay, catalog?: ReadonlyArray<FactorySignature>): TranslationResult;
226
+
227
+ /**
228
+ * Structural diff between two `FactoryCallSite[]` lists. Pure typed,
229
+ * no side effects. Used by downstream consumers (agent planner, UI
230
+ * cascade view) to turn a "previous calls" + "next calls" pair into a
231
+ * minimal change set.
21
232
  *
22
- * @packageDocumentation
233
+ * Identity for diffing is `(organism, orbital)`. Renames are not
234
+ * handled here — they show up as a delete + add. The agent layer is
235
+ * expected to merge those back into a `'rename'` op if it can prove
236
+ * the underlying domain entity was renamed.
23
237
  */
24
238
 
239
+ type CallSiteDiff = {
240
+ kind: 'add';
241
+ orbitalName: string;
242
+ next: FactoryCallSite;
243
+ } | {
244
+ kind: 'delete';
245
+ orbitalName: string;
246
+ prior: FactoryCallSite;
247
+ } | {
248
+ kind: 'edit';
249
+ orbitalName: string;
250
+ prior: FactoryCallSite;
251
+ next: FactoryCallSite;
252
+ } | {
253
+ kind: 'keep';
254
+ orbitalName: string;
255
+ call: FactoryCallSite;
256
+ };
257
+ declare function diffFactoryCalls(prior: ReadonlyArray<FactoryCallSite>, next: ReadonlyArray<FactoryCallSite>): ReadonlyArray<CallSiteDiff>;
258
+
25
259
  /**
26
260
  * One slot the agent emits per orbital. Slim shape — agent-facing,
27
261
  * carries only what factory dispatch needs. The studio renders forms
@@ -84,7 +318,7 @@ type FactoryCallPlanMutation = {
84
318
  ref: string;
85
319
  } | {
86
320
  kind: 'set-rule';
87
- rule: DomainRuleOverlayEntry;
321
+ rule: RuleOverlayEntry;
88
322
  } | {
89
323
  kind: 'remove-rule';
90
324
  ruleId: string;
@@ -102,4 +336,4 @@ interface FactoryCallPlanState {
102
336
  */
103
337
  declare function applyFactoryCallPlanMutation(state: FactoryCallPlanState, m: FactoryCallPlanMutation): FactoryCallPlanState;
104
338
 
105
- export { type FactoryCallPlanMutation, type FactoryCallPlanState, FactoryParamValue, type OrbitalCallInput, RuleOverlay, DomainRuleOverlayEntry as RuleOverlayEntry, applyFactoryCallPlanMutation };
339
+ export { type CallSiteDiff, type FactoryCallPlanMutation, type FactoryCallPlanState, type FactoryCallSite, type FactoryCallSiteParams, type FactoryEntitySignature, type FactoryPageSignature, type FactoryParamValue, type FactorySignature, type FactorySignatureCatalog, type FactorySignatureEntityField, type FactoryTraitSignature, type OrbitalCallInput, type OwnershipOverlayEntry, type PresentationNavItem, type PresentationOverlay, type RuleOverlay, type RuleOverlayEntry, type SchemaFieldType, type TraitOverlay, type TraitOverlayEntry, type TraitOverlayListener, type TranslationBinding, type TranslationResult, type TranslationWarning, applyFactoryCallPlanMutation, diffFactoryCalls, translateOverlaysToParams };
@@ -1,28 +1,12 @@
1
- // src/domain-language/types.ts
2
- var DOMAIN_TO_SCHEMA_FIELD_TYPE = {
3
- "text": "string",
4
- "long text": "string",
5
- "number": "number",
6
- "currency": "number",
7
- "yes/no": "boolean",
8
- "date": "date",
9
- "timestamp": "timestamp",
10
- "datetime": "datetime",
11
- "list": "array",
12
- "object": "object",
13
- "enum": "enum",
14
- "relation": "relation"
15
- };
16
-
17
- // src/domain-language/sync/translate-domain-to-params.ts
18
- function translateDomainToParams(binding, signature, presentation, ruleOverlay, traitOverlay, catalog) {
1
+ // src/factory/translate.ts
2
+ function translateOverlaysToParams(binding, signature, presentation, ruleOverlay, traitOverlay, catalog) {
19
3
  const warnings = [];
20
4
  const params = {};
21
- applyEntityName(binding.entity, signature, params);
22
- applyEntityFields(binding.entity, signature, params, warnings);
23
- applyPersistence(binding.entity, signature, params, warnings);
24
- applyCollection(binding.entity, params);
25
- applyPagePaths(binding.pages ?? [], signature, params, warnings);
5
+ applyEntityName(binding, signature, params);
6
+ applyEntityFields(binding, signature, params);
7
+ applyPersistence(binding, signature, params, warnings);
8
+ applyCollection(binding, params);
9
+ applyPagePaths(binding, signature, params, warnings);
26
10
  applyPresentation(presentation, signature, params, warnings);
27
11
  applyTraitOverlay(traitOverlay, signature, params, warnings);
28
12
  applyRuleOverlay(ruleOverlay, signature, binding, catalog, params, warnings);
@@ -36,60 +20,55 @@ function translateDomainToParams(binding, signature, presentation, ruleOverlay,
36
20
  warnings
37
21
  };
38
22
  }
39
- function applyEntityName(entity, signature, params) {
23
+ function applyEntityName(binding, signature, params) {
40
24
  if (signature.entities.length === 0) return;
41
- if (entity.name === signature.entities[0].name) return;
42
- params.entityName = entity.name;
25
+ if (binding.entityName === signature.entities[0].name) return;
26
+ params.entityName = binding.entityName;
43
27
  }
44
- function applyEntityFields(entity, signature, params, warnings) {
28
+ function applyEntityFields(binding, signature, params) {
29
+ if (!binding.entityFields || binding.entityFields.length === 0) return;
45
30
  if (signature.entities.length === 0) {
46
- if (entity.fields.length > 0) {
47
- warnings.push({
48
- field: `entity.${entity.name}.fields`,
49
- reason: "factory signature does not advertise an entity surface"
50
- });
51
- }
31
+ params.entityFields = [...binding.entityFields];
52
32
  return;
53
33
  }
54
34
  const canonical = new Set(signature.entities[0].fields.map((f) => f.name));
55
35
  const extras = [];
56
- for (const f of entity.fields) {
57
- if (canonical.has(f.name)) continue;
58
- const lowered = lowerField(f);
59
- if (lowered) extras.push(lowered);
36
+ for (const f of binding.entityFields) {
37
+ if (f.name && canonical.has(f.name)) continue;
38
+ extras.push(f);
60
39
  }
61
40
  if (extras.length > 0) params.entityFields = extras;
62
41
  }
63
- function applyPersistence(entity, signature, params, warnings) {
64
- if (!entity.persistence) return;
42
+ function applyPersistence(binding, signature, params, warnings) {
43
+ if (!binding.persistence) return;
65
44
  if (signature.entities.length === 0) {
66
45
  warnings.push({
67
- field: `entity.${entity.name}.persistence`,
46
+ field: `entity.${binding.entityName}.persistence`,
68
47
  reason: "factory signature has no entity to apply persistence to"
69
48
  });
70
49
  return;
71
50
  }
72
- if (entity.persistence === signature.entities[0].persistence) return;
73
- params.persistence = entity.persistence;
51
+ if (binding.persistence === signature.entities[0].persistence) return;
52
+ params.persistence = binding.persistence;
74
53
  }
75
- function applyCollection(entity, params) {
76
- if (!entity.collection) return;
77
- params.collection = entity.collection;
54
+ function applyCollection(binding, params) {
55
+ if (!binding.collection) return;
56
+ params.collection = binding.collection;
78
57
  }
79
- function applyPagePaths(pages, signature, params, warnings) {
80
- if (pages.length === 0) return;
58
+ function applyPagePaths(binding, signature, params, warnings) {
59
+ if (!binding.pagePaths) return;
81
60
  const sigPages = new Map(signature.pages.map((p) => [p.name, p]));
82
61
  const overrides = {};
83
- for (const p of pages) {
84
- const sig = sigPages.get(p.name);
62
+ for (const [pageName, url] of Object.entries(binding.pagePaths)) {
63
+ const sig = sigPages.get(pageName);
85
64
  if (!sig) {
86
65
  warnings.push({
87
- field: `page.${p.name}.url`,
88
- reason: `factory signature has no page named "${p.name}"`
66
+ field: `page.${pageName}.url`,
67
+ reason: `factory signature has no page named "${pageName}"`
89
68
  });
90
69
  continue;
91
70
  }
92
- if (sig.defaultPath !== p.url) overrides[p.name] = p.url;
71
+ if (sig.defaultPath !== url) overrides[pageName] = url;
93
72
  }
94
73
  if (Object.keys(overrides).length > 0) params.pagePaths = overrides;
95
74
  }
@@ -150,13 +129,12 @@ function mergeTraitOverride(traitName, entry, trait, params, warnings) {
150
129
  mergedConfig[k] = v;
151
130
  }
152
131
  }
153
- const next = {
154
- ...existing,
155
- ...Object.keys(mergedConfig).length > 0 ? { config: mergedConfig } : {}
156
- };
157
132
  params.traitOverrides = {
158
133
  ...params.traitOverrides,
159
- [traitName]: next
134
+ [traitName]: {
135
+ ...existing,
136
+ ...Object.keys(mergedConfig).length > 0 ? { config: mergedConfig } : {}
137
+ }
160
138
  };
161
139
  }
162
140
  function applyRuleOverlay(overlay, signature, binding, catalog, params, warnings) {
@@ -185,14 +163,14 @@ function applyRuleOverlay(overlay, signature, binding, catalog, params, warnings
185
163
  }
186
164
  if (overlay.ownership) {
187
165
  for (const entry of overlay.ownership) {
188
- if (entry.entity !== binding.entity.name) continue;
166
+ if (entry.entity !== binding.entityName) continue;
189
167
  applyOwnership(entry, params, signature, catalog, warnings);
190
168
  }
191
169
  }
192
170
  }
193
171
  function ruleAppliesToBinding(rule, binding) {
194
172
  if (rule.appliesTo.length === 0) return true;
195
- return rule.appliesTo.includes(binding.entity.name);
173
+ return rule.appliesTo.includes(binding.entityName);
196
174
  }
197
175
  function findTraitByCapability(catalog, capability) {
198
176
  for (const sig of catalog) {
@@ -204,13 +182,13 @@ function findTraitByCapability(catalog, capability) {
204
182
  }
205
183
  return void 0;
206
184
  }
207
- function appendRuleExtraTrait(rule, match, binding, params) {
185
+ function appendRuleExtraTrait(_rule, match, binding, params) {
208
186
  const fromPath = `std/behaviors/${match.signature.organism}`;
209
187
  const alias = organismToAlias(match.signature.organism);
210
188
  const ref = {
211
189
  from: fromPath,
212
190
  ref: `${alias}.traits.${match.trait.name}`,
213
- linkedEntity: binding.entity.name
191
+ linkedEntity: binding.entityName
214
192
  };
215
193
  const existing = params.extraTraits ?? [];
216
194
  params.extraTraits = [...existing, ref];
@@ -277,37 +255,6 @@ function writeOwnerField(traitName, ownerField, params) {
277
255
  }
278
256
  };
279
257
  }
280
- function lowerField(f) {
281
- const schemaType = DOMAIN_TO_SCHEMA_FIELD_TYPE[f.fieldType];
282
- if (!schemaType) return void 0;
283
- const out = {
284
- name: f.name,
285
- type: schemaType
286
- };
287
- if (f.required === true) out.required = true;
288
- if (f.enumValues && f.enumValues.length > 0) out.values = [...f.enumValues];
289
- if (f.default !== void 0) out.default = lowerDefault(f.default);
290
- if (f.items) {
291
- const itemSchema = DOMAIN_TO_SCHEMA_FIELD_TYPE[f.items.type];
292
- if (itemSchema) out.items = { type: itemSchema };
293
- }
294
- return out;
295
- }
296
- function lowerDefault(d) {
297
- if (d === void 0 || d === null) return d;
298
- if (typeof d === "string" || typeof d === "number" || typeof d === "boolean") {
299
- return d;
300
- }
301
- if (Array.isArray(d)) {
302
- return d.map(lowerDefault);
303
- }
304
- if (typeof d === "object") {
305
- const out = {};
306
- for (const [k, v] of Object.entries(d)) out[k] = lowerDefault(v);
307
- return out;
308
- }
309
- return void 0;
310
- }
311
258
  function navItemToParamValue(item) {
312
259
  const out = {
313
260
  label: item.label,
@@ -317,7 +264,7 @@ function navItemToParamValue(item) {
317
264
  return out;
318
265
  }
319
266
 
320
- // src/domain-language/sync/diff-factory-calls.ts
267
+ // src/factory/diff.ts
321
268
  function diffFactoryCalls(prior, next) {
322
269
  const out = [];
323
270
  const priorByKey = new Map(prior.map((c) => [callKey(c), c]));
@@ -349,6 +296,7 @@ function paramsEqual(a, b) {
349
296
  }
350
297
  function canonicalParams(p) {
351
298
  const keys = [
299
+ "collection",
352
300
  "entityFields",
353
301
  "entityName",
354
302
  "extraTraits",
@@ -479,6 +427,6 @@ function patchOrbital(state, orbitalName, patch) {
479
427
  };
480
428
  }
481
429
 
482
- export { applyFactoryCallPlanMutation, diffFactoryCalls, translateDomainToParams, translateDomainToParams as translateOverlaysToParams };
430
+ export { applyFactoryCallPlanMutation, diffFactoryCalls, translateOverlaysToParams };
483
431
  //# sourceMappingURL=index.js.map
484
432
  //# sourceMappingURL=index.js.map