@software-dlc/cli 0.192.5 → 0.192.7

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 (78) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/local/local-org.d.ts.map +1 -1
  3. package/dist/local/local-org.js +3 -1
  4. package/dist/local/local-org.js.map +1 -1
  5. package/dist/local/portable-commit-store.d.ts +3 -0
  6. package/dist/local/portable-commit-store.d.ts.map +1 -1
  7. package/dist/local/portable-commit-store.js +7 -0
  8. package/dist/local/portable-commit-store.js.map +1 -1
  9. package/dist/local/portable-commit.d.ts +6 -0
  10. package/dist/local/portable-commit.d.ts.map +1 -1
  11. package/dist/local/portable-commit.js +7 -1
  12. package/dist/local/portable-commit.js.map +1 -1
  13. package/dist/local/workspace-commit-generations.d.ts +66 -0
  14. package/dist/local/workspace-commit-generations.d.ts.map +1 -0
  15. package/dist/local/workspace-commit-generations.js +260 -0
  16. package/dist/local/workspace-commit-generations.js.map +1 -0
  17. package/dist/local/workspace-commit-resolver.d.ts +11 -1
  18. package/dist/local/workspace-commit-resolver.d.ts.map +1 -1
  19. package/dist/local/workspace-commit-resolver.js +13 -3
  20. package/dist/local/workspace-commit-resolver.js.map +1 -1
  21. package/dist/local/workspace-graph-store.d.ts +38 -6
  22. package/dist/local/workspace-graph-store.d.ts.map +1 -1
  23. package/dist/local/workspace-graph-store.js +77 -21
  24. package/dist/local/workspace-graph-store.js.map +1 -1
  25. package/dist/local/workspace-graph-tree.d.ts +1 -1
  26. package/dist/local/workspace-graph-tree.d.ts.map +1 -1
  27. package/dist/local/workspace-graph-tree.js +2 -2
  28. package/dist/local/workspace-graph-tree.js.map +1 -1
  29. package/dist/local/workspace-history-store.d.ts +3 -0
  30. package/dist/local/workspace-history-store.d.ts.map +1 -1
  31. package/dist/local/workspace-history-store.js +32 -6
  32. package/dist/local/workspace-history-store.js.map +1 -1
  33. package/dist/local/workspace-integration-runtime.d.ts.map +1 -1
  34. package/dist/local/workspace-integration-runtime.js +26 -6
  35. package/dist/local/workspace-integration-runtime.js.map +1 -1
  36. package/dist/local/workspace-merge.d.ts +13 -0
  37. package/dist/local/workspace-merge.d.ts.map +1 -1
  38. package/dist/local/workspace-merge.js +16 -6
  39. package/dist/local/workspace-merge.js.map +1 -1
  40. package/dist/local/workspace-mixed-history.d.ts +45 -1
  41. package/dist/local/workspace-mixed-history.d.ts.map +1 -1
  42. package/dist/local/workspace-mixed-history.js +202 -8
  43. package/dist/local/workspace-mixed-history.js.map +1 -1
  44. package/dist/local/workspace-pick-runtime.d.ts.map +1 -1
  45. package/dist/local/workspace-pick-runtime.js +8 -1
  46. package/dist/local/workspace-pick-runtime.js.map +1 -1
  47. package/dist/local/workspace-pick.d.ts +9 -0
  48. package/dist/local/workspace-pick.d.ts.map +1 -1
  49. package/dist/local/workspace-pick.js +16 -7
  50. package/dist/local/workspace-pick.js.map +1 -1
  51. package/dist/local/workspace-portable-authoring.d.ts +8 -2
  52. package/dist/local/workspace-portable-authoring.d.ts.map +1 -1
  53. package/dist/local/workspace-portable-authoring.js +19 -3
  54. package/dist/local/workspace-portable-authoring.js.map +1 -1
  55. package/dist/local/workspace-remote-fetch.d.ts.map +1 -1
  56. package/dist/local/workspace-remote-fetch.js +5 -3
  57. package/dist/local/workspace-remote-fetch.js.map +1 -1
  58. package/dist/local/workspace-resolution.d.ts +3 -1
  59. package/dist/local/workspace-resolution.d.ts.map +1 -1
  60. package/dist/local/workspace-resolution.js +2 -1
  61. package/dist/local/workspace-resolution.js.map +1 -1
  62. package/dist/local/workspace-runtime.d.ts.map +1 -1
  63. package/dist/local/workspace-runtime.js +15 -5
  64. package/dist/local/workspace-runtime.js.map +1 -1
  65. package/dist/local/workspace-store-database.d.ts.map +1 -1
  66. package/dist/local/workspace-store-database.js +11 -0
  67. package/dist/local/workspace-store-database.js.map +1 -1
  68. package/dist/local/workspace-store.d.ts.map +1 -1
  69. package/dist/local/workspace-store.js +2 -1
  70. package/dist/local/workspace-store.js.map +1 -1
  71. package/dist/local/workspace-upstream-runtime.d.ts.map +1 -1
  72. package/dist/local/workspace-upstream-runtime.js +20 -5
  73. package/dist/local/workspace-upstream-runtime.js.map +1 -1
  74. package/dist/portable.d.ts +1 -1
  75. package/dist/portable.d.ts.map +1 -1
  76. package/dist/portable.js +1 -1
  77. package/dist/portable.js.map +1 -1
  78. package/package.json +1 -1
@@ -0,0 +1,260 @@
1
+ /**
2
+ * Commit generations for the local and the mixed local and portable history,
3
+ * kept in local_commit_generation. A commit's generation is one more than the
4
+ * largest generation among its own parents (local or portable rows) and, for
5
+ * a local commit converted to a portable commit, that portable commit. Every
6
+ * edge either history walks, under raw or canonical IDs, therefore runs from a
7
+ * higher generation to a lower one, which is what lets a merge base search
8
+ * stop early.
9
+ *
10
+ * A commit whose ancestry reaches a parent in neither table has no generation:
11
+ * the parent could arrive later with a larger one. Callers take the full walk
12
+ * for such a commit. Rows are filled lazily, reading each missing commit once,
13
+ * and are never rewritten except when a portable mapping added after a fill
14
+ * breaks the order (an external parent mapped to a deeper remote history):
15
+ * then the table is cleared and refilled on demand. Fills and mapping checks
16
+ * hold the store's write lock from their first read to their last write, so a
17
+ * clear, a mapping or another process's fill cannot land between them.
18
+ */
19
+ export class LocalCommitGenerations {
20
+ database;
21
+ /** Commits read by the most recent fill, for tests and cost notes. */
22
+ last_fill_read = 0;
23
+ /** Set while new mappings could not be checked: generations are not read. */
24
+ unchecked = false;
25
+ /** Commits found to have no generation, not read again in this process. */
26
+ unordered = new Set();
27
+ statements = new Map();
28
+ constructor(database) {
29
+ this.database = database;
30
+ }
31
+ /** The stored generation of a commit, filling its ancestry if needed. */
32
+ generation(commit_id) {
33
+ if (this.unchecked || this.unordered.has(commit_id))
34
+ return null;
35
+ const stored = this.stored(commit_id);
36
+ if (stored !== null)
37
+ return stored;
38
+ return this.locked(() => this.fill(commit_id)) ?? null;
39
+ }
40
+ /**
41
+ * Checks the portable mappings added since the last check. A mapping whose
42
+ * stored local generation does not sit above its portable commit's (or whose
43
+ * portable commit has none) clears the table. Each bounded search calls this
44
+ * first; when the check cannot run, generations are not read until one does.
45
+ */
46
+ checkMappings() {
47
+ // A stale read here only sends the check under the lock.
48
+ if (this.newestMapping() <= this.state('mapping_rowid')) {
49
+ this.unchecked = false;
50
+ return;
51
+ }
52
+ const checked = this.locked(() => {
53
+ const from = this.state('mapping_rowid');
54
+ const newest = this.newestMapping();
55
+ if (newest <= from)
56
+ return true;
57
+ const mappings = this.statement(`select local_commit_id, portable_commit_id
58
+ from local_commit_portable_mapping where rowid > ?`).all(from);
59
+ const broken = mappings.some((mapping) => {
60
+ // The stored row decides, not what this process remembers.
61
+ const local = this.stored(mapping.local_commit_id);
62
+ if (local === null)
63
+ return false;
64
+ const portable = this.stored(mapping.portable_commit_id) ??
65
+ this.fill(mapping.portable_commit_id);
66
+ return portable === null || portable >= local;
67
+ });
68
+ if (broken) {
69
+ this.database.exec('delete from local_commit_generation');
70
+ this.unordered.clear();
71
+ }
72
+ this.statement(`insert into local_commit_generation_state (key, value)
73
+ values ('mapping_rowid', ?)
74
+ on conflict(key) do update set value = max(value, excluded.value)`).run(newest);
75
+ return true;
76
+ });
77
+ this.unchecked = checked !== true;
78
+ }
79
+ newestMapping() {
80
+ const { newest } = this.statement('select max(rowid) as newest from local_commit_portable_mapping').get();
81
+ return newest ?? 0;
82
+ }
83
+ /**
84
+ * Records a new local commit's generation when every parent has one, in the
85
+ * caller's transaction. A commit with an unfilled parent is left to the fill.
86
+ */
87
+ recordNewLocalCommit(commit_id, parent_ids) {
88
+ let generation = 1;
89
+ for (const parent_id of parent_ids) {
90
+ const parent = this.stored(parent_id);
91
+ if (parent === null)
92
+ return;
93
+ generation = Math.max(generation, parent + 1);
94
+ }
95
+ this.statement('insert or ignore into local_commit_generation (commit_id, generation) values (?, ?)').run(commit_id, generation);
96
+ }
97
+ statement(sql) {
98
+ let statement = this.statements.get(sql);
99
+ if (!statement) {
100
+ statement = this.database.prepare(sql);
101
+ this.statements.set(sql, statement);
102
+ }
103
+ return statement;
104
+ }
105
+ /**
106
+ * Runs a fill or a mapping check with its reads and writes under the
107
+ * store's write lock, so no clear, mapping or other fill lands between what
108
+ * it read and what it writes. Inside a caller's transaction (which holds
109
+ * the lock: the stores open theirs with begin immediate) it nests as a
110
+ * savepoint. Generations are derived: when the lock cannot be had (a busy
111
+ * store) the operation is skipped and the caller walks in full.
112
+ */
113
+ locked(operation) {
114
+ // isTransaction is node:sqlite 22.16+; the package supports every Node 22,
115
+ // so without it a begin inside a transaction is told by its error.
116
+ const known = this.database.isTransaction;
117
+ let nested = known === true;
118
+ try {
119
+ this.database.exec(nested ? 'savepoint local_commit_generation' : 'begin immediate');
120
+ }
121
+ catch (error) {
122
+ if (typeof known === 'boolean' ||
123
+ !/within a transaction/i.test(error.message)) {
124
+ return undefined;
125
+ }
126
+ nested = true;
127
+ try {
128
+ this.database.exec('savepoint local_commit_generation');
129
+ }
130
+ catch {
131
+ return undefined;
132
+ }
133
+ }
134
+ try {
135
+ const result = operation();
136
+ this.database.exec(nested ? 'release local_commit_generation' : 'commit');
137
+ return result;
138
+ }
139
+ catch {
140
+ this.database.exec(nested
141
+ ? 'rollback to local_commit_generation; release local_commit_generation'
142
+ : 'rollback');
143
+ return undefined;
144
+ }
145
+ }
146
+ stored(commit_id) {
147
+ const row = this.statement('select generation from local_commit_generation where commit_id = ?').get(commit_id);
148
+ return row?.generation ?? null;
149
+ }
150
+ state(key) {
151
+ const row = this.statement('select value from local_commit_generation_state where key = ?').get(key);
152
+ return row?.value ?? 0;
153
+ }
154
+ /** The parents a generation counts, or null for a commit in neither table. */
155
+ node(commit_id) {
156
+ const local = this.statement('select parent_ids_json from local_workspace_commit where id = ?').get(commit_id);
157
+ if (local) {
158
+ const parent_ids = JSON.parse(local.parent_ids_json);
159
+ const mapping = this.statement('select portable_commit_id from local_commit_portable_mapping where local_commit_id = ?').get(commit_id);
160
+ return {
161
+ parent_ids: mapping
162
+ ? [...parent_ids, mapping.portable_commit_id]
163
+ : parent_ids
164
+ };
165
+ }
166
+ const portable = this.statement('select commit_json from portable_commit where id = ?').get(commit_id);
167
+ if (!portable)
168
+ return null;
169
+ const commit = JSON.parse(portable.commit_json);
170
+ return {
171
+ parent_ids: Array.isArray(commit.parent_ids)
172
+ ? commit.parent_ids.filter((parent_id) => typeof parent_id === 'string')
173
+ : []
174
+ };
175
+ }
176
+ /**
177
+ * Fills the generations of a commit's unfilled ancestry in one pass, each
178
+ * commit read once, and stores them. Runs only under locked(), so what it
179
+ * read is still what the table holds when it writes.
180
+ */
181
+ fill(commit_id) {
182
+ const computed = new Map();
183
+ const nodes = new Map();
184
+ const known = (id) => {
185
+ if (computed.has(id))
186
+ return computed.get(id);
187
+ const stored = this.stored(id);
188
+ if (stored !== null) {
189
+ computed.set(id, stored);
190
+ return stored;
191
+ }
192
+ if (this.unordered.has(id)) {
193
+ computed.set(id, null);
194
+ return null;
195
+ }
196
+ return undefined;
197
+ };
198
+ const stack = [
199
+ { id: commit_id, expanded: false }
200
+ ];
201
+ // Expanded commits not yet finished: the path the walk is on.
202
+ const on_path = new Set();
203
+ let read = 0;
204
+ while (stack.length > 0) {
205
+ const top = stack[stack.length - 1];
206
+ if (!top.expanded) {
207
+ if (known(top.id) !== undefined) {
208
+ stack.pop();
209
+ continue;
210
+ }
211
+ top.expanded = true;
212
+ on_path.add(top.id);
213
+ const node = this.node(top.id);
214
+ read += 1;
215
+ nodes.set(top.id, node);
216
+ for (const parent_id of node?.parent_ids ?? []) {
217
+ if (on_path.has(parent_id)) {
218
+ // A cycle has no generation order; the walk falls back.
219
+ computed.set(top.id, null);
220
+ }
221
+ else if (known(parent_id) === undefined) {
222
+ stack.push({ id: parent_id, expanded: false });
223
+ }
224
+ }
225
+ continue;
226
+ }
227
+ stack.pop();
228
+ on_path.delete(top.id);
229
+ if (computed.has(top.id))
230
+ continue;
231
+ const node = nodes.get(top.id);
232
+ let generation = node ? 1 : null;
233
+ for (const parent_id of node?.parent_ids ?? []) {
234
+ const parent = computed.get(parent_id);
235
+ if (parent === null || parent === undefined) {
236
+ generation = null;
237
+ break;
238
+ }
239
+ generation = Math.max(generation, parent + 1);
240
+ }
241
+ computed.set(top.id, generation);
242
+ }
243
+ this.last_fill_read = read;
244
+ const filled = [];
245
+ for (const id of nodes.keys()) {
246
+ const generation = computed.get(id);
247
+ if (generation === null || generation === undefined) {
248
+ this.unordered.add(id);
249
+ }
250
+ else {
251
+ filled.push([id, generation]);
252
+ }
253
+ }
254
+ const insert = this.statement('insert or ignore into local_commit_generation (commit_id, generation) values (?, ?)');
255
+ for (const [id, generation] of filled)
256
+ insert.run(id, generation);
257
+ return computed.get(commit_id) ?? null;
258
+ }
259
+ }
260
+ //# sourceMappingURL=workspace-commit-generations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-commit-generations.js","sourceRoot":"","sources":["../../src/local/workspace-commit-generations.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,sBAAsB;IASJ;IAR7B,sEAAsE;IACtE,cAAc,GAAG,CAAC,CAAC;IACnB,6EAA6E;IACrE,SAAS,GAAG,KAAK,CAAC;IAC1B,2EAA2E;IAC1D,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,UAAU,GAAG,IAAI,GAAG,EAAqB,CAAC;IAE3D,YAA6B,QAAqC;QAArC,aAAQ,GAAR,QAAQ,CAA6B;IAAG,CAAC;IAEtE,yEAAyE;IACzE,UAAU,CAAC,SAAiB;QAC1B,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC;YAAE,OAAO,IAAI,CAAC;QACjE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACtC,IAAI,MAAM,KAAK,IAAI;YAAE,OAAO,MAAM,CAAC;QACnC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAA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AAM,GAAG,CAAC,CAAC,CAAC;YACjD,CAAC;YACD,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QACnC,CAAC;QACD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,MAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YAC9B,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACpC,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;gBACpD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACzB,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAC3B,qFAAqF,CACtF,CAAC;QACF,KAAK,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,IAAI,MAAM;YAAE,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QAClE,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC;IACzC,CAAC;CACF"}
@@ -10,8 +10,18 @@ export declare class LocalWorkspaceCommitResolver {
10
10
  private readonly mixed_history;
11
11
  constructor(store: LocalWorkspaceStore, graphs: LocalWorkspaceGraphStore);
12
12
  root(commit_id: string): string;
13
+ /**
14
+ * The root a commit has in the mixed local and portable history: a local
15
+ * commit converted to a portable commit reads as that commit, whose root is
16
+ * the whole-graph sha256 root, while its own row keeps the tree root it was
17
+ * written with. The upstream store checks merge and revert evidence against
18
+ * this reading, so evidence for it is taken here, not from root().
19
+ */
20
+ historyRoot(commit_id: string): string;
13
21
  readGraph(commit_id: string): Promise<PortableGraph>;
14
- writeGraph(graph: PortableGraph): Promise<string>;
22
+ writeGraph(graph: PortableGraph, options?: {
23
+ base?: string | null;
24
+ }): Promise<string>;
15
25
  compare(local_commit_id: string, upstream_commit_id: string): LocalCommitRelation;
16
26
  findMergeBase(first_commit_id: string, second_commit_id: string): string;
17
27
  private canonicalCommitId;
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-commit-resolver.d.ts","sourceRoot":"","sources":["../../src/local/workspace-commit-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,YAAY,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE,6EAA6E;AAC7E,qBAAa,4BAA4B;IAIrC,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJzB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyB;gBAGpC,KAAK,EAAE,mBAAmB,EAC1B,MAAM,EAAE,wBAAwB;IAoBnD,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAQ/B,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAIpD,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjD,OAAO,CACL,eAAe,EAAE,MAAM,EACvB,kBAAkB,EAAE,MAAM,GACzB,mBAAmB;IAItB,aAAa,CAAC,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM;IAIxE,OAAO,CAAC,iBAAiB;CAI1B"}
1
+ {"version":3,"file":"workspace-commit-resolver.d.ts","sourceRoot":"","sources":["../../src/local/workspace-commit-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,YAAY,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE,6EAA6E;AAC7E,qBAAa,4BAA4B;IAIrC,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJzB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyB;gBAGpC,KAAK,EAAE,mBAAmB,EAC1B,MAAM,EAAE,wBAAwB;IAqBnD,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAQ/B;;;;;;OAMG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAItC,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAIpD,UAAU,CACR,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAO,GACrC,OAAO,CAAC,MAAM,CAAC;IAIlB,OAAO,CACL,eAAe,EAAE,MAAM,EACvB,kBAAkB,EAAE,MAAM,GACzB,mBAAmB;IAItB,aAAa,CAAC,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM;IAIxE,OAAO,CAAC,iBAAiB;CAI1B"}
@@ -19,18 +19,28 @@ export class LocalWorkspaceCommitResolver {
19
19
  return local
20
20
  ? { root_hash: local.root_hash, parent_ids: local.parent_ids }
21
21
  : null;
22
- });
22
+ }, this.store.history.generations);
23
23
  }
24
24
  root(commit_id) {
25
25
  return (this.store.history.getCommit(commit_id)?.root_hash ??
26
26
  this.store.portable_commits.getCommit(commit_id)?.graph_root ??
27
27
  commit_id);
28
28
  }
29
+ /**
30
+ * The root a commit has in the mixed local and portable history: a local
31
+ * commit converted to a portable commit reads as that commit, whose root is
32
+ * the whole-graph sha256 root, while its own row keeps the tree root it was
33
+ * written with. The upstream store checks merge and revert evidence against
34
+ * this reading, so evidence for it is taken here, not from root().
35
+ */
36
+ historyRoot(commit_id) {
37
+ return this.mixed_history.root(commit_id);
38
+ }
29
39
  readGraph(commit_id) {
30
40
  return this.graphs.readGraph(this.root(commit_id));
31
41
  }
32
- writeGraph(graph) {
33
- return this.graphs.writeGraph(graph);
42
+ writeGraph(graph, options = {}) {
43
+ return this.graphs.writeGraph(graph, options);
34
44
  }
35
45
  compare(local_commit_id, upstream_commit_id) {
36
46
  return this.mixed_history.compare(local_commit_id, upstream_commit_id);
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-commit-resolver.js","sourceRoot":"","sources":["../../src/local/workspace-commit-resolver.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,sBAAsB,EAEvB,MAAM,8BAA8B,CAAC;AAItC,6EAA6E;AAC7E,MAAM,OAAO,4BAA4B;IAIpB;IACA;IAJF,aAAa,CAAyB;IAEvD,YACmB,KAA0B,EAC1B,MAAgC;QADhC,UAAK,GAAL,KAAK,CAAqB;QAC1B,WAAM,GAAN,MAAM,CAA0B;QAEjD,IAAI,CAAC,aAAa,GAAG,IAAI,sBAAsB,CAC7C,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAChD,CAAC,SAAS,EAAE,EAAE;YACZ,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;YAClE,IAAI,QAAQ,EAAE,CAAC;gBACb,OAAO;oBACL,SAAS,EAAE,QAAQ,CAAC,UAAU;oBAC9B,UAAU,EAAE,QAAQ,CAAC,UAAU;iBAChC,CAAC;YACJ,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5D,SAAS,CACV,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,SAAiB;QAC3B,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED,SAAS,CAAC,SAAiB;QACzB,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,UAAU,CACR,KAAoB,EACpB,UAAoC,EAAE;QAEtC,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,CACL,eAAuB,EACvB,kBAA0B;QAE1B,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAAC;IACzE,CAAC;IAED,aAAa,CAAC,eAAuB,EAAE,gBAAwB;QAC7D,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;IAC7E,CAAC;IAEO,iBAAiB,CAAC,SAAiB;QACzC,IAAI,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;QACvE,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC;IAC7E,CAAC;CACF"}
@@ -1,6 +1,6 @@
1
1
  import type { PortableGraph } from '@software-dlc/graph/types';
2
2
  import { type LocalGraphTreeChange } from './workspace-graph-tree.js';
3
- export { graphRootFor, isTreeRoot, localGraphRootHash, localGraphTreeRoot, type LocalGraphTreeChange } from './workspace-graph-tree.js';
3
+ export { graphRootFor, isTreeRoot, localWholeGraphRoot, localGraphTreeRoot, type LocalGraphTreeChange } from './workspace-graph-tree.js';
4
4
  export declare function resolveLocalRepositoryStateDirectory(input: {
5
5
  git_common_dir: string;
6
6
  override?: string;
@@ -15,7 +15,38 @@ export type LocalWorkspaceGraphObjectPruneResult = 'removed' | 'absent' | 'chang
15
15
  export declare class LocalWorkspaceGraphStore {
16
16
  readonly state_dir: string;
17
17
  constructor(state_dir: string);
18
- writeGraph(graph: PortableGraph): Promise<string>;
18
+ /**
19
+ * Stores a graph as a tree and returns its tree root. `base`, the root the
20
+ * graph was changed from, lets the write skip every subtree the two share:
21
+ * a tree root is used as it is, and a whole-graph root through its alias,
22
+ * which a legacy root without one gets now (one whole-tree write). A base
23
+ * that cannot be read is ignored, so the write stores the whole tree.
24
+ */
25
+ writeGraph(graph: PortableGraph, options?: {
26
+ base?: string | null;
27
+ }): Promise<string>;
28
+ /**
29
+ * Stores a graph as a tree under its whole-graph root: the tree, and an
30
+ * alias naming it once it reads back with that root. For the roots that
31
+ * must keep the sha256 form, as a workspace's first head and a graph a
32
+ * remote names.
33
+ */
34
+ writeWholeGraph(graph: PortableGraph, options?: {
35
+ base?: string | null;
36
+ }): Promise<string>;
37
+ /**
38
+ * The whole-graph root of a stored root: a whole-graph root is its own, and
39
+ * a tree root's is computed from its stored objects and given an alias, so
40
+ * the graph reads by either root.
41
+ */
42
+ wholeGraphRoot(root: string): Promise<string>;
43
+ private readonly whole_roots;
44
+ /**
45
+ * Stores a graph as one legacy whole-graph object, as stores did before
46
+ * trees. Commits no longer write these; it keeps legacy stores reproducible
47
+ * for the readers and migrations that must still handle them.
48
+ */
49
+ writeLegacyGraph(graph: PortableGraph): Promise<string>;
19
50
  private withGraphObjectLock;
20
51
  withObjectStoreLock<T>(operation: string, run: () => Promise<T>): Promise<T>;
21
52
  listGraphObjects(): Promise<LocalWorkspaceGraphObject[]>;
@@ -53,14 +84,15 @@ export declare class LocalWorkspaceGraphStore {
53
84
  * a read sets once the stored pack failed to verify.
54
85
  */
55
86
  private writeTreePack;
87
+ private readonly tree_shards;
56
88
  /**
57
89
  * Stores one tree object. An object already stored is not rewritten; its
58
90
  * mtime is refreshed, so a prune that started before this write keeps it.
59
- * Returns whether the object was created.
91
+ * `present` holds the objects this write has already stored or refreshed;
92
+ * it lives for one write, so a long-lived process checks the disk again on
93
+ * its next write rather than trusting what an earlier one saw. Returns
94
+ * whether the object was created.
60
95
  */
61
- private readonly tree_shards;
62
- /** Objects this process has stored or refreshed, which need neither again. */
63
- private readonly tree_present;
64
96
  private writeTreeObject;
65
97
  /**
66
98
  * Reads a tree root as a graph. With `objects`, it reads the bucket and
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-graph-store.d.ts","sourceRoot":"","sources":["../../src/local/workspace-graph-store.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAM/D,OAAO,EAcL,KAAK,oBAAoB,EAM1B,MAAM,2BAA2B,CAAC;AASnC,OAAO,EACL,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,oBAAoB,EAC1B,MAAM,2BAA2B,CAAC;AAYnC,wBAAgB,oCAAoC,CAAC,KAAK,EAAE;IAC1D,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,CAOT;AAyBD,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAC5C,SAAS,GACT,QAAQ,GACR,SAAS,GACT,UAAU,CAAC;AAEf,qBAAa,wBAAwB;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,SAAS,EAAE,MAAM;IAQvB,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;YAWzC,mBAAmB;IAoB3B,mBAAmB,CAAC,CAAC,EACzB,SAAS,EAAE,MAAM,EACjB,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+EAA+E;YACjE,iBAAiB;YAYjB,UAAU;IA6BxB,2EAA2E;YAC7D,aAAa;IAY3B;;;;;;;OAOG;IACG,OAAO,CACX,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAO,GACrC,OAAO,CAAC,MAAM,CAAC;IAclB;;;;OAIG;IACG,SAAS,CACb,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;QAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC;QAAC,gBAAgB,EAAE,OAAO,CAAA;KAAE,CAAC;IAS1E,2EAA2E;IACrE,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAKrE"}
@@ -3,10 +3,10 @@ import { chmod, link, lstat, mkdir, readdir, readFile, rename, rm, unlink, utime
3
3
  import { dirname, isAbsolute, join, resolve } from 'node:path';
4
4
  import { portable_graph_schema } from '@software-dlc/graph/schema';
5
5
  import { canonicalizePortableGraph, stringifyCanonicalGraph } from './canonical.js';
6
- import { computeLocalGraphTree, diffLocalGraphTrees, isTreeRoot, localGraphRootHash, parseTreePack, readLocalGraphTree, TREE_FORMAT, TREE_ENTITY_KINDS, treeObjectHash, treeObjectJson, treePackText, treeRootDigest } from './workspace-graph-tree.js';
6
+ import { computeLocalGraphTree, diffLocalGraphTrees, isTreeRoot, localWholeGraphRoot, parseTreePack, readLocalGraphTree, TREE_FORMAT, TREE_ENTITY_KINDS, treeObjectHash, treeObjectJson, treePackText, treeRootDigest } from './workspace-graph-tree.js';
7
7
  import { withWorkspaceOperationLock } from './workspace-lock.js';
8
8
  import { noteGraphNodes, noteObjectRead, noteObjectWritten, noteStoreOpened } from './operation-costs.js';
9
- export { graphRootFor, isTreeRoot, localGraphRootHash, localGraphTreeRoot } from './workspace-graph-tree.js';
9
+ export { graphRootFor, isTreeRoot, localWholeGraphRoot, localGraphTreeRoot } from './workspace-graph-tree.js';
10
10
  const SHA256_ROOT_PATTERN = /^sha256:([0-9a-f]{64})$/;
11
11
  const OBJECT_HASH_PATTERN = /^[0-9a-f]{64}$/;
12
12
  /** Tree objects written at once; enough to hide file latency, few enough for any fd limit. */
@@ -51,7 +51,59 @@ export class LocalWorkspaceGraphStore {
51
51
  this.state_dir = resolve(state_dir);
52
52
  noteStoreOpened(this.state_dir);
53
53
  }
54
- async writeGraph(graph) {
54
+ /**
55
+ * Stores a graph as a tree and returns its tree root. `base`, the root the
56
+ * graph was changed from, lets the write skip every subtree the two share:
57
+ * a tree root is used as it is, and a whole-graph root through its alias,
58
+ * which a legacy root without one gets now (one whole-tree write). A base
59
+ * that cannot be read is ignored, so the write stores the whole tree.
60
+ */
61
+ async writeGraph(graph, options = {}) {
62
+ let base = null;
63
+ if (options.base) {
64
+ base = await this.treeFor(options.base).catch(() => null);
65
+ }
66
+ return (await this.writeGraphTree(graph, { base })).root;
67
+ }
68
+ /**
69
+ * Stores a graph as a tree under its whole-graph root: the tree, and an
70
+ * alias naming it once it reads back with that root. For the roots that
71
+ * must keep the sha256 form, as a workspace's first head and a graph a
72
+ * remote names.
73
+ */
74
+ async writeWholeGraph(graph, options = {}) {
75
+ const whole_root = localWholeGraphRoot(graph);
76
+ let base = null;
77
+ if (options.base) {
78
+ base = await this.treeFor(options.base).catch(() => null);
79
+ }
80
+ await this.recordTreeAlias(whole_root, graph, { base });
81
+ return whole_root;
82
+ }
83
+ /**
84
+ * The whole-graph root of a stored root: a whole-graph root is its own, and
85
+ * a tree root's is computed from its stored objects and given an alias, so
86
+ * the graph reads by either root.
87
+ */
88
+ async wholeGraphRoot(root) {
89
+ if (!isTreeRoot(root))
90
+ return root;
91
+ const known = this.whole_roots.get(root);
92
+ if (known)
93
+ return known;
94
+ const stored = await this.readTreeGraph(root, { objects: true });
95
+ const whole_root = localWholeGraphRoot(stored);
96
+ await this.writeAlias(whole_root, root);
97
+ this.whole_roots.set(root, whole_root);
98
+ return whole_root;
99
+ }
100
+ whole_roots = new Map();
101
+ /**
102
+ * Stores a graph as one legacy whole-graph object, as stores did before
103
+ * trees. Commits no longer write these; it keeps legacy stores reproducible
104
+ * for the readers and migrations that must still handle them.
105
+ */
106
+ async writeLegacyGraph(graph) {
55
107
  noteGraphNodes(graph.nodes.length);
56
108
  // The object holds exactly the canonical JSON its name hashes, so a read
57
109
  // verifies it by hashing its bytes.
@@ -259,7 +311,7 @@ export class LocalWorkspaceGraphStore {
259
311
  const alias = await this.readAlias(root_hash);
260
312
  if (alias) {
261
313
  const graph = await this.readTreeGraph(alias);
262
- if (localGraphRootHash(graph) !== root_hash) {
314
+ if (localWholeGraphRoot(graph) !== root_hash) {
263
315
  throw new Error(`Local graph alias ${root_hash} failed verification.`);
264
316
  }
265
317
  return graph;
@@ -273,7 +325,7 @@ export class LocalWorkspaceGraphStore {
273
325
  // serializing it again. Bytes that are not canonical (an older writer)
274
326
  // are verified by their canonical form.
275
327
  if (sha256Root(text) !== root_hash &&
276
- localGraphRootHash(graph) !== root_hash) {
328
+ localWholeGraphRoot(graph) !== root_hash) {
277
329
  throw new Error(`Local graph object ${root_hash} failed verification.`);
278
330
  }
279
331
  noteGraphNodes(graph.nodes.length);
@@ -425,23 +477,24 @@ export class LocalWorkspaceGraphStore {
425
477
  await rm(temporary, { force: true });
426
478
  }
427
479
  }
480
+ tree_shards = new Set();
428
481
  /**
429
482
  * Stores one tree object. An object already stored is not rewritten; its
430
483
  * mtime is refreshed, so a prune that started before this write keeps it.
431
- * Returns whether the object was created.
484
+ * `present` holds the objects this write has already stored or refreshed;
485
+ * it lives for one write, so a long-lived process checks the disk again on
486
+ * its next write rather than trusting what an earlier one saw. Returns
487
+ * whether the object was created.
432
488
  */
433
- tree_shards = new Set();
434
- /** Objects this process has stored or refreshed, which need neither again. */
435
- tree_present = new Set();
436
- async writeTreeObject(hash, json) {
437
- if (this.tree_present.has(hash))
489
+ async writeTreeObject(hash, json, present) {
490
+ if (present.has(hash))
438
491
  return false;
439
492
  const path = this.treeObjectPath(hash);
440
493
  try {
441
494
  if ((await lstat(path)).isFile()) {
442
495
  const retained_at = new Date();
443
496
  await utimes(path, retained_at, retained_at);
444
- this.tree_present.add(hash);
497
+ present.add(hash);
445
498
  return false;
446
499
  }
447
500
  }
@@ -480,7 +533,7 @@ export class LocalWorkspaceGraphStore {
480
533
  const retained_at = new Date();
481
534
  await utimes(path, retained_at, retained_at);
482
535
  }
483
- this.tree_present.add(hash);
536
+ present.add(hash);
484
537
  return created;
485
538
  }
486
539
  /**
@@ -506,8 +559,10 @@ export class LocalWorkspaceGraphStore {
506
559
  async writeGraphTree(graph, options = {}) {
507
560
  noteGraphNodes(graph.nodes.length);
508
561
  const tree = computeLocalGraphTree(graph);
562
+ // A base object that does not read leaves its subtree to be written whole.
563
+ const readBase = (hash, type) => this.readTreeObject(hash, type).catch(() => null);
509
564
  const base = options.base && isTreeRoot(options.base)
510
- ? await this.readTreeObject(treeRootDigest(options.base), 'root')
565
+ ? await readBase(treeRootDigest(options.base), 'root')
511
566
  : null;
512
567
  // The objects that differ from the base, by level.
513
568
  const entities = [];
@@ -523,7 +578,7 @@ export class LocalWorkspaceGraphStore {
523
578
  if (base_set_hash === set.hash)
524
579
  continue;
525
580
  const base_set = base_set_hash
526
- ? await this.readTreeObject(base_set_hash, 'set')
581
+ ? await readBase(base_set_hash, 'set')
527
582
  : null;
528
583
  for (const [key, bucket_hash] of Object.entries(set.object.buckets)) {
529
584
  const base_bucket_hash = base_set?.buckets[key];
@@ -531,7 +586,7 @@ export class LocalWorkspaceGraphStore {
531
586
  continue;
532
587
  const bucket = tree.buckets.get(bucket_hash);
533
588
  const base_bucket = base_bucket_hash
534
- ? await this.readTreeObject(base_bucket_hash, 'bucket')
589
+ ? await readBase(base_bucket_hash, 'bucket')
535
590
  : null;
536
591
  const kept = new Set(base_bucket?.entries.map((entry) => entry[1]));
537
592
  for (const [, entity_hash] of bucket.entries) {
@@ -553,13 +608,14 @@ export class LocalWorkspaceGraphStore {
553
608
  }
554
609
  // Children before parents, so a stored parent always has its children.
555
610
  let written = 0;
611
+ const present = new Set();
556
612
  for (const level of [
557
613
  entities,
558
614
  buckets,
559
615
  sets,
560
616
  [[treeRootDigest(tree.root), treeObjectJson(tree.root_object)]]
561
617
  ]) {
562
- written += await this.writeTreeObjects(level);
618
+ written += await this.writeTreeObjects(level, present);
563
619
  }
564
620
  // Packs are not objects: `written` counts tree objects only. A pack is
565
621
  // derived, so failing to store one (a full disk) leaves a stored tree
@@ -575,13 +631,13 @@ export class LocalWorkspaceGraphStore {
575
631
  return { root: tree.root, written };
576
632
  }
577
633
  /** Writes one level of a tree, a bounded number of files at a time. */
578
- async writeTreeObjects(objects) {
634
+ async writeTreeObjects(objects, present) {
579
635
  let created = 0;
580
636
  let next = 0;
581
637
  const worker = async () => {
582
638
  while (next < objects.length) {
583
639
  const [hash, json] = objects[next++];
584
- if (await this.writeTreeObject(hash, json))
640
+ if (await this.writeTreeObject(hash, json, present))
585
641
  created += 1;
586
642
  }
587
643
  };
@@ -637,7 +693,7 @@ export class LocalWorkspaceGraphStore {
637
693
  // The objects, not the packs: an alias is recorded only over a tree whose
638
694
  // stored objects verify.
639
695
  const stored = await this.readTreeGraph(root, { objects: true });
640
- return { root, verified: localGraphRootHash(stored) === whole_root };
696
+ return { root, verified: localWholeGraphRoot(stored) === whole_root };
641
697
  }
642
698
  async writeAlias(whole_root, root) {
643
699
  const path = this.aliasPath(whole_root);
@@ -676,7 +732,7 @@ export class LocalWorkspaceGraphStore {
676
732
  const alias = await this.readAlias(root_hash);
677
733
  if (!alias)
678
734
  return null;
679
- if (localGraphRootHash(await this.readTreeGraph(alias)) !== root_hash) {
735
+ if (localWholeGraphRoot(await this.readTreeGraph(alias)) !== root_hash) {
680
736
  throw new Error(`Local graph alias ${root_hash} failed verification.`);
681
737
  }
682
738
  this.verified_aliases.set(root_hash, alias);