@amalgm/shell 0.1.164-main.42054328268 → 0.1.164-main.42062331539
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/apply-attempt-memory.d.ts +2 -0
- package/dist/apply-attempt-memory.js +4 -0
- package/dist/apply-attempt-memory.js.map +1 -1
- package/dist/apply-enter-build.d.ts +12 -8
- package/dist/apply-enter-build.js +13 -10
- package/dist/apply-enter-build.js.map +1 -1
- package/dist/apply-git-held.d.ts +29 -0
- package/dist/apply-git-held.js +177 -0
- package/dist/apply-git-held.js.map +1 -0
- package/dist/apply-window-cargo.d.ts +2 -1
- package/dist/apply-window-cargo.js +39 -6
- package/dist/apply-window-cargo.js.map +1 -1
- package/dist/apply-window-host.js +22 -5
- package/dist/apply-window-host.js.map +1 -1
- package/dist/git/rail.d.ts +4 -1
- package/dist/git/rail.js +34 -9
- package/dist/git/rail.js.map +1 -1
- package/dist/git-cat-file.d.ts +28 -0
- package/dist/git-cat-file.js +125 -0
- package/dist/git-cat-file.js.map +1 -0
- package/dist/git-command.d.ts +17 -0
- package/dist/git-command.js +64 -8
- package/dist/git-command.js.map +1 -1
- package/dist/machine-host.js +0 -1
- package/dist/machine-host.js.map +1 -1
- package/dist/native/cloud-files.node +0 -0
- package/dist/native/windows-fs.node +0 -0
- package/dist/runtime-wire-host.d.ts +4 -1
- package/dist/runtime-wire-host.js +11 -6
- package/dist/runtime-wire-host.js.map +1 -1
- package/dist/wire-client.d.ts +5 -8
- package/dist/wire-client.js +8 -56
- package/dist/wire-client.js.map +1 -1
- package/npm-shrinkwrap.json +6 -6
- package/package.json +5 -5
|
@@ -6,6 +6,8 @@ export declare class AttemptMemory<V> {
|
|
|
6
6
|
#private;
|
|
7
7
|
get(intent: EntityApplyIntent): V | undefined;
|
|
8
8
|
set(intent: EntityApplyIntent, value: V): void;
|
|
9
|
+
/** How many members of the attempt hold a value. */
|
|
10
|
+
count(attemptId: string): number;
|
|
9
11
|
delete(intent: EntityApplyIntent): void;
|
|
10
12
|
forget(attemptId: string): void;
|
|
11
13
|
}
|
|
@@ -12,6 +12,10 @@ export class AttemptMemory {
|
|
|
12
12
|
this.#attempts.set(intent.attemptId, members = new Map());
|
|
13
13
|
members.set(intent.entityId, value);
|
|
14
14
|
}
|
|
15
|
+
/** How many members of the attempt hold a value. */
|
|
16
|
+
count(attemptId) {
|
|
17
|
+
return this.#attempts.get(attemptId)?.size ?? 0;
|
|
18
|
+
}
|
|
15
19
|
delete(intent) {
|
|
16
20
|
this.#attempts.get(intent.attemptId)?.delete(intent.entityId);
|
|
17
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-attempt-memory.js","sourceRoot":"","sources":["../src/apply-attempt-memory.ts"],"names":[],"mappings":"AAEA;;mCAEmC;AACnC,MAAM,OAAO,aAAa;IACf,SAAS,GAAG,IAAI,GAAG,EAA0B,CAAC;IAEvD,GAAG,CAAC,MAAyB;QAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACpE,CAAC;IAED,GAAG,CAAC,MAAyB,EAAE,KAAQ;QACrC,IAAI,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACnD,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC;QACxE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,MAAyB;QAC9B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,SAAiB;QACtB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"apply-attempt-memory.js","sourceRoot":"","sources":["../src/apply-attempt-memory.ts"],"names":[],"mappings":"AAEA;;mCAEmC;AACnC,MAAM,OAAO,aAAa;IACf,SAAS,GAAG,IAAI,GAAG,EAA0B,CAAC;IAEvD,GAAG,CAAC,MAAyB;QAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACpE,CAAC;IAED,GAAG,CAAC,MAAyB,EAAE,KAAQ;QACrC,IAAI,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACnD,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC;QACxE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,oDAAoD;IACpD,KAAK,CAAC,SAAiB;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,IAAI,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,CAAC,MAAyB;QAC9B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,SAAiB;QACtB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -43,18 +43,20 @@ export interface EnterExpectation {
|
|
|
43
43
|
readonly leftOut: readonly string[];
|
|
44
44
|
readonly targetPath: string;
|
|
45
45
|
}
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
|
|
46
|
+
/** One Enter's staging directory inside its window's control directory.
|
|
47
|
+
* Every member of a window shares that directory, so each Enter takes its own
|
|
48
|
+
* slot, numbered in the order its window first builds it. The slot is the
|
|
49
|
+
* shortest name that keeps two Enters apart: Git for Windows refuses a
|
|
50
|
+
* repository past about 250 characters, and every character spent here is
|
|
51
|
+
* one a repository entering cannot use. */
|
|
52
|
+
export declare const enterStaging: (control: string, slot: number) => string;
|
|
51
53
|
/** Whether a seal shows exactly what the expectation asks for. */
|
|
52
54
|
export declare const sealShows: (seal: EnterSeal, expected: EnterExpectation) => boolean;
|
|
53
55
|
/** The seal an intent's staging holds, or null when it was never sealed. */
|
|
54
56
|
export declare function readEnterSeal(staging: string): EnterSeal | null;
|
|
55
|
-
/** The seal a bound Enter depends on
|
|
56
|
-
* only the seal is read. */
|
|
57
|
-
export declare function boundEnter(
|
|
57
|
+
/** The seal a bound Enter depends on, found beside the tree its receipt
|
|
58
|
+
* names. The tree may already have landed, so only the seal is read. */
|
|
59
|
+
export declare function boundEnter(tree: string): PreparedEnter;
|
|
58
60
|
/**
|
|
59
61
|
* Build, or adopt, the tree an unbound Enter lands. A sealed tree this attempt
|
|
60
62
|
* built that still stands and shows what is expected is adopted. Anything
|
|
@@ -63,6 +65,8 @@ export declare function boundEnter(staging: string): PreparedEnter;
|
|
|
63
65
|
*/
|
|
64
66
|
export declare function prepareEnter(input: {
|
|
65
67
|
readonly control: string;
|
|
68
|
+
/** This Enter's slot in its window (enterStaging). */
|
|
69
|
+
readonly slot: number;
|
|
66
70
|
readonly closure: EnterClosure;
|
|
67
71
|
readonly expected: EnterExpectation;
|
|
68
72
|
/** The binding root whose content clock qualifies the rows. */
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* with the clock epoch they were taken in, and an adopted seal has none.
|
|
23
23
|
*/
|
|
24
24
|
import { readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
25
|
-
import { join } from "node:path";
|
|
25
|
+
import { dirname, join } from "node:path";
|
|
26
26
|
import { flushEach } from "./flush.js";
|
|
27
27
|
import { ensureApplyPrivate } from "./apply-control.js";
|
|
28
28
|
import { holds, standing } from "./apply-spelling.js";
|
|
@@ -30,11 +30,13 @@ import { durabilityBarrier } from "./durability-barrier.js";
|
|
|
30
30
|
import { materializeRecords } from "./materialize-records.js";
|
|
31
31
|
import { isPhysicalKey, physicalKey } from "./source-signature.js";
|
|
32
32
|
const CONTRACT = "amalgm.apply-enter@2";
|
|
33
|
-
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
|
|
33
|
+
/** One Enter's staging directory inside its window's control directory.
|
|
34
|
+
* Every member of a window shares that directory, so each Enter takes its own
|
|
35
|
+
* slot, numbered in the order its window first builds it. The slot is the
|
|
36
|
+
* shortest name that keeps two Enters apart: Git for Windows refuses a
|
|
37
|
+
* repository past about 250 characters, and every character spent here is
|
|
38
|
+
* one a repository entering cannot use. */
|
|
39
|
+
export const enterStaging = (control, slot) => join(control, "enter", String(slot));
|
|
38
40
|
const treeOf = (staging) => join(staging, "tree");
|
|
39
41
|
const sealOf = (staging) => join(staging, "install.json");
|
|
40
42
|
const sameList = (left, right) => left.length === right.length && left.every((value, index) => value === right[index]);
|
|
@@ -65,9 +67,10 @@ export function readEnterSeal(staging) {
|
|
|
65
67
|
}
|
|
66
68
|
/** An adopted seal: the rows stand, and no process proof survives. */
|
|
67
69
|
const adopted = (staging, seal) => ({ tree: treeOf(staging), seal, proofs: new Map(), contentBoundary: null });
|
|
68
|
-
/** The seal a bound Enter depends on
|
|
69
|
-
* only the seal is read. */
|
|
70
|
-
export function boundEnter(
|
|
70
|
+
/** The seal a bound Enter depends on, found beside the tree its receipt
|
|
71
|
+
* names. The tree may already have landed, so only the seal is read. */
|
|
72
|
+
export function boundEnter(tree) {
|
|
73
|
+
const staging = dirname(tree);
|
|
71
74
|
const seal = readEnterSeal(staging);
|
|
72
75
|
if (!seal)
|
|
73
76
|
throw new Error(`bound Apply Enter has no sealed install at ${staging}`);
|
|
@@ -81,7 +84,7 @@ export function boundEnter(staging) {
|
|
|
81
84
|
*/
|
|
82
85
|
export async function prepareEnter(input) {
|
|
83
86
|
const { expected } = input;
|
|
84
|
-
const staging = enterStaging(input.control), tree = treeOf(staging);
|
|
87
|
+
const staging = enterStaging(input.control, input.slot), tree = treeOf(staging);
|
|
85
88
|
const existing = readEnterSeal(staging);
|
|
86
89
|
if (existing && sealShows(existing, expected) && holds(tree, existing.root))
|
|
87
90
|
return adopted(staging, existing);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-enter-build.js","sourceRoot":"","sources":["../src/apply-enter-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"apply-enter-build.js","sourceRoot":"","sources":["../src/apply-enter-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAI1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EAAE,iBAAiB,EAAoB,MAAM,yBAAyB,CAAC;AAE9E,OAAO,EAAE,kB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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;;uEAEuE;AACvE,KAAK,UAAU,SAAS,CAAC,OAAe,EAAE,IAAe,EAAE,OAA+B;IACxF,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,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3F,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC1B,MAAM,SAAS,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type CargoWant } from "@amalgm/live";
|
|
2
|
+
import { type WindowGround } from "./apply-window-ground.js";
|
|
3
|
+
/** One want this computer places inside a repository: its path there. */
|
|
4
|
+
export interface Placed {
|
|
5
|
+
readonly want: CargoWant;
|
|
6
|
+
readonly path: string;
|
|
7
|
+
}
|
|
8
|
+
export interface HeldBlob {
|
|
9
|
+
readonly want: CargoWant;
|
|
10
|
+
readonly bytes: Buffer;
|
|
11
|
+
}
|
|
12
|
+
export declare class GitHeld {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(ground: WindowGround, report: (error: Error) => void);
|
|
15
|
+
/** What the repository's Apply here just left behind (GitApplied.left),
|
|
16
|
+
* before what earlier ones did: two records of a repository may land
|
|
17
|
+
* before the file record that steps back. */
|
|
18
|
+
left(repository: string, commits: readonly string[]): void;
|
|
19
|
+
/** The wants whose file stands inside a repository here, by repository
|
|
20
|
+
* UUID, and the rest. From rows only: nothing is read from disk or Git. */
|
|
21
|
+
place(wants: readonly CargoWant[]): {
|
|
22
|
+
readonly near: ReadonlyMap<string, readonly Placed[]>;
|
|
23
|
+
readonly away: readonly CargoWant[];
|
|
24
|
+
};
|
|
25
|
+
/** The blobs each repository holds for its wants, as they are read. A
|
|
26
|
+
* repository Git cannot read holds nothing; any fault but Git's refusal is
|
|
27
|
+
* reported. */
|
|
28
|
+
read(near: ReadonlyMap<string, readonly Placed[]>): AsyncGenerator<HeldBlob>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/** A repository's file result from the Git this computer already holds. When
|
|
2
|
+
* a person steps a repository to a branch, tag or stash this computer's Git
|
|
3
|
+
* already has, the file's result is a blob there, so Apply reads it from Git
|
|
4
|
+
* and nothing comes over the wire for it. Only commits the repository names,
|
|
5
|
+
* or named until a recent Apply here, are asked, each at the file's place in
|
|
6
|
+
* it: HEAD, ORIG_HEAD, the stash's newest entry with its index and untracked
|
|
7
|
+
* sides, its most recent refs, and what the names those Applies rewrote named
|
|
8
|
+
* before (src/git/rail.ts), so a file whose record follows its repository's
|
|
9
|
+
* finds the stash that record popped. That memory is this process's alone: a
|
|
10
|
+
* restart between the two records leaves the wire to bring the file. A
|
|
11
|
+
* blob is the result only when its bytes hash to the record's content hash,
|
|
12
|
+
* so a filter, a line-ending conversion, or a commit reached only through
|
|
13
|
+
* history leaves the wire to bring it. Git only reads objects and refs here,
|
|
14
|
+
* in two processes started together: no command reads the index, which a
|
|
15
|
+
* reader may refresh, or looks above the repository for another. */
|
|
16
|
+
import { dirname, relative, sep } from "node:path";
|
|
17
|
+
import { CHUNK_BYTES } from "@amalgm/live";
|
|
18
|
+
import { pathInside } from "./apply-window-ground.js";
|
|
19
|
+
import { CatFile } from "./git-cat-file.js";
|
|
20
|
+
import { GitFailure, runGit } from "./git-command.js";
|
|
21
|
+
import { sha256Hex } from "./sha256.js";
|
|
22
|
+
/** Refs asked, most recently made first: a step lands on a state its
|
|
23
|
+
* repository named lately, and the question stays the same size however
|
|
24
|
+
* many refs a repository keeps. */
|
|
25
|
+
const HELD_REFS = 64;
|
|
26
|
+
/** Commits recent Applies left behind that are asked, newest first, each
|
|
27
|
+
* with its two sides. */
|
|
28
|
+
const HELD_LEFT = 16;
|
|
29
|
+
/** Bytes one read of blobs holds in memory: one download's bound. A larger
|
|
30
|
+
* blob comes over the wire, which streams it. */
|
|
31
|
+
const HELD_READ_BYTES = 2 * CHUNK_BYTES;
|
|
32
|
+
const lines = (answer) => answer.toString("utf8").split("\n").filter(line => line !== "");
|
|
33
|
+
/** Commits asked by name: where a step back most often lands. The stash's
|
|
34
|
+
* newest entry is asked with its index and untracked sides, as is each
|
|
35
|
+
* commit an Apply left behind; an older entry pops from the wire. */
|
|
36
|
+
const NAMED = ["HEAD", "ORIG_HEAD", "refs/stash", "refs/stash^2", "refs/stash^3"];
|
|
37
|
+
export class GitHeld {
|
|
38
|
+
#ground;
|
|
39
|
+
#report;
|
|
40
|
+
/** By repository UUID: what its recent Applies here left behind. */
|
|
41
|
+
#left = new Map();
|
|
42
|
+
constructor(ground, report) {
|
|
43
|
+
this.#ground = ground;
|
|
44
|
+
this.#report = report;
|
|
45
|
+
}
|
|
46
|
+
/** What the repository's Apply here just left behind (GitApplied.left),
|
|
47
|
+
* before what earlier ones did: two records of a repository may land
|
|
48
|
+
* before the file record that steps back. */
|
|
49
|
+
left(repository, commits) {
|
|
50
|
+
if (commits.length === 0)
|
|
51
|
+
return;
|
|
52
|
+
const recent = new Set([...commits, ...this.#left.get(repository) ?? []]);
|
|
53
|
+
this.#left.set(repository, [...recent].slice(0, HELD_LEFT));
|
|
54
|
+
}
|
|
55
|
+
/** The wants whose file stands inside a repository here, by repository
|
|
56
|
+
* UUID, and the rest. From rows only: nothing is read from disk or Git. */
|
|
57
|
+
place(wants) {
|
|
58
|
+
const near = new Map(), away = [];
|
|
59
|
+
for (const want of wants) {
|
|
60
|
+
const placed = this.#placeOne(want);
|
|
61
|
+
if (placed === null)
|
|
62
|
+
away.push(want);
|
|
63
|
+
else
|
|
64
|
+
near.set(placed.repository, [...near.get(placed.repository) ?? [], { want, path: placed.path }]);
|
|
65
|
+
}
|
|
66
|
+
return { near, away };
|
|
67
|
+
}
|
|
68
|
+
/** The blobs each repository holds for its wants, as they are read. A
|
|
69
|
+
* repository Git cannot read holds nothing; any fault but Git's refusal is
|
|
70
|
+
* reported. */
|
|
71
|
+
async *read(near) {
|
|
72
|
+
for (const [repository, placed] of near) {
|
|
73
|
+
const checkout = this.#ground.current(repository)?.absolutePath;
|
|
74
|
+
if (checkout === undefined)
|
|
75
|
+
continue;
|
|
76
|
+
try {
|
|
77
|
+
yield* this.#readRepository(checkout, placed, this.#left.get(repository) ?? []);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (!(error instanceof GitFailure) || error.status !== 128)
|
|
81
|
+
this.#report(error);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** A file's nearest repository and its path there, `/`-separated as Git
|
|
86
|
+
* names it; null for anything else. Its last row places it, even in Trash:
|
|
87
|
+
* a step back may return a file this computer no longer shows. */
|
|
88
|
+
#placeOne(want) {
|
|
89
|
+
if (want.artifact.kind !== "file")
|
|
90
|
+
return null;
|
|
91
|
+
const row = this.#ground.observed(want.artifact.entityId);
|
|
92
|
+
if (!row)
|
|
93
|
+
return null;
|
|
94
|
+
const seen = new Set();
|
|
95
|
+
for (let at = row; at.uuid !== at.rootUUID && at.parentUUID !== null && !seen.has(at.uuid);) {
|
|
96
|
+
seen.add(at.uuid);
|
|
97
|
+
const parent = this.#ground.current(at.parentUUID);
|
|
98
|
+
if (!parent)
|
|
99
|
+
return null;
|
|
100
|
+
if (parent.type === "repo.git") {
|
|
101
|
+
const path = relative(parent.absolutePath, row.absolutePath);
|
|
102
|
+
if (path === "" || !pathInside(parent.absolutePath, row.absolutePath))
|
|
103
|
+
return null;
|
|
104
|
+
const named = path.split(sep).join("/");
|
|
105
|
+
return named.includes("\n") ? null : { repository: parent.uuid, path: named };
|
|
106
|
+
}
|
|
107
|
+
at = parent;
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
async *#readRepository(checkout, placed, left) {
|
|
112
|
+
const invocation = { purpose: "apply", profile: { GIT_CEILING_DIRECTORIES: dirname(checkout) } };
|
|
113
|
+
const objects = new CatFile(checkout, invocation);
|
|
114
|
+
try {
|
|
115
|
+
// The states named outright are asked while Git lists the recent refs.
|
|
116
|
+
const at = (states) => placed.flatMap(entry => states.map(state => ({ entry, name: `${state}:${entry.path}` })));
|
|
117
|
+
const named = at([...NAMED, ...left.flatMap(commit => [commit, `${commit}^2`, `${commit}^3`])]);
|
|
118
|
+
const [early, refs] = await Promise.all([
|
|
119
|
+
objects.info(named.map(({ name }) => name)),
|
|
120
|
+
runGit(checkout, ["for-each-ref", "--sort=-creatordate", `--count=${HELD_REFS}`, "--format=%(objectname)"], invocation),
|
|
121
|
+
]);
|
|
122
|
+
const recent = at([...new Set(lines(refs))]);
|
|
123
|
+
const late = await objects.info(recent.map(({ name }) => name));
|
|
124
|
+
// Each blob once, with the wants it may be: a binary's manifest names its size.
|
|
125
|
+
const candidates = new Map();
|
|
126
|
+
const answers = [...early, ...late];
|
|
127
|
+
[...named, ...recent].forEach(({ entry }, index) => {
|
|
128
|
+
const found = answers[index];
|
|
129
|
+
if (!found || found.type !== "blob" || found.size > HELD_READ_BYTES)
|
|
130
|
+
return;
|
|
131
|
+
if (entry.want.manifest && entry.want.manifest.bytes !== found.size)
|
|
132
|
+
return;
|
|
133
|
+
const candidate = candidates.get(found.oid) ?? { size: found.size, wants: new Set() };
|
|
134
|
+
candidate.wants.add(entry);
|
|
135
|
+
candidates.set(found.oid, candidate);
|
|
136
|
+
});
|
|
137
|
+
// Git stops once every result asked for is found.
|
|
138
|
+
const wanted = new Set(placed.map(({ want }) => want.artifact.contentHash));
|
|
139
|
+
const found = new Set();
|
|
140
|
+
for (const group of groups(candidates)) {
|
|
141
|
+
for await (const { oid, bytes } of objects.contents(group)) {
|
|
142
|
+
const hash = sha256Hex(bytes);
|
|
143
|
+
for (const entry of candidates.get(oid)?.wants ?? []) {
|
|
144
|
+
if (entry.want.artifact.contentHash !== hash || found.has(hash))
|
|
145
|
+
continue;
|
|
146
|
+
found.add(hash);
|
|
147
|
+
yield { want: entry.want, bytes };
|
|
148
|
+
}
|
|
149
|
+
if (found.size === wanted.size)
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
await objects.close();
|
|
154
|
+
}
|
|
155
|
+
finally {
|
|
156
|
+
objects.stop();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/** Blob names in reads whose sizes together stay within the bound. */
|
|
161
|
+
function groups(candidates) {
|
|
162
|
+
const all = [];
|
|
163
|
+
let group = [], bytes = 0;
|
|
164
|
+
for (const [oid, { size }] of candidates) {
|
|
165
|
+
if (group.length > 0 && bytes + size > HELD_READ_BYTES) {
|
|
166
|
+
all.push(group);
|
|
167
|
+
group = [];
|
|
168
|
+
bytes = 0;
|
|
169
|
+
}
|
|
170
|
+
group.push(oid);
|
|
171
|
+
bytes += size;
|
|
172
|
+
}
|
|
173
|
+
if (group.length > 0)
|
|
174
|
+
all.push(group);
|
|
175
|
+
return all;
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=apply-git-held.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-git-held.js","sourceRoot":"","sources":["../src/apply-git-held.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;oEAcoE;AACpE,OAAO,E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C;IAC3B,IAAI,KAAK,GAAa,EAAE,EAAE,KAAK,GAAG,CAAC,CAAC;IACpC,KAAK,MAAM,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC;QACzC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,GAAG,IAAI,GAAG,eAAe,EAAE,CAAC;YACvD,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAChB,KAAK,GAAG,EAAE,CAAC;YACX,KAAK,GAAG,CAAC,CAAC;QACZ,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAChB,KAAK,IAAI,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type BinaryApplyPlan, type CargoWant, type ContentManifest, type LinkApplyPlan, type TextApplyPlan, type TextSplice, type TransferArtifact } from "@amalgm/live";
|
|
2
|
+
import type { GitHeld } from "./apply-git-held.js";
|
|
2
3
|
import type { AddStagingRouting } from "./workspace-add-staging.js";
|
|
3
4
|
export interface LocalApplyArtifact {
|
|
4
5
|
readonly file: string;
|
|
@@ -15,7 +16,7 @@ export type ReadContent = (wants: readonly CargoWant[], onBytes: (bytes: number)
|
|
|
15
16
|
export type OnBytes = ((bytes: number) => void) | undefined;
|
|
16
17
|
export declare class WindowCargo {
|
|
17
18
|
#private;
|
|
18
|
-
constructor(cacheDir: string, download: ReadContent);
|
|
19
|
+
constructor(cacheDir: string, download: ReadContent, held?: GitHeld);
|
|
19
20
|
/** The accepted record names its complete result. Prepare it from what
|
|
20
21
|
* this machine holds, `shown` included: the file it shows at the splice's
|
|
21
22
|
* base. It reaches for the wire only when local truth cannot produce the
|
|
@@ -12,7 +12,12 @@
|
|
|
12
12
|
* lanes cost no more memory than that bound, and a small first open waits
|
|
13
13
|
* for at most one batch, never for a whole large set. A lane joining a
|
|
14
14
|
* flight already in the air adds nothing. A staged read lands inside one
|
|
15
|
-
* Enter's private tree, so it joins any flight but none joins it.
|
|
15
|
+
* Enter's private tree, so it joins any flight but none joins it.
|
|
16
|
+
*
|
|
17
|
+
* A file inside a repository may be a blob that repository's own Git holds:
|
|
18
|
+
* a step back to a branch or stash it keeps. Such a set asks that Git first
|
|
19
|
+
* and the wire only for the rest (apply-git-held.ts); every other file goes
|
|
20
|
+
* to the wire at once. */
|
|
16
21
|
import { readFileSync } from "node:fs";
|
|
17
22
|
import { join } from "node:path";
|
|
18
23
|
import { spliceText } from "@amalgm/live";
|
|
@@ -23,11 +28,13 @@ import { sha256Hex } from "./sha256.js";
|
|
|
23
28
|
export class WindowCargo {
|
|
24
29
|
#cacheDir;
|
|
25
30
|
#download;
|
|
31
|
+
#held;
|
|
26
32
|
/** Each artifact being fetched now, by content hash, and the set fetching it. */
|
|
27
33
|
#flights = new Map();
|
|
28
|
-
constructor(cacheDir, download) {
|
|
34
|
+
constructor(cacheDir, download, held) {
|
|
29
35
|
this.#cacheDir = cacheDir;
|
|
30
36
|
this.#download = download;
|
|
37
|
+
this.#held = held;
|
|
31
38
|
}
|
|
32
39
|
/** The accepted record names its complete result. Prepare it from what
|
|
33
40
|
* this machine holds, `shown` included: the file it shows at the splice's
|
|
@@ -80,10 +87,13 @@ export class WindowCargo {
|
|
|
80
87
|
}
|
|
81
88
|
fly(wants, onBytes, staged) {
|
|
82
89
|
const listeners = new Set(onBytes ? [onBytes] : []);
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
const hear = (bytes) => {
|
|
91
|
+
for (const listener of listeners)
|
|
92
|
+
listener(bytes);
|
|
93
|
+
};
|
|
94
|
+
const lane = onBytes !== undefined;
|
|
95
|
+
const flight = { listeners,
|
|
96
|
+
landing: staged ? this.#download(wants, hear, lane, staged) : this.#land(wants, hear, lane) };
|
|
87
97
|
if (staged)
|
|
88
98
|
return flight.landing;
|
|
89
99
|
const hashes = wants.map(want => want.artifact.contentHash);
|
|
@@ -97,6 +107,29 @@ export class WindowCargo {
|
|
|
97
107
|
flight.landing.then(land, land);
|
|
98
108
|
return flight.landing;
|
|
99
109
|
}
|
|
110
|
+
/** A set sealed from its repositories' own Git where they hold it, the
|
|
111
|
+
* rest from the wire. Files away from every repository leave at once. */
|
|
112
|
+
async #land(wants, hear, lane) {
|
|
113
|
+
const placed = this.#held?.place(wants);
|
|
114
|
+
if (!placed || placed.near.size === 0)
|
|
115
|
+
return this.#download(wants, hear, lane);
|
|
116
|
+
const away = placed.away.length > 0 ? this.#download(placed.away, hear, lane) : undefined;
|
|
117
|
+
// Awaited below; until then its failure must not go unheard.
|
|
118
|
+
away?.catch(() => { });
|
|
119
|
+
const found = new Map();
|
|
120
|
+
for await (const { want, bytes } of this.#held.read(placed.near)) {
|
|
121
|
+
if (found.has(want.artifact.contentHash))
|
|
122
|
+
continue;
|
|
123
|
+
await sealContent(this.#cacheDir, want.artifact, bytes, "apply");
|
|
124
|
+
const sealed = await this.sealed(want.artifact.contentHash, hear);
|
|
125
|
+
if (sealed)
|
|
126
|
+
found.set(want.artifact.contentHash, sealed);
|
|
127
|
+
}
|
|
128
|
+
const rest = [...placed.near.values()].flat().map(({ want }) => want)
|
|
129
|
+
.filter(want => !found.has(want.artifact.contentHash));
|
|
130
|
+
const [wire, far] = await Promise.all([rest.length > 0 ? this.#download(rest, hear, lane) : undefined, away]);
|
|
131
|
+
return new Map([...found, ...wire ?? [], ...far ?? []]);
|
|
132
|
+
}
|
|
100
133
|
async readOne(artifact, manifest, onBytes) {
|
|
101
134
|
const local = (await this.read([{ artifact, ...(manifest ? { manifest } : {}) }], onBytes)).get(artifact.contentHash);
|
|
102
135
|
if (!local)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-window-cargo.js","sourceRoot":"","sources":["../src/apply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K,WAAW;YAAE,OAAO,IAAI,CAAC;QACtE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC;IACzD,CAAC;IACD;;;6BAGyB;IACzB,KAAK,CAAC,MAAM,CACV,QAA0B,EAC1B,QAA6E,EAC7E,KAAc;QAEd,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,QAAQ,CAAC,kBAAkB,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;YACvF,IAAI,IAAI,KAAK,SAAS;gBAAE,SAAS;YACjC,IAAI,IAAY,CAAC;YACjB,IAAI,CAAC;gBACH,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;YAAC,MAAM,CAAC;gBACP,SAAS;YACX,CAAC;YACD,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;YAC3E,IAAI,MAAM,KAAK,IAAI;gBAAE,SAAS;YAC9B,MAAM,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;YAC7D,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -25,8 +25,9 @@ import { ApplyDurability } from "./apply-durability.js";
|
|
|
25
25
|
import { keepAside, keepRemainder, returnKept, topmostRemainder, vacateKept } from "./apply-kept.js";
|
|
26
26
|
import { copyToNewFile } from "./filesystem.js";
|
|
27
27
|
import { flushEach } from "./flush.js";
|
|
28
|
+
import { GitHeld } from "./apply-git-held.js";
|
|
28
29
|
import { WindowCargo } from "./apply-window-cargo.js";
|
|
29
|
-
import { boundEnter,
|
|
30
|
+
import { boundEnter, prepareEnter, sealShows } from "./apply-enter-build.js";
|
|
30
31
|
import { divideEnter, entersContainer, readEnterClosure } from "./apply-enter-plan.js";
|
|
31
32
|
import { bringDisplacedHome, displacedTreeShows, proveDisplacedTree } from "./apply-displaced-tree.js";
|
|
32
33
|
import { captureGitStorage, DISPLACED_GIT, displaceGitStorage, keptStorageIsO, returnGitStorage } from "./apply-git-storage.js";
|
|
@@ -121,6 +122,7 @@ export class ApplyWindowHost {
|
|
|
121
122
|
#cacheDir;
|
|
122
123
|
#bindingDir;
|
|
123
124
|
#cargo;
|
|
125
|
+
#gitHeld;
|
|
124
126
|
#progressed;
|
|
125
127
|
/** The kept heads Enter closures fold from, held until the rail is idle:
|
|
126
128
|
* the lines', and the fetch lanes' own, so a lane never reads behind a
|
|
@@ -139,6 +141,9 @@ export class ApplyWindowHost {
|
|
|
139
141
|
#onDerivedRelocationStage;
|
|
140
142
|
#prepared = new AttemptMemory();
|
|
141
143
|
#enterClosures = new AttemptMemory();
|
|
144
|
+
/** Each container Enter's staging slot. A slot is never given back before
|
|
145
|
+
* its attempt ends, so no two Enters of one window build in one place. */
|
|
146
|
+
#enterSlots = new AttemptMemory();
|
|
142
147
|
/** The ground the window in flight holds. */
|
|
143
148
|
#held = null;
|
|
144
149
|
/** The Git storage manifest a final guard took before proving a repository
|
|
@@ -177,7 +182,9 @@ export class ApplyWindowHost {
|
|
|
177
182
|
this.constructs = new ConstructLedger(this.#database, options.now);
|
|
178
183
|
this.#cacheDir = options.cacheDir;
|
|
179
184
|
this.#bindingDir = options.bindingDir;
|
|
180
|
-
this.#
|
|
185
|
+
this.#ground = new WindowGround(this.#database);
|
|
186
|
+
this.#gitHeld = new GitHeld(this.#ground, error => options.onBackgroundError?.(error));
|
|
187
|
+
this.#cargo = new WindowCargo(options.cacheDir, options.readContent, this.#gitHeld);
|
|
181
188
|
this.#progressed = options.progressed;
|
|
182
189
|
this.cargo = {
|
|
183
190
|
readAhead: (authorityId, after, limit) => this.store.readApplyAhead(authorityId, after, limit),
|
|
@@ -186,7 +193,6 @@ export class ApplyWindowHost {
|
|
|
186
193
|
this.#acquireGround = options.acquireGround;
|
|
187
194
|
this.#onStage = options.onStage;
|
|
188
195
|
this.#onWindowEnded = options.onWindowEnded;
|
|
189
|
-
this.#ground = new WindowGround(this.#database);
|
|
190
196
|
this.#gitOwners = groundGitOwners(this.#database, null, options.gitStorage ?? null);
|
|
191
197
|
this.#onDerivedRelocationStage = options.onDerivedRelocationStage;
|
|
192
198
|
// Every type in Live's alphabet binds both sockets or the registry
|
|
@@ -378,7 +384,9 @@ export class ApplyWindowHost {
|
|
|
378
384
|
if (receipt !== null) {
|
|
379
385
|
if (judgeBoundRoot(receipt.root) !== "present")
|
|
380
386
|
return null;
|
|
381
|
-
|
|
387
|
+
if (!receipt.staged)
|
|
388
|
+
throw new Error("container Enter binds without its staged tree");
|
|
389
|
+
enter = boundEnter(receipt.staged.path);
|
|
382
390
|
}
|
|
383
391
|
else {
|
|
384
392
|
const context = this.#ground.context(plan.target, false);
|
|
@@ -388,6 +396,7 @@ export class ApplyWindowHost {
|
|
|
388
396
|
this.#emit(intent, plan, "preparation-started");
|
|
389
397
|
enter = await prepareEnter({
|
|
390
398
|
control: this.#controlOf(intent, context),
|
|
399
|
+
slot: this.#enterSlot(intent),
|
|
391
400
|
closure,
|
|
392
401
|
expected: { target: plan.target, position: closure.position, leftOut: division.leftOut,
|
|
393
402
|
targetPath: context.targetPath },
|
|
@@ -414,9 +423,16 @@ export class ApplyWindowHost {
|
|
|
414
423
|
const division = await divideEnter(closure.records, plan.target.uuid, uuid => newer.has(uuid) || this.#ground.current(uuid) !== null);
|
|
415
424
|
return { closure, division };
|
|
416
425
|
}
|
|
426
|
+
#enterSlot(intent) {
|
|
427
|
+
let slot = this.#enterSlots.get(intent);
|
|
428
|
+
if (slot === undefined)
|
|
429
|
+
this.#enterSlots.set(intent, slot = this.#enterSlots.count(intent.attemptId));
|
|
430
|
+
return slot;
|
|
431
|
+
}
|
|
417
432
|
#forgetAttempt(attemptId) {
|
|
418
433
|
this.#prepared.forget(attemptId);
|
|
419
434
|
this.#enterClosures.forget(attemptId);
|
|
435
|
+
this.#enterSlots.forget(attemptId);
|
|
420
436
|
this.#gitStorage.forget(attemptId);
|
|
421
437
|
this.#displaced.forget(attemptId);
|
|
422
438
|
this.#contentReads.forget(attemptId);
|
|
@@ -958,7 +974,8 @@ export class ApplyWindowHost {
|
|
|
958
974
|
// their name, else the wire.
|
|
959
975
|
const source = async (version) => readFile((await this.#cargo.sealed(version, this.#onBytes(intent))
|
|
960
976
|
?? await this.#cargo.readOne({ ...artifact, contentHash: version }, undefined, this.#onBytes(intent))).file);
|
|
961
|
-
const { shown } = await applyGit(receipt.address, target, source, await known(), this.#gitOwners);
|
|
977
|
+
const { shown, left } = await applyGit(receipt.address, target, source, await known(), this.#gitOwners);
|
|
978
|
+
this.#gitHeld.left(intent.entityId, left);
|
|
962
979
|
// Unflushed: a lost `ended` only runs the same install again.
|
|
963
980
|
writeFileSync(marker, shown === plan.target.payloadVersion ? "ended" : `ended ${shown}`);
|
|
964
981
|
}
|