@amalgm/live 0.2.81-preview.45708334404 → 0.2.81-preview.45793205987

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 (343) hide show
  1. package/dist/apply/plans.d.ts.map +1 -1
  2. package/dist/apply/plans.js +3 -1
  3. package/dist/apply/plans.js.map +1 -1
  4. package/dist/apply/showing.d.ts +2 -1
  5. package/dist/apply/showing.d.ts.map +1 -1
  6. package/dist/apply/showing.js +5 -2
  7. package/dist/apply/showing.js.map +1 -1
  8. package/dist/clash/bodmas.d.ts +3 -0
  9. package/dist/clash/bodmas.d.ts.map +1 -1
  10. package/dist/clash/bodmas.js +14 -6
  11. package/dist/clash/bodmas.js.map +1 -1
  12. package/dist/{sharing/command-input.d.ts → commands/input.d.ts} +9 -5
  13. package/dist/commands/input.d.ts.map +1 -0
  14. package/dist/{sharing/command-input.js → commands/input.js} +14 -4
  15. package/dist/commands/input.js.map +1 -0
  16. package/dist/commands/mcp.d.ts +30 -0
  17. package/dist/commands/mcp.d.ts.map +1 -0
  18. package/dist/commands/mcp.js +12 -0
  19. package/dist/commands/mcp.js.map +1 -0
  20. package/dist/detection/batch.d.ts +4 -0
  21. package/dist/detection/batch.d.ts.map +1 -1
  22. package/dist/detection/batch.js +4 -2
  23. package/dist/detection/batch.js.map +1 -1
  24. package/dist/detection/record-order.d.ts +9 -0
  25. package/dist/detection/record-order.d.ts.map +1 -1
  26. package/dist/detection/record-order.js +31 -4
  27. package/dist/detection/record-order.js.map +1 -1
  28. package/dist/detection/record-proposal.d.ts.map +1 -1
  29. package/dist/detection/record-proposal.js +9 -3
  30. package/dist/detection/record-proposal.js.map +1 -1
  31. package/dist/detection/removals.d.ts +2 -0
  32. package/dist/detection/removals.d.ts.map +1 -1
  33. package/dist/detection/removals.js +2 -0
  34. package/dist/detection/removals.js.map +1 -1
  35. package/dist/drive/drive.d.ts +2 -1
  36. package/dist/drive/drive.d.ts.map +1 -1
  37. package/dist/drive/drive.js +2 -1
  38. package/dist/drive/drive.js.map +1 -1
  39. package/dist/drive/listing.d.ts.map +1 -1
  40. package/dist/drive/listing.js +3 -3
  41. package/dist/drive/listing.js.map +1 -1
  42. package/dist/drive/where.d.ts +3 -0
  43. package/dist/drive/where.d.ts.map +1 -1
  44. package/dist/drive/where.js +8 -3
  45. package/dist/drive/where.js.map +1 -1
  46. package/dist/entities/cloud.d.ts.map +1 -1
  47. package/dist/entities/cloud.js +3 -3
  48. package/dist/entities/cloud.js.map +1 -1
  49. package/dist/entities/rules.d.ts +14 -2
  50. package/dist/entities/rules.d.ts.map +1 -1
  51. package/dist/entities/rules.js +17 -5
  52. package/dist/entities/rules.js.map +1 -1
  53. package/dist/files/accepted-files.d.ts.map +1 -1
  54. package/dist/files/accepted-files.js +7 -3
  55. package/dist/files/accepted-files.js.map +1 -1
  56. package/dist/files/commands.d.ts +4 -1
  57. package/dist/files/commands.d.ts.map +1 -1
  58. package/dist/files/commands.js.map +1 -1
  59. package/dist/files/plans.d.ts +2 -0
  60. package/dist/files/plans.d.ts.map +1 -1
  61. package/dist/files/plans.js +5 -4
  62. package/dist/files/plans.js.map +1 -1
  63. package/dist/files/usage.d.ts +12 -1
  64. package/dist/files/usage.d.ts.map +1 -1
  65. package/dist/files/usage.js +48 -5
  66. package/dist/files/usage.js.map +1 -1
  67. package/dist/git/holds.d.ts +105 -0
  68. package/dist/git/holds.d.ts.map +1 -0
  69. package/dist/git/holds.js +103 -0
  70. package/dist/git/holds.js.map +1 -0
  71. package/dist/git/index.d.ts +4 -1
  72. package/dist/git/index.d.ts.map +1 -1
  73. package/dist/git/index.js +4 -1
  74. package/dist/git/index.js.map +1 -1
  75. package/dist/git/parts.d.ts +41 -0
  76. package/dist/git/parts.d.ts.map +1 -0
  77. package/dist/git/parts.js +119 -0
  78. package/dist/git/parts.js.map +1 -0
  79. package/dist/git/places.d.ts +33 -0
  80. package/dist/git/places.d.ts.map +1 -0
  81. package/dist/git/places.js +36 -0
  82. package/dist/git/places.js.map +1 -0
  83. package/dist/git/restore.d.ts +35 -0
  84. package/dist/git/restore.d.ts.map +1 -0
  85. package/dist/git/restore.js +110 -0
  86. package/dist/git/restore.js.map +1 -0
  87. package/dist/git/tag.d.ts +57 -24
  88. package/dist/git/tag.d.ts.map +1 -1
  89. package/dist/git/tag.js +141 -31
  90. package/dist/git/tag.js.map +1 -1
  91. package/dist/git/turns.d.ts +6 -4
  92. package/dist/git/turns.d.ts.map +1 -1
  93. package/dist/git/turns.js +6 -4
  94. package/dist/git/turns.js.map +1 -1
  95. package/dist/history/history.d.ts +2 -4
  96. package/dist/history/history.d.ts.map +1 -1
  97. package/dist/history/history.js +28 -11
  98. package/dist/history/history.js.map +1 -1
  99. package/dist/history/identity.d.ts +29 -0
  100. package/dist/history/identity.d.ts.map +1 -0
  101. package/dist/history/identity.js +39 -0
  102. package/dist/history/identity.js.map +1 -0
  103. package/dist/history/index.d.ts +9 -6
  104. package/dist/history/index.d.ts.map +1 -1
  105. package/dist/history/index.js +6 -5
  106. package/dist/history/index.js.map +1 -1
  107. package/dist/history/rule.d.ts +22 -31
  108. package/dist/history/rule.d.ts.map +1 -1
  109. package/dist/history/rule.js +28 -67
  110. package/dist/history/rule.js.map +1 -1
  111. package/dist/history/runs.d.ts +35 -0
  112. package/dist/history/runs.d.ts.map +1 -0
  113. package/dist/history/runs.js +29 -0
  114. package/dist/history/runs.js.map +1 -0
  115. package/dist/history/types.d.ts +19 -17
  116. package/dist/history/types.d.ts.map +1 -1
  117. package/dist/history/types.js +5 -4
  118. package/dist/history/types.js.map +1 -1
  119. package/dist/history/version.d.ts +4 -1
  120. package/dist/history/version.d.ts.map +1 -1
  121. package/dist/history/version.js +8 -1
  122. package/dist/history/version.js.map +1 -1
  123. package/dist/records/rail.d.ts +3 -0
  124. package/dist/records/rail.d.ts.map +1 -1
  125. package/dist/records/rail.js +5 -0
  126. package/dist/records/rail.js.map +1 -1
  127. package/dist/records/send-line.d.ts +5 -0
  128. package/dist/records/send-line.d.ts.map +1 -1
  129. package/dist/records/send-line.js +14 -0
  130. package/dist/records/send-line.js.map +1 -1
  131. package/dist/sharing/commands.d.ts +3 -8
  132. package/dist/sharing/commands.d.ts.map +1 -1
  133. package/dist/sharing/commands.js +1 -1
  134. package/dist/sharing/commands.js.map +1 -1
  135. package/dist/sharing/index.d.ts +3 -2
  136. package/dist/sharing/index.d.ts.map +1 -1
  137. package/dist/sharing/index.js.map +1 -1
  138. package/dist/sharing/mcp.d.ts +3 -20
  139. package/dist/sharing/mcp.d.ts.map +1 -1
  140. package/dist/sharing/mcp.js +4 -9
  141. package/dist/sharing/mcp.js.map +1 -1
  142. package/dist/versions/admit.d.ts +15 -0
  143. package/dist/versions/admit.d.ts.map +1 -0
  144. package/dist/versions/admit.js +33 -0
  145. package/dist/versions/admit.js.map +1 -0
  146. package/dist/versions/api.d.ts +11 -0
  147. package/dist/versions/api.d.ts.map +1 -0
  148. package/dist/versions/api.js +102 -0
  149. package/dist/versions/api.js.map +1 -0
  150. package/dist/versions/cli-text.d.ts +8 -0
  151. package/dist/versions/cli-text.d.ts.map +1 -0
  152. package/dist/versions/cli-text.js +68 -0
  153. package/dist/versions/cli-text.js.map +1 -0
  154. package/dist/versions/cli.d.ts +20 -0
  155. package/dist/versions/cli.d.ts.map +1 -0
  156. package/dist/versions/cli.js +122 -0
  157. package/dist/versions/cli.js.map +1 -0
  158. package/dist/versions/commands.d.ts +44 -0
  159. package/dist/versions/commands.d.ts.map +1 -0
  160. package/dist/versions/commands.js +87 -0
  161. package/dist/versions/commands.js.map +1 -0
  162. package/dist/versions/content.d.ts +10 -0
  163. package/dist/versions/content.d.ts.map +1 -0
  164. package/dist/versions/content.js +29 -0
  165. package/dist/versions/content.js.map +1 -0
  166. package/dist/versions/dates.d.ts +29 -0
  167. package/dist/versions/dates.d.ts.map +1 -0
  168. package/dist/versions/dates.js +119 -0
  169. package/dist/versions/dates.js.map +1 -0
  170. package/dist/versions/deliver.d.ts +35 -0
  171. package/dist/versions/deliver.d.ts.map +1 -0
  172. package/dist/versions/deliver.js +37 -0
  173. package/dist/versions/deliver.js.map +1 -0
  174. package/dist/versions/errors.d.ts +18 -0
  175. package/dist/versions/errors.d.ts.map +1 -0
  176. package/dist/versions/errors.js +30 -0
  177. package/dist/versions/errors.js.map +1 -0
  178. package/dist/versions/index.d.ts +24 -0
  179. package/dist/versions/index.d.ts.map +1 -0
  180. package/dist/versions/index.js +15 -0
  181. package/dist/versions/index.js.map +1 -0
  182. package/dist/versions/line.d.ts +21 -0
  183. package/dist/versions/line.d.ts.map +1 -0
  184. package/dist/versions/line.js +97 -0
  185. package/dist/versions/line.js.map +1 -0
  186. package/dist/versions/list.d.ts +7 -0
  187. package/dist/versions/list.d.ts.map +1 -0
  188. package/dist/versions/list.js +12 -0
  189. package/dist/versions/list.js.map +1 -0
  190. package/dist/versions/mcp.d.ts +12 -0
  191. package/dist/versions/mcp.d.ts.map +1 -0
  192. package/dist/versions/mcp.js +36 -0
  193. package/dist/versions/mcp.js.map +1 -0
  194. package/dist/versions/ports.d.ts +81 -0
  195. package/dist/versions/ports.d.ts.map +1 -0
  196. package/dist/versions/ports.js +6 -0
  197. package/dist/versions/ports.js.map +1 -0
  198. package/dist/versions/read.d.ts +23 -0
  199. package/dist/versions/read.d.ts.map +1 -0
  200. package/dist/versions/read.js +60 -0
  201. package/dist/versions/read.js.map +1 -0
  202. package/dist/versions/restore.d.ts +11 -0
  203. package/dist/versions/restore.d.ts.map +1 -0
  204. package/dist/versions/restore.js +37 -0
  205. package/dist/versions/restore.js.map +1 -0
  206. package/dist/versions/services.d.ts +12 -0
  207. package/dist/versions/services.d.ts.map +1 -0
  208. package/dist/versions/services.js +14 -0
  209. package/dist/versions/services.js.map +1 -0
  210. package/dist/versions/show.d.ts +7 -0
  211. package/dist/versions/show.d.ts.map +1 -0
  212. package/dist/versions/show.js +15 -0
  213. package/dist/versions/show.js.map +1 -0
  214. package/dist/versions/types.d.ts +84 -0
  215. package/dist/versions/types.d.ts.map +1 -0
  216. package/dist/versions/types.js +7 -0
  217. package/dist/versions/types.js.map +1 -0
  218. package/dist/versions/versions.d.ts +15 -0
  219. package/dist/versions/versions.d.ts.map +1 -0
  220. package/dist/versions/versions.js +15 -0
  221. package/dist/versions/versions.js.map +1 -0
  222. package/dist-cjs/apply/plans.js +3 -1
  223. package/dist-cjs/apply/plans.js.map +1 -1
  224. package/dist-cjs/apply/showing.js +5 -2
  225. package/dist-cjs/apply/showing.js.map +1 -1
  226. package/dist-cjs/clash/bodmas.js +15 -5
  227. package/dist-cjs/clash/bodmas.js.map +1 -1
  228. package/dist-cjs/{sharing/command-input.js → commands/input.js} +14 -3
  229. package/dist-cjs/commands/input.js.map +1 -0
  230. package/dist-cjs/commands/mcp.js +15 -0
  231. package/dist-cjs/commands/mcp.js.map +1 -0
  232. package/dist-cjs/detection/batch.js +3 -1
  233. package/dist-cjs/detection/batch.js.map +1 -1
  234. package/dist-cjs/detection/record-order.js +31 -4
  235. package/dist-cjs/detection/record-order.js.map +1 -1
  236. package/dist-cjs/detection/record-proposal.js +9 -3
  237. package/dist-cjs/detection/record-proposal.js.map +1 -1
  238. package/dist-cjs/detection/removals.js +2 -0
  239. package/dist-cjs/detection/removals.js.map +1 -1
  240. package/dist-cjs/drive/drive.js +2 -1
  241. package/dist-cjs/drive/drive.js.map +1 -1
  242. package/dist-cjs/drive/listing.js +2 -2
  243. package/dist-cjs/drive/listing.js.map +1 -1
  244. package/dist-cjs/drive/where.js +8 -2
  245. package/dist-cjs/drive/where.js.map +1 -1
  246. package/dist-cjs/entities/cloud.js +2 -2
  247. package/dist-cjs/entities/cloud.js.map +1 -1
  248. package/dist-cjs/entities/rules.js +19 -5
  249. package/dist-cjs/entities/rules.js.map +1 -1
  250. package/dist-cjs/files/accepted-files.js +7 -3
  251. package/dist-cjs/files/accepted-files.js.map +1 -1
  252. package/dist-cjs/files/commands.js.map +1 -1
  253. package/dist-cjs/files/plans.js +5 -4
  254. package/dist-cjs/files/plans.js.map +1 -1
  255. package/dist-cjs/files/usage.js +48 -5
  256. package/dist-cjs/files/usage.js.map +1 -1
  257. package/dist-cjs/git/holds.js +110 -0
  258. package/dist-cjs/git/holds.js.map +1 -0
  259. package/dist-cjs/git/index.js +9 -2
  260. package/dist-cjs/git/index.js.map +1 -1
  261. package/dist-cjs/git/parts.js +127 -0
  262. package/dist-cjs/git/parts.js.map +1 -0
  263. package/dist-cjs/git/places.js +39 -0
  264. package/dist-cjs/git/places.js.map +1 -0
  265. package/dist-cjs/git/restore.js +113 -0
  266. package/dist-cjs/git/restore.js.map +1 -0
  267. package/dist-cjs/git/tag.js +144 -32
  268. package/dist-cjs/git/tag.js.map +1 -1
  269. package/dist-cjs/git/turns.js +6 -4
  270. package/dist-cjs/git/turns.js.map +1 -1
  271. package/dist-cjs/history/history.js +27 -10
  272. package/dist-cjs/history/history.js.map +1 -1
  273. package/dist-cjs/history/identity.js +43 -0
  274. package/dist-cjs/history/identity.js.map +1 -0
  275. package/dist-cjs/history/index.js +9 -9
  276. package/dist-cjs/history/index.js.map +1 -1
  277. package/dist-cjs/history/rule.js +28 -69
  278. package/dist-cjs/history/rule.js.map +1 -1
  279. package/dist-cjs/history/runs.js +33 -0
  280. package/dist-cjs/history/runs.js.map +1 -0
  281. package/dist-cjs/history/types.js +5 -4
  282. package/dist-cjs/history/types.js.map +1 -1
  283. package/dist-cjs/history/version.js +8 -1
  284. package/dist-cjs/history/version.js.map +1 -1
  285. package/dist-cjs/records/rail.js +5 -0
  286. package/dist-cjs/records/rail.js.map +1 -1
  287. package/dist-cjs/records/send-line.js +14 -0
  288. package/dist-cjs/records/send-line.js.map +1 -1
  289. package/dist-cjs/sharing/commands.js +15 -15
  290. package/dist-cjs/sharing/commands.js.map +1 -1
  291. package/dist-cjs/sharing/index.js.map +1 -1
  292. package/dist-cjs/sharing/mcp.js +4 -9
  293. package/dist-cjs/sharing/mcp.js.map +1 -1
  294. package/dist-cjs/versions/admit.js +36 -0
  295. package/dist-cjs/versions/admit.js.map +1 -0
  296. package/dist-cjs/versions/api.js +106 -0
  297. package/dist-cjs/versions/api.js.map +1 -0
  298. package/dist-cjs/versions/cli-text.js +72 -0
  299. package/dist-cjs/versions/cli-text.js.map +1 -0
  300. package/dist-cjs/versions/cli.js +126 -0
  301. package/dist-cjs/versions/cli.js.map +1 -0
  302. package/dist-cjs/versions/commands.js +93 -0
  303. package/dist-cjs/versions/commands.js.map +1 -0
  304. package/dist-cjs/versions/content.js +32 -0
  305. package/dist-cjs/versions/content.js.map +1 -0
  306. package/dist-cjs/versions/dates.js +125 -0
  307. package/dist-cjs/versions/dates.js.map +1 -0
  308. package/dist-cjs/versions/deliver.js +41 -0
  309. package/dist-cjs/versions/deliver.js.map +1 -0
  310. package/dist-cjs/versions/errors.js +35 -0
  311. package/dist-cjs/versions/errors.js.map +1 -0
  312. package/dist-cjs/versions/index.js +37 -0
  313. package/dist-cjs/versions/index.js.map +1 -0
  314. package/dist-cjs/versions/line.js +100 -0
  315. package/dist-cjs/versions/line.js.map +1 -0
  316. package/dist-cjs/versions/list.js +15 -0
  317. package/dist-cjs/versions/list.js.map +1 -0
  318. package/dist-cjs/versions/mcp.js +39 -0
  319. package/dist-cjs/versions/mcp.js.map +1 -0
  320. package/dist-cjs/versions/ports.js +7 -0
  321. package/dist-cjs/versions/ports.js.map +1 -0
  322. package/dist-cjs/versions/read.js +66 -0
  323. package/dist-cjs/versions/read.js.map +1 -0
  324. package/dist-cjs/versions/restore.js +40 -0
  325. package/dist-cjs/versions/restore.js.map +1 -0
  326. package/dist-cjs/versions/services.js +17 -0
  327. package/dist-cjs/versions/services.js.map +1 -0
  328. package/dist-cjs/versions/show.js +18 -0
  329. package/dist-cjs/versions/show.js.map +1 -0
  330. package/dist-cjs/versions/types.js +8 -0
  331. package/dist-cjs/versions/types.js.map +1 -0
  332. package/dist-cjs/versions/versions.js +18 -0
  333. package/dist-cjs/versions/versions.js.map +1 -0
  334. package/package.json +16 -4
  335. package/dist/git/commands.d.ts +0 -3
  336. package/dist/git/commands.d.ts.map +0 -1
  337. package/dist/git/commands.js +0 -35
  338. package/dist/git/commands.js.map +0 -1
  339. package/dist/sharing/command-input.d.ts.map +0 -1
  340. package/dist/sharing/command-input.js.map +0 -1
  341. package/dist-cjs/git/commands.js +0 -39
  342. package/dist-cjs/git/commands.js.map +0 -1
  343. package/dist-cjs/sharing/command-input.js.map +0 -1
@@ -5,21 +5,38 @@
5
5
  * which schedules the one release that acceptance fixes, and arms one timer
6
6
  * at `nextDueAt`. `cleanup` runs when that timer fires. Nothing polls.
7
7
  */
8
- import { judge, releaseFixedBy } from './rule.js';
8
+ import { contentKind } from '../clash/bodmas.js';
9
+ import { TYPES } from '../entities/types.js';
10
+ import { releaseFixedBy } from './rule.js';
9
11
  /** Releases or artifacts read in one store call. */
10
12
  const BATCH = 256;
11
- function createHistory({ store, now }) {
13
+ const UNPLAYED = Symbol('unplayed');
14
+ /**
15
+ * The state `version` replaces on the played line, as the versions listing
16
+ * reads it (`src/versions/line.ts`): the newest earlier record whose bytes
17
+ * the line took, or null when none did. Content of another kind than what
18
+ * stands is not played (`src/clash/bodmas.ts`, rule 3): it neither ends a
19
+ * version nor is one, so it answers UNPLAYED and is passed over when it
20
+ * comes before. Only a retype changes the kind, so the newest one decides
21
+ * it; with none, the kind never changed, so every earlier content was played.
22
+ */
23
+ async function stateBefore(store, version) {
24
+ if (version.sequence === 1 || version.sets === null || version.deleted)
25
+ return null;
26
+ const { entityId, sequence } = version;
27
+ const setter = await store.setBefore(entityId, sequence, []);
28
+ if (setter === null)
29
+ return store.setBefore(entityId, sequence, [...TYPES]);
30
+ const kind = contentKind(setter.type);
31
+ if (version.sets === 'content' && contentKind(version.type) !== kind)
32
+ return UNPLAYED;
33
+ return store.setBefore(entityId, sequence, [...TYPES].filter((type) => contentKind(type) === kind));
34
+ }
35
+ function createHistory({ store, planOf, now }) {
12
36
  return {
13
- async versions(entityId) {
14
- return judge(await store.versions(entityId), now()).filter(version => version.state !== 'gone');
15
- },
16
37
  async accepted(version) {
17
- const release = await releaseFixedBy(version, async (sequence) => {
18
- const earlier = await store.version(version.entityId, sequence);
19
- if (earlier === null)
20
- throw new Error(`version ${sequence} of ${version.entityId} was never accepted`);
21
- return earlier;
22
- });
38
+ const before = await stateBefore(store, version);
39
+ const release = before === UNPLAYED ? null : await releaseFixedBy(version, before, () => planOf(version.authorityId));
23
40
  if (release !== null)
24
41
  await store.schedule(release);
25
42
  return release;
@@ -1 +1 @@
1
- {"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/history/history.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGlD,oDAAoD;AACpD,MAAM,KAAK,GAAG,GAAG,CAAC;AAWlB,SAAS,aAAa,CAAC,EAAE,KAAK,EAAE,GAAG,EAAgB;IACjD,OAAO;QACL,KAAK,CAAC,QAAQ,CAAC,QAAQ;YACrB,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC;QAClG,CAAC;QAED,KAAK,CAAC,QAAQ,CAAC,OAAO;YACpB,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,KAAK,EAAC,QAAQ,EAAC,EAAE;gBAC7D,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;gBAChE,IAAI,OAAO,KAAK,IAAI;oBAAE,MAAM,IAAI,KAAK,CAAC,WAAW,QAAQ,OAAO,OAAO,CAAC,QAAQ,qBAAqB,CAAC,CAAC;gBACvG,OAAO,OAAO,CAAC;YACjB,CAAC,CAAC,CAAC;YACH,IAAI,OAAO,KAAK,IAAI;gBAAE,MAAM,KAAK,CAAC,QAAQ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AAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBACnG,KAAK,MAAM,QAAQ,IAAI,MAAM,EAAE,CAAC;oBAC9B,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;oBAC1C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;wBACnB,OAAO,IAAI,CAAC,CAAC;wBACb,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC;oBACxB,CAAC;gBACH,CAAC;YACH,CAAC;YACD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;QAC1E,CAAC;KACF,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * What a version of each type is, and how long a replaced one stays.
3
+ *
4
+ * One table, shared by the keeping rule and by the version commands, so what
5
+ * is kept and what is listed never disagree. It reads only what the
6
+ * authority accepted: the sync rails never read it.
7
+ *
8
+ * Two neighbouring states with one identity are one version. An identity
9
+ * starts with the state's type, so a retype always starts a version.
10
+ */
11
+ import type { CloudEntityRecord } from '../entities/cloud.js';
12
+ import type { EntityType } from '../entities/types.js';
13
+ import type { FilesPlan } from '../files/plans.js';
14
+ import { type TransferArtifact } from '../transfer/artifacts.js';
15
+ /** A repository package's five parts (`gitParts`), by its transport
16
+ * version. The host computes each once and keeps it beside history. */
17
+ export type GitPartsOf = (transportVersion: string) => string;
18
+ export interface VersionDefinition {
19
+ /** What one state with these bytes is. */
20
+ identity(artifact: TransferArtifact, gitParts: GitPartsOf): string;
21
+ /** Days a replaced version stays, on the plan its owner holds. */
22
+ keepDays(plan: FilesPlan): number;
23
+ }
24
+ /** Null: the type has no bytes of its own, so no versions. */
25
+ export declare const VERSION_DEFINITIONS: Readonly<Record<EntityType, VersionDefinition | null>>;
26
+ /** The identity of one state, or null when it is no version: a type with
27
+ * no bytes, bytes not yet captured, or a permanent deletion. */
28
+ export declare function identityOf(row: CloudEntityRecord, gitParts: GitPartsOf): string | null;
29
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/history/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEpF;uEACuE;AACvE,MAAM,MAAM,UAAU,GAAG,CAAC,gBAAgB,EAAE,MAAM,KAAK,MAAM,CAAC;AAE9D,MAAM,WAAW,iBAAiB;IAChC,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,GAAG,MAAM,CAAC;IACnE,kEAAkE;IAClE,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;CACnC;AAiBD,8DAA8D;AAC9D,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI,CAAC,CAMrF,CAAC;AAEH;iEACiE;AACjE,wBAAgB,UAAU,CAAC,GAAG,EAAE,iBAAiB,EAAE,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAItF"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * What a version of each type is, and how long a replaced one stays.
3
+ *
4
+ * One table, shared by the keeping rule and by the version commands, so what
5
+ * is kept and what is listed never disagree. It reads only what the
6
+ * authority accepted: the sync rails never read it.
7
+ *
8
+ * Two neighbouring states with one identity are one version. An identity
9
+ * starts with the state's type, so a retype always starts a version.
10
+ */
11
+ import { artifactForRecord } from '../transfer/artifacts.js';
12
+ /** Its bytes: a new version only when they change. */
13
+ const byBytes = {
14
+ identity: artifact => `${artifact.kind}:${artifact.contentHash}`,
15
+ keepDays: plan => plan.versionDays,
16
+ };
17
+ /** Git's own state, in five parts; housekeeping makes no version. */
18
+ const byGitParts = {
19
+ identity: (artifact, gitParts) => gitParts(artifact.contentHash),
20
+ keepDays: plan => plan.versionDays,
21
+ };
22
+ /** A secret's value someone replaced must not stay readable. */
23
+ const keepsNothing = { ...byBytes, keepDays: () => 0 };
24
+ /** Null: the type has no bytes of its own, so no versions. */
25
+ export const VERSION_DEFINITIONS = Object.freeze({
26
+ 'file.text': byBytes, 'file.binary': byBytes, link: byBytes,
27
+ agent: byBytes, automation: byBytes, app: byBytes, tool: byBytes,
28
+ 'repo.git': byGitParts,
29
+ secret: keepsNothing,
30
+ workspace: null, folder: null, reference: null,
31
+ });
32
+ /** The identity of one state, or null when it is no version: a type with
33
+ * no bytes, bytes not yet captured, or a permanent deletion. */
34
+ export function identityOf(row, gitParts) {
35
+ const definition = VERSION_DEFINITIONS[row.type];
36
+ const artifact = definition === null ? null : artifactForRecord(row);
37
+ return artifact === null ? null : `${row.type}:${definition.identity(artifact, gitParts)}`;
38
+ }
39
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/history/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAAE,iBAAiB,EAAyB,MAAM,0BAA0B,CAAC;AAapF,sDAAsD;AACtD,MAAM,OAAO,GAAsB;IACjC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,WAAW,EAAE;IAChE,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW;CACnC,CAAC;AAEF,qEAAqE;AACrE,MAAM,UAAU,GAAsB;IACpC,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC;IAChE,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW;CACnC,CAAC;AAEF,gEAAgE;AAChE,MAAM,YAAY,GAAsB,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;AAE1E,8DAA8D;AAC9D,MAAM,CAAC,MAAM,mBAAmB,GAA2D,MAAM,CAAC,MAAM,CAAC;IACvG,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO;IAC3D,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO;IAChE,UAAU,EAAE,UAAU;IACtB,MAAM,EAAE,YAAY;IACpB,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI;CAC/C,CAAC,CAAC;AAEH;iEACiE;AACjE,MAAM,UAAU,UAAU,CAAC,GAAsB,EAAE,QAAoB;IACrE,MAAM,UAAU,GAAG,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACrE,OAAO,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI,UAAW,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;AAC9F,CAAC"}
@@ -1,12 +1,15 @@
1
1
  /**
2
- * Version history: the newest ten versions of every entity stay, so does
3
- * every version replaced in the last thirty days, and each version neither
4
- * keeps waits thirty days in version Trash before its bytes go. One rule for
5
- * every type, one cleanup run, one timer.
2
+ * Version history: a replaced version stays for its type's days on its
3
+ * owner's plan, then its bytes go unless something still holds them. One
4
+ * rule for every type, one cleanup run, one timer.
6
5
  */
7
6
  export { createHistory } from './history.js';
8
7
  export type { History } from './history.js';
9
- export { KEEP_NEWEST, KEEP_REPLACED_MS, VERSION_TRASH_MS, judge, releaseFixedBy } from './rule.js';
8
+ export { VERSION_DEFINITIONS, identityOf } from './identity.js';
9
+ export type { GitPartsOf, VersionDefinition } from './identity.js';
10
+ export { releaseFixedBy } from './rule.js';
11
+ export { foldRuns } from './runs.js';
12
+ export type { LinePoint, VersionRun } from './runs.js';
10
13
  export { packageContents, versionOf } from './version.js';
11
- export type { ArtifactRef, Cleanup, Dropped, HistoryPorts, HistoryStore, HistoryVersion, JudgedVersion, Release, VersionState, } from './types.js';
14
+ export type { ArtifactRef, Cleanup, Dropped, HistoryPorts, HistoryStore, HistoryVersion, Release, } from './types.js';
12
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/history/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1D,YAAY,EACV,WAAW,EACX,OAAO,EACP,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,aAAa,EACb,OAAO,EACP,YAAY,GACb,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/history/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1D,YAAY,EACV,WAAW,EACX,OAAO,EACP,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,OAAO,GACR,MAAM,YAAY,CAAC"}
@@ -1,10 +1,11 @@
1
1
  /**
2
- * Version history: the newest ten versions of every entity stay, so does
3
- * every version replaced in the last thirty days, and each version neither
4
- * keeps waits thirty days in version Trash before its bytes go. One rule for
5
- * every type, one cleanup run, one timer.
2
+ * Version history: a replaced version stays for its type's days on its
3
+ * owner's plan, then its bytes go unless something still holds them. One
4
+ * rule for every type, one cleanup run, one timer.
6
5
  */
7
6
  export { createHistory } from './history.js';
8
- export { KEEP_NEWEST, KEEP_REPLACED_MS, VERSION_TRASH_MS, judge, releaseFixedBy } from './rule.js';
7
+ export { VERSION_DEFINITIONS, identityOf } from './identity.js';
8
+ export { releaseFixedBy } from './rule.js';
9
+ export { foldRuns } from './runs.js';
9
10
  export { packageContents, versionOf } from './version.js';
10
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/history/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/history/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
@@ -1,38 +1,29 @@
1
1
  /**
2
- * The version history rule, the same for every entity type:
2
+ * The keeping rule, one law for every type: a version stays while it is
3
+ * current, and for its type's days (`identity.ts`) on its owner's plan after
4
+ * a state with another identity replaces it. Then its records are released.
3
5
  *
4
- * 1. the newest ten versions are kept, however old;
5
- * 2. a version replaced in the last thirty days is kept;
6
- * 3. a version neither rule keeps waits thirty days in version Trash, then
7
- * goes.
6
+ * A version is the run of records with one identity, so accepting record `k`
7
+ * fixes a release exactly when `k` sets the bytes or type, the play takes
8
+ * them, and it replaces a version with a state of another identity: records 1 through `k - 1` go together
9
+ * at that time plus the days of the replaced state's type. A rename, a Trash
10
+ * or a repository's housekeeping sets no new identity and fixes nothing.
11
+ * An echo (`src/clash/echo.ts`) states a joined line and sets nothing: it can
12
+ * end a listed version, yet fixes no release, so what is kept always covers
13
+ * what is listed.
8
14
  *
9
- * The current version is always kept. A permanent deletion keeps no history:
10
- * every version before it goes when it is accepted. A secret keeps none either:
11
- * an old value someone replaced must not stay readable.
12
- *
13
- * Time is the authority's acceptance time, never a device clock. Because a
14
- * version's end depends only on the versions after it, accepting version `k`
15
- * fixes exactly one end: that of version `k - 10`, the one it pushes out of
16
- * the newest ten. Versions go oldest first.
17
- */
18
- import type { HistoryVersion, JudgedVersion, Release } from './types.js';
19
- /** Rule 1: this many newest versions stay, however old. */
20
- export declare const KEEP_NEWEST = 10;
21
- /** Rule 2: a replaced version stays this long after it was replaced. */
22
- export declare const KEEP_REPLACED_MS: number;
23
- /** Rule 3: a version no rule keeps waits this long in version Trash. */
24
- export declare const VERSION_TRASH_MS: number;
25
- /**
26
- * The one release accepting `version` fixes, or null when it fixes none yet.
27
- * `versionAt` reads an earlier version of the same entity; only the one that
28
- * replaced the version leaving the newest ten is read.
15
+ * A permanent deletion keeps no history: everything before it goes when it
16
+ * is accepted. A secret keeps no replaced value, since its type keeps it for
17
+ * zero days. Time is the authority's acceptance time, never a device clock.
29
18
  */
30
- export declare function releaseFixedBy(version: HistoryVersion, versionAt: (sequence: number) => Promise<HistoryVersion>): Promise<Release | null>;
19
+ import type { FilesPlan } from '../files/plans.js';
20
+ import type { HistoryVersion, Release } from './types.js';
31
21
  /**
32
- * Every version of one entity as the rule stands at `now`: current, kept,
33
- * trashed, or gone. `versions` runs in sequence order from any version to the
34
- * newest; a version's end depends only on the versions after it, so released
35
- * ones before need not be read.
22
+ * The one release accepting `version` fixes, or null when it fixes none.
23
+ * `before` is the newest earlier record whose bytes the played line took
24
+ * (null when none did): a state with no identity, such as a folder, is no
25
+ * version, so replacing it releases nothing. `plan` answers the one its
26
+ * owner holds now, asked only when a release replaces a version.
36
27
  */
37
- export declare function judge(versions: readonly HistoryVersion[], now: number): JudgedVersion[];
28
+ export declare function releaseFixedBy(version: HistoryVersion, before: HistoryVersion | null, plan: () => Promise<FilesPlan>): Promise<Release | null>;
38
29
  //# sourceMappingURL=rule.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rule.d.ts","sourceRoot":"","sources":["../../src/history/rule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAIzE,2DAA2D;AAC3D,eAAO,MAAM,WAAW,KAAK,CAAC;AAE9B,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,QAAc,CAAC;AAE5C,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,QAAc,CAAC;AAc5C;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,GACvD,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CASzB;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,aAAa,EAAE,CAmBvF"}
1
+ {"version":3,"file":"rule.d.ts","sourceRoot":"","sources":["../../src/history/rule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAI1D;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,GACrF,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAOzB"}
@@ -1,78 +1,39 @@
1
1
  /**
2
- * The version history rule, the same for every entity type:
2
+ * The keeping rule, one law for every type: a version stays while it is
3
+ * current, and for its type's days (`identity.ts`) on its owner's plan after
4
+ * a state with another identity replaces it. Then its records are released.
3
5
  *
4
- * 1. the newest ten versions are kept, however old;
5
- * 2. a version replaced in the last thirty days is kept;
6
- * 3. a version neither rule keeps waits thirty days in version Trash, then
7
- * goes.
6
+ * A version is the run of records with one identity, so accepting record `k`
7
+ * fixes a release exactly when `k` sets the bytes or type, the play takes
8
+ * them, and it replaces a version with a state of another identity: records 1 through `k - 1` go together
9
+ * at that time plus the days of the replaced state's type. A rename, a Trash
10
+ * or a repository's housekeeping sets no new identity and fixes nothing.
11
+ * An echo (`src/clash/echo.ts`) states a joined line and sets nothing: it can
12
+ * end a listed version, yet fixes no release, so what is kept always covers
13
+ * what is listed.
8
14
  *
9
- * The current version is always kept. A permanent deletion keeps no history:
10
- * every version before it goes when it is accepted. A secret keeps none either:
11
- * an old value someone replaced must not stay readable.
12
- *
13
- * Time is the authority's acceptance time, never a device clock. Because a
14
- * version's end depends only on the versions after it, accepting version `k`
15
- * fixes exactly one end: that of version `k - 10`, the one it pushes out of
16
- * the newest ten. Versions go oldest first.
15
+ * A permanent deletion keeps no history: everything before it goes when it
16
+ * is accepted. A secret keeps no replaced value, since its type keeps it for
17
+ * zero days. Time is the authority's acceptance time, never a device clock.
17
18
  */
19
+ import { VERSION_DEFINITIONS } from './identity.js';
18
20
  const DAY_MS = 24 * 60 * 60 * 1000;
19
- /** Rule 1: this many newest versions stay, however old. */
20
- export const KEEP_NEWEST = 10;
21
- /** Rule 2: a replaced version stays this long after it was replaced. */
22
- export const KEEP_REPLACED_MS = 30 * DAY_MS;
23
- /** Rule 3: a version no rule keeps waits this long in version Trash. */
24
- export const VERSION_TRASH_MS = 30 * DAY_MS;
25
- /**
26
- * When a version leaves both keeping rules: thirty days after `next`
27
- * replaced it, or when `tenth` pushed it out of the newest ten, whichever is
28
- * later. It then waits in version Trash.
29
- */
30
- function keptUntil(next, tenth) {
31
- return Math.max(next.acceptedAt + KEEP_REPLACED_MS, tenth.acceptedAt);
32
- }
33
- /** Accepting this version ends every version before it, at once. */
34
- const endsHistory = (version) => version.deleted || version.type === 'secret';
35
21
  /**
36
- * The one release accepting `version` fixes, or null when it fixes none yet.
37
- * `versionAt` reads an earlier version of the same entity; only the one that
38
- * replaced the version leaving the newest ten is read.
22
+ * The one release accepting `version` fixes, or null when it fixes none.
23
+ * `before` is the newest earlier record whose bytes the played line took
24
+ * (null when none did): a state with no identity, such as a folder, is no
25
+ * version, so replacing it releases nothing. `plan` answers the one its
26
+ * owner holds now, asked only when a release replaces a version.
39
27
  */
40
- export async function releaseFixedBy(version, versionAt) {
28
+ export async function releaseFixedBy(version, before, plan) {
41
29
  const { entityId, sequence, acceptedAt } = version;
42
- if (endsHistory(version)) {
43
- return sequence > 1 ? { entityId, through: sequence - 1, dueAt: acceptedAt } : null;
44
- }
45
- const leaving = sequence - KEEP_NEWEST;
46
- if (leaving < 1)
30
+ if (sequence === 1)
47
31
  return null;
48
- const end = keptUntil(await versionAt(leaving + 1), version);
49
- return { entityId, through: leaving, dueAt: end + VERSION_TRASH_MS };
50
- }
51
- /**
52
- * Every version of one entity as the rule stands at `now`: current, kept,
53
- * trashed, or gone. `versions` runs in sequence order from any version to the
54
- * newest; a version's end depends only on the versions after it, so released
55
- * ones before need not be read.
56
- */
57
- export function judge(versions, now) {
58
- const count = versions.length;
59
- const last = versions[count - 1];
60
- const endedAt = last !== undefined && endsHistory(last) ? last.acceptedAt : null;
61
- return versions.map((version, index) => {
62
- if (index === count - 1)
63
- return { ...version, state: 'current', trashedAt: null, goneAt: null };
64
- if (endedAt !== null) {
65
- return { ...version, state: 'gone', trashedAt: endedAt, goneAt: endedAt };
66
- }
67
- const next = versions[index + 1];
68
- const tenth = versions[index + KEEP_NEWEST];
69
- if (tenth === undefined) {
70
- return { ...version, state: 'kept', trashedAt: null, goneAt: null };
71
- }
72
- const trashedAt = keptUntil(next, tenth);
73
- const goneAt = trashedAt + VERSION_TRASH_MS;
74
- const state = now < trashedAt ? 'kept' : now < goneAt ? 'trashed' : 'gone';
75
- return { ...version, state, trashedAt, goneAt };
76
- });
32
+ if (version.deleted)
33
+ return { entityId, through: sequence - 1, dueAt: acceptedAt };
34
+ if (!version.sets || before === null || before.identity === null || before.identity === version.identity)
35
+ return null;
36
+ const days = VERSION_DEFINITIONS[before.type].keepDays(await plan());
37
+ return { entityId, through: sequence - 1, dueAt: acceptedAt + days * DAY_MS };
77
38
  }
78
39
  //# sourceMappingURL=rule.js.map
@@ -1 +1 @@
1
- {"version":3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E,QAAQ,GAAG,CAAC,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,GAAG,MAAM,EAAE,CAAC;AAChF,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The run fold: neighbouring states of one entity with one identity are one
3
+ * version. A, B, A is three versions: the fold never looks back.
4
+ */
5
+ import type { CloudEntityRecord } from '../entities/cloud.js';
6
+ /** One state in an entity's line. */
7
+ export interface LinePoint {
8
+ /** The entity's own channel sequence of the record that produced this
9
+ * state. 0 is the state it was born with: in its first sign-in or a package. */
10
+ readonly sequence: number;
11
+ /** Authority acceptance time. Never a device clock. */
12
+ readonly acceptedAt: number;
13
+ readonly actorId: string;
14
+ readonly originDeviceId: string;
15
+ readonly row: CloudEntityRecord;
16
+ /** The row's identity (`identityOf`); null when it is no version. */
17
+ readonly identity: string | null;
18
+ }
19
+ /** Neighbouring points with one identity: one version. */
20
+ export interface VersionRun {
21
+ readonly identity: string;
22
+ /** Began the version: its number and its time. */
23
+ readonly first: LinePoint;
24
+ /** The version's last name, type and mode. */
25
+ readonly last: LinePoint;
26
+ /** When the next state replaced it; null while it is current. */
27
+ readonly endedAt: number | null;
28
+ }
29
+ /** One pass. A point with the open run's identity extends it; any other
30
+ * ends the open run at its time, and opens a new run unless it has no
31
+ * identity. */
32
+ export declare function foldRuns(points: readonly LinePoint[]): readonly VersionRun[];
33
+ /** The run whose records include this sequence, or null. */
34
+ export declare function runHolding(runs: readonly VersionRun[], sequence: number): VersionRun | null;
35
+ //# sourceMappingURL=runs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../src/history/runs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,qCAAqC;AACrC,MAAM,WAAW,SAAS;IACxB;qFACiF;IACjF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,uDAAuD;IACvD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;IAChC,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,0DAA0D;AAC1D,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED;;gBAEgB;AAChB,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,UAAU,EAAE,CAe5E;AAED,4DAA4D;AAC5D,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAE3F"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The run fold: neighbouring states of one entity with one identity are one
3
+ * version. A, B, A is three versions: the fold never looks back.
4
+ */
5
+ /** One pass. A point with the open run's identity extends it; any other
6
+ * ends the open run at its time, and opens a new run unless it has no
7
+ * identity. */
8
+ export function foldRuns(points) {
9
+ const runs = [];
10
+ for (const point of points) {
11
+ const { identity } = point;
12
+ const open = runs.at(-1);
13
+ if (open?.endedAt === null) {
14
+ if (open.identity === identity) {
15
+ runs[runs.length - 1] = { ...open, last: point };
16
+ continue;
17
+ }
18
+ runs[runs.length - 1] = { ...open, endedAt: point.acceptedAt };
19
+ }
20
+ if (identity !== null)
21
+ runs.push({ identity, first: point, last: point, endedAt: null });
22
+ }
23
+ return runs;
24
+ }
25
+ /** The run whose records include this sequence, or null. */
26
+ export function runHolding(runs, sequence) {
27
+ return runs.find((run) => run.first.sequence <= sequence && sequence <= run.last.sequence) ?? null;
28
+ }
29
+ //# sourceMappingURL=runs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runs.js","sourceRoot":"","sources":["../../src/history/runs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA6BH;;gBAEgB;AAChB,MAAM,UAAU,QAAQ,CAAC,MAA4B;IACnD,MAAM,IAAI,GAAiB,EAAE,CAAC;IAC9B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,IAAI,EAAE,OAAO,KAAK,IAAI,EAAE,CAAC;YAC3B,IAAI,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBAC/B,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;gBACjD,SAAS;YACX,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC;QACjE,CAAC;QACD,IAAI,QAAQ,KAAK,IAAI;YAAE,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3F,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,UAAU,CAAC,IAA2B,EAAE,QAAgB;IACtE,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,QAAQ,IAAI,QAAQ,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC;AACrG,CAAC"}
@@ -1,11 +1,13 @@
1
1
  /**
2
2
  * Version history: how long the cloud keeps each entity's earlier versions.
3
- * A version is one accepted record on the entity's channel; its bytes are the
4
- * one artifact that record names. History never writes records and never
5
- * changes Watch, Detect, Record, Send, Receive, Apply or Verify. It reads
6
- * what the authority accepted and lets go of bytes the rule no longer keeps.
3
+ * A version is a run of accepted records with one identity (`identity.ts`);
4
+ * its bytes are the artifacts those records name. History never writes
5
+ * records and never changes Watch, Detect, Record, Send, Receive, Apply or
6
+ * Verify. It reads what the authority accepted and lets go of bytes the rule
7
+ * no longer keeps.
7
8
  */
8
9
  import type { EntityType } from '../entities/types.js';
10
+ import type { FilesPlan } from '../files/plans.js';
9
11
  /** One accepted record, as history sees it. */
10
12
  interface HistoryVersion {
11
13
  readonly entityId: string;
@@ -23,20 +25,18 @@ interface HistoryVersion {
23
25
  readonly type: EntityType;
24
26
  /** A permanent deletion. Nothing follows it on its channel. */
25
27
  readonly deleted: boolean;
28
+ /** What the record sets: its type with its bytes (it creates or
29
+ * retypes), its bytes alone (content), or neither. Only a record that
30
+ * sets one can start a version. */
31
+ readonly sets: 'type' | 'content' | null;
32
+ /** Its result's identity (`identityOf`); null when it is no version. */
33
+ readonly identity: string | null;
26
34
  }
27
35
  /** One stored artifact: its content hash within its authority's storage. */
28
36
  interface ArtifactRef {
29
37
  readonly authorityId: string;
30
38
  readonly contentHash: string;
31
39
  }
32
- type VersionState = 'current' | 'kept' | 'trashed' | 'gone';
33
- /** A version and where the rule stands on it. `trashedAt` and `goneAt` are
34
- * null until a later version fixes them. */
35
- interface JudgedVersion extends HistoryVersion {
36
- readonly state: VersionState;
37
- readonly trashedAt: number | null;
38
- readonly goneAt: number | null;
39
- }
40
40
  /** Versions 1 through `through` of one entity go at `dueAt`. */
41
41
  interface Release {
42
42
  readonly entityId: string;
@@ -57,10 +57,9 @@ type Dropped = {
57
57
  * mark on versions, and a queue of artifacts to check.
58
58
  */
59
59
  interface HistoryStore {
60
- /** The versions of one entity not yet released, in sequence order. */
61
- versions(entityId: string): Promise<HistoryVersion[]>;
62
- /** One version, or null when the authority has not accepted it. */
63
- version(entityId: string, sequence: number): Promise<HistoryVersion | null>;
60
+ /** The newest accepted record of the entity before `sequence` that sets
61
+ * its type, or sets bytes of one of `types`; null when there is none. */
62
+ setBefore(entityId: string, sequence: number, types: readonly EntityType[]): Promise<HistoryVersion | null>;
64
63
  /** Keep this release until it is due. Saving the same release again changes nothing. */
65
64
  schedule(release: Release): Promise<void>;
66
65
  /** Scheduled releases due by `now`, earliest first, at most `limit`. */
@@ -93,6 +92,9 @@ interface HistoryStore {
93
92
  }
94
93
  interface HistoryPorts {
95
94
  readonly store: HistoryStore;
95
+ /** The plan the person who owns this authority holds now, asked only
96
+ * when an acceptance replaces a version. */
97
+ planOf(authorityId: string): Promise<FilesPlan>;
96
98
  /** The authority's clock. */
97
99
  now(): number;
98
100
  }
@@ -103,5 +105,5 @@ interface Cleanup {
103
105
  readonly bytes: number;
104
106
  readonly nextDueAt: number | null;
105
107
  }
106
- export type { ArtifactRef, Cleanup, Dropped, HistoryPorts, HistoryStore, HistoryVersion, JudgedVersion, Release, VersionState, };
108
+ export type { ArtifactRef, Cleanup, Dropped, HistoryPorts, HistoryStore, HistoryVersion, Release, };
107
109
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/history/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,+CAA+C;AAC/C,UAAU,cAAc;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IA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,EACX,OAAO,EACP,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,OAAO,GACR,CAAC"}
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * Version history: how long the cloud keeps each entity's earlier versions.
3
- * A version is one accepted record on the entity's channel; its bytes are the
4
- * one artifact that record names. History never writes records and never
5
- * changes Watch, Detect, Record, Send, Receive, Apply or Verify. It reads
6
- * what the authority accepted and lets go of bytes the rule no longer keeps.
3
+ * A version is a run of accepted records with one identity (`identity.ts`);
4
+ * its bytes are the artifacts those records name. History never writes
5
+ * records and never changes Watch, Detect, Record, Send, Receive, Apply or
6
+ * Verify. It reads what the authority accepted and lets go of bytes the rule
7
+ * no longer keeps.
7
8
  */
8
9
  export {};
9
10
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/history/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/history/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -3,8 +3,11 @@ import type { DetectedChangeProposal } from '../detection/record-proposal.js';
3
3
  import type { GraphPageRef } from '../entities/graph-pages.js';
4
4
  import type { Sha256Hex } from '../entities/types.js';
5
5
  import type { AcceptedEntityRecord } from '../records/contracts.js';
6
+ import { type GitPartsOf } from './identity.js';
6
7
  import type { HistoryVersion } from './types.js';
7
- export declare function versionOf(record: AcceptedEntityRecord): HistoryVersion;
8
+ /** `gitParts` answers a repository package's five parts; it is asked only
9
+ * when the record's result is a repository. */
10
+ export declare function versionOf(record: AcceptedEntityRecord, gitParts: GitPartsOf): HistoryVersion;
8
11
  /** Every artifact one package holds: its pages and the bytes of each entity
9
12
  * it carries. A member has no version of its own until its first change, so
10
13
  * its first bytes are the package's, and the package holds them for as long
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/history/version.ts"],"names":[],"mappings":"AAAA,4E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