@almadar/core 10.55.0 → 10.56.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 { O as OrbitalSchema } from './schema-0C1bXRFm.js';
1
+ import { O as OrbitalSchema } from './schema-Nk1usPv6.js';
2
2
  import { S as SExpr } from './expression-Fk8bQWef.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { O as OrbitalSchema, a as OrbitalDefinition } from '../schema-0C1bXRFm.js';
1
+ import { O as OrbitalSchema, a as OrbitalDefinition } from '../schema-Nk1usPv6.js';
2
2
  import { h as CallSiteConfig, i as CallSiteConfigEntry, g as Trait } from '../trait-WnYkvPdZ.js';
3
3
  import { E as EntityField, a as EntityPersistence } from '../effect-DxD-XTI8.js';
4
4
  import { MakeTraitRefOpts } from '../builders.js';
@@ -210,6 +210,24 @@ declare function applyDeclarationEntityRename(schema: OrbitalSchema, rename: Ent
210
210
  * declaration disagrees with `curName` → `ORB_ID_NAME_MISMATCH`.
211
211
  */
212
212
  at: string): OrbitalSchema;
213
+ /**
214
+ * Ledger/declaration agreement heal for the factory build path: every entity
215
+ * declaration carrying an id must find its ledger row naming the SAME name
216
+ * the declaration carries. A re-instantiate adopts the prior `.orb`'s ledger
217
+ * via `orb stamp --prior` — including rename rows an earlier build recorded —
218
+ * while the factory re-emits the entity at its baked/requested name, so a
219
+ * stale `curName` would survive a corrective rebuild unchanged and
220
+ * manufacture an `ORB_ID_NAME_MISMATCH` no repair pass can edit away
221
+ * (battery 2026-08-06 domain-rule: param-fill renamed MarketplaceUserOrbital's
222
+ * entity to `Product`; the corrective re-instantiate at `entityName:
223
+ * "MarketplaceUser"` applies NO rename — from === to — and the adopted row
224
+ * kept `curName: "Product"` against a `MarketplaceUser` declaration).
225
+ *
226
+ * Sound on this path only: the factory always re-emits the declaration at the
227
+ * requested/baked name, so the declaration is the build's truth and the
228
+ * adopted row carries identity (the id) forward. No-op when they agree.
229
+ */
230
+ declare function healEntityLedgerRows(schema: OrbitalSchema, at: string): OrbitalSchema;
213
231
  /**
214
232
  * The overlay. Resolves the effective entity name + collection, calls
215
233
  * `makeOrbitalWithUses` with the rewritten data, then applies the params'
@@ -233,4 +251,4 @@ declare function applyParamsToOrb(orb: OrbitalSchema, orbitalName: string, _mani
233
251
 
234
252
  declare function applyParamsToWholeOrb(orb: OrbitalSchema, manifests: readonly OrbitalParamsManifest[], params: OrbitalFactoryParams): OrbitalSchema;
235
253
 
236
- export { type EntityDeclarationRename, type OrbitalFactoryParams, type OrbitalParamsManifest, type OrbitalTraitOverride, type ParamFieldDescriptor, type ParamValidationError, type ParamValidationResult, applyDeclarationEntityRename, applyDeclarationTraitRenames, applyParamsToOrb, applyParamsToWholeOrb, extractManifest, mergeCallSiteConfigOverrides, rebindInlineTraitEntity, rewriteEntityInInlineTrait, validateOrbitalFactoryParams };
254
+ export { type EntityDeclarationRename, type OrbitalFactoryParams, type OrbitalParamsManifest, type OrbitalTraitOverride, type ParamFieldDescriptor, type ParamValidationError, type ParamValidationResult, applyDeclarationEntityRename, applyDeclarationTraitRenames, applyParamsToOrb, applyParamsToWholeOrb, extractManifest, healEntityLedgerRows, mergeCallSiteConfigOverrides, rebindInlineTraitEntity, rewriteEntityInInlineTrait, validateOrbitalFactoryParams };
@@ -1284,6 +1284,23 @@ var UseDeclarationSchema = z.object({
1284
1284
  'Alias must be PascalCase (e.g., "Health", "GameCore")'
1285
1285
  )
1286
1286
  });
1287
+ var ExpectDeclarationSchema = z.discriminatedUnion("kind", [
1288
+ z.object({
1289
+ kind: z.literal("identity"),
1290
+ name: z.string().optional(),
1291
+ shape: z.array(EntityFieldSchema).optional()
1292
+ }),
1293
+ z.object({
1294
+ kind: z.literal("entity"),
1295
+ name: z.string().min(1, "Expected entity name is required"),
1296
+ shape: z.array(EntityFieldSchema).optional()
1297
+ }),
1298
+ z.object({
1299
+ kind: z.literal("event"),
1300
+ traitName: z.string().min(1, "Expected event trait name is required"),
1301
+ event: z.string().min(1, "Expected event name is required")
1302
+ })
1303
+ ]);
1287
1304
  var EntityRefStringSchema = z.string().regex(
1288
1305
  /^[A-Z][a-zA-Z0-9]*\.entity$/,
1289
1306
  'Entity reference must be in format "Alias.entity" (e.g., "Goblin.entity")'
@@ -1373,6 +1390,8 @@ var OrbitalDefinitionSchema = z.object({
1373
1390
  visual_prompt: z.string().optional(),
1374
1391
  // Import system
1375
1392
  uses: z.array(UseDeclarationSchema).optional(),
1393
+ // Consumer-side requirement declarations (`.lolo` `expects ...`)
1394
+ expects: z.array(ExpectDeclarationSchema).optional(),
1376
1395
  // Theme & Services
1377
1396
  theme: ThemeRefSchema.optional(),
1378
1397
  services: z.array(ServiceRefSchema).optional(),
@@ -1571,6 +1590,7 @@ function makeOrbitalWithUses(opts) {
1571
1590
  const orbital = {
1572
1591
  name: opts.name,
1573
1592
  uses: opts.uses,
1593
+ ...opts.expects !== void 0 ? { expects: opts.expects } : {},
1574
1594
  entity: opts.entity,
1575
1595
  traits: opts.traits,
1576
1596
  pages: opts.pages ?? []
@@ -1921,6 +1941,21 @@ function applyDeclarationEntityRename(schema, rename, at) {
1921
1941
  }
1922
1942
  return { ...schema, orbitals, ...ledger !== schema.ledger ? { ledger } : {} };
1923
1943
  }
1944
+ function healEntityLedgerRows(schema, at) {
1945
+ let ledger = schema.ledger;
1946
+ if (ledger === void 0) return schema;
1947
+ for (const orbital of schema.orbitals) {
1948
+ const entity = orbital.entity;
1949
+ if (typeof entity !== "object" || entity === null) continue;
1950
+ const id = entity.id;
1951
+ const name = entity.name;
1952
+ if (typeof id !== "string" || typeof name !== "string") continue;
1953
+ const entry = ledger.entries[id];
1954
+ if (entry === void 0 || entry.kind !== "entity" || entry.curName === name) continue;
1955
+ ledger = ledgerRename(ledger, id, name, at);
1956
+ }
1957
+ return ledger !== schema.ledger ? { ...schema, ledger } : schema;
1958
+ }
1924
1959
  function applyParamsToOrb(orb, orbitalName, _manifest, params) {
1925
1960
  const orbital = findOrbitalOrThrow(orb, orbitalName);
1926
1961
  const canonicalEntity = assertResolvedEntity(orbital.entity, orbitalName, orb.name);
@@ -1930,6 +1965,10 @@ function applyParamsToOrb(orb, orbitalName, _manifest, params) {
1930
1965
  const built = makeOrbitalWithUses({
1931
1966
  name: orbital.name,
1932
1967
  uses: orbital.uses ?? [],
1968
+ // Derived `expects` declarations ride the overlay untouched — they name
1969
+ // SIBLING entities (never the orbital's own), so the entityName rename
1970
+ // below cannot affect them.
1971
+ ...orbital.expects !== void 0 ? { expects: orbital.expects } : {},
1933
1972
  entity: buildEntity(ctx, canonicalEntityName, effectiveCollection, params),
1934
1973
  traits: rebuildTraits(orbital.traits),
1935
1974
  pages: rebuildPages(orbital.pages)
@@ -1991,6 +2030,6 @@ function applyParamsToWholeOrb(orb, manifests, params) {
1991
2030
  return { ...orb, orbitals: rebuilt };
1992
2031
  }
1993
2032
 
1994
- export { applyDeclarationEntityRename, applyDeclarationTraitRenames, applyParamsToOrb, applyParamsToWholeOrb, extractManifest, mergeCallSiteConfigOverrides, rebindInlineTraitEntity, rewriteEntityInInlineTrait, validateOrbitalFactoryParams };
2033
+ export { applyDeclarationEntityRename, applyDeclarationTraitRenames, applyParamsToOrb, applyParamsToWholeOrb, extractManifest, healEntityLedgerRows, mergeCallSiteConfigOverrides, rebindInlineTraitEntity, rewriteEntityInInlineTrait, validateOrbitalFactoryParams };
1995
2034
  //# sourceMappingURL=index.js.map
1996
2035
  //# sourceMappingURL=index.js.map