@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.
- package/dist/accepted-fold.d.ts +24 -46
- package/dist/accepted-fold.js +62 -140
- package/dist/accepted-fold.js.map +1 -1
- package/dist/accepted-tail.d.ts +3 -3
- package/dist/accepted-tail.js +6 -6
- package/dist/accepted-tail.js.map +1 -1
- package/dist/apply-control.d.ts +9 -4
- package/dist/apply-control.js +18 -5
- package/dist/apply-control.js.map +1 -1
- package/dist/apply-enter-build.d.ts +6 -7
- package/dist/apply-enter-build.js +4 -10
- package/dist/apply-enter-build.js.map +1 -1
- package/dist/apply-enter-plan.d.ts +9 -7
- package/dist/apply-enter-plan.js +40 -27
- package/dist/apply-enter-plan.js.map +1 -1
- package/dist/apply-local-work.d.ts +8 -20
- package/dist/apply-local-work.js +18 -95
- package/dist/apply-local-work.js.map +1 -1
- package/dist/apply-showing.d.ts +15 -1
- package/dist/apply-showing.js +26 -4
- package/dist/apply-showing.js.map +1 -1
- package/dist/apply-window-ground.d.ts +7 -9
- package/dist/apply-window-ground.js +16 -11
- package/dist/apply-window-ground.js.map +1 -1
- package/dist/apply-window-host.d.ts +29 -4
- package/dist/apply-window-host.js +212 -280
- package/dist/apply-window-host.js.map +1 -1
- package/dist/apply-window-line.d.ts +2 -1
- package/dist/apply-window-line.js +5 -4
- package/dist/apply-window-line.js.map +1 -1
- package/dist/apply-window-recovery.js +18 -30
- package/dist/apply-window-recovery.js.map +1 -1
- package/dist/apply-window-reveal.d.ts +0 -7
- package/dist/apply-window-reveal.js +5 -48
- package/dist/apply-window-reveal.js.map +1 -1
- package/dist/apply-window-rows.d.ts +1 -24
- package/dist/apply-window-rows.js.map +1 -1
- package/dist/apply-window-saves.d.ts +16 -9
- package/dist/apply-window-saves.js +65 -19
- package/dist/apply-window-saves.js.map +1 -1
- package/dist/apply-window-store.d.ts +6 -6
- package/dist/apply-window-store.js +7 -4
- package/dist/apply-window-store.js.map +1 -1
- package/dist/apply-window-verify.d.ts +4 -7
- package/dist/apply-window-verify.js +4 -23
- package/dist/apply-window-verify.js.map +1 -1
- package/dist/baseline-content.d.ts +3 -5
- package/dist/baseline-content.js +7 -44
- package/dist/baseline-content.js.map +1 -1
- package/dist/content-cache-retention.d.ts +3 -2
- package/dist/content-cache-retention.js +11 -11
- package/dist/content-cache-retention.js.map +1 -1
- package/dist/content-capture-pool.d.ts +4 -47
- package/dist/content-capture-pool.js +3 -42
- package/dist/content-capture-pool.js.map +1 -1
- package/dist/content-capture-worker.d.ts +2 -3
- package/dist/content-capture-worker.js +2 -19
- package/dist/content-capture-worker.js.map +1 -1
- package/dist/declaration-absorption.d.ts +9 -15
- package/dist/declaration-absorption.js +14 -32
- package/dist/declaration-absorption.js.map +1 -1
- package/dist/declaration-commit.d.ts +0 -5
- package/dist/declaration-commit.js +1 -6
- package/dist/declaration-commit.js.map +1 -1
- package/dist/declaration-save.d.ts +0 -4
- package/dist/declaration-save.js +0 -4
- package/dist/declaration-save.js.map +1 -1
- package/dist/detection/accepted-result.js +1 -1
- package/dist/detection/accepted-result.js.map +1 -1
- package/dist/detection/admission-save.d.ts +7 -17
- package/dist/detection/admission-save.js +4 -11
- package/dist/detection/admission-save.js.map +1 -1
- package/dist/detection/admission-units.d.ts +10 -26
- package/dist/detection/admission-units.js +12 -50
- package/dist/detection/admission-units.js.map +1 -1
- package/dist/detection/apply-ownership.d.ts +2 -2
- package/dist/detection/apply-ownership.js +2 -7
- package/dist/detection/apply-ownership.js.map +1 -1
- package/dist/detection/capture-outcome.js +12 -19
- package/dist/detection/capture-outcome.js.map +1 -1
- package/dist/detection/dispositions.d.ts +1 -1
- package/dist/detection/dispositions.js +3 -4
- package/dist/detection/dispositions.js.map +1 -1
- package/dist/detection/ground-proof.d.ts +1 -3
- package/dist/detection/ground-proof.js +0 -9
- package/dist/detection/ground-proof.js.map +1 -1
- package/dist/detection/ground-reader.d.ts +1 -5
- package/dist/detection/ground-reader.js +1 -31
- package/dist/detection/ground-reader.js.map +1 -1
- package/dist/detection/notebook-basis.d.ts +1 -2
- package/dist/detection/notebook-basis.js +2 -4
- package/dist/detection/notebook-basis.js.map +1 -1
- package/dist/detection/owed-selection.d.ts +2 -3
- package/dist/detection/owed-selection.js +3 -6
- package/dist/detection/owed-selection.js.map +1 -1
- package/dist/detection/portable.d.ts +7 -48
- package/dist/detection/portable.js +46 -155
- package/dist/detection/portable.js.map +1 -1
- package/dist/detection/repository-state.d.ts +35 -0
- package/dist/detection/repository-state.js +51 -0
- package/dist/detection/repository-state.js.map +1 -0
- package/dist/detection/root-examination.d.ts +1 -11
- package/dist/detection/root-examination.js +69 -127
- package/dist/detection/root-examination.js.map +1 -1
- package/dist/detection/runtime.d.ts +8 -32
- package/dist/detection/runtime.js +36 -140
- package/dist/detection/runtime.js.map +1 -1
- package/dist/detection/scope-frame.d.ts +32 -62
- package/dist/detection/scope-frame.js +139 -214
- package/dist/detection/scope-frame.js.map +1 -1
- package/dist/detection/scoped-identity-port.d.ts +1 -1
- package/dist/detection/scoped-identity-port.js +3 -4
- package/dist/detection/scoped-identity-port.js.map +1 -1
- package/dist/detection/walk-law.d.ts +3 -11
- package/dist/detection/walk-law.js +5 -9
- package/dist/detection/walk-law.js.map +1 -1
- package/dist/git/ground-owners.d.ts +8 -0
- package/dist/git/ground-owners.js +25 -0
- package/dist/git/ground-owners.js.map +1 -0
- package/dist/git/home.d.ts +39 -0
- package/dist/git/home.js +81 -0
- package/dist/git/home.js.map +1 -0
- package/dist/git/marker.d.ts +21 -0
- package/dist/git/marker.js +30 -0
- package/dist/git/marker.js.map +1 -0
- package/dist/git/objects.d.ts +42 -0
- package/dist/git/objects.js +144 -0
- package/dist/git/objects.js.map +1 -0
- package/dist/git/rail.d.ts +90 -0
- package/dist/git/rail.js +341 -0
- package/dist/git/rail.js.map +1 -0
- package/dist/git/read-state.d.ts +21 -0
- package/dist/git/read-state.js +143 -0
- package/dist/git/read-state.js.map +1 -0
- package/dist/git/repository.d.ts +48 -0
- package/dist/git/repository.js +110 -0
- package/dist/git/repository.js.map +1 -0
- package/dist/git/write-files.d.ts +9 -0
- package/dist/git/write-files.js +125 -0
- package/dist/git/write-files.js.map +1 -0
- package/dist/git-binding.d.ts +0 -53
- package/dist/git-binding.js +3 -114
- package/dist/git-binding.js.map +1 -1
- package/dist/git-command.js +11 -2
- package/dist/git-command.js.map +1 -1
- package/dist/git-index-entries.d.ts +7 -15
- package/dist/git-index-entries.js +3 -41
- package/dist/git-index-entries.js.map +1 -1
- package/dist/git-index-format.d.ts +4 -7
- package/dist/git-index-format.js +41 -106
- package/dist/git-index-format.js.map +1 -1
- package/dist/graph-publication.d.ts +6 -7
- package/dist/graph-publication.js +9 -21
- package/dist/graph-publication.js.map +1 -1
- package/dist/ground-basis.d.ts +1 -37
- package/dist/ground-basis.js +5 -162
- package/dist/ground-basis.js.map +1 -1
- package/dist/ground-database.js +0 -22
- package/dist/ground-database.js.map +1 -1
- package/dist/ground-install-saves.d.ts +0 -4
- package/dist/ground-install-saves.js +0 -4
- package/dist/ground-install-saves.js.map +1 -1
- package/dist/ground-inventory-schema.js +0 -3
- package/dist/ground-inventory-schema.js.map +1 -1
- package/dist/ground-marks.d.ts +7 -33
- package/dist/ground-marks.js +8 -55
- package/dist/ground-marks.js.map +1 -1
- package/dist/ground-relations.d.ts +2 -2
- package/dist/ground-relations.js +5 -10
- package/dist/ground-relations.js.map +1 -1
- package/dist/ground-row.d.ts +0 -7
- package/dist/ground-row.js +7 -12
- package/dist/ground-row.js.map +1 -1
- package/dist/ground-save-ops.d.ts +2 -1
- package/dist/ground-save-ops.js +2 -1
- package/dist/ground-save-ops.js.map +1 -1
- package/dist/ground-store.d.ts +0 -10
- package/dist/ground-store.js +19 -131
- package/dist/ground-store.js.map +1 -1
- package/dist/materialize-records.d.ts +19 -20
- package/dist/materialize-records.js +123 -244
- package/dist/materialize-records.js.map +1 -1
- package/dist/materialized-graph.d.ts +3 -22
- package/dist/materialized-graph.js +1 -142
- package/dist/materialized-graph.js.map +1 -1
- package/dist/received-state.d.ts +4 -6
- package/dist/received-state.js +6 -11
- package/dist/received-state.js.map +1 -1
- package/dist/root-install.d.ts +1 -2
- package/dist/root-install.js +2 -11
- package/dist/root-install.js.map +1 -1
- package/dist/sharing-admission.d.ts +1 -2
- package/dist/sharing-admission.js +8 -77
- package/dist/sharing-admission.js.map +1 -1
- package/dist/source-witness.d.ts +1 -7
- package/dist/source-witness.js +0 -12
- package/dist/source-witness.js.map +1 -1
- package/dist/user-ground-host.d.ts +21 -35
- package/dist/user-ground-host.js +423 -1484
- package/dist/user-ground-host.js.map +1 -1
- package/npm-shrinkwrap.json +24 -24
- package/package.json +5 -5
- package/dist/apply-window-repository.d.ts +0 -97
- package/dist/apply-window-repository.js +0 -464
- package/dist/apply-window-repository.js.map +0 -1
- package/dist/detection/codec-standing.d.ts +0 -27
- package/dist/detection/codec-standing.js +0 -86
- package/dist/detection/codec-standing.js.map +0 -1
- package/dist/detection/git-notice.d.ts +0 -104
- package/dist/detection/git-notice.js +0 -483
- package/dist/detection/git-notice.js.map +0 -1
- package/dist/detection/held-survey.d.ts +0 -39
- package/dist/detection/held-survey.js +0 -105
- package/dist/detection/held-survey.js.map +0 -1
- package/dist/detection/held-territory.d.ts +0 -73
- package/dist/detection/held-territory.js +0 -266
- package/dist/detection/held-territory.js.map +0 -1
- package/dist/detection/name-reach.d.ts +0 -12
- package/dist/detection/name-reach.js +0 -28
- package/dist/detection/name-reach.js.map +0 -1
- package/dist/detection/own-channel.d.ts +0 -17
- package/dist/detection/own-channel.js +0 -31
- package/dist/detection/own-channel.js.map +0 -1
- package/dist/detection/repository-publication.d.ts +0 -22
- package/dist/detection/repository-publication.js +0 -81
- package/dist/detection/repository-publication.js.map +0 -1
- package/dist/detection/repository-routes.d.ts +0 -50
- package/dist/detection/repository-routes.js +0 -118
- package/dist/detection/repository-routes.js.map +0 -1
- package/dist/detection/repository-seals.d.ts +0 -98
- package/dist/detection/repository-seals.js +0 -145
- package/dist/detection/repository-seals.js.map +0 -1
- package/dist/detection/seal-law.d.ts +0 -59
- package/dist/detection/seal-law.js +0 -103
- package/dist/detection/seal-law.js.map +0 -1
- package/dist/git-capture.d.ts +0 -47
- package/dist/git-capture.js +0 -153
- package/dist/git-capture.js.map +0 -1
- package/dist/git-card.d.ts +0 -30
- package/dist/git-card.js +0 -136
- package/dist/git-card.js.map +0 -1
- package/dist/git-checkpoint-construction.d.ts +0 -54
- package/dist/git-checkpoint-construction.js +0 -126
- package/dist/git-checkpoint-construction.js.map +0 -1
- package/dist/git-checkpoint-preparation.d.ts +0 -47
- package/dist/git-checkpoint-preparation.js +0 -201
- package/dist/git-checkpoint-preparation.js.map +0 -1
- package/dist/git-configuration.d.ts +0 -53
- package/dist/git-configuration.js +0 -238
- package/dist/git-configuration.js.map +0 -1
- package/dist/git-evidence.d.ts +0 -50
- package/dist/git-evidence.js +0 -114
- package/dist/git-evidence.js.map +0 -1
- package/dist/git-facts.d.ts +0 -2
- package/dist/git-facts.js +0 -35
- package/dist/git-facts.js.map +0 -1
- package/dist/git-index-witness.d.ts +0 -34
- package/dist/git-index-witness.js +0 -85
- package/dist/git-index-witness.js.map +0 -1
- package/dist/git-literal-batch.d.ts +0 -82
- package/dist/git-literal-batch.js +0 -152
- package/dist/git-literal-batch.js.map +0 -1
- package/dist/git-literal-host.d.ts +0 -76
- package/dist/git-literal-host.js +0 -185
- package/dist/git-literal-host.js.map +0 -1
- package/dist/git-literal-read.d.ts +0 -74
- package/dist/git-literal-read.js +0 -186
- package/dist/git-literal-read.js.map +0 -1
- package/dist/git-literal-replay.d.ts +0 -83
- package/dist/git-literal-replay.js +0 -393
- package/dist/git-literal-replay.js.map +0 -1
- package/dist/git-native-file.d.ts +0 -42
- package/dist/git-native-file.js +0 -145
- package/dist/git-native-file.js.map +0 -1
- package/dist/git-native-index.d.ts +0 -27
- package/dist/git-native-index.js +0 -44
- package/dist/git-native-index.js.map +0 -1
- package/dist/git-operation-host.d.ts +0 -42
- package/dist/git-operation-host.js +0 -115
- package/dist/git-operation-host.js.map +0 -1
- package/dist/git-private-repository.d.ts +0 -4
- package/dist/git-private-repository.js +0 -66
- package/dist/git-private-repository.js.map +0 -1
- package/dist/git-private-view.d.ts +0 -72
- package/dist/git-private-view.js +0 -318
- package/dist/git-private-view.js.map +0 -1
- package/dist/git-records.d.ts +0 -29
- package/dist/git-records.js +0 -119
- package/dist/git-records.js.map +0 -1
- package/dist/git-ref-store.d.ts +0 -12
- package/dist/git-ref-store.js +0 -68
- package/dist/git-ref-store.js.map +0 -1
- package/dist/git-registration-host.d.ts +0 -42
- package/dist/git-registration-host.js +0 -98
- package/dist/git-registration-host.js.map +0 -1
- package/dist/git-repository-host.d.ts +0 -291
- package/dist/git-repository-host.js +0 -1291
- package/dist/git-repository-host.js.map +0 -1
- package/dist/git-spelling.d.ts +0 -41
- package/dist/git-spelling.js +0 -233
- package/dist/git-spelling.js.map +0 -1
- package/dist/git-tree-objects.d.ts +0 -22
- package/dist/git-tree-objects.js +0 -205
- package/dist/git-tree-objects.js.map +0 -1
- package/dist/git-worktree-host.d.ts +0 -2
- package/dist/git-worktree-host.js +0 -16
- package/dist/git-worktree-host.js.map +0 -1
- package/dist/ground-territory.d.ts +0 -106
- package/dist/ground-territory.js +0 -340
- package/dist/ground-territory.js.map +0 -1
- package/dist/repository-checkpoint-file.d.ts +0 -20
- package/dist/repository-checkpoint-file.js +0 -129
- package/dist/repository-checkpoint-file.js.map +0 -1
- package/dist/repository-statement.d.ts +0 -21
- package/dist/repository-statement.js +0 -33
- package/dist/repository-statement.js.map +0 -1
- package/dist/reveal-owner.d.ts +0 -16
- package/dist/reveal-owner.js +0 -74
- package/dist/reveal-owner.js.map +0 -1
package/dist/apply-control.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* window's attempt, so no two windows ever share one. Everything a window
|
|
7
7
|
* stages or sets aside lives there until the durability point removes the
|
|
8
8
|
* tree: a file or link result before its reveal, an Enter's sealed tree, the
|
|
9
|
-
* object a Leave takes from its address, a repository
|
|
10
|
-
*
|
|
9
|
+
* object a Leave takes from its address, a repository's Git part marker,
|
|
10
|
+
* and a former repository's Git storage. The tree is never ground:
|
|
11
11
|
* Detect does not look beneath the reserved directory.
|
|
12
12
|
*
|
|
13
13
|
* Bound root law: every address a receipt names lies in its binding root,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* - replaced: another directory on the same device stands there. What the
|
|
21
21
|
* window held left with the old object: its members stay owed, and
|
|
22
22
|
* nothing beneath the new root is touched, not even the control tree. */
|
|
23
|
-
import { lstatSync } from "node:fs";
|
|
23
|
+
import { lstatSync, readFileSync } from "node:fs";
|
|
24
24
|
import { basename, dirname, join } from "node:path";
|
|
25
25
|
import { LOCAL_DIR_NAME } from "@amalgm/core/identity";
|
|
26
26
|
import { ensureDirBeneath } from "./filesystem.js";
|
|
@@ -50,8 +50,21 @@ export const ensureApplyPrivate = (control, directory = control) => ensureDirBen
|
|
|
50
50
|
export const stagedPath = (control, entityId) => join(control, "staged", entityId);
|
|
51
51
|
/** Where the object a member replaces or removes is set aside. */
|
|
52
52
|
export const displacedPath = (control, entityId) => join(control, "displaced", entityId);
|
|
53
|
-
/**
|
|
54
|
-
|
|
53
|
+
/** A repository reveal's Git part marker: absent before the part begins,
|
|
54
|
+
* `started`, durably, before Git writes anything, and `ended` once Git's own
|
|
55
|
+
* read proved the result (apply-window-recovery.ts). */
|
|
56
|
+
export const gitPartPath = (control, entityId) => join(control, "git", entityId);
|
|
57
|
+
/** The member's Git part; anything but `ended` is a `started` a crash tore. */
|
|
58
|
+
export function readGitPart(control, entityId) {
|
|
59
|
+
try {
|
|
60
|
+
return readFileSync(gitPartPath(control, entityId), "utf8") === "ended" ? "ended" : "started";
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (["ENOENT", "ENOTDIR"].includes(error.code ?? ""))
|
|
64
|
+
return null;
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
55
68
|
/** A container Enter's staging (src/apply-enter-build.ts). */
|
|
56
69
|
export const enterControl = (control, entityId) => join(control, "enter", entityId);
|
|
57
70
|
/** A former repository's displaced Git storage (src/apply-git-storage.ts). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-control.js","sourceRoot":"","sources":["../src/apply-control.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;2EAqB2E;AAC3E,OAAO,EAAE,SAAS,EAAoB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"apply-control.js","sourceRoot":"","sources":["../src/apply-control.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;2EAqB2E;AAC3E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAoB,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,cAAc,IAAI,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AASnE;4EAC4E;AAC5E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,SAAiB,EAAiB,EAAE,CAC9E,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAE/E;0EAC0E;AAC1E,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,KAAK,IAAI,EAAE,GAAG,OAAO,I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,EAAmB,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { CloudEntityRecord,
|
|
1
|
+
import type { CloudEntityRecord, TransferArtifact } from "@amalgm/live";
|
|
2
2
|
import type { EnterClosure } from "./apply-enter-plan.js";
|
|
3
3
|
import type { ContentBoundary } from "./content-clock.js";
|
|
4
|
+
import type { GitOwners } from "./git/home.js";
|
|
4
5
|
import { type LocalArtifactFile } from "./materialize-records.js";
|
|
5
|
-
declare const CONTRACT = "amalgm.apply-enter@
|
|
6
|
+
declare const CONTRACT = "amalgm.apply-enter@2";
|
|
6
7
|
/** One row the landing saves, addressed relative to the tree. The target's
|
|
7
8
|
* own row has the empty path. */
|
|
8
9
|
export interface SealedEnterRow {
|
|
@@ -25,10 +26,6 @@ export interface EnterSeal {
|
|
|
25
26
|
/** Where the tree lands. Reference link text was computed from it. */
|
|
26
27
|
readonly targetPath: string;
|
|
27
28
|
readonly rows: readonly SealedEnterRow[];
|
|
28
|
-
readonly repositories: readonly {
|
|
29
|
-
readonly uuid: string;
|
|
30
|
-
readonly identity: readonly RepoIdentityEntry[];
|
|
31
|
-
}[];
|
|
32
29
|
}
|
|
33
30
|
export interface PreparedEnter {
|
|
34
31
|
readonly tree: string;
|
|
@@ -66,8 +63,10 @@ export declare function prepareEnter(input: {
|
|
|
66
63
|
/** The binding root whose content clock qualifies the rows. */
|
|
67
64
|
readonly clockRoot: string;
|
|
68
65
|
readonly databaseFile: string;
|
|
69
|
-
readonly cacheDir: string;
|
|
70
66
|
readonly bindingDir: string;
|
|
67
|
+
/** The repositories this computer already holds, where a worktree or
|
|
68
|
+
* submodule entering finds its home. */
|
|
69
|
+
readonly held: GitOwners;
|
|
71
70
|
readContent(artifacts: readonly TransferArtifact[]): Promise<ReadonlyMap<string, LocalArtifactFile>>;
|
|
72
71
|
}): Promise<PreparedEnter>;
|
|
73
72
|
export {};
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
* Content proofs (`sighting`) are process facts. They stay in memory
|
|
17
17
|
* with the clock epoch they were taken in, and an adopted seal has none.
|
|
18
18
|
*/
|
|
19
|
-
import { createHash } from "node:crypto";
|
|
20
19
|
import { readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
21
20
|
import { join } from "node:path";
|
|
22
21
|
import { flushDirectory, flushFile } from "./flush.js";
|
|
@@ -24,10 +23,8 @@ import { ensureApplyPrivate } from "./apply-control.js";
|
|
|
24
23
|
import { holds, standing } from "./apply-spelling.js";
|
|
25
24
|
import { durabilityBarrier } from "./durability-barrier.js";
|
|
26
25
|
import { materializeRecords } from "./materialize-records.js";
|
|
27
|
-
import { projectMaterializedGraph } from "./materialized-graph.js";
|
|
28
26
|
import { isPhysicalKey, physicalKey } from "./source-signature.js";
|
|
29
|
-
const CONTRACT = "amalgm.apply-enter@
|
|
30
|
-
const sha256Hex = (input) => createHash("sha256").update(input).digest("hex");
|
|
27
|
+
const CONTRACT = "amalgm.apply-enter@2";
|
|
31
28
|
/** The staging directory inside the attempt's own control directory. */
|
|
32
29
|
export const enterStaging = (control) => join(control, "enter");
|
|
33
30
|
const treeOf = (staging) => join(staging, "tree");
|
|
@@ -52,7 +49,7 @@ export function readEnterSeal(staging) {
|
|
|
52
49
|
throw new Error(`Apply Enter seal contract ${String(seal.contract)} is superseded`);
|
|
53
50
|
if (typeof seal.targetVersion !== "string" || !Number.isSafeInteger(seal.position)
|
|
54
51
|
|| !Array.isArray(seal.leftOut) || !isPhysicalKey(seal.root)
|
|
55
|
-
|| typeof seal.targetPath !== "string" || !Array.isArray(seal.rows)
|
|
52
|
+
|| typeof seal.targetPath !== "string" || !Array.isArray(seal.rows)
|
|
56
53
|
|| seal.rows.filter(row => row.relativePath === "").length !== 1) {
|
|
57
54
|
throw new Error("Apply Enter seal is malformed");
|
|
58
55
|
}
|
|
@@ -87,14 +84,14 @@ export async function prepareEnter(input) {
|
|
|
87
84
|
rootPath: tree,
|
|
88
85
|
database: input.databaseFile,
|
|
89
86
|
boundaryUUID: expected.target.uuid,
|
|
90
|
-
cacheDir: input.cacheDir,
|
|
91
87
|
bindingDir: input.bindingDir,
|
|
92
88
|
clockRoot: input.clockRoot,
|
|
93
89
|
revealedAt: expected.targetPath,
|
|
94
90
|
leftOut: new Set(expected.leftOut),
|
|
91
|
+
held: input.held,
|
|
95
92
|
readContent: artifacts => input.readContent(artifacts),
|
|
96
93
|
});
|
|
97
|
-
const
|
|
94
|
+
const { rows } = built;
|
|
98
95
|
await durabilityBarrier(tree, (await built.durable).files);
|
|
99
96
|
const root = standing(tree);
|
|
100
97
|
if (!root?.isDirectory())
|
|
@@ -110,9 +107,6 @@ export async function prepareEnter(input) {
|
|
|
110
107
|
record: row.record, relativePath: row.relativePath, physicalKey: row.physicalKey,
|
|
111
108
|
sourceSignature: row.sourceSignature, filesystemMode: row.filesystemMode,
|
|
112
109
|
})),
|
|
113
|
-
repositories: built.repositories.map(repository => ({
|
|
114
|
-
uuid: repository.record.uuid, identity: repository.state.territory.identity,
|
|
115
|
-
})),
|
|
116
110
|
};
|
|
117
111
|
writeSeal(staging, seal);
|
|
118
112
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-enter-build.js","sourceRoot":"","sources":["../src/apply-enter-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"apply-enter-build.js","sourceRoot":"","sources":["../src/apply-enter-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC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E,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACpG,eAAe,EAAE,KAAK,CAAC,eAAe;KACvC,CAAC;AACJ,CAAC;AAED;;aAEa;AACb,SAAS,SAAS,CAAC,OAAe,EAAE,IAAe;IACjD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,GAAG,IAAI,UAAU,CAAC;IAC1D,aAAa,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACrE,SAAS,CAAC,OAAO,CAAC,CAAC;IACnB,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC1B,cAAc,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
* other entity has an unresolved row inside that run, so the state at that
|
|
10
10
|
* position is a prefix the line really had.
|
|
11
11
|
*
|
|
12
|
+
* Beneath a root on demand an Enter shows one unit (src/drive/): the target
|
|
13
|
+
* alone, or a repository with every member short of a nested repository,
|
|
14
|
+
* which is a unit of its own. Everything else stays listed.
|
|
15
|
+
*
|
|
12
16
|
* What this computer already shows stays where it is. A closure member that
|
|
13
17
|
* O holds an active row for, in any root, including a frozen row in an
|
|
14
18
|
* unavailable root, is protected local ground, not a copy for the Enter to
|
|
15
|
-
* create. It is left out with its subtree
|
|
16
|
-
* encloses it. In that case the repository's parcel carries it, and the
|
|
17
|
-
* repository relocation guard owns it. A nested repository is the exception:
|
|
18
|
-
* it owns its own subtree, so it lies outside the enclosing repository's
|
|
19
|
-
* territory and is left out like any other shown member.
|
|
19
|
+
* create. It is left out with its subtree; its own records move it.
|
|
20
20
|
*/
|
|
21
21
|
import { type CloudEntityRecord, type EntityApplyIntent, type EntityApplyPlan } from "@amalgm/live";
|
|
22
22
|
import type Database from "better-sqlite3";
|
|
@@ -30,13 +30,15 @@ export interface EnterClosure {
|
|
|
30
30
|
* accepted result. */
|
|
31
31
|
readonly records: readonly CloudEntityRecord[];
|
|
32
32
|
}
|
|
33
|
-
/** The closure an Enter installs, read at its target's delivery position
|
|
34
|
-
* A missing kept head throws
|
|
33
|
+
/** The closure an Enter installs, read at its target's delivery position:
|
|
34
|
+
* one unit's when `unit`. A missing kept head throws
|
|
35
|
+
* ReceivedStateUnavailableError. */
|
|
35
36
|
export declare function readEnterClosure(input: {
|
|
36
37
|
readonly database: Database.Database;
|
|
37
38
|
readonly intent: EntityApplyIntent;
|
|
38
39
|
readonly target: CloudEntityRecord;
|
|
39
40
|
readonly heads: HeldHeads;
|
|
41
|
+
readonly unit: boolean;
|
|
40
42
|
}): Promise<EnterClosure>;
|
|
41
43
|
export interface EnterDivision {
|
|
42
44
|
/** Members left where this computer shows them, each with its subtree,
|
package/dist/apply-enter-plan.js
CHANGED
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
* other entity has an unresolved row inside that run, so the state at that
|
|
10
10
|
* position is a prefix the line really had.
|
|
11
11
|
*
|
|
12
|
+
* Beneath a root on demand an Enter shows one unit (src/drive/): the target
|
|
13
|
+
* alone, or a repository with every member short of a nested repository,
|
|
14
|
+
* which is a unit of its own. Everything else stays listed.
|
|
15
|
+
*
|
|
12
16
|
* What this computer already shows stays where it is. A closure member that
|
|
13
17
|
* O holds an active row for, in any root, including a frozen row in an
|
|
14
18
|
* unavailable root, is protected local ground, not a copy for the Enter to
|
|
15
|
-
* create. It is left out with its subtree
|
|
16
|
-
* encloses it. In that case the repository's parcel carries it, and the
|
|
17
|
-
* repository relocation guard owns it. A nested repository is the exception:
|
|
18
|
-
* it owns its own subtree, so it lies outside the enclosing repository's
|
|
19
|
-
* territory and is left out like any other shown member.
|
|
19
|
+
* create. It is left out with its subtree; its own records move it.
|
|
20
20
|
*/
|
|
21
21
|
import { CONTAINERS, eachStep, materializableRecordsSteps, } from "@amalgm/live";
|
|
22
22
|
import { readReceivedState } from "./received-state.js";
|
|
@@ -24,8 +24,9 @@ import { cachedStatement } from "./sqlite.js";
|
|
|
24
24
|
import { finishStepsInTurns } from "./turns.js";
|
|
25
25
|
/** Whether this plan shows a container that was not shown here. */
|
|
26
26
|
export const entersContainer = (plan) => plan.play === "enter" && CONTAINERS.has(plan.target.type);
|
|
27
|
-
/** The closure an Enter installs, read at its target's delivery position
|
|
28
|
-
* A missing kept head throws
|
|
27
|
+
/** The closure an Enter installs, read at its target's delivery position:
|
|
28
|
+
* one unit's when `unit`. A missing kept head throws
|
|
29
|
+
* ReceivedStateUnavailableError. */
|
|
29
30
|
export async function readEnterClosure(input) {
|
|
30
31
|
const { database, intent, target } = input;
|
|
31
32
|
const delivered = cachedStatement(database, `SELECT delivery_sequence AS position FROM record_inbox
|
|
@@ -42,10 +43,30 @@ export async function readEnterClosure(input) {
|
|
|
42
43
|
throw new Error(`received state at delivery ${delivered.position} does not hold Enter target ${target.uuid}`);
|
|
43
44
|
}
|
|
44
45
|
const records = state.records.map(record => record.uuid === target.uuid ? target : record);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const closure = await finishStepsInTurns(materializableRecordsSteps(records, target.uuid));
|
|
47
|
+
return { position: delivered.position, records: input.unit ? unitOf(closure, target) : closure };
|
|
48
|
+
}
|
|
49
|
+
/** One unit of a closure: the target alone, or a repository's members short
|
|
50
|
+
* of a nested repository. */
|
|
51
|
+
function unitOf(closure, target) {
|
|
52
|
+
if (target.type !== "repo.git")
|
|
53
|
+
return closure.filter(record => record.uuid === target.uuid);
|
|
54
|
+
const byUuid = new Map(closure.map(record => [record.uuid, record]));
|
|
55
|
+
const inside = new Map([[target.uuid, true]]);
|
|
56
|
+
const within = (start) => {
|
|
57
|
+
const chain = [];
|
|
58
|
+
let record = start;
|
|
59
|
+
let answer = record && (inside.get(record.uuid) ?? (record.type === "repo.git" ? false : undefined));
|
|
60
|
+
while (answer === undefined) {
|
|
61
|
+
chain.push(record.uuid);
|
|
62
|
+
record = byUuid.get(record.parentUUID);
|
|
63
|
+
answer = record ? inside.get(record.uuid) ?? (record.type === "repo.git" ? false : undefined) : false;
|
|
64
|
+
}
|
|
65
|
+
for (const uuid of chain)
|
|
66
|
+
inside.set(uuid, answer);
|
|
67
|
+
return answer;
|
|
48
68
|
};
|
|
69
|
+
return closure.filter(within);
|
|
49
70
|
}
|
|
50
71
|
/** The closure's division against `shown`, which answers whether O holds an
|
|
51
72
|
* active row for an identity. */
|
|
@@ -54,33 +75,25 @@ export function divideEnter(closure, rootUuid, shown) {
|
|
|
54
75
|
}
|
|
55
76
|
function* divideEnterSteps(closure, rootUuid, shown) {
|
|
56
77
|
const byUuid = new Map(closure.map(record => [record.uuid, record]));
|
|
57
|
-
|
|
78
|
+
/** Whether a record lies beneath a left-out member, itself included. */
|
|
79
|
+
const out = new Map();
|
|
58
80
|
const leftOut = [];
|
|
59
81
|
const pass = (record) => {
|
|
60
|
-
const known =
|
|
82
|
+
const known = out.get(record.uuid);
|
|
61
83
|
if (known !== undefined)
|
|
62
84
|
return known;
|
|
63
|
-
let result;
|
|
64
|
-
if (record.uuid
|
|
65
|
-
result = record.type === "repo.git" ? "enclosed" : "free";
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
85
|
+
let result = false;
|
|
86
|
+
if (record.uuid !== rootUuid) {
|
|
68
87
|
const parent = byUuid.get(record.parentUUID);
|
|
69
88
|
if (!parent)
|
|
70
89
|
throw new Error(`Enter closure member ${record.uuid} has no parent in its closure`);
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
result = "out";
|
|
74
|
-
}
|
|
75
|
-
else if (shown(record.uuid) && (above === "free" || record.type === "repo.git")) {
|
|
90
|
+
result = pass(parent);
|
|
91
|
+
if (!result && shown(record.uuid)) {
|
|
76
92
|
leftOut.push(record.uuid);
|
|
77
|
-
result =
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
result = above === "enclosed" || record.type === "repo.git" ? "enclosed" : "free";
|
|
93
|
+
result = true;
|
|
81
94
|
}
|
|
82
95
|
}
|
|
83
|
-
|
|
96
|
+
out.set(record.uuid, result);
|
|
84
97
|
return result;
|
|
85
98
|
};
|
|
86
99
|
yield* eachStep(closure, pass);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-enter-plan.js","sourceRoot":"","sources":["../src/apply-enter-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,UAAU,EACV,QAAQ,EACR,0BAA0B,GAK3B,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,iBAAiB,EAAkB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,mEAAmE;AACnE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAqB,EAAW,EAAE,CAChE,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAU5D
|
|
1
|
+
{"version":3,"file":"apply-enter-plan.js","sourceRoot":"","sources":["../src/apply-enter-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,UAAU,EACV,QAAQ,EACR,0BAA0B,GAK3B,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,iBAAiB,EAAkB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,mEAAmE;AACnE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAqB,EAAW,EAAE,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E,CAAC;YAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,UAAW,CAAC,CAAC;YAC9C,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,MAAM,CAAC,IAAI,+BAA+B,CAAC,CAAC;YACjG,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;YACtB,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;gBAClC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAC1B,MAAM,GAAG,IAAI,CAAC;YAChB,CAAC;QACH,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC7B,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IACF,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC/B,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -1,32 +1,20 @@
|
|
|
1
1
|
/** Live's local-work gate (src/apply/local-work.ts) over this computer's
|
|
2
|
-
* Outbox
|
|
3
|
-
*
|
|
2
|
+
* Outbox and Inbox: whether a local record on an entity's own channel is not
|
|
3
|
+
* ordered at or before an accepted target.
|
|
4
4
|
*
|
|
5
5
|
* Order is delivery position. A stamped receipt carries its own; a pending
|
|
6
6
|
* row takes the Inbox position of the same mutation when Receive already
|
|
7
7
|
* holds it, because Send's stamp can land after Receive; otherwise its
|
|
8
8
|
* position is unknown, so it is after every target. Send accepts one row at
|
|
9
9
|
* a time in local order, so stamped positions rise with local order, and on
|
|
10
|
-
* one channel with the channel's sequence:
|
|
11
|
-
*
|
|
10
|
+
* one channel with the channel's sequence: the newest receipt alone says
|
|
11
|
+
* whether any receipt is after the target.
|
|
12
12
|
*
|
|
13
|
-
* The entity's own channel speaks for it, and so do the packages of the
|
|
14
|
-
* repository Live names from this computer's notebook (speakingRepository).
|
|
15
13
|
* Most targets meet no local work at all, so one probe of the authority's
|
|
16
14
|
* pending rows and newest receipt answers them before any channel is read. */
|
|
17
|
-
import { type TargetPlacement } from "@amalgm/live";
|
|
18
15
|
import type Database from "better-sqlite3";
|
|
19
|
-
/**
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
readonly result: TargetPlacement;
|
|
24
|
-
}
|
|
25
|
-
/** The full gate for one target. */
|
|
26
|
-
export declare function hasLocalWorkAfter(database: Database.Database, authorityId: string, target: LocalWorkTarget): boolean;
|
|
27
|
-
/** The full gate for the retained Inbox row at `globalSequence` on the
|
|
28
|
-
* entity's channel: the Apply store's port form. */
|
|
16
|
+
/** Whether a local record on the entity's channel is after `deliverySequence`. */
|
|
17
|
+
export declare function hasLocalWorkAfter(database: Database.Database, authorityId: string, entityId: string, deliverySequence: number): boolean;
|
|
18
|
+
/** The gate for the retained Inbox row at `globalSequence` on the entity's
|
|
19
|
+
* channel: the Apply store's port form. */
|
|
29
20
|
export declare function hasLocalWorkAfterSequence(database: Database.Database, authorityId: string, entityId: string, globalSequence: number): boolean;
|
|
30
|
-
/** Only the entity's own channel, for a target that rests on its own row
|
|
31
|
-
* alone: every statement after `deliverySequence`, pending ones included. */
|
|
32
|
-
export declare function hasOwnWorkAfter(database: Database.Database, authorityId: string, entityId: string, deliverySequence: number): boolean;
|
package/dist/apply-local-work.js
CHANGED
|
@@ -1,27 +1,11 @@
|
|
|
1
|
-
/** Live's local-work gate (src/apply/local-work.ts) over this computer's
|
|
2
|
-
* Outbox, Inbox and notebook: whether a local statement that speaks for an
|
|
3
|
-
* entity is not ordered at or before an accepted target.
|
|
4
|
-
*
|
|
5
|
-
* Order is delivery position. A stamped receipt carries its own; a pending
|
|
6
|
-
* row takes the Inbox position of the same mutation when Receive already
|
|
7
|
-
* holds it, because Send's stamp can land after Receive; otherwise its
|
|
8
|
-
* position is unknown, so it is after every target. Send accepts one row at
|
|
9
|
-
* a time in local order, so stamped positions rise with local order, and on
|
|
10
|
-
* one channel with the channel's sequence: each read below seeks the newest
|
|
11
|
-
* receipt and stops at the first one ordered at or before the target.
|
|
12
|
-
*
|
|
13
|
-
* The entity's own channel speaks for it, and so do the packages of the
|
|
14
|
-
* repository Live names from this computer's notebook (speakingRepository).
|
|
15
|
-
* Most targets meet no local work at all, so one probe of the authority's
|
|
16
|
-
* pending rows and newest receipt answers them before any channel is read. */
|
|
17
|
-
import { speakingRepository } from "@amalgm/live";
|
|
18
1
|
import { cachedStatement } from "./sqlite.js";
|
|
19
|
-
/**
|
|
20
|
-
export function hasLocalWorkAfter(database, authorityId,
|
|
21
|
-
return
|
|
2
|
+
/** Whether a local record on the entity's channel is after `deliverySequence`. */
|
|
3
|
+
export function hasLocalWorkAfter(database, authorityId, entityId, deliverySequence) {
|
|
4
|
+
return anyWorkAfter(database, authorityId, deliverySequence)
|
|
5
|
+
&& channelWorkAfter(database, authorityId, entityId, deliverySequence);
|
|
22
6
|
}
|
|
23
|
-
/** The
|
|
24
|
-
*
|
|
7
|
+
/** The gate for the retained Inbox row at `globalSequence` on the entity's
|
|
8
|
+
* channel: the Apply store's port form. */
|
|
25
9
|
export function hasLocalWorkAfterSequence(database, authorityId, entityId, globalSequence) {
|
|
26
10
|
const deliverySequence = cachedStatement(database, `SELECT delivery_sequence FROM record_inbox
|
|
27
11
|
WHERE entity_id = ? AND global_sequence = ? AND authority_id = ?`).pluck()
|
|
@@ -29,33 +13,9 @@ export function hasLocalWorkAfterSequence(database, authorityId, entityId, globa
|
|
|
29
13
|
if (deliverySequence === undefined) {
|
|
30
14
|
throw new Error(`Apply local-work target ${entityId}@${globalSequence} is not retained`);
|
|
31
15
|
}
|
|
32
|
-
return
|
|
33
|
-
const result = cachedStatement(database, `SELECT json_extract(record_json, '$.change.result.uuid') AS uuid,
|
|
34
|
-
json_extract(record_json, '$.change.result.type') AS type,
|
|
35
|
-
json_extract(record_json, '$.change.result.parentUUID') AS parentUUID,
|
|
36
|
-
json_extract(record_json, '$.change.result.transportVersion') AS transportVersion
|
|
37
|
-
FROM record_inbox WHERE entity_id = ? AND global_sequence = ?`).get(entityId, globalSequence);
|
|
38
|
-
return result;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/** Only the entity's own channel, for a target that rests on its own row
|
|
42
|
-
* alone: every statement after `deliverySequence`, pending ones included. */
|
|
43
|
-
export function hasOwnWorkAfter(database, authorityId, entityId, deliverySequence) {
|
|
44
|
-
return anyWorkAfter(database, authorityId, deliverySequence)
|
|
45
|
-
&& channelWorkAfter(database, authorityId, entityId, deliverySequence, false);
|
|
16
|
+
return hasLocalWorkAfter(database, authorityId, entityId, deliverySequence);
|
|
46
17
|
}
|
|
47
|
-
|
|
48
|
-
if (!anyWorkAfter(database, authorityId, deliverySequence))
|
|
49
|
-
return false;
|
|
50
|
-
if (channelWorkAfter(database, authorityId, entityId, deliverySequence, false))
|
|
51
|
-
return true;
|
|
52
|
-
const held = cachedStatement(database, `SELECT root_uuid AS rootUUID, type, parent_uuid AS parentUUID,
|
|
53
|
-
transport_version AS transportVersion
|
|
54
|
-
FROM detection_notebook WHERE uuid = ? LIMIT 1`).get(entityId);
|
|
55
|
-
const repositoryId = speakingRepository(result(), held ?? null, notebookGround(database, held));
|
|
56
|
-
return repositoryId !== null && channelWorkAfter(database, authorityId, repositoryId, deliverySequence, true);
|
|
57
|
-
}
|
|
58
|
-
/** Whether any local statement on the authority may be after the target:
|
|
18
|
+
/** Whether any local record on the authority may be after the target:
|
|
59
19
|
* a pending row, or a newest receipt delivered after it. */
|
|
60
20
|
function anyWorkAfter(database, authorityId, deliverySequence) {
|
|
61
21
|
return cachedStatement(database, `SELECT
|
|
@@ -65,57 +25,20 @@ function anyWorkAfter(database, authorityId, deliverySequence) {
|
|
|
65
25
|
ORDER BY local_sequence DESC LIMIT 1), 0) > ?`).pluck()
|
|
66
26
|
.get(authorityId, authorityId, deliverySequence) === 1;
|
|
67
27
|
}
|
|
68
|
-
const
|
|
69
|
-
const pendingAfter = (packagesOnly) => `SELECT EXISTS (SELECT 1 FROM record_outbox AS local
|
|
28
|
+
const PENDING_AFTER = `SELECT EXISTS (SELECT 1 FROM record_outbox AS local
|
|
70
29
|
WHERE local.authority_id = ? AND local.entity_id = ? AND local.status = 'pending'
|
|
71
|
-
${packagesOnly ? `AND ${PACKAGE}` : ""}
|
|
72
30
|
AND NOT EXISTS (SELECT 1 FROM record_inbox AS inbox
|
|
73
31
|
WHERE inbox.entity_id = local.entity_id AND inbox.mutation_id = local.mutation_id
|
|
74
32
|
AND inbox.authority_id = local.authority_id AND inbox.delivery_sequence <= ?))`;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
/** Whether a statement on this channel, or only a package on it, is after
|
|
81
|
-
* the target. */
|
|
82
|
-
function channelWorkAfter(database, authorityId, entityId, deliverySequence, packagesOnly) {
|
|
83
|
-
const pending = cachedStatement(database, packagesOnly ? PENDING_AFTER.package : PENDING_AFTER.statement)
|
|
84
|
-
.pluck().get(authorityId, entityId, deliverySequence) === 1;
|
|
85
|
-
if (pending)
|
|
33
|
+
const NEWEST_RECEIPT = `SELECT delivery_sequence FROM record_outbox
|
|
34
|
+
WHERE authority_id = ? AND entity_id = ? AND global_sequence IS NOT NULL
|
|
35
|
+
ORDER BY global_sequence DESC LIMIT 1`;
|
|
36
|
+
function channelWorkAfter(database, authorityId, entityId, deliverySequence) {
|
|
37
|
+
if (cachedStatement(database, PENDING_AFTER).pluck().get(authorityId, entityId, deliverySequence) === 1)
|
|
86
38
|
return true;
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
throw new Error(`entity ${entityId} has an accepted local row with no delivery position`);
|
|
92
|
-
if (receipt.deliverySequence <= deliverySequence)
|
|
93
|
-
return false;
|
|
94
|
-
if (!packagesOnly || receipt.package === 1)
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
/** The notebook's answers for speakingRepository. Only a container holds
|
|
100
|
-
* rows beneath it; a parcel beneath one is found by climbing from the
|
|
101
|
-
* parcels in its root, never by walking its subtree. */
|
|
102
|
-
function notebookGround(database, held) {
|
|
103
|
-
return {
|
|
104
|
-
repositoryAt: (containerId) => cachedStatement(database, `WITH RECURSIVE up(uuid, type, parent_uuid) AS (
|
|
105
|
-
SELECT uuid, type, parent_uuid FROM detection_notebook WHERE uuid = ?
|
|
106
|
-
UNION
|
|
107
|
-
SELECT notebook.uuid, notebook.type, notebook.parent_uuid
|
|
108
|
-
FROM detection_notebook AS notebook JOIN up ON notebook.uuid = up.parent_uuid
|
|
109
|
-
WHERE up.type <> 'repo.git')
|
|
110
|
-
SELECT uuid FROM up WHERE type = 'repo.git' LIMIT 1`).pluck().get(containerId) ?? null,
|
|
111
|
-
holdsParcel: (entityId) => held !== undefined && (held.type === "folder" || held.type === "workspace")
|
|
112
|
-
&& cachedStatement(database, `WITH RECURSIVE up(uuid) AS (
|
|
113
|
-
SELECT parent_uuid FROM detection_notebook
|
|
114
|
-
WHERE root_uuid = ? AND (type = 'repo.git' OR transport_version IS NOT NULL) AND parent_uuid IS NOT NULL
|
|
115
|
-
UNION
|
|
116
|
-
SELECT notebook.parent_uuid FROM detection_notebook AS notebook JOIN up ON notebook.uuid = up.uuid
|
|
117
|
-
WHERE up.uuid <> ? AND notebook.parent_uuid IS NOT NULL)
|
|
118
|
-
SELECT EXISTS (SELECT 1 FROM up WHERE uuid = ?)`).pluck().get(held.rootUUID, entityId, entityId) === 1,
|
|
119
|
-
};
|
|
39
|
+
const newest = cachedStatement(database, NEWEST_RECEIPT).pluck().get(authorityId, entityId);
|
|
40
|
+
if (newest === null)
|
|
41
|
+
throw new Error(`entity ${entityId} has an accepted local row with no delivery position`);
|
|
42
|
+
return newest !== undefined && newest > deliverySequence;
|
|
120
43
|
}
|
|
121
44
|
//# sourceMappingURL=apply-local-work.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-local-work.js","sourceRoot":"","sources":["../src/apply-local-work.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apply-local-work.js","sourceRoot":"","sources":["../src/apply-local-work.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,kFAAkF;AAClF,MAAM,UAAU,iBAAiB,CAAC,QAA2B,EAAE,WAAmB,EAAE,QAAgB,EAClG,gBAAwB;IACxB,OAAO,YAAY,CAAC,QAAQ,EAAE,WAAW,EAAE,gBAAgB,CAAC;WACvD,gBAAgB,CAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC;AAC3E,CAAC;AAED;2CAC2C;AAC3C,MAAM,UAAU,yBAAyB,CAAC,QAA2B,EAAE,WAAmB,EAAE,QAAgB,EAC1G,cAAsB;IACtB,MAAM,gBAAgB,GAAG,eAAe,CAAC,QAAQ,EAAE;sEACiB,CAAC,CAAC,KAAK,EAAE;SAC1E,GAAG,CAAC,QAAQ,EAAE,cAAc,EAAE,WAAW,CAAuB,CAAC;IACpE,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,2BAA2B,QAAQ,IAAI,cAAc,kBAAkB,CAAC,CAAC;IAC3F,CAAC;IACD,OAAO,iBAAiB,CAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC;AAC9E,CAAC;AAED;4DAC4D;AAC5D,SAAS,YAAY,CAAC,QAA2B,EAAE,WAAmB,EAAE,gBAAwB;IAC9F,OAAO,eAAe,CAAC,QAAQ,EAAE;;;;iEAI8B,CAAC,CAAC,KAAK,EAAE;SACrE,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,aAAa,GAAG;;;;2GAIqF,CAAC;AAC5G,MAAM,cAAc,GAAG;;2CAEoB,CAAC;AAE5C,SAAS,gBAAgB,CAAC,QAA2B,EAAE,WAAmB,EAAE,QAAgB,EAC1F,gBAAwB;IACxB,IAAI,eAAe,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE,gBAAgB,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACrH,MAAM,MAAM,GAAG,eAAe,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAA8B,CAAC;IACzH,IAAI,MAAM,KAAK,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,UAAU,QAAQ,sDAAsD,CAAC,CAAC;IAC/G,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,GAAG,gBAAgB,CAAC;AAC3D,CAAC"}
|
package/dist/apply-showing.d.ts
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
* construct has no ground: it was shown when the construct ledger holds it
|
|
7
7
|
* active (construct-ledger.ts).
|
|
8
8
|
*
|
|
9
|
+
* A root the drive serves is on demand (src/drive/): what O holds beneath it
|
|
10
|
+
* was placed and keeps applying, and a result that would enter is listed
|
|
11
|
+
* until something opens it. An opened unit enters as it would anywhere.
|
|
12
|
+
*
|
|
9
13
|
* The line reader, the settle save and the unbound guard all judge
|
|
10
14
|
* through this one reading, so a save or a guard judges exactly what the
|
|
11
15
|
* read judged, against the tables as they stand then. One judge reads each
|
|
@@ -13,10 +17,20 @@
|
|
|
13
17
|
* same reading (Live window.ts, Independence). */
|
|
14
18
|
import { type CloudEntityRecord, type ShowingJudgment, type WindowPlace } from "@amalgm/live";
|
|
15
19
|
import type Database from "better-sqlite3";
|
|
20
|
+
export interface OnDemand {
|
|
21
|
+
/** Whether this computer places a root's contents on demand. */
|
|
22
|
+
root(rootUUID: string): boolean;
|
|
23
|
+
/** Whether something opened this unit beneath such a root. */
|
|
24
|
+
opened(uuid: string): boolean;
|
|
25
|
+
}
|
|
26
|
+
/** A computer that shows every root whole. */
|
|
27
|
+
export declare const NOTHING_ON_DEMAND: OnDemand;
|
|
16
28
|
export declare class ShownGround {
|
|
17
29
|
#private;
|
|
18
|
-
constructor(database: Database.Database);
|
|
30
|
+
constructor(database: Database.Database, onDemand: OnDemand);
|
|
19
31
|
judge(result: CloudEntityRecord): ShowingJudgment;
|
|
32
|
+
/** Whether the root a result shows beneath places on demand. */
|
|
33
|
+
beneathOnDemand(result: CloudEntityRecord): boolean;
|
|
20
34
|
/** O's active row for one place, read once per judge. */
|
|
21
35
|
place(uuid: string): WindowPlace | undefined;
|
|
22
36
|
}
|