@x12i/memorix-docs 1.0.1 → 1.1.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.
- package/dist/generated/bundle.d.ts +4849 -3
- package/dist/generated/bundle.d.ts.map +1 -1
- package/dist/generated/bundle.js +7582 -47
- 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 +5 -4
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# Learn the memorix-record/2 envelope
|
|
2
|
+
|
|
3
|
+
> **Use case id:** `learn-record-envelope`
|
|
4
|
+
> **Goal:** Internalize OT/CT, composition, discriminators, and what must not live on the record.
|
|
5
|
+
> **Audiences:** developers
|
|
6
|
+
> **Tags:** format, record
|
|
7
|
+
|
|
8
|
+
## Reading path
|
|
9
|
+
|
|
10
|
+
1. **Format for Dummies** (developers) → chapters: `2-anatomy-of-memorix-record-2`, `4-object-type-content-type-and-data-category`, `9-composition-same-subject-different-content`, `10-discriminated-content-instances`, `12-relationships-are-not-record-content`
|
|
11
|
+
|
|
12
|
+
## From: Format for Dummies — 2. Anatomy of `memorix-record/2`
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"format": "memorix-record/2",
|
|
17
|
+
"recordId": "WI-100",
|
|
18
|
+
"revision": 1,
|
|
19
|
+
"objectType": "work-items",
|
|
20
|
+
"contentType": "snapshots",
|
|
21
|
+
"dataCategory": "entity",
|
|
22
|
+
"concept": {},
|
|
23
|
+
"data": {},
|
|
24
|
+
"_system": {}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
*(The empty `{}` above are illustration only — real records must not ship empty optional buckets.)*
|
|
29
|
+
|
|
30
|
+
| Root | Meaning |
|
|
31
|
+
|---|---|
|
|
32
|
+
| `format` | Must be exactly `"memorix-record/2"`. |
|
|
33
|
+
| `recordId` | Stable subject identity (org-wide). |
|
|
34
|
+
| `revision` | Integer ≥ 1 for *this* content instance; starts at 1. |
|
|
35
|
+
| `objectType` | Concrete subject type (`work-items`, `employees`, …). |
|
|
36
|
+
| `contentType` | Kind of content (`snapshots`, `raw`, `workflow`, …). |
|
|
37
|
+
| `dataCategory` | Data universe: `entity` \| `event` \| `knowledge`. |
|
|
38
|
+
| `concept` | Stable identifying / business-facing info (title + identifiers). |
|
|
39
|
+
| `data` | Content-type-specific payload. |
|
|
40
|
+
| `_system` | Machine state, timestamps, optional lifecycle & provenance. |
|
|
41
|
+
|
|
42
|
+
**Also allowed (narrowly):**
|
|
43
|
+
|
|
44
|
+
- Snapshot-like types may carry non-empty `analytics`, `enrichment`, `insights`.
|
|
45
|
+
- Storage-only `_id` may exist; format law ignores it as business identity.
|
|
46
|
+
- Format validation still recognizes lightweight root `associated*` refs (compatibility). Production V2 writers reject *new* root `associated*` writes — authoritative links live in central `relationships` collections.
|
|
47
|
+
|
|
48
|
+
**Rules you will feel every day:**
|
|
49
|
+
|
|
50
|
+
- Unknown root properties are **rejected**.
|
|
51
|
+
- Empty optional buckets are **omitted** — never emit meaningless `{}`.
|
|
52
|
+
- Only `_system` and `_id` underscore roots are allowed on the record.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## From: Format for Dummies — 4. Object type, content type, and data category
|
|
57
|
+
|
|
58
|
+
Explain the three separately — they answer different questions.
|
|
59
|
+
|
|
60
|
+
| Field | Meaning | Example |
|
|
61
|
+
|---|---|---|
|
|
62
|
+
| `objectType` | Concrete subject type | `work-items` |
|
|
63
|
+
| `contentType` | Content about that subject | `snapshots` |
|
|
64
|
+
| `dataCategory` | Database category | `entity` |
|
|
65
|
+
|
|
66
|
+
### Common data categories
|
|
67
|
+
|
|
68
|
+
| Category | Typical subjects |
|
|
69
|
+
|---|---|
|
|
70
|
+
| `entity` | employees, work-items, contractors |
|
|
71
|
+
| `event` | activity-events |
|
|
72
|
+
| `knowledge` | procedures, documents |
|
|
73
|
+
|
|
74
|
+
Operational runs, ledgers, artifacts, and quarantines belong to **operational** storage. They are not ordinary subject content and are not written as `memorix-record/2` subject envelopes.
|
|
75
|
+
|
|
76
|
+
### Common content types
|
|
77
|
+
|
|
78
|
+
`raw` · `snapshots` · `analysis` · `decisions` · `discovery` · `workflow` · `context`
|
|
79
|
+
|
|
80
|
+
Metadata defines which object/content types exist for an agent pack. This list is **not** permanently closed — profiles come from effective metadata (with built-in defaults for well-known types).
|
|
81
|
+
|
|
82
|
+
Physical collection name: `<objectType>-<contentType>`
|
|
83
|
+
Example: `work-items-snapshots` in database `g12opsabc123_entity`.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## From: Format for Dummies — 9. Composition: same subject, different content
|
|
88
|
+
|
|
89
|
+
### Core rule
|
|
90
|
+
|
|
91
|
+
> **Same `recordId` means composition, not a relationship.**
|
|
92
|
+
|
|
93
|
+
### Ops journey example
|
|
94
|
+
|
|
95
|
+
All of these are sibling content about `wi-100`:
|
|
96
|
+
|
|
97
|
+
| Content | Instance |
|
|
98
|
+
|---|---|
|
|
99
|
+
| Snapshot | `wi-100` + `snapshots` |
|
|
100
|
+
| Workflow | `wi-100` + `workflow` |
|
|
101
|
+
| Analysis | `wi-100` + `analysis` + `capacity` |
|
|
102
|
+
| Analysis | `wi-100` + `analysis` + `delivery-risk` |
|
|
103
|
+
| Decision | `wi-100` + `decisions` + `priority` |
|
|
104
|
+
|
|
105
|
+
### Read behavior
|
|
106
|
+
|
|
107
|
+
- Default reads (`getContent`) return **one** requested content instance.
|
|
108
|
+
- Composition must be **explicitly** requested (`composeSubject`).
|
|
109
|
+
- Composed results contain **arrays by content type** (even for singletons).
|
|
110
|
+
- Siblings are **never** flattened into the snapshot.
|
|
111
|
+
- Workflow and context are ordinary sibling content.
|
|
112
|
+
- Composition **never** creates relationship definitions or links.
|
|
113
|
+
|
|
114
|
+
### Composition response shape (virtual)
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"recordId": "wi-100",
|
|
119
|
+
"objectType": "work-items",
|
|
120
|
+
"dataCategory": "entity",
|
|
121
|
+
"contents": {
|
|
122
|
+
"snapshots": [ /* V2 */ ],
|
|
123
|
+
"analysis": [ /* zero or more */ ],
|
|
124
|
+
"decisions": [ /* zero or more */ ],
|
|
125
|
+
"workflow": [ /* V2 */ ]
|
|
126
|
+
},
|
|
127
|
+
"warnings": []
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## From: Format for Dummies — 10. Discriminated content instances
|
|
134
|
+
|
|
135
|
+
### Why some content types have more than one instance
|
|
136
|
+
|
|
137
|
+
Analysis, decisions, and discovery can exist many times per subject (capacity vs delivery-risk; priority vs schedule; …).
|
|
138
|
+
|
|
139
|
+
### Built-in discriminator paths (defaults)
|
|
140
|
+
|
|
141
|
+
| Content type | Path | Default |
|
|
142
|
+
|---|---|---|
|
|
143
|
+
| `analysis` | `data.analysisType` | `"default"` |
|
|
144
|
+
| `decisions` | `data.decisionType` | `"default"` |
|
|
145
|
+
| `discovery` | `data.discoveryType` | `"default"` |
|
|
146
|
+
|
|
147
|
+
Metadata defines path / requiredness / default / allowed values. Defaults are applied and **persisted** before addressing so the record stays self-describing.
|
|
148
|
+
|
|
149
|
+
### Addressing
|
|
150
|
+
|
|
151
|
+
Same `recordId` + `contentType` + discriminator value → one instance.
|
|
152
|
+
|
|
153
|
+
- Discriminator values are **immutable** for an existing instance.
|
|
154
|
+
- Changing the discriminator requires **remove + add**.
|
|
155
|
+
- Each instance has its own revision.
|
|
156
|
+
- Mongo’s deterministic storage key is internal; `recordId` remains the subject.
|
|
157
|
+
|
|
158
|
+
### Two analyses on one work item
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"recordId": "wi-100",
|
|
163
|
+
"contentType": "analysis",
|
|
164
|
+
"data": { "analysisType": "delivery-risk", "risk": "low" }
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
```json
|
|
169
|
+
{
|
|
170
|
+
"recordId": "wi-100",
|
|
171
|
+
"contentType": "analysis",
|
|
172
|
+
"data": { "analysisType": "capacity", "load": "nominal" }
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Validation: missing required discriminator → `V2-DISCRIMINATOR`. Missing with default → warning `V2-DISCRIMINATOR-DEFAULT` (writers apply default).
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## From: Format for Dummies — 12. Relationships are not record content
|
|
181
|
+
|
|
182
|
+
### Core rule
|
|
183
|
+
|
|
184
|
+
> **Different `recordId` values are connected using relationship links.**
|
|
185
|
+
|
|
186
|
+
### Four-field stored link
|
|
187
|
+
|
|
188
|
+
```json
|
|
189
|
+
{
|
|
190
|
+
"relationshipId": "…",
|
|
191
|
+
"relationshipDefinitionId": "people-assigned-to-work-items",
|
|
192
|
+
"fromRecordId": "employee-10",
|
|
193
|
+
"toRecordId": "wi-100"
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
These are the **only** persisted link fields.
|
|
198
|
+
|
|
199
|
+
| Concept | Role |
|
|
200
|
+
|---|---|
|
|
201
|
+
| Relationship **definition** | Metadata (meaning, directionality, path) |
|
|
202
|
+
| Relationship **link** | Data (four fields) |
|
|
203
|
+
|
|
204
|
+
### Rules
|
|
205
|
+
|
|
206
|
+
- Links do not contain copied names, titles, or target records.
|
|
207
|
+
- Links live in centralized per-category `relationships` collections (`g12opsabc123_entity.relationships`, etc.).
|
|
208
|
+
- Forward and inverse traversal query the **same** physical link.
|
|
209
|
+
- Expansion loads **current** target content when requested.
|
|
210
|
+
- Missing targets appear as `unresolved` (calculated) — the link is not deleted.
|
|
211
|
+
- Updating the target changes expansion without changing the link.
|
|
212
|
+
- Relationship history / provenance belongs in operational runs.
|
|
213
|
+
|
|
214
|
+
### Compatibility nuance
|
|
215
|
+
|
|
216
|
+
| Shape | Status |
|
|
217
|
+
|---|---|
|
|
218
|
+
| Lightweight root `associated*` | Format-valid for validation/migration; **not** authoritative storage |
|
|
219
|
+
| Production V2 writers | Reject new root `associated*` writes |
|
|
220
|
+
| Sibling `contentType: "relationships"` | Format-valid profile only; **not** authoritative storage — writers reject it |
|
|
221
|
+
| Nested `.data.associated*` | Valid when it is untouched **provider raw** data |
|
|
222
|
+
|
|
223
|
+
Authoritative storage is the central per-category `relationships` collection (not root `associated*`, not a `contentType: "relationships"` sibling).
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Also see
|
|
228
|
+
|
|
229
|
+
- **Format for Dummies** (`01-format-for-dummies`) — Mental model of the record envelope — OT/CT, composition, discriminators, and what is not stored on the record.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
_Generated use-case pack for agents and humans. See `agent-manifest.json` for discovery._
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# List, filter, and paginate correctly
|
|
2
|
+
|
|
3
|
+
> **Use case id:** `lists-cursors-pagination`
|
|
4
|
+
> **Goal:** Use cursors, pageInfo, and query grammar without inventing offsets.
|
|
5
|
+
> **Audiences:** developers
|
|
6
|
+
> **Tags:** lists, cursor, http
|
|
7
|
+
|
|
8
|
+
## Reading path
|
|
9
|
+
|
|
10
|
+
1. **Lists, Queries, Pagination** (developers) → chapters: `3-common-list-response-pageinfo-contract`, `8-cursor-contract`, `9-pagination-guarantees`, `21-client-side-iteration-patterns`
|
|
11
|
+
|
|
12
|
+
## From: Lists, Queries, Pagination — 3. Common list response / `pageInfo` contract
|
|
13
|
+
|
|
14
|
+
### 3.1 Concrete content page (HTTP)
|
|
15
|
+
|
|
16
|
+
```http
|
|
17
|
+
GET /api/data/content?objectType=work-items&contentType=snapshots&limit=50&cursor=<opaque>
|
|
18
|
+
x-memorix-org-id: g12opsabc123
|
|
19
|
+
x-memorix-agent-ids: ops
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"scope": { "orgId": "g12opsabc123", "agentIds": ["ops"] },
|
|
25
|
+
"addressing": {
|
|
26
|
+
"orgId": "g12opsabc123",
|
|
27
|
+
"objectType": "work-items",
|
|
28
|
+
"contentType": "snapshots",
|
|
29
|
+
"id": null
|
|
30
|
+
},
|
|
31
|
+
"records": [ /* memorix-record/2 … */ ],
|
|
32
|
+
"pageInfo": { "nextCursor": "mrxq1...." },
|
|
33
|
+
"unresolvedRelationships": [],
|
|
34
|
+
"currentRevision": null
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 3.2 Abstract page (HTTP)
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"scope": { "orgId": "g12opsabc123", "agentIds": ["ops"] },
|
|
43
|
+
"abstractType": "People",
|
|
44
|
+
"records": [
|
|
45
|
+
{
|
|
46
|
+
"abstractType": "People",
|
|
47
|
+
"recordId": "employee-10",
|
|
48
|
+
"objectType": "employees",
|
|
49
|
+
"dataCategory": "entity",
|
|
50
|
+
"contentType": "snapshots",
|
|
51
|
+
"properties": { }
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"pageInfo": { "nextCursor": null }
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 3.3 Package-level result
|
|
59
|
+
|
|
60
|
+
Inside `@x12i/memorix-data`, list results use `items` + optional `nextCursor`. HTTP maps that to `records` + `pageInfo.nextCursor` (null when exhausted). Relationship sections expose `items` + `pageInfo: { limit, nextCursor? }`.
|
|
61
|
+
|
|
62
|
+
### 3.4 Clarifications
|
|
63
|
+
|
|
64
|
+
| Situation | Contract |
|
|
65
|
+
|---|---|
|
|
66
|
+
| Empty list | HTTP 200, empty array, `nextCursor` null/omitted |
|
|
67
|
+
| Missing single get | Not-found class error — not an empty list |
|
|
68
|
+
| Totals | **May be absent** even when pagination works — do not require `totalCount` |
|
|
69
|
+
| Relationship pagination | Independent from source-content pagination |
|
|
70
|
+
| Expanded targets | Virtual; never part of stored source |
|
|
71
|
+
| Diagnostics | Related-property and some operational lists may include plan diagnostics |
|
|
72
|
+
|
|
73
|
+
`PageInfo` (OpenAPI): `nextCursor` (string \| null) and optionally `limit`. Do not assume `hasMore`, query-plan dumps, or correlation ids unless the accepted schema includes them.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## From: Lists, Queries, Pagination — 8. Cursor contract
|
|
78
|
+
|
|
79
|
+
Cursors are opaque tokens. Product encoding uses a versioned prefix (e.g. `mrxq1.…`) wrapping a payload that includes:
|
|
80
|
+
|
|
81
|
+
- cursor version + kind (`concrete` | `abstract`)
|
|
82
|
+
- **query shape hash** bound to filters + sort + addressing
|
|
83
|
+
- continuation position (sort values + internal storage key)
|
|
84
|
+
|
|
85
|
+
### 8.1 Public rules
|
|
86
|
+
|
|
87
|
+
| Rule | Why |
|
|
88
|
+
|---|---|
|
|
89
|
+
| Opaque | Clients never parse or mint cursors |
|
|
90
|
+
| Bound to query shape | Changing filters/sort/addressing → `READ_CURSOR_MISMATCH` |
|
|
91
|
+
| Bound to kind | Concrete cursor ≠ abstract cursor |
|
|
92
|
+
| No credentials | Cursor must not carry secrets or unrestricted payloads |
|
|
93
|
+
| Forward continuation | Resume with the **same** query + `nextCursor` |
|
|
94
|
+
| Exhausted | `nextCursor` null/omitted → done |
|
|
95
|
+
|
|
96
|
+
### 8.2 Error matrix
|
|
97
|
+
|
|
98
|
+
| Condition | Code (package) | Client action |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| Malformed / wrong prefix | `READ_CURSOR_INVALID` | Restart query from the beginning |
|
|
101
|
+
| Unsupported version | `READ_CURSOR_INVALID` | Restart; upgrade client expectations |
|
|
102
|
+
| Shape / kind mismatch | `READ_CURSOR_MISMATCH` | Restart with one consistent query |
|
|
103
|
+
| Cursor from another endpoint | mismatch / invalid | Do not reuse across routes |
|
|
104
|
+
| Referring to removed data | Continue or shorten pages | Treat as concurrent mutation (ch. 20) |
|
|
105
|
+
|
|
106
|
+
**When the query shape changes, restart.** Do not “fix” a cursor by editing it.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## From: Lists, Queries, Pagination — 9. Pagination guarantees
|
|
111
|
+
|
|
112
|
+
### 9.1 What is guaranteed
|
|
113
|
+
|
|
114
|
+
- Forward cursor pagination with stable ordering **for a fixed sort + tie-breaker** under quiet data
|
|
115
|
+
- Page size clamped to an accepted max (content lists: default **50**, max **200**)
|
|
116
|
+
- Empty final page signal via null/omitted `nextCursor`
|
|
117
|
+
- Org isolation: another org’s WI-100 never appears in your page
|
|
118
|
+
|
|
119
|
+
### 9.2 What is **not** promised
|
|
120
|
+
|
|
121
|
+
| Question | Honest answer |
|
|
122
|
+
|---|---|
|
|
123
|
+
| Snapshot-isolated pages? | **No** — do not promise snapshot isolation unless a read token exists |
|
|
124
|
+
| Concurrent inserts? | May appear on later pages |
|
|
125
|
+
| Concurrent deletes? | May shorten later pages |
|
|
126
|
+
| Updates to sort fields? | May move an item across boundaries (rare duplicate/gap under change) |
|
|
127
|
+
| Reverse pagination? | Not a public contract |
|
|
128
|
+
| Unlimited cursor TTL? | Do not retain cursors indefinitely; restart if mismatch/expiry occurs |
|
|
129
|
+
| Metadata change mid-abstract-iteration? | Effective union may change with `agentIds[]` / pack updates — restart |
|
|
130
|
+
|
|
131
|
+
### 9.3 Safe client guidance
|
|
132
|
+
|
|
133
|
+
**Stable data:** paginate once; process; optionally re-list with a watermark filter (`_system.modifiedAt` / business field) if metadata allows.
|
|
134
|
+
|
|
135
|
+
**Concurrent data:** design handlers idempotent; prefer keys (`recordId` + `contentType` + discriminator) for side effects; for exports use an operational job (ch. 16) instead of a hours-long cursor walk.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## From: Lists, Queries, Pagination — 21. Client-side iteration patterns
|
|
140
|
+
|
|
141
|
+
### 21.1 Safe page loop (HTTP)
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
async function iterateWorkItemSnapshots(baseUrl: string, headers: HeadersInit) {
|
|
145
|
+
let cursor: string | null = null;
|
|
146
|
+
const filter = encodeURIComponent(
|
|
147
|
+
JSON.stringify([{ field: "data.status", op: "eq", value: "in-progress" }]),
|
|
148
|
+
);
|
|
149
|
+
const sort = encodeURIComponent(
|
|
150
|
+
JSON.stringify([{ field: "recordId", direction: "asc" }]),
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
for (;;) {
|
|
154
|
+
const qs = new URLSearchParams({
|
|
155
|
+
objectType: "work-items",
|
|
156
|
+
contentType: "snapshots",
|
|
157
|
+
limit: "50",
|
|
158
|
+
});
|
|
159
|
+
// Pass filter/sort only when your service build wires them (see OpenAPI).
|
|
160
|
+
qs.set("filter", filter);
|
|
161
|
+
qs.set("sort", sort);
|
|
162
|
+
if (cursor) qs.set("cursor", cursor);
|
|
163
|
+
|
|
164
|
+
const res = await fetch(`${baseUrl}/api/data/content?${qs}`, { headers });
|
|
165
|
+
if (!res.ok) throw new Error(await res.text());
|
|
166
|
+
const body = await res.json();
|
|
167
|
+
|
|
168
|
+
for (const record of body.records ?? []) {
|
|
169
|
+
await handle(record); // idempotent on recordId+revision
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
cursor = body.pageInfo?.nextCursor ?? null;
|
|
173
|
+
if (!cursor) break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### 21.2 Checklist
|
|
179
|
+
|
|
180
|
+
- Preserve the **exact** query between pages
|
|
181
|
+
- On process restart, reuse stored cursor **only** with the same shape; on mismatch, restart
|
|
182
|
+
- Avoid duplicate side effects (upsert by business key / revision)
|
|
183
|
+
- Iterate abstract unions with abstract cursors — do not merge concrete pages yourself unless you reimplement the merge contract
|
|
184
|
+
- Paginate relationships independently from content
|
|
185
|
+
- Prefer export jobs for huge extracts
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Also see
|
|
190
|
+
|
|
191
|
+
- **Runtime Data Client** (`02-runtime-data-client`) — Connection, scope, exact reads, writes, compose, abstracts, and client anti-patterns through Memorix Service / OpenAPI.
|
|
192
|
+
- **Data Access Patterns** (`04-data-access-patterns`) — Decision matrix — best / acceptable / forbidden access methods for real client tasks.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
_Generated use-case pack for agents and humans. See `agent-manifest.json` for discovery._
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Run local acceptance on g12ops*
|
|
2
|
+
|
|
3
|
+
> **Use case id:** `local-acceptance-g12ops`
|
|
4
|
+
> **Goal:** Bring up the stack with ops-pack and prove the ops narrative in an isolated org.
|
|
5
|
+
> **Audiences:** developers
|
|
6
|
+
> **Tags:** acceptance, ops, local
|
|
7
|
+
|
|
8
|
+
## Reading path
|
|
9
|
+
|
|
10
|
+
1. **Platform Overview** (developers) → chapters: `6-the-ops-mental-path-end-to-end`, `7-local-stack-quick-start`
|
|
11
|
+
1. **Agent Packs & Ops** (developers) → chapters: `3-harness-up-down-reset-accept`, `7-install-into-a-fresh-acceptance-org`
|
|
12
|
+
|
|
13
|
+
## From: Platform Overview — 6. The ops mental path end to end
|
|
14
|
+
|
|
15
|
+
1. **Scope** — create/select fresh `g12ops*`, set `agentIds: ["ops"]`.
|
|
16
|
+
2. **Resolve metadata** — install ops pack; load types, views, pipelines for that scope.
|
|
17
|
+
3. **Write / read** — data plane (`/api/data`) for subject content.
|
|
18
|
+
4. **Ingest** — Memory lands exact raw → pipelines promote → relationships link.
|
|
19
|
+
5. **Operate** — verify/rebuild links, inspect runs, install proposed metadata (**human** confirm).
|
|
20
|
+
|
|
21
|
+
Composition example: request all content about `WI-100` and receive siblings (snapshot, workflow, analyses) without flattening them into one document.
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
Agent inheritance (Design) selects which metadata definitions contribute to effective resolution:
|
|
26
|
+
|
|
27
|
+

|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## From: Platform Overview — 7. Local stack (quick start)
|
|
32
|
+
|
|
33
|
+
From the monorepo after workspace install:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
node scripts/dev-stack.mjs
|
|
37
|
+
# opens browser tabs: stack status, /_live views, Studio
|
|
38
|
+
# use --no-open to skip browser tabs
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
| Surface | Default URL |
|
|
42
|
+
|---|---|
|
|
43
|
+
| Studio | http://127.0.0.1:5101/ |
|
|
44
|
+
| Stack status | http://127.0.0.1:5103/ (hub — not Studio; links to each `/_live`) |
|
|
45
|
+
| Service live view | http://127.0.0.1:5100/_live (`@x12i/api-live-view` via `@x12i/core-service`) |
|
|
46
|
+
| Service OpenAPI | http://127.0.0.1:5100/api/openapi.json |
|
|
47
|
+
| Service health | http://127.0.0.1:5100/health |
|
|
48
|
+
| Ops-source live / health | http://127.0.0.1:5102/_live · `/health` |
|
|
49
|
+
|
|
50
|
+
Ports: Memorix zone **5100–5119** (even = API, odd = UI) from [`@x12i/ports-manager`](../../ports-manager/). Avoid **5000/7000** (macOS AirPlay). Quarantine **5000–5099**. How-to for new HTTP workers: [Building Services — HTTP process compliance](../../07-services/developers/BOOK.md#http-process-compliance-local-services). Remote data clients call `/api/*` only — do not install ports kits.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
curl -sS \
|
|
54
|
+
-H 'x-memorix-org-id: g12ops-demo' \
|
|
55
|
+
-H 'x-memorix-agent-ids: ops' \
|
|
56
|
+
http://127.0.0.1:5100/api/openapi.json
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
What to install in *your* app:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Default remote host: nothing required for HTTP
|
|
63
|
+
npm install @x12i/memorix-format@^3.0.1 # optional offline validate/migrate
|
|
64
|
+
|
|
65
|
+
# Trusted platform process only:
|
|
66
|
+
npm install @x12i/memorix-data@^3.0.1 @x12i/memorix-metadata-runtime@^3.0.1
|
|
67
|
+
|
|
68
|
+
# New HTTP services in x12i/exellix (bind a port):
|
|
69
|
+
npm install @x12i/core-service
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## From: Agent Packs & Ops — 3. Harness: up / down / reset / accept
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
cd memorix-ops-pack
|
|
78
|
+
npm install && npm test
|
|
79
|
+
node scripts/harness.mjs up # OPS_SOURCE_PORT default 5102
|
|
80
|
+
node scripts/harness.mjs reset # reset fixture control state
|
|
81
|
+
node scripts/harness.mjs accept # smoke: metadata files + source routes
|
|
82
|
+
node scripts/harness.mjs down
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Prefer the monorepo stack when exercising Studio + service together:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
node scripts/dev-stack.mjs
|
|
89
|
+
# includes ops-source on :5102 (even ports = APIs), stack-status :5103, /_live on APIs
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
| Command | Purpose |
|
|
93
|
+
|---|---|
|
|
94
|
+
| `up` | Start localhost `ops-source` (PID under `.run/`) |
|
|
95
|
+
| `down` | Stop ops-source via PID file |
|
|
96
|
+
| `reset` | POST fixture control reset; re-establish known source state |
|
|
97
|
+
| `accept` | Verify manifest files exist; hit key source routes; assert negative paths |
|
|
98
|
+
|
|
99
|
+
### What `accept` is (and is not)
|
|
100
|
+
|
|
101
|
+
**Is:** a deterministic smoke that the pack’s metadata files and fixture server behave.
|
|
102
|
+
|
|
103
|
+
**Is not:** a license to use live customer orgs; not a substitute for service-level gates on a fresh `g12ops*` with explicit metadata install + pipeline green.
|
|
104
|
+
|
|
105
|
+
Platform product acceptance always pairs pack smoke with:
|
|
106
|
+
|
|
107
|
+
```http
|
|
108
|
+
x-memorix-org-id: g12ops<suffix>
|
|
109
|
+
x-memorix-agent-ids: ops
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
and an explicit `/api/metadata/install` (or Studio install) into that org.
|
|
113
|
+
|
|
114
|
+
### Harness sketch in CI
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
node scripts/harness.mjs up
|
|
118
|
+
node scripts/harness.mjs accept
|
|
119
|
+
npx memorix-format validate-v2 examples/v2
|
|
120
|
+
node scripts/harness.mjs down
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## From: Agent Packs & Ops — 7. Install into a fresh acceptance org
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
ORG=$(node -e "console.log('g12ops'+Math.random().toString(36).slice(2,10))")
|
|
129
|
+
H=(-H "x-memorix-org-id: $ORG" -H "x-memorix-agent-ids: ops")
|
|
130
|
+
|
|
131
|
+
curl -s "${H[@]}" -X POST "$SERVICE/api/metadata/install" \
|
|
132
|
+
-H "content-type: application/json" \
|
|
133
|
+
-d '{"packId":"ops","confirm":true}'
|
|
134
|
+
|
|
135
|
+
curl -s "${H[@]}" "$SERVICE/api/metadata/effective" | head
|
|
136
|
+
|
|
137
|
+
# Memory pull from ops-source (credentialRef per Memory contracts)
|
|
138
|
+
# Pipeline start → assert WI-100 composition + links
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Assertions for a full gate:
|
|
142
|
+
|
|
143
|
+
- [ ] Manifest files present; `harness accept` green
|
|
144
|
+
- [ ] `validate-v2` green on `examples/v2`
|
|
145
|
+
- [ ] Install with `confirm: true` into `g12ops*`
|
|
146
|
+
- [ ] Memory pull lands raw for employees / work-items / …
|
|
147
|
+
- [ ] Pipeline green; Explore/HTTP composition for `wi-100`
|
|
148
|
+
- [ ] Relationship verify for documented definitions
|
|
149
|
+
- [ ] Custom kinds (if any) visible via `/api/metadata/kinds` and **not** executed by pipelines
|
|
150
|
+
- [ ] No live customer org; agents `["ops"]`
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Also see
|
|
155
|
+
|
|
156
|
+
- **Migration & Troubleshooting** (`13-migration-troubleshooting`) — associated* rejection, stale revisions, HTTP failure matrix, escalate packets.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
_Generated use-case pack for agents and humans. See `agent-manifest.json` for discovery._
|