@x12i/memorix-docs 1.0.2 → 1.1.1
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.
- package/dist/generated/bundle.d.ts +4849 -3
- package/dist/generated/bundle.d.ts.map +1 -1
- package/dist/generated/bundle.js +7580 -45
- package/dist/generated/bundle.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/files/INDEX.md +84 -0
- package/files/SEARCH.json +3087 -0
- package/files/agent-manifest.json +1785 -0
- package/files/apis/memorix-records/overview.md +22 -0
- package/files/concepts/abstracts-bindings.md +27 -0
- package/files/concepts/agents-inheritance.md +28 -0
- package/files/concepts/analysis-objects.md +26 -0
- package/files/concepts/composition.md +27 -0
- package/files/concepts/decisions-content.md +27 -0
- package/files/concepts/effective-metadata.md +27 -0
- package/files/concepts/explicit-metadata-installation.md +26 -0
- package/files/concepts/intelligence-proposals.md +27 -0
- package/files/concepts/mappings-transforms.md +26 -0
- package/files/concepts/object-content-category.md +26 -0
- package/files/concepts/org-agent-scope.md +27 -0
- package/files/concepts/people-union.md +27 -0
- package/files/concepts/raw-records.md +26 -0
- package/files/concepts/record-revisions.md +26 -0
- package/files/concepts/relationship-definitions.md +26 -0
- package/files/concepts/relationship-references.md +27 -0
- package/files/concepts/resolved-unresolved.md +27 -0
- package/files/concepts/sources-and-memory.md +26 -0
- package/files/concepts/traversal.md +27 -0
- package/files/diagrams/agent-inheritance.md +34 -0
- package/files/diagrams/intelligence-journey.md +38 -0
- package/files/diagrams/memorix-central-journey.md +51 -0
- package/files/diagrams/metadata-lifecycle.md +40 -0
- package/files/diagrams/people-union-diagram.md +36 -0
- package/files/diagrams/record-content-model.md +43 -0
- package/files/diagrams/relationship-traversal.md +40 -0
- package/files/diagrams/revision-safe-write.md +39 -0
- package/files/examples/analysis-decision-records.md +11 -0
- package/files/examples/memorix-record-envelope.md +11 -0
- package/files/examples/metadata-pack-install.md +11 -0
- package/files/examples/people-abstract-query.md +11 -0
- package/files/examples/raw-vs-composed.md +11 -0
- package/files/examples/relationship-def-and-ref.md +11 -0
- package/files/examples/revision-conflict-response.md +11 -0
- package/files/examples/revision-safe-write.md +11 -0
- package/files/examples/traversal-resolved-unresolved.md +11 -0
- package/files/glossary/abstract.md +9 -0
- package/files/glossary/agent.md +9 -0
- package/files/glossary/analysis.md +9 -0
- package/files/glossary/binding.md +9 -0
- package/files/glossary/composition.md +9 -0
- package/files/glossary/content-type.md +9 -0
- package/files/glossary/data-category.md +9 -0
- package/files/glossary/decision.md +9 -0
- package/files/glossary/effective-metadata.md +9 -0
- package/files/glossary/intelligence-proposal.md +9 -0
- package/files/glossary/mapping.md +9 -0
- package/files/glossary/memory.md +9 -0
- package/files/glossary/object-type.md +9 -0
- package/files/glossary/relationship-definition.md +9 -0
- package/files/glossary/relationship-reference.md +9 -0
- package/files/glossary/revision.md +9 -0
- package/files/glossary/scope.md +9 -0
- package/files/glossary/source.md +9 -0
- package/files/glossary/traversal.md +9 -0
- package/files/guides/apply-scope.md +40 -0
- package/files/guides/choose-access-method.md +24 -0
- package/files/guides/compose-subject-ui.md +24 -0
- package/files/guides/define-traverse-relationship.md +26 -0
- package/files/guides/diagnose-unresolved.md +24 -0
- package/files/guides/evidence-to-decision.md +25 -0
- package/files/guides/first-revision-safe-write.md +30 -0
- package/files/guides/inspect-effective-metadata.md +30 -0
- package/files/guides/query-people-abstract.md +25 -0
- package/files/guides/reload-retry-conflict.md +32 -0
- package/files/guides/validate-install-pack.md +32 -0
- package/files/indexes/books.json +95 -0
- package/files/indexes/books.md +17 -0
- package/files/indexes/concepts.json +119 -0
- package/files/indexes/concepts.md +21 -0
- package/files/indexes/diagrams.json +53 -0
- package/files/indexes/diagrams.md +10 -0
- package/files/indexes/guides.json +71 -0
- package/files/indexes/guides.md +13 -0
- package/files/indexes/scenarios.json +41 -0
- package/files/indexes/scenarios.md +8 -0
- package/files/indexes/tutorials.json +47 -0
- package/files/indexes/tutorials.md +9 -0
- package/files/indexes/use-cases.json +239 -0
- package/files/indexes/use-cases.md +41 -0
- package/files/knowledge.json +2940 -0
- package/files/packs/concept/abstracts-bindings/PACK.md +11 -0
- package/files/packs/concept/abstracts-bindings/pack.json +13 -0
- package/files/packs/concept/agents-inheritance/PACK.md +11 -0
- package/files/packs/concept/agents-inheritance/pack.json +13 -0
- package/files/packs/concept/analysis-objects/PACK.md +11 -0
- package/files/packs/concept/analysis-objects/pack.json +14 -0
- package/files/packs/concept/composition/PACK.md +11 -0
- package/files/packs/concept/composition/pack.json +13 -0
- package/files/packs/concept/decisions-content/PACK.md +11 -0
- package/files/packs/concept/decisions-content/pack.json +13 -0
- package/files/packs/concept/effective-metadata/PACK.md +11 -0
- package/files/packs/concept/effective-metadata/pack.json +13 -0
- package/files/packs/concept/explicit-metadata-installation/PACK.md +11 -0
- package/files/packs/concept/explicit-metadata-installation/pack.json +14 -0
- package/files/packs/concept/intelligence-proposals/PACK.md +11 -0
- package/files/packs/concept/intelligence-proposals/pack.json +13 -0
- package/files/packs/concept/mappings-transforms/PACK.md +11 -0
- package/files/packs/concept/mappings-transforms/pack.json +13 -0
- package/files/packs/concept/object-content-category/PACK.md +11 -0
- package/files/packs/concept/object-content-category/pack.json +14 -0
- package/files/packs/concept/org-agent-scope/PACK.md +11 -0
- package/files/packs/concept/org-agent-scope/pack.json +14 -0
- package/files/packs/concept/people-union/PACK.md +11 -0
- package/files/packs/concept/people-union/pack.json +13 -0
- package/files/packs/concept/raw-records/PACK.md +11 -0
- package/files/packs/concept/raw-records/pack.json +14 -0
- package/files/packs/concept/record-revisions/PACK.md +11 -0
- package/files/packs/concept/record-revisions/pack.json +13 -0
- package/files/packs/concept/relationship-definitions/PACK.md +11 -0
- package/files/packs/concept/relationship-definitions/pack.json +14 -0
- package/files/packs/concept/relationship-references/PACK.md +11 -0
- package/files/packs/concept/relationship-references/pack.json +13 -0
- package/files/packs/concept/resolved-unresolved/PACK.md +11 -0
- package/files/packs/concept/resolved-unresolved/pack.json +13 -0
- package/files/packs/concept/sources-and-memory/PACK.md +11 -0
- package/files/packs/concept/sources-and-memory/pack.json +13 -0
- package/files/packs/concept/traversal/PACK.md +11 -0
- package/files/packs/concept/traversal/pack.json +13 -0
- package/files/packs/guide/apply-scope/PACK.md +11 -0
- package/files/packs/guide/apply-scope/pack.json +13 -0
- package/files/packs/guide/choose-access-method/PACK.md +11 -0
- package/files/packs/guide/choose-access-method/pack.json +15 -0
- package/files/packs/guide/compose-subject-ui/PACK.md +11 -0
- package/files/packs/guide/compose-subject-ui/pack.json +13 -0
- package/files/packs/guide/define-traverse-relationship/PACK.md +11 -0
- package/files/packs/guide/define-traverse-relationship/pack.json +14 -0
- package/files/packs/guide/diagnose-unresolved/PACK.md +11 -0
- package/files/packs/guide/diagnose-unresolved/pack.json +13 -0
- package/files/packs/guide/evidence-to-decision/PACK.md +11 -0
- package/files/packs/guide/evidence-to-decision/pack.json +14 -0
- package/files/packs/guide/first-revision-safe-write/PACK.md +11 -0
- package/files/packs/guide/first-revision-safe-write/pack.json +13 -0
- package/files/packs/guide/inspect-effective-metadata/PACK.md +11 -0
- package/files/packs/guide/inspect-effective-metadata/pack.json +13 -0
- package/files/packs/guide/query-people-abstract/PACK.md +11 -0
- package/files/packs/guide/query-people-abstract/pack.json +13 -0
- package/files/packs/guide/reload-retry-conflict/PACK.md +11 -0
- package/files/packs/guide/reload-retry-conflict/pack.json +13 -0
- package/files/packs/guide/validate-install-pack/PACK.md +11 -0
- package/files/packs/guide/validate-install-pack/pack.json +13 -0
- package/files/packs/scenario/choose-subject-view/PACK.md +11 -0
- package/files/packs/scenario/choose-subject-view/pack.json +11 -0
- package/files/packs/scenario/pack-valid-not-installed/PACK.md +11 -0
- package/files/packs/scenario/pack-valid-not-installed/pack.json +11 -0
- package/files/packs/scenario/scope-mismatch/PACK.md +11 -0
- package/files/packs/scenario/scope-mismatch/pack.json +11 -0
- package/files/packs/scenario/stale-revision-conflict/PACK.md +11 -0
- package/files/packs/scenario/stale-revision-conflict/pack.json +11 -0
- package/files/packs/scenario/traversal-direction/PACK.md +11 -0
- package/files/packs/scenario/traversal-direction/pack.json +11 -0
- package/files/packs/scenario/unresolved-relationship/PACK.md +11 -0
- package/files/packs/scenario/unresolved-relationship/pack.json +11 -0
- package/files/packs/tutorial/analysis-decision-lab/PACK.md +11 -0
- package/files/packs/tutorial/analysis-decision-lab/pack.json +14 -0
- package/files/packs/tutorial/compare-views/PACK.md +11 -0
- package/files/packs/tutorial/compare-views/pack.json +14 -0
- package/files/packs/tutorial/conflict-lab/PACK.md +11 -0
- package/files/packs/tutorial/conflict-lab/pack.json +13 -0
- package/files/packs/tutorial/first-revision-safe-record/PACK.md +11 -0
- package/files/packs/tutorial/first-revision-safe-record/pack.json +13 -0
- package/files/packs/tutorial/install-pack-lab/PACK.md +11 -0
- package/files/packs/tutorial/install-pack-lab/pack.json +13 -0
- package/files/packs/tutorial/relationships-lab/PACK.md +11 -0
- package/files/packs/tutorial/relationships-lab/pack.json +13 -0
- package/files/packs/tutorial/start-with-sample-data/PACK.md +11 -0
- package/files/packs/tutorial/start-with-sample-data/pack.json +13 -0
- package/files/sample-data/memorix-synthetic-basic.md +13 -0
- package/files/scenarios/choose-subject-view.md +36 -0
- package/files/scenarios/pack-valid-not-installed.md +33 -0
- package/files/scenarios/scope-mismatch.md +44 -0
- package/files/scenarios/stale-revision-conflict.md +38 -0
- package/files/scenarios/traversal-direction.md +30 -0
- package/files/scenarios/unresolved-relationship.md +31 -0
- package/files/tutorials/analysis-decision-lab.md +18 -0
- package/files/tutorials/compare-views.md +22 -0
- package/files/tutorials/conflict-lab.md +18 -0
- package/files/tutorials/first-revision-safe-record.md +18 -0
- package/files/tutorials/install-pack-lab.md +22 -0
- package/files/tutorials/relationships-lab.md +18 -0
- package/files/tutorials/start-with-sample-data.md +18 -0
- package/files/ui/clients/memorix-studio.md +9 -0
- package/files/use-cases/abstract-people-list.md +237 -0
- package/files/use-cases/ai-pipeline-fail-closed.md +117 -0
- package/files/use-cases/author-pipeline-e2e.md +339 -0
- package/files/use-cases/build-callable-service.md +347 -0
- package/files/use-cases/builder-acceptance-ops.md +112 -0
- package/files/use-cases/choose-access-method.md +111 -0
- package/files/use-cases/client-first-read-write.md +374 -0
- package/files/use-cases/compose-for-ui.md +97 -0
- package/files/use-cases/custom-kind-descriptors.md +137 -0
- package/files/use-cases/data-journey-evidence.md +115 -0
- package/files/use-cases/discriminated-content-writes.md +152 -0
- package/files/use-cases/embed-studio-host.md +165 -0
- package/files/use-cases/four-field-links.md +246 -0
- package/files/use-cases/http-process-compliance.md +225 -0
- package/files/use-cases/install-metadata-pack.md +180 -0
- package/files/use-cases/intelligence-propose-install.md +163 -0
- package/files/use-cases/knowx-claims-review.md +396 -0
- package/files/use-cases/learn-record-envelope.md +233 -0
- package/files/use-cases/lists-cursors-pagination.md +196 -0
- package/files/use-cases/local-acceptance-g12ops.md +160 -0
- package/files/use-cases/memory-hourly-ingest.md +276 -0
- package/files/use-cases/metadata-before-write.md +145 -0
- package/files/use-cases/migrate-associated-star.md +159 -0
- package/files/use-cases/openapi-typed-client.md +78 -0
- package/files/use-cases/ops-pack-fixtures.md +168 -0
- package/files/use-cases/orient-platform.md +172 -0
- package/files/use-cases/pipeline-retry-evidence.md +121 -0
- package/files/use-cases/relationship-rebuild-verify.md +128 -0
- package/files/use-cases/revision-stale-conflicts.md +194 -0
- package/files/use-cases/start-from-zero.md +171 -0
- package/files/use-cases/studio-design-types.md +122 -0
- package/files/use-cases/studio-explore-subject.md +89 -0
- package/files/use-cases/studio-operate-pipelines.md +100 -0
- package/files/use-cases/studio-review-intelligence.md +74 -0
- package/files/use-cases/studio-scope-isolation.md +67 -0
- package/files/use-cases/studio-stale-conflict-ui.md +54 -0
- package/files/use-cases/troubleshoot-http-matrix.md +164 -0
- package/files/use-cases/trusted-in-process-embed.md +94 -0
- package/files/use-cases/workflow-sibling-api.md +212 -0
- package/files/visuals/revision-conflict.md +19 -0
- package/files/visuals/scope-apply.md +19 -0
- package/package.json +4 -3
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# Author and run a pipeline end-to-end
|
|
2
|
+
|
|
3
|
+
> **Use case id:** `author-pipeline-e2e`
|
|
4
|
+
> **Goal:** Define steps, execute under g12ops*, and observe runs/artifacts.
|
|
5
|
+
> **Audiences:** developers
|
|
6
|
+
> **Tags:** pipelines, ops
|
|
7
|
+
|
|
8
|
+
## Reading path
|
|
9
|
+
|
|
10
|
+
1. **Building Pipelines** (developers) → chapters: `1-pipeline-definition`, `2-execution-model`, `4-step-types-one-by-one`, `13-complete-ops-tutorial`
|
|
11
|
+
|
|
12
|
+
## From: Building Pipelines — 1. Pipeline definition
|
|
13
|
+
|
|
14
|
+
### Identity
|
|
15
|
+
|
|
16
|
+
- Stable pipeline metadata ID (`pipelineId`) belongs to an agent (e.g. `ops`).
|
|
17
|
+
- Inheritance and child replacement follow multi-agent metadata rules.
|
|
18
|
+
- Pipeline ID is **not** a run ID.
|
|
19
|
+
- Metadata does not hold runtime state; fingerprints and build evidence live on the run.
|
|
20
|
+
- Do not invent unsupported metadata-version machinery beyond what the runtime captures.
|
|
21
|
+
|
|
22
|
+
### Scope
|
|
23
|
+
|
|
24
|
+
Every run uses:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
{
|
|
28
|
+
orgId: string; // e.g. g12ops7a3c — complete data universe
|
|
29
|
+
agentIds: string[]; // e.g. ["ops"] — effective metadata only
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Scope is captured on the run. Every step receives the same canonical scope. Steps must not reinterpret scope. `agentIds` does not filter organization data.
|
|
34
|
+
|
|
35
|
+
```http
|
|
36
|
+
x-memorix-org-id: g12ops7a3c
|
|
37
|
+
x-memorix-agent-ids: ops
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Definition fields (runtime)
|
|
41
|
+
|
|
42
|
+
Core runtime shape (`PipelineDefinition` in `@x12i/memorix-pipeline`):
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
type PipelineDefinition = {
|
|
46
|
+
pipelineId: string;
|
|
47
|
+
version: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
steps: StepDefinition[];
|
|
50
|
+
services?: ServiceRef[];
|
|
51
|
+
schedules?: ScheduleDefinition[];
|
|
52
|
+
retryPolicy?: RetryPolicy;
|
|
53
|
+
dataRefThresholdBytes?: number; // default 1_048_576
|
|
54
|
+
metadata?: Record<string, unknown>;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
type StepDefinition = {
|
|
58
|
+
stepId: string;
|
|
59
|
+
stepKind: StepKind;
|
|
60
|
+
label?: string;
|
|
61
|
+
dependsOn?: string[];
|
|
62
|
+
inputs?: DataRefExpr[];
|
|
63
|
+
outputKey?: string;
|
|
64
|
+
retryPolicy?: RetryPolicy;
|
|
65
|
+
idempotencyKeyExpr?: string; // required for mutating steps
|
|
66
|
+
port?: string;
|
|
67
|
+
portConfig?: unknown;
|
|
68
|
+
serviceId?: string;
|
|
69
|
+
batchSize?: number;
|
|
70
|
+
atomicBatch?: boolean; // opt-in; rejected unless adapter supports
|
|
71
|
+
timeoutMs?: number;
|
|
72
|
+
disabled?: boolean;
|
|
73
|
+
inputSchema?: unknown;
|
|
74
|
+
outputSchema?: unknown;
|
|
75
|
+
};
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Agent-pack metadata may use a lighter authoring shape (`id`, `name`, `trigger`, `mode`, `steps[]` with `kind` / `serviceId` / `mappingId`). The runtime compiles or binds that into the executable definition. Always validate packs with `@x12i/memorix-metadata` before install.
|
|
79
|
+
|
|
80
|
+
### Inputs and outputs
|
|
81
|
+
|
|
82
|
+
**Inputs:** small inline JSON, DataRef/artifact, record/content address, list/query, abstract reference, relationship reference, Memory source/pull reference, captured context, batch manifest, workflow reference, external trigger payload.
|
|
83
|
+
|
|
84
|
+
**Outputs:** inline result, DataRef, record address/revision, relationship run result, partial batch manifest, external action receipt, workflow/analysis/decision/narrative references, diagnostics.
|
|
85
|
+
|
|
86
|
+
Prefer references to stored results over copying large payloads into the run ledger. Default DataRef threshold: **1 MiB**.
|
|
87
|
+
|
|
88
|
+
### DAG and dependencies
|
|
89
|
+
|
|
90
|
+
Rules:
|
|
91
|
+
|
|
92
|
+
- Unique `stepId`s
|
|
93
|
+
- `dependsOn` edges; topological execution
|
|
94
|
+
- Fan-out / fan-in and parallelism for independent branches
|
|
95
|
+
- Cycle rejection; unreachable steps rejected at validate
|
|
96
|
+
- Output-to-input via `inputs` DataRef expressions (`fromStep`, `key`, `path`)
|
|
97
|
+
- Disabled steps skipped
|
|
98
|
+
|
|
99
|
+
Loops are not a graph feature. Repeated work uses batches, retries, schedules, or an explicit redesign — not hidden cycles.
|
|
100
|
+
|
|
101
|
+
### Control flow (supported)
|
|
102
|
+
|
|
103
|
+
Sequential execution · parallel independent branches · per-item batch work · short-circuit on terminal failure · continue-on-item-failure for batches · optional/disabled steps · cancellation.
|
|
104
|
+
|
|
105
|
+
**Unsupported as global features:** cross-service distributed transactions, hidden graph cycles, silent compensation without an explicit step. Atomic batch is **opt-in** and only when the backing port declares support.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## From: Building Pipelines — 2. Execution model
|
|
110
|
+
|
|
111
|
+
### Run, step, attempt
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
Pipeline definition
|
|
115
|
+
→ Run (one execution)
|
|
116
|
+
→ Step (one node in the definition)
|
|
117
|
+
→ Attempt (one try)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Retries create **attempts**; they do not duplicate logical steps.
|
|
121
|
+
|
|
122
|
+
### Run statuses
|
|
123
|
+
|
|
124
|
+
| Status | Meaning | Terminal? |
|
|
125
|
+
|---|---|---|
|
|
126
|
+
| `pending` | Queued | No |
|
|
127
|
+
| `running` | Active | No |
|
|
128
|
+
| `succeeded` | All required work ok | Yes |
|
|
129
|
+
| `failed` | Terminal failure | Yes |
|
|
130
|
+
| `partial` | Explicit partial success (e.g. batch) | Yes |
|
|
131
|
+
| `cancelled` | Operator/runtime cancel | Yes |
|
|
132
|
+
|
|
133
|
+
### Step statuses
|
|
134
|
+
|
|
135
|
+
`pending` · `running` · `succeeded` · `failed` · `skipped`
|
|
136
|
+
|
|
137
|
+
### Durable production runtime
|
|
138
|
+
|
|
139
|
+
Production requires durable run ledger, durable artifact store, real canonical ports, real service bindings, and explicit production mode.
|
|
140
|
+
|
|
141
|
+
Production rejects: missing ledger, missing artifact store, required missing ports, stub services without opt-in, in-memory operational fallback presented as prod, unknown step kinds, invalid definitions.
|
|
142
|
+
|
|
143
|
+
Development stubs require explicit opt-in.
|
|
144
|
+
|
|
145
|
+
### At-least-once execution
|
|
146
|
+
|
|
147
|
+
A mutating step may be attempted again. Services and mutation ports must be idempotent. A successful external effect may occur before the runtime sees the response — retries must not create duplicate records, links, or external actions.
|
|
148
|
+
|
|
149
|
+
### Idempotency
|
|
150
|
+
|
|
151
|
+
| Concern | Mechanism |
|
|
152
|
+
|---|---|
|
|
153
|
+
| Memory pulls | Cursor + content-hash dedup |
|
|
154
|
+
| Raw persistence | Content hash / absent-or-revision |
|
|
155
|
+
| Record writes | Precondition + idempotency key |
|
|
156
|
+
| Relationship writes | Deterministic `relationshipId` |
|
|
157
|
+
| Mapping | Pure replay |
|
|
158
|
+
| Analysis / decision / narrative writes | Discriminator + revision / key |
|
|
159
|
+
| External actions | Mandatory key + receipt reuse |
|
|
160
|
+
| AI jobs | Captured input; one accepted mutation |
|
|
161
|
+
| Batch items | Per-item status (`already_applied`) |
|
|
162
|
+
| Artifacts | Content hash |
|
|
163
|
+
|
|
164
|
+
Mutating step kinds include: `persist-raw`, `write-record`, `relationship-write`, `workflow`, `narrative`. These require `idempotencyKeyExpr`.
|
|
165
|
+
|
|
166
|
+
### Retry
|
|
167
|
+
|
|
168
|
+
Default policy: `maxAttempts: 3`, `backoffMs: 1000`, `backoffMultiplier: 2`, `maxBackoffMs: 60000`.
|
|
169
|
+
|
|
170
|
+
Classify errors as retryable vs terminal. Support automatic retry, manual retry of one failed step, and retry of failed batch items only. Each attempt is recorded.
|
|
171
|
+
|
|
172
|
+
### Resume
|
|
173
|
+
|
|
174
|
+
If the runtime process stops, the durable ledger determines completed steps. Succeeded upstream work is not rerun unnecessarily. Failed/incomplete work resumes with captured context and stable artifact references.
|
|
175
|
+
|
|
176
|
+
### Partial success
|
|
177
|
+
|
|
178
|
+
Examples: record write succeeded + relationship write failed; valid batch items + invalid items. Per-item ledger; retry failed portion only; final run status may be `partial`; artifact holds the partial manifest.
|
|
179
|
+
|
|
180
|
+
### Atomicity
|
|
181
|
+
|
|
182
|
+
Default: **no** global pipeline transaction. Successful prior steps remain successful. Atomic batch is opt-in only when supported — otherwise rejected before execution. Do not claim cross-service global atomicity.
|
|
183
|
+
|
|
184
|
+
### Cancellation
|
|
185
|
+
|
|
186
|
+
Cancel queued work or active attempts. Respect remote-service limits. If an external side effect may already have occurred, record uncertainty honestly. Retain artifacts per retention policy.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## From: Building Pipelines — 4. Step types, one by one
|
|
191
|
+
|
|
192
|
+
Registered `StepKind` values:
|
|
193
|
+
|
|
194
|
+
`memory-pull` · `persist-raw` · `map-normalize` · `validate` · `identity-dedupe` · `write-record` · `relationship-discover` · `relationship-write` · `compose` · `verify` · `workflow` · `enrich` · `analyze` · `decide` · `narrative`
|
|
195
|
+
|
|
196
|
+
Behavioral steps may reference `serviceId` for custom/AI work. Generic invoke is expressed through these kinds (and pack-level `invoke-service` where metadata uses that authoring alias) — not a second runtime.
|
|
197
|
+
|
|
198
|
+
### 4.1 `memory-pull`
|
|
199
|
+
|
|
200
|
+
**Purpose:** Invoke one configured Memory source.
|
|
201
|
+
|
|
202
|
+
Cover: scheduled/on-demand, knowledge vs context mode, `sourceId`, workRef, cursor, pull/run reference, quarantine, context expiry, dedup, exact raw payload. Credentials via `credentialRef` only.
|
|
203
|
+
|
|
204
|
+
Memory owns raw landing end-to-end for the pull; `persist-raw` is used when the graph needs an explicit handoff step in front of later ports — do not document two competing “ways to land raw.”
|
|
205
|
+
|
|
206
|
+
**Ops:** Pull procedures from `ops-source` into `g12ops*`; land raw for **PROC-2**.
|
|
207
|
+
|
|
208
|
+
### 4.2 `persist-raw`
|
|
209
|
+
|
|
210
|
+
**Purpose:** Persist normalized Memory handoff as `<objectType>-raw` with exact provider `.data`, provenance, absent/revision behavior, dedup hash, directory registration — when the plan separates pull from persist.
|
|
211
|
+
|
|
212
|
+
**Anti-pattern:** Decorating raw `.data` or promoting to snapshot inside this step.
|
|
213
|
+
|
|
214
|
+
### 4.3 `map-normalize`
|
|
215
|
+
|
|
216
|
+
**Purpose:** Execute the shared mapping AST (`@x12i/memorix-mapping`).
|
|
217
|
+
|
|
218
|
+
Source mapping, registered transforms, no arbitrary JavaScript, no I/O, deterministic replay. Mapping errors are structured. Prefer this over inventing a service for renames/shapes.
|
|
219
|
+
|
|
220
|
+
### 4.4 `validate`
|
|
221
|
+
|
|
222
|
+
**Purpose:** Validate data/drafts/contracts.
|
|
223
|
+
|
|
224
|
+
Distinguish V2 format validation, metadata validation, mapping output validation, service output validation, and domain validation services. Output structured errors — not message-only failures.
|
|
225
|
+
|
|
226
|
+
### 4.5 `identity-dedupe`
|
|
227
|
+
|
|
228
|
+
**Purpose:** Establish or resolve identity safely.
|
|
229
|
+
|
|
230
|
+
`recordId`, external identifiers, record directory, Memory content hash, duplicate identity conflict, semantic duplicate *candidates*. No silent merge. No invented record IDs.
|
|
231
|
+
|
|
232
|
+
### 4.6 `write-record`
|
|
233
|
+
|
|
234
|
+
**Purpose:** Canonical writer — `add` | `upsert` | `patch` | `replace` | `remove`.
|
|
235
|
+
|
|
236
|
+
Absent/revision preconditions, discriminator addressing, lifecycle, stale conflicts, directory behavior, idempotency, partial batch writes. This is how drafts become stored subject content.
|
|
237
|
+
|
|
238
|
+
### 4.7 `relationship-discover`
|
|
239
|
+
|
|
240
|
+
**Purpose:** Compile/evaluate relationship metadata and calculate expected candidates.
|
|
241
|
+
|
|
242
|
+
Abstract endpoint unions, deterministic operators, registered resolvers, provider raw references, bounded discovery plans, dry-run, diagnostics. Discovery-only does not mutate links.
|
|
243
|
+
|
|
244
|
+
### 4.8 `relationship-write`
|
|
245
|
+
|
|
246
|
+
**Purpose:** Materialize candidates through the relationship engine.
|
|
247
|
+
|
|
248
|
+
Deterministic `relationshipId`, four-field link, idempotent writes, category routing, stale-link removal where required. No copied payload. No manual arbitrary links. Partial failure/retry supported.
|
|
249
|
+
|
|
250
|
+
### 4.9 `compose`
|
|
251
|
+
|
|
252
|
+
**Purpose:** Retrieve selected sibling content for one `recordId`.
|
|
253
|
+
|
|
254
|
+
Selected content types, arrays per type, discriminated instances. No flattening. No relationship definition. Prefer captured composition for retry-sensitive downstream AI/analysis.
|
|
255
|
+
|
|
256
|
+
### 4.10 `enrich`
|
|
257
|
+
|
|
258
|
+
**Purpose:** Deterministic or service-based enrichment.
|
|
259
|
+
|
|
260
|
+
Preferred flow: capture → service/mapping → validate → `write-record`. Do not hide uncontrolled persistence inside enrich.
|
|
261
|
+
|
|
262
|
+
**Ops:** Enrich **WI-100** priority via `ops-completion` / enrich service.
|
|
263
|
+
|
|
264
|
+
### 4.11 `analyze`
|
|
265
|
+
|
|
266
|
+
**Purpose:** Produce analysis content/artifacts.
|
|
267
|
+
|
|
268
|
+
Captured context, deterministic or AI service, required `analysisType` discriminator, output validation, DataRef, sibling V2 persistence through writer, repeated-run idempotency.
|
|
269
|
+
|
|
270
|
+
### 4.12 `decide`
|
|
271
|
+
|
|
272
|
+
**Purpose:** Produce decision/recommendation content with `decisionType`.
|
|
273
|
+
|
|
274
|
+
Consume analysis inputs; keep rationale as domain content where appropriate; operational provenance separate. A decision does **not** perform an external action — that is a later action service step.
|
|
275
|
+
|
|
276
|
+
### 4.13 `narrative`
|
|
277
|
+
|
|
278
|
+
**Purpose:** Produce narrative content or artifact.
|
|
279
|
+
|
|
280
|
+
Current/captured context, relationship expansion, deterministic/AI service, validation, content versus artifact. No legacy narrative mutation path. Mutating when it persists — requires idempotency key.
|
|
281
|
+
|
|
282
|
+
### 4.14 `workflow`
|
|
283
|
+
|
|
284
|
+
**Purpose:** Read/update workflow sibling content or invoke workflow actions.
|
|
285
|
+
|
|
286
|
+
Exact revision, composition, workflow action service, state transition, retries. No separate workflow persistence model.
|
|
287
|
+
|
|
288
|
+
### 4.15 `verify`
|
|
289
|
+
|
|
290
|
+
**Purpose:** Explicit verification — relationship verify, data/directory checks, output postconditions — selected by configuration. Do not use one vague verify to hide unrelated behaviors.
|
|
291
|
+
|
|
292
|
+
### External actions and intelligence
|
|
293
|
+
|
|
294
|
+
External actions are **service invocations** (action role) from enrich/workflow/generic service steps with declared side effects — not a separate hidden step kind unless your pack aliases one. Structural intelligence is a service/pipeline pattern: deterministic profiling first, proposal artifacts, optional AI, **no** metadata auto-install, **no** data/link mutation inside the proposal step.
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## From: Building Pipelines — 13. Complete ops tutorial
|
|
299
|
+
|
|
300
|
+
End-to-end non-cyber drill. Use a **fresh** `g12ops*` org every acceptance run.
|
|
301
|
+
|
|
302
|
+
1. **Define procedure source** in ops metadata (`ops-source`).
|
|
303
|
+
2. **Define connector** (Memory collect; `credentialRef` only).
|
|
304
|
+
3. **Define knowledge-ingestion pipeline** (`memory-pull` → raw → map → validate → write → relationships).
|
|
305
|
+
4. **Pull procedures**; confirm raw for **PROC-2**.
|
|
306
|
+
5. **Inspect raw** in Explore / data API (`procedures-raw`).
|
|
307
|
+
6. **Promote** selected procedure snapshot via map/validate/`write-record` — never automatic.
|
|
308
|
+
7. **Pull work-item context** for **WI-100** (context mode as configured).
|
|
309
|
+
8. **Normalize** employee/contractor data (mapping and/or normalize service).
|
|
310
|
+
9. **List People** abstract (employees + contractors including **Alex**).
|
|
311
|
+
10. **Materialize assignments** (relationship discover + write).
|
|
312
|
+
11. **Create work-item ↔ procedure relationship** (WI-100 ↔ PROC-2).
|
|
313
|
+
12. **Run enrichment** (priority completion / enrich service).
|
|
314
|
+
13. **Produce analysis** (`analyze` + `analysisType`).
|
|
315
|
+
14. **Produce decision** (`decide` + `decisionType`).
|
|
316
|
+
15. **Generate narrative** (recorded AI adapter acceptable).
|
|
317
|
+
16. **Update workflow** sibling with exact revision.
|
|
318
|
+
17. **Trigger controlled relationship failure** (e.g. break a definition temporarily).
|
|
319
|
+
18. **Retry relationship step only**; confirm records not duplicated.
|
|
320
|
+
19. **Restart runtime** during another run.
|
|
321
|
+
20. **Resume** without repeating completed work.
|
|
322
|
+
21. **Inspect captured context** artifacts vs current data.
|
|
323
|
+
22. **Inspect artifacts** (hashes, sizes, step association).
|
|
324
|
+
23. **Inspect final records/links** in Explore — four-field links, no copied payloads.
|
|
325
|
+
24. **Run scheduled** invocation; confirm schedule history.
|
|
326
|
+
25. **Run on-demand** invocation with explicit input; confirm distinct `runId`.
|
|
327
|
+
|
|
328
|
+
Tutorial companion narrative: [documentation/tutorials/04-memory-and-pipeline.md](../../../documentation/tutorials/04-memory-and-pipeline.md).
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## Also see
|
|
333
|
+
|
|
334
|
+
- **Building Services** (`07-services`) — When to build a service, handlers, pipeline invoke, and core-service / ports-manager / api-live-view.
|
|
335
|
+
- **Agent Packs & Ops** (`11-agent-packs-and-ops`) — Pack layout, harness, g12ops* acceptance, custom kinds, golden V2 validation.
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
_Generated use-case pack for agents and humans. See `agent-manifest.json` for discovery._
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
# Build a service Memorix pipelines invoke
|
|
2
|
+
|
|
3
|
+
> **Use case id:** `build-callable-service`
|
|
4
|
+
> **Goal:** Decide you need a service, define it, implement handlers, bind, and invoke from a step.
|
|
5
|
+
> **Audiences:** developers
|
|
6
|
+
> **Tags:** services, pipelines
|
|
7
|
+
|
|
8
|
+
## Reading path
|
|
9
|
+
|
|
10
|
+
1. **Building Services** (developers) → chapters: `1-do-i-need-a-service`, `2-one-model-roles-catalog`, `3-define-the-service`, `4-implement-the-handler`, `7-invoke-from-a-pipeline`
|
|
11
|
+
|
|
12
|
+
## From: Building Services — 1. Do I need a service?
|
|
13
|
+
|
|
14
|
+
### Decision guide
|
|
15
|
+
|
|
16
|
+
| Prefer | When |
|
|
17
|
+
|---|---|
|
|
18
|
+
| **Mapping** (`@x12i/memorix-mapping`) | Pure deterministic field transform; no I/O; expressible in the shared AST |
|
|
19
|
+
| **Memory** (`@x12i/memorix-memory`) | External source material must land exact raw first (`*-raw`) |
|
|
20
|
+
| **Relationship metadata** | Connecting different `recordId`s with deterministic rules/operators |
|
|
21
|
+
| **Composition** | Same `recordId`, different content types (siblings) |
|
|
22
|
+
| **Pipeline** | Ordered, scheduled, retryable, multi-step work with run evidence |
|
|
23
|
+
| **Service** | Custom code, remote I/O, specialized compute, reusable external action, or model execution |
|
|
24
|
+
|
|
25
|
+
### Decision tree
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
Is it a pure deterministic field transformation?
|
|
29
|
+
├─ Yes → mapping (@x12i/memorix-mapping)
|
|
30
|
+
└─ No
|
|
31
|
+
|
|
32
|
+
Is it external source material that must land raw?
|
|
33
|
+
├─ Yes → Memory source + connector (collect role)
|
|
34
|
+
└─ No
|
|
35
|
+
|
|
36
|
+
Is it connecting different recordIds?
|
|
37
|
+
├─ Expressible by metadata rules → relationship engine
|
|
38
|
+
├─ Needs custom resolution → resolver service + relationship engine
|
|
39
|
+
└─ Same recordId → composition (siblings), not a relationship service
|
|
40
|
+
|
|
41
|
+
Is it several ordered / retryable operations?
|
|
42
|
+
├─ Yes → pipeline (may invoke services as steps)
|
|
43
|
+
└─ No
|
|
44
|
+
|
|
45
|
+
Does it require custom computation, I/O, or AI?
|
|
46
|
+
└─ Service
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
See also [diagrams/decision-tree.md](../diagrams/decision-tree.md).
|
|
50
|
+
|
|
51
|
+
### Things that are not services
|
|
52
|
+
|
|
53
|
+
Object types, content types, mappings, abstract bindings, relationship definitions, schedules, pipelines, workflow content, the record writer/reader, the relationship store, the artifact store, and the metadata catalog are **platform surfaces**. A service may *use* them through canonical contracts; it must not reimplement them.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## From: Building Services — 2. One model — roles catalog
|
|
58
|
+
|
|
59
|
+
Service “types” are **roles** (capabilities) on one model. A single service declares one or more capabilities; pipelines and operators still see one `serviceId`.
|
|
60
|
+
|
|
61
|
+
| Role | Capability examples | Purpose |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| **Collect** | `collect`, `connector`, `source-pull` | Read material from an external source for Memory |
|
|
64
|
+
| **Enrich** | `enrich`, `normalize`, `completion`, `lookup` | Compute or fetch additional information for an existing subject |
|
|
65
|
+
| **Resolve** | `resolve`, `identity`, `dedupe`, `relationship-candidates` | Produce identity or relationship *candidates* — engine writes links |
|
|
66
|
+
| **Action** | `action`, `notify`, `external-command`, `workflow-action` | Deliberate external side effect with idempotency |
|
|
67
|
+
| **AI job** | `ai`, `extract`, `classify`, `summarize`, `narrative`, `analyze` | Model call behind the single AI adapter |
|
|
68
|
+
|
|
69
|
+
Ops-pack examples use capabilities such as `normalize` and `completion` on services `ops-normalize` and `ops-completion` — same model, different roles.
|
|
70
|
+
|
|
71
|
+
### Side-effect classifications
|
|
72
|
+
|
|
73
|
+
| Classification | Retry safe? | Idempotency key | Typical evidence |
|
|
74
|
+
|---|---|---|---|
|
|
75
|
+
| Pure / read-only | Yes | Optional | Input/output hashes |
|
|
76
|
+
| External read | Usually yes | Recommended | Source receipt, cursor |
|
|
77
|
+
| Deterministic computation | Yes | Optional | Output artifact |
|
|
78
|
+
| Platform draft producer | Yes (draft only) | Recommended | Draft + validation result |
|
|
79
|
+
| External action | Only with key | **Mandatory** | External receipt |
|
|
80
|
+
| AI / model call | Re-callable; output may differ | Capture input; one accepted write | Request/response artifacts |
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## From: Building Services — 3. Define the service
|
|
85
|
+
|
|
86
|
+
### Metadata shape
|
|
87
|
+
|
|
88
|
+
Exact logical contract (`ServiceDefinition` in `@x12i/memorix-metadata`):
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
type ServiceIoPort = {
|
|
92
|
+
id: string;
|
|
93
|
+
schemaRef?: string; // logical schema reference — not a runtime payload
|
|
94
|
+
description?: string;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
type ServiceInvocation = {
|
|
98
|
+
kind: "http" | "worker" | "internal";
|
|
99
|
+
operation?: string;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
type ServiceDefinition = {
|
|
103
|
+
id: string;
|
|
104
|
+
name: string;
|
|
105
|
+
description?: string;
|
|
106
|
+
capabilities: string[];
|
|
107
|
+
inputs?: ServiceIoPort[];
|
|
108
|
+
outputs?: ServiceIoPort[];
|
|
109
|
+
invocation?: ServiceInvocation;
|
|
110
|
+
};
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Example — enrich WI-100 with an external priority scorer:
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"id": "ops-wi-priority-enrich",
|
|
118
|
+
"name": "Work-item priority enricher",
|
|
119
|
+
"description": "Returns a patch plan for work-item snapshot priority from an external scorer",
|
|
120
|
+
"capabilities": ["enrich", "lookup"],
|
|
121
|
+
"inputs": [
|
|
122
|
+
{ "id": "snapshot", "schemaRef": "memorix-record/snapshots" }
|
|
123
|
+
],
|
|
124
|
+
"outputs": [
|
|
125
|
+
{ "id": "patch-plan", "schemaRef": "memorix-patch-plan/1" }
|
|
126
|
+
],
|
|
127
|
+
"invocation": { "kind": "worker", "operation": "enrichPriority" }
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Identity rules
|
|
132
|
+
|
|
133
|
+
- Stable `id` is the logical name pipelines reference (`serviceId`).
|
|
134
|
+
- Agent ownership and inheritance follow the same multi-agent resolution as other kinds.
|
|
135
|
+
- Child agents may replace a service definition; unrelated agents must not silently collide.
|
|
136
|
+
- Service ID is **not** an endpoint URL.
|
|
137
|
+
- Metadata has no mutable runtime state; build/version belongs in run evidence.
|
|
138
|
+
|
|
139
|
+
### Input contract
|
|
140
|
+
|
|
141
|
+
Prefer references over copying large records into pipeline definitions or ledgers:
|
|
142
|
+
|
|
143
|
+
| Form | Use when |
|
|
144
|
+
|---|---|
|
|
145
|
+
| Small inline JSON | Tiny control values |
|
|
146
|
+
| DataRef / artifact | Large payloads, batches, model responses |
|
|
147
|
+
| Concrete record reference | Address by `(objectType, contentType, recordId)` + revision |
|
|
148
|
+
| Abstract projection reference | Read through virtual union (People), write concrete later |
|
|
149
|
+
| Captured context reference | Exact revision frozen for the run |
|
|
150
|
+
| Source / pull reference | Memory work |
|
|
151
|
+
| Relationship definition reference | Resolver / discovery helpers |
|
|
152
|
+
| Batch reference | Per-item manifests |
|
|
153
|
+
|
|
154
|
+
Every input is schema-validated. Prefer captured revisions for retry-sensitive work.
|
|
155
|
+
|
|
156
|
+
### Output contract
|
|
157
|
+
|
|
158
|
+
| Form | Meaning |
|
|
159
|
+
|---|---|
|
|
160
|
+
| Inline result | Small structured result |
|
|
161
|
+
| Artifact / DataRef | Large or binary output |
|
|
162
|
+
| Record draft / patch plan | Candidate content — **not** yet stored |
|
|
163
|
+
| Validation / mapping result | Structured issues |
|
|
164
|
+
| Relationship candidate result | Candidates for the relationship engine |
|
|
165
|
+
| Analysis / decision / narrative draft | Sibling content drafts with discriminators |
|
|
166
|
+
| External-action receipt | Proof of side effect |
|
|
167
|
+
| Diagnostics / metrics | Operational only |
|
|
168
|
+
| Retryable / non-retryable error | Machine-readable codes |
|
|
169
|
+
|
|
170
|
+
A service output is **not** automatically persisted as subject content. The pipeline validates and persists through canonical ports.
|
|
171
|
+
|
|
172
|
+
Forbidden in metadata: secret values, deployment URLs as identity, fake “always succeed” stubs presented as production contracts.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## From: Building Services — 4. Implement the handler
|
|
177
|
+
|
|
178
|
+
### Lifecycle
|
|
179
|
+
|
|
180
|
+
1. Identify the capability.
|
|
181
|
+
2. Confirm it should be a service (decision guide).
|
|
182
|
+
3. Select roles / capabilities.
|
|
183
|
+
4. Define input/output schemas in pack metadata (`ServiceDefinition`).
|
|
184
|
+
5. Declare side effects and errors.
|
|
185
|
+
6. Implement a **`PortHandler`** for the canonical pipeline **`StepKind`** that will run the work (usually `enrich` / `analyze` / `decide` / `narrative`).
|
|
186
|
+
7. Register a runtime **`ServiceRef`** (`serviceId` + `kind`) — from pack bridge, pipeline `services[]`, or env defaults.
|
|
187
|
+
8. Add service metadata to the agent pack (`ops`) as `services[]` with pack field `id`.
|
|
188
|
+
9. Reference it from a pipeline step: `stepKind` selects the handler; optional `serviceId` must resolve in the registry.
|
|
189
|
+
10. Validate / install metadata.
|
|
190
|
+
11. Run conformance tests.
|
|
191
|
+
12. Deploy; execute through the pipeline; observe runs / attempts / artifacts.
|
|
192
|
+
|
|
193
|
+
### Real invocation contract (pipeline v2)
|
|
194
|
+
|
|
195
|
+
Handlers are **not** free-standing “service handlers.” They are **step-kind port handlers**:
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
type StepKind =
|
|
199
|
+
| "memory-pull" | "persist-raw" | "map-normalize" | "validate"
|
|
200
|
+
| "identity-dedupe" | "write-record" | "relationship-discover"
|
|
201
|
+
| "relationship-write" | "compose" | "verify" | "workflow"
|
|
202
|
+
| "enrich" | "analyze" | "decide" | "narrative";
|
|
203
|
+
|
|
204
|
+
type StepExecutionRequest = {
|
|
205
|
+
scope: { orgId: string; agentIds: string[] };
|
|
206
|
+
runId: string;
|
|
207
|
+
stepId: string;
|
|
208
|
+
attempt: number;
|
|
209
|
+
stepType: StepKind;
|
|
210
|
+
idempotencyKey?: string;
|
|
211
|
+
deadline?: string;
|
|
212
|
+
inputs: Record<string, unknown>;
|
|
213
|
+
capturedContextRef?: /* DataRef */;
|
|
214
|
+
config?: unknown; // from step.portConfig
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
type StepExecutionResult = {
|
|
218
|
+
status: "succeeded" | "failed" | "partial";
|
|
219
|
+
output?: unknown;
|
|
220
|
+
itemOutcomes?: /* BatchItemOutcome[] */;
|
|
221
|
+
diagnostics?: Record<string, unknown>;
|
|
222
|
+
mutationRefs?: unknown[];
|
|
223
|
+
retryable?: boolean; // failed + retryable ≈ safe to attempt again
|
|
224
|
+
error?: { code: string; message: string };
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
type PortHandler = (req: StepExecutionRequest) => Promise<StepExecutionResult>;
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Package: `@x12i/memorix-pipeline` (`createLivePortRegistry`, `createPortInvoker`, `createServiceRegistry`).
|
|
231
|
+
|
|
232
|
+
**Critical:** `serviceId` on a step does **not** select which function runs. Execution is always:
|
|
233
|
+
|
|
234
|
+
```text
|
|
235
|
+
step.stepKind → PortRegistry[stepKind] → PortHandler(req)
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
If `step.serviceId` is set, the runtime **resolves** that id in the service registry (fail closed if missing), then still invokes the **stepKind** port.
|
|
239
|
+
|
|
240
|
+
Do not invent private Mongo handles. Use the adapters the live port registry already wires (`@x12i/memorix-data`, relationships, Memory).
|
|
241
|
+
|
|
242
|
+
### Result contract
|
|
243
|
+
|
|
244
|
+
Every result is machine-readable — callers must not parse free-text messages:
|
|
245
|
+
|
|
246
|
+
| `status` | Meaning |
|
|
247
|
+
|---|---|
|
|
248
|
+
| `succeeded` | Full success |
|
|
249
|
+
| `partial` | Batch: some items ok (`itemOutcomes`) |
|
|
250
|
+
| `failed` | Failure — set `retryable: true` when safe to attempt again; omit or `false` when terminal |
|
|
251
|
+
|
|
252
|
+
Timeouts, cancellations, and skips are expressed as `failed` (+ diagnostics / error codes) or by the pipeline runtime — there is no separate port-status enum for `timed_out` / `cancelled` / `skipped`.
|
|
253
|
+
|
|
254
|
+
### Pack definition versus runtime binding
|
|
255
|
+
|
|
256
|
+
| Layer | Shape | Role |
|
|
257
|
+
|---|---|---|
|
|
258
|
+
| Pack metadata | `ServiceDefinition`: `{ id, name, capabilities, inputs?, outputs?, invocation? }` | Declarative catalog (`services[]` in agent pack) |
|
|
259
|
+
| Runtime registry | `ServiceRef`: `{ serviceId, kind, endpoint?, credentialRef?, … }` | Deploy binding |
|
|
260
|
+
| Bridge | `servicesFromMetadata` | Maps pack `id` → `serviceId`, `invocation.kind` → `kind` (default `internal`) |
|
|
261
|
+
|
|
262
|
+
```ts
|
|
263
|
+
// Pack (ops-pack metadata/services.json)
|
|
264
|
+
{ id: "ops-enrich-priority", capabilities: ["enrich"], invocation: { kind: "worker" } }
|
|
265
|
+
|
|
266
|
+
// Runtime after bridge
|
|
267
|
+
{ serviceId: "ops-enrich-priority", kind: "worker", capabilities: ["enrich"] }
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### In-process versus remote
|
|
271
|
+
|
|
272
|
+
| | In-process | Remote |
|
|
273
|
+
|---|---|---|
|
|
274
|
+
| Use when | Trusted, low-latency, deterministic platform code | Separate process, vendor API, isolation |
|
|
275
|
+
| Binding | Live `PortHandler` on the step kind + `ServiceRef` | `ServiceRef.endpoint` + HTTP worker process |
|
|
276
|
+
| Credentials | `credentialRef` → runtime vault | Same — never in metadata |
|
|
277
|
+
| Large I/O | DataRef / artifacts | Same |
|
|
278
|
+
| Failure | Process-local errors → attempt ledger | Unavailable → `failed` + `retryable`; missing binding → fail closed in prod |
|
|
279
|
+
|
|
280
|
+
Helper `createServiceInvokePorts().invokeRemote` POSTs `JSON.stringify(req.inputs)` to `endpoint` and expects HTTP 200 + JSON. It is **not** a first-class `StepKind` — wire it from a custom `enrich`/`analyze`/… port when you need remote dispatch. Prefer `@x12i/core-service` on the worker process (see HTTP process compliance below).
|
|
281
|
+
|
|
282
|
+
Production rejects missing bindings and silent stub handlers. Development stubs require **explicit** opt-in (`mode: "dev"` + `allowStubPorts: true`) and clear labeling.
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## From: Building Services — 7. Invoke from a pipeline
|
|
287
|
+
|
|
288
|
+
Preferred split:
|
|
289
|
+
|
|
290
|
+
```text
|
|
291
|
+
read / capture
|
|
292
|
+
→ StepKind port (enrich / analyze / …) [optional serviceId resolve]
|
|
293
|
+
→ validate result
|
|
294
|
+
→ write-record or relationship-write
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Avoid a service that hides computation and persistence in one opaque call. External-action services are the exception — the side effect is their declared purpose.
|
|
298
|
+
|
|
299
|
+
### Adding a service to a pipeline (ops recipe)
|
|
300
|
+
|
|
301
|
+
1. Add `services[]` entry to the agent pack (`id`, `capabilities`, `invocation`) — see `memorix-ops-pack/metadata/services.json` (`ops-enrich-priority`).
|
|
302
|
+
2. Install / resolve effective metadata for `g12ops*` + `agentIds: ["ops"]`.
|
|
303
|
+
3. Bridge pack services → `ServiceRef`s (`servicesFromMetadata`) when constructing the pipeline runtime.
|
|
304
|
+
4. Implement or override the **`enrich`** (or other) live port so the handler returns a **draft / patch plan**, not a silent Mongo write.
|
|
305
|
+
5. Author a v2 pipeline step:
|
|
306
|
+
```ts
|
|
307
|
+
{
|
|
308
|
+
stepId: "enrich",
|
|
309
|
+
stepKind: "enrich", // selects PortHandler
|
|
310
|
+
serviceId: "ops-enrich-priority", // must resolve in registry
|
|
311
|
+
portConfig: { /* optional */ },
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
Pack authoring may use the same `serviceId` with kind `enrich` (see `ops-enrich-priority` pipeline in ops-pack). Pack kinds are not always identical to v2 `StepKind` — the platform compile/bind path must produce a valid v2 definition.
|
|
315
|
+
6. Add a separate mutation step (`write-record` / `relationship-write`) that applies the draft with revision preconditions.
|
|
316
|
+
7. Start the run; inspect `/api/pipelines` attempts and artifacts (or Studio Operate).
|
|
317
|
+
|
|
318
|
+
There is **no** v2 `StepKind` named `invoke-service`. Older pack sketches that used `kind: "invoke-service"` are not executable until rewritten to a canonical step kind.
|
|
319
|
+
|
|
320
|
+
### Partial batches
|
|
321
|
+
|
|
322
|
+
- Per-item input and per-item success/failure.
|
|
323
|
+
- Retry only failed items.
|
|
324
|
+
- No false global atomicity unless a port explicitly declares atomic batch support.
|
|
325
|
+
- Output artifact holds the partial manifest.
|
|
326
|
+
|
|
327
|
+
### Retry matrix (summary)
|
|
328
|
+
|
|
329
|
+
| Kind | Repeat same invocation? |
|
|
330
|
+
|---|---|
|
|
331
|
+
| Pure calculation | Yes |
|
|
332
|
+
| External read | Yes (watch rate limits / cursors) |
|
|
333
|
+
| Enrichment draft | Yes; one accepted write |
|
|
334
|
+
| AI call | Yes; outputs may differ; capture input; one accepted mutation |
|
|
335
|
+
| External action | Only with idempotency key + receipt reuse |
|
|
336
|
+
| Relationship candidates | Yes; engine write remains idempotent |
|
|
337
|
+
| Artifact processing | Yes if content-addressed |
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
## Also see
|
|
342
|
+
|
|
343
|
+
- **Building Pipelines** (`08-pipelines`) — Pipeline definition, step kinds, AI fail-closed, operations, and the complete ops tutorial.
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
_Generated use-case pack for agents and humans. See `agent-manifest.json` for discovery._
|