@manifesto-ai/lineage 0.1.1 → 3.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/README.md +29 -25
- package/dist/chunk-Q3WY563K.js +269 -0
- package/dist/chunk-Q3WY563K.js.map +1 -0
- package/dist/index.d.ts +7 -198
- package/dist/index.js +118 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +47 -0
- package/dist/internal.js +13 -0
- package/dist/internal.js.map +1 -0
- package/dist/runtime-types-CXAjv1Op.d.ts +220 -0
- package/package.json +11 -4
package/README.md
CHANGED
|
@@ -1,44 +1,48 @@
|
|
|
1
1
|
# @manifesto-ai/lineage
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Seal-aware continuity for the ADR-017 decorator runtime.
|
|
4
4
|
|
|
5
|
-
`@manifesto-ai/lineage` is the package
|
|
5
|
+
`@manifesto-ai/lineage` is the package that adds time, history, and restore to a composable manifesto.
|
|
6
6
|
|
|
7
|
-
> **Current Contract Note:** The current
|
|
7
|
+
> **Current Contract Note:** The truthful current package contract is [docs/lineage-SPEC-v3.0.0-draft.md](docs/lineage-SPEC-v3.0.0-draft.md). The v2 lineage spec remains as the historical service-first baseline.
|
|
8
8
|
|
|
9
9
|
## What This Package Owns
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
11
|
+
- `withLineage(createManifesto(...), config).activate()`
|
|
12
|
+
- lineage-aware `dispatchAsync` that seals before publication
|
|
13
|
+
- restore, head, branch, and world queries on the activated runtime
|
|
14
|
+
- `LineageStore`, `LineageService`, and sealing substrate
|
|
15
|
+
- deterministic world identity, branch semantics, and restore normalization
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## Canonical Path
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
```ts
|
|
20
|
+
import { createManifesto } from "@manifesto-ai/sdk";
|
|
21
|
+
import { withLineage, createInMemoryLineageStore } from "@manifesto-ai/lineage";
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const manifesto = createManifesto<CounterDomain>(schema, effects);
|
|
24
|
+
const world = withLineage(manifesto, {
|
|
25
|
+
store: createInMemoryLineageStore(),
|
|
26
|
+
}).activate();
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
await world.dispatchAsync(
|
|
29
|
+
world.createIntent(world.MEL.actions.increment),
|
|
30
|
+
);
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} from "@manifesto-ai/lineage";
|
|
33
|
-
|
|
34
|
-
const store = createInMemoryLineageStore();
|
|
35
|
-
const lineage = createLineageService(store);
|
|
32
|
+
const head = await world.getLatestHead();
|
|
33
|
+
if (head) {
|
|
34
|
+
await world.restore(head.worldId);
|
|
35
|
+
}
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
## Low-Level Usage
|
|
39
|
+
|
|
40
|
+
`LineageService` and `LineageStore` remain public. Use them directly when you need hashing, prepared commits, branch inspection, or custom persistence without the activated runtime wrapper.
|
|
41
|
+
|
|
38
42
|
## Docs
|
|
39
43
|
|
|
40
44
|
- [Docs Landing](docs/README.md)
|
|
41
45
|
- [Lineage Guide](docs/GUIDE.md)
|
|
42
|
-
- [Lineage Specification](docs/lineage-SPEC-
|
|
43
|
-
- [Historical
|
|
46
|
+
- [Lineage Specification](docs/lineage-SPEC-v3.0.0-draft.md)
|
|
47
|
+
- [Historical v2 Service-First SPEC](docs/lineage-SPEC-2.0.0v.md)
|
|
44
48
|
- [VERSION-INDEX](docs/VERSION-INDEX.md)
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
// src/internal.ts
|
|
2
|
+
import {
|
|
3
|
+
DisposedError,
|
|
4
|
+
ManifestoError
|
|
5
|
+
} from "@manifesto-ai/sdk";
|
|
6
|
+
var LINEAGE_DECORATION = /* @__PURE__ */ Symbol("manifesto-lineage.decoration");
|
|
7
|
+
function attachLineageDecoration(manifesto, decoration) {
|
|
8
|
+
Object.defineProperty(manifesto, LINEAGE_DECORATION, {
|
|
9
|
+
enumerable: false,
|
|
10
|
+
configurable: false,
|
|
11
|
+
writable: false,
|
|
12
|
+
value: decoration
|
|
13
|
+
});
|
|
14
|
+
return manifesto;
|
|
15
|
+
}
|
|
16
|
+
function getLineageDecoration(manifesto) {
|
|
17
|
+
const internal = manifesto;
|
|
18
|
+
return internal[LINEAGE_DECORATION] ?? null;
|
|
19
|
+
}
|
|
20
|
+
function createLineageRuntimeController(kernel, service, config) {
|
|
21
|
+
let readiness = null;
|
|
22
|
+
let currentBranchId = null;
|
|
23
|
+
let currentCompletedWorldId = null;
|
|
24
|
+
async function ensureReady() {
|
|
25
|
+
if (readiness) {
|
|
26
|
+
return readiness;
|
|
27
|
+
}
|
|
28
|
+
readiness = bootstrapLineage().catch((error) => {
|
|
29
|
+
readiness = null;
|
|
30
|
+
throw error;
|
|
31
|
+
});
|
|
32
|
+
return readiness;
|
|
33
|
+
}
|
|
34
|
+
async function bootstrapLineage() {
|
|
35
|
+
const branches = await service.getBranches();
|
|
36
|
+
if (branches.length === 0) {
|
|
37
|
+
if (config.branchId) {
|
|
38
|
+
throw new ManifestoError(
|
|
39
|
+
"LINEAGE_BRANCH_NOT_FOUND",
|
|
40
|
+
`Configured branch "${config.branchId}" does not exist in the lineage store`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
const genesisSnapshot = kernel.getVisibleCoreSnapshot();
|
|
44
|
+
const prepared = await service.prepareSealGenesis({
|
|
45
|
+
schemaHash: kernel.schema.hash,
|
|
46
|
+
terminalSnapshot: genesisSnapshot,
|
|
47
|
+
createdAt: genesisSnapshot.meta.timestamp
|
|
48
|
+
});
|
|
49
|
+
await service.commitPrepared(prepared);
|
|
50
|
+
currentBranchId = prepared.branchId;
|
|
51
|
+
currentCompletedWorldId = prepared.worldId;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const branch = await bindInitialBranch(config.branchId);
|
|
55
|
+
currentBranchId = branch.id;
|
|
56
|
+
currentCompletedWorldId = branch.head;
|
|
57
|
+
const restored = await service.restore(branch.head);
|
|
58
|
+
kernel.setVisibleSnapshot(restored, { notify: false });
|
|
59
|
+
}
|
|
60
|
+
async function bindInitialBranch(branchId) {
|
|
61
|
+
if (!branchId) {
|
|
62
|
+
return service.getActiveBranch();
|
|
63
|
+
}
|
|
64
|
+
const branch = await service.getBranch(branchId);
|
|
65
|
+
if (!branch) {
|
|
66
|
+
throw new ManifestoError(
|
|
67
|
+
"LINEAGE_BRANCH_NOT_FOUND",
|
|
68
|
+
`Configured branch "${branchId}" does not exist in the lineage store`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
const activeBranch = await service.getActiveBranch();
|
|
72
|
+
if (activeBranch.id !== branch.id) {
|
|
73
|
+
await service.switchActiveBranch(branch.id);
|
|
74
|
+
}
|
|
75
|
+
return branch;
|
|
76
|
+
}
|
|
77
|
+
async function sealIntent(intent, options) {
|
|
78
|
+
if (kernel.isDisposed()) {
|
|
79
|
+
throw new DisposedError();
|
|
80
|
+
}
|
|
81
|
+
const enrichedIntent = kernel.ensureIntentId(intent);
|
|
82
|
+
const runSeal = async () => {
|
|
83
|
+
if (kernel.isDisposed()) {
|
|
84
|
+
throw new DisposedError();
|
|
85
|
+
}
|
|
86
|
+
await ensureReady();
|
|
87
|
+
if (!kernel.isActionAvailable(enrichedIntent.type)) {
|
|
88
|
+
return kernel.rejectUnavailable(enrichedIntent);
|
|
89
|
+
}
|
|
90
|
+
let result;
|
|
91
|
+
try {
|
|
92
|
+
result = await kernel.executeHost(enrichedIntent);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
kernel.restoreVisibleSnapshot();
|
|
95
|
+
throw toError(error);
|
|
96
|
+
}
|
|
97
|
+
if (!currentBranchId || !currentCompletedWorldId) {
|
|
98
|
+
kernel.restoreVisibleSnapshot();
|
|
99
|
+
throw new ManifestoError(
|
|
100
|
+
"LINEAGE_STATE_ERROR",
|
|
101
|
+
"Lineage runtime has no active branch continuity after bootstrap"
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
let prepared;
|
|
105
|
+
try {
|
|
106
|
+
prepared = await service.prepareSealNext({
|
|
107
|
+
schemaHash: kernel.schema.hash,
|
|
108
|
+
baseWorldId: currentCompletedWorldId,
|
|
109
|
+
branchId: currentBranchId,
|
|
110
|
+
terminalSnapshot: result.snapshot,
|
|
111
|
+
createdAt: result.snapshot.meta.timestamp,
|
|
112
|
+
...options?.proposalRef ? { proposalRef: options.proposalRef } : {},
|
|
113
|
+
...options?.decisionRef ? { decisionRef: options.decisionRef } : {}
|
|
114
|
+
});
|
|
115
|
+
await service.commitPrepared(prepared);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
kernel.restoreVisibleSnapshot();
|
|
118
|
+
throw toError(error);
|
|
119
|
+
}
|
|
120
|
+
if (prepared.branchChange.headAdvanced) {
|
|
121
|
+
currentCompletedWorldId = prepared.worldId;
|
|
122
|
+
}
|
|
123
|
+
if (prepared.branchChange.headAdvanced && options?.publishOnCompleted !== false) {
|
|
124
|
+
return {
|
|
125
|
+
intent: enrichedIntent,
|
|
126
|
+
hostResult: result,
|
|
127
|
+
preparedCommit: prepared,
|
|
128
|
+
publishedSnapshot: kernel.setVisibleSnapshot(result.snapshot)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
kernel.restoreVisibleSnapshot();
|
|
132
|
+
return {
|
|
133
|
+
intent: enrichedIntent,
|
|
134
|
+
hostResult: result,
|
|
135
|
+
preparedCommit: prepared
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
if (options?.assumeEnqueued) {
|
|
139
|
+
return runSeal();
|
|
140
|
+
}
|
|
141
|
+
return kernel.enqueue(runSeal);
|
|
142
|
+
}
|
|
143
|
+
async function getWorld(worldId) {
|
|
144
|
+
await ensureReady();
|
|
145
|
+
return service.getWorld(worldId);
|
|
146
|
+
}
|
|
147
|
+
async function getLatestHead() {
|
|
148
|
+
await ensureReady();
|
|
149
|
+
return service.getLatestHead();
|
|
150
|
+
}
|
|
151
|
+
async function getHeads() {
|
|
152
|
+
await ensureReady();
|
|
153
|
+
return service.getHeads();
|
|
154
|
+
}
|
|
155
|
+
async function getBranches() {
|
|
156
|
+
await ensureReady();
|
|
157
|
+
return service.getBranches();
|
|
158
|
+
}
|
|
159
|
+
async function getActiveBranch() {
|
|
160
|
+
await ensureReady();
|
|
161
|
+
if (currentBranchId) {
|
|
162
|
+
const branch = await service.getBranch(currentBranchId);
|
|
163
|
+
if (branch) {
|
|
164
|
+
return branch;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return service.getActiveBranch();
|
|
168
|
+
}
|
|
169
|
+
async function getCurrentBranchId() {
|
|
170
|
+
return (await getActiveBranch()).id;
|
|
171
|
+
}
|
|
172
|
+
async function getCurrentCompletedWorldId() {
|
|
173
|
+
await ensureReady();
|
|
174
|
+
if (!currentCompletedWorldId) {
|
|
175
|
+
throw new ManifestoError(
|
|
176
|
+
"LINEAGE_STATE_ERROR",
|
|
177
|
+
"Lineage runtime has no completed world continuity"
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
return currentCompletedWorldId;
|
|
181
|
+
}
|
|
182
|
+
async function restore(worldId) {
|
|
183
|
+
if (kernel.isDisposed()) {
|
|
184
|
+
throw new DisposedError();
|
|
185
|
+
}
|
|
186
|
+
await kernel.enqueue(async () => {
|
|
187
|
+
if (kernel.isDisposed()) {
|
|
188
|
+
throw new DisposedError();
|
|
189
|
+
}
|
|
190
|
+
await ensureReady();
|
|
191
|
+
const restored = await service.restore(worldId);
|
|
192
|
+
kernel.setVisibleSnapshot(restored);
|
|
193
|
+
currentCompletedWorldId = worldId;
|
|
194
|
+
const branches = await service.getBranches();
|
|
195
|
+
const matchingBranch = branches.find((branch) => branch.head === worldId);
|
|
196
|
+
if (matchingBranch) {
|
|
197
|
+
currentBranchId = matchingBranch.id;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
async function switchActiveBranch(branchId) {
|
|
202
|
+
if (kernel.isDisposed()) {
|
|
203
|
+
throw new DisposedError();
|
|
204
|
+
}
|
|
205
|
+
return kernel.enqueue(async () => {
|
|
206
|
+
if (kernel.isDisposed()) {
|
|
207
|
+
throw new DisposedError();
|
|
208
|
+
}
|
|
209
|
+
await ensureReady();
|
|
210
|
+
const result = await service.switchActiveBranch(branchId);
|
|
211
|
+
const branch = await service.getBranch(branchId);
|
|
212
|
+
if (!branch) {
|
|
213
|
+
throw new ManifestoError(
|
|
214
|
+
"LINEAGE_BRANCH_NOT_FOUND",
|
|
215
|
+
`Cannot switch to unknown branch "${branchId}"`
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
const restored = await service.restore(branch.head);
|
|
219
|
+
kernel.setVisibleSnapshot(restored);
|
|
220
|
+
currentBranchId = branch.id;
|
|
221
|
+
currentCompletedWorldId = branch.head;
|
|
222
|
+
return result;
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
async function createBranch(name, fromWorldId) {
|
|
226
|
+
if (kernel.isDisposed()) {
|
|
227
|
+
throw new DisposedError();
|
|
228
|
+
}
|
|
229
|
+
return kernel.enqueue(async () => {
|
|
230
|
+
if (kernel.isDisposed()) {
|
|
231
|
+
throw new DisposedError();
|
|
232
|
+
}
|
|
233
|
+
await ensureReady();
|
|
234
|
+
const headWorldId = fromWorldId ?? currentCompletedWorldId;
|
|
235
|
+
if (!headWorldId) {
|
|
236
|
+
throw new ManifestoError(
|
|
237
|
+
"LINEAGE_STATE_ERROR",
|
|
238
|
+
"Cannot create a branch before lineage continuity is bootstrapped"
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
return service.createBranch(name, headWorldId);
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
ensureReady,
|
|
246
|
+
sealIntent,
|
|
247
|
+
getWorld,
|
|
248
|
+
getLatestHead,
|
|
249
|
+
getHeads,
|
|
250
|
+
getBranches,
|
|
251
|
+
getActiveBranch,
|
|
252
|
+
getCurrentBranchId,
|
|
253
|
+
getCurrentCompletedWorldId,
|
|
254
|
+
restore,
|
|
255
|
+
switchActiveBranch,
|
|
256
|
+
createBranch
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function toError(error) {
|
|
260
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export {
|
|
264
|
+
LINEAGE_DECORATION,
|
|
265
|
+
attachLineageDecoration,
|
|
266
|
+
getLineageDecoration,
|
|
267
|
+
createLineageRuntimeController
|
|
268
|
+
};
|
|
269
|
+
//# sourceMappingURL=chunk-Q3WY563K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internal.ts"],"sourcesContent":["import {\n DisposedError,\n ManifestoError,\n type BaseLaws,\n type ComposableManifesto,\n type LineageLaws,\n type ManifestoDomainShape,\n type Snapshot,\n} from \"@manifesto-ai/sdk\";\nimport type { RuntimeKernel } from \"@manifesto-ai/sdk/internal\";\nimport type { Intent } from \"@manifesto-ai/core\";\n\nimport type { LineageConfig } from \"./runtime-types.js\";\nimport type {\n BranchId,\n BranchInfo,\n BranchSwitchResult,\n LineageService,\n PreparedNextCommit,\n World,\n WorldHead,\n WorldId,\n} from \"./types.js\";\n\nexport const LINEAGE_DECORATION = Symbol(\"manifesto-lineage.decoration\");\n\nexport type ResolvedLineageConfig = LineageConfig & {\n readonly service: LineageService;\n};\n\nexport type LineageDecoration = {\n readonly service: LineageService;\n readonly config: ResolvedLineageConfig;\n};\n\nexport type InternalLineageComposableManifesto<\n T extends ManifestoDomainShape,\n Laws extends BaseLaws,\n> = ComposableManifesto<T, Laws & LineageLaws> & {\n readonly [LINEAGE_DECORATION]: LineageDecoration;\n};\n\nexport type SealIntentOptions = {\n readonly proposalRef?: string;\n readonly decisionRef?: string;\n readonly publishOnCompleted?: boolean;\n readonly assumeEnqueued?: boolean;\n};\n\nexport type SealedIntentResult<T extends ManifestoDomainShape> = {\n readonly intent: Intent;\n readonly hostResult: Awaited<ReturnType<RuntimeKernel<T>[\"executeHost\"]>>;\n readonly preparedCommit: PreparedNextCommit;\n readonly publishedSnapshot?: Snapshot<T[\"state\"]>;\n};\n\nexport interface LineageRuntimeController<T extends ManifestoDomainShape> {\n ensureReady(): Promise<void>;\n sealIntent(\n intent: Intent,\n options?: SealIntentOptions,\n ): Promise<SealedIntentResult<T>>;\n getWorld(worldId: WorldId): Promise<World | null>;\n getLatestHead(): Promise<WorldHead | null>;\n getHeads(): Promise<readonly WorldHead[]>;\n getBranches(): Promise<readonly BranchInfo[]>;\n getActiveBranch(): Promise<BranchInfo>;\n getCurrentBranchId(): Promise<BranchId>;\n getCurrentCompletedWorldId(): Promise<WorldId>;\n restore(worldId: WorldId): Promise<void>;\n switchActiveBranch(branchId: BranchId): Promise<BranchSwitchResult>;\n createBranch(name: string, fromWorldId?: WorldId): Promise<BranchId>;\n}\n\nexport function attachLineageDecoration<\n T extends ManifestoDomainShape,\n Laws extends BaseLaws,\n>(\n manifesto: ComposableManifesto<T, Laws & LineageLaws>,\n decoration: LineageDecoration,\n): InternalLineageComposableManifesto<T, Laws> {\n Object.defineProperty(manifesto, LINEAGE_DECORATION, {\n enumerable: false,\n configurable: false,\n writable: false,\n value: decoration,\n });\n\n return manifesto as InternalLineageComposableManifesto<T, Laws>;\n}\n\nexport function getLineageDecoration<\n T extends ManifestoDomainShape,\n Laws extends BaseLaws,\n>(\n manifesto: ComposableManifesto<T, Laws>,\n): LineageDecoration | null {\n const internal = manifesto as Partial<InternalLineageComposableManifesto<T, Laws>>;\n return internal[LINEAGE_DECORATION] ?? null;\n}\n\nexport function createLineageRuntimeController<T extends ManifestoDomainShape>(\n kernel: RuntimeKernel<T>,\n service: LineageService,\n config: ResolvedLineageConfig,\n): LineageRuntimeController<T> {\n let readiness: Promise<void> | null = null;\n let currentBranchId: string | null = null;\n let currentCompletedWorldId: WorldId | null = null;\n\n async function ensureReady(): Promise<void> {\n if (readiness) {\n return readiness;\n }\n\n readiness = bootstrapLineage().catch((error) => {\n readiness = null;\n throw error;\n });\n\n return readiness;\n }\n\n async function bootstrapLineage(): Promise<void> {\n const branches = await service.getBranches();\n if (branches.length === 0) {\n if (config.branchId) {\n throw new ManifestoError(\n \"LINEAGE_BRANCH_NOT_FOUND\",\n `Configured branch \"${config.branchId}\" does not exist in the lineage store`,\n );\n }\n\n const genesisSnapshot = kernel.getVisibleCoreSnapshot();\n const prepared = await service.prepareSealGenesis({\n schemaHash: kernel.schema.hash,\n terminalSnapshot: genesisSnapshot,\n createdAt: genesisSnapshot.meta.timestamp,\n });\n await service.commitPrepared(prepared);\n currentBranchId = prepared.branchId;\n currentCompletedWorldId = prepared.worldId;\n return;\n }\n\n const branch = await bindInitialBranch(config.branchId);\n currentBranchId = branch.id;\n currentCompletedWorldId = branch.head;\n const restored = await service.restore(branch.head);\n kernel.setVisibleSnapshot(restored, { notify: false });\n }\n\n async function bindInitialBranch(branchId?: string): Promise<BranchInfo> {\n if (!branchId) {\n return service.getActiveBranch();\n }\n\n const branch = await service.getBranch(branchId);\n if (!branch) {\n throw new ManifestoError(\n \"LINEAGE_BRANCH_NOT_FOUND\",\n `Configured branch \"${branchId}\" does not exist in the lineage store`,\n );\n }\n\n const activeBranch = await service.getActiveBranch();\n if (activeBranch.id !== branch.id) {\n await service.switchActiveBranch(branch.id);\n }\n\n return branch;\n }\n\n async function sealIntent(\n intent: Intent,\n options?: SealIntentOptions,\n ): Promise<SealedIntentResult<T>> {\n if (kernel.isDisposed()) {\n throw new DisposedError();\n }\n\n const enrichedIntent = kernel.ensureIntentId(intent);\n\n const runSeal = async () => {\n if (kernel.isDisposed()) {\n throw new DisposedError();\n }\n\n await ensureReady();\n\n if (!kernel.isActionAvailable(enrichedIntent.type as keyof T[\"actions\"])) {\n return kernel.rejectUnavailable(enrichedIntent);\n }\n\n let result: Awaited<ReturnType<RuntimeKernel<T>[\"executeHost\"]>>;\n try {\n result = await kernel.executeHost(enrichedIntent);\n } catch (error) {\n kernel.restoreVisibleSnapshot();\n throw toError(error);\n }\n\n if (!currentBranchId || !currentCompletedWorldId) {\n kernel.restoreVisibleSnapshot();\n throw new ManifestoError(\n \"LINEAGE_STATE_ERROR\",\n \"Lineage runtime has no active branch continuity after bootstrap\",\n );\n }\n\n let prepared: PreparedNextCommit;\n try {\n prepared = await service.prepareSealNext({\n schemaHash: kernel.schema.hash,\n baseWorldId: currentCompletedWorldId,\n branchId: currentBranchId,\n terminalSnapshot: result.snapshot,\n createdAt: result.snapshot.meta.timestamp,\n ...(options?.proposalRef ? { proposalRef: options.proposalRef } : {}),\n ...(options?.decisionRef ? { decisionRef: options.decisionRef } : {}),\n });\n await service.commitPrepared(prepared);\n } catch (error) {\n kernel.restoreVisibleSnapshot();\n throw toError(error);\n }\n\n if (prepared.branchChange.headAdvanced) {\n currentCompletedWorldId = prepared.worldId;\n }\n\n if (prepared.branchChange.headAdvanced && options?.publishOnCompleted !== false) {\n return {\n intent: enrichedIntent,\n hostResult: result,\n preparedCommit: prepared,\n publishedSnapshot: kernel.setVisibleSnapshot(result.snapshot),\n };\n }\n\n kernel.restoreVisibleSnapshot();\n return {\n intent: enrichedIntent,\n hostResult: result,\n preparedCommit: prepared,\n };\n };\n\n if (options?.assumeEnqueued) {\n return runSeal();\n }\n\n return kernel.enqueue(runSeal);\n }\n\n async function getWorld(worldId: WorldId): Promise<World | null> {\n await ensureReady();\n return service.getWorld(worldId);\n }\n\n async function getLatestHead(): Promise<WorldHead | null> {\n await ensureReady();\n return service.getLatestHead();\n }\n\n async function getHeads(): Promise<readonly WorldHead[]> {\n await ensureReady();\n return service.getHeads();\n }\n\n async function getBranches(): Promise<readonly BranchInfo[]> {\n await ensureReady();\n return service.getBranches();\n }\n\n async function getActiveBranch(): Promise<BranchInfo> {\n await ensureReady();\n if (currentBranchId) {\n const branch = await service.getBranch(currentBranchId);\n if (branch) {\n return branch;\n }\n }\n return service.getActiveBranch();\n }\n\n async function getCurrentBranchId(): Promise<BranchId> {\n return (await getActiveBranch()).id;\n }\n\n async function getCurrentCompletedWorldId(): Promise<WorldId> {\n await ensureReady();\n if (!currentCompletedWorldId) {\n throw new ManifestoError(\n \"LINEAGE_STATE_ERROR\",\n \"Lineage runtime has no completed world continuity\",\n );\n }\n return currentCompletedWorldId;\n }\n\n async function restore(worldId: WorldId): Promise<void> {\n if (kernel.isDisposed()) {\n throw new DisposedError();\n }\n\n await kernel.enqueue(async () => {\n if (kernel.isDisposed()) {\n throw new DisposedError();\n }\n\n await ensureReady();\n const restored = await service.restore(worldId);\n kernel.setVisibleSnapshot(restored);\n currentCompletedWorldId = worldId;\n\n const branches = await service.getBranches();\n const matchingBranch = branches.find((branch) => branch.head === worldId);\n if (matchingBranch) {\n currentBranchId = matchingBranch.id;\n }\n });\n }\n\n async function switchActiveBranch(branchId: string): Promise<BranchSwitchResult> {\n if (kernel.isDisposed()) {\n throw new DisposedError();\n }\n\n return kernel.enqueue(async () => {\n if (kernel.isDisposed()) {\n throw new DisposedError();\n }\n\n await ensureReady();\n const result = await service.switchActiveBranch(branchId);\n const branch = await service.getBranch(branchId);\n\n if (!branch) {\n throw new ManifestoError(\n \"LINEAGE_BRANCH_NOT_FOUND\",\n `Cannot switch to unknown branch \"${branchId}\"`,\n );\n }\n\n const restored = await service.restore(branch.head);\n kernel.setVisibleSnapshot(restored);\n currentBranchId = branch.id;\n currentCompletedWorldId = branch.head;\n return result;\n });\n }\n\n async function createBranch(name: string, fromWorldId?: WorldId): Promise<BranchId> {\n if (kernel.isDisposed()) {\n throw new DisposedError();\n }\n\n return kernel.enqueue(async () => {\n if (kernel.isDisposed()) {\n throw new DisposedError();\n }\n\n await ensureReady();\n const headWorldId = fromWorldId ?? currentCompletedWorldId;\n if (!headWorldId) {\n throw new ManifestoError(\n \"LINEAGE_STATE_ERROR\",\n \"Cannot create a branch before lineage continuity is bootstrapped\",\n );\n }\n\n return service.createBranch(name, headWorldId);\n });\n }\n\n return {\n ensureReady,\n sealIntent,\n getWorld,\n getLatestHead,\n getHeads,\n getBranches,\n getActiveBranch,\n getCurrentBranchId,\n getCurrentCompletedWorldId,\n restore,\n switchActiveBranch,\n createBranch,\n };\n}\n\nfunction toError(error: unknown): Error {\n return error instanceof Error\n ? error\n : new Error(String(error));\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAMK;AAgBA,IAAM,qBAAqB,uBAAO,8BAA8B;AAkDhE,SAAS,wBAId,WACA,YAC6C;AAC7C,SAAO,eAAe,WAAW,oBAAoB;AAAA,IACnD,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,UAAU;AAAA,IACV,OAAO;AAAA,EACT,CAAC;AAED,SAAO;AACT;AAEO,SAAS,qBAId,WAC0B;AAC1B,QAAM,WAAW;AACjB,SAAO,SAAS,kBAAkB,KAAK;AACzC;AAEO,SAAS,+BACd,QACA,SACA,QAC6B;AAC7B,MAAI,YAAkC;AACtC,MAAI,kBAAiC;AACrC,MAAI,0BAA0C;AAE9C,iBAAe,cAA6B;AAC1C,QAAI,WAAW;AACb,aAAO;AAAA,IACT;AAEA,gBAAY,iBAAiB,EAAE,MAAM,CAAC,UAAU;AAC9C,kBAAY;AACZ,YAAM;AAAA,IACR,CAAC;AAED,WAAO;AAAA,EACT;AAEA,iBAAe,mBAAkC;AAC/C,UAAM,WAAW,MAAM,QAAQ,YAAY;AAC3C,QAAI,SAAS,WAAW,GAAG;AACzB,UAAI,OAAO,UAAU;AACnB,cAAM,IAAI;AAAA,UACR;AAAA,UACA,sBAAsB,OAAO,QAAQ;AAAA,QACvC;AAAA,MACF;AAEA,YAAM,kBAAkB,OAAO,uBAAuB;AACtD,YAAM,WAAW,MAAM,QAAQ,mBAAmB;AAAA,QAChD,YAAY,OAAO,OAAO;AAAA,QAC1B,kBAAkB;AAAA,QAClB,WAAW,gBAAgB,KAAK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,mBAAmB,QAAQ;AACxD,YAAM,SAAS,MAAM,QAAQ,UAAU,QAAQ;AAE/C,UAAI,CAAC,QAAQ;AACX,cAAM,IAAI;AAAA,UACR;AAAA,UACA,oCAAoC,QAAQ;AAAA,QAC9C;AAAA,MACF;AAEA,YAAM,WAAW,MAAM,QAAQ,QAAQ,OAAO,IAAI;AAClD,aAAO,mBAAmB,QAAQ;AAClC,wBAAkB,OAAO;AACzB,gCAA0B,OAAO;AACjC,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAEA,iBAAe,aAAa,MAAc,aAA0C;AAClF,QAAI,OAAO,WAAW,GAAG;AACvB,YAAM,IAAI,cAAc;AAAA,IAC1B;AAEA,WAAO,OAAO,QAAQ,YAAY;AAChC,UAAI,OAAO,WAAW,GAAG;AACvB,cAAM,IAAI,cAAc;AAAA,MAC1B;AAEA,YAAM,YAAY;AAClB,YAAM,cAAc,eAAe;AACnC,UAAI,CAAC,aAAa;AAChB,cAAM,IAAI;AAAA,UACR;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAEA,aAAO,QAAQ,aAAa,MAAM,WAAW;AAAA,IAC/C,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,SAAS,QAAQ,OAAuB;AACtC,SAAO,iBAAiB,QACpB,QACA,IAAI,MAAM,OAAO,KAAK,CAAC;AAC7B;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,201 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { W as WorldId, T as TerminalStatus, C as CurrentErrorSignature, S as SnapshotHashInput, a as World, b as WorldEdge, B as BranchId, c as SealGenesisInput, d as SealAttempt, e as SealNextInput, P as PersistedBranchEntry, f as BranchInfo, g as WorldHead, L as LineageStore, h as WorldLineage, i as PreparedBranchMutation, j as PreparedLineageCommit, k as LineageService, l as BranchSwitchResult, m as LineageConfig, n as LineageComposableManifesto } from './runtime-types-CXAjv1Op.js';
|
|
2
|
+
export { q as ArtifactRef, A as AttemptId, y as LineageInstance, s as PersistedBranchState, r as PersistedPatchDeltaV2, t as PreparedBranchBootstrap, u as PreparedBranchChange, w as PreparedGenesisCommit, v as PreparedLineageRecords, x as PreparedNextCommit, p as ProvenanceRef, o as SchemaHash } from './runtime-types-CXAjv1Op.js';
|
|
3
|
+
import { Snapshot, ErrorValue, Requirement } from '@manifesto-ai/core';
|
|
2
4
|
export { Patch, Snapshot } from '@manifesto-ai/core';
|
|
3
|
-
|
|
4
|
-
type WorldId = string;
|
|
5
|
-
type BranchId = string;
|
|
6
|
-
type SchemaHash = string;
|
|
7
|
-
type ProvenanceRef = string;
|
|
8
|
-
type AttemptId = string;
|
|
9
|
-
interface ArtifactRef {
|
|
10
|
-
readonly uri: string;
|
|
11
|
-
readonly hash: string;
|
|
12
|
-
}
|
|
13
|
-
type TerminalStatus = "completed" | "failed";
|
|
14
|
-
interface CurrentErrorSignature {
|
|
15
|
-
readonly code: string;
|
|
16
|
-
readonly source: {
|
|
17
|
-
readonly actionId: string;
|
|
18
|
-
readonly nodePath: string;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
interface SnapshotHashInput {
|
|
22
|
-
readonly data: Record<string, unknown>;
|
|
23
|
-
readonly system: {
|
|
24
|
-
readonly terminalStatus: TerminalStatus;
|
|
25
|
-
readonly currentError: CurrentErrorSignature | null;
|
|
26
|
-
readonly pendingDigest: string;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
interface World {
|
|
30
|
-
readonly worldId: WorldId;
|
|
31
|
-
readonly schemaHash: SchemaHash;
|
|
32
|
-
readonly snapshotHash: string;
|
|
33
|
-
readonly parentWorldId: WorldId | null;
|
|
34
|
-
readonly terminalStatus: TerminalStatus;
|
|
35
|
-
}
|
|
36
|
-
interface WorldEdge {
|
|
37
|
-
readonly edgeId: string;
|
|
38
|
-
readonly from: WorldId;
|
|
39
|
-
readonly to: WorldId;
|
|
40
|
-
}
|
|
41
|
-
interface WorldLineage {
|
|
42
|
-
readonly genesis: WorldId;
|
|
43
|
-
readonly worlds: ReadonlyMap<WorldId, World>;
|
|
44
|
-
readonly edges: ReadonlyMap<string, WorldEdge>;
|
|
45
|
-
}
|
|
46
|
-
interface PersistedPatchDeltaV2 {
|
|
47
|
-
readonly _patchFormat: 2;
|
|
48
|
-
readonly patches: readonly Patch[];
|
|
49
|
-
}
|
|
50
|
-
interface SealGenesisInput {
|
|
51
|
-
readonly schemaHash: SchemaHash;
|
|
52
|
-
readonly terminalSnapshot: Snapshot;
|
|
53
|
-
readonly createdAt: number;
|
|
54
|
-
readonly branchName?: string;
|
|
55
|
-
readonly proposalRef?: ProvenanceRef;
|
|
56
|
-
readonly traceRef?: ArtifactRef;
|
|
57
|
-
}
|
|
58
|
-
interface SealNextInput {
|
|
59
|
-
readonly schemaHash: SchemaHash;
|
|
60
|
-
readonly baseWorldId: WorldId;
|
|
61
|
-
readonly branchId: BranchId;
|
|
62
|
-
readonly terminalSnapshot: Snapshot;
|
|
63
|
-
readonly createdAt: number;
|
|
64
|
-
readonly patchDelta?: PersistedPatchDeltaV2;
|
|
65
|
-
readonly proposalRef?: ProvenanceRef;
|
|
66
|
-
readonly decisionRef?: ProvenanceRef;
|
|
67
|
-
readonly traceRef?: ArtifactRef;
|
|
68
|
-
}
|
|
69
|
-
interface BranchInfo {
|
|
70
|
-
readonly id: BranchId;
|
|
71
|
-
readonly name: string;
|
|
72
|
-
readonly head: WorldId;
|
|
73
|
-
readonly tip: WorldId;
|
|
74
|
-
readonly headAdvancedAt: number;
|
|
75
|
-
readonly epoch: number;
|
|
76
|
-
readonly schemaHash: SchemaHash;
|
|
77
|
-
readonly createdAt: number;
|
|
78
|
-
}
|
|
79
|
-
interface PersistedBranchEntry {
|
|
80
|
-
readonly id: BranchId;
|
|
81
|
-
readonly name: string;
|
|
82
|
-
readonly head: WorldId;
|
|
83
|
-
readonly tip: WorldId;
|
|
84
|
-
readonly headAdvancedAt: number;
|
|
85
|
-
readonly epoch: number;
|
|
86
|
-
readonly schemaHash: SchemaHash;
|
|
87
|
-
readonly createdAt: number;
|
|
88
|
-
}
|
|
89
|
-
interface PersistedBranchState {
|
|
90
|
-
readonly branches: readonly PersistedBranchEntry[];
|
|
91
|
-
readonly activeBranchId: BranchId;
|
|
92
|
-
}
|
|
93
|
-
interface WorldHead {
|
|
94
|
-
readonly worldId: WorldId;
|
|
95
|
-
readonly branchId: BranchId;
|
|
96
|
-
readonly branchName: string;
|
|
97
|
-
readonly createdAt: number;
|
|
98
|
-
readonly schemaHash: SchemaHash;
|
|
99
|
-
}
|
|
100
|
-
interface BranchSwitchResult {
|
|
101
|
-
readonly previousBranchId: BranchId;
|
|
102
|
-
readonly targetBranchId: BranchId;
|
|
103
|
-
readonly sourceBranchEpochAfter: number;
|
|
104
|
-
}
|
|
105
|
-
interface PreparedBranchMutation {
|
|
106
|
-
readonly kind: "advance";
|
|
107
|
-
readonly branchId: BranchId;
|
|
108
|
-
readonly expectedHead: WorldId;
|
|
109
|
-
readonly nextHead: WorldId;
|
|
110
|
-
readonly headAdvanced: boolean;
|
|
111
|
-
readonly expectedTip: WorldId;
|
|
112
|
-
readonly nextTip: WorldId;
|
|
113
|
-
readonly headAdvancedAt: number | null;
|
|
114
|
-
readonly expectedEpoch: number;
|
|
115
|
-
readonly nextEpoch: number;
|
|
116
|
-
}
|
|
117
|
-
interface PreparedBranchBootstrap {
|
|
118
|
-
readonly kind: "bootstrap";
|
|
119
|
-
readonly branch: PersistedBranchEntry;
|
|
120
|
-
readonly activeBranchId: BranchId;
|
|
121
|
-
}
|
|
122
|
-
type PreparedBranchChange = PreparedBranchMutation | PreparedBranchBootstrap;
|
|
123
|
-
interface SealAttempt {
|
|
124
|
-
readonly attemptId: AttemptId;
|
|
125
|
-
readonly worldId: WorldId;
|
|
126
|
-
readonly branchId: BranchId;
|
|
127
|
-
readonly baseWorldId: WorldId | null;
|
|
128
|
-
readonly parentWorldId: WorldId | null;
|
|
129
|
-
readonly proposalRef?: ProvenanceRef;
|
|
130
|
-
readonly decisionRef?: ProvenanceRef;
|
|
131
|
-
readonly createdAt: number;
|
|
132
|
-
readonly traceRef?: ArtifactRef;
|
|
133
|
-
readonly patchDelta?: PersistedPatchDeltaV2;
|
|
134
|
-
readonly reused: boolean;
|
|
135
|
-
}
|
|
136
|
-
interface PreparedLineageRecords {
|
|
137
|
-
readonly worldId: WorldId;
|
|
138
|
-
readonly world: World;
|
|
139
|
-
readonly terminalSnapshot: Snapshot;
|
|
140
|
-
readonly hashInput: SnapshotHashInput;
|
|
141
|
-
readonly attempt: SealAttempt;
|
|
142
|
-
}
|
|
143
|
-
interface PreparedGenesisCommit extends PreparedLineageRecords {
|
|
144
|
-
readonly kind: "genesis";
|
|
145
|
-
readonly branchId: BranchId;
|
|
146
|
-
readonly terminalStatus: "completed";
|
|
147
|
-
readonly edge: null;
|
|
148
|
-
readonly branchChange: PreparedBranchBootstrap;
|
|
149
|
-
}
|
|
150
|
-
interface PreparedNextCommit extends PreparedLineageRecords {
|
|
151
|
-
readonly kind: "next";
|
|
152
|
-
readonly branchId: BranchId;
|
|
153
|
-
readonly terminalStatus: TerminalStatus;
|
|
154
|
-
readonly edge: WorldEdge;
|
|
155
|
-
readonly forkCreated: boolean;
|
|
156
|
-
readonly branchChange: PreparedBranchMutation;
|
|
157
|
-
}
|
|
158
|
-
type PreparedLineageCommit = PreparedGenesisCommit | PreparedNextCommit;
|
|
159
|
-
interface LineageStore {
|
|
160
|
-
putWorld(world: World): Promise<void>;
|
|
161
|
-
getWorld(worldId: WorldId): Promise<World | null>;
|
|
162
|
-
putSnapshot(worldId: WorldId, snapshot: Snapshot): Promise<void>;
|
|
163
|
-
getSnapshot(worldId: WorldId): Promise<Snapshot | null>;
|
|
164
|
-
putAttempt(attempt: SealAttempt): Promise<void>;
|
|
165
|
-
getAttempts(worldId: WorldId): Promise<readonly SealAttempt[]>;
|
|
166
|
-
getAttemptsByBranch(branchId: BranchId): Promise<readonly SealAttempt[]>;
|
|
167
|
-
putHashInput?(snapshotHash: string, input: SnapshotHashInput): Promise<void>;
|
|
168
|
-
getHashInput?(snapshotHash: string): Promise<SnapshotHashInput | null>;
|
|
169
|
-
putEdge(edge: WorldEdge): Promise<void>;
|
|
170
|
-
getEdges(worldId: WorldId): Promise<readonly WorldEdge[]>;
|
|
171
|
-
getBranchHead(branchId: BranchId): Promise<WorldId | null>;
|
|
172
|
-
getBranchTip(branchId: BranchId): Promise<WorldId | null>;
|
|
173
|
-
getBranchEpoch(branchId: BranchId): Promise<number>;
|
|
174
|
-
mutateBranch(mutation: PreparedBranchMutation): Promise<void>;
|
|
175
|
-
putBranch(branch: PersistedBranchEntry): Promise<void>;
|
|
176
|
-
getBranches(): Promise<readonly PersistedBranchEntry[]>;
|
|
177
|
-
getActiveBranchId(): Promise<BranchId | null>;
|
|
178
|
-
switchActiveBranch(sourceBranchId: BranchId, targetBranchId: BranchId): Promise<void>;
|
|
179
|
-
commitPrepared(prepared: PreparedLineageCommit): Promise<void>;
|
|
180
|
-
}
|
|
181
|
-
interface LineageService {
|
|
182
|
-
prepareSealGenesis(input: SealGenesisInput): Promise<PreparedGenesisCommit>;
|
|
183
|
-
prepareSealNext(input: SealNextInput): Promise<PreparedNextCommit>;
|
|
184
|
-
commitPrepared(prepared: PreparedLineageCommit): Promise<void>;
|
|
185
|
-
createBranch(name: string, headWorldId: WorldId): Promise<BranchId>;
|
|
186
|
-
getBranch(branchId: BranchId): Promise<BranchInfo | null>;
|
|
187
|
-
getBranches(): Promise<readonly BranchInfo[]>;
|
|
188
|
-
getActiveBranch(): Promise<BranchInfo>;
|
|
189
|
-
switchActiveBranch(targetBranchId: BranchId): Promise<BranchSwitchResult>;
|
|
190
|
-
getWorld(worldId: WorldId): Promise<World | null>;
|
|
191
|
-
getSnapshot(worldId: WorldId): Promise<Snapshot | null>;
|
|
192
|
-
getAttempts(worldId: WorldId): Promise<readonly SealAttempt[]>;
|
|
193
|
-
getAttemptsByBranch(branchId: BranchId): Promise<readonly SealAttempt[]>;
|
|
194
|
-
getLineage(): Promise<WorldLineage>;
|
|
195
|
-
getHeads(): Promise<readonly WorldHead[]>;
|
|
196
|
-
getLatestHead(): Promise<WorldHead | null>;
|
|
197
|
-
restore(worldId: WorldId): Promise<Snapshot>;
|
|
198
|
-
}
|
|
5
|
+
import { ManifestoDomainShape, BaseLaws, ComposableManifesto } from '@manifesto-ai/sdk';
|
|
199
6
|
|
|
200
7
|
declare function computeHash(value: unknown): string;
|
|
201
8
|
declare function isPlatformNamespace(key: string): boolean;
|
|
@@ -408,4 +215,6 @@ declare class DefaultLineageService implements LineageService {
|
|
|
408
215
|
}
|
|
409
216
|
declare function createLineageService(store: LineageStore): LineageService;
|
|
410
217
|
|
|
411
|
-
|
|
218
|
+
declare function withLineage<T extends ManifestoDomainShape, Laws extends BaseLaws>(manifesto: ComposableManifesto<T, Laws>, config?: LineageConfig): LineageComposableManifesto<T, Laws>;
|
|
219
|
+
|
|
220
|
+
export { BranchId, BranchInfo, BranchSwitchResult, CurrentErrorSignature, DefaultLineageService, InMemoryLineageStore, LineageComposableManifesto, LineageConfig, LineageService, LineageStore, PersistedBranchEntry, PreparedBranchMutation, PreparedLineageCommit, SealAttempt, SealGenesisInput, SealNextInput, SnapshotHashInput, TerminalStatus, World, WorldEdge, WorldHead, WorldId, WorldLineage, type WorldRecordResult, buildWorldLineage, computeHash, computePendingDigest, computeSnapshotHash, computeWorldId, createGenesisBranchEntry, createInMemoryLineageStore, createLineageService, createSealGenesisAttempt, createSealNextAttempt, createSnapshotHashInput, createWorldEdge, createWorldRecord, deriveTerminalStatus, getHeadsFromStore, isPlatformNamespace, normalizeContext, restoreSnapshot, selectLatestHead, stripPlatformNamespaces, toBranchInfo, toCurrentErrorSignature, toWorldHead, withLineage };
|