@almadar/core 11.1.0 → 11.2.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.
Files changed (62) hide show
  1. package/dist/{builders-ZJeyUxCs.d.ts → builders-C4TIhiks.d.ts} +92 -92
  2. package/dist/builders.d.ts +4 -4
  3. package/dist/builders.js +3 -3
  4. package/dist/{bus-BwqO-o6e.d.ts → bus-do1P9luP.d.ts} +4 -4
  5. package/dist/{chunk-ENOCKYGA.js → chunk-2NKK2X53.js} +3 -3
  6. package/dist/{chunk-ENOCKYGA.js.map → chunk-2NKK2X53.js.map} +1 -1
  7. package/dist/{chunk-TDNQT3M3.js → chunk-3DZOFI53.js} +4 -4
  8. package/dist/{chunk-TDNQT3M3.js.map → chunk-3DZOFI53.js.map} +1 -1
  9. package/dist/{chunk-5YTPYMPZ.js → chunk-6H3UIZR2.js} +3 -3
  10. package/dist/{chunk-5YTPYMPZ.js.map → chunk-6H3UIZR2.js.map} +1 -1
  11. package/dist/{chunk-FGT5OS2Y.js → chunk-7B4JRMRL.js} +15 -3
  12. package/dist/chunk-7B4JRMRL.js.map +1 -0
  13. package/dist/{chunk-5WQ3U7NJ.js → chunk-IE6WCCJP.js} +14 -2
  14. package/dist/chunk-IE6WCCJP.js.map +1 -0
  15. package/dist/{chunk-PNGFWLHD.js → chunk-LPJ7GKRM.js} +18 -8
  16. package/dist/chunk-LPJ7GKRM.js.map +1 -0
  17. package/dist/{chunk-SNZYN7UA.js → chunk-N3CK4AYW.js} +106 -16
  18. package/dist/{chunk-SNZYN7UA.js.map → chunk-N3CK4AYW.js.map} +1 -1
  19. package/dist/{chunk-E4T2MQAV.js → chunk-PYYHDYTD.js} +3 -3
  20. package/dist/{chunk-E4T2MQAV.js.map → chunk-PYYHDYTD.js.map} +1 -1
  21. package/dist/{chunk-Z7BI7DE7.js → chunk-VIHQKKTZ.js} +45 -15
  22. package/dist/chunk-VIHQKKTZ.js.map +1 -0
  23. package/dist/{chunk-GF7KCLNR.js → chunk-VOFHP52Z.js} +29 -4
  24. package/dist/chunk-VOFHP52Z.js.map +1 -0
  25. package/dist/{chunk-66Q5VX2F.js → chunk-ZDIHVDTW.js} +6 -6
  26. package/dist/chunk-ZDIHVDTW.js.map +1 -0
  27. package/dist/{effect-BLpc68hI.d.ts → effect-Dr--GXRe.d.ts} +44 -36
  28. package/dist/{effect-result-AQSZ27vS.d.ts → effect-result-geymPT9w.d.ts} +39 -5
  29. package/dist/factory/index.d.ts +2 -2
  30. package/dist/factory/index.js +4 -4
  31. package/dist/factory-runtime/index.d.ts +2 -2
  32. package/dist/factory-runtime/index.js +10 -10
  33. package/dist/fixtures.d.ts +3 -3
  34. package/dist/fixtures.js +2 -2
  35. package/dist/i18n/index.js +1 -1
  36. package/dist/{index-CIlDAOq-.d.ts → index-C8mF8btS.d.ts} +20 -9
  37. package/dist/index.d.ts +12 -12
  38. package/dist/index.js +15 -15
  39. package/dist/kernel-wire.d.ts +2 -2
  40. package/dist/kernel-wire.js +1 -1
  41. package/dist/language/validation-codes.json +25 -0
  42. package/dist/language/vocabulary.json +2 -0
  43. package/dist/language-data.js +1 -1
  44. package/dist/patterns/component-mapping.json +1 -1
  45. package/dist/patterns/definitions.d.ts +1 -1
  46. package/dist/patterns/definitions.js +1 -1
  47. package/dist/patterns/event-contracts.json +1 -1
  48. package/dist/patterns/index.d.ts +2 -2
  49. package/dist/patterns/index.js +2 -2
  50. package/dist/patterns/patterns-registry.json +104 -14
  51. package/dist/patterns/registry.json +104 -14
  52. package/dist/{trait-SNHnODBK.d.ts → trait-D9MjuwGC.d.ts} +8 -8
  53. package/dist/types/index.d.ts +7 -7
  54. package/dist/types/index.js +7 -7
  55. package/dist/{types-DSAL7TDM.d.ts → types-Bi-KSa0a.d.ts} +2 -2
  56. package/package.json +4 -4
  57. package/dist/chunk-5WQ3U7NJ.js.map +0 -1
  58. package/dist/chunk-66Q5VX2F.js.map +0 -1
  59. package/dist/chunk-FGT5OS2Y.js.map +0 -1
  60. package/dist/chunk-GF7KCLNR.js.map +0 -1
  61. package/dist/chunk-PNGFWLHD.js.map +0 -1
  62. package/dist/chunk-Z7BI7DE7.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/os-grants.ts","../src/types/skeleton.ts","../src/types/state-machine.ts","../src/types/trait.ts","../src/types/page.ts","../src/types/service.ts","../src/types/orbital.ts","../src/protocols.ts","../src/types/schema.ts","../src/types/behavior-value.ts"],"names":["out","z","ProtocolSideSchema","ProtocolSpecSchema"],"mappings":";;;;;;AAiCO,SAAS,aAAA,CAAc,GAAyB,CAAA,EAAmC;AACxF,EAAA,MAAM,OAAO,CAAI,CAAA,EAA6B,MAAqC,CAAC,uBAAO,GAAA,CAAI,CAAC,GAAI,CAAA,IAAK,EAAC,EAAI,GAAI,KAAK,EAAG,CAAC,CAAC,CAAA;AAC5H,EAAA,MAAM,QAAQ,CAAO,CAAA,EAA6B,CAAA,EAA6B,GAAA,EAAuB,OAA+B,IAAA,KAAwC;AAC3K,IAAA,MAAMA,IAAAA,uBAAU,GAAA,EAAe;AAC/B,IAAA,KAAA,MAAW,KAAA,IAAS,CAAC,GAAI,CAAA,IAAK,IAAK,GAAI,CAAA,IAAK,EAAG,CAAA,EAAG;AAChD,MAAA,MAAM,IAAA,GAAOA,IAAAA,CAAI,GAAA,CAAI,GAAA,CAAI,KAAK,CAAC,CAAA;AAC/B,MAAAA,KAAI,GAAA,CAAI,GAAA,CAAI,KAAK,CAAA,EAAG,IAAA,KAAS,SAAY,KAAA,GAAQ,IAAA,CAAK,IAAA,EAAM,IAAA,CAAK,MAAM,IAAI,CAAA,EAAG,MAAM,KAAK,CAAC,CAAC,CAAC,CAAA;AAAA,IAC9F;AACA,IAAA,OAAO,CAAC,GAAGA,IAAAA,CAAI,MAAA,EAAQ,CAAA;AAAA,EACzB,CAAA;AACA,EAAA,MAAM,QAAA,GAAW,CAAI,CAAA,EAA6B,CAAA,KAAqC;AACrF,IAAA,MAAMA,I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,EAAUA,EAAE,MAAA,EAAO;AAAA,EACnB,MAAA,EAAQ,yBAAA;AAAA,EACR,KAAA,EAAOA,CAAAA,CAAE,KAAA,CAAM,eAAe,CAAA;AAAA,EAC9B,QAAA,EAAUA,CAAAA,CAAE,KAAA,CAAM,wBAAwB,CAAA;AAAA;AAAA,EAE1C,MAAMA,CAAAA,CAAE,KAAA,CAAMA,EAAE,MAAA,EAAQ,EAAE,QAAA;AAC5B,CAAC,EAAE,MAAA","file":"chunk-LPJ7GKRM.js","sourcesContent":["/**\n * OS grants: the program's closed-by-default `os/` permissions. The types are generated from `OsGrants` in\n * `orbital-core/crates/base/src/host/os_grants/mod.rs` (`generated/kernel-wire.ts`); only the union lives here.\n */\n\nimport { z } from \"zod\";\nimport type { AnchoredGrants, KvMode, OsGrants } from \"../generated/kernel-wire.js\";\n\nexport type {\n AnchoredExec,\n AnchoredFsGrant,\n AnchoredGrants,\n AnchoredNetGrant,\n DesktopKind,\n DevGrant,\n DevKind,\n FfiGrant,\n FsGrant,\n FsMode,\n GpuGrant,\n GrantAnchor,\n KernelGrant,\n KvMode,\n MemGrant,\n NetGrant,\n NetKind,\n NetPart,\n OsGrants,\n StdioKind,\n SysKind,\n} from \"../generated/kernel-wire.js\";\n\n/** Every grant either declares: lists deduplicated in first-seen order, an fs glob or net target named by both with its modes or kinds unioned. */\nexport function unionOsGrants(a: OsGrants | undefined, b: OsGrants | undefined): OsGrants {\n const list = <T>(x: readonly T[] | undefined, y: readonly T[] | undefined): T[] => [...new Set([...(x ?? []), ...(y ?? [])])];\n const keyed = <G, K>(x: readonly G[] | undefined, y: readonly G[] | undefined, key: (g: G) => string, items: (g: G) => readonly K[], make: (g: G, merged: K[]) => G): G[] => {\n const out = new Map<string, G>();\n for (const grant of [...(x ?? []), ...(y ?? [])]) {\n const seen = out.get(key(grant));\n out.set(key(grant), seen === undefined ? grant : make(seen, list(items(seen), items(grant))));\n }\n return [...out.values()];\n };\n const distinct = <T>(x: readonly T[] | undefined, y: readonly T[] | undefined): T[] => {\n const out = new Map<string, T>();\n for (const g of [...(x ?? []), ...(y ?? [])]) out.set(JSON.stringify(g), g);\n return [...out.values()];\n };\n const out: OsGrants = {};\n const fs = keyed(a?.fs, b?.fs, (g) => g.glob, (g) => g.modes, (g, modes) => ({ ...g, modes }));\n const net = keyed(a?.net, b?.net, (g) => g.target, (g) => g.kinds, (g, kinds) => ({ ...g, kinds }));\n if (fs.length > 0) out.fs = fs;\n if (net.length > 0) out.net = net;\n const dev = keyed(a?.dev, b?.dev, (g) => g.target, (g) => g.kinds, (g, kinds) => ({ ...g, kinds }));\n if (dev.length > 0) out.dev = dev;\n const mem = keyed(a?.mem, b?.mem, (g) => g.target, (g) => g.kinds, (g, kinds) => ({ ...g, kinds }));\n const kernel = keyed(a?.kernel, b?.kernel, (g) => g.target, (g) => g.kinds, (g, kinds) => ({ ...g, kinds }));\n const gpu = keyed(a?.gpu, b?.gpu, (g) => g.target, (g) => g.kinds, (g, kinds) => ({ ...g, kinds }));\n if (mem.length > 0) out.mem = mem;\n if (kernel.length > 0) out.kernel = kernel;\n if (gpu.length > 0) out.gpu = gpu;\n const kv: Record<string, KvMode[]> = {};\n for (const store of [...Object.keys(a?.kv ?? {}), ...Object.keys(b?.kv ?? {})]) {\n kv[store] = list(a?.kv?.[store], b?.kv?.[store]);\n }\n if (Object.keys(kv).length > 0) out.kv = kv;\n const anchored: AnchoredGrants = {};\n const anchoredFs = distinct(a?.anchored?.fs, b?.anchored?.fs);\n const anchoredExec = distinct(a?.anchored?.exec, b?.anchored?.exec);\n const anchoredNet = distinct(a?.anchored?.net, b?.anchored?.net);\n if (anchoredFs.length > 0) anchored.fs = anchoredFs;\n if (anchoredExec.length > 0) anchored.exec = anchoredExec;\n if (anchoredNet.length > 0) anchored.net = anchoredNet;\n if (Object.keys(anchored).length > 0) out.anchored = anchored;\n const exec = list(a?.exec, b?.exec);\n const env = list(a?.env, b?.env);\n const stdio = list(a?.stdio, b?.stdio);\n const sys = list(a?.sys, b?.sys);\n const desktop = list(a?.desktop, b?.desktop);\n const ffi = distinct(a?.ffi, b?.ffi);\n const credentials = list(a?.credentials, b?.credentials);\n if (ffi.length > 0) out.ffi = ffi;\n if (credentials.length > 0) out.credentials = credentials;\n if (exec.length > 0) out.exec = exec;\n if (env.length > 0) out.env = env;\n if (stdio.length > 0) out.stdio = stdio;\n if (sys.length > 0) out.sys = sys;\n if (desktop.length > 0) out.desktop = desktop;\n return out;\n}\n\n/** The boundary check for a program's `os-grants`: an object. The Rust serde parse owns the shape. */\nexport const OsGrantsSchema = z.custom<OsGrants>((v) => typeof v === \"object\" && v !== null && !Array.isArray(v));\n\n/** `deployment` — target name to the orbital names deployed there. */\nexport const DeploymentSchema = z.record(z.string(), z.array(z.string()));\nexport type Deployment = z.infer<typeof DeploymentSchema>;\n","/**\n * Awaiting-server skeletons — the platform-neutral contract.\n *\n * A server-backed trait renders through a server round trip (on entering the\n * screen and on events that open a new view). While it waits, an empty slot\n * (or embedded frame) shows a skeleton shaped like what the server WILL render:\n * - every data pattern declares its natural shape as the default of its\n * universal `skeleton` prop, and a `.lolo` element may override it\n * (`skeleton: list`, `skeleton: { variant: table, rows: 6 }`, `skeleton: none`);\n * - orbital-compiler (enrich, resolve/codegen only — never persisted) folds the\n * render a transition's server effects lead to into a `SkeletonNode` and\n * attaches it to the transition as `awaitRender`;\n * - each execution engine marks a trait as awaiting from server-leg send until\n * fold or error (`AwaitingTrait`), and the shell draws the node.\n */\nimport { z } from \"zod\";\n\n/** The skeleton shapes every shell can draw. */\nexport const SKELETON_VARIANTS = [\"header\", \"table\", \"list\", \"grid\", \"detail\", \"stats\", \"form\", \"card\", \"text\"] as const;\nexport type SkeletonVariant = (typeof SKELETON_VARIANTS)[number];\nexport const SkeletonVariantSchema = z.enum(SKELETON_VARIANTS);\n\n/** A sized shape. `rows` for table/list/text, cards for grid, field pairs for detail; `columns` for table/stats; `fields` for form. */\nexport type SkeletonShape = {\n variant: SkeletonVariant;\n rows?: number;\n columns?: number;\n fields?: number;\n};\n\nexport const SkeletonShapeSchema = z.object({\n variant: SkeletonVariantSchema,\n rows: z.number().int().positive().optional(),\n columns: z.number().int().positive().optional(),\n fields: z.number().int().positive().optional(),\n});\n\n/**\n * The universal `skeleton` prop value on a render-ui node: a shape name, a\n * sized shape, or `none` (this element contributes no skeleton).\n */\nexport type SkeletonSpec = SkeletonVariant | \"none\" | SkeletonShape;\n\nexport const SkeletonSpecSchema = z.union([SkeletonVariantSchema, z.literal(\"none\"), SkeletonShapeSchema]);\n\n/** A predicted skeleton: one shape, or a vertical stack of nodes (a container's children). */\nexport type SkeletonNode = { shape: SkeletonShape } | { stack: SkeletonNode[] };\n\nexport const SkeletonNodeSchema: z.ZodType<SkeletonNode> = z.lazy(() =>\n z.union([z.object({ shape: SkeletonShapeSchema }), z.object({ stack: z.array(SkeletonNodeSchema) })]),\n);\n\n/**\n * One predicted render a transition's server effects lead to: `trait` (the seed\n * itself, or a listener reached across the declared listens graph) will render\n * into `slot` something shaped like `skeleton`.\n */\nexport type AwaitRender = {\n trait: string;\n slot: string;\n skeleton: SkeletonNode;\n};\n\nexport const AwaitRenderSchema = z.object({\n trait: z.string(),\n slot: z.string(),\n skeleton: SkeletonNodeSchema,\n});\n\nexport type { AwaitingTrait } from '../generated/kernel-wire.js';\n","/**\n * State Machine Types (Self-Contained)\n *\n * Defines state machine types for traits.\n * Copied from schema/state-machine.ts to make orbitals/ self-contained.\n *\n * @packageDocumentation\n */\n\nimport { AwaitRenderSchema, type AwaitRender } from \"./skeleton.js\";\nimport { z } from \"zod\";\nimport { FieldProjectionSchema, type FieldProjection } from \"./projection.js\";\nimport type { Effect } from \"./effect.js\";\nimport { EffectSchema } from \"./effect.js\";\nimport type { Expression, SExpr } from \"./expression.js\";\nimport { ExpressionSchema, SExprListSchema, SExprSchema } from \"./expression.js\";\nimport type { EventId } from \"./identity.js\";\nimport { EventIdSchema } from \"./identity.js\";\n\n// ============================================================================\n// State\n// ============================================================================\n\n/**\n * Represents a state in the state machine\n */\nexport type State = {\n /** State name (unique identifier) */\n name: string;\n /** Whether this is the initial state */\n isInitial?: boolean;\n /** Whether this is a terminal state (no outgoing transitions expected) */\n isTerminal?: boolean;\n /** Whether this is a final state (legacy alias for isTerminal) */\n isFinal?: boolean;\n /** Human-readable description */\n description?: string;\n /** Effect names to run on entry */\n onEntry?: string[];\n /** Effect names to run on exit */\n onExit?: string[];\n /** `@holds <expr>`: the trait's `@entity` satisfies it whenever the trait is in this state, proved by `orb validate`. No runtime effect. */\n holds?: SExpr;\n};\n\nexport const StateSchema = z.object({\n name: z.string().min(1, \"State name is required\"),\n isInitial: z.boolean().optional(),\n isTerminal: z.boolean().optional(),\n isFinal: z.boolean().optional(),\n description: z.string().optional(),\n onEntry: z.array(z.string()).optional(),\n onExit: z.array(z.string()).optional(),\n holds: SExprSchema.optional(),\n});\n\n// ============================================================================\n// Event\n// ============================================================================\n\n/**\n * Payload field definition for events\n */\n/**\n * One condition of a payload field's `typeWhen` conditional list: \"when\n * config knob `knob` resolves to the literal whose string spelling is\n * `equals`, this field's type is `type`\". Declared DATA — authored in\n * `.lolo` as a type-level `match` block (§25 — REPLACED the `@typeWhen`\n * annotation spelling outright) — never a compiler-side predicate over a\n * specific knob name. This wire shape is `match`'s lowered form, unchanged.\n * Mirrors Rust `PayloadTypeWhen`.\n */\nexport type PayloadTypeWhen = {\n knob: string;\n equals: string;\n type: string;\n};\n\nexport const PayloadTypeWhenSchema: z.ZodType<PayloadTypeWhen> = z.object({\n knob: z.string().min(1),\n equals: z.string().min(1),\n type: z.string().min(1),\n});\n\nexport type PayloadField = {\n name: string;\n /**\n * Field type. Mirrors the Rust validator's acceptance: any non-empty\n * string. Primitives ('string' | 'number' | 'boolean' | 'object' |\n * 'array') are the canonical values; entity-name references like\n * 'CartItem' and array-of-entity references like '[CartItem]' are also\n * valid because the Rust IR's PayloadField.field_type is just a String.\n */\n type: string;\n required?: boolean;\n nullable?: boolean;\n /** Human-readable description. Mirrors Rust `PayloadField.description`. */\n description?: string;\n additionalProperties?: PayloadField;\n /** Closed value set (`\"a\" | \"b\"`) — element-wise for an array type. Mirrors Rust `PayloadField.values`. */\n values?: ReadonlyArray<string>;\n /** Structured property schema for object-typed payload fields (recursive). */\n properties?: ReadonlyArray<PayloadField>;\n /**\n * Declared knob-conditional type list (`match` in `.lolo`, §25). Resolved\n * and cleared once composed — the emitted `.orb` carries only the\n * resolved truth, never the conditional.\n */\n typeWhen?: ReadonlyArray<PayloadTypeWhen>;\n /**\n * The declared entity this field's value IS an instance of — stamped by\n * lowering when an entity-typed payload field (`row: Note`, scalar or\n * `[Note]` array — the array form names the element entity) is flattened\n * into `type: \"object\"`/`\"[object]\"` + `properties`. Mirrors Rust\n * `PayloadField.entity`. Absent for an anonymous struct/object field with\n * no declared entity — never inferred from shape or name.\n */\n entity?: string;\n /**\n * `.lolo` `T.f` / `[T.f]`: the declared field this field's value — each\n * element's, for an array type — was projected from. Mirrors Rust\n * `PayloadField.projected_from`.\n */\n projectedFrom?: FieldProjection;\n /**\n * The element type of an `array` field whose element is itself a typed field (a union of named types:\n * `[(Adv | string)]`), the nested form an entity field's `items` takes. Mirrors Rust `PayloadField.items`.\n */\n items?: PayloadField;\n};\n\n/**\n * The container a payload field's `type` string declares. `[X]` (and the\n * bare `array` primitive) is an array of `X`; `Map<K,V>` carries key/value\n * types; `object` is a plain object;\n * every other spelling — scalars, entity names, `@entity`, type variables,\n * unions — is opaque to a container check.\n */\nexport type PayloadTypeContainer =\n | { kind: 'array'; element: string }\n | { kind: 'map'; key: string; value: string }\n | { kind: 'object' }\n | { kind: 'opaque' };\n\nexport function payloadTypeContainer(type: string): PayloadTypeContainer {\n if (type === 'array') return { kind: 'array', element: '' };\n if (type === 'object') return { kind: 'object' };\n if (type.startsWith('Map<') && type.endsWith('>')) {\n const inner = type.slice(4, -1);\n const comma = inner.indexOf(',');\n if (comma > 0 && comma < inner.length - 1) {\n return { kind: 'map', key: inner.slice(0, comma).trim(), value: inner.slice(comma + 1).trim() };\n }\n }\n if (type.length > 2 && type.startsWith('[') && type.endsWith(']')) {\n return { kind: 'array', element: type.slice(1, -1) };\n }\n return { kind: 'opaque' };\n}\n\nconst payloadFieldShape = {\n type: z.string().min(1),\n required: z.boolean().optional(),\n nullable: z.boolean().optional(),\n description: z.string().optional(),\n additionalProperties: z.lazy(() => PayloadFieldDescriptorSchema).optional(),\n values: z.array(z.string()).optional(),\n properties: z.lazy(() => z.array(PayloadFieldSchema)).optional(),\n typeWhen: z.array(PayloadTypeWhenSchema).optional(),\n entity: z.string().min(1).optional(),\n projectedFrom: FieldProjectionSchema.optional(),\n items: z.lazy(() => PayloadFieldDescriptorSchema).optional(),\n};\n\n/** A payload field as a nested member (`additionalProperties`, `items`): the name may be empty. */\nexport const PayloadFieldDescriptorSchema: z.ZodType<PayloadField> = z.object({\n name: z.string(),\n ...payloadFieldShape,\n});\n\nexport const PayloadFieldSchema: z.ZodType<PayloadField> = z.object({\n name: z.string().min(1),\n ...payloadFieldShape,\n});\n\n/** What an inbound event declares: the hook name it receives and the event whose payload answers the request. */\nexport type InboundDeclaration = {\n name: string;\n answers: string;\n /** The sender check the runtime makes before the handler runs; its result is the payload's `verified`. */\n verifies?: InboundVerification;\n};\n\n/** `verifies \"<header>\" \"<CREDENTIAL>\"`: the request header that must equal the named credential (compared in constant time, never exposed to program data). */\nexport type InboundVerification = {\n header: string;\n credential: string;\n};\n\nexport const InboundVerificationSchema = z.object({\n header: z.string().min(1),\n credential: z.string().min(1),\n});\n\nexport const InboundDeclarationSchema = z.object({\n name: z.string().min(1),\n answers: z.string().min(1),\n verifies: InboundVerificationSchema.optional(),\n});\n\n/**\n * Represents an event that can trigger transitions\n */\nexport type Event = {\n /** Event key (UPPER_SNAKE_CASE) */\n key: string;\n /** V4 dual-carry id sibling of `key` — optional until the Phase-7 flip. */\n id?: EventId;\n /** Human-readable name */\n name: string;\n /** Description (authored `@description` on the emit/listen). */\n description?: string;\n /** User-vocabulary synonyms (comma-separated) — per-event analogue of a\n * field/config `@synonyms`. Feeds the curation event matcher. */\n synonyms?: string;\n /** Authoring tier (`essential`/`customization`/`advanced`/`internal`). */\n tier?: string;\n /** Expected payload structure */\n payloadSchema?: PayloadField[];\n /**\n * The entity this WHOLE payload was declared as (`type X = Event\n * <EntityName>`, the bare/concrete form) — mirrors Rust\n * `EventDefinition.payload_entity` (G4, `Almadar_Compiler_Gaps.md` §82).\n * Distinct from `PayloadField.entity` (a single NESTED field's value is\n * an entity instance): this marks the payload schema ITSELF as a 1:1\n * mirror of that entity's CURRENT fields. Consumed by\n * `resolveTraitTypeParamSentinels` (`resolver/sentinel-resolution.ts`)\n * to re-derive `payloadSchema` from the entity's post-`fields{}`/\n * `extend{}` shape once an orbital-import or trait-reference override\n * has materialized; kept in sync across entity renames the same one\n * owner `PayloadField.entity` already uses\n * (`renamePayloadEntityMarkers`, `reference-resolver.ts`).\n */\n payloadEntity?: string;\n /**\n * A declared input (`listens { EVENT -> input { … } }`): a client\n * outside the program (an API, an agent, an MCP client) may send this event to\n * the trait. Absent = not an input. Mirrors Rust `EventDefinition.input`.\n */\n input?: boolean;\n /**\n * Declared in the trait's own `listens { EVENT … }` block (the local form, input or\n * not): an input the author offers to the program. Absent = not declared there.\n * Mirrors Rust `EventDefinition.listened`.\n */\n listened?: boolean;\n /**\n * A declared inbound delivery (`listens { EVENT -> inbound \"name\" answers ANSWER { … } }`): the\n * host carries the request at `/api/hooks/<name>` and the kernel delivers it to this event; the\n * handler's emit of `answers` (`{ status, body }`) is the HTTP answer. Mirrors Rust\n * `EventDefinition.inbound`.\n */\n inbound?: InboundDeclaration;\n /** Domain vs System classification (optional, for analysis) */\n classification?: \"domain\" | \"system\";\n /** Semantic role of this event (optional, for analysis) */\n semanticRole?: string;\n};\n\nexport const EventSchema = z.object({\n key: z.string().min(1, \"Event key is required\"),\n id: EventIdSchema.optional(),\n name: z.string().min(1, \"Event name is required\"),\n description: z.string().optional(),\n synonyms: z.string().optional(),\n tier: z.string().optional(),\n payloadSchema: z.array(PayloadFieldSchema).optional(),\n payloadEntity: z.string().optional(),\n input: z.boolean().optional(),\n listened: z.boolean().optional(),\n inbound: InboundDeclarationSchema.optional(),\n classification: z.enum([\"domain\", \"system\"]).optional(),\n semanticRole: z.string().optional(),\n});\n\n// ============================================================================\n// Guard\n// ============================================================================\n\n/**\n * Represents a named guard condition.\n * Expression must be an S-expression.\n *\n * @example\n * {\n * name: \"hasHealth\",\n * expression: [\">\", \"@entity.health\", 0],\n * description: \"Check if entity has health remaining\"\n * }\n */\nexport type Guard = {\n name: string;\n /** Guard expression - S-expression array only */\n expression: Expression;\n description?: string;\n};\n\nexport const GuardSchema = z.object({\n name: z.string().min(1, \"Guard name is required\"),\n expression: ExpressionSchema,\n description: z.string().optional(),\n});\n\n// ============================================================================\n// Transition (Effect imported separately to avoid circular deps)\n// ============================================================================\n\n/**\n * Represents a transition between states.\n * Guards and effects must be S-expressions.\n *\n * @example\n * {\n * from: \"idle\",\n * to: \"running\",\n * event: \"START\",\n * guard: [\">\", \"@entity.fuel\", 0],\n * effects: [\n * [\"set\", \"@entity.status\", \"running\"],\n * [\"emit\", \"ENGINE_STARTED\"]\n * ]\n * }\n */\nexport type Transition = {\n /** Source state name */\n from: string;\n /** Target state name */\n to: string;\n /** Event key that triggers this transition */\n event: string;\n /** V4 dual-carry id sibling of `event` — optional until the Phase-7 flip. */\n eventId?: EventId;\n /** Guard expression - S-expression array */\n guard?: Expression | null;\n /** Effects to execute - S-expression arrays */\n effects?: Effect[];\n /** `@ensures <expr>`: the outcome contract owed at this transition (`@fromEntity` is the row before it); proved by `orb validate`, judged by `orb verify`. No runtime effect. */\n ensures?: SExpr[];\n /** Description */\n description?: string | null;\n /**\n * Predicted renders this transition's server effects lead to, used to draw\n * awaiting-server skeletons. Computed by orbital-compiler (enrich) in the\n * resolved schema only — never authored, never persisted in a registry `.orb`.\n */\n awaitRender?: AwaitRender[];\n};\n\nexport const TransitionSchema = z.object({\n from: z.string().min(1, \"Transition source state is required\"),\n to: z.string().min(1, \"Transition target state is required\"),\n event: z.string().min(1, \"Transition event is required\"),\n eventId: EventIdSchema.optional(),\n guard: ExpressionSchema.nullish(),\n effects: z.array(EffectSchema).optional(),\n ensures: SExprListSchema.optional(),\n description: z.string().nullish(),\n awaitRender: z.array(AwaitRenderSchema).optional(),\n});\n\n// ============================================================================\n// State Machine\n// ============================================================================\n\n/**\n * Complete state machine definition\n */\nexport type StateMachine = {\n /** All states in the machine */\n states: State[];\n /** All events that can be triggered */\n events: Event[];\n /** All transitions between states */\n transitions: Transition[];\n /** Named guard definitions */\n guards?: Guard[];\n};\n\nexport const StateMachineSchema = z.object({\n states: z.array(StateSchema).min(1, \"At least one state is required\"),\n events: z.array(EventSchema),\n transitions: z.array(TransitionSchema),\n guards: z.array(GuardSchema).optional(),\n});\n\n// ============================================================================\n// Type exports\n// ============================================================================\n\nexport type StateInput = z.input<typeof StateSchema>;\nexport type EventInput = z.input<typeof EventSchema>;\nexport type GuardInput = z.input<typeof GuardSchema>;\nexport type TransitionInput = z.input<typeof TransitionSchema>;\nexport type StateMachineInput = z.input<typeof StateMachineSchema>;\n\n// ============================================================================\n// Event Utilities\n// ============================================================================\n\n/**\n * Check if an event is a circuit event (not internal/system event).\n * Circuit events are user-defined events that participate in the closed circuit pattern.\n * Internal/system events start with underscore (e.g., _INIT, _TICK, _TIMER).\n *\n * @param {string} event - Event name to check\n * @returns {boolean} true if event is a circuit event (doesn't start with underscore)\n *\n * @example\n * isCircuitEvent('CREATE') // true\n * isCircuitEvent('SAVE') // true\n * isCircuitEvent('_INIT') // false (internal)\n * isCircuitEvent('_TICK') // false (internal)\n */\nexport function isCircuitEvent(event: string): boolean {\n return !event.startsWith('_');\n}\n","/**\n * Trait Types (Self-Contained)\n *\n * Defines trait types for behavioral patterns.\n * Self-contained - imports only from local orbital types.\n *\n * @packageDocumentation\n */\n\nimport { z } from 'zod';\nimport { FieldProjectionSchema, type FieldProjection } from './projection.js';\nimport type { TraitId, EntityId, EventId, PageId, OrbitalId } from './identity.js';\nimport { TraitIdSchema, EntityIdSchema, EventIdSchema, PageIdSchema, OrbitalIdSchema } from './identity.js';\nimport type { StateMachine, PayloadField } from './state-machine.js';\nimport { StateMachineSchema, PayloadFieldSchema, PayloadFieldDescriptorSchema } from './state-machine.js';\nimport type { Effect } from './effect.js';\nimport { EffectSchema, PatternObjectSchema } from './effect.js';\nimport type { Entity } from './entity.js';\nimport { EntitySchema } from './entity.js';\nimport type { AnyPatternConfig } from '../patterns/index.js';\nimport type { Expression, SExpr } from './expression.js';\nimport { ExpressionSchema, SExprSchema } from './expression.js';\nimport { JsonValueSchema } from './json.js';\nimport { EntityFieldSchema, TypeVariableSchema, type EntityField, type TypeVariable } from './field.js';\n\n// ============================================================================\n// Trait Configuration\n// ============================================================================\n\n/**\n * A single value in a trait's call-site `config: { ... }` block. Supports\n * scalars (string, number, boolean, null), arrays (e.g. `fields: [\"name\",\n * \"description\"]`), and nested objects. This is the authoring surface for\n * molecules to parameterize imported atoms: the atom's render-ui reads back\n * via `@config.<key>` bindings.\n */\nexport type TraitConfigValue =\n | string\n | number\n | boolean\n | null\n | ReadonlyArray<TraitConfigValue>\n | TraitConfigObject;\n\nexport type TraitConfigObject = {\n readonly [key: string]: TraitConfigValue;\n};\n\nexport type TraitConfig = TraitConfigObject;\n\n/** Zod schema for TraitConfig. Recursive via z.lazy to allow nested structures. */\nexport const TraitConfigValueSchema: z.ZodType<TraitConfigValue> = z.lazy(() =>\n z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(TraitConfigValueSchema),\n z.record(z.string(), TraitConfigValueSchema),\n ])\n);\n\nexport const TraitConfigSchema: z.ZodType<TraitConfig> = z.record(z.string(), TraitConfigValueSchema);\n\n/**\n * A single entry in a call-site `config { }` override block. Either a plain\n * wiring value (`TraitConfigValue` — string, number, bool, array, object) or\n * a fully-annotated re-declaration (`ConfigFieldDeclaration` — carries `type`,\n * optional `label`/`description`/`synonyms`/`tier`). Disambiguated at runtime\n * by `isCallSiteConfigDeclaration`: the presence of a `\"type\"` string key\n * marks the annotated form.\n *\n * The `.orb` compiler emits plain values for wiring entries and\n * `{ type, default, ... }` objects for annotated entries. Consumers that only\n * need the value (e.g. `apply-params-to-orb.ts`) read `entry` directly for\n * primitives or `entry.default` for the declaration form.\n */\nexport type CallSiteConfigEntry = TraitConfigValue | ConfigFieldDeclaration;\n\n/** Typed map of call-site config entries (one per knob). */\nexport type CallSiteConfig = Readonly<Record<string, CallSiteConfigEntry>>;\n\n/**\n * Type guard: returns `true` when `entry` is an annotated `ConfigFieldDeclaration`\n * (a config-field SCHEMA: a `\"type\"` string key AND a `\"default\"` value slot)\n * rather than a plain wiring value or a render value object.\n *\n * The `\"default\"` requirement disambiguates a declaration from a `render-ui`\n * VALUE object (e.g. `{ type: \"tabs\", items: \"@entity.items\", ... }`) that\n * coincidentally carries a UI-component `type` key — such a value has no\n * `default` slot and is a `TraitConfigValue`, not a schema declaration. Every\n * annotated config field lowered from `.lolo` carries a `default`; misreading a\n * render value as a declaration drops it straight into the `config` map where\n * Rust's `serde` rejects its inner fields (e.g. `items` is a binding string,\n * not a `FieldDefinition`).\n */\nexport function isCallSiteConfigDeclaration(\n entry: CallSiteConfigEntry,\n): entry is ConfigFieldDeclaration {\n return (\n typeof entry === 'object' &&\n entry !== null &&\n !Array.isArray(entry) &&\n 'type' in entry &&\n typeof entry.type === 'string' &&\n 'default' in entry\n );\n}\n\n/**\n * Whether a call-site config entry RE-DECLARES its knob (legal for a knob the trait does not\n * declare) rather than setting a value. Twin of orbital-core `ConfigField::is_declaration_form`:\n * a value wrapped as `{ type: 'unknown', default }` (what `mergeCallSiteConfigOverrides` builds)\n * is a value; a typed declaration, or one carrying `label`/`description`/`synonyms`/`tier`, is not.\n */\nexport function isConfigRedeclaration(entry: CallSiteConfigEntry): boolean {\n if (!isCallSiteConfigDeclaration(entry)) return false;\n if (entry.wired === true) return false;\n return (\n entry.type !== 'unknown' ||\n entry.label !== undefined ||\n entry.description !== undefined ||\n entry.synonyms !== undefined ||\n entry.tier !== undefined\n );\n}\n\n/** Metadata keys that only ever appear on a declared config-field SCHEMA\n * (never on a render-value object that merely carries a UI `type` key). */\nconst CONFIG_DECLARATION_META_KEYS = ['label', 'description', 'tier', 'synonyms', 'values'] as const;\n\n/**\n * Type guard: `entry` is a declared config-field SCHEMA — a string `type` plus\n * EITHER a `default` slot OR declaration metadata (`label`/`description`/\n * `tier`/`synonyms`/`values`). Broader than `isCallSiteConfigDeclaration`,\n * which requires a `default`: a field declared with no default (e.g.\n * `leftIcon : icon` → `{ type: \"icon\", label, description, tier }`) is still a\n * schema, and its runtime VALUE is its (absent → `undefined`) default, NOT the\n * schema object itself. A render-value object that coincidentally has a `type`\n * key (e.g. `{ type: \"tabs\", items: … }`) carries none of these metadata keys\n * and is therefore left untouched as a plain value.\n */\nexport function isConfigFieldSchema(entry: CallSiteConfigEntry): entry is ConfigFieldDeclaration {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return false;\n if (!('type' in entry) || typeof (entry as { type?: TraitConfigValue }).type !== 'string') return false;\n return 'default' in entry || CONFIG_DECLARATION_META_KEYS.some((k) => k in entry);\n}\n\n/**\n * Convert a call-site config map into plain runtime values.\n *\n * A `CallSiteConfig` may contain either plain wiring values\n * (`TraitConfigValue`) or annotated `ConfigFieldDeclaration` objects\n * (`{ type, default, label, ... }`). Both the JS interpreter\n * (`@almadar/runtime`) and the render substrate (`@almadar/ui`) need this\n * extraction, so it lives here — the most-upstream package they share —\n * rather than being duplicated in each.\n *\n * A declared field with no `default` yields no value (dropped), as the\n * kernel reads it. Leaking such a schema object through as a\n * value made `@config.leftIcon` resolve to `{ type: \"icon\", … }`, which the\n * render substrate then mounted as an element and passed to `Input`'s icon\n * slot → \"Element type is invalid: got <SlotContentRenderer />\".\n */\nexport function normalizeCallSiteConfigToValues(\n config: CallSiteConfig | undefined,\n): TraitConfig | undefined {\n if (config === undefined) {\n return undefined;\n }\n\n const out: Record<string, TraitConfigValue> = {};\n let hasAny = false;\n for (const [key, entry] of Object.entries(config)) {\n const value = isConfigFieldSchema(entry)\n ? entry.default\n : entry;\n if (value !== undefined) {\n out[key] = value;\n hasAny = true;\n }\n }\n\n return hasAny ? out : undefined;\n}\n\n/**\n * Merge call-site config overrides onto a base `CallSiteConfig`. Every entry\n * in the result is a `ConfigField` (Rust's `HashMap<String, ConfigField>`):\n * bare values — base AND override — are wrapped as `{ type: 'unknown', default }`\n * when not already a declaration. Override folds into an existing declaration's\n * `default` field.\n */\nexport function mergeCallSiteConfigOverrides(\n base: CallSiteConfig,\n overrides: CallSiteConfig,\n): Record<string, ConfigFieldDeclaration> {\n const next: Record<string, ConfigFieldDeclaration> = {};\n for (const [k, entry] of Object.entries(base)) {\n next[k] = isConfigFieldSchema(entry)\n ? entry\n : { type: 'unknown', default: entry };\n }\n for (const [k, v] of Object.entries(overrides)) {\n if (isCallSiteConfigDeclaration(v)) {\n next[k] = v;\n continue;\n }\n const existing = base[k];\n next[k] = existing !== undefined && isConfigFieldSchema(existing)\n ? { ...existing, default: v }\n : { type: 'unknown', default: v };\n }\n return next;\n}\n\n/**\n * Per-field entry in a trait's DECLARED `config { }` schema as it lives\n * on the `.orb` JSON: `{ type: \"string\" | \"[string]\" | \"object\" | ...,\n * default?: <value> }`. Distinct from `TraitConfigValue` (which is the\n * resolved runtime value). The runtime reads `default` to seed the\n * `@config.X` binding context when no call-site override is supplied.\n *\n * Authored as `config { foo : string = \"bar\" }` in `.lolo`; lowered to\n * `{ foo: { type: \"string\", default: \"bar\" } }` in `.orb`. The optional\n * metadata fields below (`label`/`description`/`tier`/`values`/`synonyms`)\n * carry the `.lolo` `@label`/`@description`/`@tier`/`@synonyms` annotations and\n * the enum member list through lowering — consumed by config-driven UI\n * (e.g. the playground property inspector) to render typed controls.\n */\n/**\n * The reference config-field types (V4-W5). A config knob typed `entity`,\n * `trait`, or `event` holds a REFERENCE (an entity/trait/event name), not a\n * plain value — so the stamp records the referenced node's id on the field\n * (`ConfigFieldDeclaration.refId`) and both execution paths resolve the value to\n * the node's CURRENT name by id, exactly like `entityRefIds`/`traitEmbedIds`.\n * This is the deterministic, source-tagged contract that lets a declaration-only\n * rename flow through a config value without any name-scanning heuristic.\n */\nexport const REFERENCE_CONFIG_TYPES = ['entity', 'trait', 'event'] as const;\nexport type ReferenceConfigType = (typeof REFERENCE_CONFIG_TYPES)[number];\n\n/** True when a config field's `type` marks its value as an entity/trait/event reference. */\nexport function isReferenceConfigType(type: string): type is ReferenceConfigType {\n return (REFERENCE_CONFIG_TYPES as readonly string[]).includes(type);\n}\n\n/**\n * The secret config-field types. A config knob typed `secret` holds a\n * credential REFERENCE (an env-var key name for `resolveCredentialRef`) —\n * and, as defense-in-depth against a host wrongly inlining material, its\n * VALUE must never flow into spec.json, traces, plan snapshots, or factory\n * bakes in cleartext: consumers mask it (see `maskSecretConfigValues`) and\n * UI password-renders the knob. `.lolo` accepts `: secret` as a config-field\n * type (I-29, 2026-08-23 — previously the parser silently read it as a\n * meaningless named type); this contract is the single deterministic source\n * downstream consumers (studio, verifiers, rabit bakes) key on.\n */\nexport const SECRET_CONFIG_TYPES = ['secret'] as const;\nexport type SecretConfigType = (typeof SECRET_CONFIG_TYPES)[number];\n\n/** True when a config field's `type` marks its value as a credential to be masked. */\nexport function isSecretConfigType(type: string): type is SecretConfigType {\n return (SECRET_CONFIG_TYPES as readonly string[]).includes(type);\n}\n\n/**\n * Return `values` with every `secret`-declared field's string value masked to\n * its last 4 characters (shorter values fully masked). Non-secret fields and\n * non-string values pass through untouched. Use before echoing call-site\n * config into traces, spec snapshots, or logs.\n */\nexport function maskSecretConfigValues(\n config: DeclaredTraitConfig,\n values: TraitConfig,\n): TraitConfig {\n const masked: Record<string, TraitConfigValue> = {};\n for (const [key, value] of Object.entries(values)) {\n const decl = config[key];\n if (decl !== undefined && isSecretConfigType(decl.type) && typeof value === 'string' && value.length > 0) {\n masked[key] = value.length > 4 ? `••••${value.slice(-4)}` : '••••';\n } else {\n masked[key] = value;\n }\n }\n return masked;\n}\n\n/**\n * A `trait`-typed knob's override may spell the unbound sentinel as the bare\n * `none` — `orbital-lolo`'s plain-wiring grammar has no static type at the\n * call site, so it lowers `none` to the literal string `\"none\"` like any\n * other identifier. This is the one place the field's declared `type` is\n * known, so it is where the string is canonicalized to `null` — the\n * language's single \"unbound\" representation for a `trait`-typed knob\n * (owner ruling 2026-09-13), mirroring the compiler's\n * `canonicalize_unbound_trait_override` (`orbital-compiler/src/phases/\n * inline/trait.rs`). A no-op for every other type or value.\n */\nfunction canonicalizeUnboundTraitOverride(fieldType: string, value: TraitConfigValue): TraitConfigValue {\n return fieldType === 'trait' && value === 'none' ? null : value;\n}\n\n/**\n * Fold an override value map onto a `DeclaredTraitConfig`'s per-knob\n * `default`, mirroring the compiler's `ORB_O_CONFIG_UNKNOWN_KEY` check.\n * Single owner for the factory-runtime overlay (`applyParamsToOrb` folding\n * `OrbitalFactoryParams.config`) and the runtime's `OrbitalRefObject.config`\n * fold (`reference-resolver.ts`) — same operation, two call sites.\n *\n * Throws when `overrides` names a key `declared` does not declare. Callers\n * validate the override keys against the manifest / upstream config first\n * (`validateOrbitalFactoryParams`, the resolver's own pre-check), so this is\n * a should-never-happen guard, not a user-facing error path.\n */\nexport function overrideDeclaredKnobs(\n declared: DeclaredTraitConfig,\n overrides: Readonly<Record<string, TraitConfigValue>>,\n): DeclaredTraitConfig {\n const out: Record<string, ConfigFieldDeclaration> = { ...declared };\n for (const key of Object.keys(overrides)) {\n const field = declared[key];\n if (field === undefined) {\n throw new Error(\n `overrideDeclaredKnobs: config override \"${key}\" is not a declared knob ` +\n `(ORB_O_CONFIG_UNKNOWN_KEY). Declared: ${Object.keys(declared).join(', ') || '(none)'}`,\n );\n }\n out[key] = { ...field, default: canonicalizeUnboundTraitOverride(field.type, overrides[key]) };\n }\n return out;\n}\n\nexport type ConfigFieldDeclaration = {\n readonly nullable?: boolean;\n readonly additionalProperties?: EntityField;\n readonly type: string;\n readonly default?: TraitConfigValue;\n /**\n * V4-W5 dual-carry id — set by the stamp when `type` is a reference config\n * type (`entity`/`trait`/`event`): the stable id of the entity/trait/event\n * the field's value names. Readers resolve the value to that node's current\n * name by id (rename-proof); absent for non-reference fields.\n */\n readonly refId?: string;\n /** Marks the knob as mandatory at every call site (own-page binding exempt). `required` + `default` may coexist — the default only serves the trait's own demo page. */\n readonly required?: boolean;\n /** `@label` — human-readable control label. */\n readonly label?: string;\n /** `@description` — help/tooltip text for the field. */\n readonly description?: string;\n /** `@tier` — disclosure tier: `presentation`|`domain`|`policy`|`infra`|`internal`. */\n readonly tier?: string;\n /** Enum members when the field's type is a string union — drives a select control. */\n readonly values?: ReadonlyArray<string>;\n /** `@synonyms` — comma-separated vocabulary synonyms (metadata). */\n readonly synonyms?: string;\n /** Structured per-item schema for array-of-object fields — `edges : [{from: string!, …}]` in `.lolo` lowers to `{ type: \"object\", properties: {…} }`. */\n readonly items?: ConfigFieldItemsDeclaration;\n /** Structured property schema for object-typed config fields (no items wrapper). */\n readonly properties?: Readonly<Record<string, TraitEntityField>>;\n /**\n * Provenance for a collapsed knob forward. The L2 inline phase (and the\n * runtime resolver) fold a trait's `default: \"@config.<knob>\"` (or a\n * call-site override of the same shape) down to the resolved value, so\n * the resolved schema no longer carries the literal `@config.<knob>`\n * token anywhere. `forwardedFrom` records that token — the original\n * app/orbital-level knob name this field's value came from — so a\n * dead-knob check (`ORB_O_CONFIG_DEAD_KNOB` / `orbital-config-knob-unforwarded`)\n * can still recognize the knob as forwarded on an already-resolved\n * schema. Absent when the field's `default`/value was authored directly\n * (not a forward), or on an unresolved schema where the `@config.<knob>`\n * token itself is still present.\n */\n readonly forwardedFrom?: string;\n /**\n * The `@config.<knob>` tokens nested INSIDE this field's value (an array\n * element or object member, e.g. `metrics[].target`) that the resolver\n * folded to their values — the list twin of `forwardedFrom`, so the\n * dead-knob check still sees those knobs as read. Absent when nothing\n * nested resolved. Compiled-path wire key `nestedForwardedFrom`.\n */\n readonly nestedForwardedFrom?: ReadonlyArray<string>;\n /**\n * The definer knob this field is the payload companion of, when its\n * declared type was `@payload(<knob>)`: the L2 sigil pass rewrites the\n * sentinel to the resolved payload type and records the knob here, the\n * same way `forwardedFrom` keeps a provenance the resolved `default` /\n * `type` can no longer show. Absent for any field that was never a\n * `@payload(<knob>)` sentinel. Compiled-path wire key `payloadFor`.\n */\n readonly payloadFor?: string;\n /** `.lolo` `T.f`: the declared field this knob's type was projected from. */\n readonly projectedFrom?: FieldProjection;\n /** `field R T`: the record `R` as a type string (`@entity`, `@payload(knob)`, an entity or alias name, `$r`). */\n readonly record?: string;\n /** A call-site entry that wires a value into a knob the trait declares; `type` then carries the SOURCE knob's type (`unknown` for a literal). */\n readonly wired?: boolean;\n};\n\nexport type ConfigFieldItemsDeclaration = {\n readonly nullable?: boolean;\n readonly additionalProperties?: EntityField;\n readonly type?: string;\n /** Absent for arrays of scalars (`items: { type: \"string\" }`). */\n readonly properties?: Readonly<Record<string, TraitEntityField>>;\n /** Nested per-item schema for arrays of arrays (recursive). */\n readonly items?: ConfigFieldItemsDeclaration;\n /** Union member names when the item type is a union — including a by-name recursive back-reference. */\n readonly values?: ReadonlyArray<string>;\n};\n\nexport const ConfigFieldItemsDeclarationSchema: z.ZodType<ConfigFieldItemsDeclaration, object> = z.lazy(() =>\n z.object({\n nullable: z.boolean().optional(),\n additionalProperties: EntityFieldSchema.optional(),\n type: z.string().optional(),\n properties: z.record(z.string(), TraitEntityFieldSchema).optional(),\n items: ConfigFieldItemsDeclarationSchema.optional(),\n values: z.array(z.string()).optional(),\n }),\n);\n\nexport const ConfigFieldDeclarationSchema: z.ZodType<ConfigFieldDeclaration, object> = z.object({\n nullable: z.boolean().optional(),\n additionalProperties: EntityFieldSchema.optional(),\n type: z.string(),\n default: TraitConfigValueSchema.optional(),\n refId: z.string().optional(),\n required: z.boolean().optional(),\n label: z.string().optional(),\n description: z.string().optional(),\n tier: z.string().optional(),\n values: z.array(z.string()).optional(),\n synonyms: z.string().optional(),\n items: ConfigFieldItemsDeclarationSchema.optional(),\n properties: z.lazy(() => z.record(z.string(), TraitEntityFieldSchema)).optional(),\n forwardedFrom: z.string().optional(),\n nestedForwardedFrom: z.array(z.string()).optional(),\n payloadFor: z.string().optional(),\n projectedFrom: FieldProjectionSchema.optional(),\n record: z.string().optional(),\n wired: z.boolean().optional(),\n});\n\n/**\n * Map of declared config fields keyed by name. Lives on `Trait.config`\n * for atoms/molecules that expose typed configuration to consumers.\n */\nexport type DeclaredTraitConfig = Readonly<Record<string, ConfigFieldDeclaration>>;\n\nexport const DeclaredTraitConfigSchema: z.ZodType<DeclaredTraitConfig, Record<string, object>> = z.record(z.string(),\n ConfigFieldDeclarationSchema,\n);\n\n// ============================================================================\n// Trait Entity Field (simplified)\n// ============================================================================\n\n/**\n * Field types for trait data entities\n */\n// `trait` / `slot` / `pattern` mirror Rust's `FieldType::{Trait, Slot, Pattern}`\n// (orbital-core schema/types.rs) — config-field-only types: a `@trait.X`\n// embed slot, a UI slot name, a pattern type name.\n// `union` is the closed variant type — a real .lolo/.orb type, so the\n// trait-side mirror must carry it or generated factories fail DTS.\nexport type TraitFieldType = 'string' | 'number' | 'boolean' | 'date' | 'array' | 'object' | 'timestamp' | 'datetime' | 'instant' | 'enum' | 'email' | 'url' | 'phone' | 'uuid' | 'image' | 'bytes' | 'trait' | 'slot' | 'pattern' | 'node' | 'event' | 'EventAddress' | 'CallKey' | 'SExpr' | 'union' | 'tuple' | 'field' | TypeVariable;\n\n/** Every `TraitFieldType`, as a runtime array — the ONE list `TraitEntityFieldSchema`\n * and `RequiredFieldSchema` both read. Two separate inline copies of this enum had\n * already fallen behind the TS type twice (`node` missing, then `union`\n * missing) — mirrors the `FIELD_TYPES` fix for `FieldType` in `field.ts`. */\nexport const TRAIT_FIELD_TYPES = [\n 'string',\n 'number',\n 'boolean',\n 'date',\n 'array',\n 'object',\n 'timestamp',\n 'datetime',\n 'instant',\n 'enum',\n 'email',\n 'url',\n 'phone',\n 'uuid',\n 'image',\n 'bytes',\n 'trait',\n 'slot',\n 'pattern',\n 'node',\n 'event',\n 'EventAddress',\n 'CallKey',\n 'SExpr',\n 'union',\n 'tuple',\n 'field',\n] as const satisfies readonly TraitFieldType[];\n\n/**\n * Simplified field for trait data entities\n */\nexport type TraitEntityField = {\n nullable?: boolean;\n additionalProperties?: EntityField;\n name: string;\n type: TraitFieldType;\n required?: boolean;\n /** Field default parsed from `.orb` — always a JSON-shaped value. */\n default?: TraitConfigValue;\n values?: string[];\n /** Structured per-item schema for array-of-object fields (recursive). */\n items?: ConfigFieldItemsDeclaration;\n /** Structured property schema for object-typed entity fields. */\n properties?: Readonly<Record<string, TraitEntityField>>;\n /** `@payload(.<sibling>)`: an `object` with no `properties` is the declared payload of the event its sibling member names. */\n record?: string;\n};\n\nexport const TraitEntityFieldSchema: z.ZodType<TraitEntityField, object> = z.object({\n nullable: z.boolean().optional(),\n additionalProperties: EntityFieldSchema.optional(),\n name: z.string().min(1),\n type: z.union([z.enum(TRAIT_FIELD_TYPES), TypeVariableSchema]),\n required: z.boolean().optional(),\n default: TraitConfigValueSchema.optional(),\n values: z.array(z.string()).optional(),\n items: ConfigFieldItemsDeclarationSchema.optional(),\n properties: z.lazy(() => z.record(z.string(), TraitEntityFieldSchema)).optional(),\n record: z.string().optional(),\n});\n\n// ============================================================================\n// Trait Data Entity\n// ============================================================================\n\n/**\n * Simplified data entity for traits\n */\nexport type TraitDataEntity = {\n name: string;\n collection?: string;\n fields: TraitEntityField[];\n timestamps?: boolean;\n description?: string;\n runtime?: boolean;\n singleton?: boolean;\n pages?: string[];\n};\n\nexport const TraitDataEntitySchema = z.object({\n name: z.string().min(1),\n collection: z.string().optional(),\n fields: z.array(TraitEntityFieldSchema).min(1),\n timestamps: z.boolean().optional(),\n description: z.string().optional(),\n runtime: z.boolean().optional(),\n singleton: z.boolean().optional(),\n pages: z.array(z.string()).optional(),\n});\n\n// ============================================================================\n// Trait Tick\n// ============================================================================\n\n/**\n * Tick rule for traits.\n * Guards can be legacy strings or S-expressions.\n * Effects can be typed Effect objects or S-expressions.\n */\nexport type TraitTick = {\n name: string;\n description?: string;\n priority?: number;\n interval: string | number;\n appliesTo?: string[];\n /** `[background]`: runs with no client mounted; otherwise paused while no client has the trait mounted. */\n runsInBackground?: boolean;\n /** `[visible]`: a browser tick that pauses while its trait's rendered output is off screen. */\n whileVisible?: boolean;\n pages?: string[];\n /** V4 dual-carry id sibling of `pages` — optional until the Phase-7 flip. */\n pageIds?: PageId[];\n /** Guard expression - string (legacy) or S-expression array */\n guard?: Expression;\n /** Effects to execute (S-expressions) */\n effects: Effect[];\n /**\n * Events this tick emits.\n * Must reference events defined in trait's emits array.\n * Used for validation and documentation.\n */\n emits?: string[];\n /** V4 dual-carry id sibling of `emits` — optional until the Phase-7 flip. */\n emitIds?: EventId[];\n};\n\n/** `\"500ms\"` / `\"5s\"` / `\"1m\"` / `\"1h\"` / `\"1d\"` — the duration form both schedulers parse. */\nconst DURATION_INTERVAL = /^\\d+(ms|s|m|h|d)$/;\n/** A 5-field cron expression, e.g. `\"0 9 * * *\"`. */\nconst CRON_INTERVAL = /^\\S+(\\s+\\S+){4}$/;\n\n/**\n * A tick's cadence: `\"frame\"`, a positive number of milliseconds, a duration\n * string, or a cron expression.\n *\n * This schema previously accepted only `\"frame\"` or a number, while `TraitTick`\n * declared `string | number` and the kernel's tick clock already parsed durations and cron\n * (`TickClock` → `cron::parse_cron`).\n * The gate therefore rejected every cron/duration tick before its runtime could\n * run it — `std-data-erasure`'s hourly `executionScan` made the whole orbital\n * unloadable in the interpreter with only `traits.N: Invalid input` to go on.\n */\nexport const TickIntervalSchema = z.union([\n z.literal('frame'),\n z.number().positive(),\n z.string().refine((v) => DURATION_INTERVAL.test(v) || CRON_INTERVAL.test(v), {\n message:\n 'interval must be \"frame\", a positive number of milliseconds, a duration (\"500ms\"/\"5s\"/\"1m\"/\"1h\"/\"1d\"), or a 5-field cron expression (\"0 9 * * *\")',\n }),\n]);\n\nexport const TraitTickSchema = z.object({\n name: z.string().min(1),\n description: z.string().optional(),\n priority: z.number().optional(),\n interval: TickIntervalSchema,\n appliesTo: z.array(z.string()).optional(),\n runsInBackground: z.boolean().optional(),\n whileVisible: z.boolean().optional(),\n pages: z.array(z.string()).optional(),\n pageIds: z.array(PageIdSchema).optional(),\n guard: ExpressionSchema.optional(),\n effects: z.array(EffectSchema).min(1),\n emits: z.array(z.string()).optional(),\n emitIds: z.array(EventIdSchema).optional(),\n});\n\n// ============================================================================\n// Event Scope\n// ============================================================================\n\n/**\n * Event scope determines visibility:\n * - 'internal': Trait-to-trait within same orbital (default)\n * - 'external': Exposed for cross-orbital communication\n */\nexport type EventScope = 'internal' | 'external';\n\nexport const EventScopeSchema = z.enum(['internal', 'external']);\n\n// ============================================================================\n// Event Payload Field\n// ============================================================================\n\n/**\n * Payload field definition for events: the one {@link PayloadField} (Rust `PayloadField`),\n * re-exported under the event-contract name.\n */\nexport type EventPayloadField = PayloadField;\n\nexport const EventPayloadTypeMemberSchema: z.ZodType<EventPayloadField> = PayloadFieldDescriptorSchema;\n\nexport const EventPayloadFieldSchema: z.ZodType<EventPayloadField> = PayloadFieldSchema;\n\n// ============================================================================\n// Trait Event Contract\n// ============================================================================\n\n/**\n * Event contract for events a trait emits.\n * Declares the event name, scope, and payload schema.\n */\nexport type TraitEventContract = {\n /** Event name (UPPER_SNAKE_CASE) */\n event: string;\n /** V4 dual-carry id sibling of `event` — optional until the Phase-7 flip. */\n eventId?: EventId;\n /** Human-readable description */\n description?: string;\n /** User-vocabulary synonyms (comma-separated) — the per-event analogue of a\n * field/config `@synonyms`. Feeds the curation event matcher. */\n synonyms?: string;\n /** Authoring tier (`essential`/`customization`/`advanced`/`internal`). */\n tier?: string;\n /**\n * The config knob whose value DEFINES this event's name, when the emit was\n * authored as `emits { @config.<knob> }`. Captured at L1, where the\n * `@config.X` spelling still exists — after inlining, `event` holds the\n * resolved literal and the fact that it came from a knob is otherwise\n * unrecoverable.\n *\n * A definer knob CREATES an event name rather than referencing one, which\n * is why consumers must not pin such a knob to the trait's existing event\n * vocabulary: doing so forbids the very name it exists to introduce.\n */\n definerKnob?: string;\n /**\n * `true` when `scope` was set by a CALL-SITE `emitsScope` override (the\n * inline phase applies it), not by the source atom's own `-> external`\n * declaration. An atom declaring its emits external is an unexamined\n * default (nearly every atom does), while a composition restating it is\n * the consumer's own deferral — the dead-control check honours it as an\n * exemption. See ORB-X-EXTERNAL-EMIT-EXEMPTION.\n */\n scopeOverridden?: boolean;\n /** Payload schema — declarative type info for the event's payload.\n * Distinct from the runtime payload value (`@payload.X` bindings,\n * `EventPayload`) which is a separate concept. */\n payloadSchema?: EventPayloadField[];\n /**\n * Same marker as `Event.payloadEntity` (`state-machine.ts`) — this\n * emit's payload was declared `type X = Event <EntityName>` and is a\n * flat mirror of that entity's fields. See that field's doc for the\n * full contract (G4, `Almadar_Compiler_Gaps.md` §82).\n */\n payloadEntity?: string;\n /**\n * Event scope:\n * - 'internal': Trait-to-trait within same orbital (default)\n * - 'external': Exposed for cross-orbital communication\n */\n scope?: EventScope;\n};\n\n/**\n * `@config.<knob>` is the only legal reference form for an emit/listen\n * event name (Option B — the declared event name resolves to a\n * `string`- or `event`-typed config knob's value at inline/resolve time).\n * Matches the Rust lexer's dotted-sigil body (`config.<ident>`, no further\n * dots).\n */\nexport const CONFIG_REF_EVENT_PATTERN = /^@config\\.[A-Za-z_][A-Za-z0-9_]*$/;\n\n/** Returns the knob identifier when `event` is a `@config.<knob>` reference, else `undefined`. */\nexport function configRefEventKnob(event: string): string | undefined {\n return CONFIG_REF_EVENT_PATTERN.test(event) ? event.slice('@config.'.length) : undefined;\n}\n\n/** Why a `@config.<knob>` emit/listen event-name reference failed to resolve. */\nexport type ConfigRefEventError = 'unknown-knob' | 'not-string' | 'no-default';\n\n/**\n * Resolve a `@config.<knob>` emit/listen event-name reference to its\n * concrete literal, given the trait's declared config schema and the\n * effective config value map (call-site override folded over declared\n * default — same precedence the Rust inline phase's `effective_config`\n * uses). The single JS-side owner of this resolution rule; mirrors\n * `resolve_config_ref_event_name` in `orbital-core::schema` (Rust).\n * Returns the resolved literal, or the specific contract clause that failed.\n */\nexport function resolveConfigRefEventName(\n event: string,\n declaredConfig: DeclaredTraitConfig | undefined,\n effectiveConfig: Readonly<Record<string, TraitConfigValue>>,\n): { readonly ok: true; readonly value: string } | { readonly ok: false; readonly error: ConfigRefEventError } {\n const knob = configRefEventKnob(event);\n if (knob === undefined) return { ok: false, error: 'unknown-knob' };\n const field = declaredConfig?.[knob];\n if (field === undefined) return { ok: false, error: 'unknown-knob' };\n // A-UNIFY: definer knobs (whose value CREATES the event name) spell\n // `: event` same as reference knobs — the declared field type is\n // `'string' | 'event'`, the VALUE still must be a plain string literal.\n if (field.type !== 'string' && field.type !== 'event') return { ok: false, error: 'not-string' };\n if (field.default === undefined) return { ok: false, error: 'no-default' };\n const value = effectiveConfig[knob];\n if (typeof value !== 'string') return { ok: false, error: 'not-string' };\n return { ok: true, value };\n}\n\nexport const TraitEventContractSchema = z.object({\n /**\n * Event name. Mirrors the Rust validator's `is_valid_event_identifier`:\n * starts with a letter, then any letters / digits / underscores. Both\n * UPPER_SNAKE_CASE and PascalCase shapes are valid identifiers in the\n * post-Phase 2.5 nominal-event type system (events declared via\n * `type X = Event<T>`). A pre-resolution `@config.<knob>` reference\n * (Option B) is also legal — inline/resolve substitutes it with the\n * knob's effective literal before codegen/runtime consume it.\n */\n event: z.string().min(1).regex(\n /^([A-Za-z][A-Za-z0-9_]*|@config\\.[A-Za-z_][A-Za-z0-9_]*)$/,\n 'Event name must start with a letter and contain only letters, digits, and underscores, or be a `@config.<knob>` reference'\n ),\n eventId: EventIdSchema.optional(),\n description: z.string().optional(),\n synonyms: z.string().optional(),\n tier: z.string().optional(),\n definerKnob: z.string().optional(),\n scopeOverridden: z.boolean().optional(),\n payloadSchema: z.array(EventPayloadFieldSchema).optional(),\n payloadEntity: z.string().optional(),\n scope: EventScopeSchema.optional(),\n});\n\n// ============================================================================\n// Trait Event Listener\n// ============================================================================\n\n/**\n * Event listener for trait communication.\n * Guards can be legacy strings or S-expressions.\n * Enhanced with scope and payloadMapping for cross-orbital communication.\n */\n/**\n * Source-scoping for a `listens {}` entry. Determines which emitters the\n * listener responds to.\n *\n * - `{ kind: \"any\" }`: wildcard (`* EVENT -> TRIGGER`). Any trait, any orbital.\n * - `{ kind: \"trait\", trait: \"X\" }`: intra-orbital (`X EVENT -> TRIGGER`).\n * Only emits from the same orbital's trait `X`.\n * - `{ kind: \"orbital\", orbital: \"O\", trait: \"X\" }`: cross-orbital\n * (`O.X EVENT -> TRIGGER`). Only emits from orbital `O`'s trait `X`.\n *\n * Absent (undefined) means the listener is a local payload-declaration only\n * — pure type metadata, no bus subscription.\n */\nexport type ListenSource =\n | { kind: 'any' }\n | {\n kind: 'trait';\n trait: string;\n /** V4 dual-carry id sibling of `trait` — optional until the Phase-7 flip. */\n traitId?: TraitId;\n }\n | {\n kind: 'orbital';\n orbital: string;\n trait: string;\n /** V4 dual-carry id sibling of `orbital` — optional until the Phase-7 flip. */\n orbitalId?: OrbitalId;\n /** V4 dual-carry id sibling of `trait` — optional until the Phase-7 flip. */\n traitId?: TraitId;\n };\n\nexport const ListenSourceSchema = z.union([\n z.object({ kind: z.literal('any') }),\n z.object({\n kind: z.literal('trait'),\n trait: z.string().min(1),\n traitId: TraitIdSchema.optional(),\n }),\n z.object({\n kind: z.literal('orbital'),\n orbital: z.string().min(1),\n trait: z.string().min(1),\n orbitalId: OrbitalIdSchema.optional(),\n traitId: TraitIdSchema.optional(),\n }),\n]);\n\n/**\n * Split a `listens`-addressed event (`EVENT`, `Trait.EVENT`, `*.EVENT`,\n * `Orbital.Trait.EVENT`) into the bare event and its source. The one parser of\n * the address form, shared by `listens` and event-typed values. Mirrors\n * `orbital-core` `split_event_address`.\n */\nexport function splitEventAddress(raw: string): { event: string; source?: ListenSource } {\n const parts = raw.split('.');\n if (parts.length <= 1) return { event: raw };\n if (parts.length === 2) {\n const [src, event] = parts;\n return src === '*'\n ? { event, source: { kind: 'any' } }\n : { event, source: { kind: 'trait', trait: src } };\n }\n const n = parts.length;\n return {\n event: parts[n - 1],\n source: { kind: 'orbital', orbital: parts.slice(0, n - 2).join('.'), trait: parts[n - 2] },\n };\n}\n\n/** Inverse of {@link splitEventAddress}. */\nexport function joinEventAddress(event: string, source?: ListenSource): string {\n if (source === undefined) return event;\n switch (source.kind) {\n case 'any':\n return `*.${event}`;\n case 'trait':\n return `${source.trait}.${event}`;\n case 'orbital':\n return `${source.orbital}.${source.trait}.${event}`;\n }\n}\n\nexport type TraitEventListener = {\n /** Event key to listen for (bare event name, no source prefix in the new shape) */\n event: string;\n /** V4 dual-carry id sibling of `event` — optional until the Phase-7 flip. */\n eventId?: EventId;\n /** State machine event to trigger */\n triggers: string;\n /** V4 dual-carry id sibling of `triggers` — optional until the Phase-7 flip. */\n triggersId?: EventId;\n /** Human-readable description (authored `@description` on the listen). */\n description?: string;\n /** User-vocabulary synonyms (comma-separated). */\n synonyms?: string;\n /** Authoring tier (`essential`/`customization`/`advanced`/`internal`). */\n tier?: string;\n /** Guard expression - string (legacy) or S-expression array */\n guard?: Expression;\n /**\n * Listener scope:\n * - 'internal': Listen to events within same orbital (default)\n * - 'external': Listen to events from other orbitals\n */\n scope?: EventScope;\n /**\n * `with { ... }` payload rewrite: `{ targetField: SExpr }`. Each value is a\n * full s-expression evaluated against the source payload — a `@payload.<field>`\n * read, a literal, or an operator list. The kernel applies it\n * (`applyListenMapping` crosses into it).\n */\n payloadMapping?: Record<string, SExpr>;\n /**\n * `per <expr>`: the row of the listening entity this delivery steps, an s-expression over the source payload that\n * must evaluate to a non-empty string. The kernel evaluates it and creates the row on first use.\n */\n key?: SExpr;\n /**\n * Source scoping (see `ListenSource`). Undefined when the listen entry is\n * a local payload declaration rather than a bus subscription.\n */\n source?: ListenSource;\n};\n\nexport const TraitEventListenerSchema = z.object({\n event: z.string().min(1),\n eventId: EventIdSchema.optional(),\n triggers: z.string().min(1),\n triggersId: EventIdSchema.optional(),\n description: z.string().optional(),\n synonyms: z.string().optional(),\n tier: z.string().optional(),\n guard: ExpressionSchema.optional(),\n scope: EventScopeSchema.optional(),\n payloadMapping: z.record(z.string(), SExprSchema).optional(),\n key: SExprSchema.optional(),\n source: ListenSourceSchema.optional(),\n});\n\n// ============================================================================\n// Required Field\n// ============================================================================\n\n/**\n * Field required by a trait from its linkedEntity\n */\nexport type RequiredField = {\n name: string;\n type: TraitFieldType;\n description?: string;\n};\n\nexport const RequiredFieldSchema = z.object({\n name: z.string().min(1),\n type: z.union([z.enum(TRAIT_FIELD_TYPES), TypeVariableSchema]),\n description: z.string().optional(),\n});\n\n// ============================================================================\n// Trait Reference\n// ============================================================================\n\n/**\n * Reference to a trait from an entity or page.\n *\n * Phase F treats a trait reference as a function call: `ref` names the\n * imported trait and the sibling fields are arguments. The compiler's\n * identifier-substitution pass uses these arguments to rewrite the\n * inlined trait clone before lowering.\n */\nexport type TraitReference = {\n ref: string;\n /** V4 dual-carry id sibling of `ref` — optional until the Phase-7 flip. */\n refId?: TraitId;\n /**\n * V4 LOCAL DECLARATION id — the identity of this trait AS DECLARED in its\n * orbital (`trait X = Alias.traits.Y` declares node X; `refId` carries\n * Y's id). Minted by the stamp so page trait refs and `@trait.X` embeds\n * resolve by id across `name:` renames (the composed-organism surface was\n * the one declaration class without an id).\n */\n id?: TraitId;\n /**\n * Phase 1.2: optional registry path disambiguator. Pairs with `ref` to\n * explicitly name which `uses` entry the alias was imported from\n * (e.g. \"std/behaviors/atoms/std-browse\"). Helpful for programmatic\n * descriptor construction and inline-phase disambiguation when multiple\n * registries expose the same alias prefix.\n */\n from?: string;\n linkedEntity?: string;\n /** V4 dual-carry id sibling of `linkedEntity` — optional until the Phase-7 flip. */\n linkedEntityId?: EntityId;\n /** Phase F: rename the inlined trait at the call site */\n name?: string;\n /** Phase F: rename atom event keys at the call site, e.g. {OPEN: \"ADD_ITEM\"} */\n events?: Record<string, string>;\n /**\n * 3-II trait type-parameter arguments (`:: p SomeType` in `.lolo`):\n * declared-param name → type-vocabulary name (an entity, a primitive incl.\n * `scalar`, or a struct alias from the AUTHORING file's `types` map).\n * Present on pre-inline registry references only — the inline phase\n * consumes it while resolving `$<name>` payload sentinels and it never\n * appears in a final composed `.orb`.\n */\n typeArgs?: Record<string, string>;\n /** Preprocess-output carrier: the fully resolved trait this reference stands\n * for (`@almadar/runtime` `preprocessSchema` output only; never in a `.orb`). */\n _resolved?: Trait;\n /** V4 dual-carry id sibling of `events` (keys = baked event names resolved to ids) — optional until the Phase-7 flip. */\n eventIds?: Record<string, EventId>;\n /**\n * Entity-field remap: rewrite the inlined trait's canonical `@entity.X` /\n * `@payload.row.X` field references to the consumer entity's field names,\n * e.g. `{ name: \"title\", folder: \"parentId\" }`. Mirrors `events` for\n * fields. Applied during inline substitution alongside `linkedEntity`.\n */\n fields?: Record<string, string>;\n /**\n * Call-site config overrides. Each entry is either a plain wiring value\n * (`TraitConfigValue`) or a fully-annotated re-declaration\n * (`ConfigFieldDeclaration` with `type`, optional `label`/`description`/\n * `synonyms`/`tier`). Use `isCallSiteConfigDeclaration` to discriminate.\n *\n * Plain wiring (existing callers): `config: { icon: \"star\", count: 5 }`.\n * Annotated (new): `config: { icon: { type: \"string\", default: \"star\",\n * label: \"Icon\", tier: \"presentation\" } }`.\n */\n config?: CallSiteConfig;\n appliesTo?: string[];\n /**\n * Phase F.7: replace the imported trait's `listens` array with the\n * caller-supplied list. Empty array clears all upstream listens. The\n * inliner applies this AFTER substitution, overwriting whatever the\n * upstream declared. Use sparingly: this drops external event wiring.\n */\n listens?: TraitEventListener[];\n /**\n * Phase F.7: set every emit's `scope` to the caller-supplied value.\n * `'internal'` confines emits to the orbital's internal bus; `'external'`\n * broadcasts them. Applied after substitution and listens replacement.\n */\n emitsScope?: 'internal' | 'external';\n /**\n * Phase F.8: per-transition effects override. The map's keys are event\n * names (the transition triggers, AFTER any rename via `events`). The\n * values are the SExpression effect lists that REPLACE the matching\n * transitions' `effects[]` arrays.\n *\n * This is the unified content + effect override mechanism. Whether the\n * override list contains `[\"render-ui\", ...]` (visual content),\n * `[\"fetch\", ...]` (data load), `[\"persist\", ...]` (mutation), or any\n * combination, the inliner just substitutes the whole list. Identifier\n * substitution (entity refs, event refs) still runs over the merged\n * trait body, so override effects can use either upstream or caller\n * identifiers and the F.3 walker will rewrite them consistently.\n *\n * Example:\n * ```json\n * \"effects\": {\n * \"ADD_ITEM\": [\n * [\"fetch\", \"CartItem\"],\n * [\"render-ui\", \"main\", { ... }]\n * ],\n * \"SAVE\": [\n * [\"persist\", \"create\", \"CartItem\", \"@payload.data\"]\n * ]\n * }\n * ```\n */\n effects?: Record<string, SExpr[]>;\n};\n\n/** The reference object's fields, before the `events` refinement (so other shapes can `.pick` from it). */\nexport const TraitReferenceObjectSchema = z\n .object({\n ref: z.string().min(1),\n refId: TraitIdSchema.optional(),\n // V4 local declaration id (see the interface doc) — declared so the\n // strip-mode zod gate carries it through instead of dropping it.\n id: TraitIdSchema.optional(),\n // Phase 1.2: optional registry path disambiguator, pairs with `ref`.\n from: z.string().optional(),\n linkedEntity: z.string().optional(),\n linkedEntityId: EntityIdSchema.optional(),\n name: z.string().optional(),\n events: z\n .record(\n z.string().min(1, \"events key (atom event name) must be non-empty\"),\n z.string().min(1, \"events value (caller event name) must be non-empty\"),\n )\n .optional(),\n eventIds: z.record(z.string().min(1), EventIdSchema).optional(),\n _resolved: z.lazy(() => TraitSchema).optional(),\n // 3-II type-parameter arguments (see `TraitReference.typeArgs`).\n typeArgs: z\n .record(\n z.string().min(1, \"typeArgs key (declared param name) must be non-empty\"),\n z.string().min(1, \"typeArgs value (type name) must be non-empty\"),\n )\n .optional(),\n fields: z\n .record(\n z.string().min(1, \"fields key (canonical field name) must be non-empty\"),\n z.string().min(1, \"fields value (consumer field name) must be non-empty\"),\n )\n .optional(),\n // Each value is either a plain wiring value (TraitConfigValue) or an\n // annotated ConfigFieldDeclaration. Declaration form is tried first\n // (it's more specific — has a `\"type\"` string key); plain values fall\n // through to the recursive TraitConfigValue union.\n config: z.record(z.string(), z.union([ConfigFieldDeclarationSchema, TraitConfigValueSchema])).optional(),\n appliesTo: z.array(z.string()).optional(),\n // Phase F.7: caller-supplied listen entries are already-resolved\n // structured definitions (see `TraitReference.listens`).\n listens: z.array(TraitEventListenerSchema).optional(),\n emitsScope: z.enum(['internal', 'external']).optional(),\n // Phase F.8: per-transition effects override. The keys are event\n // names (the transition triggers AFTER renames); values are SExpr\n // effect tuples.\n effects: z\n .record(\n z.string().min(1, \"effects override key (event name) must be non-empty\"),\n z.array(SExprSchema),\n )\n .optional(),\n });\n\nexport const TraitReferenceSchema = TraitReferenceObjectSchema\n .refine(\n (ref) => {\n if (!ref.events) return true;\n // Phase F.4: reject empty event-name strings on either side of\n // every entry. The substitution pass treats empty strings as\n // no-ops at runtime, but accepting them at the schema boundary\n // hides authoring errors. The per-entry .min(1) above already\n // rejects most cases; this refine is the belt-and-braces check\n // that survives any future relaxation of the inner validators.\n for (const [from, to] of Object.entries(ref.events)) {\n if (from.length === 0 || to.length === 0) return false;\n }\n return true;\n },\n {\n message:\n 'TraitReference \"events\" entries must have non-empty atom and caller event names',\n path: [\"events\"],\n },\n );\n\n/**\n * Simplified trait reference - supports string, reference object, or inline Trait definition\n * - string: \"TraitName\" - reference to a trait by name\n * - { ref: \"TraitName\" }: reference object with optional config / overrides\n * - { name: \"TraitName\", stateMachine: {...} }: inline trait definition\n *\n * Phase F adds `name` and `events` to the reference object form so callers\n * can rename the trait and remap atom event keys.\n */\n/** A trait in an orbital: a bare name, a reference (the full `TraitReference` the wire carries), or an inline trait. */\nexport type TraitRef = string | TraitReference | Trait;\n\n// TraitRefSchema is defined after TraitSchema (see below) to avoid forward reference\n\n// ============================================================================\n// Trait UI Binding\n// ============================================================================\n\nexport type PresentationType = 'modal' | 'drawer' | 'popover' | 'inline' | 'confirm-dialog';\n\nexport type TraitUIBinding = {\n [stateName: string]: {\n presentation: PresentationType;\n content: AnyPatternConfig | AnyPatternConfig[];\n props?: {\n size?: 'sm' | 'md' | 'lg' | 'xl' | 'full';\n position?: 'left' | 'right' | 'top' | 'bottom' | 'center';\n title?: string;\n closable?: boolean;\n width?: string;\n showProgress?: boolean;\n step?: number;\n totalSteps?: number;\n };\n };\n};\n\n/**\n * Zod schema for {@link TraitUIBinding}. `content` is a pattern config (or\n * list of them), validated as pattern objects by {@link PatternObjectSchema}\n * (the registry checks props at validate time).\n */\nexport const TraitUIBindingSchema = z.record(z.string(),\n z.object({\n presentation: z.enum(['modal', 'drawer', 'popover', 'inline', 'confirm-dialog']),\n content: z.union([PatternObjectSchema, z.array(PatternObjectSchema)]),\n props: z\n .object({\n size: z.enum(['sm', 'md', 'lg', 'xl', 'full']).optional(),\n position: z.enum(['left', 'right', 'top', 'bottom', 'center']).optional(),\n title: z.string().optional(),\n closable: z.boolean().optional(),\n width: z.string().optional(),\n showProgress: z.boolean().optional(),\n step: z.number().optional(),\n totalSteps: z.number().optional(),\n })\n .optional(),\n }),\n);\n\n// ============================================================================\n// Trait Definition\n// ============================================================================\n\n/**\n * A Trait is a reusable behavioral module with state machine.\n *\n * Traits declare their event contracts via `emits` and `listens`:\n * - `emits`: Events this trait can emit (with scope and payload schema)\n * - `listens`: Events this trait listens for (with optional payloadMapping)\n */\n/**\n * Inferred field contract for a `@rebindable` trait binding. `requires` =\n * entity fields the trait READS via `@entity.<field>`; `provides` = fields it\n * WRITES via `(set @entity.<field> ...)`. A consumer that rebinds the trait\n * (`linkedEntity`) must point at an entity whose fields ⊇ `requires`. Inferred\n * by the lolo lowerer from the trait's own SExpr usage; the orbital-rust L2\n * validator enforces it (`ORB_T_REBIND_MISSING_FIELDS`). Mirrors the Rust\n * `EntityFieldContract` serde shape exactly.\n */\nexport type EntityFieldContract = {\n requires: string[];\n provides: string[];\n};\n\nexport const EntityFieldContractSchema = z.object({\n requires: z.array(z.string()),\n provides: z.array(z.string()),\n});\n\n/**\n * Where in a trait an effect is declared. The distinction is load-bearing: a\n * `render-ui` in a transition fires when that transition fires, but one inside a\n * `ticks` block repaints every frame, so two tick writers on one slot paint\n * together where two transition writers routinely alternate.\n */\nexport type EffectSite = 'transition' | 'tick';\n\nexport const EffectSiteSchema = z.enum(['transition', 'tick']);\n\n/**\n * One effect a trait produces, with the resource it acts on — the slot for\n * `render-ui`, the entity for `persist`/`fetch`, the event for `emit`, the\n * binding path for `set`. `resource` is recorded verbatim as authored; when the\n * author deferred it to a call site (`@config.surface`) the reference is kept as\n * written and `resolved` is false. Mirrors the Rust `EffectUse` serde shape.\n */\nexport type EffectUse = {\n kind: string;\n resource?: string;\n /** Absent means true — only an unresolved `@config.*` resource sets it. */\n resolved?: boolean;\n /** Absent means `'transition'`. */\n site?: EffectSite;\n};\n\nexport const EffectUseSchema = z.object({\n kind: z.string(),\n resource: z.string().optional(),\n resolved: z.boolean().optional(),\n site: EffectSiteSchema.optional(),\n});\n\n/**\n * Every effect a trait produces — what composing it actually brings along.\n *\n * Inferred by the lolo lowerer from the trait's own effects (never authored, the\n * way {@link EntityFieldContract} is never authored), then re-derived\n * post-inline once call-site config makes `@config.*` resources concrete. A\n * trait's type used to say nothing about its effects, which is why \"is this safe\n * to compose?\" could only be answered by reading the atom.\n */\nexport type EffectRow = EffectUse[];\n\nexport const EffectRowSchema = z.array(EffectUseSchema);\n\n/**\n * Client dispatch strategy for a trait's transitions — the ONE rule,\n * computed from declared facts only, never inferred from a trait's effects\n * (`docs/Almadar_LOLO.md` §7). Mirrors `orbital-core`'s\n * `runtime::dispatch_mode::DispatchMode` serde shape exactly (the enum both\n * `OirTrait::dispatch_mode` (compiled path) and `TraitDefinition::dispatch_mode`\n * (runtime kernel) return) — same variant spellings, so a value round-trips\n * on the wire unchanged.\n */\nexport type DispatchMode = 'persistedAwaited' | 'hybridClientOnly' | 'runtimeOptimistic';\n\nexport const DispatchModeSchema = z.enum(['persistedAwaited', 'hybridClientOnly', 'runtimeOptimistic']);\n\n/** The `[client]` / `[optimistic]` / `[server]` trait-header word; absent = server dispatch, `server` is the explicit spelling that overrides an atom's mode. Mirrors Rust `DispatchMode` (serde lowercase). */\nexport type TraitDispatchMode = 'client' | 'optimistic' | 'server';\n\nexport const TraitDispatchModeSchema = z.enum(['client', 'optimistic', 'server']);\n\nexport type Trait = {\n /** V4 dual-carry id sibling of `name` — optional until the Phase-7 flip. */\n id?: TraitId;\n name: string;\n description?: string;\n description_visual_prompt?: string;\n /**\n * Opt-in marker authored as `-> @rebindable Entity` in `.lolo`. When\n * `true`, a consuming molecule/organism may rebind this trait's entity via\n * `linkedEntity`; otherwise the binding is fixed and the validator rejects\n * any rebind (`ORB_T_ENTITY_NOT_REBINDABLE`). Absent on traits that don't\n * bind an entity.\n */\n entityRebindable?: boolean;\n /**\n * Inferred field contract a rebind target must satisfy. Emitted only\n * alongside `entityRebindable: true`. See {@link EntityFieldContract}.\n */\n entityContract?: EntityFieldContract;\n /**\n * Inferred effect surface. Absent on traits that produce no effects at all.\n * See {@link EffectRow}.\n */\n effectRow?: EffectRow;\n /**\n * `@description \"...\"` authored on the `@rebindable` binding in `.lolo`.\n * Surfaced to catalog prose + knob-embeddings so the LLM can reach for the\n * binding from intent vocabulary (binding-discovery). Absent when unmarked.\n */\n entityBindingDescription?: string;\n /** `@synonyms \"...\"` authored on the `@rebindable` binding in `.lolo`. */\n entityBindingSynonyms?: string;\n /**\n * Dispatch mode authored as `[client]` / `[optimistic]` / `[server]` on the `.lolo` trait\n * header. Absent means server dispatch. Mirrors the Rust\n * `TraitDefinition.dispatch` field; never inferred from effects.\n */\n dispatch?: TraitDispatchMode;\n /**\n * The entity this trait is linked to.\n * Required for inline trait definitions within an orbital.\n */\n linkedEntity?: string;\n /** V4 dual-carry id sibling of `linkedEntity` — optional until the Phase-7 flip. */\n linkedEntityId?: EntityId;\n /**\n * V4 leverage-ids — id side-map for `@entity.<Name>` binding tokens + positional\n * entity args (`fetch`/`ref`/`persist`/`spawn`) in this trait's guards/effects/\n * ticks/listens. Maps the referenced entity NAME → its stable id, so readers\n * resolve these bare-string positions by id (else name) and an entity rename never\n * strands them — the coverage that lets the entity name-rewriter be deleted.\n */\n entityRefIds?: Record<string, EntityId>;\n /**\n * V4 leverage-ids — id side-map for `@trait.<Name>` embed tokens (render-ui embeds /\n * effect-tree sibling refs). Maps the embed token NAME → the embedded trait's stable\n * id, so readers splice embeds by id (else name) — the coverage that lets the\n * `@trait.` name-rewriter be deleted.\n */\n traitEmbedIds?: Record<string, TraitId>;\n requiredFields?: RequiredField[];\n dataEntities?: TraitDataEntity[];\n stateMachine?: StateMachine;\n initialEffects?: Effect[];\n ticks?: TraitTick[];\n /**\n * Events this trait emits.\n * Each event can be scoped as internal or external.\n * External events are namespaced at orbital level (TraitName.EVENT_NAME).\n */\n emits?: TraitEventContract[];\n /**\n * Events this trait listens for.\n * External listeners reference namespaced events (TraitName.EVENT_NAME).\n */\n listens?: TraitEventListener[];\n /**\n * `events { ACTION: CONFIRM_VOID }` — the call-site rename map that binds a\n * pattern's own event slot (the key, e.g. a Button's `ACTION`) to the app\n * event it fires (the value). Emitted into the IR by the inliner and read\n * by wiring analysis: without it, an affordance whose event lives here\n * rather than in the render payload looks like it fires nothing.\n */\n events?: Readonly<Record<string, string>>;\n ui?: TraitUIBinding;\n /**\n * Declared `config { }` schema authored on the trait. Drives\n * `@config.X` substitution: each field's `default` seeds the\n * binding context behind any caller-supplied call-site\n * `config: { ... }` override.\n */\n config?: DeclaredTraitConfig;\n /**\n * Set by the resolve/inline phase when this trait was cloned from a\n * `uses[]` import. Absent for traits authored directly on the\n * orbital. Viewport-only metadata — runtime and codegen ignore it.\n * Drives Studio's L2 grouping (imported traits collapse under one\n * card per alias) and L3 drill (alias → that behavior's transitions).\n */\n sourceBehavior?: SourceBehaviorMetadata;\n sourceDeclaration?: SourceDeclarationMetadata;\n /**\n * Set by the resolve/inline phase alongside `sourceBehavior`. Carries\n * the resolved `Entity` definition of the imported behavior so the\n * client-side mock-data generator can produce rows for the trait's\n * `linkedEntity` without re-walking the import graph at runtime.\n */\n sourceEntityDefinition?: Entity;\n /**\n * Increment 3-II: this trait's own declared type parameters. Present\n * only on an atom's DECLARING inline trait (never authored on a\n * reference); survives cloning into a consumer's composed schema.\n */\n typeParams?: TraitTypeParamDef[];\n};\n\n/**\n * Provenance attached to a trait that was cloned from a `uses[]` import\n * during the inline phase. The resolved schema carries this so Studio\n * can group L2 cards by source behavior and offer an L3 drill into the\n * import's own transitions.\n */\nexport type SourceBehaviorMetadata = {\n /** Behavior name (e.g. \"std-stat-card\") — the resolved `from:` value. */\n behavior: string;\n /** Alias used at the import site (e.g. \"Stat\"). Multiple imports of\n * the same atom group by alias, not by behavior. */\n alias: string;\n /** Original trait name inside the imported behavior, before any\n * call-site `name:` rename. */\n originalName: string;\n};\n\nexport type SourceDeclarationMetadata = {\n traitId: string;\n fingerprint: string;\n};\n\nexport const SourceDeclarationMetadataSchema = z.object({\n traitId: z.string().min(1),\n fingerprint: z.string().min(1),\n});\n\nexport const SourceBehaviorMetadataSchema = z.object({\n behavior: z.string().min(1),\n alias: z.string().min(1),\n originalName: z.string().min(1),\n});\n\n/**\n * One trait-level type parameter — `(V : Type, R : Type)` in\n * `trait Name (V : Type, R : Type) -> Entity { ... }`. Present only on an\n * atom's DECLARING inline trait; survives cloning into a consumer's composed\n * schema so the inline phase can read each param's `kind` when resolving a\n * surviving `\"$<name>\"` payload sentinel. `kind` is one of the six alias\n * type-parameter kind names (`Type`, `Entity`, `Trait`, `Page`, `Orbital`,\n * `Event`) — in practice `Type` and `Entity` are the two meaningful kinds\n * for a trait param today.\n */\nexport type TraitTypeParamDef = {\n name: string;\n kind: string;\n /**\n * Declaration default (`(r : Type = <name>)`) — a primitive name (incl.\n * `scalar`), an entity name, or a struct-alias name, all resolved in\n * the atom's own file. Consulted only when no call-site `::` arg was\n * supplied (and, for Entity-kind, only when `linkedEntity` also gave no\n * default).\n */\n default?: string;\n};\n\nexport const TraitTypeParamDefSchema: z.ZodType<TraitTypeParamDef> = z.object({\n name: z.string().min(1),\n kind: z.string().min(1),\n default: z.string().optional(),\n});\n\nexport const TraitSchema = z.object({\n id: TraitIdSchema.optional(),\n name: z.string().min(1),\n description: z.string().optional(),\n description_visual_prompt: z.string().optional(),\n entityRebindable: z.boolean().optional(),\n entityContract: EntityFieldContractSchema.optional(),\n effectRow: EffectRowSchema.optional(),\n entityBindingDescription: z.string().optional(),\n entityBindingSynonyms: z.string().optional(),\n dispatch: TraitDispatchModeSchema.optional(),\n linkedEntity: z.string().optional(),\n linkedEntityId: EntityIdSchema.optional(),\n entityRefIds: z.record(z.string().min(1), EntityIdSchema).optional(),\n traitEmbedIds: z.record(z.string().min(1), TraitIdSchema).optional(),\n requiredFields: z.array(RequiredFieldSchema).optional(),\n dataEntities: z.array(TraitDataEntitySchema).optional(),\n stateMachine: StateMachineSchema.optional(),\n initialEffects: z.array(EffectSchema).optional(),\n ticks: z.array(TraitTickSchema).optional(),\n emits: z.array(TraitEventContractSchema).optional(),\n listens: z.array(TraitEventListenerSchema).optional(),\n /** Call-site rename map (`events { ACTION: CONFIRM_VOID }`) — mirrors `Trait.events`. */\n events: z.record(z.string().min(1), z.string().min(1)).optional(),\n ui: TraitUIBindingSchema.optional(),\n config: DeclaredTraitConfigSchema.optional(),\n sourceBehavior: SourceBehaviorMetadataSchema.optional(),\n sourceDeclaration: SourceDeclarationMetadataSchema.optional(),\n sourceEntityDefinition: EntitySchema.optional(),\n typeParams: z.array(TraitTypeParamDefSchema).optional(),\n});\n\n// TraitRefSchema defined here after TraitSchema to avoid forward reference.\n//\n// The reference arm IS `TraitReferenceSchema` — one schema for one shape. It\n// used to be a narrower hand-rolled copy (`ref`/`config`/`linkedEntity`/`name`/\n// `events` only), and because `z.object()` STRIPS undeclared keys rather than\n// rejecting them, every `.orb` that came through the loader's `safeParse` lost\n// `id`, `refId`, `linkedEntityId`, `listens`, `emitsScope`, `effects`, `fields`\n// and `eventIds` on every trait ref — silently, with a schema that reported\n// success. An atom's own sub-view refs (`trait DenseTableView =\n// TableView.traits.TableViewRender -> BrowseItem { listens {…} }`) arrived with\n// no listens at all, so the interpreted path could not wire what the compiled\n// path wires from the same file.\nexport const TraitRefSchema = z.union([\n z.string().min(1),\n TraitReferenceSchema,\n TraitSchema, // Allow inline trait definitions\n]);\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Check if a trait ref is an inline Trait definition\n */\n/**\n * Checks if a trait reference is an inline trait definition.\n * \n * Type guard to determine if a TraitRef is an inline trait object\n * (with 'name' property) rather than a string reference or object reference.\n * \n * @param {TraitRef} traitRef - Trait reference to check\n * @returns {boolean} True if traitRef is an inline trait, false otherwise\n * \n * @example\n * isInlineTrait({ name: 'MyTrait' }); // returns true (inline)\n * isInlineTrait('MyTrait'); // returns false (string reference)\n * isInlineTrait({ ref: 'MyTrait' }); // returns false (object reference)\n */\nexport function isInlineTrait(traitRef: TraitRef): traitRef is Trait {\n return typeof traitRef === 'object' && 'name' in traitRef && !('ref' in traitRef);\n}\n\n/**\n * Extracts the trait name from a trait reference.\n * \n * Handles all trait reference formats (string, inline object, object reference)\n * and returns the canonical trait name.\n * \n * @param {TraitRef} traitRef - Trait reference to extract name from\n * @returns {string} Trait name\n * \n * @example\n * getTraitName('MyTrait'); // returns 'MyTrait'\n * getTraitName({ name: 'MyTrait' }); // returns 'MyTrait'\n * getTraitName({ ref: 'MyTrait' }); // returns 'MyTrait'\n */\nexport function getTraitName(traitRef: TraitRef): string {\n if (typeof traitRef === 'string') {\n return traitRef;\n }\n if (isInlineTrait(traitRef)) {\n return traitRef.name;\n }\n return traitRef.ref;\n}\n\n/**\n * Extracts the configuration from a trait reference.\n * \n * Returns the configuration object for trait references that support it\n * (object references with 'config' property). Returns undefined for\n * string references and inline traits.\n * \n * @param {TraitRef} traitRef - Trait reference to extract config from\n * @returns {TraitConfig | undefined} Trait configuration or undefined\n *\n * @example\n * getTraitConfig('MyTrait'); // returns undefined\n * getTraitConfig({ name: 'MyTrait' }); // returns undefined\n * getTraitConfig({ ref: 'MyTrait', config: { option: 'value' } }); // returns config object\n */\nexport function getTraitConfig(traitRef: TraitRef): CallSiteConfig | undefined {\n if (typeof traitRef === 'string') {\n return undefined;\n }\n if (isInlineTrait(traitRef)) {\n return undefined; // Inline traits don't have config\n }\n return traitRef.config;\n}\n\n/**\n * Normalizes a trait reference to object form.\n * \n * Converts any trait reference format (string, inline, object) to a\n * standardized object format with 'ref' and optional 'config' properties.\n * \n * @param {TraitRef} traitRef - Trait reference to normalize\n * @returns {{ ref: string; config?: TraitConfig }} Normalized trait reference\n *\n * @example\n * normalizeTraitRef('MyTrait'); // returns { ref: 'MyTrait' }\n * normalizeTraitRef({ name: 'MyTrait' }); // returns { ref: 'MyTrait' }\n * normalizeTraitRef({ ref: 'MyTrait', config: {...} }); // returns original\n */\nexport function normalizeTraitRef(traitRef: TraitRef): { ref: string; config?: CallSiteConfig } {\n if (typeof traitRef === 'string') {\n return { ref: traitRef };\n }\n if (isInlineTrait(traitRef)) {\n return { ref: traitRef.name };\n }\n return traitRef;\n}\n\n// ============================================================================\n// Type exports\n// ============================================================================\n\nexport type TraitInput = z.input<typeof TraitSchema>;\nexport type TraitReferenceInput = z.input<typeof TraitReferenceSchema>;\n\n// Backward compatibility aliases\nexport type OrbitalTraitRef = TraitRef;\nexport const OrbitalTraitRefSchema = TraitRefSchema;\n","/**\n * Page Types for Orbital Units\n *\n * Defines OrbitalPage type for pages within an Orbital Unit.\n *\n * IMPORTANT: Trait-driven UI architecture requires pages to have traits.\n * Static sections are NO LONGER SUPPORTED.\n *\n * @packageDocumentation\n */\n\nimport { z } from 'zod';\nimport type { PageId, TraitId, EntityId } from './identity.js';\nimport { PageIdSchema, TraitIdSchema, EntityIdSchema } from './identity.js';\nimport { TraitConfigSchema, type TraitConfig } from './trait.js';\nimport { SExprSchema, type SExpr } from './expression.js';\n\n// ============================================================================\n// View Type\n// ============================================================================\n\n/**\n * Page view types.\n * Note: viewType may be deprecated in favor of trait-driven UI.\n */\nexport type ViewType = 'list' | 'detail' | 'create' | 'edit' | 'dashboard' | 'custom';\n\nexport const ViewTypeSchema = z.enum([\n 'list',\n 'detail',\n 'create',\n 'edit',\n 'dashboard',\n 'custom',\n]);\n\n// ============================================================================\n// Trait Reference\n// ============================================================================\n\n/**\n * Trait reference on a page.\n */\nexport type PageTraitRef = {\n /** Trait name from library */\n ref: string;\n /** V4 dual-carry id sibling of `ref` — optional until the Phase-7 flip. */\n refId?: TraitId;\n /** Entity this trait operates on */\n linkedEntity?: string;\n /** V4 dual-carry id sibling of `linkedEntity` — optional until the Phase-7 flip. */\n linkedEntityId?: EntityId;\n /** Additional trait configuration */\n config?: TraitConfig;\n};\n\nexport const PageTraitRefSchema = z.object({\n ref: z.string().min(1, 'Trait ref is required'),\n refId: TraitIdSchema.optional(),\n linkedEntity: z.string().optional(),\n linkedEntityId: EntityIdSchema.optional(),\n config: TraitConfigSchema.optional(),\n});\n\n// ============================================================================\n// Page modifiers (access, indexing, metadata)\n// ============================================================================\n\n/** `access:` — `public` admits anonymous viewers; `authenticated` mounts the\n * page circuit only for a resolved signed-in viewer. Absent = no gate. */\nexport type PageAccess = 'public' | 'authenticated';\nexport const PageAccessSchema = z.enum(['public', 'authenticated']);\n\n/** `indexing:` — a search-engine directive, never access control. */\nexport type PageIndexing = 'index' | 'noindex';\nexport const PageIndexingSchema = z.enum(['index', 'noindex']);\n\n/** `title:` / `description:` — a literal, or `[\"i18n/t\", key]` resolved\n * against the route's locale. No entity/config/viewer bindings. */\nexport type PageMeta = string | ['i18n/t', string];\nexport const PageMetaSchema = z.union([\n z.string(),\n z.tuple([z.literal('i18n/t'), z.string().min(1)]),\n]);\n\n/** Resolve a {@link PageMeta} through a message lookup. */\nexport function resolvePageMeta(\n meta: PageMeta | undefined,\n lookup: (key: string) => string | undefined,\n): string | undefined {\n if (meta === undefined) return undefined;\n return typeof meta === 'string' ? meta : lookup(meta[1]);\n}\n\n// ============================================================================\n// Orbital Page\n// ============================================================================\n\n/**\n * OrbitalPage - a page definition within an Orbital Unit.\n *\n * TRAIT-DRIVEN: Pages must have traits array. Sections are NOT supported.\n */\nexport type OrbitalPage = {\n /** V4 dual-carry id sibling of `name` — optional until the Phase-7 flip. */\n id?: PageId;\n\n /** Page name (PascalCase, e.g., \"TasksPage\") */\n name: string;\n\n /** URL path (e.g., \"/tasks\", \"/tasks/:id\"); \"\" on a protocol page, whose `address` says where it is reached. */\n path: string;\n\n /** Protocol word of a non-route page (`page http { … }`, `page stdio`, `page boot`). Absent = route. */\n protocol?: string;\n\n /** The protocol's address record (`{ host, port, path }`), an expression typed against the protocol table row. Absent on a route and on a protocol row with no address. */\n address?: SExpr;\n\n /** View type (optional in trait-driven mode) */\n viewType?: ViewType;\n\n /** `title:` page modifier — the document title. */\n title?: PageMeta;\n\n /** `description:` page modifier — the document meta description. */\n description?: PageMeta;\n\n /** `access:` page modifier. */\n access?: PageAccess;\n\n /** `indexing:` page modifier. */\n indexing?: PageIndexing;\n\n /**\n * The upstream page this one was imported from (its id, kept through nested\n * imports). Imports of one page in different locales are language\n * alternates. Set by import resolution, never authored.\n */\n sourcePage?: string;\n\n /** `translationOf:` page modifier — pages sharing it in different locales are language alternates (ahead of `sourcePage`). */\n translationOf?: string;\n\n /** Primary entity for this page */\n primaryEntity?: string;\n\n /**\n * Traits that drive UI for this page.\n * REQUIRED in trait-driven architecture.\n */\n traits?: PageTraitRef[];\n\n /** Is this the initial page for navigation? */\n isInitial?: boolean;\n\n /** Is this the page shown for a path no page matches (`[notFound]`)? */\n isNotFound?: boolean;\n\n /** Nav icon name — `@icon \"...\"` annotation on the page declaration. */\n icon?: string;\n\n /** Nav label — `@label \"...\"` annotation. Only a page that declares one is a `@pages` nav entry. */\n label?: string;\n\n /** Roles the nav entry shows for — `@roles \"a, b\"` annotation. Absent = everyone. */\n roles?: string[];\n};\n\n/**\n * Strict Zod schema for trait-driven pages.\n * Rejects unknown properties like 'sections'.\n */\n/** The page modifiers a `pages {}` remap entry declares for one imported page. */\nexport interface PageModifiers {\n access?: PageAccess;\n indexing?: PageIndexing;\n title?: PageMeta;\n description?: PageMeta;\n translationOf?: string;\n /** The page's nav entry, declared on a `pages {}` remap entry. */\n label?: string;\n icon?: string;\n roles?: string[];\n}\n\nexport const PageModifiersSchema = z.object({\n access: PageAccessSchema.optional(),\n indexing: PageIndexingSchema.optional(),\n title: PageMetaSchema.optional(),\n description: PageMetaSchema.optional(),\n translationOf: z.string().min(1).optional(),\n label: z.string().optional(),\n icon: z.string().optional(),\n roles: z.array(z.string().min(1)).min(1).optional(),\n}).strict();\n\nexport const OrbitalPageStrictSchema = z.object({\n id: PageIdSchema.optional(),\n name: z.string().min(1, 'Page name is required'),\n path: z.string().min(1, 'Page path is required').startsWith('/', 'Path must start with /'),\n primaryEntity: z.string().min(1, 'Primary entity is required'),\n traits: z.array(PageTraitRefSchema).min(1, 'Page must have at least one trait'),\n title: PageMetaSchema.optional(),\n description: PageMetaSchema.optional(),\n access: PageAccessSchema.optional(),\n indexing: PageIndexingSchema.optional(),\n sourcePage: z.string().min(1).optional(),\n translationOf: z.string().min(1).optional(),\n icon: z.string().optional(),\n label: z.string().optional(),\n roles: z.array(z.string().min(1)).min(1).optional(),\n}).strict(); // Reject unknown keys like 'sections'\n\n/**\n * Zod schema for OrbitalPage.\n * Trait-driven: pages have traits instead of static sections/patterns.\n * Uses .strict() to reject unknown keys like 'sections'.\n */\nexport const OrbitalPageSchema = z.object({\n id: PageIdSchema.optional(),\n name: z.string().min(1, 'Page name is required'),\n path: z.string(),\n protocol: z.string().min(1).optional(),\n address: SExprSchema.optional(),\n viewType: ViewTypeSchema.optional(),\n title: PageMetaSchema.optional(),\n description: PageMetaSchema.optional(),\n access: PageAccessSchema.optional(),\n indexing: PageIndexingSchema.optional(),\n sourcePage: z.string().min(1).optional(),\n translationOf: z.string().min(1).optional(),\n primaryEntity: z.string().optional(),\n traits: z.array(PageTraitRefSchema).optional(),\n isInitial: z.boolean().optional(),\n isNotFound: z.boolean().optional(),\n icon: z.string().optional(),\n label: z.string().optional(),\n roles: z.array(z.string().min(1)).min(1).optional(),\n}).strict().superRefine((page, ctx) => {\n if (page.protocol !== undefined) {\n if (page.path !== '') ctx.addIssue({ code: 'custom', path: ['path'], message: 'A protocol page has an empty path; its address says where it is reached' });\n return;\n }\n if (page.address !== undefined) ctx.addIssue({ code: 'custom', path: ['address'], message: 'A route page takes no address; its path is its address' });\n if (page.path.length === 0) ctx.addIssue({ code: 'custom', path: ['path'], message: 'Page path is required' });\n else if (!page.path.startsWith('/')) ctx.addIssue({ code: 'custom', path: ['path'], message: 'Path must start with /' });\n}); // Rejects unknown keys like 'sections' - use traits with render_ui effects\n\nexport type OrbitalPageInput = z.input<typeof OrbitalPageSchema>;\nexport type OrbitalPageStrictInput = z.input<typeof OrbitalPageStrictSchema>;\n\n// ============================================================================\n// Type Aliases (for cleaner imports)\n// ============================================================================\n\n/** Alias for OrbitalPage - preferred name */\nexport type Page = OrbitalPage;\n\n/** Alias for OrbitalPageSchema - preferred name */\nexport const PageSchema = OrbitalPageSchema;\n\n// ============================================================================\n// Protocols (EXEC-ENDPOINT-1)\n// ============================================================================\n\n/** The side of the program that serves a protocol's endpoints. Mirrors Rust `ProtocolSide`. */\nexport type ProtocolSide = 'client' | 'server' | 'process' | 'start';\nexport const ProtocolSideSchema = z.enum(['client', 'server', 'process', 'start']);\n\n/** One field of a protocol's address record. `ty` is the lolo type text. */\nexport interface ProtocolAddressField {\n name: string;\n ty: string;\n required: boolean;\n}\n\n/** A row of the protocol table (`orb reference protocols`, orbital-core `lang/protocols.rs`). */\nexport interface ProtocolSpec {\n name: string;\n address?: ProtocolAddressField[];\n viewer: boolean;\n grant?: string;\n side: ProtocolSide;\n}\n\nexport const ProtocolSpecSchema = z.object({\n name: z.string().min(1),\n address: z.array(z.object({ name: z.string().min(1), ty: z.string().min(1), required: z.boolean() }).strict()).optional(),\n viewer: z.boolean(),\n grant: z.string().min(1).optional(),\n side: ProtocolSideSchema,\n}).strict();\n\n/** `route` is the protocol of a page that declares none. */\nexport const ROUTE_PROTOCOL = 'route';\n\n/** A page reached by a path a client opens (no protocol word). */\nexport function isRoutePage(page: Pick<OrbitalPage, 'protocol'> & object): boolean {\n return page.protocol === undefined;\n}\n\n/** The protocol a page speaks: its protocol word, or `route`. */\nexport function protocolName(page: Pick<OrbitalPage, 'protocol'> & object): string {\n return page.protocol ?? ROUTE_PROTOCOL;\n}\n","/**\n * Service Types for Orbital Schema\n *\n * Defines external service integrations (REST APIs, WebSockets, MCP servers)\n * that can be used by orbital units via the `call_service` effect.\n *\n * @packageDocumentation\n */\n\nimport { z } from \"zod\";\nimport type { RuntimeValue } from './json.js';\n\n// ============================================================================\n// Service Type Enum\n// ============================================================================\n\n/**\n * Types of external services that can be integrated.\n */\nexport const SERVICE_TYPES = [\"rest\", \"socket\", \"mcp\"] as const;\n\nexport type ServiceType = (typeof SERVICE_TYPES)[number];\n\nexport const ServiceTypeSchema = z.enum(SERVICE_TYPES);\n\n// ============================================================================\n// REST Service Definition\n// ============================================================================\n\n/**\n * Configuration for a REST API service.\n *\n * @example\n * ```typescript\n * const weatherService: RestServiceDef = {\n * name: 'WeatherAPI',\n * type: 'rest',\n * baseUrl: 'https://api.openweathermap.org/data/2.5',\n * headers: {\n * 'Content-Type': 'application/json',\n * },\n * auth: {\n * type: 'api-key',\n * keyName: 'appid',\n * location: 'query',\n * },\n * };\n * ```\n */\nexport type RestServiceDef = {\n /** Unique service name (used in call_service effect) */\n name: string;\n\n /** Service type */\n type: \"rest\";\n\n /** Optional description */\n description?: string;\n\n /** Base URL for the API */\n baseUrl: string;\n\n /** Default headers to include in all requests */\n headers?: Record<string, string>;\n\n /** Authentication configuration */\n auth?: RestAuthConfig;\n\n /** Timeout in milliseconds (default: 30000) */\n timeout?: number;\n};\n\n/**\n * Authentication configuration for REST services.\n */\nexport type RestAuthConfig = {\n /** Authentication type */\n type: \"api-key\" | \"bearer\" | \"basic\" | \"oauth2\";\n\n /** For api-key: the query parameter or header name */\n keyName?: string;\n\n /** For api-key: where to place the key */\n location?: \"query\" | \"header\";\n\n /** Environment variable name containing the secret (for secure storage) */\n secretEnv?: string;\n};\n\nexport const RestAuthConfigSchema = z.object({\n type: z.enum([\"api-key\", \"bearer\", \"basic\", \"oauth2\"]),\n keyName: z.string().optional(),\n location: z.enum([\"query\", \"header\"]).optional(),\n secretEnv: z.string().optional(),\n});\n\nexport const RestServiceDefSchema = z.object({\n name: z.string().min(1, \"Service name is required\"),\n type: z.literal(\"rest\"),\n description: z.string().optional(),\n baseUrl: z.string().url(\"Base URL must be a valid URL\"),\n headers: z.record(z.string(), z.string()).optional(),\n auth: RestAuthConfigSchema.optional(),\n timeout: z.number().positive().optional(),\n});\n\n// ============================================================================\n// Socket Service Definition\n// ============================================================================\n\n/**\n * Configuration for a WebSocket service.\n *\n * @example\n * ```typescript\n * const chatService: SocketServiceDef = {\n * name: 'ChatSocket',\n * type: 'socket',\n * url: 'wss://chat.example.com',\n * events: {\n * inbound: ['message_received', 'user_joined', 'user_left'],\n * outbound: ['send_message', 'join_room', 'leave_room'],\n * },\n * };\n * ```\n */\nexport type SocketServiceDef = {\n /** Unique service name */\n name: string;\n\n /** Service type */\n type: \"socket\";\n\n /** Optional description */\n description?: string;\n\n /** WebSocket URL */\n url: string;\n\n /** Event definitions */\n events: SocketEvents;\n\n /** Reconnection configuration */\n reconnect?: {\n /** Enable automatic reconnection */\n enabled: boolean;\n /** Maximum reconnection attempts */\n maxAttempts?: number;\n /** Delay between attempts in ms */\n delayMs?: number;\n };\n};\n\n/**\n * Socket event definitions.\n */\nexport type SocketEvents = {\n /** Events received from server (maps to orbital events) */\n inbound: string[];\n\n /** Events sent to server (triggered by effects) */\n outbound: string[];\n};\n\nexport const SocketEventsSchema = z.object({\n inbound: z.array(z.string()),\n outbound: z.array(z.string()),\n});\n\nexport const SocketServiceDefSchema = z.object({\n name: z.string().min(1, \"Service name is required\"),\n type: z.literal(\"socket\"),\n description: z.string().optional(),\n url: z.string().url(\"WebSocket URL must be valid\"),\n events: SocketEventsSchema,\n reconnect: z\n .object({\n enabled: z.boolean(),\n maxAttempts: z.number().positive().optional(),\n delayMs: z.number().positive().optional(),\n })\n .optional(),\n});\n\n// ============================================================================\n// MCP Service Definition\n// ============================================================================\n\n/**\n * Configuration for an MCP (Model Context Protocol) server.\n *\n * @example\n * ```typescript\n * const mcpService: McpServiceDef = {\n * name: 'DatabaseMCP',\n * type: 'mcp',\n * serverPath: './mcp-servers/database',\n * capabilities: ['query', 'insert', 'update'],\n * };\n * ```\n */\nexport type McpServiceDef = {\n /** Unique service name */\n name: string;\n\n /** Service type */\n type: \"mcp\";\n\n /** Optional description */\n description?: string;\n\n /** Path to MCP server executable or module */\n serverPath: string;\n\n /** List of capabilities/tools exposed by the MCP server */\n capabilities: string[];\n\n /** Environment variables to pass to the MCP server */\n env?: Record<string, string>;\n};\n\nexport const McpServiceDefSchema = z.object({\n name: z.string().min(1, \"Service name is required\"),\n type: z.literal(\"mcp\"),\n description: z.string().optional(),\n serverPath: z.string().min(1, \"Server path is required\"),\n capabilities: z\n .array(z.string())\n .min(1, \"At least one capability is required\"),\n env: z.record(z.string(), z.string()).optional(),\n});\n\n// ============================================================================\n// Union Type: ServiceDefinition\n// ============================================================================\n\n/**\n * Union type for all service definitions.\n */\nexport type ServiceDefinition =\n | RestServiceDef\n | SocketServiceDef\n | McpServiceDef;\n\nexport const ServiceDefinitionSchema = z.discriminatedUnion(\"type\", [\n RestServiceDefSchema,\n SocketServiceDefSchema,\n McpServiceDefSchema,\n]);\n\n// ============================================================================\n// Service Reference (Inline OR Reference)\n// ============================================================================\n\n/**\n * ServiceRef - Service can be inline definition, reference object with overrides,\n * or bare string reference to an imported service.\n *\n * Reference format: \"Alias.services.ServiceName\"\n */\nexport type ServiceRef = ServiceDefinition | ServiceRefObject | string;\n\n/**\n * Phase F: Service reference object with override fields.\n *\n * Mirrors the Rust `ServiceRefObject` at\n * `orbital-rust/crates/orbital-core/src/schema/types.rs:353-375`. A caller\n * imports a service via `uses[]`, references it by `ref`, and supplies\n * any subset of these fields to override the imported service's defaults\n * during inlining.\n *\n * @example\n * ```typescript\n * const ref: ServiceRefObject = {\n * ref: \"Weather.services.openweather\",\n * baseUrl: \"https://staging.weather.example.com\",\n * headers: { \"X-Tenant\": \"acme\" },\n * };\n * ```\n */\nexport type ServiceRefObject = {\n /** Reference to imported service: \"Alias.services.ServiceName\" */\n ref: string;\n /** Override the service description */\n description?: string;\n /** Override the REST baseUrl */\n baseUrl?: string;\n /** Override or merge default headers (caller wins on key collision) */\n headers?: Record<string, string>;\n /** Override the WebSocket url */\n url?: string;\n /** Override the MCP server path */\n serverPath?: string;\n};\n\n/**\n * Checks if a service reference is a bare string reference.\n *\n * Type guard to determine if a service reference is a string reference\n * (format: \"Alias.services.ServiceName\") rather than an inline service\n * definition or a reference object.\n *\n * @param {ServiceRef} service - Service reference to check\n * @returns {boolean} True if service is a string reference, false otherwise\n *\n * @example\n * isServiceReference(\"Weather.services.openweather\"); // returns true\n * isServiceReference({ name: \"weather\", type: \"rest\" }); // returns false\n * isServiceReference({ ref: \"Weather.services.openweather\" }); // returns false\n */\nexport function isServiceReference(service: ServiceRef): service is string {\n return typeof service === \"string\";\n}\n\n/**\n * Phase F: Type guard for `ServiceRefObject` (the override-carrying form).\n *\n * @param {ServiceRef} service - Service reference to check\n * @returns {boolean} True if service is a ServiceRefObject\n */\nexport function isServiceReferenceObject(\n service: ServiceRef,\n): service is ServiceRefObject {\n return (\n typeof service === \"object\" &&\n service !== null &&\n \"ref\" in service &&\n !(\"type\" in service)\n );\n}\n\n/**\n * Validate service reference format: \"Alias.services.ServiceName\"\n */\nexport const ServiceRefStringSchema = z\n .string()\n .regex(\n /^[A-Z][a-zA-Z0-9]*\\.services\\.[a-zA-Z][a-zA-Z0-9]*$/,\n 'Service reference must be in format \"Alias.services.ServiceName\" (e.g., \"Weather.services.openweather\")',\n );\n\nexport const ServiceRefObjectSchema = z.object({\n ref: ServiceRefStringSchema,\n description: z.string().optional(),\n baseUrl: z.string().url(\"baseUrl override must be a valid URL\").optional(),\n headers: z.record(z.string(), z.string()).optional(),\n url: z.string().url(\"url override must be a valid URL\").optional(),\n serverPath: z.string().optional(),\n});\n\nexport const ServiceRefSchema = z.union([\n ServiceDefinitionSchema,\n ServiceRefObjectSchema,\n ServiceRefStringSchema,\n]);\n\n/**\n * Parses a service reference into its components.\n * \n * Extracts the alias and service name from a service reference string\n * in format \"Alias.services.ServiceName\". Returns null if not a valid reference.\n * \n * @param {string} ref - Service reference string\n * @returns {{ alias: string; serviceName: string } | null} Parsed components or null\n * \n * @example\n * parseServiceRef(\"Weather.services.openweather\"); // returns { alias: \"Weather\", serviceName: \"openweather\" }\n * parseServiceRef(\"invalid\"); // returns null\n */\nexport function parseServiceRef(\n ref: string,\n): { alias: string; serviceName: string } | null {\n const match = ref.match(\n /^([A-Z][a-zA-Z0-9]*)\\.services\\.([a-zA-Z][a-zA-Z0-9]*)$/,\n );\n if (!match) return null;\n return { alias: match[1], serviceName: match[2] };\n}\n\n// ============================================================================\n// Utility Functions\n// ============================================================================\n\n/**\n * Checks if a service definition is a REST service.\n * \n * Type guard to determine if a service definition represents a REST API service.\n * Used for service type discrimination and validation.\n * \n * @param {ServiceDefinition} service - Service definition to check\n * @returns {boolean} True if service is a REST service, false otherwise\n * \n * @example\n * isRestService({ name: \"weather\", type: \"rest\", baseUrl: \"...\" }); // returns true\n * isRestService({ name: \"chat\", type: \"socket\" }); // returns false\n */\nexport function isRestService(\n service: ServiceDefinition,\n): service is RestServiceDef {\n return service.type === \"rest\";\n}\n\n/**\n * Checks if a service definition is a Socket service.\n * \n * Type guard to determine if a service definition represents a WebSocket service.\n * Used for service type discrimination and validation.\n * \n * @param {ServiceDefinition} service - Service definition to check\n * @returns {boolean} True if service is a Socket service, false otherwise\n * \n * @example\n * isSocketService({ name: \"chat\", type: \"socket\", url: \"wss://...\" }); // returns true\n * isSocketService({ name: \"weather\", type: \"rest\" }); // returns false\n */\nexport function isSocketService(\n service: ServiceDefinition,\n): service is SocketServiceDef {\n return service.type === \"socket\";\n}\n\n/**\n * Checks if a service definition is an MCP service.\n * \n * Type guard to determine if a service definition represents an MCP\n * (Multiplayer Control Protocol) service. Used for service type discrimination.\n * \n * @param {ServiceDefinition} service - Service definition to check\n * @returns {boolean} True if service is an MCP service, false otherwise\n * \n * @example\n * isMcpService({ name: \"game\", type: \"mcp\", serverUrl: \"...\" }); // returns true\n * isMcpService({ name: \"chat\", type: \"socket\" }); // returns false\n */\nexport function isMcpService(\n service: ServiceDefinition,\n): service is McpServiceDef {\n return service.type === \"mcp\";\n}\n\n/**\n * Get all service names from a list of services.\n */\nexport function getServiceNames(services: ServiceDefinition[]): string[] {\n return services.map((s) => s.name);\n}\n\n/**\n * Find a service by name.\n */\nexport function findService(\n services: ServiceDefinition[],\n name: string,\n): ServiceDefinition | undefined {\n return services.find((s) => s.name.toLowerCase() === name.toLowerCase());\n}\n\n/**\n * Check if a service name exists (case-insensitive).\n */\nexport function hasService(\n services: ServiceDefinition[],\n name: string,\n): boolean {\n return services.some((s) => s.name.toLowerCase() === name.toLowerCase());\n}\n\n/**\n * Allowed leaf value for `ServiceParams`. Mirrors `EventPayloadValue`'s\n * recursive-array shape so integration call signatures can express the\n * nested structures real services need (port mappings, volume mounts,\n * pagination cursors), and so a value satisfying `EventPayloadValue`\n * also satisfies `ServiceParamsValue` without a cast — the same data\n * flows through `call-service` and `emit` without boundary widening.\n */\nexport type ServiceParamsValue =\n | string\n | number\n | boolean\n | Date\n | null\n | undefined\n | ServiceParams\n | readonly ServiceParamsValue[];\n\n/** Parameters passed to call-service effects. Recursive for nested request shapes. */\nexport type ServiceParams = {\n [key: string]: ServiceParamsValue;\n};\n\nexport interface CredentialIdentity {\n name: string;\n principal?: string;\n}\n\nexport function credentialStorageKey(identity: CredentialIdentity): string {\n if (typeof identity.name !== 'string' || (identity.principal !== undefined && typeof identity.principal !== 'string')) {\n throw new Error('credential identity requires string name and principal');\n }\n return JSON.stringify([identity.principal ?? null, identity.name]);\n}\n\nexport function resolveCredentialStatusIdentity(selection: RuntimeValue, principal: string | undefined): CredentialIdentity {\n if (selection !== null && typeof selection === 'object' && !Array.isArray(selection)) {\n const keys = Reflect.ownKeys(selection);\n if (keys.length !== 2 || !keys.includes('credential') || !keys.includes('scope') || !('credential' in selection) || !('scope' in selection)) {\n throw new Error('credential-status: expected { credential, scope: app | user }');\n }\n const { credential, scope } = selection;\n if (typeof credential !== 'string' || (scope !== 'app' && scope !== 'user')) {\n throw new Error('credential-status: expected { credential, scope: app | user }');\n }\n if (scope === 'app') return { name: credential };\n if (principal === undefined) throw new Error('credential-status: nobody is signed in');\n return { name: credential, principal };\n }\n if (principal === undefined) throw new Error('credential-status: nobody is signed in');\n if (typeof selection !== 'string') throw new Error(\"credential-status: the credential must be a secret knob's name\");\n return { name: selection, principal };\n}\n\nexport function credentialStatusConnected(value: string | undefined, principal: string | undefined): boolean {\n return value !== undefined && (principal !== undefined || value !== '');\n}\n","/**\n * Orbital Type (Self-Contained)\n *\n * Defines the Orbital - the atomic building block of applications.\n * Formula: Orbital = Entity × Traits × Pages\n *\n * An Orbital is a module that exports { entity, traits, pages }.\n * Use `uses` to import other Orbitals and access their components via:\n * - Alias.entity\n * - Alias.traits.TraitName\n * - Alias.pages.PageName\n *\n * @packageDocumentation\n */\n\nimport { z } from \"zod\";\nimport type { OsGrants } from \"./os-grants.js\";\nimport { OsGrantsSchema } from \"./os-grants.js\";\nimport type { OrbitalId, EntityId, TraitId, PageId } from \"./identity.js\";\nimport { OrbitalIdSchema, EntityIdSchema, TraitIdSchema, PageIdSchema } from \"./identity.js\";\nimport type { Entity, EntityPersistence } from \"./entity.js\";\nimport { EntitySchema, EntityPersistenceSchema } from \"./entity.js\";\nimport type { EntityField } from \"./field.js\";\nimport { EntityFieldSchema } from \"./field.js\";\nimport type { Page, PageAccess, PageIndexing, PageMeta, PageModifiers } from \"./page.js\";\nimport { PageSchema, PageAccessSchema, PageIndexingSchema, PageMetaSchema, PageModifiersSchema } from \"./page.js\";\nimport type {\n TraitRef,\n CallSiteConfig,\n EventPayloadField,\n EventScope,\n Trait,\n DeclaredTraitConfig,\n TraitEventListener,\n ConfigFieldDeclaration,\n TraitDispatchMode,\n DispatchMode,\n} from \"./trait.js\";\nimport {\n isInlineTrait,\n mergeCallSiteConfigOverrides,\n TraitRefSchema,\n EventPayloadFieldSchema,\n EventPayloadTypeMemberSchema,\n EventScopeSchema,\n TraitSchema,\n DeclaredTraitConfigSchema,\n TraitEventListenerSchema,\n ConfigFieldDeclarationSchema,\n TraitDispatchModeSchema,\n DispatchModeSchema,\n} from \"./trait.js\";\nimport type {\n DomainContext,\n DesignPreferences,\n SuggestedGuard,\n ThemeRef,\n} from \"./domain.js\";\nimport {\n DomainContextSchema,\n DesignPreferencesSchema,\n SuggestedGuardSchema,\n ThemeRefSchema,\n} from \"./domain.js\";\nimport type { ServiceRef } from \"./service.js\";\nimport { ServiceRefSchema } from \"./service.js\";\nimport type { Expression, SExpr } from \"./expression.js\";\nimport { ExpressionSchema, SExprListSchema, SExprSchema } from \"./expression.js\";\n\n// ============================================================================\n// Use Declaration (Import System)\n// ============================================================================\n\n/**\n * UseDeclaration - Import an external Orbital as a namespace.\n *\n * After importing, access components via:\n * - Alias.entity - The entity definition\n * - Alias.traits.TraitName - A specific trait\n * - Alias.pages.PageName - A specific page\n *\n * @example\n * ```json\n * {\n * \"uses\": [\n * { \"from\": \"./health.orb\", \"as\": \"Health\" },\n * { \"from\": \"std/behaviors/game-core\", \"as\": \"GameCore\" }\n * ]\n * }\n * ```\n */\nexport type UseDeclaration = {\n /**\n * Import source path:\n * - \"std/behaviors/game-core\" - Standard library\n * - \"./shared/health.orb\" - Local .orb file (relative path)\n * - \"../common/physics.orb\" - Parent directory .orb file\n * - \"@game-lib/enemies.orb\" - Scoped package (configured base)\n */\n from: string;\n\n /**\n * Alias for accessing imported components.\n * Used as namespace: Alias.entity, Alias.traits.X, Alias.pages.X\n */\n as: string;\n\n /** `uses A from \"…\" { config { … } }` override of the upstream schema's declared `config {}` — keys must exist in `OrbitalSchema.config`. */\n config?: DeclaredTraitConfig;\n\n /** `uses lazy A from \"…\"` — the imported behavior is compiled to its own `.orb` and loaded when one of its pages is opened; see {@link LazyPage}. */\n lazy?: boolean;\n};\n\nexport const UseDeclarationSchema = z.object({\n from: z.string().min(1, \"Import source is required\"),\n as: z\n .string()\n .min(1, \"Alias is required\")\n .regex(\n /^[A-Z][a-zA-Z0-9]*$/,\n 'Alias must be PascalCase (e.g., \"Health\", \"GameCore\")',\n ),\n config: DeclaredTraitConfigSchema.optional(),\n lazy: z.boolean().optional(),\n});\n\n/**\n * A page served by a lazily-used behavior. The importer's `.orb` lists the\n * page so routing and prerender know it; the behavior itself lives in the\n * `.orb` at `orbRef` (relative to the importer's `.orb`) and is fetched when\n * the page is opened.\n */\nexport type LazyPage = {\n path: string;\n orbital: string;\n orbRef: string;\n /** The link and navigate targets inside the page's behavior, sorted and unique; page reachability follows them between lazy pages. */\n links?: string[];\n /** The page's protocol (`http`, `stdio`, `boot`); absent for a route. A lazy orbital with an endpoint page loads when the host starts. */\n protocol?: string;\n /** The eager orbital that preceded the lazy one in the importer: where its listeners sit in fan-out order. */\n after?: string;\n /** The traits the page places. */\n places?: string[];\n /** The traits of the page's orbital the kernel registers before the behavior is loaded (EXEC-LOAD-2). */\n traits?: LazyTrait[];\n};\n\n/** A trait of a lazily-used orbital as its importer records it: its name, the events it listens to, and whether it has a background tick. */\nexport type LazyTrait = {\n name: string;\n /** The trait's declared dispatch mode: a `[client]` trait never triggers a server load. */\n dispatchMode: DispatchMode;\n listens?: TraitEventListener[];\n backgroundTicks?: boolean;\n};\n\nexport const LazyTraitSchema = z.object({\n name: z.string().min(1),\n dispatchMode: DispatchModeSchema,\n listens: z.array(TraitEventListenerSchema).optional(),\n backgroundTicks: z.boolean().optional(),\n});\n\nexport const LazyPageSchema = z.object({\n path: z.string().min(1),\n orbital: z.string().min(1),\n orbRef: z.string().min(1),\n links: z.array(z.string()).optional(),\n protocol: z.string().optional(),\n after: z.string().optional(),\n places: z.array(z.string()).optional(),\n traits: z.array(LazyTraitSchema).optional(),\n});\n\n// ============================================================================\n// Expect Declaration (Consumer-Side Requirements)\n// ============================================================================\n\n/**\n * ExpectDeclaration - a consumer-side requirement: \"some sibling orbital\n * provides this, and here is the minimal typed slice of it I rely on.\"\n *\n * The dual of a provider: the entity `[identity]` tag declares \"I am the\n * roster\"; `expects identity` declares \"I read the roster\". Standalone\n * validation trusts the declaration and uses its shape as the local type\n * environment; composed-program validation link-checks it against the real\n * provider. The shape reuses the canonical `EntityField` so all type\n * compatibility flows through the one compat owner. Compile-time only.\n * See docs/Almadar_LOLO_Expects_Proposal.md.\n */\nexport type ExpectDeclaration = ExpectDeclarationShape & {\n /** Set when the obligation arrived through a spec import: an unprovided one is an error, not deferred. */\n strict?: boolean;\n};\n\ntype ExpectDeclarationShape =\n | {\n /** `expects identity Customer { role : \"admin\" | \"member\" }` — the `@user` fields this orbital reads, typed. */\n kind: \"identity\";\n name?: string;\n shape?: EntityField[];\n }\n | {\n /** `expects entity OrderRecord { totalAmount : number }` — a sibling entity this orbital touches. Shape omitted = opaque reference. */\n kind: \"entity\";\n name: string;\n shape?: EntityField[];\n /** `[persistent]` / `[runtime]`: the storage mode the provider must declare. */\n persistence?: EntityPersistence;\n /** `[shared]` / `[browser]`: the provider must carry the same tag. */\n shared?: boolean;\n browser?: boolean;\n /** `@read|@create|@update|@delete <expr>`: the provider's policy must be this expression. */\n read_policy?: SExpr;\n create_policy?: SExpr;\n update_policy?: SExpr;\n delete_policy?: SExpr;\n /** `@<op> none \"<reason>\"`: the provider must declare a waiver for each op named. */\n access_waivers?: Entity[\"access_waivers\"];\n /** `@invariant <expr>` (spec only): every stored row satisfies each, proved by `orb validate`. */\n invariants?: SExpr[];\n }\n | {\n /** `expects event Checkout.ORDER_PLACED` — a sibling trait produces this event (Phase 2). */\n kind: \"event\";\n traitName: string;\n event: string;\n /** The payload fields the event must carry, checked against the provider's `emits`. */\n payload?: EventPayloadField[];\n }\n | {\n /**\n * `expects page \"/articles/:slug\"` — a route a sibling orbital declares\n * and this one navigates to. The one cross-boundary edge a `navigate`\n * effect cannot state for itself: the effect carries a static prefix\n * (`/articles/`), the provider a pattern (`/articles/:slug`), and the\n * parameterisation is information the usage does not hold. Derived, not\n * hand-authored — `orb behaviors expects` derives them.\n */\n kind: \"page\";\n path: string;\n /** `expects page \"/p\" -> A, B`: the traits the provider page must mount. */\n traits?: string[];\n }\n | {\n /** `expects trait T { state paid }`: the provider trait declares this state. */\n kind: \"state\";\n traitName: string;\n state: string;\n /** `state paid @holds <expr>` (spec only): holds over `@entity` while the trait is in the state, proved by `orb validate`. */\n holds?: SExpr;\n }\n | {\n /** `expects trait T { state idle { PAY -> paid } }`: the provider trait has this transition. */\n kind: \"transition\";\n traitName: string;\n from: string;\n event: string;\n to: string;\n /** `@ensures <expr>`: the outcome contract owed at this transition (`@fromEntity` is the row before it). */\n ensures?: SExpr[];\n }\n | {\n /** `expects config { stdio : string = \"pipe\" }`: a trait declares this knob, of this type and stated default. */\n kind: \"config\";\n name: string;\n knob: ConfigFieldDeclaration;\n };\n\n/**\n * The entity name an expectation is ABOUT, or undefined when it is not about\n * an entity at all (`event` names a trait's event, `page` a route, and a bare\n * `expects identity` defers to whoever is tagged `[identity]`).\n *\n * TS counterpart of the compiler's `expectations::expected_entity_names` and\n * L1's `types::expected_entity_names`. Exists so callers stop reaching for\n * `kind !== \"event\"` as a stand-in for \"has a name\" — a proxy that silently\n * became wrong the moment a second nameless kind was added.\n */\nexport function expectedEntityName(decl: ExpectDeclaration): string | undefined {\n switch (decl.kind) {\n case \"entity\":\n return decl.name;\n case \"identity\":\n return decl.name;\n case \"event\":\n case \"page\":\n case \"state\":\n case \"transition\":\n case \"config\":\n return undefined;\n }\n}\n\nexport const ExpectDeclarationSchema = z.discriminatedUnion(\"kind\", [\n z.object({\n strict: z.boolean().optional(),\n kind: z.literal(\"identity\"),\n name: z.string().optional(),\n shape: z.array(EntityFieldSchema).optional(),\n }),\n z.object({\n strict: z.boolean().optional(),\n kind: z.literal(\"entity\"),\n name: z.string().min(1, \"Expected entity name is required\"),\n shape: z.array(EntityFieldSchema).optional(),\n persistence: EntityPersistenceSchema.optional(),\n shared: z.boolean().optional(),\n browser: z.boolean().optional(),\n read_policy: SExprSchema.optional(),\n create_policy: SExprSchema.optional(),\n update_policy: SExprSchema.optional(),\n delete_policy: SExprSchema.optional(),\n access_waivers: z\n .object({\n read: z.string().optional(),\n create: z.string().optional(),\n update: z.string().optional(),\n delete: z.string().optional(),\n })\n .optional(),\n invariants: z.array(SExprSchema).optional(),\n }),\n z.object({\n strict: z.boolean().optional(),\n kind: z.literal(\"event\"),\n traitName: z.string().min(1, \"Expected event trait name is required\"),\n event: z.string().min(1, \"Expected event name is required\"),\n payload: z.array(EventPayloadFieldSchema).optional(),\n }),\n z.object({\n strict: z.boolean().optional(),\n kind: z.literal(\"page\"),\n path: z.string().min(1, \"Expected page path is required\"),\n traits: z.array(z.string().min(1)).optional(),\n }),\n z.object({\n strict: z.boolean().optional(),\n kind: z.literal(\"state\"),\n traitName: z.string().min(1, \"Expected state trait name is required\"),\n state: z.string().min(1, \"Expected state name is required\"),\n holds: SExprSchema.optional(),\n }),\n z.object({\n strict: z.boolean().optional(),\n kind: z.literal(\"transition\"),\n traitName: z.string().min(1, \"Expected transition trait name is required\"),\n from: z.string().min(1),\n event: z.string().min(1),\n to: z.string().min(1),\n ensures: SExprListSchema.optional(),\n }),\n z.object({\n strict: z.boolean().optional(),\n kind: z.literal(\"config\"),\n name: z.string().min(1, \"Expected config knob name is required\"),\n knob: ConfigFieldDeclarationSchema,\n }),\n]);\n\n/** A cross-boundary usage `orb behaviors expects` could not turn into a declaration. */\nexport const ExpectationDiagnosticSchema = z\n .object({\n kind: z.enum([\"unknown-orbital\", \"identity-field-not-declared\", \"entity-field-not-declared\", \"event-source-unknown\"]),\n orbital: z.string(),\n entity: z.string().optional(),\n field: z.string().optional(),\n })\n .strict();\nexport type ExpectationDiagnostic = z.infer<typeof ExpectationDiagnosticSchema>;\n\n/**\n * What `orb behaviors expects <organism>` prints: every orbital's derived `expects`\n * (docs/Almadar_LOLO_Expects_Proposal.md §7; the derivation lives in `orbital-core`).\n */\nexport const OrganismExpectationsSchema = z.record(z.string(),\n z.object({ expectations: z.array(ExpectDeclarationSchema), diagnostics: z.array(ExpectationDiagnosticSchema) }).strict(),\n);\nexport type OrganismExpectations = z.infer<typeof OrganismExpectationsSchema>;\n\n// ============================================================================\n// Entity Reference (Inline OR Reference)\n// ============================================================================\n\n/**\n * EntityCall - Reference to an imported entity with optional override arguments.\n *\n * Treats the imported entity as a callable function: the atom's declared\n * fields are defaults and the caller can append extra fields, rename, or\n * override persistence/collection. The discriminator key is `extends` to\n * stay consistent with the Phase A.5 Rust schema (`EntityRef::Extends`).\n *\n * @example\n * ```json\n * // Inherit ModalRecord's fields, rename to CartItem, add pendingId\n * {\n * \"extends\": \"Modal.entity\",\n * \"name\": \"CartItem\",\n * \"fields\": [{ \"name\": \"pendingId\", \"type\": \"string\" }]\n * }\n * ```\n */\nexport type EntityCall = {\n /** Reference to the imported entity using the \"extends\" discriminator key */\n extends: string;\n /** V4 dual-carry id sibling of `extends` — optional until the Phase-7 flip. */\n extendsId?: EntityId;\n /** Optional rename for the resulting entity */\n name?: string;\n /** Additional fields appended to the inherited set (caller wins on name collision) */\n fields?: EntityField[];\n /** Optional persistence override */\n persistence?: EntityPersistence;\n /** Optional collection override */\n collection?: string;\n};\n\n/**\n * EntityRef - Entity can be inline definition OR reference to imported entity.\n *\n * Reference formats:\n * - Simple string: \"Alias.entity\"\n * - Call form (with overrides): { extends: \"Alias.entity\", name?, fields?, persistence?, collection? }\n *\n * @example\n * ```json\n * // Inline\n * { \"entity\": { \"name\": \"Player\", \"fields\": [...] } }\n *\n * // Simple reference\n * { \"entity\": \"Goblin.entity\" }\n *\n * // Call form with overrides (Phase F)\n * { \"entity\": { \"extends\": \"Modal.entity\", \"name\": \"CartItem\", \"fields\": [...] } }\n * ```\n */\nexport type EntityRef = Entity | string | EntityCall;\n\n/**\n * Checks if an entity reference is a string reference.\n *\n * Type guard to determine if an EntityRef is a string reference\n * (format: \"Alias.entity\") rather than an inline entity definition or\n * an EntityCall object.\n *\n * Note: This guard intentionally narrows to `string` only. To check for\n * any non-inline form (string OR EntityCall), use `isEntityReferenceAny`.\n *\n * @param {EntityRef} entity - Entity reference to check\n * @returns {boolean} True if entity is a string reference, false otherwise\n *\n * @example\n * const ref1 = \"User.entity\"; // string reference\n * const ref2 = { name: \"User\", fields: [...] }; // inline definition\n * const ref3 = { extends: \"User.entity\" }; // EntityCall\n *\n * isEntityReference(ref1); // returns true\n * isEntityReference(ref2); // returns false\n * isEntityReference(ref3); // returns false\n */\nexport function isEntityReference(entity: EntityRef): entity is string {\n return typeof entity === \"string\";\n}\n\n/**\n * Checks if an entity reference is an EntityCall (extends form).\n *\n * Type guard for the call-form EntityRef introduced in Phase F. EntityCall\n * is identified by the presence of the \"extends\" discriminator key.\n *\n * @param {EntityRef} entity - Entity reference to check\n * @returns {boolean} True if entity is an EntityCall object\n *\n * @example\n * isEntityCall({ extends: \"Modal.entity\", name: \"CartItem\" }); // returns true\n * isEntityCall(\"Modal.entity\"); // returns false\n * isEntityCall({ name: \"Modal\", fields: [] }); // returns false\n */\nexport function isEntityCall(entity: EntityRef): entity is EntityCall {\n return typeof entity === \"object\" && entity !== null && \"extends\" in entity;\n}\n\n/**\n * Checks if an entity reference is any non-inline form (string or EntityCall).\n *\n * Broader companion to `isEntityReference` that recognizes both the bare\n * string reference and the Phase F EntityCall form.\n *\n * @param {EntityRef} entity - Entity reference to check\n * @returns {boolean} True if entity is a string reference or EntityCall\n */\nexport function isEntityReferenceAny(\n entity: EntityRef,\n): entity is string | EntityCall {\n return isEntityReference(entity) || isEntityCall(entity);\n}\n\n/**\n * Validate entity reference format: \"Alias.entity\", or the placeholder a\n * reference-form orbital carries before inline, \"Alias.orbitals.Name.entity\".\n */\nexport const EntityRefStringSchema = z\n .string()\n .regex(\n /^[A-Z][a-zA-Z0-9]*(\\.orbitals\\.[A-Z][a-zA-Z0-9]*)?\\.entity$/,\n 'Entity reference must be in format \"Alias.entity\" (e.g., \"Goblin.entity\") or \"Alias.orbitals.Name.entity\"',\n );\n\n/**\n * Validate EntityCall (extends form) shape.\n *\n * Phase F.4 refines:\n * - The `fields` override array must not contain duplicate field names\n * (case-sensitive). Duplicates would silently shadow each other during\n * the inliner's field-merge step, so reject at the schema boundary.\n */\nexport const EntityCallSchema = z\n .object({\n extends: z\n .string()\n .regex(\n /^[A-Z][a-zA-Z0-9]*\\.entity$/,\n 'EntityCall \"extends\" must be in format \"Alias.entity\"',\n ),\n name: z.string().optional(),\n fields: z.array(EntityFieldSchema).optional(),\n persistence: EntityPersistenceSchema.optional(),\n collection: z.string().optional(),\n })\n .refine(\n (call) => {\n if (!call.fields) return true;\n const seen = new Set<string>();\n for (const field of call.fields) {\n if (field.name === undefined) continue;\n if (seen.has(field.name)) return false;\n seen.add(field.name);\n }\n return true;\n },\n {\n message:\n 'EntityCall \"fields\" override list must not contain duplicate field names',\n path: [\"fields\"],\n },\n );\n\nexport const EntityRefSchema = z.union([\n EntitySchema,\n EntityRefStringSchema,\n EntityCallSchema,\n]);\n\n// ============================================================================\n// Page Reference (Inline OR Reference)\n// ============================================================================\n\n/**\n * PageRefObject - Reference to imported page with optional override arguments.\n *\n * Phase F adds `linkedEntity` and `traits` arguments so a caller can rebind\n * the imported page's entity and trait set, treating the page as a callable\n * function.\n */\nexport type PageRefObject = {\n /**\n * Reference to imported page: \"Alias.pages.PageName\"\n */\n ref: string;\n\n /** V4 dual-carry id sibling of `ref` — optional until the Phase-7 flip. */\n refId?: PageId;\n\n /**\n * Phase 1.2: optional registry path disambiguator. Pairs with `ref` to\n * explicitly name which `uses` entry the alias was imported from\n * (e.g. \"std/behaviors/atoms/std-browse\"). Helpful for programmatic\n * descriptor construction and inline-phase disambiguation when multiple\n * registries expose the same alias prefix.\n */\n from?: string;\n\n /**\n * Optional path override.\n * If provided, overrides the original page's path.\n */\n path?: string;\n\n /**\n * Phase F: rebind the page's entity to the caller's entity.\n * Identifier-substitution pass rewrites references to the original\n * entity inside the imported page.\n */\n linkedEntity?: string;\n\n /** V4 dual-carry id sibling of `linkedEntity` — optional until the Phase-7 flip. */\n linkedEntityId?: EntityId;\n\n /**\n * Phase F: override the page's trait set with the caller-supplied list.\n * Each entry may be a string trait reference or an inline trait reference object.\n */\n traits?: TraitRef[];\n\n /** V4 dual-carry id sibling of `traits` — optional until the Phase-7 flip. */\n traitRefIds?: TraitId[];\n\n /** Explicit page-modifier overrides; absent fields inherit the upstream page's. */\n access?: PageAccess;\n indexing?: PageIndexing;\n title?: PageMeta;\n description?: PageMeta;\n /** `translationOf:` — the translation group this page belongs to. */\n translationOf?: string;\n /** The page's nav entry (`@label`/`@icon`/`@roles`). */\n label?: string;\n icon?: string;\n roles?: string[];\n};\n\n/**\n * PageRef - Page can be inline definition OR reference to imported page.\n *\n * Reference formats:\n * - \"Alias.pages.PageName\" - Simple reference (keeps original path)\n * - { ref: \"Alias.pages.PageName\", path: \"/custom\" } - Reference with path override\n *\n * @example\n * ```json\n * // Inline\n * { \"name\": \"Dashboard\", \"path\": \"/\", ... }\n *\n * // Simple reference\n * \"User.pages.Profile\"\n *\n * // Reference with path override\n * { \"ref\": \"User.pages.Profile\", \"path\": \"/my-profile\" }\n * ```\n */\nexport type PageRef = Page | string | PageRefObject;\n\n/**\n * Checks if a page reference is a string reference.\n * \n * Type guard to determine if a PageRef is a simple string reference\n * (format: \"Alias.pages.PageName\") rather than an inline page definition or object reference.\n * \n * @param {PageRef} page - Page reference to check\n * @returns {boolean} True if page is a string reference, false otherwise\n * \n * @example\n * const ref1 = \"User.pages.Profile\"; // string reference\n * const ref2 = { name: \"Dashboard\", path: \"/\" }; // inline definition\n * \n * isPageReferenceString(ref1); // returns true\n * isPageReferenceString(ref2); // returns false\n */\nexport function isPageReferenceString(page: PageRef): page is string {\n return typeof page === \"string\";\n}\n\n/**\n * Checks if a page reference is a reference object.\n * \n * Type guard to determine if a PageRef is an object reference\n * with a 'ref' property rather than an inline page definition.\n * \n * @param {PageRef} page - Page reference to check\n * @returns {boolean} True if page is a reference object, false otherwise\n * \n * @example\n * const ref1 = { ref: \"User.pages.Profile\", path: \"/custom\" }; // reference object\n * const ref2 = { name: \"Dashboard\", path: \"/\" }; // inline definition\n * \n * isPageReferenceObject(ref1); // returns true\n * isPageReferenceObject(ref2); // returns false\n */\nexport function isPageReferenceObject(page: PageRef): page is PageRefObject {\n return typeof page === \"object\" && \"ref\" in page && !(\"name\" in page);\n}\n\n/**\n * Checks if a page reference is any type of reference.\n * \n * Type guard to determine if a PageRef is a reference (string or object)\n * rather than an inline page definition.\n * \n * @param {PageRef} page - Page reference to check\n * @returns {boolean} True if page is a reference, false if inline definition\n * \n * @example\n * const ref1 = \"User.pages.Profile\"; // string reference\n * const ref2 = { ref: \"User.pages.Profile\", path: \"/custom\" }; // object reference\n * const ref3 = { name: \"Dashboard\", path: \"/\" }; // inline definition\n * \n * isPageReference(ref1); // returns true\n * isPageReference(ref2); // returns true\n * isPageReference(ref3); // returns false\n */\nexport function isPageReference(page: PageRef): page is string | PageRefObject {\n return isPageReferenceString(page) || isPageReferenceObject(page);\n}\n\n/**\n * Validate page reference format: \"Alias.pages.PageName\"\n */\nexport const PageRefStringSchema = z\n .string()\n .regex(\n /^[A-Z][a-zA-Z0-9]*\\.pages\\.[A-Z][a-zA-Z0-9]*$/,\n 'Page reference must be in format \"Alias.pages.PageName\" (e.g., \"User.pages.Profile\")',\n );\n\nexport const PageRefObjectSchema = z.object({\n ref: PageRefStringSchema,\n refId: PageIdSchema.optional(),\n // Phase 1.2: optional registry path disambiguator, pairs with `ref`.\n from: z.string().optional(),\n path: z.string().startsWith(\"/\").optional(),\n linkedEntity: z.string().optional(),\n linkedEntityId: EntityIdSchema.optional(),\n traits: z.array(TraitRefSchema).optional(),\n traitRefIds: z.array(TraitIdSchema).optional(),\n access: PageAccessSchema.optional(),\n indexing: PageIndexingSchema.optional(),\n title: PageMetaSchema.optional(),\n description: PageMetaSchema.optional(),\n translationOf: z.string().min(1).optional(),\n label: z.string().optional(),\n icon: z.string().optional(),\n roles: z.array(z.string().min(1)).min(1).optional(),\n});\n\nexport const PageRefSchema = z.union([\n PageSchema,\n PageRefStringSchema,\n PageRefObjectSchema,\n]);\n\n// ============================================================================\n// Orbital Reference\n// ============================================================================\n\n/**\n * OrbitalRefObject - Reference to an imported orbital (\"Alias.orbitals.OrbitalName\"),\n * mirroring PageRefObject/TraitRef's reference-with-overrides shape.\n *\n * Set on `OrbitalDefinition.reference` by lowering and cleared by the\n * compiler's inline phase / runtime's resolver — transient, never present on\n * a fully resolved orbital.\n */\nexport type OrbitalRefObject = {\n /** Reference to imported orbital: \"Alias.orbitals.OrbitalName\" */\n ref: string;\n\n /** V4 dual-carry id sibling of `ref` — optional until the Phase-7 flip. */\n refId?: OrbitalId;\n\n /** `entity E` — rebind the primary entity (bare name). */\n entity?: string;\n\n /** `fields { up: local }` — primary-entity field renames. */\n fields?: Readonly<Record<string, string>>;\n\n /** `pages { \"/up\": \"/local\" }` — route remap; unmapped paths keep the upstream value. */\n pages?: Readonly<Record<string, string>>;\n\n /** `pages { \"/up\": \"/local\" [access: …] }` — page modifiers per remap entry, keyed by the upstream path. */\n pageModifiers?: Readonly<Record<string, PageModifiers>>;\n\n /** Trim the imported trait set to everything but these. */\n omit?: readonly string[];\n\n /** Trim the imported trait set to only these. */\n only?: readonly string[];\n\n /** Overrides of the upstream orbital's DECLARED knobs only. */\n config?: DeclaredTraitConfig;\n\n /** `events { UP: LOCAL }` — orbital-scope rename over every trait's emits + listen keys. */\n events?: Readonly<Record<string, string>>;\n\n /**\n * `roles { approver: [owner, project_manager] employee: team_member }` —\n * remap the upstream's role literals to the consumer roster. Values are\n * ALWAYS arrays, even for a single target: one target is a literal swap\n * (`(= @user.role \"approver\")` → `(= @user.role \"owner\")`); a list rewrites\n * an equality comparison into `(array/includes [...] @user.role)` (and\n * wraps `!=`/`neq` in `not`), and expands the literals of an existing\n * `array/includes` haystack. Every target must be a member of the\n * consumer's `[identity]` role vocabulary.\n */\n roles?: Readonly<Record<string, readonly string[]>>;\n\n /**\n * `entities { Employee: Person }` — retarget an out-of-orbital relation\n * (an entity named by the imported closure but declared by another\n * orbital of the same upstream alias) to a consumer entity. Applied to\n * relation targets, `@Entity` tokens, fetch/persist targets, policy\n * comparisons, and page `primaryEntity` / `sourceEntityDefinition`.\n * `entity E` (the primary rebind) is a separate field, not part of this map.\n */\n entities?: Readonly<Record<string, string>>;\n\n /**\n * `pages { \"/up\": \"/local\" -> TraitA, TraitB }` — sibling traits mounted\n * onto the remapped page, keyed by the UPSTREAM page path. These traits\n * ride the reference body unprefixed; `omit`/`only` never apply to them.\n */\n mounts?: Readonly<Record<string, readonly string[]>>;\n\n /**\n * `extend { field : type = default }` — ADD fields to the upstream primary\n * entity (full entity-field syntax; `fields {}` stays rename-only). Applied\n * after `fields {}` renames; a name colliding with the upstream primary\n * (post-rename) or a `fields {}` rename target refuses resolution\n * (`ORB_O_EXTEND_FIELD_COLLISION`). A relation-typed added field's target\n * resolves in the CONSUMER's own scope, never upstream's. An added field\n * no trait of the materialized orbital ever reads/sets/renders/forwards is\n * a `orb validate` WARNING (`ORB_O_EXTEND_FIELD_UNREAD`), not a JS-resolve\n * concern.\n */\n extend?: readonly EntityField[];\n\n /**\n * `mock { field: \"a, b\" }` — sample data for fields of the materialized\n * primary entity (named after `fields {}` renames, or an `extend {}` field),\n * replacing the upstream field's `@mock`. A key naming no such field is\n * `ORB_O_MOCK_UNKNOWN_FIELD`.\n */\n mock?: Readonly<Record<string, string>>;\n\n /**\n * `retype { field : type = default }` — replace the type/default of fields the\n * upstream primary entity already declares (named after `fields {}` renames).\n * Unlike `extend {}`, every name MUST exist (`ORB_O_RETYPE_UNKNOWN_FIELD`); a\n * field also in `extend {}` or listed twice is `ORB_O_RETYPE_FIELD_CONFLICT`.\n */\n retype?: readonly EntityField[];\n\n /**\n * `entity Name [persistent: tbl]` — override the materialized primary entity's\n * persistence mode. Refused when the upstream entity is not `persistent`\n * (`ORB_O_ENTITY_PERSISTENCE_LOCKED`), the factory-runtime rule.\n */\n persistence?: EntityPersistence;\n\n /** `entity Name [persistent: tbl]` — override the primary entity's collection. */\n collection?: string;\n\n /** Entity-header flags of the `entity` line; each switches the flag ON. */\n shared?: boolean;\n identity?: boolean;\n browser?: boolean;\n\n /**\n * `traits { UpstreamTrait { … } }` — per-imported-trait overrides keyed by the\n * trait's UPSTREAM name (the §8 trait-reference body). A key naming no upstream\n * trait is `ORB_O_TRAITS_UNKNOWN_TRAIT`; one `omit`/`only` dropped is\n * `ORB_O_TRAITS_OMITTED_TRAIT`; a config key the trait never declares is\n * `ORB_O_CONFIG_UNKNOWN_KEY`.\n */\n traits?: Readonly<Record<string, OrbitalRefTraitOverride>>;\n\n /**\n * `listens { Source.EVENT -> Target.TRIGGER }` — declared routes INTO the\n * imported set. Each entry appends one listen to the imported trait named\n * by `trait` (upstream name). A source naming an imported trait follows\n * the prefix; any other source is a host sibling and keeps its name. The\n * trigger is in the post-`events {}` vocabulary. A target outside the\n * imported set (after omit/only) refuses resolution\n * (`ORB_O_LISTEN_TARGET_UNKNOWN`).\n */\n listens?: readonly OrbitalRefListen[];\n};\n\n/** One orbital-import `traits {}` entry: the trait-reference override surface for one imported trait. */\nexport type OrbitalRefTraitOverride = {\n /** `-> Entity`: rebinds the trait's linked entity. */\n linkedEntity?: string;\n config?: DeclaredTraitConfig;\n events?: Readonly<Record<string, string>>;\n fields?: Readonly<Record<string, string>>;\n /** Replaces the trait's whole `listens` array. */\n listens?: readonly TraitEventListener[];\n emitsScope?: EventScope;\n /** `Up [client|optimistic|server]`: replaces the imported trait's declared dispatch mode. */\n dispatch?: TraitDispatchMode;\n};\n\n/** One orbital-import `listens {}` entry: the target imported trait plus an ordinary listen. */\nexport type OrbitalRefListen = TraitEventListener & { trait: string };\n\n/**\n * Validate orbital reference format: \"Alias.orbitals.OrbitalName\"\n */\nexport const OrbitalRefStringSchema = z\n .string()\n .regex(\n /^[A-Z][a-zA-Z0-9]*\\.orbitals\\.[A-Z][a-zA-Z0-9]*$/,\n 'Orbital reference must be \"Alias.orbitals.OrbitalName\"',\n );\n\nexport const OrbitalRefObjectSchema = z.object({\n ref: OrbitalRefStringSchema,\n refId: OrbitalIdSchema.optional(),\n entity: z.string().optional(),\n fields: z.record(z.string(), z.string()).optional(),\n pages: z.record(z.string(), z.string()).optional(),\n pageModifiers: z.record(z.string(), PageModifiersSchema).optional(),\n omit: z.array(z.string()).optional(),\n only: z.array(z.string()).optional(),\n config: DeclaredTraitConfigSchema.optional(),\n events: z.record(z.string(), z.string()).optional(),\n roles: z.record(z.string(), z.array(z.string())).optional(),\n entities: z.record(z.string(), z.string()).optional(),\n mounts: z.record(z.string(), z.array(z.string())).optional(),\n extend: z.array(EntityFieldSchema).optional(),\n mock: z.record(z.string(), z.string()).optional(),\n retype: z.array(EntityFieldSchema).optional(),\n persistence: EntityPersistenceSchema.optional(),\n collection: z.string().optional(),\n shared: z.boolean().optional(),\n identity: z.boolean().optional(),\n browser: z.boolean().optional(),\n traits: z\n .record(\n z.string(),\n z.object({\n linkedEntity: z.string().optional(),\n config: DeclaredTraitConfigSchema.optional(),\n events: z.record(z.string(), z.string()).optional(),\n fields: z.record(z.string(), z.string()).optional(),\n listens: z.array(TraitEventListenerSchema).optional(),\n emitsScope: EventScopeSchema.optional(),\n dispatch: TraitDispatchModeSchema.optional(),\n }),\n )\n .optional(),\n listens: z.array(TraitEventListenerSchema.extend({ trait: z.string() })).optional(),\n});\n\n/**\n * Parses an orbital reference.\n *\n * Extracts the alias and orbital name from an orbital reference\n * in format \"Alias.orbitals.OrbitalName\". Returns null if not a valid orbital reference.\n *\n * @param {string} ref - Orbital reference to parse\n * @returns {{ alias: string; orbitalName: string } | null} Parsed reference or null\n *\n * @example\n * parseOrbitalRef(\"TimeTracking.orbitals.TimesheetPanelOrbital\"); // returns { alias: \"TimeTracking\", orbitalName: \"TimesheetPanelOrbital\" }\n * parseOrbitalRef(\"TimeTracking.traits.X\"); // returns null\n */\nexport function parseOrbitalRef(\n ref: string,\n): { alias: string; orbitalName: string } | null {\n const match = ref.match(/^([A-Z][a-zA-Z0-9]*)\\.orbitals\\.([A-Z][a-zA-Z0-9]*)$/);\n if (!match) return null;\n return { alias: match[1], orbitalName: match[2] };\n}\n\n// ============================================================================\n// Trait Reference Extensions\n// ============================================================================\n\n/**\n * Extended trait reference format for imported traits.\n *\n * Formats:\n * - \"TraitName\" - Local trait (inline or from uses without alias)\n * - \"Alias.traits.TraitName\" - Imported trait with namespace\n *\n * The existing TraitRef type already supports these via string.\n */\n\n/**\n * Validate trait reference format for imported traits.\n */\nexport const ImportedTraitRefStringSchema = z\n .string()\n .regex(\n /^([A-Z][a-zA-Z0-9]*\\.traits\\.)?[A-Z][a-zA-Z0-9]*$/,\n 'Trait reference must be \"TraitName\" or \"Alias.traits.TraitName\"',\n );\n\n/**\n * Checks if a trait reference is an imported reference.\n * \n * Determines if a trait reference uses the imported format\n * \"Alias.traits.TraitName\" rather than a simple \"TraitName\".\n * \n * @param {string} ref - Trait reference to check\n * @returns {boolean} True if reference is imported format, false otherwise\n * \n * @example\n * isImportedTraitRef(\"User.traits.Profile\"); // returns true\n * isImportedTraitRef(\"Profile\"); // returns false\n */\nexport function isImportedTraitRef(ref: string): boolean {\n return /^[A-Z][a-zA-Z0-9]*\\.traits\\.[A-Z][a-zA-Z0-9]*$/.test(ref);\n}\n\n/**\n * Parses an imported trait reference.\n * \n * Extracts the alias and trait name from an imported trait reference\n * in format \"Alias.traits.TraitName\". Returns null if not a valid imported reference.\n * \n * @param {string} ref - Trait reference to parse\n * @returns {{ alias: string; traitName: string } | null} Parsed reference or null\n * \n * @example\n * parseImportedTraitRef(\"User.traits.Profile\"); // returns { alias: \"User\", traitName: \"Profile\" }\n * parseImportedTraitRef(\"Profile\"); // returns null\n */\nexport function parseImportedTraitRef(\n ref: string,\n): { alias: string; traitName: string } | null {\n const match = ref.match(/^([A-Z][a-zA-Z0-9]*)\\.traits\\.([A-Z][a-zA-Z0-9]*)$/);\n if (!match) return null;\n return { alias: match[1], traitName: match[2] };\n}\n\n/**\n * Parses an entity reference.\n * \n * Extracts the alias from an entity reference in format \"Alias.entity\".\n * Returns null if not a valid entity reference.\n * \n * @param {string} ref - Entity reference to parse\n * @returns {{ alias: string } | null} Parsed reference or null\n * \n * @example\n * parseEntityRef(\"User.entity\"); // returns { alias: \"User\" }\n * parseEntityRef(\"User\"); // returns null\n */\nexport function parseEntityRef(ref: string): { alias: string } | null {\n const match = ref.match(/^([A-Z][a-zA-Z0-9]*)\\.entity$/);\n if (!match) return null;\n return { alias: match[1] };\n}\n\n/**\n * Parses a page reference.\n * \n * Extracts the alias and page name from a page reference\n * in format \"Alias.pages.PageName\". Returns null if not a valid page reference.\n * \n * @param {string} ref - Page reference to parse\n * @returns {{ alias: string; pageName: string } | null} Parsed reference or null\n * \n * @example\n * parsePageRef(\"User.pages.Profile\"); // returns { alias: \"User\", pageName: \"Profile\" }\n * parsePageRef(\"Profile\"); // returns null\n */\nexport function parsePageRef(\n ref: string,\n): { alias: string; pageName: string } | null {\n const match = ref.match(/^([A-Z][a-zA-Z0-9]*)\\.pages\\.([A-Z][a-zA-Z0-9]*)$/);\n if (!match) return null;\n return { alias: match[1], pageName: match[2] };\n}\n\n// ============================================================================\n// Event Listener (Legacy)\n// ============================================================================\n\n/**\n * Event listener for cross-orbital communication (legacy format).\n * @deprecated Use trait-level listens with scope instead.\n */\nexport interface EventListener {\n /** Event key to listen for */\n event: string;\n /** Action to trigger */\n triggers: string;\n /** Optional guard condition */\n guard?: string;\n}\n\nexport const EventListenerSchema = z.object({\n event: z.string().min(1),\n triggers: z.string().min(1),\n guard: z.string().optional(),\n});\n\n// ============================================================================\n// Computed Event Contract (Trait-Centric Model)\n// ============================================================================\n\n/**\n * Source of an event - which trait/transition/tick emits it.\n */\nexport type EventSource = {\n /** Trait that emits this event */\n trait: string;\n /** Transition that emits this event (if applicable) */\n transition?: string;\n /** Tick that emits this event (if applicable) */\n tick?: string;\n};\n\nexport const EventSourceSchema = z.object({\n trait: z.string().min(1),\n transition: z.string().optional(),\n tick: z.string().optional(),\n});\n\n/**\n * Computed event contract with source tracking.\n * Generated by aggregating trait-level emits with namespacing.\n */\nexport type ComputedEventContract = {\n /** Namespaced event: \"TraitName.EVENT_NAME\" */\n event: string;\n /** Original event name without namespace */\n originalEvent: string;\n /** Source trait that emits this event */\n source: EventSource;\n /** Human-readable description */\n description?: string;\n /** Payload schema */\n payload?: EventPayloadField[];\n};\n\nexport const ComputedEventContractSchema = z.object({\n event: z.string().min(1),\n originalEvent: z.string().min(1),\n source: EventSourceSchema,\n description: z.string().optional(),\n payload: z.array(EventPayloadFieldSchema).optional(),\n});\n\n/**\n * Computed event listener with source tracking.\n * Generated by aggregating trait-level listens.\n */\nexport type ComputedEventListener = {\n /** Event to listen for (may be namespaced) */\n event: string;\n /** Source trait that defines this listener */\n source: EventSource;\n /** State machine event to trigger */\n triggers: string;\n /** Guard expression */\n guard?: Expression;\n /** `with { ... }` payload rewrite: `{ targetField: SExpr }`, evaluated against the source payload. */\n payloadMapping?: Record<string, SExpr>;\n};\n\nexport const ComputedEventListenerSchema = z.object({\n event: z.string().min(1),\n source: EventSourceSchema,\n triggers: z.string().min(1),\n guard: ExpressionSchema.optional(),\n payloadMapping: z.record(z.string(), SExprSchema).optional(),\n});\n\n// ============================================================================\n// Orbital\n// ============================================================================\n\n/**\n * Orbital - The atomic building block of applications.\n *\n * Formula: Orbital = Entity × Traits × Pages\n *\n * An orbital is a self-contained feature unit that groups:\n * - One entity (the data nucleus) - inline OR referenced via \"Alias.entity\"\n * - Zero or more traits (behavioral patterns) - inline OR referenced via \"Alias.traits.X\"\n * - Zero or more pages (UI entry points) - inline OR referenced via \"Alias.pages.X\"\n *\n * Use `uses` to import other orbitals and access their components.\n */\nexport type Orbital = OrbitalDefinition;\n\nexport type OrbitalDefinition = {\n /** V4 dual-carry id sibling of `name` — optional until the Phase-7 flip. */\n id?: OrbitalId;\n\n /** Human-readable name */\n name: string;\n\n /** Optional description */\n description?: string;\n\n /** Visual prompt override */\n visual_prompt?: string;\n\n // ========================================================================\n // Import System (Unified Reference)\n // ========================================================================\n\n /**\n * Import external orbitals as namespaces.\n *\n * After importing, access components via:\n * - Alias.entity - The entity definition\n * - Alias.traits.TraitName - A specific trait\n * - Alias.pages.PageName - A specific page\n * - Alias.theme - The theme definition\n * - Alias.services.ServiceName - A specific service\n *\n * @example\n * ```json\n * \"uses\": [\n * { \"from\": \"./health.orb\", \"as\": \"Health\" },\n * { \"from\": \"std/behaviors/game-core\", \"as\": \"GameCore\" }\n * ]\n * ```\n */\n uses?: UseDeclaration[];\n\n /**\n * Consumer-side requirement declarations (`.lolo` `expects ...`).\n *\n * Promises about sibling orbitals this unit relies on: trusted as the\n * local type environment when the orbital is validated standalone,\n * link-checked against real providers at compose. Compile-time only —\n * runtime semantics are unchanged.\n * See docs/Almadar_LOLO_Expects_Proposal.md.\n */\n expects?: ExpectDeclaration[];\n\n /** An orbital of only `expects` lines: a spec. It provides nothing; its obligations bind the orbital that imports it. */\n spec?: boolean;\n\n // ========================================================================\n // Theme & Services\n // ========================================================================\n\n /**\n * Theme definition (inline OR reference via \"Alias.theme\").\n *\n * @example\n * ```json\n * // Inline\n * \"theme\": { \"name\": \"ocean\", \"tokens\": { \"colors\": { \"primary\": \"#0ea5e9\" } } }\n *\n * // Reference\n * \"theme\": \"Ocean.theme\"\n * ```\n */\n theme?: ThemeRef;\n\n /**\n * Service definitions (inline OR reference via \"Alias.services.ServiceName\").\n *\n * @example\n * ```json\n * // Inline\n * \"services\": [{ \"name\": \"weather\", \"type\": \"rest\", \"baseUrl\": \"...\" }]\n *\n * // Reference\n * \"services\": [\"Weather.services.openweather\"]\n * ```\n */\n services?: ServiceRef[];\n\n // ========================================================================\n // Components (Inline OR Reference)\n // ========================================================================\n\n /**\n * Entity definition (nucleus).\n *\n * Can be:\n * - Inline: Full entity definition\n * - Reference: \"Alias.entity\" (from uses)\n *\n * Entity sharing depends on persistence type:\n * - persistent: Shared (same DB collection)\n * - runtime: Isolated (each orbital gets own instances)\n */\n entity: EntityRef;\n\n /**\n * Imported atom entities surfaced into this orbital's resolution\n * scope WITHOUT modifying the primary `entity`. Populated by the\n * compiler's inline phase when a trait reference imports an atom\n * and OMITS the `-> Entity` linkedEntity rebind: the atom keeps its\n * own entity (e.g. `SearchResult` from std-search), and that entity\n * is registered here so validators / codegen / runtime can resolve\n * `linkedEntity = \"SearchResult\"` lookups, register persistence for\n * it, and emit its TypeScript type alongside the primary entity.\n * The orbital's per-trait entity arity stays 1:1 — this is purely a\n * NAME-RESOLUTION side channel for cross-import linkedEntity\n * references.\n */\n auxiliaryEntities?: EntityRef[];\n\n /** Trait references (local or imported via \"Alias.traits.TraitName\") */\n traits: TraitRef[];\n\n /**\n * Page definitions.\n *\n * Can be:\n * - Inline: Full page definition\n * - Reference string: \"Alias.pages.PageName\"\n * - Reference object: { ref: \"Alias.pages.PageName\", path: \"/custom\" }\n */\n pages: PageRef[];\n\n // ========================================================================\n // Event Interface (Trait-Centric Model)\n // ========================================================================\n\n /**\n * Events this orbital emits.\n *\n * COMPUTED from trait-level emits:\n * - Aggregated from all traits with `scope: 'external'`\n * - Namespaced as \"TraitName.EVENT_NAME\"\n * - Filtered by `exposes` if present\n *\n * Do not author directly - computed by resolver.\n */\n emits?: ComputedEventContract[];\n\n /**\n * Events this orbital listens for.\n *\n * COMPUTED from trait-level listens:\n * - Aggregated from all traits with `scope: 'external'`\n *\n * Do not author directly - computed by resolver.\n */\n listens?: ComputedEventListener[];\n\n /**\n * Filter which trait events are exposed externally.\n * If omitted, all external-scoped trait events are exposed.\n * Format: [\"TraitName.EVENT_NAME\", ...]\n */\n exposes?: string[];\n\n /** `os-grants { … }` — the `os/` permissions this orbital holds beyond the program's. */\n osGrants?: OsGrants;\n\n /**\n * This orbital's own DECLARED knobs (§4.5) — distinct from `OrbitalSchema.config`,\n * which declares organism-wide knobs shared by every orbital. Traits publish a\n * knob by forwarding `@config.<knob>`; an importer overrides via\n * `OrbitalRefObject.config` or `UseDeclaration.config`.\n */\n config?: DeclaredTraitConfig;\n\n /**\n * TRANSIENT — set by lowering when this orbital is authored as\n * `orbital X = Alias.orbitals.Y { ... }` (the reference form). Cleared by\n * the compiler's inline phase / runtime's resolver during flattening; must\n * never reach validation, codegen, or a committed `.orb`.\n */\n reference?: OrbitalRefObject;\n\n // ========================================================================\n // Context fields - persisted throughout orbital lifecycle\n // ========================================================================\n\n /** Domain context - category, vocabulary, personas */\n domainContext?: DomainContext;\n\n /** Design preferences - style, colors, UX hints */\n design?: DesignPreferences;\n\n /**\n * Suggested guards (decomposition phase only).\n * Natural language descriptions that generator converts to S-expressions.\n * Removed after generation - guards live in traits.\n */\n suggestedGuards?: SuggestedGuard[];\n\n /**\n * This orbital's own named STRUCT aliases (`type X = { ... }`), each\n * flattened to the same payload-field tree emit/listen payloads use.\n * The `.orb`'s only record of a struct alias post-L1 — a Type-kind trait\n * type-param arg (`:: p SomeStructAlias`) resolves against this map.\n * Enum/primitive/entity aliases are NOT carried here (not legal `::`\n * args). A dictionary or list alias (`Map string string`, `[string]`) is one\n * unnamed member (`name: ''`) carrying the type string; a tagged union alias is one\n * unnamed member typed `union` whose `properties` are its variants.\n */\n types?: Record<string, EventPayloadField[]>;\n};\n\n/**\n * A named type alias of an orbital: a record alias is its fields; a dictionary or list alias\n * (`type Cells = Map string string`) is one unnamed member carrying the type string; a tagged union alias\n * (`type Item = Shape | Text`) is one unnamed member typed `union` whose properties are its variants.\n */\nexport const TypeAliasMembersSchema = z.union([\n z.array(EventPayloadFieldSchema),\n z.tuple([EventPayloadTypeMemberSchema.refine((field) => field.name === '', 'An unnamed alias member requires an empty name')]),\n]);\n\nexport const OrbitalDefinitionSchema = z.object({\n id: OrbitalIdSchema.optional(),\n name: z.string().min(1, \"Orbital name is required\"),\n description: z.string().optional(),\n visual_prompt: z.string().optional(),\n // Import system\n uses: z.array(UseDeclarationSchema).optional(),\n // Consumer-side requirement declarations (`.lolo` `expects ...`)\n expects: z.array(ExpectDeclarationSchema).optional(),\n spec: z.boolean().optional(),\n // Theme & Services\n theme: ThemeRefSchema.optional(),\n services: z.array(ServiceRefSchema).optional(),\n // Components (inline or reference)\n entity: EntityRefSchema,\n // Mirrors the `OrbitalDefinition.auxiliaryEntities` type field — WAS\n // undeclared here, so `OrbitalSchemaSchema.safeParse` (every load through\n // `external-loader.ts`) silently stripped it on every externally-loaded\n // orbital (zod drops unrecognized keys by default), while a schema parsed\n // directly via `JSON.parse` kept it. Found via the entity-field auto-merge\n // rebind-target fallback landing on the wrong entity for any RECURSIVELY\n // loaded `uses` file (`packages/almadar-runtime/src/resolver/\n // reference-resolver.ts`'s `mergeImportedEntityFieldsIntoOrbital`).\n auxiliaryEntities: z.array(EntityRefSchema).optional(),\n traits: z.array(TraitRefSchema),\n // A reference-form orbital's pages come from its upstream until inline.\n pages: z.array(PageRefSchema).default([]),\n // Event interface (trait-centric model) - computed by resolver\n emits: z.array(ComputedEventContractSchema).optional(),\n listens: z.array(ComputedEventListenerSchema).optional(),\n // Filter for exposed events (trait-centric model)\n exposes: z.array(z.string()).optional(),\n osGrants: OsGrantsSchema.optional(),\n // This orbital's own declared knobs (§4.5)\n config: DeclaredTraitConfigSchema.optional(),\n // Transient — set by lowering, cleared by inline/resolve\n reference: OrbitalRefObjectSchema.optional(),\n // Context fields - persisted throughout orbital lifecycle\n domainContext: DomainContextSchema.optional(),\n design: DesignPreferencesSchema.optional(),\n suggestedGuards: z.array(SuggestedGuardSchema).optional(),\n types: z.record(z.string(), TypeAliasMembersSchema).optional(),\n}).superRefine((orbital, ctx) => {\n // The compiler's EntityNoFields, which skips a spec's shell entity (`validate_all_entities`).\n if (orbital.spec === true) return;\n const entities: Array<[EntityRef, (string | number)[]]> = [[orbital.entity, ['entity']], ...(orbital.auxiliaryEntities ?? []).map((e, i): [EntityRef, (string | number)[]] => [e, ['auxiliaryEntities', i]])];\n for (const [entity, path] of entities) {\n if (!isEntityReferenceAny(entity) && entity.fields.length === 0) {\n ctx.addIssue({ code: 'too_small', minimum: 1, origin: 'array', inclusive: true, path: [...path, 'fields'], message: 'At least one field is required' });\n }\n }\n});\n\nexport const OrbitalSchema = OrbitalDefinitionSchema;\n\n/**\n * Unwrap a composed trait (`X = Atom.traits.T`) carried as a `{ ref, config?, _resolved }` wrapper to\n * its resolved trait, returning the call-site `config` beside it. A string ref, an inline trait and a\n * wrapper with no `_resolved` come back as they are, with no config.\n */\nexport function unwrapTraitRef(traitRef: TraitRef): { trait: TraitRef; config?: CallSiteConfig } {\n if (typeof traitRef === 'string' || isInlineTrait(traitRef) || traitRef._resolved === undefined) {\n return { trait: traitRef };\n }\n return traitRef.config === undefined\n ? { trait: traitRef._resolved }\n : { trait: traitRef._resolved, config: traitRef.config };\n}\n\n/**\n * The orbitals with every composed-trait wrapper replaced by its inline trait, the call-site `config`\n * folded onto the trait's declared knobs (`mergeCallSiteConfigOverrides`). Pure.\n */\nexport function inlineTraitRefs(orbitals: readonly OrbitalDefinition[]): OrbitalDefinition[] {\n return orbitals.map((orbital) => ({\n ...orbital,\n traits: orbital.traits.map((traitRef) => {\n const { trait, config } = unwrapTraitRef(traitRef);\n if (config === undefined || typeof trait === 'string' || !isInlineTrait(trait)) return trait;\n return { ...trait, config: mergeCallSiteConfigOverrides(trait.config ?? {}, config) };\n }),\n }));\n}\n\n// ============================================================================\n// Type Guards\n// ============================================================================\n\n/**\n * Type guard to check if an Orbital is a full definition.\n * @deprecated No longer needed since Orbital is always OrbitalDefinition now.\n */\nexport function isOrbitalDefinition(\n orbital: Orbital,\n): orbital is OrbitalDefinition {\n return \"entity\" in orbital;\n}\n\n// ============================================================================\n// Type exports\n// ============================================================================\n\nexport type OrbitalInput = z.input<typeof OrbitalSchema>;\n\n// Backward compatibility\nexport type OrbitalUnit = Orbital;\nexport const OrbitalUnitSchema = OrbitalSchema;\n","/**\n * The endpoint protocol table (EXEC-ENDPOINT-1): the protocols a `page` can be written with, the record type of each\n * address, whether a viewer exists, the grant it needs and the side that serves it. `tsup` writes it to\n * `dist/language/protocols.json` (`orbLanguage.protocols`); `orb` reads it to lower, validate and mount protocol\n * pages, and a compiled client program carries it in `_metadata.protocols`. A protocol's behavior is std `.lolo`; a\n * row only declares it.\n *\n * @packageDocumentation\n */\nimport { z } from 'zod';\n\nexport const ProtocolSideSchema = z.enum(['client', 'server', 'process', 'start']);\nexport const ProtocolGrantSchema = z.enum(['net-listen', 'stdio']);\n\nexport const ProtocolAddressFieldSchema = z.strictObject({\n name: z.string().min(1),\n type: z.string().min(1),\n required: z.boolean(),\n});\n\nexport const ProtocolSpecSchema = z.strictObject({\n name: z.string().min(1),\n address: z.array(ProtocolAddressFieldSchema).nullable(),\n viewer: z.boolean(),\n grant: ProtocolGrantSchema.nullable(),\n side: ProtocolSideSchema,\n});\n\nexport type ProtocolSide = z.infer<typeof ProtocolSideSchema>;\nexport type ProtocolGrant = z.infer<typeof ProtocolGrantSchema>;\nexport type ProtocolAddressField = z.infer<typeof ProtocolAddressFieldSchema>;\nexport type ProtocolSpec = z.infer<typeof ProtocolSpecSchema>;\n\nconst HTTP_ADDRESS: ProtocolAddressField[] = [\n { name: 'host', type: 'string', required: true },\n { name: 'port', type: 'number', required: true },\n { name: 'path', type: 'string', required: false },\n];\n\nexport const PROTOCOLS: readonly ProtocolSpec[] = [\n { name: 'route', address: null, viewer: true, grant: null, side: 'client' },\n { name: 'http', address: HTTP_ADDRESS, viewer: false, grant: 'net-listen', side: 'server' },\n { name: 'stdio', address: null, viewer: false, grant: 'stdio', side: 'process' },\n { name: 'boot', address: null, viewer: false, grant: null, side: 'start' },\n];\n","/**\n * Orbital Schema Type (Self-Contained)\n *\n * Defines the OrbitalSchema - the top-level application definition.\n * An application is a composition of orbitals: App = Σ(Orbitals)\n *\n * @packageDocumentation\n */\n\nimport { z } from \"zod\";\nimport { ProtocolSpecSchema, type ProtocolSpec } from \"../protocols.js\";\nimport type { EventPayloadField } from \"./trait.js\";\nimport type { Orbital, LazyPage } from \"./orbital.js\";\nimport { OrbitalSchema as OrbitalZodSchema, LazyPageSchema, TypeAliasMembersSchema } from \"./orbital.js\";\nimport type {\n DomainContext,\n DesignPreferences,\n DesignTokens,\n CustomPatternMap,\n} from \"./domain.js\";\nimport {\n DomainContextSchema,\n DesignPreferencesSchema,\n DesignTokensSchema,\n CustomPatternMapSchema,\n} from \"./domain.js\";\nimport type { ServiceDefinition } from \"./service.js\";\nimport { ServiceDefinitionSchema } from \"./service.js\";\nimport type { Trait, DeclaredTraitConfig } from \"./trait.js\";\nimport { DeclaredTraitConfigSchema } from \"./trait.js\";\nimport type { IdentityLedger } from \"./identity.js\";\nimport { IdentityLedgerSchema } from \"./identity.js\";\nimport type { ThemeDefinition, ThemeRef } from \"./domain.js\";\nimport { ThemeDefinitionSchema, ThemeRefSchema } from \"./domain.js\";\nimport type { RuntimeValue } from \"./json.js\";\nimport type { OsGrants, Deployment } from \"./os-grants.js\";\nimport { OsGrantsSchema, DeploymentSchema } from \"./os-grants.js\";\n\n// ============================================================================\n// Orbital Schema\n// ============================================================================\n\n/**\n * OrbitalSchema - The top-level application definition.\n *\n * An application is a composition of orbitals:\n * App = Σ(Orbitals)\n *\n * Custom traits can be defined at the schema level and referenced\n * by orbitals via TraitRef. This allows LLMs to generate custom\n * traits that aren't in the trait library.\n */\n/**\n * One `@config.<knob>` → render-ui prop substitution recorded by the inline\n * phase. Lets a consumer trace a resolved render-ui literal back to the config\n * knob it came from (the `@config.X` string is erased after substitution).\n * Mirrors the Rust `ConfigProvenanceRecord`.\n */\nexport interface ConfigProvenanceRecord {\n /** Resolved trait name (post call-site rename) owning the render-ui effect. */\n trait: string;\n /** Pattern path within the render-ui tree (e.g. `root.children.0`). */\n patternPath?: string;\n /** The pattern-node prop key whose value was a `@config.X` binding. */\n prop: string;\n /** The config knob name (`X` in `@config.X`). */\n knob: string;\n}\n\n/** Compiler-emitted schema metadata — the resolved `.orb` `_metadata` block. */\nexport interface SchemaMetadata {\n version?: number;\n createdAt?: number;\n source?: string;\n updatedAt?: number;\n /** Config→knob provenance keyed by orbital name. See {@link ConfigProvenanceRecord}. */\n configProvenance?: Record<string, ConfigProvenanceRecord[]>;\n /** For a program with `locales`: each loaded behavior → its source folder, relative to the program's (catalogs at `<folder>/locales/<locale>/<name>.json`). */\n messageSources?: Record<string, string>;\n /** Compiled client programs: where each effect operator the client's traits run executes, for a kernel with no operator table. */\n operatorSites?: Record<string, 'client' | 'server' | 'any'>;\n /** Compiled client programs: the operator-table facts a kernel reads at dispatch. */\n dispatchFacts?: DispatchFacts;\n /** Compiled client programs: the endpoint protocol table, for a kernel with no installed core. */\n protocols?: ProtocolSpec[];\n}\n\n/** The operator-table facts a browser kernel reads at dispatch (`emit` busExcluded, `program/dispatch` targetOptions). */\nexport interface DispatchFacts {\n busExcluded: string[];\n targetOptions: string[];\n}\n\n/** App-level site modifiers: `origin`, `icon`, `siteName` (→ `name`), `signIn`. */\nexport interface SiteMeta {\n /** Canonical production origin, e.g. `https://orb.almadar.io`. */\n origin?: string;\n /** Site icon path served from the public folder. */\n icon?: string;\n /** Site name (og:site_name). */\n name?: string;\n /** Route an `access: authenticated` page sends a non-admitted viewer to. */\n signIn?: string;\n}\n\n/**\n * The sign-in route every host provides itself (the compiled shell's login form, the\n * runtime host's sign-in surface). `signIn:` may name it without a page, and no page\n * may be declared on it. Mirrors `orbital-core` `HOST_SIGN_IN_ROUTE`.\n */\nexport const HOST_SIGN_IN_ROUTE = '/login';\n\n/** Whether `path` is {@link HOST_SIGN_IN_ROUTE}, ignoring a trailing slash. */\nexport function isHostSignInRoute(path: string): boolean {\n return path.replace(/\\/+$/, '') === HOST_SIGN_IN_ROUTE;\n}\n\nexport const SiteMetaSchema = z.object({\n origin: z.string().url().optional(),\n icon: z.string().min(1).optional(),\n name: z.string().min(1).optional(),\n signIn: z.string().startsWith('/').optional(),\n}).strict();\n\n/** A program's messages: locale → qualified key (`<behavior>:<key>`) → message. Resolution stores them in the program's `messages`. */\nexport type MessageCatalogs = Record<string, Record<string, string>>;\n\n/** The compiler's resolution stamp (`ResolvedMark` in orbital-core): the `orb` version that resolved the program and its type-contract version. */\nexport interface ResolvedMark {\n orb: string;\n typeContractVersion: 2;\n}\n\nexport interface OrbitalSchema {\n types?: Record<string, EventPayloadField[]>;\n typeContractVersion?: 1;\n resolved?: ResolvedMark;\n /** Application name */\n name: string;\n\n /** Description */\n description?: string;\n\n /**\n * App-level theme: the skin every orbital's `@currentTheme` seeds from\n * unless the orbital declares its own `theme` (precedence: orbital →\n * app → the runtime's baseline default). Authored as `theme \"<key>\"` in\n * the `.lolo` app header; a full `<base>-<light|dark>` registry key.\n * Distinct from {@link OrbitalSchema.config} — this names a registry\n * theme, not a declared knob.\n */\n theme?: ThemeRef;\n\n /**\n * The registry themes the program switches to inside a page (a sub-frame's\n * `data-theme`, a theme switcher's options), beyond its app and orbital\n * themes. Authored as `themes: [<key>, …]` in the `.lolo` app header; each\n * a full `<base>-<light|dark>` registry key.\n */\n themes?: string[];\n\n /**\n * The theme presets this program references (app and orbital `theme`\n * keys) plus the runtime default, written by `orb` when it compiles the\n * program for a runtime, so a kernel with no installed `@almadar/core`\n * (wasm, mobile) resolves `@currentTheme` from the program alone. Never\n * authored; absent on a source `.orb`.\n */\n themeDefinitions?: ThemeDefinition[];\n\n /**\n * Short human-readable summary distinct from `description`. Typically an\n * AI-generated one-liner used by app list views, breadcrumbs, and the\n * `GET /graphs/:appId/domain-text` projection. Kept separate from\n * `description` (which may be longer / authored copy) so consumers can\n * present a stable short label without truncating.\n */\n summary?: string;\n\n /** Version (semver) */\n version?: string;\n\n /** Domain context - user request + classification */\n domainContext?: DomainContext;\n\n /** Design preferences */\n design?: DesignPreferences;\n\n /**\n * Design tokens - reusable Tailwind class collections.\n * Reference via `token: \"surfaces.glass\"` in patterns.\n */\n designTokens?: DesignTokens;\n\n /**\n * Custom pattern definitions for app-specific reusable patterns.\n * Register custom designs that can be referenced by name.\n */\n customPatterns?: CustomPatternMap;\n\n /** Array of orbitals */\n orbitals: Orbital[];\n\n /** `locales [en, ar, sl]` — the locales this program ships; every `(i18n/t …)` key must exist in each one's catalog. */\n locales?: string[];\n /** The program's messages, written by resolution and never authored: the program carries its own text wherever it is opened. */\n messages?: MessageCatalogs;\n\n /** `public: \"./public\"` — a folder beside the program copied verbatim to the built site's root. */\n publicDir?: string;\n\n /** `app … [store: Driver]` — the default store-driver orbital for persistent entities that name none. */\n store?: string;\n\n /** Origins (`scheme://host[:port]`) the program's `http` effects may reach. */\n egress?: string[];\n\n /** `os-grants { … }` — the `os/` permissions the whole program holds; every orbital inherits them. */\n osGrants?: OsGrants;\n\n /** `deployment { target: [Orbital, …] }` — which orbitals ship to which target. */\n deployment?: Deployment;\n\n /** `inbound: [...]` — the hook names (`/api/hooks/<name>`) the program accepts deliveries on. */\n inbound?: string[];\n\n /** Site modifiers from the app bracket (`origin`, `icon`, `siteName`, `signIn`). */\n site?: SiteMeta;\n\n /** Pages served by `uses lazy` behaviors, each loaded from its own `.orb` when opened. */\n lazyPages?: LazyPage[];\n\n /** External services */\n services?: ServiceDefinition[];\n\n /**\n * Organism-level DECLARED knobs (§4.5) — shared by every orbital in this\n * schema, forwarded via `@config.<knob>`. Distinct from `Orbital.config`,\n * which declares one orbital's own knobs.\n */\n config?: DeclaredTraitConfig;\n\n /** Compiler-emitted metadata (resolved `.orb` `_metadata`). */\n _metadata?: SchemaMetadata;\n\n /**\n * V4 IR schema version. Distinct from the semver `version` above; gates the\n * identity-keyed reference semantics. Optional/unset for pre-V4 schemas.\n */\n schemaVersion?: number;\n\n /**\n * V4 identity ledger — the sole name↔id map for this schema's nodes. Optional\n * until the Phase-7 flip; absent on pre-V4 schemas.\n */\n ledger?: IdentityLedger;\n}\n\nexport const ConfigProvenanceRecordSchema = z.object({\n trait: z.string(),\n patternPath: z.string().optional(),\n prop: z.string(),\n knob: z.string(),\n});\n\nexport const SchemaMetadataSchema = z.object({\n version: z.number().optional(),\n createdAt: z.number().optional(),\n source: z.string().optional(),\n updatedAt: z.number().optional(),\n configProvenance: z.record(z.string(), z.array(ConfigProvenanceRecordSchema)).optional(),\n messageSources: z.record(z.string(), z.string()).optional(),\n operatorSites: z.record(z.string(), z.enum(['client', 'server', 'any'])).optional(),\n dispatchFacts: z.object({ busExcluded: z.array(z.string()), targetOptions: z.array(z.string()) }).optional(),\n protocols: z.array(ProtocolSpecSchema).optional(),\n});\n\nexport const OrbitalSchemaSchema: z.ZodType<OrbitalSchema, object> = z.object({\n types: z.record(z.string(), TypeAliasMembersSchema).optional(),\n typeContractVersion: z.literal(1).optional(),\n resolved: z.object({ orb: z.string(), typeContractVersion: z.literal(2) }).optional(),\n name: z.string().min(1, \"Schema name is required\"),\n description: z.string().optional(),\n theme: ThemeRefSchema.optional(),\n themes: z.array(z.string().min(1)).optional(),\n themeDefinitions: z.array(ThemeDefinitionSchema).optional(),\n summary: z.string().optional(),\n version: z.string().optional(),\n domainContext: DomainContextSchema.optional(),\n design: DesignPreferencesSchema.optional(),\n designTokens: DesignTokensSchema,\n customPatterns: CustomPatternMapSchema,\n orbitals: z\n .array(OrbitalZodSchema)\n .min(1, \"At least one orbital is required\"),\n locales: z.array(z.string().min(1)).optional(),\n messages: z.record(z.string(), z.record(z.string(), z.string())).optional(),\n publicDir: z.string().min(1).optional(),\n store: z.string().min(1).optional(),\n egress: z.array(z.string().min(1)).optional(),\n osGrants: OsGrantsSchema.optional(),\n deployment: DeploymentSchema.optional(),\n inbound: z.array(z.string().min(1)).optional(),\n site: SiteMetaSchema.optional(),\n lazyPages: z.array(LazyPageSchema).optional(),\n services: z.array(ServiceDefinitionSchema).optional(),\n config: DeclaredTraitConfigSchema.optional(),\n _metadata: SchemaMetadataSchema.optional(),\n // V4 identity — optional/dual-carry until the Phase-7 flip. Present on\n // id-carrying `.orb` files so `parseOrbitalSchema` preserves them instead\n // of stripping unknown keys.\n schemaVersion: z.number().optional(),\n ledger: IdentityLedgerSchema.optional(),\n});\n\n// ============================================================================\n// Persisted/Flattened View\n// ============================================================================\n\n/**\n * Flattened `OrbitalSchema` view used by the persistence/runtime layer.\n *\n * Canonical `OrbitalSchema` keeps every trait inside its owning\n * `OrbitalDefinition.traits`. Some runtime paths (e.g. the orbital-agent\n * stream, Firestore persistence) additionally roll the resolved trait set up\n * to the top level as `traits[]` so diffs and list views don't have to walk\n * every orbital.\n *\n * This is intentionally a LOSSY persisted view, NOT the canonical authoring\n * shape: it carries the rolled-up array alongside the per-orbital trait\n * lists, and consumers should prefer `OrbitalSchema` whenever the rolled-up\n * surface isn't required.\n */\nexport interface OrbitalSchemaWithTraits extends OrbitalSchema {\n /** Flattened trait set rolled up from all orbitals. Persisted-view only. */\n traits?: Trait[];\n}\n\n// ============================================================================\n// Parsing Functions\n// ============================================================================\n\n/**\n * Parses raw data into a validated OrbitalSchema.\n * \n * Uses Zod validation to ensure the data conforms to the OrbitalSchema structure.\n * Throws a ZodError if validation fails. For safe parsing that doesn't throw,\n * use `safeParseOrbitalSchema()` instead.\n * \n * @param {unknown} data - Raw data to parse (typically JSON)\n * @returns {OrbitalSchema} Validated orbital schema\n * @throws {z.ZodError} If data doesn't match OrbitalSchema structure\n * \n * @example\n * ```typescript\n * try {\n * const schema = parseOrbitalSchema(jsonData);\n * console.log('Valid schema:', schema.name);\n * } catch (error) {\n * console.error('Invalid schema:', error);\n * }\n * ```\n * \n * @see safeParseOrbitalSchema\n */\nexport function parseOrbitalSchema(data: RuntimeValue): OrbitalSchema {\n return OrbitalSchemaSchema.parse(data);\n}\n\n/**\n * Safely parses raw data into a validated OrbitalSchema without throwing.\n * \n * Uses Zod's safeParse method to validate data and return a result object\n * instead of throwing errors. This is useful for form validation and\n * user input handling where you want to gracefully handle invalid data.\n * \n * @param {unknown} data - Raw data to parse (typically JSON)\n * @returns {z.ZodSafeParseResult<OrbitalSchema>} Parse result with success/status\n * \n * @example\n * ```typescript\n * const result = safeParseOrbitalSchema(jsonData);\n * if (result.success) {\n * console.log('Valid schema:', result.data.name);\n * } else {\n * console.error('Validation errors:', result.error);\n * }\n * ```\n * \n * @see parseOrbitalSchema\n */\nexport function safeParseOrbitalSchema(data: RuntimeValue) {\n return OrbitalSchemaSchema.safeParse(data);\n}\n\n// ============================================================================\n// Type exports\n// ============================================================================\n\nexport type OrbitalSchemaInput = z.input<typeof OrbitalSchemaSchema>;\n","/**\n * Behaviors as first-class values (language trio, `docs/Almadar_Studio_Behavior.md`).\n *\n * A trait value names a trait of an installed behavior package and carries the\n * call-site overrides of the trait-reference form (LOLO §8); an orbital value\n * names an orbital and carries the orbital-import body (LOLO §8b). Their literal\n * spellings mirror those forms with the `uses` specifier in the alias position:\n * `std/std-kanban.traits.KanbanBoard`, `std/std-kanban.orbitals.KanbanOrbital`.\n * orbital-core's `schema::behavior_value` is the Rust twin.\n *\n * @packageDocumentation\n */\n\nimport { z } from 'zod';\nimport { DeclaredTraitConfigSchema, TraitConfigValueSchema, TraitReferenceObjectSchema, type TraitConfigValue, type TraitReference } from './trait.js';\nimport { ExpectDeclarationSchema, OrbitalRefObjectSchema, type OrbitalRefObject } from './orbital.js';\nimport { EntityFieldSchema, type EntityField } from './field.js';\nimport { EntityPersistenceSchema } from './entity.js';\nimport { StateMachineSchema, type StateMachine } from './state-machine.js';\nimport type { JsonValue, RuntimeValue } from './json.js';\nimport type { OrbitalSchema } from './schema.js';\nimport type { FactoryExposure } from '../factory/types.js';\n\n/** The §8 call-site override surface a trait value records (`behavior/apply`). */\nexport type TraitOverrides = Pick<TraitReference, 'config' | 'events' | 'fields' | 'listens' | 'emitsScope' | 'linkedEntity'>;\n\n/** A trait of an installed behavior, plus the overrides applied to it. */\nexport type TraitValue = TraitOverrides & {\n /** The behavior's specifier: canonical `<prefix>/<name>` (the compiler and `behavior/catalog` emit it), `std/behaviors/<name>` as authored, or workspace-relative `./orbitals/<name>` (what `program/eval` wrote). */\n readonly behavior: string;\n /** The trait's upstream name. */\n readonly trait: string;\n};\n\nconst TRAITS_SEGMENT = '.traits.';\nconst ORBITALS_SEGMENT = '.orbitals.';\nconst PASCAL = /^[A-Z][A-Za-z0-9]*$/;\n// `<prefix>/<name>` (canonical), the `uses` std spelling `std/behaviors/<name>`, or a\n// workspace-relative `./<dir>/<name>` (a program `program/eval` wrote, default `./orbitals/`).\nconst SPECIFIER = /^(?:[a-z0-9][a-z0-9-]*(?:\\/behaviors)?|\\.(?:\\/[A-Za-z0-9_-]+)+)\\/[A-Za-z0-9][A-Za-z0-9_-]*$/;\n\nfunction splitLiteral(raw: string, segment: string): { behavior: string; name: string } | undefined {\n const at = raw.lastIndexOf(segment);\n if (at <= 0) return undefined;\n const behavior = raw.slice(0, at);\n const name = raw.slice(at + segment.length);\n if (!SPECIFIER.test(behavior) || !PASCAL.test(name)) return undefined;\n return { behavior, name };\n}\n\n/** Parse `<prefix>/<name>.traits.<Trait>`; undefined for anything else (a local `@trait.X` included). */\nexport function parseTraitValueLiteral(raw: string): TraitValue | undefined {\n const parts = splitLiteral(raw, TRAITS_SEGMENT);\n return parts === undefined ? undefined : { behavior: parts.behavior, trait: parts.name };\n}\n\n/** Parse `<prefix>/<name>.orbitals.<Orbital>`; undefined for anything else. */\nexport function parseOrbitalValueLiteral(raw: string): OrbitalValue | undefined {\n const parts = splitLiteral(raw, ORBITALS_SEGMENT);\n return parts === undefined ? undefined : { behavior: parts.behavior, orbital: parts.name };\n}\n\n/** Parse either literal form. */\nexport function parseBehaviorValueLiteral(raw: string): BehaviorValue | undefined {\n return parseTraitValueLiteral(raw) ?? parseOrbitalValueLiteral(raw);\n}\n\n/** Inverse of {@link parseTraitValueLiteral}; drops overrides (they have no literal form). */\nexport function formatTraitValueLiteral(value: Pick<TraitValue, 'behavior' | 'trait'>): string {\n return `${value.behavior}${TRAITS_SEGMENT}${value.trait}`;\n}\n\n/** Inverse of {@link parseOrbitalValueLiteral}; drops the recorded import body. */\nexport function formatOrbitalValueLiteral(value: Pick<OrbitalValue, 'behavior' | 'orbital'>): string {\n return `${value.behavior}${ORBITALS_SEGMENT}${value.orbital}`;\n}\n\n/** Either literal form, by kind. */\nexport function formatBehaviorValueLiteral(value: BehaviorValue): string {\n return isOrbitalValueShape(value) ? formatOrbitalValueLiteral(value) : formatTraitValueLiteral(value);\n}\n\n/** Validates the §8 override object `behavior/apply` takes; unknown keys are rejected. */\nexport const TraitOverridesSchema = TraitReferenceObjectSchema.pick({\n config: true,\n events: true,\n fields: true,\n listens: true,\n emitsScope: true,\n linkedEntity: true,\n}).strict();\n\n/** Validates a trait value carried as data: identity plus the recorded overrides. */\nexport const TraitValueSchema = TraitOverridesSchema.extend({\n behavior: z.string().regex(SPECIFIER),\n trait: z.string().regex(PASCAL),\n}).strict();\n\n/**\n * The §8b import body an orbital value records. Config holds plain values, as at\n * a trait call site; the import builder wraps them into the IR's declaration form.\n * `name` is the orbital's name in the importing program (default: the upstream name).\n */\nexport type OrbitalOverrides = Omit<OrbitalRefObject, 'ref' | 'refId' | 'config' | 'traits'> & {\n readonly name?: string;\n /** The source behavior's app-level knobs (its top-level `config {}`), as `uses Source { config }` sets them. */\n readonly app?: Readonly<Record<string, TraitConfigValue>>;\n readonly config?: Readonly<Record<string, TraitConfigValue>>;\n readonly traits?: Readonly<Record<string, TraitOverrides>>;\n /** Imports the value's sibling traits compose from, beside its own source. */\n readonly uses?: readonly OrbitalValueUse[];\n /** Traits the import orbital declares beside the imported ones, mountable through `mounts`. */\n readonly siblings?: readonly OrbitalValueSibling[];\n};\n\n/** An orbital of an installed behavior, plus the import body applied to it. */\nexport type OrbitalValue = OrbitalOverrides & {\n readonly behavior: string;\n /** The orbital's upstream name. */\n readonly orbital: string;\n};\n\n/** A trait value or an orbital value. */\nexport type BehaviorValue = TraitValue | OrbitalValue;\n\n/** One import the value's own sibling traits compose from (`uses <as> from <from>` on the import orbital). */\nexport const OrbitalValueUseSchema = z.object({ from: z.string(), as: z.string().regex(PASCAL) }).strict();\nexport type OrbitalValueUse = z.infer<typeof OrbitalValueUseSchema>;\n\n/** A trait the import orbital declares beside the imported ones (`trait <name> = <ref> { config }`), mountable through `mounts`. */\nexport const OrbitalValueSiblingSchema = z\n .object({\n name: z.string().regex(PASCAL),\n ref: z.string(),\n linkedEntity: z.string().optional(),\n config: z.record(z.string(), TraitConfigValueSchema).optional(),\n })\n .strict();\nexport type OrbitalValueSibling = z.infer<typeof OrbitalValueSiblingSchema>;\n\n/** Validates the §8b body `behavior/apply` takes for an orbital value; unknown keys are rejected. */\nexport const OrbitalOverridesSchema = OrbitalRefObjectSchema.omit({ ref: true, refId: true, config: true, traits: true })\n .extend({\n name: z.string().regex(PASCAL).optional(),\n app: z.record(z.string(), TraitConfigValueSchema).optional(),\n config: z.record(z.string(), TraitConfigValueSchema).optional(),\n traits: z.record(z.string(), TraitOverridesSchema).optional(),\n uses: z.array(OrbitalValueUseSchema).optional(),\n siblings: z.array(OrbitalValueSiblingSchema).optional(),\n })\n .strict();\n\n/** Validates an orbital value carried as data. */\nexport const OrbitalValueSchema = OrbitalOverridesSchema.extend({\n behavior: z.string().regex(SPECIFIER),\n orbital: z.string().regex(PASCAL),\n}).strict();\n\n/** Validates either kind. */\nexport const BehaviorValueSchema = z.union([TraitValueSchema, OrbitalValueSchema]);\n\ntype Mutable<T> = { -readonly [K in keyof T]: T[K] };\n\nfunction mergeTraitOverrides(base: TraitOverrides, overrides: TraitOverrides): TraitOverrides {\n const merged: Mutable<TraitOverrides> = { ...base };\n if (overrides.config !== undefined) merged.config = { ...base.config, ...overrides.config };\n if (overrides.events !== undefined) merged.events = { ...base.events, ...overrides.events };\n if (overrides.fields !== undefined) merged.fields = { ...base.fields, ...overrides.fields };\n if (overrides.listens !== undefined) merged.listens = overrides.listens;\n if (overrides.emitsScope !== undefined) merged.emitsScope = overrides.emitsScope;\n if (overrides.linkedEntity !== undefined) merged.linkedEntity = overrides.linkedEntity;\n return merged;\n}\n\n/**\n * `behavior/apply` on a trait value: `config`, `events` and `fields` merge\n * key-wise with the later value winning; `listens`, `emitsScope` and\n * `linkedEntity` replace. Pure — the input is not mutated.\n */\nexport function applyTraitOverrides(value: TraitValue, overrides: TraitOverrides): TraitValue {\n return { ...mergeTraitOverrides(value, overrides), behavior: value.behavior, trait: value.trait };\n}\n\nfunction mergeFieldsByName(base: readonly EntityField[] | undefined, next: readonly EntityField[]): EntityField[] {\n const out = [...(base ?? [])];\n for (const field of next) {\n const at = field.name === undefined ? -1 : out.findIndex((f) => f.name === field.name);\n if (at >= 0) out[at] = field;\n else out.push(field);\n }\n return out;\n}\n\n/**\n * `behavior/apply` on an orbital value — the §8b merge table. Maps\n * (`config`, `events`, `fields`, `pages`, `pageModifiers`, `roles`, `entities`,\n * `mounts`, `mock`) merge key-wise, later wins; `traits` merges per trait with the\n * trait-value rules; `extend` and `retype` merge by field name; everything else\n * (`name`, `entity`, `persistence`, `collection`, `only`, `omit`, `listens`, the\n * flags) replaces. Pure.\n */\nexport function applyOrbitalOverrides(value: OrbitalValue, overrides: OrbitalOverrides): OrbitalValue {\n const merged: Mutable<OrbitalValue> = { ...value, ...overrides, behavior: value.behavior, orbital: value.orbital };\n if (overrides.app !== undefined) merged.app = { ...value.app, ...overrides.app };\n if (overrides.config !== undefined) merged.config = { ...value.config, ...overrides.config };\n if (overrides.events !== undefined) merged.events = { ...value.events, ...overrides.events };\n if (overrides.fields !== undefined) merged.fields = { ...value.fields, ...overrides.fields };\n if (overrides.pages !== undefined) merged.pages = { ...value.pages, ...overrides.pages };\n if (overrides.pageModifiers !== undefined) merged.pageModifiers = { ...value.pageModifiers, ...overrides.pageModifiers };\n if (overrides.roles !== undefined) merged.roles = { ...value.roles, ...overrides.roles };\n if (overrides.entities !== undefined) merged.entities = { ...value.entities, ...overrides.entities };\n if (overrides.mounts !== undefined) merged.mounts = { ...value.mounts, ...overrides.mounts };\n if (overrides.mock !== undefined) merged.mock = { ...value.mock, ...overrides.mock };\n if (overrides.extend !== undefined) merged.extend = mergeFieldsByName(value.extend, overrides.extend);\n if (overrides.retype !== undefined) merged.retype = mergeFieldsByName(value.retype, overrides.retype);\n if (overrides.uses !== undefined) {\n const byAlias = new Map((value.uses ?? []).map((u) => [u.as, u]));\n for (const use of overrides.uses) byAlias.set(use.as, use);\n merged.uses = [...byAlias.values()];\n }\n if (overrides.siblings !== undefined) {\n const byName = new Map((value.siblings ?? []).map((t) => [t.name, t]));\n for (const sibling of overrides.siblings) {\n const prior = byName.get(sibling.name);\n byName.set(sibling.name, { ...prior, ...sibling, ...(prior?.config !== undefined || sibling.config !== undefined ? { config: { ...prior?.config, ...sibling.config } } : {}) });\n }\n merged.siblings = [...byName.values()];\n }\n if (overrides.traits !== undefined) {\n const traits: Record<string, TraitOverrides> = { ...value.traits };\n for (const [name, entry] of Object.entries(overrides.traits)) {\n traits[name] = mergeTraitOverrides(traits[name] ?? {}, entry);\n }\n merged.traits = traits;\n }\n return merged;\n}\n\n/** `behavior/apply` for either kind; the overrides are validated against the value's kind. */\nexport function applyBehaviorOverrides(value: BehaviorValue, overrides: JsonValue): BehaviorValue {\n if (isOrbitalValueShape(value)) return applyOrbitalOverrides(value, OrbitalOverridesSchema.parse(overrides));\n return applyTraitOverrides(value, TraitOverridesSchema.parse(overrides));\n}\n\n/** Structural guard for a trait value carried as data. */\nexport function isTraitValue(value: RuntimeValue): value is TraitValue {\n if (value === null || typeof value !== 'object' || Array.isArray(value)) return false;\n if (!('behavior' in value) || !('trait' in value)) return false;\n const { behavior, trait } = value;\n return typeof behavior === 'string' && SPECIFIER.test(behavior) && typeof trait === 'string' && PASCAL.test(trait);\n}\n\n/** Structural guard for an orbital value carried as data. */\nexport function isOrbitalValue(value: RuntimeValue): value is OrbitalValue {\n if (value === null || typeof value !== 'object' || Array.isArray(value)) return false;\n if (!('behavior' in value) || !('orbital' in value)) return false;\n const { behavior, orbital } = value;\n return typeof behavior === 'string' && SPECIFIER.test(behavior) && typeof orbital === 'string' && PASCAL.test(orbital);\n}\n\n/** A whole behavior as a value (`.lolo` type `behavior`): what `behavior/ref` builds. */\nexport function behaviorRef(specifier: string): BehaviorRef {\n if (!SPECIFIER.test(specifier)) {\n throw new Error(`behavior/ref: \"${specifier}\" is not a behavior specifier (<prefix>/<name>, std/behaviors/<name> or ./<dir>/<name>)`);\n }\n return { behavior: specifier };\n}\n\n/** Structural guard for a behavior value: a bare specifier (a trait or orbital value names a member too). */\nexport function isBehaviorRefValue(value: RuntimeValue): value is BehaviorRef {\n return BehaviorRefSchema.safeParse(value).success;\n}\n\nfunction isOrbitalValueShape(value: BehaviorValue): value is OrbitalValue {\n return 'orbital' in value;\n}\n\nconst EXPOSURES = ['app', 'experience', 'palette', 'both', 'internal'] as const satisfies readonly FactoryExposure[];\nconst VectorSchema = z.array(z.number());\n\n/**\n * A `behavior/catalog` scope: registry folders `<prefix>/<topic>[/<tier>]` (the\n * tree packages ship as `<registry>/<topic>/<tier>/<name>.orb`), optionally\n * narrowed by exposure.\n */\nexport const CatalogScopeSchema = z.object({\n paths: z.array(z.string().min(1)).min(1),\n exposure: z.array(z.enum(EXPOSURES)).optional(),\n}).strict();\nexport type CatalogScope = z.infer<typeof CatalogScopeSchema>;\n\n/** A behavior named by itself, with no trait or orbital picked (what `behavior/describe` takes for a whole behavior). */\nexport const BehaviorRefSchema = z.object({ behavior: z.string().regex(SPECIFIER) }).strict();\nexport type BehaviorRef = z.infer<typeof BehaviorRefSchema>;\n\n/** One behavior `behavior/catalog` returns (`orb behaviors catalog --json`). */\nexport const CatalogEntrySchema = z.object({\n /** `<prefix>/<name>`. */\n behavior: z.string(),\n package: z.string(),\n topic: z.string(),\n level: z.enum(['atom', 'molecule', 'organism']),\n exposure: z.enum(EXPOSURES).optional(),\n /** The `@almadar/ui` pattern the behavior is the factory of (`;; @pattern`); absent when it is not one. */\n pattern: z.string().optional(),\n description: z.string(),\n capabilities: z.array(z.string()),\n /** The behavior's traits as ready-to-bind values; absent in a listing asked for without traits (`traits: false`). */\n traits: z.array(TraitValueSchema).optional(),\n /** The behavior as a value (`.lolo` type `behavior`), ready to store. */\n value: BehaviorRefSchema,\n /** Shipped embedding vectors, keyed by facet (`description`, `capabilities`). */\n vectors: z.record(z.string(), VectorSchema),\n /** The embedding model the vectors were stamped with. */\n model: z.string(),\n}).strict();\nexport type CatalogEntry = z.infer<typeof CatalogEntrySchema>;\n\n/** One knob of a described trait, with its shipped embedding vector. */\nexport type TraitKnob = {\n key: string;\n type: string;\n default?: TraitConfigValue;\n label?: string;\n description?: string;\n tier?: string;\n vector?: number[];\n};\nexport const TraitKnobSchema: z.ZodType<TraitKnob> = z.object({\n key: z.string(),\n type: z.string(),\n default: TraitConfigValueSchema.optional(),\n label: z.string().optional(),\n description: z.string().optional(),\n tier: z.string().optional(),\n vector: VectorSchema.optional(),\n}).strict();\n\n/** A described trait's events: what it emits, listens to and transitions on, and which of those its source declares `@tier \"domain\"`. */\nexport type TraitEvents = {\n emits: string[];\n listens: string[];\n /** Events the trait's own transitions fire on — the only valid `listens` triggers. */\n transitions: string[];\n domain?: string[];\n};\nexport const TraitEventsSchema: z.ZodType<TraitEvents> = z.object({\n emits: z.array(z.string()),\n listens: z.array(z.string()),\n transitions: z.array(z.string()),\n domain: z.array(z.string()).optional(),\n}).strict();\n\n/** A described trait's state machine as the program runs it (resolved: composition and renames applied). */\nexport type TraitMachine = {\n linkedEntity?: string;\n stateMachine: StateMachine;\n};\nconst TraitMachineObject = z.object({\n linkedEntity: z.string().optional(),\n stateMachine: StateMachineSchema,\n}).strict();\nexport const TraitMachineSchema: z.ZodType<TraitMachine, z.input<typeof TraitMachineObject>> = TraitMachineObject;\n\n/** A described trait printed as `.lolo` by orb's formatter, with the 1-based lines each transition (by its index in the machine) spans. */\nexport type TraitSource = {\n text: string;\n transitions: { index: number; start: number; end: number }[];\n};\nexport const TraitSourceSchema: z.ZodType<TraitSource> = z.object({\n text: z.string(),\n transitions: z.array(z.object({ index: z.number().int(), start: z.number().int(), end: z.number().int() }).strict()),\n}).strict();\n\n/** What `behavior/describe` returns for a trait value (`orb behaviors describe --json`). */\nexport type TraitDescription = {\n value: TraitValue;\n knobs: TraitKnob[];\n events: TraitEvents;\n /** The trait's state machine; absent from an older orb. */\n machine?: TraitMachine;\n /** The trait as orb prints it; absent from an older orb. */\n source?: TraitSource;\n model: string;\n};\nconst TraitDescriptionObject = z.object({\n value: TraitValueSchema,\n knobs: z.array(TraitKnobSchema),\n events: TraitEventsSchema,\n machine: TraitMachineSchema.optional(),\n source: TraitSourceSchema.optional(),\n model: z.string(),\n}).strict();\nexport const TraitDescriptionSchema: z.ZodType<TraitDescription, z.input<typeof TraitDescriptionObject>> = TraitDescriptionObject;\n\n\n/** One transition of a mounted trait (`program/self { mounted: true }`). */\nexport type MountedTransition = {\n index: number;\n from: string[];\n to: string;\n event: string;\n /** The transition carries a guard. */\n guarded: boolean;\n emits: string[];\n};\n\nexport type MountedState = { name: string; isInitial: boolean; isTerminal: boolean };\n\n/** An event a mounted trait listens for; `event` is usually qualified `Trait.EVENT`. */\nexport type MountedListen = { event: string; triggers: string | null };\n\n/** One trait of a mounted orbital, with where it sits in the trait tree. */\nexport type MountedTrait = {\n trait: string;\n orbital: string | null;\n parent: string | null;\n depth: number;\n /** Parent states whose transitions show this trait; empty when it is shown through config. */\n embeddedIn: string[];\n /** False when the trait never paints a slot (store, http, timer). */\n renders: boolean;\n /** True for a trait of another orbital the page talks to by events (an imported orbital it never mounts); it has no parent. */\n linked: boolean;\n /** The asking trait or a trait that listens to it: a view that traced it would trace its own work. */\n observer: boolean;\n stepsIn: 'browser' | 'server';\n linkedEntity: string | null;\n states: MountedState[];\n transitions: MountedTransition[];\n emits: string[];\n listens: MountedListen[];\n /** Each running instance of the trait in the asking session; empty when it never ran. */\n instances: { entityId: string; state: string }[];\n};\n\n/** A whole mounted orbital: its traits in tree pre-order (roots in declared order, each followed depth-first by its embeds). */\n/** One delivery between two traits of the tree, by the kernel's delivery rule. */\nexport type MountedWire = { from: string; to: string; event: string; triggers: string | null };\n\nexport type MountedOrbital = { page: string; traits: MountedTrait[]; wires: MountedWire[] };\n\n/** What `behavior/describe` accepts: a trait value, an orbital value, or a whole behavior. */\nexport const DescribeTargetSchema = z.union([TraitValueSchema, OrbitalValueSchema, BehaviorRefSchema]);\nexport type DescribeTarget = TraitValue | OrbitalValue | BehaviorRef;\n\n/** One knob as a payload field (`orb behaviors describe`): its struct and list shapes resolved, plus its declared docs. */\nexport interface KnobField {\n readonly name: string;\n readonly type: string;\n readonly required?: boolean;\n readonly values?: readonly string[];\n readonly properties?: readonly KnobField[];\n /** The knob's current value: what a caller keeps when it does not change it. */\n readonly default?: TraitConfigValue;\n readonly label?: string;\n readonly description?: string;\n readonly synonyms?: string;\n readonly tier?: string;\n /** The `@config.<knob>` this knob's value forwards: its text is owned (and set) there. */\n readonly forwardedFrom?: string;\n}\nexport const KnobFieldSchema: z.ZodType<KnobField> = z.lazy(() =>\n z.object({\n name: z.string(),\n type: z.string(),\n required: z.boolean().optional(),\n values: z.array(z.string()).optional(),\n properties: z.array(KnobFieldSchema).optional(),\n default: TraitConfigValueSchema.optional(),\n label: z.string().optional(),\n description: z.string().optional(),\n synonyms: z.string().optional(),\n tier: z.string().optional(),\n forwardedFrom: z.string().optional(),\n }).strict(),\n);\n\n/** One orbital of a described behavior, from its resolved program. */\nexport const OrbitalDescriptionSchema = z.object({\n value: OrbitalValueSchema,\n config: DeclaredTraitConfigSchema,\n knobs: z.array(KnobFieldSchema),\n entity: z.object({ name: z.string(), fields: z.array(EntityFieldSchema), identity: z.boolean().optional(), persistence: EntityPersistenceSchema.optional() }).strict().optional(),\n /** Entities a sibling orbital owns that this one references: what an import of it maps through `entities {}`. */\n borrows: z.array(z.string()),\n /** What the orbital needs from its siblings at runtime, derived by `orb` (identity, entities, pages, events). */\n expects: z.array(ExpectDeclarationSchema),\n traits: z.array(z.object({\n trait: z.string(),\n config: DeclaredTraitConfigSchema,\n knobs: z.array(KnobFieldSchema),\n events: TraitEventsSchema,\n /** Declared `-> @rebindable`: the trait may be bound to another record. */\n rebindable: z.boolean().optional(),\n /** The upstream trait this one composes (`trait X = Alias.traits.Y`), as written; absent for a trait the behavior defines itself. */\n ref: z.string().optional(),\n /** The trait's declared `@capabilities` tags. */\n capabilities: z.array(z.string()).optional(),\n }).strict()),\n /** Each page with the traits it mounts: what the behavior declares as standing on its own. */\n pages: z.array(z.object({ name: z.string(), path: z.string(), traits: z.array(z.string()).optional(), label: z.string().optional(), icon: z.string().optional() }).strict()),\n /** Controls the orbital leaves for an embedding organism (`emitsScope external`) that nothing in it handles: an importer must route each. */\n forwards: z.array(z.object({ trait: z.string(), event: z.string(), via: z.array(z.string()) }).strict()).optional(),\n}).strict();\nexport type OrbitalDescription = z.infer<typeof OrbitalDescriptionSchema>;\n\n/** What `behavior/describe` returns for an orbital value or a whole behavior (`orb behaviors describe --json`). */\nexport const BehaviorDescriptionSchema = z.object({\n behavior: z.string(),\n config: DeclaredTraitConfigSchema,\n knobs: z.array(KnobFieldSchema),\n orbitals: z.array(OrbitalDescriptionSchema),\n /** The behaviors this one imports (`uses … from`): what it already contains. */\n uses: z.array(z.string()).optional(),\n}).strict();\nexport type BehaviorDescription = z.infer<typeof BehaviorDescriptionSchema>;\n\n/** What `program/eval` returns: where the validated program was written, and its traits as values. */\nexport interface EvaluatedProgram {\n /** Workspace-relative specifier of the written program (`./orbitals/<name>` by default). */\n readonly behavior: string;\n readonly traits: readonly TraitValue[];\n /** The written program as a behavior value. */\n readonly value: BehaviorRef;\n}\n\n/** A validator finding `program/eval` returns as data (the shape `orb validate --json` reports). A type alias, not an interface, so it is an `EventPayload` member. */\nexport type ProgramValidationIssue = {\n readonly code: string;\n readonly message: string;\n readonly path?: string;\n readonly line?: number;\n readonly column?: number;\n};\n"]}