@x12i/memorix-metadata 3.0.3 → 3.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 (56) hide show
  1. package/README.md +4 -0
  2. package/dist/abstracts.d.ts +9 -3
  3. package/dist/abstracts.d.ts.map +1 -1
  4. package/dist/abstracts.js +70 -66
  5. package/dist/abstracts.js.map +1 -1
  6. package/dist/fold-bindings.d.ts +19 -0
  7. package/dist/fold-bindings.d.ts.map +1 -0
  8. package/dist/fold-bindings.js +103 -0
  9. package/dist/fold-bindings.js.map +1 -0
  10. package/dist/index.d.ts +3 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +3 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/kind-fields.d.ts.map +1 -1
  15. package/dist/kind-fields.js +0 -1
  16. package/dist/kind-fields.js.map +1 -1
  17. package/dist/kinds.d.ts +2 -2
  18. package/dist/kinds.d.ts.map +1 -1
  19. package/dist/kinds.js +9 -11
  20. package/dist/kinds.js.map +1 -1
  21. package/dist/normalize.d.ts +1 -0
  22. package/dist/normalize.d.ts.map +1 -1
  23. package/dist/normalize.js +5 -1
  24. package/dist/normalize.js.map +1 -1
  25. package/dist/resolve.d.ts.map +1 -1
  26. package/dist/resolve.js +14 -3
  27. package/dist/resolve.js.map +1 -1
  28. package/dist/topology.d.ts +52 -0
  29. package/dist/topology.d.ts.map +1 -0
  30. package/dist/topology.js +376 -0
  31. package/dist/topology.js.map +1 -0
  32. package/dist/types.d.ts +146 -16
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/validate.d.ts.map +1 -1
  35. package/dist/validate.js +179 -64
  36. package/dist/validate.js.map +1 -1
  37. package/examples/invalid/agent-classification.json +31 -31
  38. package/examples/invalid/broken-binding.json +27 -27
  39. package/examples/invalid/completion-mapping-with-exec-policy.json +31 -31
  40. package/examples/invalid/missing-parent.json +31 -31
  41. package/examples/invalid/operational-kind-root.json +31 -31
  42. package/examples/invalid/pipeline-unknown-service.json +31 -31
  43. package/examples/invalid/relationship-missing-rules.json +24 -24
  44. package/examples/invalid/relationship-with-storage.json +24 -24
  45. package/examples/invalid/service-with-secrets.json +27 -27
  46. package/examples/knowx/normalized/pack.json +1133 -173
  47. package/examples/opx/normalized/pack.json +309 -291
  48. package/examples/opx/raw/abstract-types.json +223 -7
  49. package/examples/opx/raw/object-types.json +26 -95
  50. package/examples/opx/raw/pipelines-and-sources.json +66 -18
  51. package/examples/opx/raw/relationship-definitions.json +17 -47
  52. package/examples/opx/raw/view-definitions.json +6 -20
  53. package/examples/opx/raw/write-and-source-mappings.json +135 -20
  54. package/examples/project-opx/normalized/pack.json +355 -263
  55. package/package.json +1 -1
  56. package/examples/opx/raw/abstract-bindings.json +0 -38
@@ -0,0 +1,376 @@
1
+ /**
2
+ * Effective metadata topology — pure projection of concrete connections.
3
+ *
4
+ * Author relationships on abstracts; consume OT↔OT edges from this projection.
5
+ * Sources/streams feed object types. Agent services declare abstract ports
6
+ * (authored service→abstract edges). Services also appear on OT neighborhoods
7
+ * when a pipeline invokes them and a mapping on the same pipeline lands on an OT.
8
+ */
9
+ import { resolveAbstractBindings, resolveAbstractBindingsFromPack, } from "./abstracts.js";
10
+ import { foldLegacyAbstractBindings } from "./fold-bindings.js";
11
+ import { resolveSourceStreams } from "./streams.js";
12
+ function nodeId(kind, entityId) {
13
+ return `${kind}:${entityId}`;
14
+ }
15
+ function displayName(def, fallback) {
16
+ if (typeof def.name === "string" && def.name.trim())
17
+ return def.name.trim();
18
+ if (typeof def.title === "string" && def.title.trim())
19
+ return def.title.trim();
20
+ return fallback;
21
+ }
22
+ function pushNode(nodes, kind, entityId, name) {
23
+ const id = nodeId(kind, entityId);
24
+ if (!nodes.has(id)) {
25
+ nodes.set(id, { id, kind, entityId, name: name ?? entityId });
26
+ }
27
+ return id;
28
+ }
29
+ function pushEdge(edges, seen, from, to, kind, via) {
30
+ const viaKey = via
31
+ ? `:${via.relationshipDefinitionId ?? ""}:${via.pipelineId ?? ""}:${via.mappingId ?? ""}:${via.streamId ?? ""}:${via.direction ?? ""}`
32
+ : "";
33
+ const id = `${from}->${to}:${kind}${viaKey}`;
34
+ if (seen.has(id))
35
+ return;
36
+ seen.add(id);
37
+ edges.push(via ? { id, from, to, kind, via } : { id, from, to, kind });
38
+ }
39
+ function isMetadataPack(input) {
40
+ return (!!input &&
41
+ typeof input === "object" &&
42
+ input.format === "memorix-metadata/1" &&
43
+ Array.isArray(input.agents));
44
+ }
45
+ function isEffectiveResult(input) {
46
+ return (!!input &&
47
+ typeof input === "object" &&
48
+ "effective" in input &&
49
+ "ok" in input &&
50
+ Array.isArray(input.effective));
51
+ }
52
+ function emptyPack(agentId) {
53
+ return {
54
+ format: "memorix-metadata/1",
55
+ agentId,
56
+ agents: [],
57
+ objectTypes: [],
58
+ abstractTypes: [],
59
+ abstractBindings: [],
60
+ relationshipDefinitions: [],
61
+ mappings: [],
62
+ views: [],
63
+ writes: [],
64
+ sources: [],
65
+ services: [],
66
+ pipelines: [],
67
+ schedules: [],
68
+ kindDeclarations: [],
69
+ extensions: {},
70
+ };
71
+ }
72
+ /** Rebuild a pack from a flat effective definition array (for entry-only callers). */
73
+ export function packFromEffectiveDefinitions(entries, agentId = "effective") {
74
+ const pack = emptyPack(agentId);
75
+ const bucket = (kind) => {
76
+ switch (kind) {
77
+ case "agents":
78
+ return pack.agents;
79
+ case "object-types":
80
+ return pack.objectTypes;
81
+ case "abstract-types":
82
+ return pack.abstractTypes;
83
+ case "relationship-definitions":
84
+ return pack.relationshipDefinitions;
85
+ case "mappings":
86
+ return pack.mappings;
87
+ case "views":
88
+ return pack.views;
89
+ case "writes":
90
+ return pack.writes;
91
+ case "sources":
92
+ return pack.sources;
93
+ case "services":
94
+ return pack.services;
95
+ case "pipelines":
96
+ return pack.pipelines;
97
+ case "schedules":
98
+ return pack.schedules;
99
+ case "kind-declarations":
100
+ return pack.kindDeclarations;
101
+ default:
102
+ return [];
103
+ }
104
+ };
105
+ for (const e of entries) {
106
+ const def = { ...(e.definition ?? {}), id: e.id };
107
+ const list = bucket(e.kind);
108
+ if (list)
109
+ list.push(def);
110
+ }
111
+ if (!pack.agents.some((a) => a.id === agentId)) {
112
+ pack.agents.push({ id: agentId, name: agentId, parentId: null });
113
+ }
114
+ return pack;
115
+ }
116
+ function resolvePackAndAbstracts(input) {
117
+ if (isMetadataPack(input)) {
118
+ const abstracts = resolveAbstractBindingsFromPack(input);
119
+ return { pack: input, abstracts, ok: abstracts.ok, issues: abstracts.issues };
120
+ }
121
+ if (isEffectiveResult(input)) {
122
+ if (input.effectivePack) {
123
+ const abstracts = resolveAbstractBindings(input);
124
+ return {
125
+ pack: input.effectivePack,
126
+ abstracts,
127
+ ok: input.ok && abstracts.ok,
128
+ issues: [
129
+ ...input.issues.map((i) => ({ code: i.code, message: i.message })),
130
+ ...abstracts.issues,
131
+ ],
132
+ };
133
+ }
134
+ if (input.effective.length > 0) {
135
+ const pack = packFromEffectiveDefinitions(input.effective, input.selectedAgentIds[0] ?? "effective");
136
+ const abstracts = resolveAbstractBindingsFromPack(pack);
137
+ return {
138
+ pack,
139
+ abstracts,
140
+ ok: input.ok && abstracts.ok,
141
+ issues: [
142
+ ...input.issues.map((i) => ({ code: i.code, message: i.message })),
143
+ ...abstracts.issues,
144
+ ],
145
+ };
146
+ }
147
+ return {
148
+ pack: null,
149
+ abstracts: {
150
+ ok: false,
151
+ issues: [],
152
+ plans: [],
153
+ relationshipExpansions: [],
154
+ identityModel: {
155
+ abstractsMaterializeRecords: false,
156
+ abstractsHaveCollections: false,
157
+ concreteRecordIdRetained: true,
158
+ },
159
+ },
160
+ ok: false,
161
+ issues: [{ code: "TOPO-EMPTY", message: "No effective metadata to project" }],
162
+ };
163
+ }
164
+ // EffectiveDefinition[]
165
+ const entries = input;
166
+ const pack = packFromEffectiveDefinitions(entries);
167
+ const abstracts = resolveAbstractBindingsFromPack(pack);
168
+ return { pack, abstracts, ok: abstracts.ok, issues: abstracts.issues };
169
+ }
170
+ function memberObjectTypes(abs) {
171
+ return [...new Set((abs.members ?? []).map((m) => m.objectType).filter(Boolean))];
172
+ }
173
+ /**
174
+ * Build a resolved graph of effective connections over metadata.
175
+ * No new authoring kinds — pure projection from pack / effective result.
176
+ */
177
+ export function buildEffectiveMetadataTopology(input) {
178
+ const { pack, abstracts, ok, issues } = resolvePackAndAbstracts(input);
179
+ if (!pack) {
180
+ return { ok: false, nodes: [], edges: [], issues };
181
+ }
182
+ foldLegacyAbstractBindings(pack);
183
+ const nodes = new Map();
184
+ const edges = [];
185
+ const seen = new Set();
186
+ // --- Agents ---
187
+ for (const a of pack.agents) {
188
+ pushNode(nodes, "agents", a.id, a.name ?? a.id);
189
+ }
190
+ // --- Object types ---
191
+ for (const ot of pack.objectTypes) {
192
+ pushNode(nodes, "object-types", ot.id, ot.name ?? ot.id);
193
+ }
194
+ // --- Abstracts + member edges (sole membership source of truth) ---
195
+ for (const abs of pack.abstractTypes) {
196
+ pushNode(nodes, "abstract-types", abs.id, abs.name ?? abs.id);
197
+ for (const m of memberObjectTypes(abs)) {
198
+ pushNode(nodes, "object-types", m);
199
+ pushEdge(edges, seen, nodeId("abstract-types", abs.id), nodeId("object-types", m), "member");
200
+ }
201
+ }
202
+ // --- Relationship defs (abstract endpoints) + projected OT↔OT ---
203
+ for (const rel of pack.relationshipDefinitions) {
204
+ pushNode(nodes, "relationship-definitions", rel.id, rel.name ?? rel.id);
205
+ const fromAbs = rel.from?.abstractType?.trim();
206
+ const toAbs = rel.to?.abstractType?.trim();
207
+ if (fromAbs) {
208
+ pushNode(nodes, "abstract-types", fromAbs);
209
+ pushEdge(edges, seen, nodeId("relationship-definitions", rel.id), nodeId("abstract-types", fromAbs), "from");
210
+ }
211
+ if (toAbs) {
212
+ pushNode(nodes, "abstract-types", toAbs);
213
+ pushEdge(edges, seen, nodeId("relationship-definitions", rel.id), nodeId("abstract-types", toAbs), "to");
214
+ }
215
+ }
216
+ for (const exp of abstracts.relationshipExpansions) {
217
+ for (const combo of exp.candidateCombinations) {
218
+ pushNode(nodes, "object-types", combo.fromObjectType);
219
+ pushNode(nodes, "object-types", combo.toObjectType);
220
+ pushEdge(edges, seen, nodeId("object-types", combo.fromObjectType), nodeId("object-types", combo.toObjectType), "related", {
221
+ relationshipDefinitionId: exp.relationshipId,
222
+ direction: "from-to",
223
+ });
224
+ }
225
+ }
226
+ // --- Mappings ---
227
+ const mappingById = new Map();
228
+ for (const m of pack.mappings) {
229
+ mappingById.set(m.id, m);
230
+ pushNode(nodes, "mappings", m.id, m.id);
231
+ if (m.objectType?.trim()) {
232
+ pushNode(nodes, "object-types", m.objectType.trim());
233
+ }
234
+ }
235
+ // --- Connector instances (metadata kind `sources`) + streams ---
236
+ // The connector *package* id lives on the instance (`connectorRef`); it is not
237
+ // a peer topology node. Operators manage one concept: installed connectors.
238
+ for (const source of pack.sources) {
239
+ const sourceNode = pushNode(nodes, "sources", source.id, source.name ?? source.id);
240
+ const streams = resolveSourceStreams(source);
241
+ const streamFed = new Set();
242
+ for (const stream of streams) {
243
+ const streamEntityId = `${source.id}/${stream.streamId}`;
244
+ const streamNode = pushNode(nodes, "streams", streamEntityId, stream.name ?? stream.endpoint ?? stream.streamId);
245
+ pushEdge(edges, seen, sourceNode, streamNode, "stream");
246
+ const ot = stream.objectType?.trim();
247
+ if (ot) {
248
+ streamFed.add(ot);
249
+ pushNode(nodes, "object-types", ot);
250
+ pushEdge(edges, seen, streamNode, nodeId("object-types", ot), "feeds", {
251
+ streamId: stream.streamId,
252
+ });
253
+ }
254
+ }
255
+ // Aggregate source→OT feeds only when no stream already covers that OT.
256
+ const routeOts = new Set();
257
+ for (const r of source.routes ?? []) {
258
+ if (r.objectType?.trim())
259
+ routeOts.add(r.objectType.trim());
260
+ }
261
+ for (const s of source.streams ?? []) {
262
+ if (s.objectType?.trim())
263
+ routeOts.add(s.objectType.trim());
264
+ }
265
+ for (const ot of routeOts) {
266
+ if (streamFed.has(ot))
267
+ continue;
268
+ pushNode(nodes, "object-types", ot);
269
+ pushEdge(edges, seen, sourceNode, nodeId("object-types", ot), "feeds");
270
+ }
271
+ }
272
+ // --- Services (authored abstract ports + pipeline-derived OT transforms) ---
273
+ for (const svc of pack.services) {
274
+ pushNode(nodes, "services", svc.id, svc.name ?? svc.id);
275
+ const ports = [...(svc.inputs ?? []), ...(svc.outputs ?? [])];
276
+ const seenAbs = new Set();
277
+ for (const port of ports) {
278
+ const abs = port.abstractType?.trim();
279
+ if (!abs || seenAbs.has(abs))
280
+ continue;
281
+ seenAbs.add(abs);
282
+ pushNode(nodes, "abstract-types", abs);
283
+ pushEdge(edges, seen, nodeId("services", svc.id), nodeId("abstract-types", abs), "transforms", { serviceId: svc.id });
284
+ }
285
+ }
286
+ // --- Pipelines: step edges + derived service→OT transforms ---
287
+ for (const pipeline of pack.pipelines) {
288
+ pushNode(nodes, "pipelines", pipeline.id, pipeline.name ?? pipeline.id);
289
+ const serviceIds = new Set();
290
+ const mappingIds = new Set();
291
+ for (const step of pipeline.steps ?? []) {
292
+ const stepKind = step.kind?.trim() || "step";
293
+ if (step.sourceId?.trim()) {
294
+ pushNode(nodes, "sources", step.sourceId.trim());
295
+ pushEdge(edges, seen, nodeId("pipelines", pipeline.id), nodeId("sources", step.sourceId.trim()), stepKind, { pipelineId: pipeline.id, stepId: step.id });
296
+ }
297
+ if (step.serviceId?.trim()) {
298
+ serviceIds.add(step.serviceId.trim());
299
+ pushNode(nodes, "services", step.serviceId.trim());
300
+ pushEdge(edges, seen, nodeId("pipelines", pipeline.id), nodeId("services", step.serviceId.trim()), stepKind, { pipelineId: pipeline.id, stepId: step.id });
301
+ }
302
+ if (step.mappingId?.trim()) {
303
+ mappingIds.add(step.mappingId.trim());
304
+ pushNode(nodes, "mappings", step.mappingId.trim());
305
+ pushEdge(edges, seen, nodeId("pipelines", pipeline.id), nodeId("mappings", step.mappingId.trim()), stepKind, { pipelineId: pipeline.id, stepId: step.id });
306
+ }
307
+ const target = step.target;
308
+ if (target?.kind === "service" && target.serviceId?.trim()) {
309
+ serviceIds.add(target.serviceId.trim());
310
+ pushNode(nodes, "services", target.serviceId.trim());
311
+ pushEdge(edges, seen, nodeId("pipelines", pipeline.id), nodeId("services", target.serviceId.trim()), stepKind, { pipelineId: pipeline.id, stepId: step.id });
312
+ }
313
+ if (target?.kind === "connector" && target.sourceId?.trim()) {
314
+ pushNode(nodes, "sources", target.sourceId.trim());
315
+ pushEdge(edges, seen, nodeId("pipelines", pipeline.id), nodeId("sources", target.sourceId.trim()), stepKind, { pipelineId: pipeline.id, stepId: step.id });
316
+ }
317
+ if (target?.kind === "pipeline" && target.pipelineId?.trim()) {
318
+ pushNode(nodes, "pipelines", target.pipelineId.trim());
319
+ pushEdge(edges, seen, nodeId("pipelines", pipeline.id), nodeId("pipelines", target.pipelineId.trim()), "run-pipeline", { pipelineId: pipeline.id, stepId: step.id });
320
+ }
321
+ if ((step.kind === "run-pipeline" ||
322
+ step.kind === "pipeline" ||
323
+ step.kind === "call-pipeline") &&
324
+ step.pipelineId?.trim()) {
325
+ pushNode(nodes, "pipelines", step.pipelineId.trim());
326
+ pushEdge(edges, seen, nodeId("pipelines", pipeline.id), nodeId("pipelines", step.pipelineId.trim()), "run-pipeline", { pipelineId: pipeline.id, stepId: step.id });
327
+ }
328
+ if ((target?.kind === "runx" && target.capabilityId?.trim()) ||
329
+ (step.kind === "runx" && step.capabilityId?.trim())) {
330
+ const cap = target?.capabilityId?.trim() || step.capabilityId?.trim() || "";
331
+ // runx capabilities are external; use services overlay for topology discovery.
332
+ pushNode(nodes, "services", `runx:${cap}`, `runx:${cap}`);
333
+ pushEdge(edges, seen, nodeId("pipelines", pipeline.id), nodeId("services", `runx:${cap}`), "runx", { pipelineId: pipeline.id, stepId: step.id });
334
+ }
335
+ }
336
+ // Derived transforms: service on pipeline + mapping on same pipeline → OT
337
+ for (const serviceId of serviceIds) {
338
+ for (const mappingId of mappingIds) {
339
+ const mapping = mappingById.get(mappingId);
340
+ const ot = mapping?.objectType?.trim();
341
+ if (!ot)
342
+ continue;
343
+ pushNode(nodes, "object-types", ot);
344
+ pushEdge(edges, seen, nodeId("services", serviceId), nodeId("object-types", ot), "transforms", { pipelineId: pipeline.id, mappingId });
345
+ }
346
+ }
347
+ }
348
+ // --- Views / writes / schedules / kind-declarations ---
349
+ for (const v of pack.views) {
350
+ pushNode(nodes, "views", v.id, displayName(v, v.id));
351
+ }
352
+ for (const w of pack.writes) {
353
+ pushNode(nodes, "writes", w.id, w.id);
354
+ }
355
+ for (const s of pack.schedules) {
356
+ pushNode(nodes, "schedules", s.id, s.id);
357
+ if (s.pipelineId?.trim()) {
358
+ pushNode(nodes, "pipelines", s.pipelineId.trim());
359
+ pushEdge(edges, seen, nodeId("schedules", s.id), nodeId("pipelines", s.pipelineId.trim()), "runs", { pipelineId: s.pipelineId.trim() });
360
+ }
361
+ }
362
+ for (const k of pack.kindDeclarations ?? []) {
363
+ pushNode(nodes, "kind-declarations", k.id, k.name ?? k.id);
364
+ }
365
+ // Drop edges whose endpoints vanished (should not happen after pushNode)
366
+ const pruned = edges.filter((e) => nodes.has(e.from) && nodes.has(e.to));
367
+ const sortedNodes = [...nodes.values()].sort((a, b) => a.id.localeCompare(b.id));
368
+ const sortedEdges = pruned.sort((a, b) => a.id.localeCompare(b.id));
369
+ return {
370
+ ok,
371
+ nodes: sortedNodes,
372
+ edges: sortedEdges,
373
+ issues,
374
+ };
375
+ }
376
+ //# sourceMappingURL=topology.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topology.js","sourceRoot":"","sources":["../src/topology.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,uBAAuB,EACvB,+BAA+B,GAEhC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AA2EpD,SAAS,MAAM,CAAC,IAAY,EAAE,QAAgB;IAC5C,OAAO,GA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AE;QACF,KAAK,EAAE,WAAW;QAClB,KAAK,EAAE,WAAW;QAClB,MAAM;KACP,CAAC;AACJ,CAAC"}
package/dist/types.d.ts CHANGED
@@ -22,7 +22,10 @@ export type AgentDefinition = {
22
22
  export declare function parentIdsOf(agent: AgentDefinition | null | undefined): string[];
23
23
  export type ContentTypeSpec = {
24
24
  id: string;
25
+ /** When true, subjects of this object type should have this content type. */
25
26
  required?: boolean;
27
+ /** Why this content type is required; set when `required` is true. */
28
+ requiredReason?: string;
26
29
  notes?: string;
27
30
  retention?: string;
28
31
  discriminator?: {
@@ -38,6 +41,13 @@ export type ObjectTypeFieldSpec = {
38
41
  valueType: string;
39
42
  /** Defaults to applying across all content types when omitted. */
40
43
  contentType?: string;
44
+ /**
45
+ * Target object type when this field holds a record id (or array of ids).
46
+ * Required for entity-valued fields (`recordId` / array of recordIds).
47
+ */
48
+ refersTo?: {
49
+ objectType: string;
50
+ };
41
51
  };
42
52
  export type ObjectTypeDefinition = {
43
53
  id: string;
@@ -57,16 +67,6 @@ export type AbstractPropertyDefinition = {
57
67
  required?: boolean;
58
68
  description?: string;
59
69
  };
60
- /**
61
- * Metadata-only abstract type. Never materializes a collection or abstract recordId.
62
- */
63
- export type AbstractTypeDefinition = {
64
- id: string;
65
- name: string;
66
- meaning: string;
67
- category: string;
68
- properties?: AbstractPropertyDefinition[];
69
- };
70
70
  /**
71
71
  * How one abstract property is satisfied for one concrete union member.
72
72
  * Direct: propertyPath (+ compatible concreteValueType).
@@ -97,9 +97,24 @@ export type AbstractMemberBinding = {
97
97
  properties?: AbstractPropertyBinding[];
98
98
  };
99
99
  /**
100
- * Binding of an abstract to one or more concrete object types (a union).
101
- * Prefer `members` for property-level detail; `concreteObjectTypes` remains valid
102
- * for membership-only unions (e.g. People = employees ∪ contractors).
100
+ * Metadata-only abstract type. Never materializes a collection or abstract recordId.
101
+ * Owns membership and property projection (`members`) — no separate binding kind.
102
+ */
103
+ export type AbstractTypeDefinition = {
104
+ id: string;
105
+ name: string;
106
+ meaning: string;
107
+ category: string;
108
+ properties?: AbstractPropertyDefinition[];
109
+ /** Concrete object types that participate + how each fills abstract properties. */
110
+ members?: AbstractMemberBinding[];
111
+ /** True when more than one concrete object type participates. */
112
+ union?: boolean;
113
+ notes?: string;
114
+ };
115
+ /**
116
+ * @deprecated Legacy separate binding documents. Folded into
117
+ * `AbstractTypeDefinition.members` by `foldLegacyAbstractBindings`.
103
118
  */
104
119
  export type AbstractBindingDefinition = {
105
120
  id: string;
@@ -162,7 +177,12 @@ export type ViewDefinition = {
162
177
  id: string;
163
178
  kind: string;
164
179
  title?: string;
180
+ /**
181
+ * @deprecated Concrete objectType binding is forbidden — views are abstract-only.
182
+ * Retained on the type only for migration diagnostics; validation rejects it.
183
+ */
165
184
  objectType?: string;
185
+ /** Required: views speak abstract language; apps stay connector-agnostic. */
166
186
  abstractType?: string;
167
187
  relationshipDefinitionId?: string;
168
188
  direction?: string;
@@ -261,10 +281,72 @@ export type SourceDefinition = {
261
281
  defaultPageSize?: number;
262
282
  };
263
283
  connectorRef?: string;
284
+ /** Connector package version for remote host / registry resolve. */
285
+ connectorVersion?: string;
286
+ /**
287
+ * Remote connector host base URL (FR-040).
288
+ * When set, Memory pulls via `createRemoteConnectorHost` instead of in-process.
289
+ */
290
+ hostBaseUrl?: string;
291
+ /**
292
+ * Logical host key resolved through the platform remote-host map
293
+ * (e.g. `mgc-source` → `MGC_SOURCE_SERVICE_URL`).
294
+ */
295
+ connectorHostKey?: string;
296
+ /**
297
+ * When true, pull MUST use a remote host (hostBaseUrl / host key / default).
298
+ * Never falls through to an in-process adapter.
299
+ */
300
+ remoteHosting?: boolean;
301
+ /**
302
+ * Authoritative direction when set (MGC catalog / pack). Prefer over capability inference.
303
+ * Source packs use `"source"`; targets use DestinationDefinition.role.
304
+ */
305
+ role?: "source" | "target";
264
306
  };
307
+ /**
308
+ * Outbound destination for target connectors (generic connectors deliver path).
309
+ * Parallel to SourceDefinition: credentialRef only; durable receipts live in Memory.
310
+ */
311
+ export type DestinationDefinition = {
312
+ id: string;
313
+ name: string;
314
+ kind: string;
315
+ connectorRef: string;
316
+ connectorVersion?: string;
317
+ credentialRef?: string;
318
+ /** Remote target host base URL (POST /v1/deliver). */
319
+ hostBaseUrl?: string;
320
+ connectorHostKey?: string;
321
+ /** Authoritative package direction (always `"target"` for destinations when set). */
322
+ role?: "target";
323
+ /** Optional mapping / stream labels for the deliver envelope. */
324
+ config?: Record<string, unknown>;
325
+ };
326
+ /**
327
+ * `agent` (default): subject I/O speaks only abstracts.
328
+ * `connector`: connector-adjacent pull/promote workers — exempt from the
329
+ * abstract-port law; may use concrete Memory surfaces (`raw`).
330
+ */
331
+ export type ServiceRole = "agent" | "connector";
265
332
  export type ServiceIoPort = {
266
333
  id: string;
267
- /** Logical schema / type reference — not a runtime payload. */
334
+ /**
335
+ * Abstract type this port speaks. Required on subject-data ports for
336
+ * `role: "agent"` services (default). Runtime may resolve to concrete members.
337
+ */
338
+ abstractType?: string;
339
+ /** Optional property / view path on the abstract. */
340
+ path?: string;
341
+ /**
342
+ * Non-subject control port (triggerReason, sourceId, cursors, …).
343
+ * Exempt from abstractType requirement on agent services.
344
+ */
345
+ control?: boolean;
346
+ /**
347
+ * Logical schema / view reference — not a runtime payload.
348
+ * Must not be `memorix-record/{contentType}` on agent services; prefer abstractType.
349
+ */
268
350
  schemaRef?: string;
269
351
  description?: string;
270
352
  };
@@ -275,13 +357,20 @@ export type ServiceInvocation = {
275
357
  /**
276
358
  * Declarative service contract: capabilities + logical I/O + invocation shape.
277
359
  * Forbidden: secret values, deployment/runtime state.
360
+ * Agent services speak only abstracts (hard rule); connector-role workers may
361
+ * land concrete raw via sources/connectors.
278
362
  */
279
363
  /** Opt-in Memorix surfaces a called service may use mid-invocation. */
280
- export type MemorixServiceAccess = "explore" | "checkpoints";
364
+ export type MemorixServiceAccess = "explore" | "checkpoints" | "raw";
281
365
  export type ServiceDefinition = {
282
366
  id: string;
283
367
  name: string;
284
368
  description?: string;
369
+ /**
370
+ * Default `agent`. Use `connector` for pull/promote workers that speak
371
+ * concrete Memory / source ids — not agent vocabulary.
372
+ */
373
+ role?: ServiceRole;
285
374
  capabilities: string[];
286
375
  inputs?: ServiceIoPort[];
287
376
  outputs?: ServiceIoPort[];
@@ -289,14 +378,51 @@ export type ServiceDefinition = {
289
378
  /**
290
379
  * When set, pipeline invoke injects a `memorix` callback context so the
291
380
  * worker can call Explore and/or Source checkpoints mid-work.
381
+ * `raw` is allowed only when `role: "connector"`.
292
382
  */
293
383
  memorixAccess?: MemorixServiceAccess[];
294
384
  };
385
+ export type PipelineStepTarget = {
386
+ kind: "service";
387
+ serviceId: string;
388
+ } | {
389
+ kind: "ai-service";
390
+ aiServiceType: string;
391
+ itemId: string;
392
+ } | {
393
+ kind: "connector";
394
+ connectorId: string;
395
+ sourceId: string;
396
+ } | {
397
+ kind: "destination";
398
+ connectorId: string;
399
+ destinationId: string;
400
+ } | {
401
+ kind: "pipeline";
402
+ pipelineId: string;
403
+ } | {
404
+ kind: "runx";
405
+ capabilityId: string;
406
+ };
295
407
  export type PipelineStep = {
296
408
  id: string;
297
409
  kind: string;
298
410
  sourceId?: string;
299
411
  serviceId?: string;
412
+ /** Nested pipeline id when kind is run-pipeline / pipeline. */
413
+ pipelineId?: string;
414
+ /** Runx capability id when kind is runx. */
415
+ capabilityId?: string;
416
+ connectorId?: string;
417
+ /** Unified invoke target (service | ai-service | connector | pipeline | runx). */
418
+ target?: PipelineStepTarget;
419
+ /** Step-level AI binding (alternative to service pack aiService). */
420
+ aiService?: {
421
+ aiServiceType?: string;
422
+ itemId?: string;
423
+ endpointEnv?: string;
424
+ endpoint?: string;
425
+ };
300
426
  contentType?: string;
301
427
  /** Completion / step execution policy belongs on the pipeline, not on mappings. */
302
428
  completionPolicy?: JsonObject;
@@ -335,7 +461,11 @@ export type MetadataPack = {
335
461
  agents: AgentDefinition[];
336
462
  objectTypes: ObjectTypeDefinition[];
337
463
  abstractTypes: AbstractTypeDefinition[];
338
- abstractBindings: AbstractBindingDefinition[];
464
+ /**
465
+ * @deprecated Always empty after normalize/fold. Kept optional for load compat.
466
+ * Membership lives on `abstractTypes[].members`.
467
+ */
468
+ abstractBindings?: AbstractBindingDefinition[];
339
469
  relationshipDefinitions: RelationshipDefinition[];
340
470
  mappings: MappingDefinition[];
341
471
  views: ViewDefinition[];