@camstack/server 1.2.196 → 1.2.198
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.
|
@@ -63,6 +63,7 @@ exports.buildSystemProvider = buildSystemProvider;
|
|
|
63
63
|
exports.buildSettingsStoreGateway = buildSettingsStoreGateway;
|
|
64
64
|
exports.buildNetworkQualityProvider = buildNetworkQualityProvider;
|
|
65
65
|
exports.buildToastProvider = buildToastProvider;
|
|
66
|
+
exports.computeTopologyPass = computeTopologyPass;
|
|
66
67
|
exports.computeTopology = computeTopology;
|
|
67
68
|
exports.createNodeRootPackageLookup = createNodeRootPackageLookup;
|
|
68
69
|
exports.buildNodesProvider = buildNodesProvider;
|
|
@@ -254,17 +255,25 @@ function getLocalIps() {
|
|
|
254
255
|
}
|
|
255
256
|
return ips;
|
|
256
257
|
}
|
|
257
|
-
/**
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
258
|
+
/** {@link computeTopology}, keeping the live entries the projection consumed. */
|
|
259
|
+
async function computeTopologyPass(agentRegistry, addonRegistry, getNodeRootPackage) {
|
|
260
|
+
const [nodes, liveNodes] = await computeTopologyInternal(agentRegistry, addonRegistry, getNodeRootPackage);
|
|
261
|
+
return { nodes, liveNodes };
|
|
262
|
+
}
|
|
262
263
|
async function computeTopology(agentRegistry, addonRegistry, getNodeRootPackage) {
|
|
263
|
-
const nodes = await agentRegistry
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
264
|
+
const [nodes] = await computeTopologyInternal(agentRegistry, addonRegistry, getNodeRootPackage);
|
|
265
|
+
return nodes;
|
|
266
|
+
}
|
|
267
|
+
async function computeTopologyInternal(agentRegistry, addonRegistry, getNodeRootPackage) {
|
|
268
|
+
// The live cluster walk and the durable offline-node history read NOTHING
|
|
269
|
+
// from each other, and the history read is one settings-store round trip —
|
|
270
|
+
// measured on the live hub at 14.8–18.3 s while the store is stalled. Awaited
|
|
271
|
+
// one after the other, that made a read cost two store ticks (D317). One
|
|
272
|
+
// wave: the projection below needs both, and neither needs the other.
|
|
273
|
+
const [nodes, history] = await Promise.all([
|
|
274
|
+
agentRegistry.listNodes(),
|
|
275
|
+
agentRegistry.getClusterNodeHistory(),
|
|
276
|
+
]);
|
|
268
277
|
const historyById = new Map(history.map((h) => [h.id, h]));
|
|
269
278
|
const liveIds = new Set(nodes.map((n) => n.info.id));
|
|
270
279
|
const allAddons = addonRegistry?.listAddons() ?? [];
|
|
@@ -432,7 +441,7 @@ async function computeTopology(agentRegistry, addonRegistry, getNodeRootPackage)
|
|
|
432
441
|
categories: [],
|
|
433
442
|
rootPackage: null,
|
|
434
443
|
}));
|
|
435
|
-
return [...liveNodes, ...offlineNodes];
|
|
444
|
+
return [[...liveNodes, ...offlineNodes], nodes];
|
|
436
445
|
}
|
|
437
446
|
/**
|
|
438
447
|
* Build the standard {@link NodeRootPackageLookup}: hub rows come from the
|
|
@@ -5941,6 +5941,15 @@ function createCapRouter_pipelineAnalytics(getProvider, createRemoteProxy) {
|
|
|
5941
5941
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
5942
5942
|
return p.getKeyEvents(methodInput);
|
|
5943
5943
|
}),
|
|
5944
|
+
getKeyEventsBatch: trpc_middleware_js_1.protectedProcedure
|
|
5945
|
+
.input(types_85.pipelineAnalyticsCapability.methods.getKeyEventsBatch.input.loose())
|
|
5946
|
+
.output(types_85.pipelineAnalyticsCapability.methods.getKeyEventsBatch.output)
|
|
5947
|
+
.query(async ({ input, ctx }) => {
|
|
5948
|
+
const { nodeId, ...methodInput } = input;
|
|
5949
|
+
const p = resolveProvider('pipeline-analytics', nodeId, () => getProvider(ctx), createRemoteProxy);
|
|
5950
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
5951
|
+
return p.getKeyEventsBatch(methodInput);
|
|
5952
|
+
}),
|
|
5944
5953
|
getEventDensity: trpc_middleware_js_1.protectedProcedure
|
|
5945
5954
|
.input(types_85.pipelineAnalyticsCapability.methods.getEventDensity.input.loose())
|
|
5946
5955
|
.output(types_85.pipelineAnalyticsCapability.methods.getEventDensity.output)
|
|
@@ -6013,6 +6022,15 @@ function createCapRouter_pipelineAnalytics(getProvider, createRemoteProxy) {
|
|
|
6013
6022
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
6014
6023
|
return p.getEventStoreFootprint(methodInput);
|
|
6015
6024
|
}),
|
|
6025
|
+
getEventMediaFootprintByKind: trpc_middleware_js_1.adminProcedure
|
|
6026
|
+
.input(types_85.pipelineAnalyticsCapability.methods.getEventMediaFootprintByKind.input.loose())
|
|
6027
|
+
.output(types_85.pipelineAnalyticsCapability.methods.getEventMediaFootprintByKind.output)
|
|
6028
|
+
.query(async ({ input, ctx }) => {
|
|
6029
|
+
const { nodeId, ...methodInput } = input;
|
|
6030
|
+
const p = resolveProvider('pipeline-analytics', nodeId, () => getProvider(ctx), createRemoteProxy);
|
|
6031
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
6032
|
+
return p.getEventMediaFootprintByKind(methodInput);
|
|
6033
|
+
}),
|
|
6016
6034
|
pruneEvents: trpc_middleware_js_1.adminProcedure
|
|
6017
6035
|
.input(types_85.pipelineAnalyticsCapability.methods.pruneEvents.input.loose())
|
|
6018
6036
|
.output(types_85.pipelineAnalyticsCapability.methods.pruneEvents.output)
|
|
@@ -7840,6 +7858,15 @@ function createCapRouter_recording(getProvider, createRemoteProxy) {
|
|
|
7840
7858
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
7841
7859
|
return p.getRelocateResidue(methodInput);
|
|
7842
7860
|
}),
|
|
7861
|
+
reconcileLedgerAgainstDisk: trpc_middleware_js_1.adminProcedure
|
|
7862
|
+
.input(types_95.recordingCapability.methods.reconcileLedgerAgainstDisk.input.loose())
|
|
7863
|
+
.output(types_95.recordingCapability.methods.reconcileLedgerAgainstDisk.output)
|
|
7864
|
+
.mutation(async ({ input, ctx }) => {
|
|
7865
|
+
const { nodeId, ...methodInput } = input;
|
|
7866
|
+
const p = resolveProvider('recording', nodeId, () => getProvider(ctx), createRemoteProxy);
|
|
7867
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
7868
|
+
return p.reconcileLedgerAgainstDisk(methodInput);
|
|
7869
|
+
}),
|
|
7843
7870
|
cancelRelocateJob: trpc_middleware_js_1.adminProcedure
|
|
7844
7871
|
.input(types_95.recordingCapability.methods.cancelRelocateJob.input.loose())
|
|
7845
7872
|
.output(types_95.recordingCapability.methods.cancelRelocateJob.output)
|
|
@@ -7956,6 +7983,15 @@ function createCapRouter_sceneMonitor(getProvider, createRemoteProxy) {
|
|
|
7956
7983
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
7957
7984
|
return p.listScenes(methodInput);
|
|
7958
7985
|
}),
|
|
7986
|
+
listScenesBatch: trpc_middleware_js_1.protectedProcedure
|
|
7987
|
+
.input(types_97.sceneMonitorCapability.methods.listScenesBatch.input.loose())
|
|
7988
|
+
.output(types_97.sceneMonitorCapability.methods.listScenesBatch.output)
|
|
7989
|
+
.query(async ({ input, ctx }) => {
|
|
7990
|
+
const { nodeId, ...methodInput } = input;
|
|
7991
|
+
const p = resolveProvider('scene-monitor', nodeId, () => getProvider(ctx), createRemoteProxy);
|
|
7992
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
7993
|
+
return p.listScenesBatch(methodInput);
|
|
7994
|
+
}),
|
|
7959
7995
|
createScene: trpc_middleware_js_1.adminProcedure
|
|
7960
7996
|
.input(types_97.sceneMonitorCapability.methods.createScene.input.loose())
|
|
7961
7997
|
.output(types_97.sceneMonitorCapability.methods.createScene.output)
|
|
@@ -10251,6 +10287,15 @@ function createCapRouter_zoneAnalytics(getProvider, createRemoteProxy) {
|
|
|
10251
10287
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
10252
10288
|
return p.getCurrentSnapshot(methodInput);
|
|
10253
10289
|
}),
|
|
10290
|
+
getCurrentSnapshotBatch: trpc_middleware_js_1.protectedProcedure
|
|
10291
|
+
.input(types_126.zoneAnalyticsCapability.methods.getCurrentSnapshotBatch.input.loose())
|
|
10292
|
+
.output(types_126.zoneAnalyticsCapability.methods.getCurrentSnapshotBatch.output)
|
|
10293
|
+
.query(async ({ input, ctx }) => {
|
|
10294
|
+
const { nodeId, ...methodInput } = input;
|
|
10295
|
+
const p = resolveProvider('zone-analytics', nodeId, () => getProvider(ctx), createRemoteProxy);
|
|
10296
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
10297
|
+
return p.getCurrentSnapshotBatch(methodInput);
|
|
10298
|
+
}),
|
|
10254
10299
|
getZoneHistory: trpc_middleware_js_1.protectedProcedure
|
|
10255
10300
|
.input(types_126.zoneAnalyticsCapability.methods.getZoneHistory.input.loose())
|
|
10256
10301
|
.output(types_126.zoneAnalyticsCapability.methods.getZoneHistory.output)
|
|
@@ -137,6 +137,24 @@ function toDescriptor(entry) {
|
|
|
137
137
|
addonIds: [...(entry.agentAddons ?? [])],
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Narrow one `$process.list` row to the sub-process shape the topology
|
|
142
|
+
* projection reads. `$process.*` is an untyped Moleculer infra boundary; the
|
|
143
|
+
* process-service owns the real `ProcessInfo` shape.
|
|
144
|
+
*/
|
|
145
|
+
function toSubProcess(p) {
|
|
146
|
+
return {
|
|
147
|
+
pid: p.pid ?? 0,
|
|
148
|
+
name: p.name ?? '',
|
|
149
|
+
command: 'moleculer-service',
|
|
150
|
+
state: p.state ?? 'running',
|
|
151
|
+
cpuPercent: p.cpuPercent ?? 0,
|
|
152
|
+
memoryRss: p.memoryRss ?? 0,
|
|
153
|
+
uptimeSeconds: p.uptimeSeconds ?? 0,
|
|
154
|
+
addonIds: p.addonIds ?? [],
|
|
155
|
+
groupId: p.groupId ?? null,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
140
158
|
class AgentRegistryService {
|
|
141
159
|
eventBus;
|
|
142
160
|
moleculer;
|
|
@@ -755,27 +773,6 @@ class AgentRegistryService {
|
|
|
755
773
|
return toNodeLiveness(this.moleculer.broker.registry.getNodeList({ onlyAvailable: false }));
|
|
756
774
|
}
|
|
757
775
|
async listNodes() {
|
|
758
|
-
// Get child processes for hub via $process.list
|
|
759
|
-
let hubProcesses = [];
|
|
760
|
-
try {
|
|
761
|
-
const processes = (await this.broker.call('$process.list'));
|
|
762
|
-
hubProcesses = processes.map((p) => ({
|
|
763
|
-
pid: p.pid ?? 0,
|
|
764
|
-
name: p.name ?? '',
|
|
765
|
-
command: 'moleculer-service',
|
|
766
|
-
state: p.state ?? 'running',
|
|
767
|
-
cpuPercent: p.cpuPercent ?? 0,
|
|
768
|
-
memoryRss: p.memoryRss ?? 0,
|
|
769
|
-
uptimeSeconds: p.uptimeSeconds ?? 0,
|
|
770
|
-
addonIds: p.addonIds ?? [],
|
|
771
|
-
groupId: p.groupId ?? null,
|
|
772
|
-
}));
|
|
773
|
-
}
|
|
774
|
-
catch {
|
|
775
|
-
// $process service may not be ready yet
|
|
776
|
-
}
|
|
777
|
-
const hubEntry = await this.buildHubEntry(hubProcesses);
|
|
778
|
-
const remoteEntries = [];
|
|
779
776
|
const registry = this.moleculer.broker.registry;
|
|
780
777
|
// `onlyAvailable: false` intentionally includes nodes Moleculer still
|
|
781
778
|
// remembers as disconnected (`available: false`) — the same registry
|
|
@@ -786,111 +783,120 @@ class AgentRegistryService {
|
|
|
786
783
|
// row disappears again. A hub-restart-surviving offline history is a
|
|
787
784
|
// separate, deliberately deferred piece of work.
|
|
788
785
|
const nodes = registry?.getNodeList?.({ onlyAvailable: false }) ?? [];
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
//
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
nodeID: nodeId,
|
|
813
|
-
timeout: 5000,
|
|
814
|
-
}));
|
|
815
|
-
subProcesses = processes.map((p) => ({
|
|
816
|
-
pid: p.pid ?? 0,
|
|
817
|
-
name: p.name ?? '',
|
|
818
|
-
command: 'moleculer-service',
|
|
819
|
-
state: p.state ?? 'running',
|
|
820
|
-
cpuPercent: p.cpuPercent ?? 0,
|
|
821
|
-
memoryRss: p.memoryRss ?? 0,
|
|
822
|
-
uptimeSeconds: p.uptimeSeconds ?? 0,
|
|
823
|
-
addonIds: p.addonIds ?? [],
|
|
824
|
-
groupId: p.groupId ?? null,
|
|
825
|
-
}));
|
|
826
|
-
}
|
|
827
|
-
catch {
|
|
828
|
-
// Fall back to addon list from $agent.status (no stats)
|
|
829
|
-
subProcesses =
|
|
830
|
-
status.addons?.map((a) => ({
|
|
831
|
-
pid: 0,
|
|
832
|
-
name: a.id ?? '',
|
|
833
|
-
command: 'moleculer-service',
|
|
834
|
-
state: (a.status ?? 'running'),
|
|
835
|
-
cpuPercent: 0,
|
|
836
|
-
memoryRss: 0,
|
|
837
|
-
uptimeSeconds: 0,
|
|
838
|
-
})) ?? [];
|
|
839
|
-
}
|
|
840
|
-
// Extract addon IDs from $agent.status
|
|
841
|
-
const agentAddons = status.addons?.map((a) => a.id) ?? [];
|
|
842
|
-
const hostname = typeof status.hostname === 'string' ? status.hostname : null;
|
|
843
|
-
const agentName = typeof status.name === 'string' ? status.name : nodeId;
|
|
844
|
-
remoteEntries.push({
|
|
845
|
-
info: {
|
|
846
|
-
id: nodeId,
|
|
847
|
-
name: agentName,
|
|
848
|
-
hostname: hostname ?? nodeId,
|
|
849
|
-
capabilities: [],
|
|
850
|
-
platform: status.platform ?? 'unknown',
|
|
851
|
-
arch: status.arch ?? 'unknown',
|
|
852
|
-
cpuCores: status.cpuCores ?? 0,
|
|
853
|
-
memoryMB: status.totalMemoryMB ?? 0,
|
|
854
|
-
cpuModel: status.cpuModel,
|
|
855
|
-
},
|
|
856
|
-
localIps: Array.isArray(status.localIps) ? status.localIps : [],
|
|
857
|
-
status: {
|
|
858
|
-
activeCameras: 0,
|
|
859
|
-
cpuPercent: status.cpuPercent ?? 0,
|
|
860
|
-
memoryPercent: status.memoryPercent ?? 0,
|
|
861
|
-
fps: {},
|
|
862
|
-
errors: [],
|
|
863
|
-
},
|
|
864
|
-
connectedSince: typeof status.uptime === 'number'
|
|
865
|
-
? Date.now() - status.uptime * 1000
|
|
866
|
-
: Date.now(),
|
|
867
|
-
isHub: false,
|
|
868
|
-
subProcesses,
|
|
869
|
-
agentAddons,
|
|
870
|
-
});
|
|
871
|
-
}
|
|
872
|
-
catch {
|
|
873
|
-
// Skip nodes without $agent service
|
|
874
|
-
}
|
|
786
|
+
// Every node's legs are INDEPENDENT of every other node's, and the hub's
|
|
787
|
+
// own legs are independent of both. Walking them with `await` in a `for`
|
|
788
|
+
// made one read cost the sum of the cluster; they are one wave now
|
|
789
|
+
// (D317). Each leg still fails closed on its own — `allSettled` semantics
|
|
790
|
+
// are preserved by the per-node `catch` inside `buildRemoteEntry`.
|
|
791
|
+
const remoteTargets = nodes.filter((node) => typeof node.id === 'string' && node.id !== 'hub' && !node.id.includes('/'));
|
|
792
|
+
const [hubEntry, remoteEntries] = await Promise.all([
|
|
793
|
+
this.listHubProcesses().then((procs) => this.buildHubEntry(procs)),
|
|
794
|
+
Promise.all(remoteTargets.map((node) => node.available
|
|
795
|
+
? // Online: one wave of `$agent.status` + `$process.list`.
|
|
796
|
+
this.buildRemoteEntry(node.id)
|
|
797
|
+
: // Offline: skip the RPC fan-out entirely (the node is unreachable —
|
|
798
|
+
// those calls would just time out) and surface a minimal,
|
|
799
|
+
// honestly-degraded row instead.
|
|
800
|
+
Promise.resolve(this.buildOfflineEntry(node)))),
|
|
801
|
+
]);
|
|
802
|
+
return [hubEntry, ...remoteEntries.filter((entry) => entry !== null)];
|
|
803
|
+
}
|
|
804
|
+
/** The hub's own runner subprocesses (`$process.list`, hub-local). */
|
|
805
|
+
async listHubProcesses() {
|
|
806
|
+
try {
|
|
807
|
+
const processes = (await this.broker.call('$process.list'));
|
|
808
|
+
return processes.map(toSubProcess);
|
|
875
809
|
}
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
810
|
+
catch {
|
|
811
|
+
// $process service may not be ready yet
|
|
812
|
+
return [];
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* One online agent's row: `$agent.status` for the descriptor + live metrics,
|
|
817
|
+
* `$process.list` for real sub-process stats. `null` when the node has no
|
|
818
|
+
* `$agent` service (it is then simply absent from the list, as before).
|
|
819
|
+
*
|
|
820
|
+
* The two calls are ONE wave, not two: `$process.list` never reads anything
|
|
821
|
+
* from `$agent.status` — only its FALLBACK does, and the fallback is applied
|
|
822
|
+
* after both have settled.
|
|
823
|
+
*/
|
|
824
|
+
async buildRemoteEntry(nodeId) {
|
|
825
|
+
const [statusResult, processResult] = await Promise.allSettled([
|
|
826
|
+
this.broker.call('$agent.status', {}, { nodeID: nodeId, timeout: 5000 }),
|
|
827
|
+
this.broker.call('$process.list', {}, { nodeID: nodeId, timeout: 5000 }),
|
|
828
|
+
]);
|
|
829
|
+
// No `$agent` service — skip the node, exactly as the sequential loop did.
|
|
830
|
+
if (statusResult.status === 'rejected')
|
|
831
|
+
return null;
|
|
832
|
+
const status = statusResult.value;
|
|
833
|
+
const subProcesses = processResult.status === 'fulfilled'
|
|
834
|
+
? processResult.value.map(toSubProcess)
|
|
835
|
+
: // Fall back to the addon list from $agent.status (no stats)
|
|
836
|
+
(status.addons?.map((a) => ({
|
|
837
|
+
pid: 0,
|
|
838
|
+
name: a.id ?? '',
|
|
839
|
+
command: 'moleculer-service',
|
|
840
|
+
state: (a.status ?? 'running'),
|
|
841
|
+
cpuPercent: 0,
|
|
842
|
+
memoryRss: 0,
|
|
843
|
+
uptimeSeconds: 0,
|
|
844
|
+
})) ?? []);
|
|
845
|
+
// Extract addon IDs from $agent.status
|
|
846
|
+
const agentAddons = status.addons?.map((a) => a.id) ?? [];
|
|
847
|
+
const hostname = typeof status.hostname === 'string' ? status.hostname : null;
|
|
848
|
+
const agentName = typeof status.name === 'string' ? status.name : nodeId;
|
|
849
|
+
return {
|
|
850
|
+
info: {
|
|
851
|
+
id: nodeId,
|
|
852
|
+
name: agentName,
|
|
853
|
+
hostname: hostname ?? nodeId,
|
|
854
|
+
capabilities: [],
|
|
855
|
+
platform: status.platform ?? 'unknown',
|
|
856
|
+
arch: status.arch ?? 'unknown',
|
|
857
|
+
cpuCores: status.cpuCores ?? 0,
|
|
858
|
+
memoryMB: status.totalMemoryMB ?? 0,
|
|
859
|
+
cpuModel: status.cpuModel,
|
|
860
|
+
},
|
|
861
|
+
localIps: Array.isArray(status.localIps) ? status.localIps : [],
|
|
862
|
+
status: {
|
|
863
|
+
activeCameras: 0,
|
|
864
|
+
cpuPercent: status.cpuPercent ?? 0,
|
|
865
|
+
memoryPercent: status.memoryPercent ?? 0,
|
|
866
|
+
fps: {},
|
|
867
|
+
errors: [],
|
|
868
|
+
},
|
|
869
|
+
connectedSince: typeof status.uptime === 'number'
|
|
870
|
+
? Date.now() - status.uptime * 1000
|
|
871
|
+
: Date.now(),
|
|
872
|
+
isHub: false,
|
|
873
|
+
subProcesses,
|
|
874
|
+
agentAddons,
|
|
875
|
+
};
|
|
887
876
|
}
|
|
888
877
|
/**
|
|
889
|
-
*
|
|
890
|
-
*
|
|
891
|
-
*
|
|
878
|
+
* A1 (R2 capture point): snapshot every ONLINE node's static descriptor +
|
|
879
|
+
* last-known addon roster into the durable, routing-blind history store.
|
|
880
|
+
* This is the ONLY place cpuModel/cores/memory/localIps are resolved from a
|
|
881
|
+
* live `$agent.status`, so it is where an offline row's descriptor must be
|
|
882
|
+
* captured while the node is still reachable. Offline entries are NOT
|
|
883
|
+
* re-snapshotted — their `lastActive` is stamped on `$node.disconnected`
|
|
884
|
+
* instead. This is a separate durable store, never a `knownAgents`-style
|
|
885
|
+
* shadow of `HubNodeRegistry` (which stays the ephemeral live cap authority).
|
|
886
|
+
*
|
|
887
|
+
* **It belongs to the PERIODIC PASS, not to a read** (D317). It used to run
|
|
888
|
+
* at the tail of `listNodes()`, which made every operator poll of
|
|
889
|
+
* `nodes.topology` perform one durable read-back — and, past the five-minute
|
|
890
|
+
* heartbeat, one durable write — per online node, in a phase that had to
|
|
891
|
+
* finish before the history read could even start. Measured on the live hub
|
|
892
|
+
* on 2026-08-31: one settings-store round trip cost 14.8–18.3 s and
|
|
893
|
+
* `nodes.topology` cost exactly two of them, 30.5 s. `TopologyEmitterService`
|
|
894
|
+
* already recomputes this picture every 30 s; the capture is its work.
|
|
895
|
+
*
|
|
896
|
+
* Never throws — the store swallows its own errors and this awaits
|
|
897
|
+
* `allSettled` so a storage hiccup can never fail the pass.
|
|
892
898
|
*/
|
|
893
|
-
async
|
|
899
|
+
async captureNodeHistory(entries) {
|
|
894
900
|
if (!this.historyStore)
|
|
895
901
|
return;
|
|
896
902
|
const online = entries.filter((e) => e.isOnline !== false);
|
|
@@ -89,7 +89,7 @@ class TopologyEmitterService {
|
|
|
89
89
|
return;
|
|
90
90
|
this.emitting = true;
|
|
91
91
|
try {
|
|
92
|
-
const nodes = await (0, cap_providers_1.
|
|
92
|
+
const { nodes, liveNodes } = await (0, cap_providers_1.computeTopologyPass)(this.agentRegistry, this.addonRegistry, this.getNodeRootPackage);
|
|
93
93
|
this.eventBus.emit({
|
|
94
94
|
id: (0, node_crypto_1.randomUUID)(),
|
|
95
95
|
timestamp: new Date(),
|
|
@@ -97,6 +97,12 @@ class TopologyEmitterService {
|
|
|
97
97
|
category: types_1.EventCategory.ClusterTopologySnapshot,
|
|
98
98
|
data: { nodes, timestamp: Date.now() },
|
|
99
99
|
});
|
|
100
|
+
// The durable capture rides THIS pass, not an operator's read (D317).
|
|
101
|
+
// This service is the periodic observer of the cluster; persisting each
|
|
102
|
+
// online node's descriptor — so it can still be rendered OFFLINE later —
|
|
103
|
+
// is that observation's durable half. It runs AFTER the emit so a stalled
|
|
104
|
+
// settings-store delays nothing a subscriber is waiting for.
|
|
105
|
+
await this.agentRegistry.captureNodeHistory(liveNodes);
|
|
100
106
|
}
|
|
101
107
|
catch {
|
|
102
108
|
// Best-effort observability path. Next lifecycle event or the
|