@proposit/proposit-core 0.9.1 → 0.10.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 (153) hide show
  1. package/README.md +59 -26
  2. package/dist/cli/commands/arguments.d.ts.map +1 -1
  3. package/dist/cli/commands/arguments.js +8 -16
  4. package/dist/cli/commands/arguments.js.map +1 -1
  5. package/dist/cli/commands/citations.d.ts +3 -0
  6. package/dist/cli/commands/citations.d.ts.map +1 -0
  7. package/dist/cli/commands/citations.js +89 -0
  8. package/dist/cli/commands/citations.js.map +1 -0
  9. package/dist/cli/commands/claims.d.ts.map +1 -1
  10. package/dist/cli/commands/claims.js +10 -2
  11. package/dist/cli/commands/claims.js.map +1 -1
  12. package/dist/cli/commands/parse.d.ts.map +1 -1
  13. package/dist/cli/commands/parse.js +9 -17
  14. package/dist/cli/commands/parse.js.map +1 -1
  15. package/dist/cli/commands/render.d.ts.map +1 -1
  16. package/dist/cli/commands/render.js +44 -18
  17. package/dist/cli/commands/render.js.map +1 -1
  18. package/dist/cli/commands/variables.d.ts.map +1 -1
  19. package/dist/cli/commands/variables.js +1 -0
  20. package/dist/cli/commands/variables.js.map +1 -1
  21. package/dist/cli/engine.d.ts.map +1 -1
  22. package/dist/cli/engine.js +12 -9
  23. package/dist/cli/engine.js.map +1 -1
  24. package/dist/cli/import.d.ts +2 -4
  25. package/dist/cli/import.d.ts.map +1 -1
  26. package/dist/cli/import.js +8 -7
  27. package/dist/cli/import.js.map +1 -1
  28. package/dist/cli/router.js +1 -1
  29. package/dist/cli/router.js.map +1 -1
  30. package/dist/cli/storage/libraries.d.ts +4 -7
  31. package/dist/cli/storage/libraries.d.ts.map +1 -1
  32. package/dist/cli/storage/libraries.js +9 -28
  33. package/dist/cli/storage/libraries.js.map +1 -1
  34. package/dist/cli/storage/migrate-v0.10.d.ts +10 -0
  35. package/dist/cli/storage/migrate-v0.10.d.ts.map +1 -0
  36. package/dist/cli/storage/migrate-v0.10.js +213 -0
  37. package/dist/cli/storage/migrate-v0.10.js.map +1 -0
  38. package/dist/cli.js +2 -2
  39. package/dist/cli.js.map +1 -1
  40. package/dist/extensions/basics/argument-parser.d.ts +1 -2
  41. package/dist/extensions/basics/argument-parser.d.ts.map +1 -1
  42. package/dist/extensions/basics/argument-parser.js.map +1 -1
  43. package/dist/extensions/basics/schemata.d.ts +1 -0
  44. package/dist/extensions/basics/schemata.d.ts.map +1 -1
  45. package/dist/extensions/ieee/{source.d.ts → citation-claim.d.ts} +5 -3
  46. package/dist/extensions/ieee/citation-claim.d.ts.map +1 -0
  47. package/dist/extensions/ieee/{source.js → citation-claim.js} +5 -4
  48. package/dist/extensions/ieee/citation-claim.js.map +1 -0
  49. package/dist/extensions/ieee/index.d.ts +1 -1
  50. package/dist/extensions/ieee/index.d.ts.map +1 -1
  51. package/dist/extensions/ieee/index.js +1 -1
  52. package/dist/extensions/ieee/index.js.map +1 -1
  53. package/dist/lib/consts.d.ts.map +1 -1
  54. package/dist/lib/consts.js +9 -13
  55. package/dist/lib/consts.js.map +1 -1
  56. package/dist/lib/core/argument-engine.d.ts +8 -8
  57. package/dist/lib/core/argument-engine.d.ts.map +1 -1
  58. package/dist/lib/core/argument-engine.js +7 -9
  59. package/dist/lib/core/argument-engine.js.map +1 -1
  60. package/dist/lib/core/argument-library.d.ts +13 -15
  61. package/dist/lib/core/argument-library.d.ts.map +1 -1
  62. package/dist/lib/core/argument-library.js +23 -9
  63. package/dist/lib/core/argument-library.js.map +1 -1
  64. package/dist/lib/core/claim-citation-library.d.ts +44 -0
  65. package/dist/lib/core/claim-citation-library.d.ts.map +1 -0
  66. package/dist/lib/core/claim-citation-library.js +336 -0
  67. package/dist/lib/core/claim-citation-library.js.map +1 -0
  68. package/dist/lib/core/claim-library.d.ts +33 -1
  69. package/dist/lib/core/claim-library.d.ts.map +1 -1
  70. package/dist/lib/core/claim-library.js +71 -3
  71. package/dist/lib/core/claim-library.js.map +1 -1
  72. package/dist/lib/core/fork-library.d.ts +19 -10
  73. package/dist/lib/core/fork-library.d.ts.map +1 -1
  74. package/dist/lib/core/fork-library.js +16 -13
  75. package/dist/lib/core/fork-library.js.map +1 -1
  76. package/dist/lib/core/fork.d.ts +6 -7
  77. package/dist/lib/core/fork.d.ts.map +1 -1
  78. package/dist/lib/core/fork.js +8 -3
  79. package/dist/lib/core/fork.js.map +1 -1
  80. package/dist/lib/core/interfaces/index.d.ts +1 -1
  81. package/dist/lib/core/interfaces/index.d.ts.map +1 -1
  82. package/dist/lib/core/interfaces/library.interfaces.d.ts +66 -160
  83. package/dist/lib/core/interfaces/library.interfaces.d.ts.map +1 -1
  84. package/dist/lib/core/proposit-core.d.ts +30 -32
  85. package/dist/lib/core/proposit-core.d.ts.map +1 -1
  86. package/dist/lib/core/proposit-core.js +68 -89
  87. package/dist/lib/core/proposit-core.js.map +1 -1
  88. package/dist/lib/index.d.ts +2 -3
  89. package/dist/lib/index.d.ts.map +1 -1
  90. package/dist/lib/index.js +2 -3
  91. package/dist/lib/index.js.map +1 -1
  92. package/dist/lib/parsing/argument-parser.d.ts +9 -12
  93. package/dist/lib/parsing/argument-parser.d.ts.map +1 -1
  94. package/dist/lib/parsing/argument-parser.js +27 -45
  95. package/dist/lib/parsing/argument-parser.js.map +1 -1
  96. package/dist/lib/parsing/index.d.ts +2 -2
  97. package/dist/lib/parsing/index.d.ts.map +1 -1
  98. package/dist/lib/parsing/index.js +1 -1
  99. package/dist/lib/parsing/index.js.map +1 -1
  100. package/dist/lib/parsing/prompt-builder.d.ts.map +1 -1
  101. package/dist/lib/parsing/prompt-builder.js +31 -24
  102. package/dist/lib/parsing/prompt-builder.js.map +1 -1
  103. package/dist/lib/parsing/schemata.d.ts +7 -19
  104. package/dist/lib/parsing/schemata.d.ts.map +1 -1
  105. package/dist/lib/parsing/schemata.js +7 -14
  106. package/dist/lib/parsing/schemata.js.map +1 -1
  107. package/dist/lib/parsing/types.d.ts +1 -2
  108. package/dist/lib/parsing/types.d.ts.map +1 -1
  109. package/dist/lib/schemata/claim-citation.d.ts +11 -0
  110. package/dist/lib/schemata/claim-citation.d.ts.map +1 -0
  111. package/dist/lib/schemata/claim-citation.js +25 -0
  112. package/dist/lib/schemata/claim-citation.js.map +1 -0
  113. package/dist/lib/schemata/claim.d.ts +1 -0
  114. package/dist/lib/schemata/claim.d.ts.map +1 -1
  115. package/dist/lib/schemata/claim.js +3 -0
  116. package/dist/lib/schemata/claim.js.map +1 -1
  117. package/dist/lib/schemata/fork.d.ts +0 -11
  118. package/dist/lib/schemata/fork.d.ts.map +1 -1
  119. package/dist/lib/schemata/fork.js +0 -10
  120. package/dist/lib/schemata/fork.js.map +1 -1
  121. package/dist/lib/schemata/index.d.ts +1 -1
  122. package/dist/lib/schemata/index.d.ts.map +1 -1
  123. package/dist/lib/schemata/index.js +1 -1
  124. package/dist/lib/schemata/index.js.map +1 -1
  125. package/dist/lib/types/checksum.d.ts +3 -5
  126. package/dist/lib/types/checksum.d.ts.map +1 -1
  127. package/dist/lib/types/validation.d.ts +9 -7
  128. package/dist/lib/types/validation.d.ts.map +1 -1
  129. package/dist/lib/types/validation.js +10 -8
  130. package/dist/lib/types/validation.js.map +1 -1
  131. package/dist/lib/utils/lookup.d.ts +7 -15
  132. package/dist/lib/utils/lookup.d.ts.map +1 -1
  133. package/dist/lib/utils/lookup.js +8 -18
  134. package/dist/lib/utils/lookup.js.map +1 -1
  135. package/package.json +1 -1
  136. package/dist/cli/commands/sources.d.ts +0 -3
  137. package/dist/cli/commands/sources.d.ts.map +0 -1
  138. package/dist/cli/commands/sources.js +0 -103
  139. package/dist/cli/commands/sources.js.map +0 -1
  140. package/dist/extensions/ieee/source.d.ts.map +0 -1
  141. package/dist/extensions/ieee/source.js.map +0 -1
  142. package/dist/lib/core/claim-source-library.d.ts +0 -32
  143. package/dist/lib/core/claim-source-library.d.ts.map +0 -1
  144. package/dist/lib/core/claim-source-library.js +0 -193
  145. package/dist/lib/core/claim-source-library.js.map +0 -1
  146. package/dist/lib/core/source-library.d.ts +0 -23
  147. package/dist/lib/core/source-library.d.ts.map +0 -1
  148. package/dist/lib/core/source-library.js +0 -21
  149. package/dist/lib/core/source-library.js.map +0 -1
  150. package/dist/lib/schemata/source.d.ts +0 -18
  151. package/dist/lib/schemata/source.d.ts.map +0 -1
  152. package/dist/lib/schemata/source.js +0 -35
  153. package/dist/lib/schemata/source.js.map +0 -1
@@ -0,0 +1,336 @@
1
+ import { Value } from "typebox/value";
2
+ import { CoreClaimCitationSchema } from "../schemata/claim-citation.js";
3
+ import { DEFAULT_CHECKSUM_CONFIG } from "../consts.js";
4
+ import { entityChecksum } from "./checksum.js";
5
+ import { CITATION_SCHEMA_INVALID, CITATION_DUPLICATE_ID, CITATION_CITING_REF_NOT_FOUND, CITATION_SOURCE_REF_NOT_FOUND, CITATION_SOURCE_NOT_CITATION_TYPE, CITATION_CYCLE_DETECTED, } from "../types/validation.js";
6
+ import { InvariantViolationError } from "./invariant-violation-error.js";
7
+ export class ClaimCitationLibrary {
8
+ citations;
9
+ citingClaimToCitations;
10
+ sourceClaimToCitations;
11
+ claimLookup;
12
+ checksumConfig;
13
+ constructor(claimLookup, options) {
14
+ this.citations = new Map();
15
+ this.citingClaimToCitations = new Map();
16
+ this.sourceClaimToCitations = new Map();
17
+ this.claimLookup = claimLookup;
18
+ this.checksumConfig = options?.checksumConfig;
19
+ }
20
+ restoreFromSnapshot(snap) {
21
+ this.citations = new Map();
22
+ this.citingClaimToCitations = new Map();
23
+ this.sourceClaimToCitations = new Map();
24
+ for (const citation of snap.claimCitations) {
25
+ this.citations.set(citation.id, citation);
26
+ }
27
+ for (const [id, citation] of this.citations) {
28
+ const citingKey = citation.citingClaimId;
29
+ if (!this.citingClaimToCitations.has(citingKey)) {
30
+ this.citingClaimToCitations.set(citingKey, new Set());
31
+ }
32
+ this.citingClaimToCitations.get(citingKey).add(id);
33
+ const sourceKey = citation.sourceClaimId;
34
+ if (!this.sourceClaimToCitations.has(sourceKey)) {
35
+ this.sourceClaimToCitations.set(sourceKey, new Set());
36
+ }
37
+ this.sourceClaimToCitations.get(sourceKey).add(id);
38
+ }
39
+ }
40
+ withValidation(fn) {
41
+ const snap = this.snapshot();
42
+ try {
43
+ const result = fn();
44
+ const validation = this.validate();
45
+ if (!validation.ok) {
46
+ this.restoreFromSnapshot(snap);
47
+ throw new InvariantViolationError(validation.violations);
48
+ }
49
+ return result;
50
+ }
51
+ catch (e) {
52
+ if (!(e instanceof InvariantViolationError)) {
53
+ this.restoreFromSnapshot(snap);
54
+ }
55
+ throw e;
56
+ }
57
+ }
58
+ add(citation) {
59
+ return this.withValidation(() => {
60
+ if (this.citations.has(citation.id)) {
61
+ throw new InvariantViolationError([
62
+ {
63
+ code: CITATION_DUPLICATE_ID,
64
+ message: `Citation with id ${citation.id} already exists`,
65
+ entityType: "citation",
66
+ entityId: citation.id,
67
+ },
68
+ ]);
69
+ }
70
+ const citingClaim = this.claimLookup.get(citation.citingClaimId, citation.citingClaimVersion);
71
+ if (!citingClaim) {
72
+ throw new InvariantViolationError([
73
+ {
74
+ code: CITATION_CITING_REF_NOT_FOUND,
75
+ message: `Citation references unknown citing claim ${citation.citingClaimId}@${citation.citingClaimVersion}`,
76
+ entityType: "citation",
77
+ entityId: citation.id,
78
+ },
79
+ ]);
80
+ }
81
+ const sourceClaim = this.claimLookup.get(citation.sourceClaimId, citation.sourceClaimVersion);
82
+ if (!sourceClaim) {
83
+ throw new InvariantViolationError([
84
+ {
85
+ code: CITATION_SOURCE_REF_NOT_FOUND,
86
+ message: `Citation references unknown source claim ${citation.sourceClaimId}@${citation.sourceClaimVersion}`,
87
+ entityType: "citation",
88
+ entityId: citation.id,
89
+ },
90
+ ]);
91
+ }
92
+ if (sourceClaim.type !== "citation") {
93
+ throw new InvariantViolationError([
94
+ {
95
+ code: CITATION_SOURCE_NOT_CITATION_TYPE,
96
+ message: `Citation source claim ${citation.sourceClaimId} has type='${sourceClaim.type}'; only 'citation' is permitted on the source side`,
97
+ entityType: "citation",
98
+ entityId: citation.id,
99
+ },
100
+ ]);
101
+ }
102
+ if (this.wouldCreateCycle(citation.citingClaimId, citation.sourceClaimId)) {
103
+ throw new InvariantViolationError([
104
+ {
105
+ code: CITATION_CYCLE_DETECTED,
106
+ message: `Adding citation from ${citation.citingClaimId} to ${citation.sourceClaimId} would create a cycle in the claim citation graph`,
107
+ entityType: "citation",
108
+ entityId: citation.id,
109
+ },
110
+ ]);
111
+ }
112
+ const full = { ...citation, checksum: "" };
113
+ full.checksum = this.computeChecksum(full);
114
+ this.citations.set(full.id, full);
115
+ let citingSet = this.citingClaimToCitations.get(full.citingClaimId);
116
+ if (!citingSet) {
117
+ citingSet = new Set();
118
+ this.citingClaimToCitations.set(full.citingClaimId, citingSet);
119
+ }
120
+ citingSet.add(full.id);
121
+ let sourceSet = this.sourceClaimToCitations.get(full.sourceClaimId);
122
+ if (!sourceSet) {
123
+ sourceSet = new Set();
124
+ this.sourceClaimToCitations.set(full.sourceClaimId, sourceSet);
125
+ }
126
+ sourceSet.add(full.id);
127
+ return full;
128
+ });
129
+ }
130
+ remove(id) {
131
+ return this.withValidation(() => {
132
+ const citation = this.citations.get(id);
133
+ if (!citation) {
134
+ throw new Error(`ClaimCitation "${id}" not found.`);
135
+ }
136
+ this.citations.delete(id);
137
+ const citingSet = this.citingClaimToCitations.get(citation.citingClaimId);
138
+ if (citingSet) {
139
+ citingSet.delete(id);
140
+ }
141
+ const sourceSet = this.sourceClaimToCitations.get(citation.sourceClaimId);
142
+ if (sourceSet) {
143
+ sourceSet.delete(id);
144
+ }
145
+ return citation;
146
+ });
147
+ }
148
+ getCitationsForCitingClaim(citingClaimId) {
149
+ const ids = this.citingClaimToCitations.get(citingClaimId);
150
+ if (!ids)
151
+ return [];
152
+ return Array.from(ids)
153
+ .map((id) => this.citations.get(id))
154
+ .filter(Boolean);
155
+ }
156
+ getCitationsForSourceClaim(sourceClaimId) {
157
+ const ids = this.sourceClaimToCitations.get(sourceClaimId);
158
+ if (!ids)
159
+ return [];
160
+ return Array.from(ids)
161
+ .map((id) => this.citations.get(id))
162
+ .filter(Boolean);
163
+ }
164
+ get(id) {
165
+ return this.citations.get(id);
166
+ }
167
+ getAll() {
168
+ return Array.from(this.citations.values());
169
+ }
170
+ filter(predicate) {
171
+ return this.getAll().filter(predicate);
172
+ }
173
+ snapshot() {
174
+ return { claimCitations: this.getAll() };
175
+ }
176
+ /** Restores a claim-citation library from a snapshot, re-indexing all citations. */
177
+ static fromSnapshot(snapshot, claimLookup, options) {
178
+ const lib = new ClaimCitationLibrary(claimLookup, options);
179
+ for (const citation of snapshot.claimCitations) {
180
+ lib.citations.set(citation.id, citation);
181
+ let citingSet = lib.citingClaimToCitations.get(citation.citingClaimId);
182
+ if (!citingSet) {
183
+ citingSet = new Set();
184
+ lib.citingClaimToCitations.set(citation.citingClaimId, citingSet);
185
+ }
186
+ citingSet.add(citation.id);
187
+ let sourceSet = lib.sourceClaimToCitations.get(citation.sourceClaimId);
188
+ if (!sourceSet) {
189
+ sourceSet = new Set();
190
+ lib.sourceClaimToCitations.set(citation.sourceClaimId, sourceSet);
191
+ }
192
+ sourceSet.add(citation.id);
193
+ }
194
+ return lib;
195
+ }
196
+ validate() {
197
+ const violations = [];
198
+ for (const [id, citation] of this.citations) {
199
+ if (!Value.Check(CoreClaimCitationSchema, citation)) {
200
+ violations.push({
201
+ code: CITATION_SCHEMA_INVALID,
202
+ message: `Citation "${id}" does not conform to schema`,
203
+ entityType: "citation",
204
+ entityId: id,
205
+ });
206
+ }
207
+ if (!this.claimLookup.get(citation.citingClaimId, citation.citingClaimVersion)) {
208
+ violations.push({
209
+ code: CITATION_CITING_REF_NOT_FOUND,
210
+ message: `Citation "${id}" references non-existent citing claim "${citation.citingClaimId}" version ${citation.citingClaimVersion}`,
211
+ entityType: "citation",
212
+ entityId: id,
213
+ });
214
+ }
215
+ if (!this.claimLookup.get(citation.sourceClaimId, citation.sourceClaimVersion)) {
216
+ violations.push({
217
+ code: CITATION_SOURCE_REF_NOT_FOUND,
218
+ message: `Citation "${id}" references non-existent source claim "${citation.sourceClaimId}" version ${citation.sourceClaimVersion}`,
219
+ entityType: "citation",
220
+ entityId: id,
221
+ });
222
+ }
223
+ }
224
+ // Strict source-side type: every citation's source claim must have
225
+ // type='citation'. Catches tampered snapshots loaded via fromSnapshot.
226
+ for (const citation of this.citations.values()) {
227
+ const sourceClaim = this.claimLookup.get(citation.sourceClaimId, citation.sourceClaimVersion);
228
+ if (sourceClaim && sourceClaim.type !== "citation") {
229
+ violations.push({
230
+ code: CITATION_SOURCE_NOT_CITATION_TYPE,
231
+ message: `Citation ${citation.id} source claim ${citation.sourceClaimId} has type='${sourceClaim.type}'; only 'citation' is permitted on the source side`,
232
+ entityType: "citation",
233
+ entityId: citation.id,
234
+ });
235
+ }
236
+ }
237
+ // Acyclicity: walk the entire citation graph (ID-only) and detect
238
+ // cycles. Catches cycles introduced by snapshot tampering.
239
+ const cycleViolations = this.detectAllCycles();
240
+ for (const v of cycleViolations)
241
+ violations.push(v);
242
+ return { ok: violations.length === 0, violations };
243
+ }
244
+ /**
245
+ * Detects all cycles in the ID-only projection of the citation graph.
246
+ * Returns one violation per cycle (deduped by the citation that closes
247
+ * each detected cycle).
248
+ */
249
+ detectAllCycles() {
250
+ const violations = [];
251
+ const visited = new Set();
252
+ const inProgress = new Set();
253
+ const reportedCycleIds = new Set();
254
+ const visit = (node, path) => {
255
+ if (inProgress.has(node)) {
256
+ // Cycle detected: report the citation that closes it.
257
+ // Find the citation linking the previous node to this one.
258
+ const prev = path[path.length - 1];
259
+ for (const citation of this.citations.values()) {
260
+ if (citation.citingClaimId === prev &&
261
+ citation.sourceClaimId === node &&
262
+ !reportedCycleIds.has(citation.id)) {
263
+ violations.push({
264
+ code: CITATION_CYCLE_DETECTED,
265
+ message: `Citation graph contains a cycle involving claim ${node}`,
266
+ entityType: "citation",
267
+ entityId: citation.id,
268
+ });
269
+ reportedCycleIds.add(citation.id);
270
+ }
271
+ }
272
+ return;
273
+ }
274
+ if (visited.has(node))
275
+ return;
276
+ visited.add(node);
277
+ inProgress.add(node);
278
+ const outgoing = this.citingClaimToCitations.get(node);
279
+ if (outgoing) {
280
+ for (const cid of outgoing) {
281
+ const c = this.citations.get(cid);
282
+ if (c)
283
+ visit(c.sourceClaimId, [...path, node]);
284
+ }
285
+ }
286
+ inProgress.delete(node);
287
+ };
288
+ for (const node of this.citingClaimToCitations.keys()) {
289
+ if (!visited.has(node))
290
+ visit(node, []);
291
+ }
292
+ return violations;
293
+ }
294
+ /**
295
+ * Returns true if adding an edge from `citingClaimId` to `sourceClaimId`
296
+ * would create a cycle in the claim-citation graph. Edges go from citing
297
+ * to source; a cycle exists when the citing claim is reachable from the
298
+ * proposed source claim by following outgoing source edges.
299
+ */
300
+ wouldCreateCycle(citingClaimId, sourceClaimId) {
301
+ // Optimization: if citing-side has type "normal", it can never appear
302
+ // on the source side, so no cycle is reachable. Type is immutable
303
+ // post-creation, so v0's type is authoritative.
304
+ const citingClaimType = this.claimLookup.get(citingClaimId, 0)?.type;
305
+ if (citingClaimType === "normal")
306
+ return false;
307
+ // DFS from sourceClaimId following outgoing source edges via the
308
+ // citingClaimToCitations index (avoids scanning all citations).
309
+ const visited = new Set();
310
+ const stack = [sourceClaimId];
311
+ while (stack.length > 0) {
312
+ const node = stack.pop();
313
+ if (node === citingClaimId)
314
+ return true;
315
+ if (visited.has(node))
316
+ continue;
317
+ visited.add(node);
318
+ const outgoingIds = this.citingClaimToCitations.get(node);
319
+ if (outgoingIds) {
320
+ for (const cid of outgoingIds) {
321
+ const c = this.citations.get(cid);
322
+ if (c) {
323
+ stack.push(c.sourceClaimId);
324
+ }
325
+ }
326
+ }
327
+ }
328
+ return false;
329
+ }
330
+ computeChecksum(citation) {
331
+ const fields = this.checksumConfig?.claimCitationFields ??
332
+ DEFAULT_CHECKSUM_CONFIG.claimCitationFields;
333
+ return entityChecksum(citation, fields);
334
+ }
335
+ }
336
+ //# sourceMappingURL=claim-citation-library.js.map
@@ -0,0 +1 @@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;YAAE,OAAO,KAAK,CAAA;QAE9C,iEAAiE;QACjE,gEAAgE;QAChE,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAA;QACjC,MAAM,KAAK,GAAa,CAAC,aAAa,CAAC,CAAA;QACvC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,EAAG,CAAA;YACzB,IAAI,IAAI,KAAK,aAAa;gBAAE,OAAO,IAAI,CAAA;YACvC,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,SAAQ;YAC/B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YACjB,MAAM,WAAW,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YACzD,IAAI,WAAW,EAAE,CAAC;gBACd,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;oBAC5B,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;oBACjC,IAAI,CAAC,EAAE,CAAC;wBACJ,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAA;oBAC/B,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAA;IAChB,CAAC;IAEO,eAAe,CAAC,QAAmB;QACvC,MAAM,MAAM,GACR,IAAI,CAAC,cAAc,EAAE,mBAAmB;YACxC,uBAAuB,CAAC,mBAAoB,CAAA;QAChD,OAAO,cAAc,CACjB,QAA8C,EAC9C,MAAM,CACT,CAAA;IACL,CAAC;CACJ"}
@@ -2,6 +2,15 @@ import type { TCoreClaim } from "../schemata/claim.js";
2
2
  import type { TCoreChecksumConfig } from "../types/checksum.js";
3
3
  import type { TClaimLibraryManagement, TClaimLibrarySnapshot } from "./interfaces/library.interfaces.js";
4
4
  import { VersionedLibrary } from "./versioned-library.js";
5
+ /**
6
+ * Input shape for {@link ClaimLibrary.create}. The `type` field is required
7
+ * (and immutable thereafter); `id` is auto-generated when omitted. Other
8
+ * extension fields on `TClaim` are passed through as-is, matching the base
9
+ * {@link VersionedLibrary.create} contract.
10
+ */
11
+ export type TClaimCreateInput<TClaim extends TCoreClaim = TCoreClaim> = Omit<TClaim, "version" | "frozen" | "checksum"> | (Omit<TClaim, "id" | "version" | "frozen" | "checksum"> & {
12
+ id?: string;
13
+ });
5
14
  export declare class ClaimLibrary<TClaim extends TCoreClaim = TCoreClaim> extends VersionedLibrary<TClaim> implements TClaimLibraryManagement<TClaim> {
6
15
  protected readonly entityLabel = "Claim";
7
16
  protected readonly entityType: "claim";
@@ -10,14 +19,37 @@ export declare class ClaimLibrary<TClaim extends TCoreClaim = TCoreClaim> extend
10
19
  version: import("typebox").TNumber;
11
20
  frozen: import("typebox").TBoolean;
12
21
  checksum: import("typebox").TString;
22
+ type: import("typebox").TUnion<[import("typebox").TLiteral<"normal">, import("typebox").TLiteral<"citation">]>;
13
23
  }>;
14
24
  protected readonly checksumFieldsKey: "claimFields";
15
25
  protected readonly schemaInvalidCode = "CLAIM_SCHEMA_INVALID";
16
26
  protected readonly frozenSuccessorCode = "CLAIM_FROZEN_NO_SUCCESSOR";
27
+ private readonly generateId;
28
+ constructor(options?: {
29
+ checksumConfig?: TCoreChecksumConfig;
30
+ generateId?: () => string;
31
+ });
32
+ /**
33
+ * Creates a new claim at version 0. The `type` field is required and is
34
+ * immutable across the claim's lifetime. `id` is auto-generated when omitted.
35
+ */
36
+ create(input: TClaimCreateInput<TClaim>): TClaim;
37
+ /**
38
+ * Applies partial updates to the latest version of a claim. Rejects any
39
+ * update that would change the immutable `type` field.
40
+ */
41
+ update(id: string, updates: Partial<Omit<TClaim, "id" | "version" | "frozen" | "checksum">>): TClaim;
17
42
  snapshot(): TClaimLibrarySnapshot<TClaim>;
18
- /** Restores a claim library from a previously captured snapshot. */
43
+ /**
44
+ * Restores a claim library from a previously captured snapshot.
45
+ * Pre-screens for legacy (pre-v0.10.0) claim entries that lack the
46
+ * required `type` field and emits {@link LEGACY_CLAIM_MISSING_TYPE} so
47
+ * the caller gets a clear migration signal rather than a generic schema
48
+ * error.
49
+ */
19
50
  static fromSnapshot<TClaim extends TCoreClaim = TCoreClaim>(snapshot: TClaimLibrarySnapshot<TClaim>, options?: {
20
51
  checksumConfig?: TCoreChecksumConfig;
52
+ generateId?: () => string;
21
53
  }): ClaimLibrary<TClaim>;
22
54
  }
23
55
  //# sourceMappingURL=claim-library.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"claim-library.d.ts","sourceRoot":"","sources":["../../../src/lib/core/claim-library.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,KAAK,EACR,uBAAuB,EACvB,qBAAqB,EACxB,MAAM,oCAAoC,CAAA;AAK3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAEzD,qBAAa,YAAY,CAAC,MAAM,SAAS,UAAU,GAAG,UAAU,CAC5D,SAAQ,gBAAgB,CAAC,MAAM,CAC/B,YAAW,uBAAuB,CAAC,MAAM,CAAC;IAE1C,SAAS,CAAC,QAAQ,CAAC,WAAW,WAAU;IACxC,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAG,OAAO,CAAS;IAChD,SAAS,CAAC,QAAQ,CAAC,MAAM;;;;;OAAkB;IAC3C,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAG,aAAa,CAAS;IAC7D,SAAS,CAAC,QAAQ,CAAC,iBAAiB,0BAAuB;IAC3D,SAAS,CAAC,QAAQ,CAAC,mBAAmB,+BAA4B;IAE3D,QAAQ,IAAI,qBAAqB,CAAC,MAAM,CAAC;IAIhD,oEAAoE;WACtD,YAAY,CAAC,MAAM,SAAS,UAAU,GAAG,UAAU,EAC7D,QAAQ,EAA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,CAAc;gBAE7B,OAAO,CAAC,EAAE;QAClB,cAAc,CAAC,EAAE,mBAAmB,CAAA;QACpC,UAAU,CAAC,EAAE,MAAM,MAAM,CAAA;KAC5B;IAKD;;;OAGG;IACa,MAAM,CAAC,KAAK,EAAE,iBAAiB,CAAC,MAAM,CAAC,GAAG,MAAM;IAUhE;;;OAGG;IACa,MAAM,CAClB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC,CAAC,GACzE,MAAM;IAmBF,QAAQ,IAAI,qBAAqB,CAAC,MAAM,CAAC;IAIhD;;;;;;OAMG;WACW,YAAY,CAAC,MAAM,SAAS,UAAU,GAAG,UAAU,EAC7D,QAAQ,EAAE,qBAAqB,CAAC,MAAM,CAAC,EACvC,OAAO,CAAC,EAAE;QACN,cAAc,CAAC,EAAE,mBAAmB,CAAA;QACpC,UAAU,CAAC,EAAE,MAAM,MAAM,CAAA;KAC5B,GACF,YAAY,CAAC,MAAM,CAAC;CA8B1B"}
@@ -1,5 +1,7 @@
1
1
  import { CoreClaimSchema } from "../schemata/claim.js";
2
- import { CLAIM_SCHEMA_INVALID, CLAIM_FROZEN_NO_SUCCESSOR, } from "../types/validation.js";
2
+ import { CLAIM_SCHEMA_INVALID, CLAIM_FROZEN_NO_SUCCESSOR, CLAIM_TYPE_IMMUTABLE, LEGACY_CLAIM_MISSING_TYPE, } from "../types/validation.js";
3
+ import { InvariantViolationError } from "./invariant-violation-error.js";
4
+ import { defaultGenerateId } from "./argument-engine.js";
3
5
  import { VersionedLibrary } from "./versioned-library.js";
4
6
  export class ClaimLibrary extends VersionedLibrary {
5
7
  entityLabel = "Claim";
@@ -8,13 +10,79 @@ export class ClaimLibrary extends VersionedLibrary {
8
10
  checksumFieldsKey = "claimFields";
9
11
  schemaInvalidCode = CLAIM_SCHEMA_INVALID;
10
12
  frozenSuccessorCode = CLAIM_FROZEN_NO_SUCCESSOR;
13
+ generateId;
14
+ constructor(options) {
15
+ super(options);
16
+ this.generateId = options?.generateId ?? defaultGenerateId;
17
+ }
18
+ /**
19
+ * Creates a new claim at version 0. The `type` field is required and is
20
+ * immutable across the claim's lifetime. `id` is auto-generated when omitted.
21
+ */
22
+ create(input) {
23
+ const inputId = input.id;
24
+ const id = inputId ?? this.generateId();
25
+ const entity = {
26
+ ...input,
27
+ id,
28
+ };
29
+ return super.create(entity);
30
+ }
31
+ /**
32
+ * Applies partial updates to the latest version of a claim. Rejects any
33
+ * update that would change the immutable `type` field.
34
+ */
35
+ update(id, updates) {
36
+ const existing = this.getCurrent(id);
37
+ if (existing !== undefined &&
38
+ updates.type !== undefined &&
39
+ updates.type !== existing.type) {
40
+ throw new InvariantViolationError([
41
+ {
42
+ code: CLAIM_TYPE_IMMUTABLE,
43
+ message: `Claim "${id}" type is immutable; cannot change type from '${existing.type}' to '${updates.type}'`,
44
+ entityType: "claim",
45
+ entityId: id,
46
+ },
47
+ ]);
48
+ }
49
+ return super.update(id, updates);
50
+ }
11
51
  snapshot() {
12
52
  return { claims: this.getAll() };
13
53
  }
14
- /** Restores a claim library from a previously captured snapshot. */
54
+ /**
55
+ * Restores a claim library from a previously captured snapshot.
56
+ * Pre-screens for legacy (pre-v0.10.0) claim entries that lack the
57
+ * required `type` field and emits {@link LEGACY_CLAIM_MISSING_TYPE} so
58
+ * the caller gets a clear migration signal rather than a generic schema
59
+ * error.
60
+ */
15
61
  static fromSnapshot(snapshot, options) {
62
+ const claims = snapshot.claims ?? [];
63
+ for (const claim of claims) {
64
+ if (claim === null ||
65
+ typeof claim !== "object" ||
66
+ !("type" in claim) ||
67
+ claim.type === undefined) {
68
+ const claimId = claim !== null &&
69
+ typeof claim === "object" &&
70
+ "id" in claim &&
71
+ typeof claim.id === "string"
72
+ ? claim.id
73
+ : "<unknown>";
74
+ throw new InvariantViolationError([
75
+ {
76
+ code: LEGACY_CLAIM_MISSING_TYPE,
77
+ message: `Claim "${claimId}" is missing the 'type' field, indicating pre-v0.10.0 data. Migration required.`,
78
+ entityType: "claim",
79
+ entityId: claimId,
80
+ },
81
+ ]);
82
+ }
83
+ }
16
84
  const lib = new ClaimLibrary(options);
17
- lib.restoreFromEntities(snapshot.claims);
85
+ lib.restoreFromEntities(claims);
18
86
  return lib;
19
87
  }
20
88
  }
@@ -1 +1 @@
1
- {"version":3,"file":"claim-library.js","sourceRoot":"","sources":["../../../src/lib/core/claim-library.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAMtD,OAAO,EACH,oBAAoB,EACpB,yBAAyB,GAC5B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAEzD,MAAM,OAAO,YACT,SAAQ,gBAAwB;IAGb,WAAW,GAAG,OAAO,CAAA;IACrB,UAAU,GAAG,OAAgB,CAAA;IAC7B,MAAM,GAAG,eAAe,CAAA;IACxB,iBAAiB,GAAG,aAAsB,CAAA;IAC1C,iBAAiB,GAAG,oBAAoB,CAAA;IACxC,mBAAmB,GAAG,yBAAyB,CAAA;IAE3D,QAAQ;QACX,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAA;IACpC,CAAC;IAED,oEAAoE;IAC7D,MAAM,CAAC,YAAY,CACtB,QAAuC,EACvC,OAAkD;QAElD,MAAM,GAAG,GAAG,IAAI,YAAY,CAAS,OAAO,CAAC,CAAA;QAC7C,GAAG,CAAC,mBAAmB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QACxC,OAAO,GAAG,CAAA;IACd,CAAC;CACJ"}
1
+ {"version":3,"file":"claim-library.js","sourceRoot":"","sources":["../../../src/lib/core/claim-library.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAMtD,OAAO,EACH,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,EACp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import type { TCoreArgumentForkRecord, TCorePremiseForkRecord, TCoreExpressionForkRecord, TCoreVariableForkRecord, TCoreClaimForkRecord, TCoreSourceForkRecord } from "../schemata/fork.js";
1
+ import type { TCoreArgumentForkRecord, TCorePremiseForkRecord, TCoreExpressionForkRecord, TCoreVariableForkRecord, TCoreClaimForkRecord } from "../schemata/fork.js";
2
2
  import { ForkNamespace } from "./fork-namespace.js";
3
3
  import type { TForkLibrarySnapshot } from "./interfaces/library.interfaces.js";
4
4
  import type { TInvariantValidationResult } from "../types/validation.js";
5
5
  /**
6
6
  * Aggregate container for fork provenance across all entity types.
7
- * Holds six {@link ForkNamespace} instances — one per entity kind
8
- * (arguments, premises, expressions, variables, claims, sources).
7
+ * Holds five {@link ForkNamespace} instances — one per entity kind
8
+ * (arguments, premises, expressions, variables, claims).
9
9
  * Fork records are immutable after creation and carry no checksums.
10
+ *
11
+ * As of v0.10.0 the legacy `sources` namespace has been folded into
12
+ * `claims` — sources are now claims with `type: "citation"`.
10
13
  */
11
- export declare class ForkLibrary<TArgFork extends TCoreArgumentForkRecord = TCoreArgumentForkRecord, TPremiseFork extends TCorePremiseForkRecord = TCorePremiseForkRecord, TExprFork extends TCoreExpressionForkRecord = TCoreExpressionForkRecord, TVarFork extends TCoreVariableForkRecord = TCoreVariableForkRecord, TClaimFork extends TCoreClaimForkRecord = TCoreClaimForkRecord, TSourceFork extends TCoreSourceForkRecord = TCoreSourceForkRecord> {
14
+ export declare class ForkLibrary<TArgFork extends TCoreArgumentForkRecord = TCoreArgumentForkRecord, TPremiseFork extends TCorePremiseForkRecord = TCorePremiseForkRecord, TExprFork extends TCoreExpressionForkRecord = TCoreExpressionForkRecord, TVarFork extends TCoreVariableForkRecord = TCoreVariableForkRecord, TClaimFork extends TCoreClaimForkRecord = TCoreClaimForkRecord> {
12
15
  readonly arguments: ForkNamespace<TArgFork>;
13
16
  readonly premises: ForkNamespace<TPremiseFork>;
14
17
  readonly expressions: ForkNamespace<TExprFork>;
15
18
  readonly variables: ForkNamespace<TVarFork>;
16
19
  readonly claims: ForkNamespace<TClaimFork>;
17
- readonly sources: ForkNamespace<TSourceFork>;
18
20
  constructor();
19
- /** Returns a serializable snapshot of all six namespaces. */
20
- snapshot(): TForkLibrarySnapshot<TArgFork, TPremiseFork, TExprFork, TVarFork, TClaimFork, TSourceFork>;
21
- /** Restores a full library from a previously captured snapshot. */
22
- static fromSnapshot<TArgFork extends TCoreArgumentForkRecord = TCoreArgumentForkRecord, TPremiseFork extends TCorePremiseForkRecord = TCorePremiseForkRecord, TExprFork extends TCoreExpressionForkRecord = TCoreExpressionForkRecord, TVarFork extends TCoreVariableForkRecord = TCoreVariableForkRecord, TClaimFork extends TCoreClaimForkRecord = TCoreClaimForkRecord, TSourceFork extends TCoreSourceForkRecord = TCoreSourceForkRecord>(snapshot: TForkLibrarySnapshot<TArgFork, TPremiseFork, TExprFork, TVarFork, TClaimFork, TSourceFork>): ForkLibrary<TArgFork, TPremiseFork, TExprFork, TVarFork, TClaimFork, TSourceFork>;
23
- /** Validates all six namespaces and returns the combined result. */
21
+ /** Returns a serializable snapshot of all five namespaces. */
22
+ snapshot(): TForkLibrarySnapshot<TArgFork, TPremiseFork, TExprFork, TVarFork, TClaimFork>;
23
+ /**
24
+ * Restores a full library from a previously captured snapshot.
25
+ *
26
+ * Pre-v0.10.0 snapshots that contained a `sources` namespace are not
27
+ * supported here — callers must convert them via the CLI migration
28
+ * (Phase 14) before invoking `fromSnapshot`. Any stray `sources` key on
29
+ * an input snapshot is silently ignored.
30
+ */
31
+ static fromSnapshot<TArgFork extends TCoreArgumentForkRecord = TCoreArgumentForkRecord, TPremiseFork extends TCorePremiseForkRecord = TCorePremiseForkRecord, TExprFork extends TCoreExpressionForkRecord = TCoreExpressionForkRecord, TVarFork extends TCoreVariableForkRecord = TCoreVariableForkRecord, TClaimFork extends TCoreClaimForkRecord = TCoreClaimForkRecord>(snapshot: TForkLibrarySnapshot<TArgFork, TPremiseFork, TExprFork, TVarFork, TClaimFork>): ForkLibrary<TArgFork, TPremiseFork, TExprFork, TVarFork, TClaimFork>;
32
+ /** Validates all five namespaces and returns the combined result. */
24
33
  validate(): TInvariantValidationResult;
25
34
  }
26
35
  //# sourceMappingURL=fork-library.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fork-library.d.ts","sourceRoot":"","sources":["../../../src/lib/core/fork-library.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACxB,MAAM,qBAAqB,CAAA;AAO5B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAC9E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAA;AAExE;;;;;GAKG;AACH,qBAAa,WAAW,CACpB,QAAQ,SAAS,uBAAuB,GAAG,uBAAuB,EAClE,YAAY,SAAS,sBAAsB,GAAG,sBAAsB,EACpE,SAAS,SAAS,yBAAyB,GAAG,yBAAyB,EACvE,QAAQ,SAAS,uBAAuB,GAAG,uBAAuB,EAClE,UAAU,SAAS,oBAAoB,GAAG,oBAAoB,EAC9D,WAAW,SAAS,qBAAqB,GAAG,qBAAqB;IAEjE,SAAgB,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;IAClD,SAAgB,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;IACrD,SAAgB,WAAW,EAAE,aAAa,CAAC,SAAS,CAAC,CAAA;IACrD,SAAgB,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;IAClD,SAAgB,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;IACjD,SAAgB,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAA;;IAiBnD,6DAA6D;IACtD,QAAQ,IAAI,oBAAoB,CACnC,QAAQ,EACR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,CAAC,CAAA;IAClD,SAAgB,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;IACrD,SAAgB,WAAW,EAAE,aAAa,CAAC,SAAS,CAAC,CAAA;IACrD,SAAgB,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;IAClD,SAAgB,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;;IAcjD,8DAA8D;IACvD,QAAQ,IAAI,oBAAoB,CACnC,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,UAAU,CACb;IAUD;;;;;;;OAOG;WACW,YAAY,CACtB,QAAQ,SAAS,uBAAuB,GAAG,uBAAuB,EAClE,YAAY,SAAS,sBAAsB,GAAG,sBAAsB,EACpE,SAAS,SAAS,yBAAyB,GAAG,yBAAyB,EACvE,QAAQ,SAAS,uBAAuB,GAAG,uBAAuB,EAClE,UAAU,SAAS,oBAAoB,GAAG,oBAAoB,EAE9D,QAAQ,EAAE,oBAAoB,CAC1B,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,UAAU,CACb,GACF,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAC;IA4BvE,qEAAqE;IAC9D,QAAQ,IAAI,0BAA0B;CAUhD"}
@@ -1,10 +1,13 @@
1
- import { CoreEntityForkRecordSchema, CoreExpressionForkRecordSchema, CoreClaimForkRecordSchema, CoreSourceForkRecordSchema, } from "../schemata/fork.js";
1
+ import { CoreEntityForkRecordSchema, CoreExpressionForkRecordSchema, CoreClaimForkRecordSchema, } from "../schemata/fork.js";
2
2
  import { ForkNamespace } from "./fork-namespace.js";
3
3
  /**
4
4
  * Aggregate container for fork provenance across all entity types.
5
- * Holds six {@link ForkNamespace} instances — one per entity kind
6
- * (arguments, premises, expressions, variables, claims, sources).
5
+ * Holds five {@link ForkNamespace} instances — one per entity kind
6
+ * (arguments, premises, expressions, variables, claims).
7
7
  * Fork records are immutable after creation and carry no checksums.
8
+ *
9
+ * As of v0.10.0 the legacy `sources` namespace has been folded into
10
+ * `claims` — sources are now claims with `type: "citation"`.
8
11
  */
9
12
  export class ForkLibrary {
10
13
  arguments;
@@ -12,16 +15,14 @@ export class ForkLibrary {
12
15
  expressions;
13
16
  variables;
14
17
  claims;
15
- sources;
16
18
  constructor() {
17
19
  this.arguments = new ForkNamespace(CoreEntityForkRecordSchema);
18
20
  this.premises = new ForkNamespace(CoreEntityForkRecordSchema);
19
21
  this.expressions = new ForkNamespace(CoreExpressionForkRecordSchema);
20
22
  this.variables = new ForkNamespace(CoreEntityForkRecordSchema);
21
23
  this.claims = new ForkNamespace(CoreClaimForkRecordSchema);
22
- this.sources = new ForkNamespace(CoreSourceForkRecordSchema);
23
24
  }
24
- /** Returns a serializable snapshot of all six namespaces. */
25
+ /** Returns a serializable snapshot of all five namespaces. */
25
26
  snapshot() {
26
27
  return {
27
28
  arguments: this.arguments.snapshot(),
@@ -29,10 +30,16 @@ export class ForkLibrary {
29
30
  expressions: this.expressions.snapshot(),
30
31
  variables: this.variables.snapshot(),
31
32
  claims: this.claims.snapshot(),
32
- sources: this.sources.snapshot(),
33
33
  };
34
34
  }
35
- /** Restores a full library from a previously captured snapshot. */
35
+ /**
36
+ * Restores a full library from a previously captured snapshot.
37
+ *
38
+ * Pre-v0.10.0 snapshots that contained a `sources` namespace are not
39
+ * supported here — callers must convert them via the CLI migration
40
+ * (Phase 14) before invoking `fromSnapshot`. Any stray `sources` key on
41
+ * an input snapshot is silently ignored.
42
+ */
36
43
  static fromSnapshot(snapshot) {
37
44
  const lib = new ForkLibrary();
38
45
  for (const record of snapshot.arguments) {
@@ -50,12 +57,9 @@ export class ForkLibrary {
50
57
  for (const record of snapshot.claims) {
51
58
  lib.claims.create(record);
52
59
  }
53
- for (const record of snapshot.sources) {
54
- lib.sources.create(record);
55
- }
56
60
  return lib;
57
61
  }
58
- /** Validates all six namespaces and returns the combined result. */
62
+ /** Validates all five namespaces and returns the combined result. */
59
63
  validate() {
60
64
  const allViolations = [
61
65
  ...this.arguments.validate().violations,
@@ -63,7 +67,6 @@ export class ForkLibrary {
63
67
  ...this.expressions.validate().violations,
64
68
  ...this.variables.validate().violations,
65
69
  ...this.claims.validate().violations,
66
- ...this.sources.validate().violations,
67
70
  ];
68
71
  return { ok: allViolations.length === 0, violations: allViolations };
69
72
  }