@amalgm/shell 0.1.164-main.41181871243 → 0.1.164-main.41233016817
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.
|
@@ -21,6 +21,14 @@
|
|
|
21
21
|
* a name reads nothing: the incarnation is observed off the event loop
|
|
22
22
|
* whenever persistence is required, since the directory may be mid-flush,
|
|
23
23
|
* and a flush credits only the incarnation it flushed.
|
|
24
|
+
*
|
|
25
|
+
* An incarnation is the directory object the namespace holds open, and its
|
|
26
|
+
* flushes go through that handle. A physical key alone proves nothing across
|
|
27
|
+
* observations (source-signature.ts): ext4 gives a removed directory's inode
|
|
28
|
+
* number to the next one, with the same birth time within one clock tick,
|
|
29
|
+
* and at any distance where its inodes keep no birth time. An object held
|
|
30
|
+
* open keeps its number, so while the address's key is the held object's
|
|
31
|
+
* key, the address names that object.
|
|
24
32
|
*/
|
|
25
33
|
/** What a cache writer did to one name. */
|
|
26
34
|
export type CachePublication = "published" | "reused";
|
|
@@ -21,7 +21,16 @@
|
|
|
21
21
|
* a name reads nothing: the incarnation is observed off the event loop
|
|
22
22
|
* whenever persistence is required, since the directory may be mid-flush,
|
|
23
23
|
* and a flush credits only the incarnation it flushed.
|
|
24
|
+
*
|
|
25
|
+
* An incarnation is the directory object the namespace holds open, and its
|
|
26
|
+
* flushes go through that handle. A physical key alone proves nothing across
|
|
27
|
+
* observations (source-signature.ts): ext4 gives a removed directory's inode
|
|
28
|
+
* number to the next one, with the same birth time within one clock tick,
|
|
29
|
+
* and at any distance where its inodes keep no birth time. An object held
|
|
30
|
+
* open keeps its number, so while the address's key is the held object's
|
|
31
|
+
* key, the address names that object.
|
|
24
32
|
*/
|
|
33
|
+
import { constants } from "node:fs";
|
|
25
34
|
import { lstat, open } from "node:fs/promises";
|
|
26
35
|
import { channel } from "node:diagnostics_channel";
|
|
27
36
|
import { dirname } from "node:path";
|
|
@@ -102,24 +111,35 @@ class CacheNamespace {
|
|
|
102
111
|
* unavailable one holds none at all; null when it is unavailable. */
|
|
103
112
|
async #observeIncarnation() {
|
|
104
113
|
const stats = await lstat(this.#directory, { bigint: true }).catch(() => undefined);
|
|
105
|
-
const physical = stats ? physicalKey(stats) : null;
|
|
106
114
|
const current = this.#incarnation;
|
|
107
|
-
if (current &&
|
|
115
|
+
if (current && stats && physicalKey(stats) === current.physical)
|
|
108
116
|
return current;
|
|
109
|
-
|
|
117
|
+
const held = stats ? await holdDirectory(this.#directory) : null;
|
|
118
|
+
// Another observation may have taken hold of this same object meanwhile.
|
|
119
|
+
if (held && this.#incarnation?.physical === held.physical) {
|
|
120
|
+
void held.handle.close().catch(() => undefined);
|
|
121
|
+
return this.#incarnation;
|
|
122
|
+
}
|
|
123
|
+
// A flush still running through the replaced handle finishes first, and
|
|
124
|
+
// a handle let go owes nothing.
|
|
125
|
+
void this.#incarnation?.handle.close().catch(() => undefined);
|
|
126
|
+
this.#incarnation = held;
|
|
110
127
|
this.#flushedThrough = 0;
|
|
111
128
|
this.#entry = false;
|
|
112
|
-
return
|
|
129
|
+
return held;
|
|
113
130
|
}
|
|
114
131
|
/** Flush the incarnation just observed; credit only while it is current. */
|
|
115
132
|
async #flush(incarnation) {
|
|
116
133
|
const target = this.#published;
|
|
117
134
|
const entry = !this.#entry;
|
|
118
135
|
const done = (async () => {
|
|
119
|
-
|
|
120
|
-
if (
|
|
136
|
+
// Replaced since it was observed, its handle may be closed: observe again.
|
|
137
|
+
if (this.#incarnation !== incarnation)
|
|
138
|
+
return;
|
|
139
|
+
await incarnation.handle.sync();
|
|
140
|
+
if (entry)
|
|
121
141
|
await flushDirectoryAsync(dirname(this.#directory));
|
|
122
|
-
if (
|
|
142
|
+
if (this.#incarnation !== incarnation)
|
|
123
143
|
return;
|
|
124
144
|
this.#flushedThrough = Math.max(this.#flushedThrough, target);
|
|
125
145
|
if (entry)
|
|
@@ -135,17 +155,19 @@ class CacheNamespace {
|
|
|
135
155
|
}
|
|
136
156
|
}
|
|
137
157
|
}
|
|
138
|
-
/**
|
|
139
|
-
|
|
140
|
-
|
|
158
|
+
/** Hold the directory standing at the address, never one a link names; null
|
|
159
|
+
* when none stands there. */
|
|
160
|
+
async function holdDirectory(directory) {
|
|
161
|
+
const handle = await open(directory, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW)
|
|
162
|
+
.catch(() => undefined);
|
|
163
|
+
if (!handle)
|
|
164
|
+
return null;
|
|
141
165
|
try {
|
|
142
|
-
|
|
143
|
-
return false;
|
|
144
|
-
await handle.sync();
|
|
145
|
-
return true;
|
|
166
|
+
return { physical: physicalKey(await handle.stat({ bigint: true })), handle };
|
|
146
167
|
}
|
|
147
|
-
|
|
168
|
+
catch (error) {
|
|
148
169
|
await handle.close();
|
|
170
|
+
throw error;
|
|
149
171
|
}
|
|
150
172
|
}
|
|
151
173
|
async function flushDirectoryAsync(directory) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-cache-namespace.js","sourceRoot":"","sources":["../src/content-cache-namespace.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"content-cache-namespace.js","sourceRoot":"","sources":["../src/content-cache-namespace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAmB,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAYpD,MAAM,OAAO,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAEpD,MAAM,cAAc;IACT,UAAU,CAAS;IACnB,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;IAClD,YAAY,GAAuB,IAAI,CAAC;IACxC,UAAU,GAAG,CA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D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAC1C,IAAI,CAAC;QAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IAAC,CAAC;YAAS,CAAC;QAAC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,GAAG,IAAI,GAAG,EAA0B,CAAC;AAErD,iEAAiE;AACjE,MAAM,UAAU,cAAc,CAAC,SAAiB;IAC9C,IAAI,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC1C,IAAI,CAAC,SAAS;QAAE,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC;IACrF,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amalgm/shell",
|
|
3
|
-
"version": "0.1.164-main.
|
|
3
|
+
"version": "0.1.164-main.41233016817",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@amalgm/shell",
|
|
9
|
-
"version": "0.1.164-main.
|
|
9
|
+
"version": "0.1.164-main.41233016817",
|
|
10
10
|
"license": "UNLICENSED",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@amalgm/agents": "0.2.3-main.39177470159",
|
|
@@ -1549,9 +1549,9 @@
|
|
|
1549
1549
|
}
|
|
1550
1550
|
},
|
|
1551
1551
|
"node_modules/cron-parser": {
|
|
1552
|
-
"version": "5.10.
|
|
1553
|
-
"resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-5.10.
|
|
1554
|
-
"integrity": "sha512-
|
|
1552
|
+
"version": "5.10.3",
|
|
1553
|
+
"resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-5.10.3.tgz",
|
|
1554
|
+
"integrity": "sha512-Fwlmlgiyoj5e7XDCy5T3ueFd3imgt714k7xjAzhkOBUrUgQxWtsjS7kWSEN3efDX34bebxBJAmPoCSisHvjlpw==",
|
|
1555
1555
|
"license": "MIT",
|
|
1556
1556
|
"dependencies": {
|
|
1557
1557
|
"luxon": "^3.7.2"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amalgm/shell",
|
|
3
|
-
"version": "0.1.164-main.
|
|
3
|
+
"version": "0.1.164-main.41233016817",
|
|
4
4
|
"description": "The Amalgm runtime host assembled from the published @amalgm SDK capabilities.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -168,11 +168,11 @@
|
|
|
168
168
|
}
|
|
169
169
|
]
|
|
170
170
|
},
|
|
171
|
-
"gitHead": "
|
|
171
|
+
"gitHead": "115d9380fc78be597fc16307d86cb024b48e5d7b",
|
|
172
172
|
"amalgmSource": {
|
|
173
173
|
"repository": "amalgm-inc/amalgm-shell",
|
|
174
174
|
"branch": "main",
|
|
175
|
-
"commit": "
|
|
176
|
-
"occurrence": "
|
|
175
|
+
"commit": "115d9380fc78be597fc16307d86cb024b48e5d7b",
|
|
176
|
+
"occurrence": "41233016817"
|
|
177
177
|
}
|
|
178
178
|
}
|