@x12i/memorix-docs 1.0.2 → 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.
Files changed (236) hide show
  1. package/dist/generated/bundle.d.ts +4849 -3
  2. package/dist/generated/bundle.d.ts.map +1 -1
  3. package/dist/generated/bundle.js +7580 -45
  4. package/dist/generated/bundle.js.map +1 -1
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +6 -4
  8. package/dist/index.js.map +1 -1
  9. package/files/INDEX.md +84 -0
  10. package/files/SEARCH.json +3087 -0
  11. package/files/agent-manifest.json +1785 -0
  12. package/files/apis/memorix-records/overview.md +22 -0
  13. package/files/concepts/abstracts-bindings.md +27 -0
  14. package/files/concepts/agents-inheritance.md +28 -0
  15. package/files/concepts/analysis-objects.md +26 -0
  16. package/files/concepts/composition.md +27 -0
  17. package/files/concepts/decisions-content.md +27 -0
  18. package/files/concepts/effective-metadata.md +27 -0
  19. package/files/concepts/explicit-metadata-installation.md +26 -0
  20. package/files/concepts/intelligence-proposals.md +27 -0
  21. package/files/concepts/mappings-transforms.md +26 -0
  22. package/files/concepts/object-content-category.md +26 -0
  23. package/files/concepts/org-agent-scope.md +27 -0
  24. package/files/concepts/people-union.md +27 -0
  25. package/files/concepts/raw-records.md +26 -0
  26. package/files/concepts/record-revisions.md +26 -0
  27. package/files/concepts/relationship-definitions.md +26 -0
  28. package/files/concepts/relationship-references.md +27 -0
  29. package/files/concepts/resolved-unresolved.md +27 -0
  30. package/files/concepts/sources-and-memory.md +26 -0
  31. package/files/concepts/traversal.md +27 -0
  32. package/files/diagrams/agent-inheritance.md +34 -0
  33. package/files/diagrams/intelligence-journey.md +38 -0
  34. package/files/diagrams/memorix-central-journey.md +51 -0
  35. package/files/diagrams/metadata-lifecycle.md +40 -0
  36. package/files/diagrams/people-union-diagram.md +36 -0
  37. package/files/diagrams/record-content-model.md +43 -0
  38. package/files/diagrams/relationship-traversal.md +40 -0
  39. package/files/diagrams/revision-safe-write.md +39 -0
  40. package/files/examples/analysis-decision-records.md +11 -0
  41. package/files/examples/memorix-record-envelope.md +11 -0
  42. package/files/examples/metadata-pack-install.md +11 -0
  43. package/files/examples/people-abstract-query.md +11 -0
  44. package/files/examples/raw-vs-composed.md +11 -0
  45. package/files/examples/relationship-def-and-ref.md +11 -0
  46. package/files/examples/revision-conflict-response.md +11 -0
  47. package/files/examples/revision-safe-write.md +11 -0
  48. package/files/examples/traversal-resolved-unresolved.md +11 -0
  49. package/files/glossary/abstract.md +9 -0
  50. package/files/glossary/agent.md +9 -0
  51. package/files/glossary/analysis.md +9 -0
  52. package/files/glossary/binding.md +9 -0
  53. package/files/glossary/composition.md +9 -0
  54. package/files/glossary/content-type.md +9 -0
  55. package/files/glossary/data-category.md +9 -0
  56. package/files/glossary/decision.md +9 -0
  57. package/files/glossary/effective-metadata.md +9 -0
  58. package/files/glossary/intelligence-proposal.md +9 -0
  59. package/files/glossary/mapping.md +9 -0
  60. package/files/glossary/memory.md +9 -0
  61. package/files/glossary/object-type.md +9 -0
  62. package/files/glossary/relationship-definition.md +9 -0
  63. package/files/glossary/relationship-reference.md +9 -0
  64. package/files/glossary/revision.md +9 -0
  65. package/files/glossary/scope.md +9 -0
  66. package/files/glossary/source.md +9 -0
  67. package/files/glossary/traversal.md +9 -0
  68. package/files/guides/apply-scope.md +40 -0
  69. package/files/guides/choose-access-method.md +24 -0
  70. package/files/guides/compose-subject-ui.md +24 -0
  71. package/files/guides/define-traverse-relationship.md +26 -0
  72. package/files/guides/diagnose-unresolved.md +24 -0
  73. package/files/guides/evidence-to-decision.md +25 -0
  74. package/files/guides/first-revision-safe-write.md +30 -0
  75. package/files/guides/inspect-effective-metadata.md +30 -0
  76. package/files/guides/query-people-abstract.md +25 -0
  77. package/files/guides/reload-retry-conflict.md +32 -0
  78. package/files/guides/validate-install-pack.md +32 -0
  79. package/files/indexes/books.json +95 -0
  80. package/files/indexes/books.md +17 -0
  81. package/files/indexes/concepts.json +119 -0
  82. package/files/indexes/concepts.md +21 -0
  83. package/files/indexes/diagrams.json +53 -0
  84. package/files/indexes/diagrams.md +10 -0
  85. package/files/indexes/guides.json +71 -0
  86. package/files/indexes/guides.md +13 -0
  87. package/files/indexes/scenarios.json +41 -0
  88. package/files/indexes/scenarios.md +8 -0
  89. package/files/indexes/tutorials.json +47 -0
  90. package/files/indexes/tutorials.md +9 -0
  91. package/files/indexes/use-cases.json +239 -0
  92. package/files/indexes/use-cases.md +41 -0
  93. package/files/knowledge.json +2940 -0
  94. package/files/packs/concept/abstracts-bindings/PACK.md +11 -0
  95. package/files/packs/concept/abstracts-bindings/pack.json +13 -0
  96. package/files/packs/concept/agents-inheritance/PACK.md +11 -0
  97. package/files/packs/concept/agents-inheritance/pack.json +13 -0
  98. package/files/packs/concept/analysis-objects/PACK.md +11 -0
  99. package/files/packs/concept/analysis-objects/pack.json +14 -0
  100. package/files/packs/concept/composition/PACK.md +11 -0
  101. package/files/packs/concept/composition/pack.json +13 -0
  102. package/files/packs/concept/decisions-content/PACK.md +11 -0
  103. package/files/packs/concept/decisions-content/pack.json +13 -0
  104. package/files/packs/concept/effective-metadata/PACK.md +11 -0
  105. package/files/packs/concept/effective-metadata/pack.json +13 -0
  106. package/files/packs/concept/explicit-metadata-installation/PACK.md +11 -0
  107. package/files/packs/concept/explicit-metadata-installation/pack.json +14 -0
  108. package/files/packs/concept/intelligence-proposals/PACK.md +11 -0
  109. package/files/packs/concept/intelligence-proposals/pack.json +13 -0
  110. package/files/packs/concept/mappings-transforms/PACK.md +11 -0
  111. package/files/packs/concept/mappings-transforms/pack.json +13 -0
  112. package/files/packs/concept/object-content-category/PACK.md +11 -0
  113. package/files/packs/concept/object-content-category/pack.json +14 -0
  114. package/files/packs/concept/org-agent-scope/PACK.md +11 -0
  115. package/files/packs/concept/org-agent-scope/pack.json +14 -0
  116. package/files/packs/concept/people-union/PACK.md +11 -0
  117. package/files/packs/concept/people-union/pack.json +13 -0
  118. package/files/packs/concept/raw-records/PACK.md +11 -0
  119. package/files/packs/concept/raw-records/pack.json +14 -0
  120. package/files/packs/concept/record-revisions/PACK.md +11 -0
  121. package/files/packs/concept/record-revisions/pack.json +13 -0
  122. package/files/packs/concept/relationship-definitions/PACK.md +11 -0
  123. package/files/packs/concept/relationship-definitions/pack.json +14 -0
  124. package/files/packs/concept/relationship-references/PACK.md +11 -0
  125. package/files/packs/concept/relationship-references/pack.json +13 -0
  126. package/files/packs/concept/resolved-unresolved/PACK.md +11 -0
  127. package/files/packs/concept/resolved-unresolved/pack.json +13 -0
  128. package/files/packs/concept/sources-and-memory/PACK.md +11 -0
  129. package/files/packs/concept/sources-and-memory/pack.json +13 -0
  130. package/files/packs/concept/traversal/PACK.md +11 -0
  131. package/files/packs/concept/traversal/pack.json +13 -0
  132. package/files/packs/guide/apply-scope/PACK.md +11 -0
  133. package/files/packs/guide/apply-scope/pack.json +13 -0
  134. package/files/packs/guide/choose-access-method/PACK.md +11 -0
  135. package/files/packs/guide/choose-access-method/pack.json +15 -0
  136. package/files/packs/guide/compose-subject-ui/PACK.md +11 -0
  137. package/files/packs/guide/compose-subject-ui/pack.json +13 -0
  138. package/files/packs/guide/define-traverse-relationship/PACK.md +11 -0
  139. package/files/packs/guide/define-traverse-relationship/pack.json +14 -0
  140. package/files/packs/guide/diagnose-unresolved/PACK.md +11 -0
  141. package/files/packs/guide/diagnose-unresolved/pack.json +13 -0
  142. package/files/packs/guide/evidence-to-decision/PACK.md +11 -0
  143. package/files/packs/guide/evidence-to-decision/pack.json +14 -0
  144. package/files/packs/guide/first-revision-safe-write/PACK.md +11 -0
  145. package/files/packs/guide/first-revision-safe-write/pack.json +13 -0
  146. package/files/packs/guide/inspect-effective-metadata/PACK.md +11 -0
  147. package/files/packs/guide/inspect-effective-metadata/pack.json +13 -0
  148. package/files/packs/guide/query-people-abstract/PACK.md +11 -0
  149. package/files/packs/guide/query-people-abstract/pack.json +13 -0
  150. package/files/packs/guide/reload-retry-conflict/PACK.md +11 -0
  151. package/files/packs/guide/reload-retry-conflict/pack.json +13 -0
  152. package/files/packs/guide/validate-install-pack/PACK.md +11 -0
  153. package/files/packs/guide/validate-install-pack/pack.json +13 -0
  154. package/files/packs/scenario/choose-subject-view/PACK.md +11 -0
  155. package/files/packs/scenario/choose-subject-view/pack.json +11 -0
  156. package/files/packs/scenario/pack-valid-not-installed/PACK.md +11 -0
  157. package/files/packs/scenario/pack-valid-not-installed/pack.json +11 -0
  158. package/files/packs/scenario/scope-mismatch/PACK.md +11 -0
  159. package/files/packs/scenario/scope-mismatch/pack.json +11 -0
  160. package/files/packs/scenario/stale-revision-conflict/PACK.md +11 -0
  161. package/files/packs/scenario/stale-revision-conflict/pack.json +11 -0
  162. package/files/packs/scenario/traversal-direction/PACK.md +11 -0
  163. package/files/packs/scenario/traversal-direction/pack.json +11 -0
  164. package/files/packs/scenario/unresolved-relationship/PACK.md +11 -0
  165. package/files/packs/scenario/unresolved-relationship/pack.json +11 -0
  166. package/files/packs/tutorial/analysis-decision-lab/PACK.md +11 -0
  167. package/files/packs/tutorial/analysis-decision-lab/pack.json +14 -0
  168. package/files/packs/tutorial/compare-views/PACK.md +11 -0
  169. package/files/packs/tutorial/compare-views/pack.json +14 -0
  170. package/files/packs/tutorial/conflict-lab/PACK.md +11 -0
  171. package/files/packs/tutorial/conflict-lab/pack.json +13 -0
  172. package/files/packs/tutorial/first-revision-safe-record/PACK.md +11 -0
  173. package/files/packs/tutorial/first-revision-safe-record/pack.json +13 -0
  174. package/files/packs/tutorial/install-pack-lab/PACK.md +11 -0
  175. package/files/packs/tutorial/install-pack-lab/pack.json +13 -0
  176. package/files/packs/tutorial/relationships-lab/PACK.md +11 -0
  177. package/files/packs/tutorial/relationships-lab/pack.json +13 -0
  178. package/files/packs/tutorial/start-with-sample-data/PACK.md +11 -0
  179. package/files/packs/tutorial/start-with-sample-data/pack.json +13 -0
  180. package/files/sample-data/memorix-synthetic-basic.md +13 -0
  181. package/files/scenarios/choose-subject-view.md +36 -0
  182. package/files/scenarios/pack-valid-not-installed.md +33 -0
  183. package/files/scenarios/scope-mismatch.md +44 -0
  184. package/files/scenarios/stale-revision-conflict.md +38 -0
  185. package/files/scenarios/traversal-direction.md +30 -0
  186. package/files/scenarios/unresolved-relationship.md +31 -0
  187. package/files/tutorials/analysis-decision-lab.md +18 -0
  188. package/files/tutorials/compare-views.md +22 -0
  189. package/files/tutorials/conflict-lab.md +18 -0
  190. package/files/tutorials/first-revision-safe-record.md +18 -0
  191. package/files/tutorials/install-pack-lab.md +22 -0
  192. package/files/tutorials/relationships-lab.md +18 -0
  193. package/files/tutorials/start-with-sample-data.md +18 -0
  194. package/files/ui/clients/memorix-studio.md +9 -0
  195. package/files/use-cases/abstract-people-list.md +237 -0
  196. package/files/use-cases/ai-pipeline-fail-closed.md +117 -0
  197. package/files/use-cases/author-pipeline-e2e.md +339 -0
  198. package/files/use-cases/build-callable-service.md +347 -0
  199. package/files/use-cases/builder-acceptance-ops.md +112 -0
  200. package/files/use-cases/choose-access-method.md +111 -0
  201. package/files/use-cases/client-first-read-write.md +374 -0
  202. package/files/use-cases/compose-for-ui.md +97 -0
  203. package/files/use-cases/custom-kind-descriptors.md +137 -0
  204. package/files/use-cases/data-journey-evidence.md +115 -0
  205. package/files/use-cases/discriminated-content-writes.md +152 -0
  206. package/files/use-cases/embed-studio-host.md +165 -0
  207. package/files/use-cases/four-field-links.md +246 -0
  208. package/files/use-cases/http-process-compliance.md +225 -0
  209. package/files/use-cases/install-metadata-pack.md +180 -0
  210. package/files/use-cases/intelligence-propose-install.md +163 -0
  211. package/files/use-cases/knowx-claims-review.md +396 -0
  212. package/files/use-cases/learn-record-envelope.md +233 -0
  213. package/files/use-cases/lists-cursors-pagination.md +196 -0
  214. package/files/use-cases/local-acceptance-g12ops.md +160 -0
  215. package/files/use-cases/memory-hourly-ingest.md +276 -0
  216. package/files/use-cases/metadata-before-write.md +145 -0
  217. package/files/use-cases/migrate-associated-star.md +159 -0
  218. package/files/use-cases/openapi-typed-client.md +78 -0
  219. package/files/use-cases/ops-pack-fixtures.md +168 -0
  220. package/files/use-cases/orient-platform.md +172 -0
  221. package/files/use-cases/pipeline-retry-evidence.md +121 -0
  222. package/files/use-cases/relationship-rebuild-verify.md +128 -0
  223. package/files/use-cases/revision-stale-conflicts.md +194 -0
  224. package/files/use-cases/start-from-zero.md +171 -0
  225. package/files/use-cases/studio-design-types.md +122 -0
  226. package/files/use-cases/studio-explore-subject.md +89 -0
  227. package/files/use-cases/studio-operate-pipelines.md +100 -0
  228. package/files/use-cases/studio-review-intelligence.md +74 -0
  229. package/files/use-cases/studio-scope-isolation.md +67 -0
  230. package/files/use-cases/studio-stale-conflict-ui.md +54 -0
  231. package/files/use-cases/troubleshoot-http-matrix.md +164 -0
  232. package/files/use-cases/trusted-in-process-embed.md +94 -0
  233. package/files/use-cases/workflow-sibling-api.md +212 -0
  234. package/files/visuals/revision-conflict.md +19 -0
  235. package/files/visuals/scope-apply.md +19 -0
  236. package/package.json +4 -3
@@ -0,0 +1,112 @@
1
+ # Acceptance tour on the ops narrative
2
+
3
+ > **Use case id:** `builder-acceptance-ops`
4
+ > **Goal:** Walk WI-100 / employees success path in Studio without API deep-dive.
5
+ > **Audiences:** builders
6
+ > **Tags:** acceptance, ops, studio
7
+
8
+ ## Reading path
9
+
10
+ 1. **Platform Overview** (builders) → chapters: `5-a-short-ops-tour-what-success-looks-like`, `9-acceptance-workspace`
11
+ 1. **Workflow & Studio** (builders) → chapters: `7-short-ops-tour-acceptance`
12
+ 1. **Agent Packs & Ops** (builders) → chapters: `1-what-you-should-see-after-a-good-install`, `2-install-checklist-fresh-g12ops`
13
+
14
+ ## From: Platform Overview — 5. A short ops tour (what success looks like)
15
+
16
+ Use subjects from the permanent narrative: employee **Alex**, work item **WI-100**, procedure **PROC-2**.
17
+
18
+ 1. **Design** — confirm ops metadata is installed for your `g12ops*` org.
19
+ 2. **Operate** — run a Memory pull from ops-source; inspect landing of raw material.
20
+ 3. **Operate** — start the relevant pipeline; watch attempts and artifacts.
21
+ 4. **Explore** — open `WI-100` (or Alex); confirm composition siblings appear.
22
+ 5. **Explore** — traverse relationship links; confirm you see navigation, not pasted neighbor fields.
23
+ 6. **Design / Operate** — if intelligence proposed metadata, review and **explicitly** install or reject — never expect auto-install.
24
+
25
+ ---
26
+
27
+ ## From: Platform Overview — 9. Acceptance workspace
28
+
29
+ Always use a fresh `g12ops*` organization with agent `ops`. Never use live customer orgs for drills. See [_shared/ops-scenario.md](../../_shared/ops-scenario.md).
30
+
31
+ ## From: Workflow & Studio — 7. Short ops tour (acceptance)
32
+
33
+ Subjects: employee **Alex**, work item **WI-100**, procedure **PROC-2**.
34
+
35
+ 1. **Scope** — fresh `g12ops*` + agent `ops`.
36
+ 2. **Design** — confirm ops metadata installed (explicit install if needed).
37
+ 3. **Operate** — Memory pull from ops-source; confirm raw landed.
38
+ 4. **Operate** — run the documented pipeline; open artifacts if anything fails.
39
+ 5. **Explore** — open `WI-100`; confirm composition siblings (snapshot + workflow, …).
40
+ 6. **Explore** — edit workflow assignment; save; confirm revision bump.
41
+ 7. **Explore** — traverse relationships; confirm expansion, not copied payloads.
42
+ 8. Optional: open a KnowX assertion and walk the review siblings (book `12`).
43
+
44
+ ---
45
+
46
+ ## From: Agent Packs & Ops — 1. What you should see after a good install
47
+
48
+ | Area | Healthy signal |
49
+ |---|---|
50
+ | Design → Agents | `ops` (and documented children) present |
51
+ | Design → Types | employees, work-items, procedures, … |
52
+ | Design → Abstracts | People-style unions bound to concrete types |
53
+ | Design → Relationships | Documented definitions available |
54
+ | Operate → Memory | Pull from ops-source succeeds |
55
+ | Operate → Runs | Pipeline attempts succeed; artifacts readable |
56
+ | Explore | WI-100 composition (snapshot, workflow, …); Alex visible; links expand |
57
+
58
+ Custom kinds (if your pack declares them): appear under metadata kinds / effective metadata after install. They do **not** by themselves run pipelines.
59
+
60
+ ---
61
+
62
+ ## From: Agent Packs & Ops — 2. Install checklist (fresh `g12ops*`)
63
+
64
+ Work top to bottom. Do not skip scope.
65
+
66
+ ### A. Workspace
67
+
68
+ - [ ] Create / select a **fresh** `g12ops*` organization
69
+ - [ ] Scope bar agent = **`ops`** (or the documented agent set)
70
+ - [ ] You are **not** on a live customer org
71
+ - [ ] Service + Studio + ops-source are up (prefer `dev-stack`)
72
+
73
+ ### B. Metadata install
74
+
75
+ - [ ] Design → metadata install / publish for the **ops** pack
76
+ - [ ] Confirmation step completed (explicit — not a silent side effect)
77
+ - [ ] Effective agents/types refresh in Design
78
+ - [ ] (Optional) If the pack declares custom kinds, confirm they appear under kinds / effective metadata
79
+
80
+ ### C. Memory
81
+
82
+ - [ ] Operate → Memory pull from **ops-source** (localhost fixture)
83
+ - [ ] Raw material landed for employees / work-items / procedures / activity-events as documented
84
+ - [ ] No raw secrets pasted into forms — credential refs only if prompted
85
+
86
+ ### D. Pipeline
87
+
88
+ - [ ] Operate → start the documented ops pipeline / schedule
89
+ - [ ] Attempts green (or failures opened with readable artifacts)
90
+ - [ ] Do not “fix” by inventing subjects outside the data plane
91
+
92
+ ### E. Explore verification
93
+
94
+ - [ ] Open **WI-100** — composition siblings present (snapshot, workflow, …)
95
+ - [ ] Open **Alex** (employee) — snapshot healthy
96
+ - [ ] Traverse a relationship link — expansion shows current targets, not pasted neighbor blobs
97
+ - [ ] Unresolved targets (if any in the scenario) are visible as unresolved — not silently invented
98
+
99
+ ### F. Optional intelligence
100
+
101
+ - [ ] If you run intelligence proposals, **review then install/reject** — proposals alone must not change types
102
+ - [ ] Prefer shipped ops pack for acceptance demos
103
+
104
+ ---
105
+
106
+ ## Also see
107
+
108
+ - **Building Pipelines** (`08-pipelines`) — Pipeline definition, step kinds, AI fail-closed, operations, and the complete ops tutorial.
109
+
110
+ ---
111
+
112
+ _Generated use-case pack for agents and humans. See `agent-manifest.json` for discovery._
@@ -0,0 +1,111 @@
1
+ # Choose the right access method
2
+
3
+ > **Use case id:** `choose-access-method`
4
+ > **Goal:** Map a task to best / acceptable / forbidden calls using the patterns matrix.
5
+ > **Audiences:** developers
6
+ > **Tags:** patterns, http
7
+
8
+ ## Reading path
9
+
10
+ 1. **Data Access Patterns** (developers) → chapters: `2-master-decision-matrix`, `5-exact-read-versus-list`, `25-decision-tree`
11
+
12
+ ## From: Data Access Patterns — 2. Master decision matrix
13
+
14
+ For every runtime goal: preferred method, acceptable ad-hoc, forbidden method, and the consistency / retry story.
15
+
16
+ | Goal | Best | Acceptable | Forbidden | Consistency / retry |
17
+ |---|---|---|---|---|
18
+ | Read one known content instance | Service `GET /api/data/content` (exact) | In-process `@x12i/memorix-data` `getContent` | Mongo `findOne` | Current revision; retry transient failures |
19
+ | Find records matching fields | Bounded list/query + opaque cursor | Temporary ad-hoc filter with hard limit | Unbounded `listAll` / decoded cursors | Cursor contract; retry **same** query+cursor |
20
+ | Read all content about one subject | Explicit composition | Two–three independent exact gets | Flatten siblings into the snapshot; invent `associated*` | Current siblings; per-sibling revisions |
21
+ | Read a union such as People | Abstract list / get | Concrete lists + UI label (diagnosis only) | Abstract collection / abstract `recordId` | Metadata-dependent projection |
22
+ | Follow relationships | Relationship query / `expandRelationships` | Bounded investigation queries | Client-side org-wide joins; copied payloads | Current targets; unresolved stays unresolved |
23
+ | Read current related properties | Related-property / expansion APIs | Two bounded queries | Persist expanded targets on the source | Current; may go stale if cached naïvely |
24
+ | Process a small known set | Batch get (if exposed) or bounded list of addresses | Parallel exact gets with concurrency cap | Cartesian fan-out | Per-item |
25
+ | Process a large set | Pipeline + DataRef | Async export for reporting | Interactive mega-list | Captured/ledgered; retry failed items |
26
+ | Import external data | Memory pull → raw | Controlled source test via Memory | Direct snapshot insert from connector | Source cursor; resume committed cursor |
27
+ | Write one content instance | `patch` / `upsert` / `replace` / `remove` + precondition | Operator script through the same API | Blind replace; Mongo update | Exact revision; never blind-retry after stale |
28
+ | Update an abstract property | `patchAbstract` reverse write | Temporary concrete patch when mapping is clear | Writing an “abstract record” | Maps to one concrete revision |
29
+ | Modify many records | Pipeline / batch with per-item revisions | Capture-all-then-write for tiny sets | Client update-many; list-mutate active sort | Partial success ledger |
30
+ | Create relationships | Relationship engine (discover / materialize / rebuild) | Dry-run / verify | Manual link inserts; `associated*` | Idempotent materialization |
31
+ | Inspect execution history | Operations / pipeline / Memory APIs | Studio Operate views | Treating ledgers as subject content | Operational identity |
32
+ | Inspect evidence / expected slots | `/api/data-journey/*` (matrix, coverage, evidence) | Studio Explore evidence UI | Inventing cells; treating journey rows as subject content | Read-only; views = slots only |
33
+ | Export large data | Asynchronous export artifact | Paginated offline consumer with checkpoint | Single-request dump | Export contract |
34
+ | Investigate once | Bounded ad-hoc API query | Studio Explore | Direct Mongo shell | Read-only unless labeled write |
35
+ | Save a repeated query | Metadata-defined view | Temporary client query | Hardcoded DB query in the product | Versioned with metadata |
36
+ | Repeated business process | Pipeline definition | Scheduled Memory + pipeline | UI-embedded “batch engine” | Durable run ledger |
37
+ | Propose new object type | Intelligence proposal → human install | Export draft for review | Intelligence auto-publish / AI writing records | Proposal ≠ live metadata |
38
+ | Secret to connector | `credentialRef` | — | Secret in body / Memory payload | Never log credentials |
39
+
40
+ ---
41
+
42
+ ## From: Data Access Patterns — 5. Exact read versus list
43
+
44
+ | Situation | Use |
45
+ |---|---|
46
+ | Known `recordId` / content address | Exact get |
47
+ | Unknown `recordId`, known properties | List / query |
48
+ | Several known addresses | Batch get or parallel exact gets (capped) |
49
+ | Same subject, several sibling types | Composition |
50
+ | Abstract union | Abstract list |
51
+ | Different related subjects | Relationship traversal |
52
+ | Large unknown set | Pipeline / export |
53
+
54
+ **Why not list a known id?** A list walk is more expensive, harder to reason about under concurrency, and invites “first hit wins” bugs. Exact get is O(1) identity.
55
+
56
+ **Why not guess `recordId` from business fields?** External ids live under `concept.identifiers`. Guessing subject ids from titles or provider keys is unsafe; list/filter by identifier fields or resolve through Memory/mapping metadata instead.
57
+
58
+ **Ops example:** Host knows `WI-100`’s Memorix `recordId` → exact snapshot get. Host only knows provider work-item key → bounded list/filter on identifier fields, then exact get thereafter.
59
+
60
+ ---
61
+
62
+ ## From: Data Access Patterns — 25. Decision tree
63
+
64
+ ```text
65
+ Do you know the exact content address?
66
+ ├─ Yes → exact read / exact revision-safe write
67
+ └─ No → bounded list/query (then exact thereafter)
68
+
69
+ Do you need several content types for the same subject?
70
+ ├─ Yes → composition
71
+ └─ No → keep exact content read
72
+
73
+ Do you need another subject?
74
+ ├─ Existing semantic link → relationship traversal / expansion
75
+ ├─ Investigating a possible link → bounded ad-hoc query
76
+ └─ Repeated meaningful join → relationship metadata + discovery
77
+
78
+ Is the write one small known instance?
79
+ ├─ Yes → revision-safe direct write
80
+ └─ No → capture addresses → batch/pipeline
81
+
82
+ Does data come from an external source?
83
+ └─ Memory → raw first → pipeline promote
84
+
85
+ Is the work large, repeatable, scheduled, or retryable?
86
+ └─ Pipeline (DataRef + ledger)
87
+
88
+ Is this a one-off investigation?
89
+ └─ Bounded ad-hoc API query — never direct Mongo
90
+
91
+ Need evidence cone / expected slots for Explore?
92
+ └─ /api/data-journey/* (read-only) — see Runtime Data Client §17
93
+
94
+ Is this a reusable product screen/query?
95
+ └─ Metadata-defined view (not a hardcoded DB query)
96
+
97
+ Is this a metadata shape suggestion?
98
+ └─ Intelligence proposal → human install (never auto-publish)
99
+ ```
100
+
101
+ Process debug (`/health`, `/_live`) is not an access pattern for domain data — see [Platform Overview](../../00-platform-overview/developers/BOOK.md). Remote clients do not install `@x12i/core-service` / ports kits.
102
+ ---
103
+
104
+ ## Also see
105
+
106
+ - **Runtime Data Client** (`02-runtime-data-client`) — Connection, scope, exact reads, writes, compose, abstracts, and client anti-patterns through Memorix Service / OpenAPI.
107
+ - **Lists, Queries, Pagination** (`03-lists-queries-pagination`) — List contracts, query grammar, cursors, page size, and multi-resource listing without foot-guns.
108
+
109
+ ---
110
+
111
+ _Generated use-case pack for agents and humans. See `agent-manifest.json` for discovery._
@@ -0,0 +1,374 @@
1
+ # Product backend first safe read/write
2
+
3
+ > **Use case id:** `client-first-read-write`
4
+ > **Goal:** Call /api/data correctly with scope, revision preconditions, and explicit compose.
5
+ > **Audiences:** developers
6
+ > **Tags:** http, client, data
7
+
8
+ ## Reading path
9
+
10
+ 1. **Runtime Data Client** (developers) → chapters: `2-connection-and-scope`, `4-exact-content-reads`, `6-explicit-composition`, `9-concrete-writes`, `10-patch-language`
11
+ 1. **Data Access Patterns** (developers) → chapters: `2-master-decision-matrix`
12
+
13
+ ## From: Runtime Data Client — 2. Connection and scope
14
+
15
+ ### Canonical client configuration
16
+
17
+ ```ts
18
+ type MemorixClientConfig = {
19
+ baseUrl: string; // e.g. http://127.0.0.1:5100
20
+ orgId: string; // exactly one — entire org data universe
21
+ agentIds: string[]; // one or more unique ids — effective metadata only
22
+ };
23
+ ```
24
+
25
+ HTTP form (every `/api/*` call):
26
+
27
+ ```http
28
+ x-memorix-org-id: g12ops<suffix>
29
+ x-memorix-agent-ids: ops
30
+ ```
31
+
32
+ Rules:
33
+
34
+ 1. Exactly **one** `orgId` — selects the organization data universe.
35
+ 2. One or more unique **`agentIds`** — selects **effective metadata** only.
36
+ 3. Canonical agent ordering is applied by the service; send a stable unique list.
37
+ 4. There is **no** singular `agentId` in supported APIs — singular headers are rejected (`400`).
38
+ 5. `agentIds` never filter which organization rows you can read; they do not replace authorization.
39
+ 6. Deployment authentication (mTLS, gateway tokens, …) is **separate** from Memorix data/metadata scope.
40
+
41
+ ### Where scope is supplied
42
+
43
+ | Channel | Role |
44
+ |---|---|
45
+ | HTTP headers | Canonical for service callers |
46
+ | SDK client config | Maps to the same headers / scope object |
47
+ | Query / body | Must not invent a *different* scope semantics per route |
48
+
49
+ There is **one** scope rule for the platform: org selects data universe; agents select effective metadata. Studio’s scope bar sets the same pair.
50
+
51
+ ### Example — configure then probe OpenAPI
52
+
53
+ ```bash
54
+ ORG=g12opsabc123
55
+ AGENTS=ops
56
+ BASE=http://127.0.0.1:5100
57
+
58
+ curl -sS \
59
+ -H "x-memorix-org-id: $ORG" \
60
+ -H "x-memorix-agent-ids: $AGENTS" \
61
+ "$BASE/api/openapi.json" | head
62
+ ```
63
+
64
+ ```ts
65
+ const client = {
66
+ baseUrl: process.env.MEMORIX_BASE_URL!,
67
+ orgId: "g12opsabc123",
68
+ agentIds: ["ops"],
69
+ };
70
+
71
+ function scopeHeaders(c: typeof client): HeadersInit {
72
+ return {
73
+ "x-memorix-org-id": c.orgId,
74
+ "x-memorix-agent-ids": c.agentIds.join(","),
75
+ };
76
+ }
77
+ ```
78
+
79
+ ### Process debug vs product API
80
+
81
+ | Surface | Purpose | Client installs kits? |
82
+ |---|---|---|
83
+ | `/api/*` (OpenAPI) | Product contract — data, metadata, Memory, pipelines, … | N/A — call HTTP |
84
+ | `GET /health` | Process liveness (local stack) | **No** — do not install `@x12i/core-service` / ports kits |
85
+ | `GET /_live` | In-process request rings for the bound service | **No** — debug only; not a domain API |
86
+
87
+ Local URLs and the Memorix zone (**5100–5119**) are oriented in [Platform Overview](../../00-platform-overview/developers/BOOK.md). Authors of **new HTTP processes** (workers Memorix invokes) follow HTTP compliance in [Building Services](../../07-services/developers/BOOK.md). Remote data clients only need `baseUrl` + scope headers.
88
+
89
+ ### Antipatterns
90
+
91
+ - Omitting agent headers and hoping defaults apply.
92
+ - Sending `agentId` (singular) “because Studio used to.”
93
+ - Using `agentIds` as a substitute for per-record ACL.
94
+ - Pointing a host app at Mongo “just for reads.”
95
+ - Treating `/_live` or `/health` as substitutes for `/api/data` or `/api/data-journey`.
96
+
97
+ ---
98
+
99
+ ## From: Runtime Data Client — 4. Exact content reads
100
+
101
+ Exact reads retrieve **one** content instance. They do **not** automatically compose siblings or expand relationships.
102
+
103
+ ### Addressing
104
+
105
+ | Field | When |
106
+ |---|---|
107
+ | `recordId` / `id` | Always for get-by-id |
108
+ | `objectType` | Required for concrete content |
109
+ | `contentType` | Required for concrete content |
110
+ | Discriminator | When the content profile is multi-instance |
111
+ | Projection / view | When the API exposes a view name |
112
+ | Scope | Always |
113
+
114
+ ### What you can retrieve
115
+
116
+ - Singleton content (e.g. Alex’s employee snapshot)
117
+ - Discriminated content (e.g. `wi-100` analysis `capacity`)
118
+ - Missing content → not-found / unavailable semantics (see errors)
119
+ - Reserved-but-empty subject → identity reserved, content not yet present
120
+ - Raw, snapshot, workflow, context, analysis, decision, discovery — as metadata allows
121
+
122
+ ### Typical response envelope fields
123
+
124
+ `format`, `recordId`, `revision`, `objectType`, `contentType`, `dataCategory`, optional discriminator, `concept`, `data`, `_system`, plus request/correlation id on the HTTP layer.
125
+
126
+ ### Example — read WI-100 snapshot
127
+
128
+ ```bash
129
+ curl -sS \
130
+ -H "x-memorix-org-id: $ORG" \
131
+ -H "x-memorix-agent-ids: $AGENTS" \
132
+ "$BASE/api/data/content?objectType=work-items&contentType=snapshots&id=wi-100"
133
+ ```
134
+
135
+ ```ts
136
+ async function getSnapshot(recordId: string) {
137
+ const url = new URL("/api/data/content", client.baseUrl);
138
+ url.searchParams.set("objectType", "work-items");
139
+ url.searchParams.set("contentType", "snapshots");
140
+ url.searchParams.set("id", recordId);
141
+ const res = await fetch(url, { headers: scopeHeaders(client) });
142
+ if (!res.ok) throw new Error(await res.text());
143
+ return res.json(); // memorix-record/2
144
+ }
145
+ ```
146
+
147
+ ### May / must-not
148
+
149
+ - **You may** read one instance and later compose if the UI needs siblings.
150
+ - **You must not** assume a get returns related employees “because the work item mentions them.”
151
+ - **You must not** treat absence of a sibling as an error unless your product requires that sibling.
152
+
153
+ ---
154
+
155
+ ## From: Runtime Data Client — 6. Explicit composition
156
+
157
+ Composition is **requested**. Same `recordId`, multiple content types/instances.
158
+
159
+ ### Shape rules
160
+
161
+ - Response uses **arrays per content type** (even singleton types appear as arrays in compose).
162
+ - Siblings are **not** flattened into one mega-document.
163
+ - Clients may select which content types to include.
164
+ - Workflow / context / analysis / decisions appear only when selected.
165
+ - Composition carries **no** relationship definitions — neighbors stay relationship APIs.
166
+
167
+ ### Ops examples
168
+
169
+ | Request | Result idea |
170
+ |---|---|
171
+ | Compose `wi-100` with `snapshots` + `workflow` | One snapshot array entry + workflow array entry |
172
+ | Include two analyses | `analysis: [capacity, delivery-risk]` (names illustrative) |
173
+ | Include three decisions | Arrays under decisions; independent revisions |
174
+ | Optional sibling missing | Empty array or omitted per contract — not a fake null record |
175
+
176
+ ```text
177
+ composeSubject(wi-100)
178
+ snapshots[] revision N
179
+ workflow[] revision M
180
+ analysis[] each own revision
181
+ decisions[] each own revision
182
+ ```
183
+
184
+ ```bash
185
+ curl -sS -X POST \
186
+ -H "content-type: application/json" \
187
+ -H "x-memorix-org-id: $ORG" \
188
+ -H "x-memorix-agent-ids: $AGENTS" \
189
+ -d '{"recordId":"wi-100","explicit":true,"contentTypes":["snapshots","workflow","analysis","decisions"]}' \
190
+ "$BASE/api/data/compose"
191
+ ```
192
+
193
+ OpenAPI operation: `dataCompose`. `explicit: true` is required. Response keeps **arrays per content type**; missing siblings are empty/omitted arrays (plus warnings when the contract exposes them) — not invented singleton objects.
194
+
195
+ ### May / must-not
196
+
197
+ - **You may** compose for a dossier / Studio Explore-style view.
198
+ - **You must not** invent a single “subject revision” by taking `max(sibling revisions)`.
199
+ - **You must not** flatten arrays into one object keyed only by content type when multiple discriminators exist.
200
+ - **You must not** call compose as `GET` with query params — the service accepts **`POST /api/data/compose`** only.
201
+
202
+ ---
203
+
204
+ ## From: Runtime Data Client — 9. Concrete writes
205
+
206
+ Supported write operations through the data plane:
207
+
208
+ | Op | Intent |
209
+ |---|---|
210
+ | `add` | Create only if absent |
211
+ | `upsert` | Create if absent **or** update at exact revision |
212
+ | `patch` | Partial update at exact revision |
213
+ | `replace` | Full content replace at exact revision |
214
+ | `remove` | Delete instance at exact revision |
215
+
216
+ Every write requires:
217
+
218
+ - Memorix scope
219
+ - Concrete content address (`objectType`, `contentType`, `recordId`, discriminator if needed)
220
+ - Explicit precondition
221
+ - Immutable envelope fields respected
222
+
223
+ ### Preconditions
224
+
225
+ ```json
226
+ { "kind": "absent" }
227
+ ```
228
+
229
+ ```json
230
+ { "kind": "revision", "revision": 3 }
231
+ ```
232
+
233
+ | Op | Precondition |
234
+ |---|---|
235
+ | `add` | `absent` |
236
+ | `patch` / `replace` / `remove` | Exact `revision` |
237
+ | `upsert` | `absent` **or** exact `revision` |
238
+
239
+ Explain:
240
+
241
+ - Blind overwrite is **forbidden**.
242
+ - Successful create produces **revision 1**.
243
+ - Successful update increments revision **once**.
244
+ - Stale write performs **no mutation** (conflict).
245
+ - Failure atomicity: a rejected write leaves the prior revision unchanged.
246
+
247
+ ### Immutable / ownership reminders
248
+
249
+ - Do not patch `format`, subject identity, or discriminator in place.
250
+ - Lifecycle and server timestamps follow ownership rules (chapter 13).
251
+ - Directory identity conflicts stop the write — `recordId` already bound to a different object type/category.
252
+
253
+ ### Example — add then patch WI-100
254
+
255
+ ```ts
256
+ // Create snapshot (absent)
257
+ await writeContent({
258
+ op: "add",
259
+ objectType: "work-items",
260
+ contentType: "snapshots",
261
+ recordId: "wi-100",
262
+ precondition: { kind: "absent" },
263
+ record: {
264
+ format: "memorix-record/2",
265
+ recordId: "wi-100",
266
+ objectType: "work-items",
267
+ contentType: "snapshots",
268
+ dataCategory: "entity",
269
+ concept: { title: "Prepare quarterly operations review" },
270
+ data: { status: "in-progress", priority: "normal" },
271
+ },
272
+ });
273
+
274
+ // Later: patch with exact revision from prior read
275
+ await writeContent({
276
+ op: "patch",
277
+ objectType: "work-items",
278
+ contentType: "snapshots",
279
+ recordId: "wi-100",
280
+ precondition: { kind: "revision", revision: 1 },
281
+ patch: [{ op: "set", path: "data.status", value: "blocked" }],
282
+ });
283
+ ```
284
+
285
+ Wire the same intent through `/api/data` per OpenAPI — never via Mongo `updateOne`.
286
+
287
+ ### Retry behavior (preview)
288
+
289
+ Network unknown after write → re-read before sending another write. Stale revision → reconcile; do not convert to blind upsert. See chapters 19–20.
290
+
291
+ ---
292
+
293
+ ## From: Runtime Data Client — 10. Patch language
294
+
295
+ Patches are structured operations with path rules — not free-form JSON Merge Patch against the whole envelope unless the contract says so.
296
+
297
+ ### Typical operations
298
+
299
+ | Op | Use |
300
+ |---|---|
301
+ | `set` | Set a value at an allowed path |
302
+ | `unset` / remove | Clear an allowed path where supported |
303
+
304
+ ### Path rules (client view)
305
+
306
+ - Prefer paths under `data`, and allowed `concept` / `_system` subsets per contract.
307
+ - Envelope fields (`format`, `recordId`, `objectType`, `contentType`, …) are immutable via patch.
308
+ - Discriminator values are immutable via patch/replace.
309
+ - Lifecycle modifications follow metadata rules — illegal transitions fail.
310
+ - Concept / data / system ownership is contract-defined; do not invent cross-bucket ownership.
311
+ - Conflicting ops in one request fail validation.
312
+ - Invalid or unsafe paths fail before mutation.
313
+ - Validation runs **after** patch application against V2 + profiles.
314
+
315
+ ### Valid vs invalid (illustrative)
316
+
317
+ **Valid**
318
+
319
+ - Set `data.priority` on WI-100 snapshot.
320
+ - Unset an optional `data` field allowed by schema.
321
+ - Set `concept.title` when the profile allows title edits.
322
+
323
+ **Invalid**
324
+
325
+ - Set `revision` or `format`.
326
+ - Set discriminator in place.
327
+ - Set root `associatedEmployees` or any `associated*`.
328
+ - Patch Mongo `_id`.
329
+ - Invent `/../../` or injection-shaped paths.
330
+ - Conflicting `set` + `unset` on the same path in one request.
331
+
332
+ ### After patch
333
+
334
+ Re-read if your client needs the server-normalized record (defaults, timestamps, omitted empty buckets). Do not assume the patch document equals the stored document byte-for-byte.
335
+
336
+ ---
337
+
338
+ ## From: Data Access Patterns — 2. Master decision matrix
339
+
340
+ For every runtime goal: preferred method, acceptable ad-hoc, forbidden method, and the consistency / retry story.
341
+
342
+ | Goal | Best | Acceptable | Forbidden | Consistency / retry |
343
+ |---|---|---|---|---|
344
+ | Read one known content instance | Service `GET /api/data/content` (exact) | In-process `@x12i/memorix-data` `getContent` | Mongo `findOne` | Current revision; retry transient failures |
345
+ | Find records matching fields | Bounded list/query + opaque cursor | Temporary ad-hoc filter with hard limit | Unbounded `listAll` / decoded cursors | Cursor contract; retry **same** query+cursor |
346
+ | Read all content about one subject | Explicit composition | Two–three independent exact gets | Flatten siblings into the snapshot; invent `associated*` | Current siblings; per-sibling revisions |
347
+ | Read a union such as People | Abstract list / get | Concrete lists + UI label (diagnosis only) | Abstract collection / abstract `recordId` | Metadata-dependent projection |
348
+ | Follow relationships | Relationship query / `expandRelationships` | Bounded investigation queries | Client-side org-wide joins; copied payloads | Current targets; unresolved stays unresolved |
349
+ | Read current related properties | Related-property / expansion APIs | Two bounded queries | Persist expanded targets on the source | Current; may go stale if cached naïvely |
350
+ | Process a small known set | Batch get (if exposed) or bounded list of addresses | Parallel exact gets with concurrency cap | Cartesian fan-out | Per-item |
351
+ | Process a large set | Pipeline + DataRef | Async export for reporting | Interactive mega-list | Captured/ledgered; retry failed items |
352
+ | Import external data | Memory pull → raw | Controlled source test via Memory | Direct snapshot insert from connector | Source cursor; resume committed cursor |
353
+ | Write one content instance | `patch` / `upsert` / `replace` / `remove` + precondition | Operator script through the same API | Blind replace; Mongo update | Exact revision; never blind-retry after stale |
354
+ | Update an abstract property | `patchAbstract` reverse write | Temporary concrete patch when mapping is clear | Writing an “abstract record” | Maps to one concrete revision |
355
+ | Modify many records | Pipeline / batch with per-item revisions | Capture-all-then-write for tiny sets | Client update-many; list-mutate active sort | Partial success ledger |
356
+ | Create relationships | Relationship engine (discover / materialize / rebuild) | Dry-run / verify | Manual link inserts; `associated*` | Idempotent materialization |
357
+ | Inspect execution history | Operations / pipeline / Memory APIs | Studio Operate views | Treating ledgers as subject content | Operational identity |
358
+ | Inspect evidence / expected slots | `/api/data-journey/*` (matrix, coverage, evidence) | Studio Explore evidence UI | Inventing cells; treating journey rows as subject content | Read-only; views = slots only |
359
+ | Export large data | Asynchronous export artifact | Paginated offline consumer with checkpoint | Single-request dump | Export contract |
360
+ | Investigate once | Bounded ad-hoc API query | Studio Explore | Direct Mongo shell | Read-only unless labeled write |
361
+ | Save a repeated query | Metadata-defined view | Temporary client query | Hardcoded DB query in the product | Versioned with metadata |
362
+ | Repeated business process | Pipeline definition | Scheduled Memory + pipeline | UI-embedded “batch engine” | Durable run ledger |
363
+ | Propose new object type | Intelligence proposal → human install | Export draft for review | Intelligence auto-publish / AI writing records | Proposal ≠ live metadata |
364
+ | Secret to connector | `credentialRef` | — | Secret in body / Memory payload | Never log credentials |
365
+
366
+ ---
367
+
368
+ ## Also see
369
+
370
+ - **Lists, Queries, Pagination** (`03-lists-queries-pagination`) — List contracts, query grammar, cursors, page size, and multi-resource listing without foot-guns.
371
+
372
+ ---
373
+
374
+ _Generated use-case pack for agents and humans. See `agent-manifest.json` for discovery._