@timurproko/a1 0.1.8-dev.277 → 0.1.8-dev.282
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/foundation/supervision/server.d.ts +11 -0
- package/dist/foundation/supervision/server.js +38 -5
- package/dist/native/darwin-arm64/manifest.json +1 -1
- package/dist/native/linux-x64/manifest.json +1 -1
- package/dist/native/win32-x64/manifest.json +2 -2
- package/dist/native/win32-x64/process-guardian.exe +0 -0
- package/package.json +1 -1
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
import { rename, rm, writeFile } from "node:fs/promises";
|
|
1
2
|
import { type SupervisorSnapshot } from "../lifecycle/index.js";
|
|
2
3
|
import { type MaterializedRelease } from "../release/index.js";
|
|
3
4
|
import { ControlStore } from "../storage/index.js";
|
|
4
5
|
import { type ProductPaths } from "./paths.js";
|
|
6
|
+
interface EndpointMetadataCommitOperations {
|
|
7
|
+
readonly platform?: NodeJS.Platform;
|
|
8
|
+
readonly write?: typeof writeFile;
|
|
9
|
+
readonly replace?: typeof rename;
|
|
10
|
+
readonly remove?: typeof rm;
|
|
11
|
+
readonly wait?: (delayMs: number) => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/** Atomically replaces endpoint metadata while tolerating bounded Windows reader sharing. */
|
|
14
|
+
export declare function commitEndpointMetadata(path: string, source: string, operations?: EndpointMetadataCommitOperations): Promise<void>;
|
|
5
15
|
/** Owns one release-cohort endpoint and the authenticated launch instances registered through it. */
|
|
6
16
|
export declare class SupervisorServer {
|
|
7
17
|
#private;
|
|
@@ -38,3 +48,4 @@ export declare class SupervisorServer {
|
|
|
38
48
|
close(stopAgents?: boolean): Promise<void>;
|
|
39
49
|
closeForReleaseReplacement(stopAgents: boolean): Promise<void>;
|
|
40
50
|
}
|
|
51
|
+
export {};
|
|
@@ -9,6 +9,36 @@ import { processIsAlive } from "../release/index.js";
|
|
|
9
9
|
import { ControlStore } from "../storage/index.js";
|
|
10
10
|
import { resolveProductPaths } from "./paths.js";
|
|
11
11
|
import { PRODUCT_IDENTITY, PRODUCT_TEXT } from "../../product-identity.js";
|
|
12
|
+
const WINDOWS_METADATA_REPLACE_RETRY_DELAYS_MS = [5, 10, 20, 40, 80, 160];
|
|
13
|
+
/** Atomically replaces endpoint metadata while tolerating bounded Windows reader sharing. */
|
|
14
|
+
export async function commitEndpointMetadata(path, source, operations = {}) {
|
|
15
|
+
const temporary = `${path}.${process.pid}.tmp`;
|
|
16
|
+
const write = operations.write ?? writeFile;
|
|
17
|
+
const replace = operations.replace ?? rename;
|
|
18
|
+
const remove = operations.remove ?? rm;
|
|
19
|
+
const wait = operations.wait ?? (delayMs => new Promise(resolvePromise => setTimeout(resolvePromise, delayMs)));
|
|
20
|
+
let committed = false;
|
|
21
|
+
try {
|
|
22
|
+
await write(temporary, source, { mode: 0o600 });
|
|
23
|
+
for (let attempt = 0;; attempt += 1) {
|
|
24
|
+
try {
|
|
25
|
+
await replace(temporary, path);
|
|
26
|
+
committed = true;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const delayMs = WINDOWS_METADATA_REPLACE_RETRY_DELAYS_MS[attempt];
|
|
31
|
+
if ((operations.platform ?? platform()) !== "win32" || delayMs === undefined || !isWindowsSharingViolation(error))
|
|
32
|
+
throw error;
|
|
33
|
+
await wait(delayMs);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
if (!committed)
|
|
39
|
+
await remove(temporary, { force: true }).catch(() => undefined);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
12
42
|
/** Owns one release-cohort endpoint and the authenticated launch instances registered through it. */
|
|
13
43
|
export class SupervisorServer {
|
|
14
44
|
store;
|
|
@@ -464,11 +494,10 @@ export class SupervisorServer {
|
|
|
464
494
|
uncertainInstanceIds: [...this.#uncertainInstances],
|
|
465
495
|
},
|
|
466
496
|
};
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
});
|
|
497
|
+
const commit = () => commitEndpointMetadata(this.paths.endpointMetadataPath, JSON.stringify(metadata, null, 2));
|
|
498
|
+
// Platform: one exhausted filesystem replacement must fail its command, but it must not
|
|
499
|
+
// poison every later ownership revision after the sharing condition has cleared.
|
|
500
|
+
this.#metadataWrites = this.#metadataWrites.then(commit, commit);
|
|
472
501
|
return this.#metadataWrites;
|
|
473
502
|
}
|
|
474
503
|
#send(socket, message) {
|
|
@@ -492,6 +521,10 @@ function sameContainmentIdentity(left, right) {
|
|
|
492
521
|
function isMessageType(value, type) {
|
|
493
522
|
return typeof value === "object" && value !== null && "type" in value && value.type === type;
|
|
494
523
|
}
|
|
524
|
+
function isWindowsSharingViolation(error) {
|
|
525
|
+
return error instanceof Error && "code" in error
|
|
526
|
+
&& (error.code === "EPERM" || error.code === "EACCES" || error.code === "EBUSY");
|
|
527
|
+
}
|
|
495
528
|
async function ensureManagedEndpointDirectory(path) {
|
|
496
529
|
await mkdir(path, { recursive: true, mode: 0o700 });
|
|
497
530
|
const metadata = await lstat(path);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"platform": "darwin",
|
|
6
6
|
"architecture": "arm64",
|
|
7
7
|
"capability": "supported",
|
|
8
|
-
"builtAt": "2026-09-
|
|
8
|
+
"builtAt": "2026-09-08T08:10:40.090Z",
|
|
9
9
|
"artifact": {
|
|
10
10
|
"filename": "process-guardian",
|
|
11
11
|
"sha256": "dc03605e5780e2aeebb4ecafd62868dc673e22ddd38b024a369aff704ff136dc",
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"platform": "linux",
|
|
6
6
|
"architecture": "x64",
|
|
7
7
|
"capability": "supported",
|
|
8
|
-
"builtAt": "2026-09-
|
|
8
|
+
"builtAt": "2026-09-08T08:10:24.232Z",
|
|
9
9
|
"artifact": {
|
|
10
10
|
"filename": "process-guardian",
|
|
11
11
|
"sha256": "ee8a00eaaf79c707459bbbfb52518e9739314967049fbe5fa625f36ce33db9ee",
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
"platform": "win32",
|
|
6
6
|
"architecture": "x64",
|
|
7
7
|
"capability": "supported",
|
|
8
|
-
"builtAt": "2026-09-
|
|
8
|
+
"builtAt": "2026-09-08T08:11:13.440Z",
|
|
9
9
|
"artifact": {
|
|
10
10
|
"filename": "process-guardian.exe",
|
|
11
|
-
"sha256": "
|
|
11
|
+
"sha256": "b6daac4921fa900e544d9db45f85177267934415ecdf2935c2d6d1ae8bc59b0a",
|
|
12
12
|
"size": 177664
|
|
13
13
|
},
|
|
14
14
|
"provenance": {
|
|
Binary file
|