@amalgm/shell 0.1.74 → 0.1.75
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/PURPOSE.md +39 -11
- package/dist/detection/runtime.d.ts +3 -0
- package/dist/detection/runtime.js +32 -1
- package/dist/detection/runtime.js.map +1 -1
- package/dist/entity-apply-host.d.ts +11 -2
- package/dist/entity-apply-host.js +25 -3
- package/dist/entity-apply-host.js.map +1 -1
- package/dist/git-command.js +14 -2
- package/dist/git-command.js.map +1 -1
- package/dist/ground-coordination.d.ts +26 -0
- package/dist/ground-coordination.js +83 -0
- package/dist/ground-coordination.js.map +1 -0
- package/dist/user-ground-host.d.ts +5 -2
- package/dist/user-ground-host.js +248 -116
- package/dist/user-ground-host.js.map +1 -1
- package/dist/watching/host.d.ts +5 -0
- package/dist/watching/host.js +22 -0
- package/dist/watching/host.js.map +1 -1
- package/package.json +1 -1
package/dist/git-command.js
CHANGED
|
@@ -14,7 +14,15 @@ export function runGit(cwd, args, input) {
|
|
|
14
14
|
input,
|
|
15
15
|
maxBuffer: MAX_GIT_BUFFER,
|
|
16
16
|
stdio: ["pipe", "pipe", "pipe"],
|
|
17
|
-
env: {
|
|
17
|
+
env: {
|
|
18
|
+
...process.env,
|
|
19
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
20
|
+
// Background observation must not create the index lock events it is
|
|
21
|
+
// itself listening for. Git still takes every lock required for a
|
|
22
|
+
// requested write; this disables only optional side effects such as
|
|
23
|
+
// refreshing the index during a read.
|
|
24
|
+
GIT_OPTIONAL_LOCKS: "0",
|
|
25
|
+
},
|
|
18
26
|
});
|
|
19
27
|
}
|
|
20
28
|
catch (error) {
|
|
@@ -42,7 +50,11 @@ export function runGitToFile(cwd, args, input, file) {
|
|
|
42
50
|
input,
|
|
43
51
|
maxBuffer: MAX_GIT_BUFFER,
|
|
44
52
|
stdio: ["pipe", descriptor, "pipe"],
|
|
45
|
-
env: {
|
|
53
|
+
env: {
|
|
54
|
+
...process.env,
|
|
55
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
56
|
+
GIT_OPTIONAL_LOCKS: "0",
|
|
57
|
+
},
|
|
46
58
|
});
|
|
47
59
|
}
|
|
48
60
|
catch (error) {
|
package/dist/git-command.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-command.js","sourceRoot":"","sources":["../src/git-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,cAAc,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAEzC,SAAS,iBAAiB,CAAC,KAAc,EAAE,IAAuB;IAChE,MAAM,OAAO,GAAG,KAAoC,CAAC;IACrD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IACvD,OAAO,CAAC,OAAO,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAC/E,MAAM,OAAO,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,GAAW,EAAE,IAAuB,EAAE,KAAkB;IAC7E,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE;YACpC,GAAG;YACH,KAAK;YACL,SAAS,EAAE,cAAc;YACzB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;YAC/B,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"git-command.js","sourceRoot":"","sources":["../src/git-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EA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,GAAW,EAAE,IAAuB;IAC7D,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAChC,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ground coordination by address cone.
|
|
3
|
+
*
|
|
4
|
+
* Every host effect that reads or writes visible ground names the directory
|
|
5
|
+
* cones it touches. Two effects conflict only when one cone contains the
|
|
6
|
+
* other; unrelated cones proceed concurrently. Conflicting effects are served
|
|
7
|
+
* in request order, so a stream of small effects can never starve an earlier
|
|
8
|
+
* large one, and a timed-out waiter leaves the queue instead of poisoning it.
|
|
9
|
+
*/
|
|
10
|
+
export interface GroundScopeOptions {
|
|
11
|
+
/** Reject instead of waiting longer than this for conflicting holders. */
|
|
12
|
+
readonly timeoutMs?: number;
|
|
13
|
+
}
|
|
14
|
+
/** True when one cone contains the other, or both are the same address. */
|
|
15
|
+
export declare function conesConflict(left: string, right: string): boolean;
|
|
16
|
+
export declare class GroundCoordinator {
|
|
17
|
+
#private;
|
|
18
|
+
/** Cones currently held or awaited, oldest first. Diagnostics only. */
|
|
19
|
+
get pending(): readonly (readonly string[])[];
|
|
20
|
+
/**
|
|
21
|
+
* Wait until every earlier ticket whose cones conflict with `cones` has
|
|
22
|
+
* been released, then hold those cones until the returned function runs.
|
|
23
|
+
* An empty cone list conflicts with nothing and returns immediately.
|
|
24
|
+
*/
|
|
25
|
+
acquire(cones: readonly string[], options?: GroundScopeOptions): Promise<() => void>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ground coordination by address cone.
|
|
3
|
+
*
|
|
4
|
+
* Every host effect that reads or writes visible ground names the directory
|
|
5
|
+
* cones it touches. Two effects conflict only when one cone contains the
|
|
6
|
+
* other; unrelated cones proceed concurrently. Conflicting effects are served
|
|
7
|
+
* in request order, so a stream of small effects can never starve an earlier
|
|
8
|
+
* large one, and a timed-out waiter leaves the queue instead of poisoning it.
|
|
9
|
+
*/
|
|
10
|
+
import { resolve, sep } from "node:path";
|
|
11
|
+
const normalizeCone = (cone) => {
|
|
12
|
+
const normalized = resolve(cone);
|
|
13
|
+
return normalized.endsWith(sep) ? normalized : `${normalized}${sep}`;
|
|
14
|
+
};
|
|
15
|
+
/** True when one cone contains the other, or both are the same address. */
|
|
16
|
+
export function conesConflict(left, right) {
|
|
17
|
+
const a = normalizeCone(left);
|
|
18
|
+
const b = normalizeCone(right);
|
|
19
|
+
return a === b || a.startsWith(b) || b.startsWith(a);
|
|
20
|
+
}
|
|
21
|
+
export class GroundCoordinator {
|
|
22
|
+
#queue = [];
|
|
23
|
+
/** Cones currently held or awaited, oldest first. Diagnostics only. */
|
|
24
|
+
get pending() {
|
|
25
|
+
return this.#queue.map((ticket) => ticket.cones);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Wait until every earlier ticket whose cones conflict with `cones` has
|
|
29
|
+
* been released, then hold those cones until the returned function runs.
|
|
30
|
+
* An empty cone list conflicts with nothing and returns immediately.
|
|
31
|
+
*/
|
|
32
|
+
async acquire(cones, options = {}) {
|
|
33
|
+
if (cones.length === 0)
|
|
34
|
+
return () => { };
|
|
35
|
+
const timeoutMs = options.timeoutMs;
|
|
36
|
+
if (timeoutMs !== undefined && (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1)) {
|
|
37
|
+
throw new Error("ground-effect wait timeout must be a positive integer");
|
|
38
|
+
}
|
|
39
|
+
let release;
|
|
40
|
+
const settled = new Promise((resolveSettled) => {
|
|
41
|
+
release = resolveSettled;
|
|
42
|
+
});
|
|
43
|
+
const ticket = { cones: cones.map(normalizeCone), settled, release };
|
|
44
|
+
const predecessors = this.#queue.filter((earlier) => earlier.cones.some((held) => ticket.cones.some((wanted) => conesConflict(held, wanted))));
|
|
45
|
+
this.#queue.push(ticket);
|
|
46
|
+
let released = false;
|
|
47
|
+
const releaseOnce = () => {
|
|
48
|
+
if (released)
|
|
49
|
+
return;
|
|
50
|
+
released = true;
|
|
51
|
+
const index = this.#queue.indexOf(ticket);
|
|
52
|
+
if (index >= 0)
|
|
53
|
+
this.#queue.splice(index, 1);
|
|
54
|
+
ticket.release();
|
|
55
|
+
};
|
|
56
|
+
const wait = Promise.all(predecessors.map((earlier) => earlier.settled)).then(() => { });
|
|
57
|
+
if (timeoutMs === undefined) {
|
|
58
|
+
await wait;
|
|
59
|
+
return releaseOnce;
|
|
60
|
+
}
|
|
61
|
+
let timer = null;
|
|
62
|
+
try {
|
|
63
|
+
await Promise.race([
|
|
64
|
+
wait,
|
|
65
|
+
new Promise((_resolve, reject) => {
|
|
66
|
+
timer = setTimeout(() => reject(new Error(`ground-effect wait exceeded ${timeoutMs}ms`)), timeoutMs);
|
|
67
|
+
}),
|
|
68
|
+
]);
|
|
69
|
+
return releaseOnce;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
// A timed-out waiter never held the cones. Leave the queue now so no
|
|
73
|
+
// later effect waits on a slot that will never be used.
|
|
74
|
+
releaseOnce();
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
if (timer)
|
|
79
|
+
clearTimeout(timer);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=ground-coordination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ground-coordination.js","sourceRoot":"","sources":["../src/ground-coordination.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAazC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE;IAC7C,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CA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QAAQ,EAAE,MAAM,EAAE,EAAE;oBACtC,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CACvC,+BAA+B,SAAS,IAAI,CAC7C,CAAC,EAAE,SAAS,CAAC,CAAC;gBACjB,CAAC,CAAC;aACH,CAAC,CAAC;YACH,OAAO,WAAW,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,qEAAqE;YACrE,wDAAwD;YACxD,WAAW,EAAE,CAAC;YACd,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,IAAI,KAAK;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -92,7 +92,10 @@ export declare class UserGroundHost {
|
|
|
92
92
|
private namedDetect;
|
|
93
93
|
private coldOperation;
|
|
94
94
|
private closing;
|
|
95
|
-
|
|
95
|
+
/** Visible-ground effects coordinate by address cone: Detect passes hold
|
|
96
|
+
* the roots they observe, Apply holds its target addresses, Register and
|
|
97
|
+
* Add hold the ground they materialize. Unrelated cones never wait. */
|
|
98
|
+
private readonly ground;
|
|
96
99
|
readonly port: UserGroundPort;
|
|
97
100
|
constructor(options: UserGroundHostOptions);
|
|
98
101
|
private stage;
|
|
@@ -145,7 +148,7 @@ export declare class UserGroundHost {
|
|
|
145
148
|
/** A finite cold command may suppress Detect while it owns publication, but
|
|
146
149
|
* it may never consume a Watch generation that arrived during that window. */
|
|
147
150
|
private finishColdOperation;
|
|
148
|
-
private
|
|
151
|
+
private acquireGroundScope;
|
|
149
152
|
private syncLocalChanges;
|
|
150
153
|
private syncLocalChangesUnlocked;
|
|
151
154
|
private publishPendingSnapshotsBeforeLookup;
|