@amalgm/shell 0.1.164-main.40070365614 → 0.1.164-main.40795482467

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 (319) hide show
  1. package/dist/accepted-fold.d.ts +24 -46
  2. package/dist/accepted-fold.js +62 -140
  3. package/dist/accepted-fold.js.map +1 -1
  4. package/dist/accepted-tail.d.ts +3 -3
  5. package/dist/accepted-tail.js +6 -6
  6. package/dist/accepted-tail.js.map +1 -1
  7. package/dist/apply-control.d.ts +9 -4
  8. package/dist/apply-control.js +18 -5
  9. package/dist/apply-control.js.map +1 -1
  10. package/dist/apply-enter-build.d.ts +6 -7
  11. package/dist/apply-enter-build.js +4 -10
  12. package/dist/apply-enter-build.js.map +1 -1
  13. package/dist/apply-enter-plan.d.ts +9 -7
  14. package/dist/apply-enter-plan.js +40 -27
  15. package/dist/apply-enter-plan.js.map +1 -1
  16. package/dist/apply-local-work.d.ts +8 -20
  17. package/dist/apply-local-work.js +18 -95
  18. package/dist/apply-local-work.js.map +1 -1
  19. package/dist/apply-showing.d.ts +15 -1
  20. package/dist/apply-showing.js +26 -4
  21. package/dist/apply-showing.js.map +1 -1
  22. package/dist/apply-window-ground.d.ts +7 -9
  23. package/dist/apply-window-ground.js +16 -11
  24. package/dist/apply-window-ground.js.map +1 -1
  25. package/dist/apply-window-host.d.ts +29 -4
  26. package/dist/apply-window-host.js +212 -280
  27. package/dist/apply-window-host.js.map +1 -1
  28. package/dist/apply-window-line.d.ts +2 -1
  29. package/dist/apply-window-line.js +5 -4
  30. package/dist/apply-window-line.js.map +1 -1
  31. package/dist/apply-window-recovery.js +18 -30
  32. package/dist/apply-window-recovery.js.map +1 -1
  33. package/dist/apply-window-reveal.d.ts +0 -7
  34. package/dist/apply-window-reveal.js +5 -48
  35. package/dist/apply-window-reveal.js.map +1 -1
  36. package/dist/apply-window-rows.d.ts +1 -24
  37. package/dist/apply-window-rows.js.map +1 -1
  38. package/dist/apply-window-saves.d.ts +16 -9
  39. package/dist/apply-window-saves.js +65 -19
  40. package/dist/apply-window-saves.js.map +1 -1
  41. package/dist/apply-window-store.d.ts +6 -6
  42. package/dist/apply-window-store.js +7 -4
  43. package/dist/apply-window-store.js.map +1 -1
  44. package/dist/apply-window-verify.d.ts +4 -7
  45. package/dist/apply-window-verify.js +4 -23
  46. package/dist/apply-window-verify.js.map +1 -1
  47. package/dist/baseline-content.d.ts +3 -5
  48. package/dist/baseline-content.js +7 -44
  49. package/dist/baseline-content.js.map +1 -1
  50. package/dist/content-cache-retention.d.ts +3 -2
  51. package/dist/content-cache-retention.js +11 -11
  52. package/dist/content-cache-retention.js.map +1 -1
  53. package/dist/content-capture-pool.d.ts +4 -47
  54. package/dist/content-capture-pool.js +3 -42
  55. package/dist/content-capture-pool.js.map +1 -1
  56. package/dist/content-capture-worker.d.ts +2 -3
  57. package/dist/content-capture-worker.js +2 -19
  58. package/dist/content-capture-worker.js.map +1 -1
  59. package/dist/declaration-absorption.d.ts +9 -15
  60. package/dist/declaration-absorption.js +14 -32
  61. package/dist/declaration-absorption.js.map +1 -1
  62. package/dist/declaration-commit.d.ts +0 -5
  63. package/dist/declaration-commit.js +1 -6
  64. package/dist/declaration-commit.js.map +1 -1
  65. package/dist/declaration-save.d.ts +0 -4
  66. package/dist/declaration-save.js +0 -4
  67. package/dist/declaration-save.js.map +1 -1
  68. package/dist/detection/accepted-result.js +1 -1
  69. package/dist/detection/accepted-result.js.map +1 -1
  70. package/dist/detection/admission-save.d.ts +7 -17
  71. package/dist/detection/admission-save.js +4 -11
  72. package/dist/detection/admission-save.js.map +1 -1
  73. package/dist/detection/admission-units.d.ts +10 -26
  74. package/dist/detection/admission-units.js +12 -50
  75. package/dist/detection/admission-units.js.map +1 -1
  76. package/dist/detection/apply-ownership.d.ts +2 -2
  77. package/dist/detection/apply-ownership.js +2 -7
  78. package/dist/detection/apply-ownership.js.map +1 -1
  79. package/dist/detection/capture-outcome.js +12 -19
  80. package/dist/detection/capture-outcome.js.map +1 -1
  81. package/dist/detection/dispositions.d.ts +1 -1
  82. package/dist/detection/dispositions.js +3 -4
  83. package/dist/detection/dispositions.js.map +1 -1
  84. package/dist/detection/ground-proof.d.ts +1 -3
  85. package/dist/detection/ground-proof.js +0 -9
  86. package/dist/detection/ground-proof.js.map +1 -1
  87. package/dist/detection/ground-reader.d.ts +1 -5
  88. package/dist/detection/ground-reader.js +1 -31
  89. package/dist/detection/ground-reader.js.map +1 -1
  90. package/dist/detection/notebook-basis.d.ts +1 -2
  91. package/dist/detection/notebook-basis.js +2 -4
  92. package/dist/detection/notebook-basis.js.map +1 -1
  93. package/dist/detection/owed-selection.d.ts +2 -3
  94. package/dist/detection/owed-selection.js +3 -6
  95. package/dist/detection/owed-selection.js.map +1 -1
  96. package/dist/detection/portable.d.ts +7 -48
  97. package/dist/detection/portable.js +46 -155
  98. package/dist/detection/portable.js.map +1 -1
  99. package/dist/detection/repository-state.d.ts +35 -0
  100. package/dist/detection/repository-state.js +51 -0
  101. package/dist/detection/repository-state.js.map +1 -0
  102. package/dist/detection/root-examination.d.ts +1 -11
  103. package/dist/detection/root-examination.js +69 -127
  104. package/dist/detection/root-examination.js.map +1 -1
  105. package/dist/detection/runtime.d.ts +8 -32
  106. package/dist/detection/runtime.js +36 -140
  107. package/dist/detection/runtime.js.map +1 -1
  108. package/dist/detection/scope-frame.d.ts +32 -62
  109. package/dist/detection/scope-frame.js +139 -214
  110. package/dist/detection/scope-frame.js.map +1 -1
  111. package/dist/detection/scoped-identity-port.d.ts +1 -1
  112. package/dist/detection/scoped-identity-port.js +3 -4
  113. package/dist/detection/scoped-identity-port.js.map +1 -1
  114. package/dist/detection/walk-law.d.ts +3 -11
  115. package/dist/detection/walk-law.js +5 -9
  116. package/dist/detection/walk-law.js.map +1 -1
  117. package/dist/git/ground-owners.d.ts +8 -0
  118. package/dist/git/ground-owners.js +25 -0
  119. package/dist/git/ground-owners.js.map +1 -0
  120. package/dist/git/home.d.ts +39 -0
  121. package/dist/git/home.js +81 -0
  122. package/dist/git/home.js.map +1 -0
  123. package/dist/git/marker.d.ts +21 -0
  124. package/dist/git/marker.js +30 -0
  125. package/dist/git/marker.js.map +1 -0
  126. package/dist/git/objects.d.ts +42 -0
  127. package/dist/git/objects.js +144 -0
  128. package/dist/git/objects.js.map +1 -0
  129. package/dist/git/rail.d.ts +90 -0
  130. package/dist/git/rail.js +341 -0
  131. package/dist/git/rail.js.map +1 -0
  132. package/dist/git/read-state.d.ts +21 -0
  133. package/dist/git/read-state.js +143 -0
  134. package/dist/git/read-state.js.map +1 -0
  135. package/dist/git/repository.d.ts +48 -0
  136. package/dist/git/repository.js +110 -0
  137. package/dist/git/repository.js.map +1 -0
  138. package/dist/git/write-files.d.ts +9 -0
  139. package/dist/git/write-files.js +125 -0
  140. package/dist/git/write-files.js.map +1 -0
  141. package/dist/git-binding.d.ts +0 -53
  142. package/dist/git-binding.js +3 -114
  143. package/dist/git-binding.js.map +1 -1
  144. package/dist/git-command.js +11 -2
  145. package/dist/git-command.js.map +1 -1
  146. package/dist/git-index-entries.d.ts +7 -15
  147. package/dist/git-index-entries.js +3 -41
  148. package/dist/git-index-entries.js.map +1 -1
  149. package/dist/git-index-format.d.ts +4 -7
  150. package/dist/git-index-format.js +41 -106
  151. package/dist/git-index-format.js.map +1 -1
  152. package/dist/graph-publication.d.ts +6 -7
  153. package/dist/graph-publication.js +9 -21
  154. package/dist/graph-publication.js.map +1 -1
  155. package/dist/ground-basis.d.ts +1 -37
  156. package/dist/ground-basis.js +5 -162
  157. package/dist/ground-basis.js.map +1 -1
  158. package/dist/ground-database.js +0 -22
  159. package/dist/ground-database.js.map +1 -1
  160. package/dist/ground-install-saves.d.ts +0 -4
  161. package/dist/ground-install-saves.js +0 -4
  162. package/dist/ground-install-saves.js.map +1 -1
  163. package/dist/ground-inventory-schema.js +0 -3
  164. package/dist/ground-inventory-schema.js.map +1 -1
  165. package/dist/ground-marks.d.ts +7 -33
  166. package/dist/ground-marks.js +8 -55
  167. package/dist/ground-marks.js.map +1 -1
  168. package/dist/ground-relations.d.ts +2 -2
  169. package/dist/ground-relations.js +5 -10
  170. package/dist/ground-relations.js.map +1 -1
  171. package/dist/ground-row.d.ts +0 -7
  172. package/dist/ground-row.js +7 -12
  173. package/dist/ground-row.js.map +1 -1
  174. package/dist/ground-save-ops.d.ts +2 -1
  175. package/dist/ground-save-ops.js +2 -1
  176. package/dist/ground-save-ops.js.map +1 -1
  177. package/dist/ground-store.d.ts +0 -10
  178. package/dist/ground-store.js +19 -131
  179. package/dist/ground-store.js.map +1 -1
  180. package/dist/materialize-records.d.ts +19 -20
  181. package/dist/materialize-records.js +123 -244
  182. package/dist/materialize-records.js.map +1 -1
  183. package/dist/materialized-graph.d.ts +3 -22
  184. package/dist/materialized-graph.js +1 -142
  185. package/dist/materialized-graph.js.map +1 -1
  186. package/dist/received-state.d.ts +4 -6
  187. package/dist/received-state.js +6 -11
  188. package/dist/received-state.js.map +1 -1
  189. package/dist/root-install.d.ts +1 -2
  190. package/dist/root-install.js +2 -11
  191. package/dist/root-install.js.map +1 -1
  192. package/dist/sharing-admission.d.ts +1 -2
  193. package/dist/sharing-admission.js +8 -77
  194. package/dist/sharing-admission.js.map +1 -1
  195. package/dist/source-witness.d.ts +1 -7
  196. package/dist/source-witness.js +0 -12
  197. package/dist/source-witness.js.map +1 -1
  198. package/dist/user-ground-host.d.ts +21 -35
  199. package/dist/user-ground-host.js +423 -1484
  200. package/dist/user-ground-host.js.map +1 -1
  201. package/npm-shrinkwrap.json +24 -24
  202. package/package.json +5 -5
  203. package/dist/apply-window-repository.d.ts +0 -97
  204. package/dist/apply-window-repository.js +0 -464
  205. package/dist/apply-window-repository.js.map +0 -1
  206. package/dist/detection/codec-standing.d.ts +0 -27
  207. package/dist/detection/codec-standing.js +0 -86
  208. package/dist/detection/codec-standing.js.map +0 -1
  209. package/dist/detection/git-notice.d.ts +0 -104
  210. package/dist/detection/git-notice.js +0 -483
  211. package/dist/detection/git-notice.js.map +0 -1
  212. package/dist/detection/held-survey.d.ts +0 -39
  213. package/dist/detection/held-survey.js +0 -105
  214. package/dist/detection/held-survey.js.map +0 -1
  215. package/dist/detection/held-territory.d.ts +0 -73
  216. package/dist/detection/held-territory.js +0 -266
  217. package/dist/detection/held-territory.js.map +0 -1
  218. package/dist/detection/name-reach.d.ts +0 -12
  219. package/dist/detection/name-reach.js +0 -28
  220. package/dist/detection/name-reach.js.map +0 -1
  221. package/dist/detection/own-channel.d.ts +0 -17
  222. package/dist/detection/own-channel.js +0 -31
  223. package/dist/detection/own-channel.js.map +0 -1
  224. package/dist/detection/repository-publication.d.ts +0 -22
  225. package/dist/detection/repository-publication.js +0 -81
  226. package/dist/detection/repository-publication.js.map +0 -1
  227. package/dist/detection/repository-routes.d.ts +0 -50
  228. package/dist/detection/repository-routes.js +0 -118
  229. package/dist/detection/repository-routes.js.map +0 -1
  230. package/dist/detection/repository-seals.d.ts +0 -98
  231. package/dist/detection/repository-seals.js +0 -145
  232. package/dist/detection/repository-seals.js.map +0 -1
  233. package/dist/detection/seal-law.d.ts +0 -59
  234. package/dist/detection/seal-law.js +0 -103
  235. package/dist/detection/seal-law.js.map +0 -1
  236. package/dist/git-capture.d.ts +0 -47
  237. package/dist/git-capture.js +0 -153
  238. package/dist/git-capture.js.map +0 -1
  239. package/dist/git-card.d.ts +0 -30
  240. package/dist/git-card.js +0 -136
  241. package/dist/git-card.js.map +0 -1
  242. package/dist/git-checkpoint-construction.d.ts +0 -54
  243. package/dist/git-checkpoint-construction.js +0 -126
  244. package/dist/git-checkpoint-construction.js.map +0 -1
  245. package/dist/git-checkpoint-preparation.d.ts +0 -47
  246. package/dist/git-checkpoint-preparation.js +0 -201
  247. package/dist/git-checkpoint-preparation.js.map +0 -1
  248. package/dist/git-configuration.d.ts +0 -53
  249. package/dist/git-configuration.js +0 -238
  250. package/dist/git-configuration.js.map +0 -1
  251. package/dist/git-evidence.d.ts +0 -50
  252. package/dist/git-evidence.js +0 -114
  253. package/dist/git-evidence.js.map +0 -1
  254. package/dist/git-facts.d.ts +0 -2
  255. package/dist/git-facts.js +0 -35
  256. package/dist/git-facts.js.map +0 -1
  257. package/dist/git-index-witness.d.ts +0 -34
  258. package/dist/git-index-witness.js +0 -85
  259. package/dist/git-index-witness.js.map +0 -1
  260. package/dist/git-literal-batch.d.ts +0 -82
  261. package/dist/git-literal-batch.js +0 -152
  262. package/dist/git-literal-batch.js.map +0 -1
  263. package/dist/git-literal-host.d.ts +0 -76
  264. package/dist/git-literal-host.js +0 -185
  265. package/dist/git-literal-host.js.map +0 -1
  266. package/dist/git-literal-read.d.ts +0 -74
  267. package/dist/git-literal-read.js +0 -186
  268. package/dist/git-literal-read.js.map +0 -1
  269. package/dist/git-literal-replay.d.ts +0 -83
  270. package/dist/git-literal-replay.js +0 -393
  271. package/dist/git-literal-replay.js.map +0 -1
  272. package/dist/git-native-file.d.ts +0 -42
  273. package/dist/git-native-file.js +0 -145
  274. package/dist/git-native-file.js.map +0 -1
  275. package/dist/git-native-index.d.ts +0 -27
  276. package/dist/git-native-index.js +0 -44
  277. package/dist/git-native-index.js.map +0 -1
  278. package/dist/git-operation-host.d.ts +0 -42
  279. package/dist/git-operation-host.js +0 -115
  280. package/dist/git-operation-host.js.map +0 -1
  281. package/dist/git-private-repository.d.ts +0 -4
  282. package/dist/git-private-repository.js +0 -66
  283. package/dist/git-private-repository.js.map +0 -1
  284. package/dist/git-private-view.d.ts +0 -72
  285. package/dist/git-private-view.js +0 -318
  286. package/dist/git-private-view.js.map +0 -1
  287. package/dist/git-records.d.ts +0 -29
  288. package/dist/git-records.js +0 -119
  289. package/dist/git-records.js.map +0 -1
  290. package/dist/git-ref-store.d.ts +0 -12
  291. package/dist/git-ref-store.js +0 -68
  292. package/dist/git-ref-store.js.map +0 -1
  293. package/dist/git-registration-host.d.ts +0 -42
  294. package/dist/git-registration-host.js +0 -98
  295. package/dist/git-registration-host.js.map +0 -1
  296. package/dist/git-repository-host.d.ts +0 -291
  297. package/dist/git-repository-host.js +0 -1291
  298. package/dist/git-repository-host.js.map +0 -1
  299. package/dist/git-spelling.d.ts +0 -41
  300. package/dist/git-spelling.js +0 -233
  301. package/dist/git-spelling.js.map +0 -1
  302. package/dist/git-tree-objects.d.ts +0 -22
  303. package/dist/git-tree-objects.js +0 -205
  304. package/dist/git-tree-objects.js.map +0 -1
  305. package/dist/git-worktree-host.d.ts +0 -2
  306. package/dist/git-worktree-host.js +0 -16
  307. package/dist/git-worktree-host.js.map +0 -1
  308. package/dist/ground-territory.d.ts +0 -106
  309. package/dist/ground-territory.js +0 -340
  310. package/dist/ground-territory.js.map +0 -1
  311. package/dist/repository-checkpoint-file.d.ts +0 -20
  312. package/dist/repository-checkpoint-file.js +0 -129
  313. package/dist/repository-checkpoint-file.js.map +0 -1
  314. package/dist/repository-statement.d.ts +0 -21
  315. package/dist/repository-statement.js +0 -33
  316. package/dist/repository-statement.js.map +0 -1
  317. package/dist/reveal-owner.d.ts +0 -16
  318. package/dist/reveal-owner.js +0 -74
  319. package/dist/reveal-owner.js.map +0 -1
@@ -1,340 +0,0 @@
1
- /** One active repository's ground, read from SQLite when a pass asks for it.
2
- * Nothing here outlives the pass that reads it, and a pass keeps only the
3
- * rows it read.
4
- *
5
- * The snapshot that opens a territory judges it by its marks (ground-marks.ts)
6
- * and consumes the facts its rows rest on (ground-basis.ts). Every later read
7
- * is a late query: read, then check that none of those facts was stamped
8
- * after S0. Stamps only rise, so while none was, the answer is S0's.
9
- *
10
- * Membership is descent: a row belongs while its parent chain reaches the
11
- * top. A row stored beneath the top's address that descends from elsewhere
12
- * is no member, and a member's children are members. */
13
- import { sep } from "node:path";
14
- import { deserialize, serialize } from "node:v8";
15
- import { beneath, rangeIsSubtree } from "./ground-marks.js";
16
- import { groundRowProjection } from "./ground-row.js";
17
- import { cachedStatement } from "./sqlite.js";
18
- import { turnBoundary } from "./turns.js";
19
- export const activeRepository = (row) => row?.type === "repo.git" && row.status === "active";
20
- /** Rows one read of a parent's children returns, one page of a subtree
21
- * crossing threads holds, and one range read returns. */
22
- const READ_ROWS = 256;
23
- /** Each inventory's reads, their text built once. */
24
- const READS = Object.fromEntries(["entities", "detection_notebook"].map(inventory => {
25
- const rows = `SELECT ${groundRowProjection(inventory)} FROM ${inventory}`;
26
- return [inventory, {
27
- row: `${rows} WHERE uuid = ?`,
28
- at: `${rows} WHERE absolute_path IN (SELECT value FROM json_each(?)) AND +root_uuid = ? ORDER BY uuid`,
29
- physical: `${rows} WHERE physical_key = ? AND root_uuid = ? ORDER BY uuid`,
30
- children: `${rows} WHERE parent_uuid = ? ORDER BY uuid`,
31
- childPage: `${rows} WHERE parent_uuid = ? AND uuid > ? ORDER BY uuid LIMIT ${READ_ROWS}`,
32
- childCount: `SELECT COUNT(*) FROM ${inventory} WHERE parent_uuid = ?`,
33
- }];
34
- }));
35
- const byUUID = (left, right) => left.uuid < right.uuid ? -1 : left.uuid > right.uuid ? 1 : 0;
36
- /** One repository's subtree as the current read transaction finds it,
37
- * ordered by UUID: each member's children are read a bounded page at a time,
38
- * so no child relation is too wide. A held row is reached again only through
39
- * a cycle. None when the top is no active repository. */
40
- export function readSubtree(database, inventory, uuid) {
41
- const top = cachedStatement(database, READS[inventory].row).get(uuid);
42
- if (!activeRepository(top))
43
- return null;
44
- const page = cachedStatement(database, READS[inventory].childPage);
45
- const rows = [top], held = new Set([uuid]), pending = [uuid];
46
- while (pending.length) {
47
- const parent = pending.pop();
48
- for (let after = "";;) {
49
- const children = page.all(parent, after);
50
- for (const row of children) {
51
- if (held.has(row.uuid))
52
- continue;
53
- held.add(row.uuid);
54
- rows.push(row);
55
- pending.push(row.uuid);
56
- }
57
- if (children.length < READ_ROWS)
58
- break;
59
- after = children.at(-1).uuid;
60
- }
61
- }
62
- return rows.sort(byUUID);
63
- }
64
- /** A subtree as it crosses to the main thread, serialized in pages: one
65
- * clone of a large subtree would hold the receiver for the whole. Each page
66
- * owns its buffer, for transfer. */
67
- export function subtreePages(rows) {
68
- const pages = [];
69
- for (let at = 0; at < rows.length; at += READ_ROWS)
70
- pages.push(serialize(rows.slice(at, at + READ_ROWS)));
71
- return pages;
72
- }
73
- /** A subtree's pages as rows, in order, one page per turn. */
74
- export async function subtreeRows(pages) {
75
- const rows = [];
76
- for (const page of pages) {
77
- for (const row of deserialize(page))
78
- rows.push(Object.freeze(row));
79
- await turnBoundary();
80
- }
81
- return rows;
82
- }
83
- /** One inventory's side of a territory. Only `row` protects what it returns;
84
- * every other read protects nothing, since the territory's facts are consumed
85
- * whole and a caller that writes a row reads it through `row`. */
86
- export class GroundTerritory {
87
- inventory;
88
- top;
89
- #database;
90
- #law;
91
- /** What this pass has read: rows by identity (null where none is stored),
92
- * descent by identity, members by address, and members' children. */
93
- #rows = new Map();
94
- #descends = new Map();
95
- #at = new Map();
96
- #children = new Map();
97
- /** Every address strictly beneath the top begins with this. */
98
- #beneath;
99
- /** Whether the whole range beneath the top has joined (joinRange). */
100
- #ranged = false;
101
- #unchecked = false;
102
- constructor(database, inventory, top, law) {
103
- this.#database = database;
104
- this.inventory = inventory;
105
- this.top = top;
106
- this.#law = law;
107
- this.#beneath = beneath(top.absolutePath)[0];
108
- this.#rows.set(top.uuid, top);
109
- this.#descends.set(top.uuid, true);
110
- }
111
- get uuid() { return this.top.uuid; }
112
- has(uuid) { return this.#checked(this.#member(uuid)); }
113
- /** A member by identity, which the observation then protects. */
114
- row(uuid) {
115
- const row = this.peek(uuid);
116
- if (row)
117
- this.#law.read(this.inventory, row);
118
- return row;
119
- }
120
- peek(uuid) {
121
- return this.#checked(this.#member(uuid) ? this.#row(uuid) : undefined);
122
- }
123
- /** Members stored at an address, ordered by UUID. */
124
- at(address) { return this.atEach([address])[0]; }
125
- /** Members stored at each address, in order, each ordered by UUID: one
126
- * read and one check for every address this pass has not read. */
127
- atEach(addresses) {
128
- const unread = new Map();
129
- for (const address of addresses) {
130
- if (this.#at.has(address))
131
- continue;
132
- if (this.#ranged && address.startsWith(this.#beneath))
133
- this.#at.set(address, []);
134
- else
135
- unread.set(address, []);
136
- }
137
- if (unread.size) {
138
- const stored = this.#query(READS[this.inventory].at, JSON.stringify([...unread.keys()]), this.top.rootUUID);
139
- for (const row of this.#members(stored))
140
- unread.get(row.absolutePath).push(row);
141
- for (const [address, rows] of unread)
142
- this.#at.set(address, rows);
143
- }
144
- return this.#checked(addresses.map(address => this.#at.get(address)));
145
- }
146
- /** A member's children stored at its address plus this name, which can
147
- * differ from their portable name. */
148
- slot(parentUUID, name) {
149
- const parent = this.peek(parentUUID);
150
- if (!parent)
151
- return [];
152
- const address = parent.absolutePath.endsWith(sep) ? parent.absolutePath + name : parent.absolutePath + sep + name;
153
- return this.at(address).filter(row => row.parentUUID === parentUUID);
154
- }
155
- /** Members at one filesystem object, ordered by UUID. Hard links
156
- * legitimately share one. */
157
- physical(physicalKey) {
158
- return this.#checked(this.#members(this.#query(READS[this.inventory].physical, physicalKey, this.top.rootUUID)));
159
- }
160
- /** A member's children, ordered by UUID; none for any other row. */
161
- children(uuid) {
162
- let rows = this.#children.get(uuid);
163
- if (!rows) {
164
- if (!this.#member(uuid))
165
- return this.#checked([]);
166
- rows = this.#query(READS[this.inventory].children, uuid).map(row => {
167
- this.#descends.set(row.uuid, true);
168
- return this.#known(row);
169
- });
170
- this.#children.set(uuid, rows);
171
- }
172
- return this.#checked(rows);
173
- }
174
- /** One page of the range beneath the top, read while that range was
175
- * exactly the subtree (RepositoryTerritory.memberPages): each row is a
176
- * member and the one row at its address. Once the last page joins, an
177
- * address beneath the top that no page held holds no member, and is never
178
- * asked again. Returns each row as this pass first read it. */
179
- joinRange(rows, last) {
180
- const joined = rows.map(row => {
181
- const known = this.#known(row);
182
- this.#descends.set(known.uuid, true);
183
- if (!this.#at.has(known.absolutePath))
184
- this.#at.set(known.absolutePath, [known]);
185
- return known;
186
- });
187
- if (last)
188
- this.#ranged = true;
189
- return joined;
190
- }
191
- childCount(uuid) {
192
- const known = this.#children.get(uuid);
193
- if (known)
194
- return known.length;
195
- if (!this.#member(uuid))
196
- return this.#checked(0);
197
- this.#unchecked = true;
198
- return this.#checked(cachedStatement(this.#database, READS[this.inventory].childCount).pluck().get(uuid));
199
- }
200
- /** Whether a row descends from the top, each identity on the way read once. */
201
- #member(uuid) {
202
- const known = this.#descends.get(uuid);
203
- if (known !== undefined)
204
- return known;
205
- const walked = new Set();
206
- let found = false;
207
- for (let at = uuid; at !== null && !walked.has(at);) {
208
- const known = this.#descends.get(at);
209
- if (known !== undefined) {
210
- found = known;
211
- break;
212
- }
213
- walked.add(at);
214
- at = this.#row(at)?.parentUUID ?? null;
215
- }
216
- for (const id of walked)
217
- this.#descends.set(id, found);
218
- return found;
219
- }
220
- #row(uuid) {
221
- let row = this.#rows.get(uuid);
222
- if (row === undefined) {
223
- row = this.#query(READS[this.inventory].row, uuid)[0] ?? null;
224
- this.#rows.set(uuid, row && Object.freeze(row));
225
- }
226
- return row ?? undefined;
227
- }
228
- /** A row as this pass first read it: every answer is S0's, so one identity
229
- * reads alike everywhere. */
230
- #known(row) {
231
- const known = this.#rows.get(row.uuid);
232
- if (known)
233
- return known;
234
- this.#rows.set(row.uuid, Object.freeze(row));
235
- return row;
236
- }
237
- #members(rows) {
238
- return rows.map(row => this.#known(row)).filter(row => this.#member(row.uuid));
239
- }
240
- #query(sql, ...values) {
241
- this.#unchecked = true;
242
- return cachedStatement(this.#database, sql).all(...values);
243
- }
244
- /** Read, then check: every read since the last check answers as S0 once
245
- * the law finds none of the territory's facts stamped after it. */
246
- #checked(value) {
247
- if (this.#unchecked) {
248
- this.#unchecked = false;
249
- this.#law.check();
250
- }
251
- return value;
252
- }
253
- }
254
- /** An active repository whose subtree in each inventory lies beneath its top,
255
- * in its root and resource, as its opening snapshot found it. */
256
- export class RepositoryTerritory {
257
- o;
258
- b;
259
- /** O's range carries no mark but the top's own, and B's range no
260
- * difference: O's subtree is O's range, held alike by B. */
261
- holdable;
262
- /** O's members revision at S0 (ground-basis.ts). */
263
- membersRevision;
264
- #database;
265
- #law;
266
- constructor(database, tops, judged, law) {
267
- this.#database = database;
268
- this.#law = law;
269
- this.o = new GroundTerritory(database, "entities", tops.o, law);
270
- this.b = new GroundTerritory(database, "detection_notebook", tops.b, law);
271
- this.holdable = judged.holdable;
272
- this.membersRevision = judged.membersRevision;
273
- }
274
- get uuid() { return this.o.uuid; }
275
- /** O's active members whose payload names a Git index object, counted over
276
- * O's range by a read that finds the range exactly O's subtree; null when
277
- * it is not. */
278
- indexed() {
279
- const top = this.o.top, [low, high] = beneath(top.absolutePath);
280
- const count = this.#database.transaction(() => rangeIsSubtree(this.#database, top)
281
- ? cachedStatement(this.#database, `SELECT COUNT(*) FROM entities WHERE +root_uuid = @root
282
- AND absolute_path >= @low AND absolute_path < @high AND status = 'active' AND type <> 'reference'
283
- AND payload_version GLOB 'git:*'`).pluck().get({ root: top.rootUUID, low, high })
284
- : null)();
285
- this.#law.check();
286
- return count;
287
- }
288
- /** O's members beneath the top in address order, a page per read, each
289
- * read finding O's range exactly O's subtree; a null page when one does
290
- * not. No two rows in such a range share an address, so the pages neither
291
- * skip nor repeat. Each page joins O's side, which then answers its
292
- * addresses, and every address beneath the top once the last page has. */
293
- *memberPages() {
294
- const top = this.o.top, [low, high] = beneath(top.absolutePath);
295
- const page = cachedStatement(this.#database, `SELECT ${groundRowProjection("entities")} FROM entities
296
- WHERE +root_uuid = @root AND absolute_path > @after AND absolute_path < @high
297
- ORDER BY absolute_path LIMIT ${READ_ROWS}`);
298
- // No address is stored with a trailing separator, so the range's low
299
- // bound itself names no row.
300
- for (let after = low;;) {
301
- const rows = this.#database.transaction(() => rangeIsSubtree(this.#database, top)
302
- ? page.all({ root: top.rootUUID, after, high }) : null)();
303
- this.#law.check();
304
- if (!rows) {
305
- yield null;
306
- return;
307
- }
308
- yield this.o.joinRange(rows, rows.length < READ_ROWS);
309
- if (rows.length < READ_ROWS)
310
- return;
311
- after = rows.at(-1).absolutePath;
312
- }
313
- }
314
- /** Both subtrees whole, each ordered by UUID and protected, read on a
315
- * content thread (`read`) after S0 and accepted once the law finds them
316
- * S0's. */
317
- async whole(read) {
318
- const found = await read(this.uuid, ["entities", "detection_notebook"]);
319
- this.#law.check(found);
320
- const [o, b] = found.subtrees;
321
- if (!o || !b)
322
- throw new Error(`territory ${this.uuid} lost its repository under an unchanged basis`);
323
- const entities = await subtreeRows(o), notebook = await subtreeRows(b);
324
- this.#law.readAll("entities", new Set(entities.map(row => row.uuid)));
325
- this.#law.readAll("detection_notebook", new Set(notebook.map(row => row.uuid)));
326
- return { entities, detection_notebook: notebook };
327
- }
328
- }
329
- /** Each territory whole, one after another, joined in order; none when there
330
- * is none. */
331
- export async function wholeTerritories(territories, read) {
332
- let joined = null;
333
- for (const territory of territories) {
334
- const rows = await territory.whole(read);
335
- joined = joined ? { entities: joined.entities.concat(rows.entities),
336
- detection_notebook: joined.detection_notebook.concat(rows.detection_notebook) } : rows;
337
- }
338
- return joined;
339
- }
340
- //# sourceMappingURL=ground-territory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ground-territory.js","sourceRoot":"","sources":["../src/ground-territory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;wDAWwD;AACxD,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGjD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAkB,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAA0B,EAAW,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,UAAU,IAAI,GAAG,CAAC,MAAM,KAAK,QAAQ,CAAC;AAE7H;yDACyD;AACzD,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,qDAAqD;A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CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACtE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChF,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAC;IACpD,CAAC;CACF;AAED;cACc;AACd,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,WAA2C,EAChF,IAAqB;IACrB,IAAI,MAAM,GAA0B,IAAI,CAAC;IACzC,KAAK,MAAM,SAAS,IAAI,WAAW,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;YACjE,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3F,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,20 +0,0 @@
1
- /**
2
- * A sealed repository package's Checkpoint, read from its file off the main
3
- * thread: the evidence its id is taken from, and the proof that the whole
4
- * package is what it claims (Live assertRepositoryTransportTruthSteps).
5
- *
6
- * The proof takes contents in the package's own layout order, at most one
7
- * non-empty content per step, so the next one is read before each step and
8
- * no step waits on the disk. Adjacent contents are read together in one
9
- * window. The next window is read while the content before it may still be
10
- * digesting, so at most two read buffers are live, each a window of up to
11
- * 4 MiB or one larger content. The header and its patch and merge evidence
12
- * are held besides.
13
- */
14
- import { type RepoCheckpointEvidence, type RepositoryTransportLayout } from "@amalgm/live";
15
- /** What the package in `file` holds as Checkpoint evidence: its patches and
16
- * merge continuation. Contents are never read. */
17
- export declare function checkpointEvidenceFromFile(file: string, layout: RepositoryTransportLayout): Promise<RepoCheckpointEvidence>;
18
- /** Prove that the package in `file`, whose header is `layout`, is what it
19
- * claims. Its Git pack is proved separately, as it streams into Git. */
20
- export declare function proveRepositoryTransportFile(file: string, layout: RepositoryTransportLayout): Promise<void>;
@@ -1,129 +0,0 @@
1
- /**
2
- * A sealed repository package's Checkpoint, read from its file off the main
3
- * thread: the evidence its id is taken from, and the proof that the whole
4
- * package is what it claims (Live assertRepositoryTransportTruthSteps).
5
- *
6
- * The proof takes contents in the package's own layout order, at most one
7
- * non-empty content per step, so the next one is read before each step and
8
- * no step waits on the disk. Adjacent contents are read together in one
9
- * window. The next window is read while the content before it may still be
10
- * digesting, so at most two read buffers are live, each a window of up to
11
- * 4 MiB or one larger content. The header and its patch and merge evidence
12
- * are held besides.
13
- */
14
- import { open } from "node:fs/promises";
15
- import { assertRepositoryTransportTruthSteps, } from "@amalgm/live";
16
- import { settleAll } from "./settled.js";
17
- import { createSha256, sha256Hex } from "./sha256.js";
18
- import { mapInTurns, resumeInTurn, turnBoundary } from "./turns.js";
19
- /** Adjacent contents read at once: a few reads cover thousands of small
20
- * files, and the window stays a small part of the process's memory. */
21
- const CONTENT_WINDOW_BYTES = 4 << 20;
22
- const EMPTY = new Uint8Array(0);
23
- const rangeEnd = (range) => range.offset + range.bytes;
24
- /** The bytes at `range`, answered in a dispatcher activation. */
25
- const readRange = resumeInTurn(async (handle, range) => {
26
- if (range.bytes === 0)
27
- return EMPTY;
28
- const output = Buffer.allocUnsafe(range.bytes);
29
- for (let cursor = 0; cursor < range.bytes;) {
30
- const { bytesRead } = await handle.read(output, cursor, range.bytes - cursor, range.offset + cursor);
31
- if (bytesRead === 0)
32
- throw new Error("repository transport file is truncated");
33
- cursor += bytesRead;
34
- }
35
- return output;
36
- });
37
- async function evidenceFrom(handle, layout) {
38
- const { checkpoint } = layout, { operation } = checkpoint;
39
- // Every read ends before the caller may close the handle they share.
40
- const [stagedPatch, unstagedPatch, message, mode] = await settleAll([checkpoint.stagedPatch,
41
- checkpoint.unstagedPatch, ...(operation === null ? [] : [operation.message, operation.mode])]
42
- .map(range => readRange(handle, range)));
43
- return { ...checkpoint, stagedPatch: stagedPatch, unstagedPatch: unstagedPatch,
44
- operation: operation === null ? null : { ...operation, message: message, mode: mode } };
45
- }
46
- /** What the package in `file` holds as Checkpoint evidence: its patches and
47
- * merge continuation. Contents are never read. */
48
- export async function checkpointEvidenceFromFile(file, layout) {
49
- const handle = await open(file, "r");
50
- try {
51
- return await evidenceFrom(handle, layout);
52
- }
53
- finally {
54
- await handle.close();
55
- }
56
- }
57
- /** The Checkpoint's contents, each taken once in the order they are laid. */
58
- class LaidContents {
59
- #handle;
60
- #ranges = [];
61
- #next = 0;
62
- #window = { offset: 0, bytes: EMPTY };
63
- constructor(handle) { this.#handle = handle; }
64
- /** The content at `range`, laid after every content laid before it. */
65
- lay(range) {
66
- if (range === null)
67
- return () => null;
68
- this.#ranges.push(range);
69
- return () => this.#take(range);
70
- }
71
- /** Hold every content up to and including the next non-empty one. */
72
- async ready() {
73
- let first = this.#next;
74
- while (first < this.#ranges.length && this.#ranges[first].bytes === 0)
75
- first += 1;
76
- const range = this.#ranges[first];
77
- if (range === undefined || this.#holds(range))
78
- return;
79
- let last = first;
80
- while (last + 1 < this.#ranges.length && rangeEnd(this.#ranges[last + 1]) - range.offset <= CONTENT_WINDOW_BYTES) {
81
- last += 1;
82
- }
83
- const window = { offset: range.offset, bytes: rangeEnd(this.#ranges[last]) - range.offset };
84
- this.#window = { offset: window.offset, bytes: await readRange(this.#handle, window) };
85
- }
86
- #take(range) {
87
- if (range !== this.#ranges[this.#next] || (range.bytes > 0 && !this.#holds(range))) {
88
- throw new Error("repository transport content was taken out of layout order");
89
- }
90
- this.#next += 1;
91
- const start = range.offset - this.#window.offset;
92
- return range.bytes === 0 ? EMPTY : this.#window.bytes.subarray(start, start + range.bytes);
93
- }
94
- #holds(range) {
95
- return range.offset >= this.#window.offset
96
- && rangeEnd(range) <= this.#window.offset + this.#window.bytes.byteLength;
97
- }
98
- }
99
- /** Prove that the package in `file`, whose header is `layout`, is what it
100
- * claims. Its Git pack is proved separately, as it streams into Git. */
101
- export async function proveRepositoryTransportFile(file, layout) {
102
- const handle = await open(file, "r");
103
- try {
104
- const evidence = await evidenceFrom(handle, layout), contents = new LaidContents(handle);
105
- // Laid as the package lays them: conflict worktrees, then untracked files.
106
- const unmerged = await mapInTurns(layout.checkpoint.unmerged, entry => {
107
- if (entry.worktree === null)
108
- return { ...entry, worktree: null };
109
- const content = contents.lay(entry.worktree.content);
110
- return { ...entry, worktree: { ...entry.worktree, get content() { return content(); } } };
111
- });
112
- const untracked = await mapInTurns(layout.checkpoint.untracked, entry => {
113
- const content = contents.lay(entry.content);
114
- return { ...entry, get content() { return content(); } };
115
- });
116
- const steps = assertRepositoryTransportTruthSteps({ ...layout, pack: null,
117
- checkpoint: { ...evidence, unmerged, untracked } }, sha256Hex, createSha256);
118
- for (;;) {
119
- await contents.ready();
120
- if (steps.next().done)
121
- return;
122
- await turnBoundary();
123
- }
124
- }
125
- finally {
126
- await handle.close();
127
- }
128
- }
129
- //# sourceMappingURL=repository-checkpoint-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"repository-checkpoint-file.js","sourceRoot":"","sources":["../src/repository-checkpoint-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,IAAI,EAAmB,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EACL,mCAAmC,GAIpC,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEpE;uEACuE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CAAC;YACrD,OAAO,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,OAAO,KAAK,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC5F,CAAC,CAAC,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE;YACtE,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC5C,OAAO,EAAE,GAAG,KAAK,EAAE,IAAI,OAAO,KAAK,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,CAAC,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,mCAAmC,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,IAAI;YACvE,UAAU,EAAE,EAAE,GAAG,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;QAC/E,SAAS,CAAC;YACR,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;YACvB,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI;gBAAE,OAAO;YAC9B,MAAM,YAAY,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;YAAS,CAAC;QAAC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IAAC,CAAC;AACrC,CAAC"}
@@ -1,21 +0,0 @@
1
- import { type RepoIdentityChange, type RepoIdentityEntry, type RepositoryApplyTerritory, type RepositoryExpectation, type RepositoryStatement } from "@amalgm/live";
2
- import { type GroundRow } from "./ground-row.js";
3
- /** The row's placement within the repository stored at `repository`, null
4
- * when the row is not active strictly beneath it. Apply's guard and Detect's
5
- * capture read a repository's expectation through this one reading of B. */
6
- export declare function repositoryStatement(repository: string, row: GroundRow | null | undefined): RepositoryStatement | null;
7
- /** expected(R) with the part of R's map it keeps: the ground R's package is
8
- * read through. */
9
- export interface ExpectedRepository extends RepositoryExpectation {
10
- readonly territory: RepositoryApplyTerritory;
11
- /** The ground stands exactly as the map places it: no member came, went
12
- * or moved. */
13
- readonly exact: boolean;
14
- }
15
- /**
16
- * expected(R) (Live expectedRepositorySteps) for ground that differs from
17
- * R's basis map by `changes`. The map and the ground are in path order; each
18
- * statement is the entity's own row. Null when the ground does not show the
19
- * basis.
20
- */
21
- export declare function expectedRepository(changes: readonly RepoIdentityChange[], basis: readonly RepoIdentityEntry[], ground: readonly RepoIdentityEntry[], statementOf: (uuid: string) => RepositoryStatement | null): Promise<ExpectedRepository | null>;
@@ -1,33 +0,0 @@
1
- /** What this computer expects of a repository's ground, read from the
2
- * entities' own sharing rows. */
3
- import { relative, sep } from "node:path";
4
- import { expectedRepositorySteps, repositoryIdentityIndexSteps, repositoryTerritorySteps, } from "@amalgm/live";
5
- import { storedWithin } from "./ground-row.js";
6
- import { finishStepsInTurns } from "./turns.js";
7
- /** The row's placement within the repository stored at `repository`, null
8
- * when the row is not active strictly beneath it. Apply's guard and Detect's
9
- * capture read a repository's expectation through this one reading of B. */
10
- export function repositoryStatement(repository, row) {
11
- if (!row)
12
- return null;
13
- const inside = row.status === "active" && row.absolutePath !== repository && storedWithin(repository, row.absolutePath);
14
- return { path: inside ? relative(repository, row.absolutePath).split(sep).join("/") : null,
15
- uuid: row.uuid, type: row.type, payloadVersion: row.type === "folder" ? null : row.payloadVersion };
16
- }
17
- /**
18
- * expected(R) (Live expectedRepositorySteps) for ground that differs from
19
- * R's basis map by `changes`. The map and the ground are in path order; each
20
- * statement is the entity's own row. Null when the ground does not show the
21
- * basis.
22
- */
23
- export function expectedRepository(changes, basis, ground, statementOf) {
24
- return finishStepsInTurns(expectedRepositoryWithTerritorySteps(changes, basis, ground, statementOf));
25
- }
26
- function* expectedRepositoryWithTerritorySteps(changes, basis, ground, statementOf) {
27
- const expectation = yield* expectedRepositorySteps(changes, basis, ground, statementOf);
28
- if (!expectation)
29
- return null;
30
- const territory = yield* repositoryTerritorySteps(yield* repositoryIdentityIndexSteps(basis), expectation);
31
- return { ...expectation, territory, exact: changes.length === 0 };
32
- }
33
- //# sourceMappingURL=repository-statement.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"repository-statement.js","sourceRoot":"","sources":["../src/repository-statement.ts"],"names":[],"mappings":"AAAA;iCACiC;AACjC,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,wBAAwB,GAOzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAkB,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD;;4EAE4E;AAC5E,MAAM,UAAU,mBAAmB,CAAC,UAAkB,EAAE,GAAiC;IACvF,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,KAAK,QAAQ,IAAI,GAAG,CAAC,YAAY,KAAK,UAAU,IAAI,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;IACxH,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI;QACxF,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;AACxG,CAAC;AAWD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAsC,EACtC,KAAmC,EACnC,MAAoC,EACpC,WAAyD;IAEzD,OAAO,kBAAkB,CAAC,oCAAoC,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;AACvG,CAAC;AAED,QAAQ,CAAC,CAAC,oCAAoC,CAC5C,OAAsC,EACtC,KAAmC,EACnC,MAAoC,EACpC,WAAyD;IAEzD,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,uBAAuB,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IACxF,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IAC9B,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,4BAA4B,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,CAAC;IAC3G,OAAO,EAAE,GAAG,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;AACpE,CAAC"}
@@ -1,16 +0,0 @@
1
- /** The marker's name in a repository's Git storage. */
2
- export declare const REVEAL_MARKER = "amalgm-reveal";
3
- /** The marker in `storage`: the attempt it names, or null when none
4
- * stands. */
5
- export declare function readRevealMarker(storage: string): string | null;
6
- /** Persists before the reveal's first repository effect, flushed off the
7
- * event loop so other work goes on while the drive answers. */
8
- export declare function writeRevealMarker(storage: string, attempt: string): Promise<void>;
9
- /** The storage directory `repository`'s `.git` names, Git's topology
10
- * followed, or null when none stands or the host refuses to resolve it (a
11
- * `.git` file that is no gitfile, a gitfile naming no storage). A fresh
12
- * reveal's `.git` holds only its marker, which Git does not yet recognise as
13
- * a repository, so this asks only that a `.git` stand. */
14
- export declare function revealStorageOf(repository: string): string | null;
15
- /** The bound storage's exact identity, as the receipt records it. */
16
- export declare function revealStoragePhysical(storage: string): string;