agl 43.0.3 → 43.0.5
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/changelog.md +18 -0
- package/dist_serve/bundle.js +1 -1
- package/dist_serve/bundle.js.map +1 -1
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.flexframedtransport.d.ts +16 -0
- package/dist_ts/classes.flexframedtransport.js +35 -20
- package/dist_ts/classes.flexservice.d.ts +7 -2
- package/dist_ts/classes.flexservice.js +11 -40
- package/dist_ts/classes.flexstore.js +4 -1
- package/dist_ts/classes.flexsupervisor.d.ts +47 -3
- package/dist_ts/classes.flexsupervisor.js +179 -32
- package/dist_ts/flexharness.child.js +9 -4
- package/dist_ts/functions.flexchildshutdown.d.ts +7 -0
- package/dist_ts/functions.flexchildshutdown.js +18 -1
- package/dist_ts_migration/index.d.ts +1 -2
- package/dist_ts_migration/index.js +2 -3
- package/dist_ts_migration/v43_flexpostharnessmigrationmarkers.d.ts +33 -0
- package/dist_ts_migration/v43_flexpostharnessmigrationmarkers.js +116 -0
- package/package.json +1 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.flexframedtransport.ts +42 -17
- package/ts/classes.flexservice.ts +9 -56
- package/ts/classes.flexstore.ts +6 -0
- package/ts/classes.flexsupervisor.ts +236 -32
- package/ts/flexharness.child.ts +8 -3
- package/ts/functions.flexchildshutdown.ts +22 -0
- package/ts_migration/index.ts +1 -2
- package/ts_migration/v43_flexpostharnessmigrationmarkers.ts +66 -0
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/dist_ts_migration/classes.flexpostharnessmigrationrunner.d.ts +0 -10
- package/dist_ts_migration/classes.flexpostharnessmigrationrunner.js +0 -15
- package/dist_ts_migration/v19_flexprojectmanagement.d.ts +0 -11
- package/dist_ts_migration/v19_flexprojectmanagement.js +0 -21
- package/ts_migration/classes.flexpostharnessmigrationrunner.ts +0 -22
- package/ts_migration/v19_flexprojectmanagement.ts +0 -28
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as plugins from './plugins.js';
|
|
2
2
|
import { FlexFramedTransport } from './classes.flexframedtransport.js';
|
|
3
3
|
import { FlexService } from './classes.flexservice.js';
|
|
4
|
-
import { createFlexChildShutdown } from './functions.flexchildshutdown.js';
|
|
4
|
+
import { createFlexChildShutdown, formatFlexChildFault } from './functions.flexchildshutdown.js';
|
|
5
5
|
import { flexIpcDisposeTimeoutMs, parseFlexChildMessage, parseFlexParentMessage, } from './interfaces.flexipc.js';
|
|
6
6
|
const readable = plugins.fs.createReadStream('', { fd: 3, autoClose: true });
|
|
7
7
|
const writable = plugins.fs.createWriteStream('', { fd: 4, autoClose: true });
|
|
@@ -30,12 +30,17 @@ service = new FlexService({
|
|
|
30
30
|
});
|
|
31
31
|
process.once('SIGTERM', () => shutdown(false));
|
|
32
32
|
process.once('SIGINT', () => shutdown(false));
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
// A fault nothing else handled is written to stderr, which the supervisor logs, before the shutdown.
|
|
34
|
+
const handleFault = (kindArg) => (errorArg) => {
|
|
35
|
+
process.stderr.write(formatFlexChildFault(kindArg, errorArg));
|
|
36
|
+
shutdown(true);
|
|
37
|
+
};
|
|
38
|
+
process.once('uncaughtException', handleFault('uncaught exception'));
|
|
39
|
+
process.once('unhandledRejection', handleFault('unhandled rejection'));
|
|
35
40
|
try {
|
|
36
41
|
await service.start();
|
|
37
42
|
}
|
|
38
43
|
catch {
|
|
39
44
|
shutdown(true);
|
|
40
45
|
}
|
|
41
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
46
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmxleGhhcm5lc3MuY2hpbGQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9mbGV4aGFybmVzcy5jaGlsZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtB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FBQyxDQUFDO0lBQzlELFFBQVEsQ0FBQyxJQUFJLENBQUMsQ0FBQztBQUNqQixDQUFDLENBQUM7QUFDRixPQUFPLENBQUMsSUFBSSxDQUFDLG1CQUFtQixFQUFFLFdBQVcsQ0FBQyxvQkFBb0IsQ0FBQyxDQUFDLENBQUM7QUFDckUsT0FBTyxDQUFDLElBQUksQ0FBQyxvQkFBb0IsRUFBRSxXQUFXLENBQUMscUJBQXFCLENBQUMsQ0FBQyxDQUFDO0FBRXZFLElBQUksQ0FBQztJQUNILE1BQU0sT0FBTyxDQUFDLEtBQUssRUFBRSxDQUFDO0FBQ3hCLENBQUM7QUFBQyxNQUFNLENBQUM7SUFDUCxRQUFRLENBQUMsSUFBSSxDQUFDLENBQUM7QUFDakIsQ0FBQyJ9
|
|
@@ -7,3 +7,10 @@ export interface IFlexChildShutdownOptions {
|
|
|
7
7
|
timeoutMs: number;
|
|
8
8
|
}
|
|
9
9
|
export declare const createFlexChildShutdown: (optionsArg: IFlexChildShutdownOptions) => ((fatalArg: boolean) => void);
|
|
10
|
+
/**
|
|
11
|
+
* What the Flex child writes to its stderr for a fault nothing else handled, before it shuts down
|
|
12
|
+
* with exit code 1: the error's name and message, its causes included, then its stack, one line
|
|
13
|
+
* each. The supervisor writes every stderr line to the controller log with credentials hidden. A
|
|
14
|
+
* thrown value that is not an Error is named by its type and inspected shallowly.
|
|
15
|
+
*/
|
|
16
|
+
export declare const formatFlexChildFault: (kindArg: 'uncaught exception' | 'unhandled rejection', errorArg: unknown) => string;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import { describeFailure } from './functions.failuredescription.js';
|
|
1
3
|
export const createFlexChildShutdown = (optionsArg) => {
|
|
2
4
|
let shutdownTask;
|
|
3
5
|
let watchdog;
|
|
@@ -43,4 +45,19 @@ export const createFlexChildShutdown = (optionsArg) => {
|
|
|
43
45
|
});
|
|
44
46
|
};
|
|
45
47
|
};
|
|
46
|
-
|
|
48
|
+
/**
|
|
49
|
+
* What the Flex child writes to its stderr for a fault nothing else handled, before it shuts down
|
|
50
|
+
* with exit code 1: the error's name and message, its causes included, then its stack, one line
|
|
51
|
+
* each. The supervisor writes every stderr line to the controller log with credentials hidden. A
|
|
52
|
+
* thrown value that is not an Error is named by its type and inspected shallowly.
|
|
53
|
+
*/
|
|
54
|
+
export const formatFlexChildFault = (kindArg, errorArg) => {
|
|
55
|
+
if (!(errorArg instanceof Error)) {
|
|
56
|
+
const value = plugins.util.inspect(errorArg, { depth: 1, breakLength: Infinity });
|
|
57
|
+
return `Flex child ${kindArg}: a thrown ${typeof errorArg} that is not an Error: ${value}\n`;
|
|
58
|
+
}
|
|
59
|
+
const failure = describeFailure(errorArg);
|
|
60
|
+
const stack = typeof errorArg.stack === 'string' ? errorArg.stack : '';
|
|
61
|
+
return `Flex child ${kindArg}: ${failure.name}: ${failure.message}\n${stack ? `${stack}\n` : ''}`;
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnVuY3Rpb25zLmZsZXhjaGlsZHNodXRkb3duLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHMvZnVuY3Rpb25zLmZsZXhjaGlsZHNodXRkb3duLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sY0FBYyxDQUFDO0FBQ3hDLE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQVdwRSxNQUFNLENBQUMsTUFBTSx1QkFBdUIsR0FBRyxDQUNyQyxVQUFxQyxFQUNOLEVBQUU7SUFDakMsSUFBSSxZQUF1QyxDQUFDO0lBQzVDLElBQUksUUFBbUQsQ0FBQztJQUN4RCxJQUFJLGlCQUFpQixHQUFHLEtBQUssQ0FBQztJQUM5QixNQUFNLGdCQUFnQixHQUFHLEdBQV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xFQUFFLEVBQUUsQ0FBQztBQUNwRyxDQUFDLENBQUMifQ==
|
|
@@ -3,8 +3,6 @@ export * from './v10_flexharnessv3migration.js';
|
|
|
3
3
|
export * from './v16_flexprovidercredentials.js';
|
|
4
4
|
export * from './v18_resourcelayout.js';
|
|
5
5
|
export * from './v18_resourcelayoutmigration.js';
|
|
6
|
-
export * from './classes.flexpostharnessmigrationrunner.js';
|
|
7
|
-
export * from './v19_flexprojectmanagement.js';
|
|
8
6
|
export * from './v22_projectfilesystemidentitymigration.js';
|
|
9
7
|
export * from './v23_runtimeconfig.js';
|
|
10
8
|
export * from './v24_legacyterminallayout.js';
|
|
@@ -30,3 +28,4 @@ export * from './v39_flexpublicheadpointers.js';
|
|
|
30
28
|
export * from './v41_ticketmigrationmarkers.js';
|
|
31
29
|
export * from './v41_ticketclosedcolumn.js';
|
|
32
30
|
export * from './v41_ticketlinkrepos.js';
|
|
31
|
+
export * from './v43_flexpostharnessmigrationmarkers.js';
|
|
@@ -3,8 +3,6 @@ export * from './v10_flexharnessv3migration.js';
|
|
|
3
3
|
export * from './v16_flexprovidercredentials.js';
|
|
4
4
|
export * from './v18_resourcelayout.js';
|
|
5
5
|
export * from './v18_resourcelayoutmigration.js';
|
|
6
|
-
export * from './classes.flexpostharnessmigrationrunner.js';
|
|
7
|
-
export * from './v19_flexprojectmanagement.js';
|
|
8
6
|
export * from './v22_projectfilesystemidentitymigration.js';
|
|
9
7
|
export * from './v23_runtimeconfig.js';
|
|
10
8
|
export * from './v24_legacyterminallayout.js';
|
|
@@ -30,4 +28,5 @@ export * from './v39_flexpublicheadpointers.js';
|
|
|
30
28
|
export * from './v41_ticketmigrationmarkers.js';
|
|
31
29
|
export * from './v41_ticketclosedcolumn.js';
|
|
32
30
|
export * from './v41_ticketlinkrepos.js';
|
|
33
|
-
|
|
31
|
+
export * from './v43_flexpostharnessmigrationmarkers.js';
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaW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FDekMsY0FBYywwQ0FBMEMsQ0FBQyJ9
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
/** The one migration AGL 43.0.4 recorded markers for: its per-session project-management walk. */
|
|
3
|
+
export type TFlexPostHarnessMigrationId = 'v19_flexprojectmanagement';
|
|
4
|
+
/** One post-harness migration that completed for one storage key (a Flex project). */
|
|
5
|
+
export interface IFlexPostHarnessMigrationMarkerDocument {
|
|
6
|
+
/** `flexPostHarnessMigrationMarkerId(controllerId, storageKey, migration)`. */
|
|
7
|
+
id: string;
|
|
8
|
+
controllerId: string;
|
|
9
|
+
storageKey: string;
|
|
10
|
+
/** The migration's name, such as `v19_flexprojectmanagement`. */
|
|
11
|
+
migration: string;
|
|
12
|
+
completedAt: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const flexPostHarnessMigrationMarkerId: (controllerIdArg: string, storageKeyArg: string, migrationArg: TFlexPostHarnessMigrationId) => string;
|
|
15
|
+
/**
|
|
16
|
+
* One record per storage key whose v19 project-management walk AGL 43.0.4 completed. Nothing
|
|
17
|
+
* reads or writes them since registration stopped walking sessions: each session's state is
|
|
18
|
+
* read, and a legacy scratchpad copied into it, when it is first loaded. The model stays
|
|
19
|
+
* registered and prepared, so the Flex store prepares what 43.0.4 prepared, and the documents
|
|
20
|
+
* stay where 43.0.4 reads them.
|
|
21
|
+
*/
|
|
22
|
+
export declare class FlexPostHarnessMigrationMarkerModel extends plugins.nosqldb.SmartDataDbDoc<FlexPostHarnessMigrationMarkerModel, IFlexPostHarnessMigrationMarkerDocument> {
|
|
23
|
+
static exact: plugins.nosqldb.TExact<FlexPostHarnessMigrationMarkerModel>;
|
|
24
|
+
id: string;
|
|
25
|
+
controllerId: string;
|
|
26
|
+
storageKey: string;
|
|
27
|
+
migration: string;
|
|
28
|
+
completedAt: string;
|
|
29
|
+
}
|
|
30
|
+
export declare const registerFlexPostHarnessMigrationMarkerModel: (managerArg: {
|
|
31
|
+
db: plugins.nosqldb.SmartdataDb;
|
|
32
|
+
}) => void;
|
|
33
|
+
export declare const initFlexPostHarnessMigrationMarkerModel: () => Promise<void>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
34
|
+
};
|
|
35
|
+
import * as plugins from './plugins.js';
|
|
36
|
+
const markerSchema = plugins.z.object({
|
|
37
|
+
id: plugins.z.string().regex(/^flex-post-harness-migration:[0-9a-f]{64}$/u),
|
|
38
|
+
controllerId: plugins.z.string().min(1).max(512),
|
|
39
|
+
storageKey: plugins.z.string().min(1).max(512),
|
|
40
|
+
migration: plugins.z.string().regex(/^v[0-9]+_[a-z0-9]+$/u),
|
|
41
|
+
completedAt: plugins.z.iso.datetime(),
|
|
42
|
+
}).strict();
|
|
43
|
+
export const flexPostHarnessMigrationMarkerId = (controllerIdArg, storageKeyArg, migrationArg) => `flex-post-harness-migration:${plugins.crypto.createHash('sha256')
|
|
44
|
+
.update(controllerIdArg, 'utf8')
|
|
45
|
+
.update('\0', 'utf8')
|
|
46
|
+
.update(storageKeyArg, 'utf8')
|
|
47
|
+
.update('\0', 'utf8')
|
|
48
|
+
.update(migrationArg, 'utf8')
|
|
49
|
+
.digest('hex')}`;
|
|
50
|
+
/**
|
|
51
|
+
* One record per storage key whose v19 project-management walk AGL 43.0.4 completed. Nothing
|
|
52
|
+
* reads or writes them since registration stopped walking sessions: each session's state is
|
|
53
|
+
* read, and a legacy scratchpad copied into it, when it is first loaded. The model stays
|
|
54
|
+
* registered and prepared, so the Flex store prepares what 43.0.4 prepared, and the documents
|
|
55
|
+
* stay where 43.0.4 reads them.
|
|
56
|
+
*/
|
|
57
|
+
let FlexPostHarnessMigrationMarkerModel = (() => {
|
|
58
|
+
let _classDecorators = [plugins.nosqldb.managed({ collectionName: 'flex_post_harness_migrations' }), plugins.nosqldb.exactPersistence({ assertDocument: (input) => { markerSchema.parse(input); } })];
|
|
59
|
+
let _classDescriptor;
|
|
60
|
+
let _classExtraInitializers = [];
|
|
61
|
+
let _classThis;
|
|
62
|
+
let _classSuper = plugins.nosqldb.SmartDataDbDoc;
|
|
63
|
+
let _id_decorators;
|
|
64
|
+
let _id_initializers = [];
|
|
65
|
+
let _id_extraInitializers = [];
|
|
66
|
+
let _controllerId_decorators;
|
|
67
|
+
let _controllerId_initializers = [];
|
|
68
|
+
let _controllerId_extraInitializers = [];
|
|
69
|
+
let _storageKey_decorators;
|
|
70
|
+
let _storageKey_initializers = [];
|
|
71
|
+
let _storageKey_extraInitializers = [];
|
|
72
|
+
let _migration_decorators;
|
|
73
|
+
let _migration_initializers = [];
|
|
74
|
+
let _migration_extraInitializers = [];
|
|
75
|
+
let _completedAt_decorators;
|
|
76
|
+
let _completedAt_initializers = [];
|
|
77
|
+
let _completedAt_extraInitializers = [];
|
|
78
|
+
var FlexPostHarnessMigrationMarkerModel = class extends _classSuper {
|
|
79
|
+
static { _classThis = this; }
|
|
80
|
+
static {
|
|
81
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
82
|
+
_id_decorators = [plugins.nosqldb.unI()];
|
|
83
|
+
_controllerId_decorators = [plugins.nosqldb.svDb()];
|
|
84
|
+
_storageKey_decorators = [plugins.nosqldb.svDb()];
|
|
85
|
+
_migration_decorators = [plugins.nosqldb.svDb()];
|
|
86
|
+
_completedAt_decorators = [plugins.nosqldb.svDb()];
|
|
87
|
+
__esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
|
|
88
|
+
__esDecorate(null, null, _controllerId_decorators, { kind: "field", name: "controllerId", static: false, private: false, access: { has: obj => "controllerId" in obj, get: obj => obj.controllerId, set: (obj, value) => { obj.controllerId = value; } }, metadata: _metadata }, _controllerId_initializers, _controllerId_extraInitializers);
|
|
89
|
+
__esDecorate(null, null, _storageKey_decorators, { kind: "field", name: "storageKey", static: false, private: false, access: { has: obj => "storageKey" in obj, get: obj => obj.storageKey, set: (obj, value) => { obj.storageKey = value; } }, metadata: _metadata }, _storageKey_initializers, _storageKey_extraInitializers);
|
|
90
|
+
__esDecorate(null, null, _migration_decorators, { kind: "field", name: "migration", static: false, private: false, access: { has: obj => "migration" in obj, get: obj => obj.migration, set: (obj, value) => { obj.migration = value; } }, metadata: _metadata }, _migration_initializers, _migration_extraInitializers);
|
|
91
|
+
__esDecorate(null, null, _completedAt_decorators, { kind: "field", name: "completedAt", static: false, private: false, access: { has: obj => "completedAt" in obj, get: obj => obj.completedAt, set: (obj, value) => { obj.completedAt = value; } }, metadata: _metadata }, _completedAt_initializers, _completedAt_extraInitializers);
|
|
92
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
93
|
+
FlexPostHarnessMigrationMarkerModel = _classThis = _classDescriptor.value;
|
|
94
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
95
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
96
|
+
}
|
|
97
|
+
id = __runInitializers(this, _id_initializers, void 0);
|
|
98
|
+
controllerId = (__runInitializers(this, _id_extraInitializers), __runInitializers(this, _controllerId_initializers, void 0));
|
|
99
|
+
storageKey = (__runInitializers(this, _controllerId_extraInitializers), __runInitializers(this, _storageKey_initializers, void 0));
|
|
100
|
+
migration = (__runInitializers(this, _storageKey_extraInitializers), __runInitializers(this, _migration_initializers, void 0));
|
|
101
|
+
completedAt = (__runInitializers(this, _migration_extraInitializers), __runInitializers(this, _completedAt_initializers, void 0));
|
|
102
|
+
constructor() {
|
|
103
|
+
super(...arguments);
|
|
104
|
+
__runInitializers(this, _completedAt_extraInitializers);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
return FlexPostHarnessMigrationMarkerModel = _classThis;
|
|
108
|
+
})();
|
|
109
|
+
export { FlexPostHarnessMigrationMarkerModel };
|
|
110
|
+
export const registerFlexPostHarnessMigrationMarkerModel = (managerArg) => {
|
|
111
|
+
plugins.nosqldb.setDefaultManagerForDoc(managerArg, FlexPostHarnessMigrationMarkerModel);
|
|
112
|
+
};
|
|
113
|
+
export const initFlexPostHarnessMigrationMarkerModel = async () => {
|
|
114
|
+
await FlexPostHarnessMigrationMarkerModel.exact.prepare();
|
|
115
|
+
};
|
|
116
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidjQzX2ZsZXhwb3N0aGFybmVzc21pZ3JhdGlvbm1hcmtlcnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90c19taWdyYXRpb24vdjQzX2ZsZXhwb3N0aGFybmVzc21pZ3JhdGlvbm1hcmtlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sY0FBYyxDQUFDO0FBZ0J4QyxNQUFNLFlBQVksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLE1BQU0sQ0FBQztJQUNwQyxFQUFFLEVBQUUsT0FBTyxDQUFDLENBQUMsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxLQUFLLENBQUMsNkNBQTZDLENBQUM7SUFDM0UsWUFBWSxFQUFFLE9BQU8sQ0FBQyxDQUFDLENBQUMsTUFBTSxFQUFFLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUM7SUFDaEQsVUFBVSxFQUFFLE9BQU8sQ0FBQyxDQUFDLENBQUMsTUFBTSxFQUFFLENBQUMsR0FBRyxD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FFLENBQUM7QUFDNUQsQ0FBQyxDQUFDIn0=
|
package/package.json
CHANGED
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -16,6 +16,14 @@ type TCloseListener = () => void;
|
|
|
16
16
|
export const flexIpcMaximumQueuedFrames = 128;
|
|
17
17
|
export const flexIpcMaximumQueuedFrameBytes = 64 * 1024 * 1024;
|
|
18
18
|
const flexIpcCloseDrainTimeoutMs = 2_000;
|
|
19
|
+
const flexIpcMaximumIgnoredStreamErrors = 16;
|
|
20
|
+
|
|
21
|
+
/** A stream error that reached the transport after it closed or failed: recorded, never acted on. */
|
|
22
|
+
export interface IFlexIgnoredStreamError {
|
|
23
|
+
stream: 'readable' | 'writable';
|
|
24
|
+
code?: string;
|
|
25
|
+
timestamp: number;
|
|
26
|
+
}
|
|
19
27
|
|
|
20
28
|
const normalizeMaximumFrameBytes = (valueArg: number | undefined): number => {
|
|
21
29
|
const selected = valueArg ?? flexIpcMaximumFrameBytes;
|
|
@@ -90,6 +98,11 @@ export const encodeFlexFrame = (
|
|
|
90
98
|
/**
|
|
91
99
|
* A single-reader/single-writer JSON transport. The body buffer is allocated
|
|
92
100
|
* only after the fixed header has passed the configured length limit.
|
|
101
|
+
*
|
|
102
|
+
* Each stream keeps an 'error' listener from construction for as long as it exists: an 'error' event
|
|
103
|
+
* without a listener throws, and a stream outlives the transport's close (a pipe socket keeps reading
|
|
104
|
+
* until its peer is gone, and a peer killed with unread frames resets it). Before close or failure
|
|
105
|
+
* a stream error fails the transport; after it, the listener records the error and ignores it.
|
|
93
106
|
*/
|
|
94
107
|
export class FlexFramedTransport<TIncoming, TOutgoing> {
|
|
95
108
|
private readonly readable: plugins.stream.Readable;
|
|
@@ -110,6 +123,7 @@ export class FlexFramedTransport<TIncoming, TOutgoing> {
|
|
|
110
123
|
private failed = false;
|
|
111
124
|
private closed = false;
|
|
112
125
|
private closePromise?: Promise<void>;
|
|
126
|
+
private readonly ignoredStreamErrors: IFlexIgnoredStreamError[] = [];
|
|
113
127
|
|
|
114
128
|
constructor(optionsArg: IFlexFramedTransportOptions<TIncoming, TOutgoing>) {
|
|
115
129
|
this.readable = optionsArg.readable;
|
|
@@ -118,10 +132,10 @@ export class FlexFramedTransport<TIncoming, TOutgoing> {
|
|
|
118
132
|
this.validateOutgoing = optionsArg.validateOutgoing;
|
|
119
133
|
this.maximumFrameBytes = normalizeMaximumFrameBytes(optionsArg.maximumFrameBytes);
|
|
120
134
|
this.readable.on('data', this.onData);
|
|
121
|
-
this.readable.
|
|
135
|
+
this.readable.on('error', this.onReadError);
|
|
122
136
|
this.readable.once('end', this.onReadableClosed);
|
|
123
137
|
this.readable.once('close', this.onReadableClosed);
|
|
124
|
-
this.writable.
|
|
138
|
+
this.writable.on('error', this.onWriteError);
|
|
125
139
|
this.writable.once('finish', this.onWritableClosed);
|
|
126
140
|
this.writable.once('close', this.onWritableClosed);
|
|
127
141
|
}
|
|
@@ -141,6 +155,11 @@ export class FlexFramedTransport<TIncoming, TOutgoing> {
|
|
|
141
155
|
return () => this.closeListeners.delete(listenerArg);
|
|
142
156
|
}
|
|
143
157
|
|
|
158
|
+
/** The stream errors that arrived after the transport closed or failed, oldest first, the last 16. */
|
|
159
|
+
public getIgnoredStreamErrors(): IFlexIgnoredStreamError[] {
|
|
160
|
+
return this.ignoredStreamErrors.map((entryArg) => ({ ...entryArg }));
|
|
161
|
+
}
|
|
162
|
+
|
|
144
163
|
/**
|
|
145
164
|
* Writes one frame after the frames before it. Every refusal before the frame's first byte reaches
|
|
146
165
|
* the stream throws `FlexIpcNotSentError`; a failure of the write itself may come after bytes went
|
|
@@ -189,9 +208,11 @@ export class FlexFramedTransport<TIncoming, TOutgoing> {
|
|
|
189
208
|
private async closeTransport(): Promise<void> {
|
|
190
209
|
this.closed = true;
|
|
191
210
|
this.detachStreams();
|
|
211
|
+
// Inbound frames are discarded once closed, so the reader goes at once; only the writer drains.
|
|
212
|
+
if (!this.readable.destroyed) this.readable.destroy();
|
|
192
213
|
let drainTimer: ReturnType<typeof setTimeout> | undefined;
|
|
193
|
-
const drainTimeout = new Promise<
|
|
194
|
-
drainTimer = setTimeout(
|
|
214
|
+
const drainTimeout = new Promise<void>((resolve) => {
|
|
215
|
+
drainTimer = setTimeout(resolve, flexIpcCloseDrainTimeoutMs);
|
|
195
216
|
drainTimer.unref?.();
|
|
196
217
|
});
|
|
197
218
|
const gracefulClose = this.writeTail.then(async () => {
|
|
@@ -200,20 +221,14 @@ export class FlexFramedTransport<TIncoming, TOutgoing> {
|
|
|
200
221
|
this.writable.end(resolve);
|
|
201
222
|
});
|
|
202
223
|
}
|
|
203
|
-
return 'drained' as const;
|
|
204
224
|
});
|
|
205
|
-
|
|
225
|
+
await Promise.race([
|
|
206
226
|
gracefulClose,
|
|
207
227
|
drainTimeout,
|
|
208
228
|
]);
|
|
209
229
|
if (drainTimer) clearTimeout(drainTimer);
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (!this.readable.destroyed) this.readable.destroy();
|
|
213
|
-
this.emitClose();
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
if (!this.readable.destroyed) this.readable.destroy();
|
|
230
|
+
// Drained or not, the writer goes too: a pipe socket ended for writing still reads from its peer.
|
|
231
|
+
if (!this.writable.destroyed) this.writable.destroy();
|
|
217
232
|
this.emitClose();
|
|
218
233
|
}
|
|
219
234
|
|
|
@@ -292,8 +307,19 @@ export class FlexFramedTransport<TIncoming, TOutgoing> {
|
|
|
292
307
|
});
|
|
293
308
|
}
|
|
294
309
|
|
|
295
|
-
private readonly onReadError = (errorArg: Error): void => this.
|
|
296
|
-
private readonly onWriteError = (errorArg: Error): void => this.
|
|
310
|
+
private readonly onReadError = (errorArg: Error): void => this.handleStreamError('readable', errorArg);
|
|
311
|
+
private readonly onWriteError = (errorArg: Error): void => this.handleStreamError('writable', errorArg);
|
|
312
|
+
|
|
313
|
+
private handleStreamError(streamArg: IFlexIgnoredStreamError['stream'], errorArg: Error): void {
|
|
314
|
+
if (!this.closed && !this.failed) {
|
|
315
|
+
this.fail(errorArg);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const code = 'code' in errorArg && typeof errorArg.code === 'string' ? errorArg.code : undefined;
|
|
319
|
+
this.ignoredStreamErrors.push({ stream: streamArg, ...(code ? { code } : {}), timestamp: Date.now() });
|
|
320
|
+
if (this.ignoredStreamErrors.length > flexIpcMaximumIgnoredStreamErrors) this.ignoredStreamErrors.shift();
|
|
321
|
+
}
|
|
322
|
+
|
|
297
323
|
private readonly onReadableClosed = (): void => {
|
|
298
324
|
if (this.closed) return;
|
|
299
325
|
if (this.headerOffset !== 0 || this.body) {
|
|
@@ -326,12 +352,11 @@ export class FlexFramedTransport<TIncoming, TOutgoing> {
|
|
|
326
352
|
this.emitClose();
|
|
327
353
|
}
|
|
328
354
|
|
|
355
|
+
/** Removes every stream listener but the error listeners, which stay for as long as the streams exist. */
|
|
329
356
|
private detachStreams(): void {
|
|
330
357
|
this.readable.removeListener('data', this.onData);
|
|
331
|
-
this.readable.removeListener('error', this.onReadError);
|
|
332
358
|
this.readable.removeListener('end', this.onReadableClosed);
|
|
333
359
|
this.readable.removeListener('close', this.onReadableClosed);
|
|
334
|
-
this.writable.removeListener('error', this.onWriteError);
|
|
335
360
|
this.writable.removeListener('finish', this.onWritableClosed);
|
|
336
361
|
this.writable.removeListener('close', this.onWritableClosed);
|
|
337
362
|
}
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
} from './classes.flexmodels.private.js';
|
|
8
8
|
import { FlexStore, type IFlexProjectManagementHost } from './classes.flexstore.js';
|
|
9
9
|
import { FlexPersistenceMigrationRunner } from '../ts_migration/classes.flexmigrationrunner.js';
|
|
10
|
-
import { FlexPostHarnessMigrationRunner } from '../ts_migration/classes.flexpostharnessmigrationrunner.js';
|
|
11
10
|
import {
|
|
12
11
|
assertCanonicalDirectory,
|
|
13
12
|
CanonicalDirectoryError,
|
|
@@ -602,11 +601,6 @@ interface IFlexChildBrowserChannel {
|
|
|
602
601
|
sessionGenerationSequence: number;
|
|
603
602
|
}
|
|
604
603
|
|
|
605
|
-
interface IFlexProjectRegistrationMigrationContext {
|
|
606
|
-
projectId: string;
|
|
607
|
-
registrationOperationId: string;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
604
|
interface IFlexPendingProjectRemoval {
|
|
611
605
|
removalOperationId: string;
|
|
612
606
|
cleanupCohort: IFlexProjectCleanupCohortEntry[];
|
|
@@ -718,11 +712,8 @@ export class FlexService {
|
|
|
718
712
|
(errorArg, contextArg) => this.projectRunFailure(errorArg, contextArg),
|
|
719
713
|
);
|
|
720
714
|
private readonly pendingProjectRegistrations = new Set<string>();
|
|
721
|
-
private readonly postHarnessMigratedProjects = new Set<string>();
|
|
722
715
|
private readonly pendingProjectRetirements = new Set<string>();
|
|
723
716
|
private readonly pendingProjectRemovals = new Map<string, IFlexPendingProjectRemoval>();
|
|
724
|
-
private readonly projectRegistrationMigrationContext =
|
|
725
|
-
new plugins.asyncHooks.AsyncLocalStorage<IFlexProjectRegistrationMigrationContext>();
|
|
726
717
|
private readonly catalogCache = new Map<string, IFlexCatalogCache>();
|
|
727
718
|
/** The models of the proxy's Claude pool, read in its connection's queue like an account's catalog. */
|
|
728
719
|
private claudePoolCatalog?: IFlexProxyClaudeModel[];
|
|
@@ -1205,12 +1196,7 @@ export class FlexService {
|
|
|
1205
1196
|
switch (methodArg) {
|
|
1206
1197
|
case 'project.register': {
|
|
1207
1198
|
const payload = payloadArg as IFlexRequestMap['project.register']['request'];
|
|
1208
|
-
const added = await this.registerProject(
|
|
1209
|
-
payload.project,
|
|
1210
|
-
payload.registrationOperationId,
|
|
1211
|
-
harness,
|
|
1212
|
-
signalArg,
|
|
1213
|
-
);
|
|
1199
|
+
const added = await this.registerProject(payload.project, signalArg);
|
|
1214
1200
|
return { result: { registered: true, added } };
|
|
1215
1201
|
}
|
|
1216
1202
|
case 'project.remove': {
|
|
@@ -3432,14 +3418,10 @@ export class FlexService {
|
|
|
3432
3418
|
);
|
|
3433
3419
|
return {
|
|
3434
3420
|
load: async (storageKey, sessionId, sessionContext) => {
|
|
3435
|
-
const registrationMigration = this.projectRegistrationMigrationContext.getStore();
|
|
3436
3421
|
const result = await this.requestHost('project-management.load', {
|
|
3437
3422
|
storageKey,
|
|
3438
3423
|
sessionId,
|
|
3439
3424
|
sessionContext: this.cloneProjectManagementSessionContext(sessionContext),
|
|
3440
|
-
...(registrationMigration?.projectId === storageKey
|
|
3441
|
-
? { registrationOperationId: registrationMigration.registrationOperationId }
|
|
3442
|
-
: {}),
|
|
3443
3425
|
});
|
|
3444
3426
|
return result.record ?? undefined;
|
|
3445
3427
|
},
|
|
@@ -5399,10 +5381,15 @@ export class FlexService {
|
|
|
5399
5381
|
}
|
|
5400
5382
|
}
|
|
5401
5383
|
|
|
5384
|
+
/**
|
|
5385
|
+
* Registration does no work per session: it runs the project's persistence migrations and makes
|
|
5386
|
+
* the project visible. FlexHarness loads the project's namespace (which repairs session
|
|
5387
|
+
* generations and reversion state) on the project's first request, and a session's
|
|
5388
|
+
* project-management state when something first reads it; that load is where the controller
|
|
5389
|
+
* copies a legacy scratchpad into the state (`loadFlexProjectManagement`).
|
|
5390
|
+
*/
|
|
5402
5391
|
private async registerProject(
|
|
5403
5392
|
projectArg: IFlexIdentityBoundProjectRecord,
|
|
5404
|
-
registrationOperationIdArg: string,
|
|
5405
|
-
harnessArg: TFlexHarness<IFlexProjectScope>,
|
|
5406
5393
|
signalArg: AbortSignal,
|
|
5407
5394
|
): Promise<boolean> {
|
|
5408
5395
|
const projectId = projectArg.projectId;
|
|
@@ -5414,16 +5401,6 @@ export class FlexService {
|
|
|
5414
5401
|
const current = this.projects.get(projectId);
|
|
5415
5402
|
if (current) {
|
|
5416
5403
|
if (!flexProjectDirectoriesEqual(current, projectArg)) throw new FlexServiceError('CONFLICT');
|
|
5417
|
-
if (!this.postHarnessMigratedProjects.has(projectId)) {
|
|
5418
|
-
await this.projectRegistrationMigrationContext.run(
|
|
5419
|
-
{ projectId, registrationOperationId: registrationOperationIdArg },
|
|
5420
|
-
() => new FlexPostHarnessMigrationRunner({
|
|
5421
|
-
harness: harnessArg,
|
|
5422
|
-
scopeIds: [projectId],
|
|
5423
|
-
}).run(signalArg),
|
|
5424
|
-
);
|
|
5425
|
-
this.postHarnessMigratedProjects.add(projectId);
|
|
5426
|
-
}
|
|
5427
5404
|
return false;
|
|
5428
5405
|
}
|
|
5429
5406
|
// Registrations of other projects run concurrently, so a pending one holds its place in the
|
|
@@ -5436,36 +5413,14 @@ export class FlexService {
|
|
|
5436
5413
|
if (!this.store) throw new FlexServiceError('NOT_READY');
|
|
5437
5414
|
|
|
5438
5415
|
this.pendingProjectRegistrations.add(projectId);
|
|
5439
|
-
const project = structuredClone(projectArg);
|
|
5440
|
-
let temporarilyVisible = false;
|
|
5441
5416
|
try {
|
|
5442
5417
|
await new FlexPersistenceMigrationRunner({
|
|
5443
5418
|
store: this.store,
|
|
5444
5419
|
storageKeys: [projectId],
|
|
5445
5420
|
}).run(signalArg);
|
|
5446
5421
|
signalArg.throwIfAborted();
|
|
5447
|
-
this.projects.set(projectId,
|
|
5448
|
-
temporarilyVisible = true;
|
|
5449
|
-
await this.projectRegistrationMigrationContext.run(
|
|
5450
|
-
{ projectId, registrationOperationId: registrationOperationIdArg },
|
|
5451
|
-
() => new FlexPostHarnessMigrationRunner({
|
|
5452
|
-
harness: harnessArg,
|
|
5453
|
-
scopeIds: [projectId],
|
|
5454
|
-
}).run(signalArg),
|
|
5455
|
-
);
|
|
5456
|
-
this.postHarnessMigratedProjects.add(projectId);
|
|
5457
|
-
const sessions = await harnessArg.listSessions(projectId);
|
|
5458
|
-
for (const session of sessions) {
|
|
5459
|
-
signalArg.throwIfAborted();
|
|
5460
|
-
await harnessArg.getSessionReversionInfo(projectId, session.sessionId);
|
|
5461
|
-
}
|
|
5462
|
-
signalArg.throwIfAborted();
|
|
5422
|
+
this.projects.set(projectId, structuredClone(projectArg));
|
|
5463
5423
|
return true;
|
|
5464
|
-
} catch (errorArg) {
|
|
5465
|
-
if (temporarilyVisible && this.projects.get(projectId) === project) {
|
|
5466
|
-
this.projects.delete(projectId);
|
|
5467
|
-
}
|
|
5468
|
-
throw errorArg;
|
|
5469
5424
|
} finally {
|
|
5470
5425
|
this.pendingProjectRegistrations.delete(projectId);
|
|
5471
5426
|
}
|
|
@@ -5524,7 +5479,6 @@ export class FlexService {
|
|
|
5524
5479
|
signalArg.throwIfAborted();
|
|
5525
5480
|
await this.deleteModelChoiceForScope(projectId);
|
|
5526
5481
|
this.projects.delete(projectId);
|
|
5527
|
-
this.postHarnessMigratedProjects.delete(projectId);
|
|
5528
5482
|
this.deleteProjectUploadGrants(projectId);
|
|
5529
5483
|
for (const key of this.promptStages.keys()) if (key.startsWith(`${projectId}\0`)) this.promptStages.delete(key);
|
|
5530
5484
|
for (const [key, event] of this.sessionChangeQueue.entries()) {
|
|
@@ -5684,7 +5638,6 @@ export class FlexService {
|
|
|
5684
5638
|
this.pendingProjectRegistrations.clear();
|
|
5685
5639
|
this.pendingProjectRetirements.clear();
|
|
5686
5640
|
this.pendingProjectRemovals.clear();
|
|
5687
|
-
this.postHarnessMigratedProjects.clear();
|
|
5688
5641
|
this.catalogCache.clear();
|
|
5689
5642
|
this.claudePoolCatalog = undefined;
|
|
5690
5643
|
this.jobs.clear();
|
package/ts/classes.flexstore.ts
CHANGED
|
@@ -2,6 +2,10 @@ import * as plugins from './plugins.js';
|
|
|
2
2
|
import { FlexOrphanIndexV33Migration } from '../ts_migration/v33_flexorphanindexes.js';
|
|
3
3
|
import { FlexLegacyPublicationV38Migration } from '../ts_migration/v38_flextranscripts.js';
|
|
4
4
|
import { FlexPublicHeadPointerV39Migration } from '../ts_migration/v39_flexpublicheadpointers.js';
|
|
5
|
+
import {
|
|
6
|
+
initFlexPostHarnessMigrationMarkerModel,
|
|
7
|
+
registerFlexPostHarnessMigrationMarkerModel,
|
|
8
|
+
} from '../ts_migration/v43_flexpostharnessmigrationmarkers.js';
|
|
5
9
|
import {
|
|
6
10
|
FlexDomainHeadModel,
|
|
7
11
|
FlexHeadModel,
|
|
@@ -1288,6 +1292,7 @@ export class FlexStore implements plugins.flexharness.IFlexHarnessStores {
|
|
|
1288
1292
|
this.manager = { db: this.database };
|
|
1289
1293
|
registerFlexPrivateModels(this.manager);
|
|
1290
1294
|
registerFlexPublicModels(this.manager);
|
|
1295
|
+
registerFlexPostHarnessMigrationMarkerModel(this.manager);
|
|
1291
1296
|
|
|
1292
1297
|
this.scopes = {
|
|
1293
1298
|
load: (storageKey) => this.loadScope(storageKey),
|
|
@@ -1366,6 +1371,7 @@ export class FlexStore implements plugins.flexharness.IFlexHarnessStores {
|
|
|
1366
1371
|
await new FlexPublicHeadPointerV39Migration(this.database, this.controllerId).run();
|
|
1367
1372
|
await initFlexPrivateModels();
|
|
1368
1373
|
await initFlexPublicModels();
|
|
1374
|
+
await initFlexPostHarnessMigrationMarkerModel();
|
|
1369
1375
|
this.initialized = true;
|
|
1370
1376
|
this.queueOrphanMaintenance();
|
|
1371
1377
|
})();
|