agl 43.9.0 → 43.10.1
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 +20 -0
- package/dist_serve/bundle.js +997 -975
- package/dist_serve/bundle.js.map +2 -2
- package/dist_ts/00_commitinfo_data.js +2 -2
- package/dist_ts/aglapi/aglapisurface.document.js +3 -3
- package/dist_ts/classes.accountsactions.d.ts +3 -1
- package/dist_ts/classes.accountsactions.js +17 -1
- package/dist_ts/classes.authstore.d.ts +6 -0
- package/dist_ts/classes.authstore.js +8 -1
- package/dist_ts/classes.controller.d.ts +7 -1
- package/dist_ts/classes.controller.js +39 -7
- package/dist_ts/classes.inferencegateway.js +7 -5
- package/dist_ts/classes.inferenceplacement.d.ts +1 -1
- package/dist_ts/classes.inferencerouter.d.ts +20 -3
- package/dist_ts/classes.inferencerouter.js +37 -10
- package/dist_ts/classes.inferenceservice.js +2 -2
- package/dist_ts/classes.mcpcallerregistry.d.ts +19 -1
- package/dist_ts/classes.mcpcallerregistry.js +33 -7
- package/dist_ts/classes.terminalcallers.d.ts +40 -0
- package/dist_ts/classes.terminalcallers.js +90 -0
- package/dist_ts/classes.terminalmanager.d.ts +20 -1
- package/dist_ts/classes.terminalmanager.js +36 -2
- package/dist_ts/classes.ticketnotifier.d.ts +2 -2
- package/dist_ts/classes.ticketnotifier.js +6 -4
- package/dist_ts/classes.ticketorderspread.d.ts +25 -0
- package/dist_ts/classes.ticketorderspread.js +52 -0
- package/dist_ts/classes.ticketstore.d.ts +60 -5
- package/dist_ts/classes.ticketstore.js +176 -40
- package/dist_ts/classes.workercallers.d.ts +40 -2
- package/dist_ts/classes.workercallers.js +156 -30
- package/dist_ts/fleet/classes.boardpump.d.ts +1 -1
- package/dist_ts/fleet/classes.boardpump.js +4 -2
- package/dist_ts/fleet/classes.claudeworkers.d.ts +18 -5
- package/dist_ts/fleet/classes.claudeworkers.js +105 -31
- package/dist_ts/fleet/classes.ticketeffects.d.ts +11 -0
- package/dist_ts/fleet/classes.ticketeffects.js +28 -1
- package/dist_ts/fleet/classes.workers.d.ts +23 -4
- package/dist_ts/fleet/classes.workers.js +65 -18
- package/dist_ts/fleet/functions.workervalidation.js +7 -4
- package/dist_ts/fleet/interfaces.workers.d.ts +16 -2
- package/dist_ts/fleet/interfaces.workers.js +8 -1
- package/dist_ts/functions.fleetworkercli.d.ts +3 -1
- package/dist_ts/functions.fleetworkercli.js +6 -2
- package/dist_ts/functions.inferencecli.js +4 -1
- package/dist_ts/functions.mcpfleetworkertools.js +3 -3
- package/dist_ts/functions.proxycapacity.d.ts +2 -1
- package/dist_ts/functions.proxycapacity.js +6 -3
- package/dist_ts/functions.proxycapacitycli.js +2 -2
- package/dist_ts/functions.workerprocessproof.d.ts +6 -0
- package/dist_ts/functions.workerprocessproof.js +8 -3
- package/dist_ts/interfaces.auth.d.ts +1 -1
- package/dist_ts/interfaces.auth.js +2 -1
- package/dist_ts/interfaces.flexipc.d.ts +3 -1
- package/dist_ts/interfaces.flexipc.js +1 -1
- package/dist_ts_authswitch/authority-contract.d.ts +25 -0
- package/dist_ts_authswitch/authority-contract.js +1 -1
- package/dist_ts_authswitch/authority-overview.d.ts +7 -0
- package/dist_ts_authswitch/authority-overview.js +10 -6
- package/dist_ts_authswitch/authority-placement.d.ts +5 -2
- package/dist_ts_authswitch/authority-placement.js +6 -3
- package/dist_ts_authswitch/classes.authoritybroker.d.ts +6 -0
- package/dist_ts_authswitch/classes.authoritybroker.js +26 -1
- package/dist_ts_authswitch/classes.authoritycli.d.ts +1 -0
- package/dist_ts_authswitch/classes.authoritycli.js +50 -4
- package/dist_ts_authswitch/classes.authorityclient.d.ts +3 -1
- package/dist_ts_authswitch/classes.authorityclient.js +9 -4
- package/dist_ts_authswitch/classes.authoritydaemon.js +7 -1
- package/dist_ts_authswitch/classes.authoritydatabase.js +5 -1
- package/dist_ts_authswitch/classes.authoritymodels.d.ts +7 -0
- package/dist_ts_authswitch/classes.authoritymodels.js +13 -6
- package/dist_ts_interfaces/fleetworkers.d.ts +26 -1
- package/dist_ts_interfaces/fleetworkers.js +1 -1
- package/dist_ts_interfaces/interfaces.d.ts +4 -2
- package/dist_ts_interfaces/interfaces.js +1 -1
- package/dist_ts_interfaces/mcprequests.d.ts +2 -1
- package/dist_ts_interfaces/mcprequests.js +3 -2
- package/dist_ts_interfaces/proxycapacity.d.ts +1 -1
- package/dist_ts_interfaces/requests.accounts.d.ts +19 -0
- package/dist_ts_interfaces/requests.accounts.js +1 -1
- package/dist_ts_interfaces/requests.d.ts +2 -2
- package/dist_ts_interfaces/requests.fleetworkers.d.ts +3 -1
- package/dist_ts_interfaces/requests.js +1 -1
- package/dist_ts_migration/classes.documentmigrationrunner.d.ts +8 -1
- package/dist_ts_migration/classes.documentmigrationrunner.js +11 -2
- package/dist_ts_migration/index.d.ts +1 -0
- package/dist_ts_migration/index.js +2 -1
- package/dist_ts_migration/v41_ticketclosedcolumn.js +7 -3
- package/dist_ts_migration/v43_ticketorderstride.d.ts +54 -0
- package/dist_ts_migration/v43_ticketorderstride.js +161 -0
- package/docs/authswitch.md +22 -0
- package/package.json +1 -1
- package/readme.md +71 -4
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/aglapi/aglapisurface.document.ts +2 -2
- package/ts/classes.accountsactions.ts +25 -0
- package/ts/classes.authstore.ts +9 -0
- package/ts/classes.controller.ts +37 -3
- package/ts/classes.inferencegateway.ts +6 -4
- package/ts/classes.inferenceplacement.ts +1 -1
- package/ts/classes.inferencerouter.ts +49 -10
- package/ts/classes.inferenceservice.ts +1 -1
- package/ts/classes.mcpcallerregistry.ts +49 -7
- package/ts/classes.terminalcallers.ts +91 -0
- package/ts/classes.terminalmanager.ts +41 -1
- package/ts/classes.ticketnotifier.ts +5 -3
- package/ts/classes.ticketorderspread.ts +50 -0
- package/ts/classes.ticketstore.ts +164 -35
- package/ts/classes.workercallers.ts +183 -30
- package/ts/fleet/classes.boardpump.ts +3 -2
- package/ts/fleet/classes.claudeworkers.ts +101 -29
- package/ts/fleet/classes.ticketeffects.ts +25 -0
- package/ts/fleet/classes.workers.ts +62 -17
- package/ts/fleet/functions.workervalidation.ts +6 -3
- package/ts/fleet/interfaces.workers.ts +16 -2
- package/ts/functions.fleetworkercli.ts +5 -1
- package/ts/functions.inferencecli.ts +2 -0
- package/ts/functions.mcpfleetworkertools.ts +2 -2
- package/ts/functions.proxycapacity.ts +5 -2
- package/ts/functions.proxycapacitycli.ts +1 -1
- package/ts/functions.workerprocessproof.ts +10 -2
- package/ts/interfaces.auth.ts +1 -0
- package/ts/interfaces.flexipc.ts +3 -1
- package/ts_authswitch/authority-contract.ts +20 -0
- package/ts_authswitch/authority-overview.ts +17 -6
- package/ts_authswitch/authority-placement.ts +7 -3
- package/ts_authswitch/classes.authoritybroker.ts +24 -0
- package/ts_authswitch/classes.authoritycli.ts +58 -4
- package/ts_authswitch/classes.authorityclient.ts +11 -4
- package/ts_authswitch/classes.authoritydaemon.ts +8 -1
- package/ts_authswitch/classes.authoritydatabase.ts +3 -0
- package/ts_authswitch/classes.authoritymodels.ts +12 -4
- package/ts_interfaces/fleetworkers.ts +26 -1
- package/ts_interfaces/interfaces.ts +4 -2
- package/ts_interfaces/mcprequests.ts +2 -1
- package/ts_interfaces/proxycapacity.ts +1 -1
- package/ts_interfaces/requests.accounts.ts +17 -0
- package/ts_interfaces/requests.fleetworkers.ts +3 -1
- package/ts_interfaces/requests.ts +2 -0
- package/ts_migration/classes.documentmigrationrunner.ts +12 -1
- package/ts_migration/index.ts +1 -0
- package/ts_migration/v41_ticketclosedcolumn.ts +6 -2
- package/ts_migration/v43_ticketorderstride.ts +156 -0
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/accounts.templates.ts +12 -2
- package/ts_web/classes.accountsreadmodel.ts +42 -6
- package/ts_web/elements.accounts.ts +45 -3
- package/ts_web/elements.harnesscontrollerapp.ts +6 -1
|
@@ -6,15 +6,16 @@ import {
|
|
|
6
6
|
type IWorkerCallerReadiness, type TWorkerCallerEnrollment, type IWorkerCallerEnrollmentResponse,
|
|
7
7
|
type IConfigurationMaster, type IConfigurationMcpStdioServer, type IControllerMcpCaller, type IControllerMcpWireCaller,
|
|
8
8
|
type IWorkerClaudeJobRequest, type TWorkerClaudeJobObservation,
|
|
9
|
-
type IWorkerClaudeProcessRequest, type TWorkerClaudeProcessIdentification,
|
|
9
|
+
type IWorkerClaudeProcessRequest, type TWorkerClaudeProcessIdentification, type IFleetWorkerIdentity,
|
|
10
10
|
} from '../ts_interfaces/index.js';
|
|
11
11
|
import { anonymousControllerMcpCaller, ControllerMcpCallerRegistry } from './classes.mcpcallerregistry.js';
|
|
12
12
|
import {
|
|
13
13
|
resolveWorkerBridgeCommand, resolveClaudeWorkerExecutable, verifyClaudeWorkerProcess, verifyClaudeReleaseProcess,
|
|
14
14
|
readWorkerBridge, verifyWorkerBridge, readWorkerProcessSnapshot, workerSnapshotsEqual, WorkerCallerProofError, WorkerProcessChangedError,
|
|
15
|
-
isWorkerCallerProofRefusal,
|
|
15
|
+
isWorkerCallerProofRefusal, inClaudeReleaseDirectory, proveConnectionProcessAncestry,
|
|
16
16
|
type IWorkerCallerConnection, type IWorkerProcessSnapshot, type IWorkerBridgeCommand,
|
|
17
17
|
} from './functions.workerprocessproof.js';
|
|
18
|
+
import { ControllerTerminalCallers } from './classes.terminalcallers.js';
|
|
18
19
|
import {
|
|
19
20
|
workerCallerDigest, workerProcessSnapshotDigest, type IWorkerCallerBindingStore, type IWorkerCallerBindingProcess,
|
|
20
21
|
type TWorkerCallerBindingRecord,
|
|
@@ -88,9 +89,47 @@ export interface IWorkerProcessRefusal {
|
|
|
88
89
|
nativeSessionId?: string;
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
/**
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Every reason a fleet worker shows as unverified for (`IFleetWorkerIdentity.reason`, AGL-1888): fixed phrases, so the
|
|
94
|
+
* views, the ticket notice and its key never carry error text, a path or an id, and one cause is one notice.
|
|
95
|
+
*/
|
|
96
|
+
export const workerUnverifiedReasons = [
|
|
97
|
+
'the process its bridge runs under runs a Claude Code release that is no longer installed',
|
|
98
|
+
'a fleet wake of its worker is in flight',
|
|
99
|
+
'its worker changed in the fleet while its process was identified',
|
|
100
|
+
'its caller record could not be bound',
|
|
101
|
+
'its worker\'s caller record changed while it was enrolled',
|
|
102
|
+
'the approved Claude Code release cannot be resolved',
|
|
103
|
+
'the process of its Claude job is not an installed Claude Code release',
|
|
104
|
+
'its bridge is not proved to be a direct child of the process of its Claude job',
|
|
105
|
+
] as const;
|
|
106
|
+
export type TWorkerUnverifiedReason = (typeof workerUnverifiedReasons)[number];
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A process enrollment's refusal once the fleet identified the bridge's parent as the process of the worker's job, so
|
|
110
|
+
* checks 1–4 passed: the refused call is the worker's (`refusedWorker`), and its reason one of the fixed phrases.
|
|
111
|
+
*/
|
|
112
|
+
interface IWorkerIdentifiedRefusal extends IWorkerProcessRefusal {
|
|
113
|
+
reason: TWorkerUnverifiedReason;
|
|
114
|
+
workerId: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The outcome of a process enrollment: the bridge's enrollment answer, a refusal (`forGood` when it is remembered for the
|
|
119
|
+
* process's life; `identified` once checks 1–4 passed), or a refusal remembered from before.
|
|
120
|
+
*/
|
|
121
|
+
type TProcessEnrollment = { kind: 'enrolled'; response: IWorkerCallerEnrollmentResponse }
|
|
122
|
+
| { kind: 'refused'; refusal: IWorkerProcessRefusal; forGood: boolean; identified: false }
|
|
123
|
+
| { kind: 'refused'; refusal: IWorkerIdentifiedRefusal; forGood: boolean; identified: true } | { kind: 'remembered' };
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The refused calls of a fleet worker's bridges since its last verified one (AGL-1888): when the first came, and the
|
|
127
|
+
* reason the worker shows as unverified for, once it does.
|
|
128
|
+
*/
|
|
129
|
+
interface IWorkerRefusedCalls {
|
|
130
|
+
since: number;
|
|
131
|
+
shown?: TWorkerUnverifiedReason;
|
|
132
|
+
}
|
|
94
133
|
|
|
95
134
|
/**
|
|
96
135
|
* The outcome of a job re-proof: the launch is bound to the bridge's process, the bridge is refused (or was refused
|
|
@@ -121,6 +160,12 @@ export interface IControllerWorkerCallerOptions {
|
|
|
121
160
|
identifyClaudeProcess?(request: IWorkerClaudeProcessRequest): Promise<TWorkerClaudeProcessIdentification>;
|
|
122
161
|
/** Where the reason a worker enrollment stays pending is written once; the controller log by default. */
|
|
123
162
|
log?(line: string): void;
|
|
163
|
+
/**
|
|
164
|
+
* Told when a fleet worker shows as unverified (`workerCallerIdentity`), each time the reason it shows changes, and
|
|
165
|
+
* when its next verified call or its revocation clears that (`undefined`): the fleet's views follow it, and the fleet
|
|
166
|
+
* notices the worker's ticket.
|
|
167
|
+
*/
|
|
168
|
+
workerIdentityChanged?(workerId: string, identity: IFleetWorkerIdentity | undefined): void;
|
|
124
169
|
}
|
|
125
170
|
|
|
126
171
|
export interface IWorkerCallerProcessProof {
|
|
@@ -131,6 +176,8 @@ export interface IWorkerCallerProcessProof {
|
|
|
131
176
|
readBridge: typeof readWorkerBridge;
|
|
132
177
|
verifyBridge: typeof verifyWorkerBridge;
|
|
133
178
|
readProcess: typeof readWorkerProcessSnapshot;
|
|
179
|
+
/** A caller's process and its parent chain, proved to hold its connection: a terminal's credential is honoured only inside it. */
|
|
180
|
+
proveAncestry: typeof proveConnectionProcessAncestry;
|
|
134
181
|
}
|
|
135
182
|
|
|
136
183
|
const pending = (): IWorkerCallerEnrollmentResponse => ({ callerPending: true, bindingRevision: 0 });
|
|
@@ -140,6 +187,10 @@ const maximumRefusals = 64;
|
|
|
140
187
|
/** Bridge images and parent processes a process enrollment refused, each a key; the oldest give way. */
|
|
141
188
|
const maximumProcessRefusals = 1024;
|
|
142
189
|
const maximumLoggedReasons = 4096;
|
|
190
|
+
/** How long the refused calls of a named worker's bridges run, since its last verified call, before it shows as unverified. */
|
|
191
|
+
const unverifiedAfterMs = 60_000;
|
|
192
|
+
/** Workers whose refused calls are remembered; the oldest give way. */
|
|
193
|
+
const maximumRefusedWorkers = 1024;
|
|
143
194
|
/** A message as a clause of a pending reason, without its final period: the log line ends the sentence. */
|
|
144
195
|
const clause = (messageArg: string): string => messageArg.replace(/\.+$/u, '');
|
|
145
196
|
const proofReason = (errorArg: unknown): string => errorArg instanceof WorkerCallerProofError
|
|
@@ -176,15 +227,20 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
176
227
|
* under it wait for that one read, until the fleet adopts or re-binds a worker.
|
|
177
228
|
*/
|
|
178
229
|
private readonly identifications = new Map<string, { epoch: number; identification: Promise<TWorkerClaudeProcessIdentification> }>();
|
|
230
|
+
/** Per fleet worker, its bridges' refused calls since its last verified one (`refusedWorker`), in memory only. */
|
|
231
|
+
private readonly refusedCalls = new Map<string, IWorkerRefusedCalls>();
|
|
179
232
|
private closed = false;
|
|
180
233
|
private readonly proof: IWorkerCallerProcessProof;
|
|
181
234
|
private readonly log: (lineArg: string) => void;
|
|
235
|
+
/** Who presents a terminal's credential as the terminal: a bridge running inside it, proved at every call (AGL-1891). */
|
|
236
|
+
private readonly terminals: ControllerTerminalCallers;
|
|
182
237
|
|
|
183
238
|
constructor(private readonly options: IControllerWorkerCallerOptions) {
|
|
184
239
|
this.proof = options.processProof ?? { resolveCommand: resolveWorkerBridgeCommand, resolveClaude: resolveClaudeWorkerExecutable,
|
|
185
240
|
verifyClaude: verifyClaudeWorkerProcess, verifyClaudeRelease: verifyClaudeReleaseProcess, readBridge: readWorkerBridge,
|
|
186
|
-
verifyBridge: verifyWorkerBridge, readProcess: readWorkerProcessSnapshot };
|
|
241
|
+
verifyBridge: verifyWorkerBridge, readProcess: readWorkerProcessSnapshot, proveAncestry: proveConnectionProcessAncestry };
|
|
187
242
|
this.log = options.log ?? ((lineArg) => console.warn(lineArg));
|
|
243
|
+
this.terminals = new ControllerTerminalCallers({ registry: options.registry, proveAncestry: this.proof.proveAncestry });
|
|
188
244
|
}
|
|
189
245
|
|
|
190
246
|
public async prepareWorkerCaller(launchArg: TFleetWorkerCallerLaunch): ReturnType<IFleetWorkerCallerHooks['prepareWorkerCaller']> {
|
|
@@ -267,6 +323,8 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
267
323
|
this.refusalEpoch += 1;
|
|
268
324
|
const record = this.workers.get(workerId);
|
|
269
325
|
if (record) this.markRevoked(record);
|
|
326
|
+
// Stopped, archived, re-bound or failed: what its refused calls showed was of the job's process before.
|
|
327
|
+
this.clearRefusedCalls(workerId);
|
|
270
328
|
if (forGood) await this.options.bindings?.delete(workerId);
|
|
271
329
|
return record;
|
|
272
330
|
});
|
|
@@ -302,7 +360,12 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
302
360
|
record = this.challenges.get(requestArg.challenge);
|
|
303
361
|
if (!record || record.binding?.nativeSessionId !== requestArg.nativeThreadId || record.launch.harnessId !== 'codex') return pending();
|
|
304
362
|
} else if (!('nativeThreadId' in requestArg)) {
|
|
305
|
-
|
|
363
|
+
// Without a launch or a thread the bridge calls with the credential it inherited unless a fleet worker's answers it
|
|
364
|
+
// here. An inherited terminal credential is honoured only for a bridge this enrollment proves to run inside that
|
|
365
|
+
// terminal (AGL-1891); a bridge the fleet answers presents the worker's credential instead and is not looked at.
|
|
366
|
+
const response = await this.enrollProcess(requestArg.bridgePid, connectionArg);
|
|
367
|
+
if (response.credential === undefined && !this.closed) await this.terminals.observe(requestArg.bridgePid, connectionArg);
|
|
368
|
+
return response;
|
|
306
369
|
} else {
|
|
307
370
|
record = this.sessions.get(`codex:${requestArg.nativeThreadId}`);
|
|
308
371
|
if (!record || !await this.prove(record, requestArg.bridgePid, connectionArg)) return pending();
|
|
@@ -323,6 +386,11 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
323
386
|
public async admit(wireArg: IControllerMcpWireCaller | undefined, connectionArg?: IWorkerCallerConnection): Promise<IWorkerCallerLease> {
|
|
324
387
|
const caller = this.options.registry.resolve(wireArg?.credential);
|
|
325
388
|
const release = () => undefined;
|
|
389
|
+
// A terminal's credential is inherited by every process started in the terminal, daemons that leave it too: it is
|
|
390
|
+
// honoured only for a bridge that runs inside the terminal, proved for this call (AGL-1891).
|
|
391
|
+
if (caller.subject.kind === 'terminal') {
|
|
392
|
+
return { caller: wireArg ? await this.terminals.admit(wireArg.credential, caller, connectionArg) : anonymousControllerMcpCaller, release };
|
|
393
|
+
}
|
|
326
394
|
if (caller.subject.kind !== 'worker_launch') return { caller, release };
|
|
327
395
|
const subject = caller.subject;
|
|
328
396
|
const record = this.launches.get(subject.launchId);
|
|
@@ -349,6 +417,17 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
349
417
|
});
|
|
350
418
|
}
|
|
351
419
|
|
|
420
|
+
/**
|
|
421
|
+
* Whether the fleet worker `workerIdArg`'s MCP calls run without its identity (AGL-1888): shown once a bridge the
|
|
422
|
+
* fleet identified as the worker's was refused for good, or its refused calls since its last verified one spanned
|
|
423
|
+
* `unverifiedAfterMs`; cleared by its next verified call or its revocation (a stop, an archive, a re-bind). Derived
|
|
424
|
+
* from those calls alone: no timer and no sweep, so a worker that does not call never shows.
|
|
425
|
+
*/
|
|
426
|
+
public workerCallerIdentity(workerIdArg: string): IFleetWorkerIdentity | undefined {
|
|
427
|
+
const refused = this.refusedCalls.get(workerIdArg);
|
|
428
|
+
return refused?.shown === undefined ? undefined : { unverified: true, reason: refused.shown, since: new Date(refused.since).toISOString() };
|
|
429
|
+
}
|
|
430
|
+
|
|
352
431
|
public clearCallerRefusals(): void {
|
|
353
432
|
this.refusalEpoch += 1;
|
|
354
433
|
this.processRefusals.clear();
|
|
@@ -462,12 +541,17 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
462
541
|
if (this.closed) return pending();
|
|
463
542
|
const outcome = await this.identifyProcess(bridgePidArg, connectionArg);
|
|
464
543
|
if (outcome.kind === 'enrolled') return outcome.response;
|
|
465
|
-
if (outcome.kind === 'refused')
|
|
544
|
+
if (outcome.kind === 'refused') {
|
|
545
|
+
this.noteProcessRefusal(outcome.refusal);
|
|
546
|
+
// Only a call the fleet identified as the worker's (checks 1–4 passed) shows it. A refusal the fleet answered for a
|
|
547
|
+
// worker it named (a lost or pending dispatch, its state, its profile home) is on the worker's record already.
|
|
548
|
+
if (outcome.identified) this.refusedWorker(outcome.refusal.workerId, outcome.refusal.reason, outcome.forGood);
|
|
549
|
+
}
|
|
466
550
|
return pending();
|
|
467
551
|
}
|
|
468
552
|
|
|
469
553
|
private async identifyProcess(bridgePidArg: number, connectionArg?: IWorkerCallerConnection): Promise<TProcessEnrollment> {
|
|
470
|
-
const refused = (refusalArg: IWorkerProcessRefusal): TProcessEnrollment => ({ kind: 'refused', refusal: refusalArg });
|
|
554
|
+
const refused = (refusalArg: IWorkerProcessRefusal): TProcessEnrollment => ({ kind: 'refused', refusal: refusalArg, forGood: false, identified: false });
|
|
471
555
|
// The epoch the local proof below begins in; the fleet's identification carries the epoch it began in.
|
|
472
556
|
const started = this.refusalEpoch;
|
|
473
557
|
// The bridge's image and the process it runs under directly, as the kernel shows them; nothing is proved by them yet.
|
|
@@ -501,18 +585,26 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
501
585
|
if (!workerSnapshotsEqual(bridge, image)) return refused({ check: 'bridge', reason: 'its bridge process changed while it was proved' });
|
|
502
586
|
// Remembered only while no adoption, re-bind or revoke happened since the evidence for it began to be read (`epochArg`): one
|
|
503
587
|
// read before may name the registry as it was, and would refuse the session just adopted for the process's life.
|
|
504
|
-
const remember = (forGoodArg: boolean, epochArg: number):
|
|
505
|
-
if (epochArg !== this.refusalEpoch) return;
|
|
588
|
+
const remember = (forGoodArg: boolean, epochArg: number): boolean => {
|
|
589
|
+
if (epochArg !== this.refusalEpoch) return false;
|
|
506
590
|
for (const key of keys) {
|
|
507
591
|
this.processRefusals.delete(key);
|
|
508
592
|
if (this.processRefusals.size >= maximumProcessRefusals) this.processRefusals.delete(this.processRefusals.keys().next().value!);
|
|
509
593
|
this.processRefusals.set(key, forGoodArg ? Number.POSITIVE_INFINITY : Date.now() + transientRefusalMs);
|
|
510
594
|
}
|
|
595
|
+
return true;
|
|
511
596
|
};
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
597
|
+
// A refusal holds for good only once it is remembered for the process's life.
|
|
598
|
+
const refuse = (refusalArg: IWorkerProcessRefusal, forGoodArg: boolean, epochArg: number): TProcessEnrollment => (
|
|
599
|
+
{ kind: 'refused', refusal: refusalArg, forGood: remember(forGoodArg, epochArg) && forGoodArg, identified: false });
|
|
600
|
+
// The parent, read again after the fleet's inventory: it ran unchanged across the read.
|
|
601
|
+
const unchanged = async (): Promise<boolean> => {
|
|
602
|
+
try { return workerSnapshotsEqual(parent, await this.proof.readProcess(parent.pid)); } catch (errorArg) {
|
|
603
|
+
if (!isWorkerCallerProofRefusal(errorArg)) throw errorArg;
|
|
604
|
+
return false;
|
|
605
|
+
}
|
|
515
606
|
};
|
|
607
|
+
const identify = this.options.identifyClaudeProcess;
|
|
516
608
|
// 5. Its parent runs an installed Claude Code release, as `reprove` requires of a job's next process: a local read of
|
|
517
609
|
// the process, before anything of the fleet is read, so a shell or a terminal the bridge runs under is refused for
|
|
518
610
|
// the process's life without an inventory read.
|
|
@@ -527,13 +619,28 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
527
619
|
if (errorArg instanceof WorkerProcessChangedError) {
|
|
528
620
|
return refuse({ check: 'release', reason: 'the process its bridge runs under changed while its release was proved' }, false, started);
|
|
529
621
|
}
|
|
530
|
-
|
|
622
|
+
if (!inClaudeReleaseDirectory(parent.executable, release)) {
|
|
623
|
+
return refuse({ check: 'release', reason: 'the process its bridge runs under is not an installed Claude Code release' }, true, started);
|
|
624
|
+
}
|
|
625
|
+
// A process in the directory of Claude Code's releases whose release file fails the check runs a release removed
|
|
626
|
+
// or replaced since it started: still a Claude job, so the fleet names its worker, for this refusal only (AGL-1888).
|
|
627
|
+
const removed = 'the process its bridge runs under runs a Claude Code release that is no longer installed';
|
|
628
|
+
if (!identify) return refuse({ check: 'release', reason: removed }, true, started);
|
|
629
|
+
const { epoch, identification } = this.identifyOnce(parent, identify);
|
|
630
|
+
const identified = await identification;
|
|
631
|
+
if (!await unchanged()) return refuse({ check: 'release', reason: 'the process its bridge runs under changed while the inventory was read' }, false, epoch);
|
|
632
|
+
if (identified.state === 'identified') {
|
|
633
|
+
return { kind: 'refused', refusal: { check: 'release', reason: removed, workerId: identified.workerId, nativeSessionId: identified.nativeSessionId },
|
|
634
|
+
forGood: remember(true, epoch), identified: true };
|
|
635
|
+
}
|
|
636
|
+
// An inventory that could not name the job yet is asked again after the short wait.
|
|
637
|
+
return refuse({ check: 'release', reason: removed, ...(identified.workerId ? { workerId: identified.workerId } : {}),
|
|
638
|
+
...(identified.nativeSessionId ? { nativeSessionId: identified.nativeSessionId } : {}) }, identified.forGood, epoch);
|
|
531
639
|
}
|
|
532
640
|
if (!workerSnapshotsEqual(job, parent)) {
|
|
533
641
|
return refuse({ check: 'release', reason: 'the process its bridge runs under changed while its release was proved' }, false, started);
|
|
534
642
|
}
|
|
535
643
|
// 3 and 4. One fresh read of the fleet's inventory and registry for every enrollment waiting under this process.
|
|
536
|
-
const identify = this.options.identifyClaudeProcess;
|
|
537
644
|
if (!identify) return refused({ check: 'inventory', reason: 'no fleet identifies the job its bridge runs under' });
|
|
538
645
|
const { epoch, identification } = this.identifyOnce(parent, identify);
|
|
539
646
|
const identified = await identification;
|
|
@@ -542,11 +649,8 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
542
649
|
...(identified.nativeSessionId ? { nativeSessionId: identified.nativeSessionId } : {}) }, identified.forGood, epoch);
|
|
543
650
|
}
|
|
544
651
|
const named = { workerId: identified.workerId, nativeSessionId: identified.nativeSessionId };
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
if (!isWorkerCallerProofRefusal(errorArg)) throw errorArg;
|
|
548
|
-
}
|
|
549
|
-
if (!after || !workerSnapshotsEqual(parent, after)) {
|
|
652
|
+
// Check 3 holds only for a parent that ran unchanged across the read: until then the call is not the worker's.
|
|
653
|
+
if (!await unchanged()) {
|
|
550
654
|
return refuse({ check: 'inventory', reason: 'the process its bridge runs under changed while the inventory was read', ...named }, false, epoch);
|
|
551
655
|
}
|
|
552
656
|
const outcome = await this.enrollIdentified(identified, epoch, job, command, bridgePidArg, connectionArg);
|
|
@@ -565,7 +669,9 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
565
669
|
parentArg: IWorkerProcessSnapshot, commandArg: IWorkerBridgeCommand, bridgePidArg: number,
|
|
566
670
|
connectionArg?: IWorkerCallerConnection): Promise<Exclude<TProcessEnrollment, { kind: 'remembered' }>> {
|
|
567
671
|
const workerId = identifiedArg.workerId;
|
|
568
|
-
|
|
672
|
+
// Every refusal here is the worker's: the fleet identified the bridge's parent as its job's process.
|
|
673
|
+
const refuse = (reasonArg: TWorkerUnverifiedReason): Exclude<TProcessEnrollment, { kind: 'remembered' }> => ({ kind: 'refused',
|
|
674
|
+
refusal: { check: 'record', reason: reasonArg, workerId, nativeSessionId: identifiedArg.nativeSessionId }, forGood: false, identified: true });
|
|
569
675
|
const state = (recordArg: IWorkerLaunch): IWorkerLaunch['state'] => recordArg.state;
|
|
570
676
|
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
571
677
|
const current = this.workers.get(workerId);
|
|
@@ -573,7 +679,7 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
573
679
|
// A record bound for another bridge of the same job right now: its bind runs on the record's chain.
|
|
574
680
|
if (!current.kept && state(current) !== 'bound') await this.serialize(current, async () => undefined);
|
|
575
681
|
if (state(current) === 'prepared' || state(current) === 'quiescing') {
|
|
576
|
-
return
|
|
682
|
+
return refuse('a fleet wake of its worker is in flight');
|
|
577
683
|
}
|
|
578
684
|
if (state(current) === 'bound') {
|
|
579
685
|
const response = await this.enrollClaude(current, bridgePidArg, connectionArg);
|
|
@@ -607,7 +713,7 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
607
713
|
return { record, binding };
|
|
608
714
|
});
|
|
609
715
|
if (created === 'stale') {
|
|
610
|
-
return
|
|
716
|
+
return refuse('its worker changed in the fleet while its process was identified');
|
|
611
717
|
}
|
|
612
718
|
if (!created) {
|
|
613
719
|
if (this.closed) break;
|
|
@@ -615,11 +721,14 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
615
721
|
}
|
|
616
722
|
try { await created.binding; } catch (errorArg) {
|
|
617
723
|
await this.revokeWorkerCaller({ launchId: created.record.launch.launchId, reason: 'failure' });
|
|
618
|
-
|
|
724
|
+
// The store's or the proof's words go to the controller log only; the refusal names the fixed reason.
|
|
725
|
+
this.log(`The caller record of fleet worker ${workerId} (claude:${identifiedArg.nativeSessionId}) could not be bound: `
|
|
726
|
+
+ `${errorArg instanceof Error ? clause(errorArg.message) : 'unknown failure'}.`);
|
|
727
|
+
return refuse('its caller record could not be bound');
|
|
619
728
|
}
|
|
620
729
|
return { kind: 'enrolled', response: await this.enrollClaude(created.record, bridgePidArg, connectionArg) };
|
|
621
730
|
}
|
|
622
|
-
return
|
|
731
|
+
return refuse('its worker\'s caller record changed while it was enrolled');
|
|
623
732
|
}
|
|
624
733
|
|
|
625
734
|
/** The current, verified record of a worker that is bound to `processArg`: the same PID and start. */
|
|
@@ -662,6 +771,41 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
662
771
|
this.log(`The MCP caller of ${subject} stays unverified: ${refusalArg.reason}.`);
|
|
663
772
|
}
|
|
664
773
|
|
|
774
|
+
/**
|
|
775
|
+
* A refused call of a bridge the fleet identified as the worker `workerIdArg`'s (AGL-1888). The worker shows as
|
|
776
|
+
* unverified once a refusal holds for good, or once its refused calls since its last verified one span
|
|
777
|
+
* `unverifiedAfterMs`, and that is told (`workerIdentityChanged`). Once it shows, only a refusal for good for another
|
|
778
|
+
* reason changes the reason it shows and is told again: a refusal that may pass never is, so the owner's own steps
|
|
779
|
+
* (a stop, a wake) write no second notice.
|
|
780
|
+
*/
|
|
781
|
+
private refusedWorker(workerIdArg: string, reasonArg: TWorkerUnverifiedReason, forGoodArg: boolean): void {
|
|
782
|
+
const now = Date.now();
|
|
783
|
+
let refused = this.refusedCalls.get(workerIdArg);
|
|
784
|
+
if (!refused) {
|
|
785
|
+
if (this.refusedCalls.size >= maximumRefusedWorkers) {
|
|
786
|
+
const [oldest, given] = this.refusedCalls.entries().next().value!;
|
|
787
|
+
this.refusedCalls.delete(oldest);
|
|
788
|
+
if (given.shown !== undefined) this.options.workerIdentityChanged?.(oldest, undefined);
|
|
789
|
+
}
|
|
790
|
+
refused = { since: now };
|
|
791
|
+
this.refusedCalls.set(workerIdArg, refused);
|
|
792
|
+
}
|
|
793
|
+
if (refused.shown !== undefined ? (!forGoodArg || refused.shown === reasonArg) : (!forGoodArg && now - refused.since < unverifiedAfterMs)) return;
|
|
794
|
+
refused.shown = reasonArg;
|
|
795
|
+
this.options.workerIdentityChanged?.(workerIdArg, this.workerCallerIdentity(workerIdArg));
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* A verified call of the fleet worker `workerIdArg`, or its revocation (a stop, an archive, a re-bind): its refused
|
|
800
|
+
* calls are forgotten, and it no longer shows as unverified.
|
|
801
|
+
*/
|
|
802
|
+
private clearRefusedCalls(workerIdArg: string): void {
|
|
803
|
+
const refused = this.refusedCalls.get(workerIdArg);
|
|
804
|
+
if (!refused) return;
|
|
805
|
+
this.refusedCalls.delete(workerIdArg);
|
|
806
|
+
if (refused.shown !== undefined) this.options.workerIdentityChanged?.(workerIdArg, undefined);
|
|
807
|
+
}
|
|
808
|
+
|
|
665
809
|
/**
|
|
666
810
|
* Proves the bridge's process to be the current process of the job the launch is bound to, from a fresh inventory the
|
|
667
811
|
* fleet reads, and binds the launch to it at the current revision. A bridge refused for good is remembered for its
|
|
@@ -704,6 +848,12 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
704
848
|
record.refusals.set(key, forGoodArg ? Number.POSITIVE_INFINITY : Date.now() + transientRefusalMs);
|
|
705
849
|
return { kind: 'refused', reason: reasonArg };
|
|
706
850
|
};
|
|
851
|
+
// Refused once the inventory showed the bridge's parent to be the process of the worker's job: the refused call is
|
|
852
|
+
// the worker's (`refusedWorker`), unless its launch was revoked meanwhile (a stop, an archive or a re-bind clears it).
|
|
853
|
+
const refuseNamed = (reasonArg: TWorkerUnverifiedReason, forGoodArg: boolean): TReproof => {
|
|
854
|
+
if (!this.revoked(record)) this.refusedWorker(record.launch.workerId, reasonArg, forGoodArg);
|
|
855
|
+
return refuse(reasonArg, forGoodArg);
|
|
856
|
+
};
|
|
707
857
|
const observed = await observe({ workerId: record.launch.workerId, projectId: record.launch.projectId,
|
|
708
858
|
nativeSessionId: binding.nativeSessionId, jobId: binding.claudeJobId });
|
|
709
859
|
if (observed.state === 'ended') return { kind: 'ended', reason: observed.reason };
|
|
@@ -732,17 +882,17 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
732
882
|
// resolves to now; a job Claude Code continues on the release it started on is the same job (AGL-1888).
|
|
733
883
|
let release: string;
|
|
734
884
|
try { release = await this.proof.resolveClaude(); } catch {
|
|
735
|
-
return
|
|
885
|
+
return refuseNamed('the approved Claude Code release cannot be resolved', false);
|
|
736
886
|
}
|
|
737
887
|
try { parent = await this.proof.verifyClaudeRelease(observed.process, release); } catch (errorArg) {
|
|
738
888
|
if (!isWorkerCallerProofRefusal(errorArg)) throw errorArg;
|
|
739
|
-
return
|
|
889
|
+
return refuseNamed('the process of its Claude job is not an installed Claude Code release', false);
|
|
740
890
|
}
|
|
741
891
|
executable = parent.executable;
|
|
742
892
|
}
|
|
743
893
|
try { await this.proof.verifyBridge(connectionArg, bridge.pid, command, parent, port); } catch (errorArg) {
|
|
744
894
|
if (!isWorkerCallerProofRefusal(errorArg)) throw errorArg;
|
|
745
|
-
return
|
|
895
|
+
return refuseNamed('its bridge is not proved to be a direct child of the process of its Claude job', true);
|
|
746
896
|
}
|
|
747
897
|
record.claudeExecutable = executable;
|
|
748
898
|
try {
|
|
@@ -912,11 +1062,13 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
912
1062
|
if (challengeArg !== undefined) this.clearChallenge(recordArg);
|
|
913
1063
|
const previous = recordArg.credentials.get(bridgePidArg);
|
|
914
1064
|
if (previous && workerSnapshotsEqual(previous.bridge, bridge) && previous.bindingRevision === revision) {
|
|
1065
|
+
this.clearRefusedCalls(recordArg.launch.workerId);
|
|
915
1066
|
return { ...this.getWorkerCallerStatus(recordArg.launch.launchId), credential: previous.credential };
|
|
916
1067
|
}
|
|
917
1068
|
this.clearCredentials(recordArg);
|
|
918
1069
|
await this.drain(recordArg);
|
|
919
|
-
|
|
1070
|
+
// Revoked or bound again while its leases drained: the bridge stays pending, as for any change before.
|
|
1071
|
+
if (this.closed || recordArg.state !== 'bound' || recordArg.revision !== revision) return pending();
|
|
920
1072
|
const credential = this.options.registry.mintWorker({ kind: 'worker_launch', launchId: recordArg.launch.launchId,
|
|
921
1073
|
controllerGeneration: this.options.controllerGeneration, bindingRevision: revision,
|
|
922
1074
|
projectId: recordArg.launch.projectId, harnessId: recordArg.launch.harnessId,
|
|
@@ -925,6 +1077,7 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
925
1077
|
// A worker id is `${projectId}:${name}`: prepared and kept launches are refused otherwise.
|
|
926
1078
|
workerName: recordArg.launch.workerId.slice(recordArg.launch.projectId.length + 1) });
|
|
927
1079
|
recordArg.credentials.set(bridgePidArg, { credential, bridge, bindingRevision: revision });
|
|
1080
|
+
this.clearRefusedCalls(recordArg.launch.workerId);
|
|
928
1081
|
return { ...this.getWorkerCallerStatus(recordArg.launch.launchId), credential };
|
|
929
1082
|
});
|
|
930
1083
|
}
|
|
@@ -6,7 +6,7 @@ import type { IFleetBoardPumpConfiguration, IFleetRepository, IFleetUnboundDrive
|
|
|
6
6
|
import type { IFleetDeployPlan, IFleetDeployStatus, IFleetDeployTargetStatus } from '../../ts_interfaces/deployments.js';
|
|
7
7
|
import type { IFleetEvent } from '../../ts_interfaces/fleetworkers.js';
|
|
8
8
|
import type { IControllerFleetWorkerView } from '../../ts_interfaces/index.js';
|
|
9
|
-
import type
|
|
9
|
+
import { workerIdentityActor, type FleetTicketEffects, type IFleetTicketEffectDocument } from './classes.ticketeffects.js';
|
|
10
10
|
import { quoteAgentMessageHeaderText } from '../functions.agentmessage.js';
|
|
11
11
|
import { unboundDriverLines } from './functions.unbounddrivers.js';
|
|
12
12
|
import { compareFleetVersions, findFleetRepository, fleetRepositorySlug } from './functions.releasefacts.js';
|
|
@@ -113,7 +113,8 @@ const clip = (textArg: string, maximumArg = 32 * 1024): string => {
|
|
|
113
113
|
};
|
|
114
114
|
/** The facts of one history; see `IBoardPumpTicketFacts`. */
|
|
115
115
|
const ticketFacts = ({ ticket, activity, questions }: ITicketHistory): IBoardPumpTicketFacts => {
|
|
116
|
-
|
|
116
|
+
// The pump's own comments and the worker identity notice (AGL-1888) are AGL's, never an answer: neither hides a comment nobody followed.
|
|
117
|
+
const own = (entryArg: ITicketActivity) => entryArg.actor.id === boardPumpActor.id || entryArg.actor.id === workerIdentityActor.id;
|
|
117
118
|
const index = activity.findLastIndex((entryArg) => discussionActions.has(entryArg.action) && !own(entryArg));
|
|
118
119
|
const entry = activity[index];
|
|
119
120
|
const comment = entry && entry.action === 'commented' && entry.actor.role !== 'driver' ? entry.changes.comment?.after as ITicketComment | undefined : undefined;
|