agl 43.3.1 → 43.3.2
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 +10 -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.controller.d.ts +11 -4
- package/dist_ts/classes.controller.js +25 -53
- package/dist_ts/classes.flexservice.d.ts +12 -1
- package/dist_ts/classes.flexservice.js +44 -13
- package/dist_ts/classes.flexstore.d.ts +20 -0
- package/dist_ts/classes.flexstore.js +30 -1
- package/dist_ts/interfaces.flexipc.d.ts +17 -9
- package/dist_ts/interfaces.flexipc.js +19 -20
- package/package.json +5 -5
- package/readme.md +1 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.controller.ts +27 -56
- package/ts/classes.flexservice.ts +57 -14
- package/ts/classes.flexstore.ts +40 -0
- package/ts/interfaces.flexipc.ts +43 -27
- package/ts_web/00_commitinfo_data.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agl",
|
|
3
|
-
"version": "43.3.
|
|
3
|
+
"version": "43.3.2",
|
|
4
4
|
"controllerUpgradeManagementVersion": 2,
|
|
5
5
|
"controllerManagementProtocolVersion": 1,
|
|
6
6
|
"controllerGatewaySourcesVersion": 1,
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"@lossless.org/objectstorage": "10.7.1",
|
|
40
40
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
41
41
|
"@modelprofile.com/catalog": "^1.1.0",
|
|
42
|
-
"@modelprofile.com/flexharness": "18.
|
|
43
|
-
"@modelprofile.com/flexharness-agent": "18.
|
|
44
|
-
"@modelprofile.com/flexharness-models": "18.
|
|
45
|
-
"@modelprofile.com/flexharness-providers": "18.
|
|
42
|
+
"@modelprofile.com/flexharness": "18.1.0",
|
|
43
|
+
"@modelprofile.com/flexharness-agent": "18.1.0",
|
|
44
|
+
"@modelprofile.com/flexharness-models": "18.1.0",
|
|
45
|
+
"@modelprofile.com/flexharness-providers": "18.1.0",
|
|
46
46
|
"@modelprofile.com/mcp-crossharness": "5.9.0",
|
|
47
47
|
"@modelprofile.com/mcp-system": "3.1.0",
|
|
48
48
|
"@opencode-ai/sdk": "1.18.15",
|
package/readme.md
CHANGED
|
@@ -68,7 +68,7 @@ OpenCode is automatically recovered only after AGL observes the exact owned chil
|
|
|
68
68
|
|
|
69
69
|
At startup, AGL can reclaim a detached OpenCode listener left by an earlier controller only when its launch metadata records that controller's PID and Linux process start time and that exact owner is no longer live. This works whether Linux reparents the orphan to PID 1, user systemd or a container subreaper. The listener must still match AGL's private runtime directory, user, executable, arguments and verified process group. New launches receive fresh `AGL_OPENCODE_OWNER_IDENTITY` metadata, never an inherited value. A live owner or missing, unreadable, malformed or inconsistent metadata prevents recovery; unmarked listeners from older releases require manual cleanup rather than guessed ownership.
|
|
70
70
|
|
|
71
|
-
Each Flex project has its own request queue in the Flex child, so a slow request of one project never holds another project's requests. When a request is cancelled — a browser tab that reloads or closes cancels its in-flight reads — the child answers at once: a request still waiting in its project's queue leaves the queue without starting, and a running read is answered as cancelled and stops holding the queue while it finishes in the background. A running write is always carried to its end, and a child that does not settle a cancelled request within two seconds is still stopped and replaced, with the request that missed the grace named in the controller log. Each child generation holds its Flex writer leases under a writer identity of its own. Once AGL has confirmed that a generation's whole process group has exited, the next generation takes over that generation's leases at once, fenced by a higher epoch, instead of waiting 30 seconds for them to expire; a lease whose writer is not proven gone still protects it until it expires. A child that fails to start reports its cause, which the controller log names.
|
|
71
|
+
Each Flex project has its own request queue in the Flex child, so a slow request of one project never holds another project's requests. When a request is cancelled — a browser tab that reloads or closes cancels its in-flight reads — the child answers at once: a request still waiting in its project's queue leaves the queue without starting, and a running read is answered as cancelled and stops holding the queue while it finishes in the background. A running write is always carried to its end, and a child that does not settle a cancelled request within two seconds is still stopped and replaced, with the request that missed the grace named in the controller log. Each child generation holds its Flex writer leases under a writer identity of its own. Once AGL has confirmed that a generation's whole process group has exited, the next generation takes over that generation's leases at once, fenced by a higher epoch, instead of waiting 30 seconds for them to expire; a lease whose writer is not proven gone still protects it until it expires. A child that fails to start reports its cause, which the controller log names. Reconciling a project's session identities when a child starts reads only the project's metadata, never its sessions' histories, so a project with a long history does not hold a new child. Each time the child loads a project's sessions it writes one line to the controller log, `Flex project load: {…}`, with the project, the outcome (`loaded`, `failed` or `aborted`), the number of sessions, the snapshots and bytes read from the database and the time spent parsing them, and the time spent reading the store, hydrating agent sessions and repairing them, and the total.
|
|
72
72
|
|
|
73
73
|
The browser receives normalized AGL data. It never receives the OpenCode server password, provider credentials, private database descriptors, raw provider responses, or Flex private snapshots.
|
|
74
74
|
|
package/ts/00_commitinfo_data.ts
CHANGED
package/ts/classes.controller.ts
CHANGED
|
@@ -1100,7 +1100,6 @@ const maxOpenCodeOperationRecoveryFailures = 3;
|
|
|
1100
1100
|
const maxOpenCodeOperationRecoveryPages = 8;
|
|
1101
1101
|
const openCodeFailClosedRetryMs = 1_000;
|
|
1102
1102
|
const openCodeSessionErrorCleanupRetryMs = 1_000;
|
|
1103
|
-
const maxFlexSessionIdentitySnapshotEntries = 2_048;
|
|
1104
1103
|
const sessionIntelligenceOrphanGraceMs = 30 * 60 * 1000;
|
|
1105
1104
|
const sessionIntelligenceCleanupIntervalMs = 15 * 60 * 1000;
|
|
1106
1105
|
const sessionIntelligenceCleanupTimeoutMs = 15_000;
|
|
@@ -12047,62 +12046,32 @@ export class OpenCodeController {
|
|
|
12047
12046
|
) throw new Error('The Flex session identity generation is no longer current.');
|
|
12048
12047
|
}
|
|
12049
12048
|
|
|
12049
|
+
/**
|
|
12050
|
+
* A project's Flex session identities, in one answer the child reads from the project's metadata:
|
|
12051
|
+
* the snapshot is atomic and never waits for a load of the sessions' histories (AGL-1713). The
|
|
12052
|
+
* supervisor has proven the answer: bounded, strictly ordered and generation-bearing.
|
|
12053
|
+
*/
|
|
12050
12054
|
private async readFlexSessionIdentitySnapshot(
|
|
12051
12055
|
supervisorArg: FlexSupervisor,
|
|
12052
12056
|
projectIdArg: string,
|
|
12053
12057
|
signalArg: AbortSignal,
|
|
12054
12058
|
): Promise<IControllerSessionSnapshotEntry[]> {
|
|
12055
|
-
|
|
12056
|
-
const sessions
|
|
12057
|
-
|
|
12058
|
-
|
|
12059
|
-
|
|
12060
|
-
|
|
12061
|
-
|
|
12062
|
-
|
|
12063
|
-
|
|
12064
|
-
|
|
12065
|
-
|
|
12066
|
-
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
|
-
|
|
12070
|
-
|
|
12071
|
-
) throw new Error('Flex returned an invalid bounded identity session snapshot.');
|
|
12072
|
-
expectedTotal ??= page.total;
|
|
12073
|
-
if (page.sessions.length === 0 && sessions.length < page.total) {
|
|
12074
|
-
throw new Error('Flex returned an incomplete identity session snapshot page.');
|
|
12075
|
-
}
|
|
12076
|
-
sessions.push(...page.sessions);
|
|
12077
|
-
const truncated = sessions.length < page.total;
|
|
12078
|
-
if (page.truncated !== truncated || sessions.length > page.total) {
|
|
12079
|
-
throw new Error('Flex identity session snapshot pagination changed during its fence.');
|
|
12080
|
-
}
|
|
12081
|
-
if (!truncated) break;
|
|
12082
|
-
}
|
|
12083
|
-
return sessions.map((sessionArg) => {
|
|
12084
|
-
if (
|
|
12085
|
-
typeof sessionArg.sessionId !== 'string'
|
|
12086
|
-
|| sessionArg.sessionId.length === 0
|
|
12087
|
-
|| typeof sessionArg.sessionGenerationId !== 'string'
|
|
12088
|
-
|| sessionArg.sessionGenerationId.length === 0
|
|
12089
|
-
|| typeof sessionArg.sessionGenerationSequence !== 'number'
|
|
12090
|
-
|| !Number.isSafeInteger(sessionArg.sessionGenerationSequence)
|
|
12091
|
-
|| sessionArg.sessionGenerationSequence < 1
|
|
12092
|
-
) throw new Error('Flex returned a session without canonical generation metadata.');
|
|
12093
|
-
return {
|
|
12094
|
-
nativeId: sessionArg.sessionId,
|
|
12095
|
-
sessionGenerationId: sessionArg.sessionGenerationId,
|
|
12096
|
-
sessionGenerationSequence: sessionArg.sessionGenerationSequence,
|
|
12097
|
-
providerSessionGeneration: flexSessionProviderGeneration(
|
|
12098
|
-
sessionArg.sessionGenerationId,
|
|
12099
|
-
sessionArg.sessionGenerationSequence,
|
|
12100
|
-
),
|
|
12101
|
-
...(sessionArg.parentSessionId === undefined
|
|
12102
|
-
? {}
|
|
12103
|
-
: { parentNativeId: sessionArg.parentSessionId }),
|
|
12104
|
-
};
|
|
12105
|
-
}).sort((leftArg, rightArg) => leftArg.nativeId.localeCompare(rightArg.nativeId));
|
|
12059
|
+
signalArg.throwIfAborted();
|
|
12060
|
+
const { sessions } = await supervisorArg.request('session.identities', {
|
|
12061
|
+
scopeId: projectIdArg,
|
|
12062
|
+
}, signalArg);
|
|
12063
|
+
return sessions.map((sessionArg) => ({
|
|
12064
|
+
nativeId: sessionArg.sessionId,
|
|
12065
|
+
sessionGenerationId: sessionArg.sessionGenerationId,
|
|
12066
|
+
sessionGenerationSequence: sessionArg.sessionGenerationSequence,
|
|
12067
|
+
providerSessionGeneration: flexSessionProviderGeneration(
|
|
12068
|
+
sessionArg.sessionGenerationId,
|
|
12069
|
+
sessionArg.sessionGenerationSequence,
|
|
12070
|
+
),
|
|
12071
|
+
...(sessionArg.parentSessionId === undefined
|
|
12072
|
+
? {}
|
|
12073
|
+
: { parentNativeId: sessionArg.parentSessionId }),
|
|
12074
|
+
})).sort((leftArg, rightArg) => leftArg.nativeId.localeCompare(rightArg.nativeId));
|
|
12106
12075
|
}
|
|
12107
12076
|
|
|
12108
12077
|
private async captureFlexCleanupCohort(
|
|
@@ -29427,10 +29396,12 @@ export class OpenCodeController {
|
|
|
29427
29396
|
/**
|
|
29428
29397
|
* The reversion requests that settle what a Flex session already recorded: a capture's inspection
|
|
29429
29398
|
* and finalization, a pending undo or redo, a release. A project reconciling its session authority
|
|
29430
|
-
* admits them.
|
|
29431
|
-
*
|
|
29432
|
-
*
|
|
29433
|
-
*
|
|
29399
|
+
* admits them. The first full load of the project's sessions in the child (the child's recovery
|
|
29400
|
+
* load once it is ready, a held prompt's settlement or a managed creation's recovery during the
|
|
29401
|
+
* reconciliation, any session read; never `session.identities`) settles each session's pending
|
|
29402
|
+
* capture and apply before it answers; a refused settlement fails that load, and with it a
|
|
29403
|
+
* reconciliation waiting for it, which then never succeeds. The ending turn of a run closes its
|
|
29404
|
+
* capture with the same requests. A new capture
|
|
29434
29405
|
* (`reversion.prepare`) is new work and stays refused while authority is uncertain.
|
|
29435
29406
|
*/
|
|
29436
29407
|
private flexHostMethodSettlesRecordedReversion(methodArg: TFlexHostRequestMethod): boolean {
|
|
@@ -5,7 +5,11 @@ import {
|
|
|
5
5
|
type IFlexModelChoiceDocument,
|
|
6
6
|
assertFlexModelChoiceDocument,
|
|
7
7
|
} from './classes.flexmodels.private.js';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
FlexStore,
|
|
10
|
+
type IFlexProjectManagementHost,
|
|
11
|
+
type IFlexScopeLoadReads,
|
|
12
|
+
} from './classes.flexstore.js';
|
|
9
13
|
import { FlexPersistenceMigrationRunner } from '../ts_migration/classes.flexmigrationrunner.js';
|
|
10
14
|
import {
|
|
11
15
|
assertCanonicalDirectory,
|
|
@@ -46,8 +50,10 @@ import {
|
|
|
46
50
|
type TFlexProjectManagementSessionContext,
|
|
47
51
|
type TFlexRequestMethod,
|
|
48
52
|
type TFlexPromptAdmissionGeneration,
|
|
53
|
+
type TFlexScopeLoadMetrics,
|
|
49
54
|
type TFlexSessionGeneration,
|
|
50
55
|
type TFlexSessionGenerationCohortEntry,
|
|
56
|
+
type TFlexSessionIdentity,
|
|
51
57
|
createFlexServiceError,
|
|
52
58
|
flexGenerationLeaseCleanupTimeoutMs,
|
|
53
59
|
flexIntelligenceInstallationScopeId,
|
|
@@ -64,6 +70,7 @@ import {
|
|
|
64
70
|
flexIpcMaximumPromptQueueEntries,
|
|
65
71
|
flexIpcMaximumQueuedSessionChangeBytes,
|
|
66
72
|
flexIpcMaximumQueuedSessionChanges,
|
|
73
|
+
flexIpcMaximumSessionIdentities,
|
|
67
74
|
flexIpcMaximumDeltaBytes,
|
|
68
75
|
flexIpcProtocolVersion,
|
|
69
76
|
flexIpcReversionMaintenanceTimeoutMs,
|
|
@@ -341,6 +348,26 @@ export const isReadOnlyFlexToolCall = (callArg: { toolName: string; input: unkno
|
|
|
341
348
|
&& callArg.input !== null
|
|
342
349
|
&& (callArg.input as { action?: unknown }).action === 'list');
|
|
343
350
|
|
|
351
|
+
/**
|
|
352
|
+
* The controller log line of one FlexHarness load of a project's sessions (AGL-1713): what FlexHarness
|
|
353
|
+
* measured, with the snapshots the store read and decoded for that load.
|
|
354
|
+
*/
|
|
355
|
+
export const formatFlexScopeLoadLine = (
|
|
356
|
+
metricsArg: TFlexScopeLoadMetrics,
|
|
357
|
+
readsArg: IFlexScopeLoadReads,
|
|
358
|
+
): string => `Flex project load: ${JSON.stringify({
|
|
359
|
+
projectId: metricsArg.scopeId,
|
|
360
|
+
outcome: metricsArg.outcome,
|
|
361
|
+
sessions: metricsArg.sessions,
|
|
362
|
+
snapshotsRead: readsArg.snapshots,
|
|
363
|
+
bytesRead: readsArg.bytes,
|
|
364
|
+
parseMs: Math.round(readsArg.decodeMs),
|
|
365
|
+
storeReadMs: Math.round(metricsArg.storeReadMs),
|
|
366
|
+
agentSessionMs: Math.round(metricsArg.agentSessionMs),
|
|
367
|
+
repairMs: Math.round(metricsArg.repairMs),
|
|
368
|
+
totalMs: Math.round(metricsArg.totalMs),
|
|
369
|
+
})}`;
|
|
370
|
+
|
|
344
371
|
export const createFlexBuiltInTools = (): plugins.flexharness.IFlexBuiltInToolsOptions => ({
|
|
345
372
|
renameSession: true,
|
|
346
373
|
projectManagement: {
|
|
@@ -355,7 +382,7 @@ const projectSerializedMethods: ReadonlySet<TFlexRequestMethod> = new Set([
|
|
|
355
382
|
'project.remove',
|
|
356
383
|
'intelligence.start',
|
|
357
384
|
'intelligence.cancel',
|
|
358
|
-
'session.
|
|
385
|
+
'session.identities',
|
|
359
386
|
'session.create',
|
|
360
387
|
'session.get',
|
|
361
388
|
'session.cache.warm',
|
|
@@ -398,7 +425,7 @@ const projectScopedMethods: ReadonlySet<TFlexRequestMethod> = new Set([
|
|
|
398
425
|
'intelligence.start',
|
|
399
426
|
'intelligence.get',
|
|
400
427
|
'intelligence.cancel',
|
|
401
|
-
'session.
|
|
428
|
+
'session.identities',
|
|
402
429
|
'session.create',
|
|
403
430
|
'session.get',
|
|
404
431
|
'session.metrics',
|
|
@@ -988,6 +1015,7 @@ export class FlexService {
|
|
|
988
1015
|
reversionPolicy: 'workspace-required',
|
|
989
1016
|
slashCommands: [this.worktreeSlashCommand()],
|
|
990
1017
|
stores: store,
|
|
1018
|
+
scopeLoadObserver: (metrics) => this.reportScopeLoad(store, metrics),
|
|
991
1019
|
builtInTools: createFlexBuiltInTools(),
|
|
992
1020
|
toolOutputLimits: { maxDepth: 12, maxBytes: toolOutputBytes },
|
|
993
1021
|
toolCatalog: { codeMode: true },
|
|
@@ -1036,6 +1064,15 @@ export class FlexService {
|
|
|
1036
1064
|
}
|
|
1037
1065
|
}
|
|
1038
1066
|
|
|
1067
|
+
/**
|
|
1068
|
+
* Writes one line per FlexHarness load of a project to stderr, which the supervisor writes to the
|
|
1069
|
+
* controller log, whatever the load's outcome; the store's reads of that load end with it.
|
|
1070
|
+
*/
|
|
1071
|
+
private reportScopeLoad(storeArg: FlexStore, metricsArg: TFlexScopeLoadMetrics): void {
|
|
1072
|
+
const reads = storeArg.takeScopeLoadReads(metricsArg.storageKey);
|
|
1073
|
+
process.stderr.write(`${formatFlexScopeLoadLine(metricsArg, reads)}\n`);
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1039
1076
|
/**
|
|
1040
1077
|
* An opaque FlexHarness projection that failed the initialization, restated with the raw failure
|
|
1041
1078
|
* it replaced, and the harness step that met it, as its cause.
|
|
@@ -1246,19 +1283,25 @@ export class FlexService {
|
|
|
1246
1283
|
const payload = payloadArg as IFlexRequestMap['configuration.adapt']['request'];
|
|
1247
1284
|
return { result: await this.adaptConfiguration(payload, signalArg) };
|
|
1248
1285
|
}
|
|
1249
|
-
case 'session.
|
|
1250
|
-
const payload = payloadArg as IFlexRequestMap['session.
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
const limit = payload.limit ?? 50;
|
|
1286
|
+
case 'session.identities': {
|
|
1287
|
+
const payload = payloadArg as IFlexRequestMap['session.identities']['request'];
|
|
1288
|
+
// FlexHarness answers from the project's metadata, before a load of its histories settles.
|
|
1289
|
+
const identities = await harness.listSessionIdentities(payload.scopeId);
|
|
1290
|
+
if (identities.length > flexIpcMaximumSessionIdentities) {
|
|
1291
|
+
throw new FlexServiceError('LIMIT_EXCEEDED');
|
|
1292
|
+
}
|
|
1257
1293
|
return {
|
|
1258
1294
|
result: {
|
|
1259
|
-
sessions:
|
|
1260
|
-
|
|
1261
|
-
|
|
1295
|
+
sessions: identities.map((identity) => ({
|
|
1296
|
+
sessionId: identity.sessionId,
|
|
1297
|
+
sessionGenerationId: identity.sessionGenerationId,
|
|
1298
|
+
sessionGenerationSequence: identity.sessionGenerationSequence,
|
|
1299
|
+
...(identity.parentSessionId === undefined
|
|
1300
|
+
? {}
|
|
1301
|
+
: { parentSessionId: identity.parentSessionId }),
|
|
1302
|
+
})).sort((left, right) => (
|
|
1303
|
+
left.sessionId < right.sessionId ? -1 : left.sessionId > right.sessionId ? 1 : 0
|
|
1304
|
+
)),
|
|
1262
1305
|
},
|
|
1263
1306
|
};
|
|
1264
1307
|
}
|
package/ts/classes.flexstore.ts
CHANGED
|
@@ -104,6 +104,16 @@ export interface IFlexTranscriptMigrationPage {
|
|
|
104
104
|
nextCursor?: TFlexObjectId;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
/** What the store read for one FlexHarness load of a storage key (AGL-1713). */
|
|
108
|
+
export interface IFlexScopeLoadReads {
|
|
109
|
+
/** Private snapshots read from the database; a cached one costs no read and is not counted. */
|
|
110
|
+
snapshots: number;
|
|
111
|
+
/** Their JSON bytes. */
|
|
112
|
+
bytes: number;
|
|
113
|
+
/** Decoding them: base64, chunk and snapshot SHA-256, concatenation, UTF-8 and `JSON.parse`. */
|
|
114
|
+
decodeMs: number;
|
|
115
|
+
}
|
|
116
|
+
|
|
107
117
|
export interface IFlexStoreOptions {
|
|
108
118
|
database: plugins.nosqldb.SmartdataDb;
|
|
109
119
|
controllerId: string;
|
|
@@ -1268,6 +1278,12 @@ export class FlexStore implements plugins.flexharness.IFlexHarnessStores {
|
|
|
1268
1278
|
/** Transcripts by id; they are addressed by their content, so a cached one never goes stale. */
|
|
1269
1279
|
private readonly transcriptCache = new Map<string, IFlexCachedTranscript>();
|
|
1270
1280
|
private transcriptCacheBytes = 0;
|
|
1281
|
+
/**
|
|
1282
|
+
* What FlexHarness's load of each storage key has read so far: opened by the load's first read,
|
|
1283
|
+
* its scope snapshot, and ended by the load's report (`takeScopeLoadReads`), a purge or the
|
|
1284
|
+
* close. At most one entry per storage key, numbers only.
|
|
1285
|
+
*/
|
|
1286
|
+
private readonly scopeLoadReads = new Map<string, IFlexScopeLoadReads>();
|
|
1271
1287
|
|
|
1272
1288
|
constructor(optionsArg: IFlexStoreOptions) {
|
|
1273
1289
|
assertIdentifier(optionsArg.controllerId, 'controllerId');
|
|
@@ -1638,6 +1654,7 @@ export class FlexStore implements plugins.flexharness.IFlexHarnessStores {
|
|
|
1638
1654
|
await this.runStorage(storageKeyArg, async (lease) => {
|
|
1639
1655
|
this.evictProviderScope(storageKeyArg);
|
|
1640
1656
|
this.forgetCachedSnapshots(storageKeyArg);
|
|
1657
|
+
this.scopeLoadReads.delete(storageKeyArg);
|
|
1641
1658
|
let lastDomainHeadId: TFlexObjectId | undefined;
|
|
1642
1659
|
while (true) {
|
|
1643
1660
|
const domainHeads = await this.readDomainHeadPage({
|
|
@@ -1756,6 +1773,16 @@ export class FlexStore implements plugins.flexharness.IFlexHarnessStores {
|
|
|
1756
1773
|
}
|
|
1757
1774
|
}
|
|
1758
1775
|
|
|
1776
|
+
/**
|
|
1777
|
+
* The reads of FlexHarness's load of a storage key since it began, which end here: FlexHarness
|
|
1778
|
+
* reports each load once it ended, whatever its outcome.
|
|
1779
|
+
*/
|
|
1780
|
+
public takeScopeLoadReads(storageKeyArg: string): IFlexScopeLoadReads {
|
|
1781
|
+
const reads = this.scopeLoadReads.get(storageKeyArg) ?? { snapshots: 0, bytes: 0, decodeMs: 0 };
|
|
1782
|
+
this.scopeLoadReads.delete(storageKeyArg);
|
|
1783
|
+
return reads;
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1759
1786
|
public async close(): Promise<void> {
|
|
1760
1787
|
if (this.closeComplete) return;
|
|
1761
1788
|
if (this.closePromise) return this.closePromise;
|
|
@@ -1801,6 +1828,7 @@ export class FlexStore implements plugins.flexharness.IFlexHarnessStores {
|
|
|
1801
1828
|
}
|
|
1802
1829
|
this.agentEventStores.clear();
|
|
1803
1830
|
this.jobStores.clear();
|
|
1831
|
+
this.scopeLoadReads.clear();
|
|
1804
1832
|
const releaseResults = await Promise.allSettled(
|
|
1805
1833
|
[...this.heldLeases.values()].map((lease) => this.releaseHeldLease(
|
|
1806
1834
|
lease,
|
|
@@ -1822,6 +1850,11 @@ export class FlexStore implements plugins.flexharness.IFlexHarnessStores {
|
|
|
1822
1850
|
}
|
|
1823
1851
|
|
|
1824
1852
|
private async loadScope(storageKeyArg: string): Promise<TFlexScopeSnapshot | undefined> {
|
|
1853
|
+
// FlexHarness loads a scope's sessions after its scope snapshot, so its reads count from here on
|
|
1854
|
+
// until the load reports. A load already counting keeps what it read.
|
|
1855
|
+
if (!this.scopeLoadReads.has(storageKeyArg)) {
|
|
1856
|
+
this.scopeLoadReads.set(storageKeyArg, { snapshots: 0, bytes: 0, decodeMs: 0 });
|
|
1857
|
+
}
|
|
1825
1858
|
return this.runStorage(storageKeyArg, async () => {
|
|
1826
1859
|
const loaded = await this.loadDomainDirect<TFlexScopeSnapshot>(
|
|
1827
1860
|
{ storageKey: storageKeyArg, domain: 'scope' },
|
|
@@ -2877,6 +2910,7 @@ export class FlexStore implements plugins.flexharness.IFlexHarnessStores {
|
|
|
2877
2910
|
scopeId: storageKeyArg,
|
|
2878
2911
|
}),
|
|
2879
2912
|
);
|
|
2913
|
+
const decodeStartedAt = performance.now();
|
|
2880
2914
|
const chunks: Buffer[] = [];
|
|
2881
2915
|
for (const chunkManifest of manifestArg.chunks) {
|
|
2882
2916
|
abortSignalArg?.throwIfAborted();
|
|
@@ -2923,6 +2957,12 @@ export class FlexStore implements plugins.flexharness.IFlexHarnessStores {
|
|
|
2923
2957
|
{ cause: errorArg },
|
|
2924
2958
|
);
|
|
2925
2959
|
}
|
|
2960
|
+
const scopeLoadReads = this.scopeLoadReads.get(storageKeyArg);
|
|
2961
|
+
if (scopeLoadReads) {
|
|
2962
|
+
scopeLoadReads.snapshots += 1;
|
|
2963
|
+
scopeLoadReads.bytes += manifestArg.bytes;
|
|
2964
|
+
scopeLoadReads.decodeMs += performance.now() - decodeStartedAt;
|
|
2965
|
+
}
|
|
2926
2966
|
abortSignalArg?.throwIfAborted();
|
|
2927
2967
|
try {
|
|
2928
2968
|
return await validateArg(parsed);
|
package/ts/interfaces.flexipc.ts
CHANGED
|
@@ -67,8 +67,12 @@ export type TFlexTurnReversionCaptureInspectionV2 =
|
|
|
67
67
|
plugins.flexharness.TFlexTurnReversionCaptureInspectionV2;
|
|
68
68
|
export type TFlexTurnReversionApplyInspection =
|
|
69
69
|
plugins.flexharness.IFlexTurnReversionApplyInspection;
|
|
70
|
+
/** A session's identity as its project's metadata holds it, read without loading its history. */
|
|
71
|
+
export type TFlexSessionIdentity = plugins.flexharness.IFlexSessionIdentity;
|
|
72
|
+
/** What one FlexHarness load of a project's sessions took. */
|
|
73
|
+
export type TFlexScopeLoadMetrics = plugins.flexharness.IFlexScopeLoadMetrics;
|
|
70
74
|
|
|
71
|
-
export const flexIpcProtocolVersion =
|
|
75
|
+
export const flexIpcProtocolVersion = 40 as const;
|
|
72
76
|
/**
|
|
73
77
|
* The installation's own Flex runs, which belong to no project: the configuration projection's adapting run, and
|
|
74
78
|
* Session Intelligence over a session outside every project.
|
|
@@ -93,6 +97,8 @@ export const flexIpcMaximumPromptPayloadBytes = flexIpcMaximumFrameBytes - 64 *
|
|
|
93
97
|
export const flexIpcMaximumPromptQueueEntries = 128;
|
|
94
98
|
export const flexIpcMaximumQueuedSessionChanges = 256;
|
|
95
99
|
export const flexIpcMaximumQueuedSessionChangeBytes = 8 * 1024 * 1024;
|
|
100
|
+
/** The most sessions one project's `session.identities` answer names; more is refused, never cut. */
|
|
101
|
+
export const flexIpcMaximumSessionIdentities = 2_048;
|
|
96
102
|
export const flexGenerationLeaseCleanupTimeoutMs = 30_000;
|
|
97
103
|
export const flexIpcControlTimeoutMs = 35_000;
|
|
98
104
|
export const flexIpcMaximumHostTimeoutMs = 5 * 60 * 1000;
|
|
@@ -694,10 +700,9 @@ export interface IFlexJobAdmission {
|
|
|
694
700
|
jobId: string;
|
|
695
701
|
}
|
|
696
702
|
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
truncated: boolean;
|
|
703
|
+
/** Every session of a project, ordered by `sessionId` (UTF-16 code units), in one answer. */
|
|
704
|
+
export interface IFlexSessionIdentitiesResult {
|
|
705
|
+
sessions: TFlexSessionIdentity[];
|
|
701
706
|
}
|
|
702
707
|
|
|
703
708
|
export type TFlexSlashExecutionResult =
|
|
@@ -771,9 +776,14 @@ export interface IFlexRequestMap {
|
|
|
771
776
|
request: IFlexConfigurationAdaptationRequest;
|
|
772
777
|
response: IFlexConfigurationAdaptationResult;
|
|
773
778
|
};
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
779
|
+
/**
|
|
780
|
+
* The identities of a project's sessions, from its metadata: never waits for a load of their
|
|
781
|
+
* histories, so the controller's identity reconciliation after `project.register` stays within
|
|
782
|
+
* its control budget however long the project's history is (AGL-1713).
|
|
783
|
+
*/
|
|
784
|
+
'session.identities': {
|
|
785
|
+
request: { scopeId: string };
|
|
786
|
+
response: IFlexSessionIdentitiesResult;
|
|
777
787
|
};
|
|
778
788
|
'session.create': {
|
|
779
789
|
request: {
|
|
@@ -1363,7 +1373,7 @@ export type TFlexChildMessage =
|
|
|
1363
1373
|
export const readOnlyFlexRequestMethods: ReadonlySet<TFlexRequestMethod> = new Set<TFlexRequestMethod>([
|
|
1364
1374
|
'service.status',
|
|
1365
1375
|
'intelligence.get',
|
|
1366
|
-
'session.
|
|
1376
|
+
'session.identities',
|
|
1367
1377
|
'session.get',
|
|
1368
1378
|
'session.metrics',
|
|
1369
1379
|
'session.reversion.info',
|
|
@@ -1387,7 +1397,7 @@ const requestMethods: ReadonlySet<string> = new Set<TFlexRequestMethod>([
|
|
|
1387
1397
|
'intelligence.get',
|
|
1388
1398
|
'intelligence.cancel',
|
|
1389
1399
|
'configuration.adapt',
|
|
1390
|
-
'session.
|
|
1400
|
+
'session.identities',
|
|
1391
1401
|
'session.create',
|
|
1392
1402
|
'session.get',
|
|
1393
1403
|
'session.metrics',
|
|
@@ -1648,14 +1658,23 @@ const isFlexProjectCleanupCohortEntry = (
|
|
|
1648
1658
|
&& isFlexSessionGeneration(valueArg)
|
|
1649
1659
|
&& typeof valueArg.cleanupRoot === 'boolean';
|
|
1650
1660
|
|
|
1661
|
+
const isFlexSessionIdentity = (valueArg: unknown): valueArg is TFlexSessionIdentity =>
|
|
1662
|
+
isFlexPlainObject(valueArg)
|
|
1663
|
+
&& hasFlexExactKeys(
|
|
1664
|
+
valueArg,
|
|
1665
|
+
['sessionId', 'sessionGenerationId', 'sessionGenerationSequence'],
|
|
1666
|
+
['parentSessionId'],
|
|
1667
|
+
)
|
|
1668
|
+
&& isIdentifier(valueArg.sessionId)
|
|
1669
|
+
&& isFlexSessionGeneration(valueArg)
|
|
1670
|
+
&& (valueArg.parentSessionId === undefined || isIdentifier(valueArg.parentSessionId));
|
|
1671
|
+
|
|
1651
1672
|
const isStrictlyOrderedFlexCohort = <TEntry extends { sessionId: string }>(
|
|
1652
1673
|
valueArg: unknown,
|
|
1653
1674
|
entryCheckArg: (entryArg: unknown) => entryArg is TEntry,
|
|
1675
|
+
maximumEntriesArg: number = plugins.flexharness.FLEX_SESSION_GENERATION_COHORT_MAX_ENTRIES,
|
|
1654
1676
|
): valueArg is TEntry[] => {
|
|
1655
|
-
if (
|
|
1656
|
-
!Array.isArray(valueArg)
|
|
1657
|
-
|| valueArg.length > plugins.flexharness.FLEX_SESSION_GENERATION_COHORT_MAX_ENTRIES
|
|
1658
|
-
) return false;
|
|
1677
|
+
if (!Array.isArray(valueArg) || valueArg.length > maximumEntriesArg) return false;
|
|
1659
1678
|
let previousSessionId: string | undefined;
|
|
1660
1679
|
for (const entry of valueArg) {
|
|
1661
1680
|
if (
|
|
@@ -2547,13 +2566,9 @@ export const isFlexRequestPayload = <TMethod extends TFlexRequestMethod>(
|
|
|
2547
2566
|
&& configurationAdaptationTargets.has(String(harness.targetId))
|
|
2548
2567
|
&& isBoundedString(harness.source, 256 * 1024, true)
|
|
2549
2568
|
&& isBoundedString(harness.profile, 4 * 1024));
|
|
2550
|
-
case 'session.
|
|
2551
|
-
return hasFlexExactKeys(valueArg, ['scopeId']
|
|
2552
|
-
&& isControllerProjectId(valueArg.scopeId)
|
|
2553
|
-
&& (valueArg.offset === undefined || isNonNegativeInteger(valueArg.offset))
|
|
2554
|
-
&& (valueArg.limit === undefined
|
|
2555
|
-
|| (Number.isSafeInteger(valueArg.limit) && Number(valueArg.limit) >= 1
|
|
2556
|
-
&& Number(valueArg.limit) <= 50));
|
|
2569
|
+
case 'session.identities':
|
|
2570
|
+
return hasFlexExactKeys(valueArg, ['scopeId'])
|
|
2571
|
+
&& isControllerProjectId(valueArg.scopeId);
|
|
2557
2572
|
case 'session.create':
|
|
2558
2573
|
return hasFlexExactKeys(valueArg, ['scopeId', 'options'])
|
|
2559
2574
|
&& isControllerProjectId(valueArg.scopeId)
|
|
@@ -3436,13 +3451,14 @@ export const isFlexResponseResult = <TMethod extends TFlexRequestMethod>(
|
|
|
3436
3451
|
&& isFlexPlainObject(valueArg.instructions)
|
|
3437
3452
|
&& Object.entries(valueArg.instructions).every(([targetId, text]) => configurationAdaptationTargets.has(targetId)
|
|
3438
3453
|
&& isBoundedString(text, 256 * 1024, true));
|
|
3439
|
-
case 'session.
|
|
3454
|
+
case 'session.identities':
|
|
3440
3455
|
return isFlexPlainObject(valueArg)
|
|
3441
|
-
&& hasFlexExactKeys(valueArg, ['sessions'
|
|
3442
|
-
&&
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3456
|
+
&& hasFlexExactKeys(valueArg, ['sessions'])
|
|
3457
|
+
&& isStrictlyOrderedFlexCohort(
|
|
3458
|
+
valueArg.sessions,
|
|
3459
|
+
isFlexSessionIdentity,
|
|
3460
|
+
flexIpcMaximumSessionIdentities,
|
|
3461
|
+
);
|
|
3446
3462
|
case 'session.create':
|
|
3447
3463
|
case 'session.get':
|
|
3448
3464
|
case 'session.update':
|