@almadar/core 7.25.0 → 8.0.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,7 @@
1
- import { d7 as UISlot, Z as Effect, cE as Trait, bN as RenderUIEffect, cQ as TraitEventContract, a2 as Entity, cS as TraitEventListener, cH as TraitConfig, a6 as EntityField, a9 as EntityPersistence, ag as EntityRow, dc as UseDeclaration, ab as EntityRef, cV as TraitRef, bs as PageRef, b6 as OrbitalDefinition, bh as OrbitalSchema, br as Page, bt as PageRefObject, cX as TraitReference } from './schema-BVni4uNf.js';
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';
2
3
  import { S as SExpr } from './expression-BVRFm0sV.js';
3
- 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-CHAMivlZ.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
5
  import { AnyPatternConfig } from '@almadar/patterns';
5
6
  import 'zod';
6
7
 
@@ -1,4 +1,4 @@
1
- import { b6 as OrbitalDefinition, bh as OrbitalSchema } from './schema-BVni4uNf.js';
1
+ import { X as OrbitalDefinition, a3 as OrbitalSchema } from './schema-Bg4qX43l.js';
2
2
 
3
3
  /**
4
4
  * Event Wiring
@@ -0,0 +1,648 @@
1
+ import { B as EntityField, H as EntityPersistence, bz as TraitReference, bD as TraitScope, bu as TraitEventListener } from './trait-BPe356_9.js';
2
+
3
+ /**
4
+ * Domain Language Types
5
+ *
6
+ * AST node types for the domain language that maps to KFlow schema.
7
+ * All entity references use explicit names (e.g., Order, Task, CurrentUser)
8
+ * per GAP-002 - no magic variables like `entity.` or `context.`.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+
13
+ /**
14
+ * Field type mapping: OrbitalSchema type → Domain Language keyword
15
+ *
16
+ * This is the single source of truth for type conversion.
17
+ * When adding new field types to OrbitalSchema, add the mapping here.
18
+ */
19
+ declare const FIELD_TYPE_MAPPING: {
20
+ readonly string: "text";
21
+ readonly number: "number";
22
+ readonly boolean: "yes/no";
23
+ readonly date: "date";
24
+ readonly timestamp: "timestamp";
25
+ readonly datetime: "datetime";
26
+ readonly array: "list";
27
+ readonly object: "object";
28
+ readonly enum: "enum";
29
+ readonly relation: "relation";
30
+ };
31
+ /**
32
+ * Effect operator mapping: Both systems use the same operator names
33
+ */
34
+ declare const EFFECT_OPERATORS: readonly ["set", "emit", "navigate", "render-ui", "persist", "call-service", "spawn", "despawn", "do", "notify"];
35
+ /**
36
+ * Effect operator names (S-expression first element)
37
+ * These are the operators used in S-expression effects like ['emit', ...]
38
+ */
39
+ type EffectType = (typeof EFFECT_OPERATORS)[number];
40
+ interface SourceLocation {
41
+ line: number;
42
+ column: number;
43
+ offset: number;
44
+ }
45
+ interface SourceRange {
46
+ start: SourceLocation;
47
+ end: SourceLocation;
48
+ }
49
+ interface ASTNode {
50
+ type: string;
51
+ range?: SourceRange;
52
+ }
53
+ /**
54
+ * Domain Language field types
55
+ *
56
+ * Note: These map to OrbitalSchema types via DOMAIN_TO_SCHEMA_FIELD_TYPE
57
+ */
58
+ type DomainFieldType = 'text' | 'long text' | 'number' | 'currency' | 'date' | 'timestamp' | 'datetime' | 'yes/no' | 'enum' | 'list' | 'object' | 'relation';
59
+ /**
60
+ * OrbitalSchema field types (for reference)
61
+ */
62
+ type SchemaFieldType = keyof typeof FIELD_TYPE_MAPPING;
63
+ /**
64
+ * Default value for a `DomainField`. Mirrors the JSON-leaf shape an
65
+ * `EntityField.default` may carry on `OrbitalSchema`: scalar, list, or
66
+ * nested object (when the field type is `'object'` or `'list'`).
67
+ */
68
+ type DomainFieldDefault = string | number | boolean | null | DomainFieldDefault[] | {
69
+ [k: string]: DomainFieldDefault;
70
+ };
71
+ /**
72
+ * For `fieldType: 'list'`, the typed shape of each item. Mirrors
73
+ * `EntityField.items` on `OrbitalSchema`. Currently a single-level
74
+ * type tag (matching how the schema uses it); extend if/when nested
75
+ * list-of-list / list-of-object signatures are required.
76
+ */
77
+ interface DomainFieldItems {
78
+ type: DomainFieldType;
79
+ }
80
+ interface DomainField extends ASTNode {
81
+ type: 'field';
82
+ name: string;
83
+ fieldType: DomainFieldType;
84
+ required: boolean;
85
+ unique: boolean;
86
+ auto: boolean;
87
+ default?: DomainFieldDefault;
88
+ enumValues?: string[];
89
+ /** List-of-X item type when `fieldType === 'list'`. */
90
+ items?: DomainFieldItems;
91
+ }
92
+ type RelationshipType = 'belongs_to' | 'has_many' | 'has_one';
93
+ interface DomainRelationship extends ASTNode {
94
+ type: 'relationship';
95
+ relationshipType: RelationshipType;
96
+ targetEntity: string;
97
+ alias?: string;
98
+ }
99
+ interface DomainEntity extends ASTNode {
100
+ type: 'entity';
101
+ name: string;
102
+ description: string;
103
+ fields: DomainField[];
104
+ relationships: DomainRelationship[];
105
+ states?: string[];
106
+ initialState?: string;
107
+ /**
108
+ * Storage mode on the resolved schema. Mirrors `EntityPersistence` in
109
+ * `@almadar/core/types/entity.ts`. Omitted ⇒ projector defaults to
110
+ * `'persistent'`. Domain text syntax: `Persistence: <value>` line in
111
+ * the entity section.
112
+ */
113
+ persistence?: EntityPersistence;
114
+ /**
115
+ * Storage collection key. Mirrors `OrbitalSchema.entities[i].collection`.
116
+ * Omitted ⇒ defaults to `plural(name).toLowerCase()`. Surfaced to the
117
+ * factory translator so the LLM can override the storage key without
118
+ * touching the entity name (e.g. entity `Product` → collection
119
+ * `"catalog"`).
120
+ */
121
+ collection?: string;
122
+ }
123
+ interface DomainPageSection extends ASTNode {
124
+ type: 'page_section';
125
+ description: string;
126
+ }
127
+ interface DomainPageAction extends ASTNode {
128
+ type: 'page_action';
129
+ trigger: string;
130
+ action: string;
131
+ }
132
+ interface DomainPage extends ASTNode {
133
+ type: 'page';
134
+ name: string;
135
+ description: string;
136
+ purpose: string;
137
+ url: string;
138
+ primaryEntity?: string;
139
+ traitName?: string;
140
+ sections: DomainPageSection[];
141
+ actions: DomainPageAction[];
142
+ onAccess?: string;
143
+ }
144
+ type ComparisonOperator = '==' | '!=' | '>' | '<' | '>=' | '<=';
145
+ type LogicalOperator = 'AND' | 'OR';
146
+ interface FieldReference extends ASTNode {
147
+ type: 'field_reference';
148
+ entityName: string;
149
+ fieldName: string;
150
+ }
151
+ interface FieldCheckCondition extends ASTNode {
152
+ type: 'field_check';
153
+ field: FieldReference;
154
+ check: 'provided' | 'empty' | 'equals';
155
+ value?: string | number | boolean;
156
+ }
157
+ interface ComparisonCondition extends ASTNode {
158
+ type: 'comparison';
159
+ field: FieldReference;
160
+ operator: ComparisonOperator;
161
+ value: string | number | boolean;
162
+ }
163
+ interface UserCheckCondition extends ASTNode {
164
+ type: 'user_check';
165
+ check: 'is_role' | 'owns_this';
166
+ role?: string;
167
+ ownerField?: string;
168
+ }
169
+ interface LogicalCondition extends ASTNode {
170
+ type: 'logical';
171
+ operator: LogicalOperator;
172
+ left: GuardCondition;
173
+ right: GuardCondition;
174
+ }
175
+ type GuardCondition = FieldCheckCondition | ComparisonCondition | UserCheckCondition | LogicalCondition;
176
+ interface DomainGuard extends ASTNode {
177
+ type: 'guard';
178
+ condition: GuardCondition;
179
+ raw: string;
180
+ }
181
+ interface DomainEffect extends ASTNode {
182
+ type: 'effect';
183
+ effectType: EffectType;
184
+ description: string;
185
+ config: Record<string, unknown>;
186
+ }
187
+ interface DomainTransition extends ASTNode {
188
+ type: 'transition';
189
+ fromState: string;
190
+ toState: string;
191
+ event: string;
192
+ guards: DomainGuard[];
193
+ effects: DomainEffect[];
194
+ }
195
+ interface DomainTick extends ASTNode {
196
+ type: 'tick';
197
+ name: string;
198
+ interval: string;
199
+ intervalMs?: number;
200
+ guard?: DomainGuard;
201
+ effects: DomainEffect[];
202
+ }
203
+ interface DomainBehavior extends ASTNode {
204
+ type: 'behavior';
205
+ name: string;
206
+ entityName: string;
207
+ states: string[];
208
+ initialState: string;
209
+ transitions: DomainTransition[];
210
+ ticks: DomainTick[];
211
+ rules: string[];
212
+ /**
213
+ * Instance- vs collection-scoped state machine. Mirrors
214
+ * `Trait.scope: TraitScope` in `@almadar/core/types/trait.ts`.
215
+ * Omitted ⇒ projector defaults to `'instance'`. Domain text syntax:
216
+ * `Scope: instance|collection` line in the behavior section.
217
+ */
218
+ scope?: TraitScope;
219
+ }
220
+ interface DomainDocument extends ASTNode {
221
+ type: 'document';
222
+ entities: DomainEntity[];
223
+ pages: DomainPage[];
224
+ behaviors: DomainBehavior[];
225
+ }
226
+ interface SectionMapping {
227
+ sectionId: string;
228
+ sectionType: 'entity' | 'page' | 'behavior' | 'tick';
229
+ schemaPath: string;
230
+ domainText: string;
231
+ aiDescription?: string;
232
+ range?: SourceRange;
233
+ lastModified?: number;
234
+ }
235
+ interface ParseError {
236
+ message: string;
237
+ range?: SourceRange;
238
+ suggestion?: string;
239
+ }
240
+ interface ParseResult<T> {
241
+ success: boolean;
242
+ data?: T;
243
+ errors: ParseError[];
244
+ warnings: ParseError[];
245
+ }
246
+ /**
247
+ * One field on a factory's canonical entity, in signature form. Mirrors
248
+ * the subset of `EntityField` that the projector needs to score a
249
+ * domain-entity match. Auto-added audit fields (id / createdAt /
250
+ * updatedAt) are omitted by the extractor.
251
+ */
252
+ interface FactorySignatureEntityField {
253
+ name: string;
254
+ type: SchemaFieldType;
255
+ required: boolean;
256
+ }
257
+ /**
258
+ * The canonical entity a factory produces. Almost always one entity
259
+ * per orbital; modeled as an array to keep the door open for orbitals
260
+ * that compose multiple entities.
261
+ */
262
+ interface FactoryEntitySignature {
263
+ /** Canonical entity name the factory's params build (e.g. `"ChatMessage"`). */
264
+ name: string;
265
+ /** Fields the factory emits, post-auto-field stripping. */
266
+ fields: ReadonlyArray<FactorySignatureEntityField>;
267
+ /** Persistence mode declared on the canonical entity in the `.orb`. */
268
+ persistence: EntityPersistence;
269
+ }
270
+ /**
271
+ * One trait the factory composes into the orbital. The projector reads
272
+ * these to determine which factory's trait stack covers a given
273
+ * `DomainBehavior` + which override knobs a presentation overlay can
274
+ * deterministically target. Trait identity is by `name` only; the
275
+ * projector matches structurally on the event / config arrays — no
276
+ * inferred "kind" tag.
277
+ */
278
+ interface FactoryTraitSignature {
279
+ /** Canonical trait name post-rename (e.g. `"ChatMessageList"`). */
280
+ name: string;
281
+ /** Event keys this trait emits (post-rename). Read directly from
282
+ * the trait's `emits[].event`. */
283
+ emittedEvents: ReadonlyArray<string>;
284
+ /** Event keys this trait listens for. Read directly from `listens[].event`. */
285
+ listenedEvents: ReadonlyArray<string>;
286
+ /** Config keys overridable via `traitOverrides.<name>.config.<key>`.
287
+ * Read directly from the trait's `config` declaration block. */
288
+ overridableConfigKeys: ReadonlyArray<string>;
289
+ /** Capability tags lifted directly from the source `.lolo` trait's
290
+ * header annotations. Free-form strings — the Phase 4 translator
291
+ * overlay matches rules to traits by exact set membership. Empty
292
+ * when the trait declared none. See `docs/Almadar_Domain_Language.md`
293
+ * Phase 3. */
294
+ capabilities: ReadonlyArray<string>;
295
+ }
296
+ /** One page the factory emits. The path is the factory default; the
297
+ * projector may override via `params.pagePath` or `params.pages[].path`. */
298
+ interface FactoryPageSignature {
299
+ name: string;
300
+ defaultPath: string;
301
+ primaryEntity: string;
302
+ }
303
+ interface FactorySignature {
304
+ /** Organism the factory belongs to (e.g. `"std-realtime-chat"`). */
305
+ organism: string;
306
+ /** Orbital this factory builds within that organism. */
307
+ orbital: string;
308
+ /** Tier the factory sits in (informational; drives nothing today). */
309
+ tier: 'atoms' | 'molecules' | 'organisms';
310
+ /** Path of the generated factory source (relative to the std root). */
311
+ factoryPath: string;
312
+ /** Canonical entity surface(s) the factory produces. */
313
+ entities: ReadonlyArray<FactoryEntitySignature>;
314
+ /** Trait stack the factory composes. */
315
+ traits: ReadonlyArray<FactoryTraitSignature>;
316
+ /** Pages the factory emits. */
317
+ pages: ReadonlyArray<FactoryPageSignature>;
318
+ /** Union of all `traits[].emittedEvents`. */
319
+ emittedEvents: ReadonlyArray<string>;
320
+ /** Union of all `traits[].listenedEvents`. */
321
+ listenedEvents: ReadonlyArray<string>;
322
+ /**
323
+ * Phase 5 — canonical starting `DomainDocument` fragment the studio
324
+ * questionnaire renders before any user input. Lifted verbatim from
325
+ * the factory's resolved `.orb` by `almadar-pattern-sync`. Users
326
+ * append / override via `DomainMutation` from the questionnaire UI;
327
+ * the base itself is never edited in place (consumers compose with
328
+ * `mergeDocuments(base, overlay)`).
329
+ *
330
+ * Optional during the 7.26.x transition — older catalog snapshots
331
+ * predating the sync regeneration omit it. Consumers should fall
332
+ * back to building a minimal document from `entities` + `pages`
333
+ * when this is missing.
334
+ */
335
+ baseDocument?: DomainDocument;
336
+ }
337
+ /**
338
+ * Aggregate catalog written to
339
+ * `packages/almadar-std/behaviors/registry/factory-signatures.json`.
340
+ * Sorted by organism then orbital. One entry per factory in the
341
+ * regenerate pipeline.
342
+ */
343
+ interface FactorySignatureCatalog {
344
+ /** Generated-by version stamp (the `@almadar/std` minor it shipped in). */
345
+ generatedFromStdVersion: string;
346
+ /** Sorted list of factory signatures. */
347
+ signatures: ReadonlyArray<FactorySignature>;
348
+ }
349
+ /**
350
+ * A single factory invocation, as the typed result of the translator.
351
+ * Lower into runtime by calling the factory at `factoryPath` with
352
+ * these `params`. Stable identity for downstream diffing is
353
+ * `(organism, orbital)`.
354
+ */
355
+ interface FactoryCallSite {
356
+ /** Matches `FactorySignature.organism`. */
357
+ organism: string;
358
+ /** Matches `FactorySignature.orbital`. */
359
+ orbital: string;
360
+ /** Matches `FactorySignature.factoryPath`. Convenience pointer; the
361
+ * authoritative source remains the signature catalog. */
362
+ factoryPath: string;
363
+ /** Typed param surface fed to the factory at invocation time. */
364
+ params: FactoryCallSiteParams;
365
+ }
366
+ /**
367
+ * The typed param surface every factory's call site populates. Each
368
+ * field on this interface corresponds to one row in the translator's
369
+ * domain↔factory mapping table. Adding a new domain concept means
370
+ * adding a field here AND wiring it in `translateDomainToParams`.
371
+ *
372
+ * Fields are all optional because not every factory consumes every
373
+ * concept; the translator only sets what the chosen signature
374
+ * advertises.
375
+ */
376
+ interface FactoryCallSiteParams {
377
+ /** Override `signature.entities[0].name` (entity rename). */
378
+ entityName?: string;
379
+ /** Additional or overriding entity fields. Caller wins on collision. */
380
+ entityFields?: ReadonlyArray<EntityField>;
381
+ /** Override `signature.entities[0].persistence`. */
382
+ persistence?: EntityPersistence;
383
+ /** Override the entity's storage collection key. Defaults to
384
+ * `plural(entityName).toLowerCase()` at factory dispatch time
385
+ * when omitted. */
386
+ collection?: string;
387
+ /** Per-page path overrides keyed by `signature.pages[i].name`. */
388
+ pagePaths?: Readonly<Record<string, string>>;
389
+ /** Trait config overrides keyed by `signature.traits[i].name`. Each
390
+ * value is a record keyed by the trait's `overridableConfigKeys`. */
391
+ traitOverrides?: Readonly<Record<string, {
392
+ config?: Readonly<Record<string, FactoryParamValue>>;
393
+ }>>;
394
+ /** Extra traits to compose into the orbital that aren't part of the
395
+ * canonical signature trait stack. Used when a domain behavior
396
+ * isn't covered by any canonical trait. */
397
+ extraTraits?: ReadonlyArray<TraitReference>;
398
+ }
399
+ /**
400
+ * Allowed leaf values for the typed factory-param surface. Same as
401
+ * `DomainFieldDefault` minus null, plus arrays + records to mirror
402
+ * the trait-config shape factories accept today.
403
+ */
404
+ type FactoryParamValue = string | number | boolean | ReadonlyArray<FactoryParamValue> | {
405
+ readonly [key: string]: FactoryParamValue;
406
+ };
407
+ /**
408
+ * Discriminated union of edits to a `DomainDocument`. Each variant
409
+ * carries typed AST nodes already defined in this file — never raw
410
+ * JSON. `applyMutation` is total over this union.
411
+ */
412
+ type DomainMutation = {
413
+ kind: 'add-entity';
414
+ entity: DomainEntity;
415
+ } | {
416
+ kind: 'remove-entity';
417
+ entityName: string;
418
+ } | {
419
+ kind: 'rename-entity';
420
+ from: string;
421
+ to: string;
422
+ } | {
423
+ kind: 'update-entity';
424
+ entityName: string;
425
+ entity: DomainEntity;
426
+ } | {
427
+ kind: 'add-field';
428
+ entityName: string;
429
+ field: DomainField;
430
+ } | {
431
+ kind: 'remove-field';
432
+ entityName: string;
433
+ fieldName: string;
434
+ } | {
435
+ kind: 'update-field';
436
+ entityName: string;
437
+ field: DomainField;
438
+ } | {
439
+ kind: 'add-page';
440
+ page: DomainPage;
441
+ } | {
442
+ kind: 'remove-page';
443
+ pageName: string;
444
+ } | {
445
+ kind: 'update-page';
446
+ pageName: string;
447
+ page: DomainPage;
448
+ } | {
449
+ kind: 'add-behavior';
450
+ behavior: DomainBehavior;
451
+ } | {
452
+ kind: 'remove-behavior';
453
+ behaviorName: string;
454
+ } | {
455
+ kind: 'update-behavior';
456
+ behaviorName: string;
457
+ behavior: DomainBehavior;
458
+ } | {
459
+ kind: 'add-transition';
460
+ behaviorName: string;
461
+ transition: DomainTransition;
462
+ } | {
463
+ kind: 'remove-transition';
464
+ behaviorName: string;
465
+ from: string;
466
+ to: string;
467
+ event: string;
468
+ } | {
469
+ kind: 'add-relationship';
470
+ entityName: string;
471
+ relationship: DomainRelationship;
472
+ } | {
473
+ kind: 'remove-relationship';
474
+ entityName: string;
475
+ targetEntity: string;
476
+ relationshipType: RelationshipType;
477
+ };
478
+ /**
479
+ * Cross-cutting presentation knobs that don't live in `DomainDocument`
480
+ * because they're factory-layer concerns (nav items live on a layout
481
+ * trait; theme is a separate `ThemeRef`). The translator reads these
482
+ * and threads them into the matching factory params.
483
+ */
484
+ interface PresentationOverlay {
485
+ /** Nav items to add to the orbital's layout trait. The translator
486
+ * looks for a `signature.traits[i]` with `overridableConfigKeys`
487
+ * including `navItems` and writes into `traitOverrides[name].config.navItems`. */
488
+ navAdditions?: ReadonlyArray<PresentationNavItem>;
489
+ /** Optional theme ref override for the orbital. */
490
+ themeRef?: string;
491
+ }
492
+ interface PresentationNavItem {
493
+ label: string;
494
+ path: string;
495
+ /** Optional icon key (consumer-resolved). */
496
+ icon?: string;
497
+ }
498
+ /**
499
+ * LLM-authored trait-level overrides keyed by trait name (matches
500
+ * `signature.traits[].name`). Each entry's `config` keys are
501
+ * validated against `signature.traits[i].overridableConfigKeys`;
502
+ * unknown trait names or unknown config keys emit typed warnings
503
+ * and are skipped. Mirrors the existing call-site override surface
504
+ * on `TraitReference` in `OrbitalSchema`.
505
+ */
506
+ type TraitOverlay = Readonly<Record<string, TraitOverlayEntry>>;
507
+ interface TraitOverlayEntry {
508
+ config?: Readonly<Record<string, FactoryParamValue>>;
509
+ linkedEntity?: string;
510
+ events?: Readonly<Record<string, string>>;
511
+ name?: string;
512
+ emitsScope?: 'internal' | 'external';
513
+ /** Reuses `TraitEventListener` from `@almadar/core/types/trait` so the
514
+ * overlay's listen entries carry the same `event` / `triggers` /
515
+ * `source` / `guard` shape as everywhere else — no narrower clone. */
516
+ listens?: ReadonlyArray<TraitEventListener>;
517
+ }
518
+ /** @deprecated Phase 4.1 placeholder — use `TraitEventListener` instead.
519
+ * Kept as a structural type alias so callers that imported it keep
520
+ * compiling through the transition; will be removed in 7.25.0. */
521
+ type TraitOverlayListener = TraitEventListener;
522
+ /**
523
+ * Rules carry a free-form `capability: string` that the translator
524
+ * matches against `signature.traits[].capabilities` (source-tagged
525
+ * in `.lolo`, propagated via `@almadar/core@7.22.0`).
526
+ *
527
+ * NO closed enum on `capability` — atoms advertise capability
528
+ * strings in their `.lolo` headers, and the catalog grows the
529
+ * vocabulary organically. The agent emits whatever capability
530
+ * string the user's domain expresses; if no trait in the catalog
531
+ * advertises that capability, the translator emits a typed warning.
532
+ */
533
+ interface RuleOverlay {
534
+ rules: ReadonlyArray<DomainRuleOverlayEntry>;
535
+ /**
536
+ * Entity-level ownership signal. Until Phase 1.5 promotes
537
+ * `ownedBy` into `DomainEntity`, ownership rides here as a
538
+ * parallel typed channel. The translator threads it into the
539
+ * matched trait's `config.ownerField` (when the matched trait
540
+ * advertises that key in `overridableConfigKeys`).
541
+ */
542
+ ownership?: ReadonlyArray<OwnershipOverlayEntry>;
543
+ }
544
+ interface DomainRuleOverlayEntry {
545
+ id: string;
546
+ /** Free-form capability label, matched against
547
+ * `signature.traits[].capabilities` by exact set membership. */
548
+ capability: string;
549
+ description: string;
550
+ /** Entity names this rule binds to. Empty array = cross-cutting:
551
+ * the rule applies to every orbital the translator visits. */
552
+ appliesTo: ReadonlyArray<string>;
553
+ /** Optional role name (e.g. `"admin"`) when the rule is role-scoped. */
554
+ role?: string;
555
+ /** Optional extra config knobs threaded into the matched trait's
556
+ * `config`. Validated against the trait's `overridableConfigKeys`. */
557
+ config?: Readonly<Record<string, FactoryParamValue>>;
558
+ }
559
+ interface OwnershipOverlayEntry {
560
+ /** Entity name (matches `DomainEntity.name`). */
561
+ entity: string;
562
+ /** Field name on the entity that carries the owner identifier. */
563
+ ownerField: string;
564
+ }
565
+
566
+ /**
567
+ * Deterministic translator: one `DomainDocument` slice + one chosen
568
+ * `FactorySignature` → one `FactoryCallSite`. The agent picks the
569
+ * signature upstream via embedding-search over the catalog; this
570
+ * function does ZERO matching. It just lowers domain fields onto the
571
+ * factory's advertised param surface, field-by-field.
572
+ *
573
+ * The binding (which `DomainEntity` / `DomainPage[]` map to this
574
+ * orbital) is the agent's explicit decision and is passed in. No name
575
+ * matching, no scoring, no tie-breaks.
576
+ *
577
+ * Adding a new domain concept means:
578
+ * 1. Add a field on `DomainEntity` / `DomainPage` / `DomainBehavior`
579
+ * (`packages/almadar-core/src/domain-language/types.ts`).
580
+ * 2. Make sure at least one factory signature advertises a
581
+ * consuming knob (Phase 1.5 gate — generated by
582
+ * almadar-pattern-sync from `.orb`).
583
+ * 3. Add one helper-fn row below that lowers the new field into
584
+ * `FactoryCallSiteParams`.
585
+ *
586
+ * If a binding field has no signature consumer, the translator emits
587
+ * a typed warning and SKIPS the field — that's the loud signal the
588
+ * field shouldn't have been admitted to the language.
589
+ */
590
+
591
+ /**
592
+ * The slice of `DomainDocument` that maps onto the chosen signature.
593
+ * The agent assembles this when it picks the signature: it knows
594
+ * which `DomainEntity` / `DomainPage[]` are this orbital's
595
+ * responsibility.
596
+ */
597
+ interface TranslationBinding {
598
+ /** The single domain entity this signature's orbital owns. */
599
+ entity: DomainEntity;
600
+ /** Pages from the domain doc that map to this orbital's pages. The
601
+ * translator pairs them with `signature.pages[]` by name. */
602
+ pages?: ReadonlyArray<DomainPage>;
603
+ }
604
+ interface TranslationWarning {
605
+ /** Dotted path of the domain field that couldn't be lowered. */
606
+ field: string;
607
+ /** Human-readable reason. */
608
+ reason: string;
609
+ }
610
+ interface TranslationResult {
611
+ callSite: FactoryCallSite;
612
+ warnings: ReadonlyArray<TranslationWarning>;
613
+ }
614
+ declare function translateDomainToParams(binding: TranslationBinding, signature: FactorySignature, presentation?: PresentationOverlay, ruleOverlay?: RuleOverlay, traitOverlay?: TraitOverlay, catalog?: ReadonlyArray<FactorySignature>): TranslationResult;
615
+
616
+ /**
617
+ * Structural diff between two `FactoryCallSite[]` lists. Pure typed,
618
+ * no side effects. Used by downstream consumers (agent planner, UI
619
+ * cascade view) to turn a "previous calls" + "next calls" pair into a
620
+ * minimal change set.
621
+ *
622
+ * Identity for diffing is `(organism, orbital)`. Renames are not
623
+ * handled here — they show up as a delete + add. The agent layer is
624
+ * expected to merge those back into a `'rename'` op if it can prove
625
+ * the underlying domain entity was renamed.
626
+ */
627
+
628
+ type CallSiteDiff = {
629
+ kind: 'add';
630
+ orbitalName: string;
631
+ next: FactoryCallSite;
632
+ } | {
633
+ kind: 'delete';
634
+ orbitalName: string;
635
+ prior: FactoryCallSite;
636
+ } | {
637
+ kind: 'edit';
638
+ orbitalName: string;
639
+ prior: FactoryCallSite;
640
+ next: FactoryCallSite;
641
+ } | {
642
+ kind: 'keep';
643
+ orbitalName: string;
644
+ call: FactoryCallSite;
645
+ };
646
+ declare function diffFactoryCalls(prior: ReadonlyArray<FactoryCallSite>, next: ReadonlyArray<FactoryCallSite>): ReadonlyArray<CallSiteDiff>;
647
+
648
+ export { type UserCheckCondition as $, type ASTNode as A, type FieldCheckCondition as B, type CallSiteDiff as C, type DomainBehavior as D, type EffectType as E, type FactoryCallSite as F, type FieldReference as G, type GuardCondition as H, type LogicalOperator as I, type ParseResult as J, type PresentationNavItem as K, type LogicalCondition as L, type PresentationOverlay as M, type RuleOverlay as N, type OwnershipOverlayEntry as O, type ParseError as P, type SectionMapping as Q, type RelationshipType as R, type SchemaFieldType as S, type SourceLocation as T, type SourceRange as U, type TraitOverlay as V, type TraitOverlayEntry as W, type TraitOverlayListener as X, type TranslationBinding as Y, type TranslationResult as Z, type TranslationWarning as _, type ComparisonCondition as a, diffFactoryCalls as a0, translateDomainToParams as a1, type ComparisonOperator as b, type DomainDocument as c, type DomainEffect as d, type DomainEntity as e, type DomainField as f, type DomainFieldDefault as g, type DomainFieldItems as h, type DomainFieldType as i, type DomainGuard as j, type DomainMutation as k, type DomainPage as l, type DomainPageAction as m, type DomainPageSection as n, type DomainRelationship as o, type DomainRuleOverlayEntry as p, type DomainTick as q, type DomainTransition as r, type FactoryCallSiteParams as s, type FactoryEntitySignature as t, type FactoryPageSignature as u, type FactoryParamValue as v, type FactorySignature as w, type FactorySignatureCatalog as x, type FactorySignatureEntityField as y, type FactoryTraitSignature as z };