@camstack/server 1.2.153 → 1.2.155
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.
|
@@ -678,8 +678,7 @@ class AddonRegistryService {
|
|
|
678
678
|
// excluded from the plan (filtered inside `buildAddonGroupPlan`) — except
|
|
679
679
|
// a builtin declaring `execution.isolate`, which is spawned in two
|
|
680
680
|
// waves (infra isolates BEFORE in-process builtins, consumers AFTER —
|
|
681
|
-
// see `partitionIsolatedBuiltinIds` and
|
|
682
|
-
// calls).
|
|
681
|
+
// see `partitionIsolatedBuiltinIds` and `runHubAddonBoot`).
|
|
683
682
|
// A failed runner spawn is logged and the addon surfaces as
|
|
684
683
|
// `addon.error` — there is NO in-process-on-the-hub fallback (it
|
|
685
684
|
// would violate one-addon-one-process). Retry policy for a failed
|
|
@@ -690,7 +689,7 @@ class AddonRegistryService {
|
|
|
690
689
|
// the iteration order — while each one costs a fork plus a full addon
|
|
691
690
|
// bundle evaluated on the hub's event loop. Serially that was ~4 s of the
|
|
692
691
|
// measured 10 s kernel boot and grew with every addon shipped. The ordering
|
|
693
|
-
// that IS load-bearing is BETWEEN the
|
|
692
|
+
// that IS load-bearing is BETWEEN the waves in `runHubAddonBoot`, not
|
|
694
693
|
// inside one.
|
|
695
694
|
const spawnRunnerPlan = async (plan) => {
|
|
696
695
|
await (0, runner_spawn_fanout_js_1.spawnPlanConcurrently)(plan, async (runnerId, runnerAddons) => {
|
|
@@ -730,45 +729,6 @@ class AddonRegistryService {
|
|
|
730
729
|
const entry = this.addonEntries.get(id);
|
|
731
730
|
return entry?.declaredCapabilities ?? [];
|
|
732
731
|
});
|
|
733
|
-
if (isolatedInfraIds.length > 0) {
|
|
734
|
-
this.logger.info('Spawning isolated infrastructure builtins', {
|
|
735
|
-
meta: { addonIds: isolatedInfraIds },
|
|
736
|
-
});
|
|
737
|
-
await spawnRunnerPlan(this.buildAddonGroupPlan(isolatedInfraIds));
|
|
738
|
-
}
|
|
739
|
-
await spawnRunnerPlan(this.buildAddonGroupPlan(allIds.filter((id) => !isolatedBuiltins.has(id))));
|
|
740
|
-
// Spawn returns when the child process exists. The UDS handshake that
|
|
741
|
-
// puts `data-store-provider` in this process's `getCollection` lands
|
|
742
|
-
// on a later tick — waiting immediately after the infra spawn (1.2.151)
|
|
743
|
-
// deadlocked: onModuleInit never yielded to the UDS read, the 30 s
|
|
744
|
-
// timeout aborted bootstrap, the starter crash-looped. The general
|
|
745
|
-
// spawn plan above is a sequence of `await`s, so the handshake can
|
|
746
|
-
// land; this wait is the remainder. A timeout must NOT throw: aborting
|
|
747
|
-
// boot is a crash loop, and the in-process builtins then skip the
|
|
748
|
-
// empty door the same way 1.2.150 did.
|
|
749
|
-
if (isolatedInfraIds.length > 0) {
|
|
750
|
-
try {
|
|
751
|
-
await (0, system_1.waitUntilReady)(() => this.capabilityRegistry.getCollection('data-store-provider').length > 0, {
|
|
752
|
-
timeoutMs: 30_000,
|
|
753
|
-
intervalMs: 50,
|
|
754
|
-
what: 'isolated data-store-provider engine',
|
|
755
|
-
});
|
|
756
|
-
}
|
|
757
|
-
catch (err) {
|
|
758
|
-
this.logger.error('Isolated data-store-provider engine did not register in time', {
|
|
759
|
-
meta: { error: (0, types_1.errMsg)(err), addonIds: isolatedInfraIds },
|
|
760
|
-
});
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
// In-process boot for `@camstack/system` builtins. Core builtins stay
|
|
764
|
-
// resident on the hub process — they provide the storage / settings
|
|
765
|
-
// / logging infrastructure every forked runner depends on, reachable
|
|
766
|
-
// via the hub broker, so `buildAddonGroupPlan` excludes them from
|
|
767
|
-
// the runner plan above. They boot in two ordered passes:
|
|
768
|
-
// infrastructure caps first (`INFRA_CAPABILITIES`,
|
|
769
|
-
// storage→settings→logging), then the remaining builtins in
|
|
770
|
-
// capability-dependency order.
|
|
771
|
-
//
|
|
772
732
|
// A core builtin is identified by `packageName === "@camstack/system"`,
|
|
773
733
|
// NOT by the absence of an `execution` declaration — a builtin may
|
|
774
734
|
// still declare `execution` (e.g. `platform-probe`); the package
|
|
@@ -778,102 +738,141 @@ class AddonRegistryService {
|
|
|
778
738
|
// failure surfaces as `addon.error`; quietly running the addon on the hub
|
|
779
739
|
// instead would defeat the isolation on exactly the day it is needed.
|
|
780
740
|
const isCoreBuiltin = (id) => this.addonEntries.get(id)?.packageName === '@camstack/system' && !isolatedBuiltins.has(id);
|
|
781
|
-
//
|
|
782
|
-
//
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
if (
|
|
791
|
-
|
|
741
|
+
// Order is load-bearing (D234): forked addons `resolveConfig()` against
|
|
742
|
+
// the settings door. Spawn them before the engine is in `getCollection`
|
|
743
|
+
// and the door has booted and they initialise from constructor defaults
|
|
744
|
+
// — cloudflare-tunnel then auto-starts a quick tunnel while notifications
|
|
745
|
+
// still mint the named hostname (Cloudflare 530, 2026-08-25).
|
|
746
|
+
// `runHubAddonBoot` is the only sequence; a timeout on the engine wait
|
|
747
|
+
// must NOT throw (1.2.151 crash-looped the starter).
|
|
748
|
+
await (0, system_1.runHubAddonBoot)({
|
|
749
|
+
spawnIsolatedInfra: async () => {
|
|
750
|
+
if (isolatedInfraIds.length === 0)
|
|
751
|
+
return;
|
|
752
|
+
this.logger.info('Spawning isolated infrastructure builtins', {
|
|
753
|
+
meta: { addonIds: isolatedInfraIds },
|
|
754
|
+
});
|
|
755
|
+
await spawnRunnerPlan(this.buildAddonGroupPlan(isolatedInfraIds));
|
|
756
|
+
},
|
|
757
|
+
waitForDataStoreProvider: async () => {
|
|
758
|
+
if (isolatedInfraIds.length === 0)
|
|
759
|
+
return;
|
|
792
760
|
try {
|
|
793
|
-
await this.
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
const msg = (0, types_1.errMsg)(error);
|
|
798
|
-
this.emitAddonLifecycleEvent('addon.error', addonId, {
|
|
799
|
-
error: msg,
|
|
800
|
-
phase: 'init',
|
|
801
|
-
});
|
|
802
|
-
if (infra.required) {
|
|
803
|
-
throw new Error(`Required infrastructure addon "${addonId}" failed: ${msg}`, {
|
|
804
|
-
cause: error,
|
|
805
|
-
});
|
|
806
|
-
}
|
|
807
|
-
this.logger.warn('Optional infra addon failed -- continuing', {
|
|
808
|
-
tags: { addonId },
|
|
809
|
-
meta: { error: msg },
|
|
761
|
+
await (0, system_1.waitUntilReady)(() => this.capabilityRegistry.getCollection('data-store-provider').length > 0, {
|
|
762
|
+
timeoutMs: 30_000,
|
|
763
|
+
intervalMs: 50,
|
|
764
|
+
what: 'isolated data-store-provider engine',
|
|
810
765
|
});
|
|
811
766
|
}
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
// Pass 2 — remaining core builtins, in capability-dependency order.
|
|
818
|
-
const bootOrder = this.capabilityRegistry.getBootOrder();
|
|
819
|
-
const infraNames = new Set(system_1.INFRA_CAPABILITIES.map((c) => c.name));
|
|
820
|
-
for (const capName of bootOrder) {
|
|
821
|
-
if (infraNames.has(capName))
|
|
822
|
-
continue; // Handled in pass 1
|
|
823
|
-
for (const id of allIds) {
|
|
824
|
-
const entry = this.addonEntries.get(id);
|
|
825
|
-
if (!entry || entry.initialized || !isCoreBuiltin(id))
|
|
826
|
-
continue;
|
|
827
|
-
// Check if this addon provides this capability
|
|
828
|
-
const provides = this.getAddonCapabilities(entry.addon);
|
|
829
|
-
if (!provides.some((c) => c.name === capName))
|
|
830
|
-
continue;
|
|
831
|
-
try {
|
|
832
|
-
await this.initializeAddon(id);
|
|
833
|
-
this.wireCapabilities(id);
|
|
834
|
-
}
|
|
835
|
-
catch (error) {
|
|
836
|
-
const msg = (0, types_1.errMsg)(error);
|
|
837
|
-
this.emitAddonLifecycleEvent('addon.error', id, {
|
|
838
|
-
error: msg,
|
|
839
|
-
phase: 'init',
|
|
840
|
-
});
|
|
841
|
-
this.logger.error('Core builtin failed to initialize -- skipping', {
|
|
842
|
-
tags: { addonId: id },
|
|
843
|
-
meta: { error: msg },
|
|
767
|
+
catch (err) {
|
|
768
|
+
this.logger.error('Isolated data-store-provider engine did not register in time', {
|
|
769
|
+
meta: { error: (0, types_1.errMsg)(err), addonIds: isolatedInfraIds },
|
|
844
770
|
});
|
|
845
771
|
}
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
772
|
+
},
|
|
773
|
+
bootInProcessInfra: async () => {
|
|
774
|
+
// Pass 1 — infrastructure builtins. A failed REQUIRED infra cap
|
|
775
|
+
// aborts boot: nothing downstream can run without storage/settings.
|
|
776
|
+
for (const infra of system_1.INFRA_CAPABILITIES) {
|
|
777
|
+
const addonId = this.findAddonForCapability(infra.name, allIds);
|
|
778
|
+
if (addonId) {
|
|
779
|
+
const entry = this.addonEntries.get(addonId);
|
|
780
|
+
// Only core builtins boot in-process here. A non-core addon that
|
|
781
|
+
// happens to provide an infra cap (e.g. an alternate
|
|
782
|
+
// storage-provider) lives in its own runner — never in-process.
|
|
783
|
+
if (!entry || entry.initialized || !isCoreBuiltin(addonId))
|
|
784
|
+
continue;
|
|
785
|
+
try {
|
|
786
|
+
await this.initializeAddon(addonId);
|
|
787
|
+
this.wireCapabilities(addonId);
|
|
788
|
+
}
|
|
789
|
+
catch (error) {
|
|
790
|
+
const msg = (0, types_1.errMsg)(error);
|
|
791
|
+
this.emitAddonLifecycleEvent('addon.error', addonId, {
|
|
792
|
+
error: msg,
|
|
793
|
+
phase: 'init',
|
|
794
|
+
});
|
|
795
|
+
if (infra.required) {
|
|
796
|
+
throw new Error(`Required infrastructure addon "${addonId}" failed: ${msg}`, {
|
|
797
|
+
cause: error,
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
this.logger.warn('Optional infra addon failed -- continuing', {
|
|
801
|
+
tags: { addonId },
|
|
802
|
+
meta: { error: msg },
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
else if (infra.required) {
|
|
807
|
+
throw new Error(`No addon provides required infrastructure capability "${infra.name}"`);
|
|
808
|
+
}
|
|
855
809
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
810
|
+
},
|
|
811
|
+
spawnForkedAddons: async () => {
|
|
812
|
+
await spawnRunnerPlan(this.buildAddonGroupPlan(allIds.filter((id) => !isolatedBuiltins.has(id))));
|
|
813
|
+
},
|
|
814
|
+
bootInProcessConsumers: async () => {
|
|
815
|
+
// Pass 2 — remaining core builtins, in capability-dependency order.
|
|
816
|
+
const bootOrder = this.capabilityRegistry.getBootOrder();
|
|
817
|
+
const infraNames = new Set(system_1.INFRA_CAPABILITIES.map((c) => c.name));
|
|
818
|
+
for (const capName of bootOrder) {
|
|
819
|
+
if (infraNames.has(capName))
|
|
820
|
+
continue; // Handled in pass 1
|
|
821
|
+
for (const id of allIds) {
|
|
822
|
+
const entry = this.addonEntries.get(id);
|
|
823
|
+
if (!entry || entry.initialized || !isCoreBuiltin(id))
|
|
824
|
+
continue;
|
|
825
|
+
const provides = this.getAddonCapabilities(entry.addon);
|
|
826
|
+
if (!provides.some((c) => c.name === capName))
|
|
827
|
+
continue;
|
|
828
|
+
try {
|
|
829
|
+
await this.initializeAddon(id);
|
|
830
|
+
this.wireCapabilities(id);
|
|
831
|
+
}
|
|
832
|
+
catch (error) {
|
|
833
|
+
const msg = (0, types_1.errMsg)(error);
|
|
834
|
+
this.emitAddonLifecycleEvent('addon.error', id, {
|
|
835
|
+
error: msg,
|
|
836
|
+
phase: 'init',
|
|
837
|
+
});
|
|
838
|
+
this.logger.error('Core builtin failed to initialize -- skipping', {
|
|
839
|
+
tags: { addonId: id },
|
|
840
|
+
meta: { error: msg },
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
}
|
|
866
844
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
845
|
+
// Pass 3 — core builtins that declare no capabilities at all.
|
|
846
|
+
for (const id of allIds) {
|
|
847
|
+
const entry = this.addonEntries.get(id);
|
|
848
|
+
if (entry && !entry.initialized && isCoreBuiltin(id)) {
|
|
849
|
+
try {
|
|
850
|
+
await this.initializeAddon(id);
|
|
851
|
+
this.wireCapabilities(id);
|
|
852
|
+
}
|
|
853
|
+
catch (error) {
|
|
854
|
+
const msg = (0, types_1.errMsg)(error);
|
|
855
|
+
this.emitAddonLifecycleEvent('addon.error', id, {
|
|
856
|
+
error: msg,
|
|
857
|
+
phase: 'init',
|
|
858
|
+
});
|
|
859
|
+
this.logger.error('Core builtin failed to initialize -- skipping', {
|
|
860
|
+
tags: { addonId: id },
|
|
861
|
+
meta: { error: msg },
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
},
|
|
867
|
+
spawnIsolatedConsumers: async () => {
|
|
868
|
+
if (isolatedConsumerIds.length === 0)
|
|
869
|
+
return;
|
|
870
|
+
this.logger.info('Spawning isolated system builtins', {
|
|
871
|
+
meta: { addonIds: isolatedConsumerIds },
|
|
872
|
+
});
|
|
873
|
+
await spawnRunnerPlan(this.buildAddonGroupPlan(isolatedConsumerIds));
|
|
874
|
+
},
|
|
875
|
+
});
|
|
877
876
|
const initializedIds = [...this.addonEntries.entries()]
|
|
878
877
|
.filter(([, e]) => e.initialized)
|
|
879
878
|
.map(([id]) => id);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MoleculerService = void 0;
|
|
3
|
+
exports.ChildManifestGate = exports.CHILD_MANIFEST_SKIP_SAMPLE = exports.MoleculerService = void 0;
|
|
4
4
|
exports.childOwnerToken = childOwnerToken;
|
|
5
5
|
exports.buildChildUdsManifest = buildChildUdsManifest;
|
|
6
6
|
const node_crypto_1 = require("node:crypto");
|
|
7
7
|
const system_1 = require("@camstack/system");
|
|
8
8
|
const types_1 = require("@camstack/types");
|
|
9
|
-
const agent_readiness_pull_js_1 = require("./agent-readiness-pull.js");
|
|
10
9
|
const cap_router_runtime_js_1 = require("../../api/trpc/cap-router-runtime.js");
|
|
11
10
|
const core_cap_bridge_js_1 = require("../../api/trpc/core-cap-bridge.js");
|
|
11
|
+
const agent_readiness_pull_js_1 = require("./agent-readiness-pull.js");
|
|
12
12
|
const cap_call_fn_js_1 = require("./cap-call-fn.js");
|
|
13
13
|
const cap_route_authority_js_1 = require("./cap-route-authority.js");
|
|
14
14
|
class MoleculerService {
|
|
@@ -43,6 +43,12 @@ class MoleculerService {
|
|
|
43
43
|
* See `docs/decisions/adr-0188-an-unregister-carries-proof-of-ownership.md`.
|
|
44
44
|
*/
|
|
45
45
|
nodeOwners = new Map();
|
|
46
|
+
/**
|
|
47
|
+
* Skips the manifest rebuild for a child re-register that carries nothing new
|
|
48
|
+
* — 246 of them in 30 minutes with zero respawns, measured live 2026-08-25.
|
|
49
|
+
* See {@link ChildManifestGate}.
|
|
50
|
+
*/
|
|
51
|
+
childManifestGate = new ChildManifestGate();
|
|
46
52
|
/**
|
|
47
53
|
* Fixed-period agent-readiness snapshot sweep (D8 reconcile) — repairs
|
|
48
54
|
* agent-origin readiness deltas lost while the agent stayed connected.
|
|
@@ -421,6 +427,25 @@ class MoleculerService {
|
|
|
421
427
|
const hubNodeId = this.brokerSafe.nodeID;
|
|
422
428
|
const childNodeId = `${hubNodeId}/${child.childId}`;
|
|
423
429
|
const params = buildChildUdsManifest(childNodeId, child.childId, child.caps);
|
|
430
|
+
// `updateCaps()` re-sends the whole register frame on the same socket,
|
|
431
|
+
// so this fires far more often than a runner starts: 246 rebuilds in 30
|
|
432
|
+
// minutes with zero respawns, measured live. A re-register that carries
|
|
433
|
+
// the same incarnation AND the same manifest has nothing to apply — see
|
|
434
|
+
// ChildManifestGate for why it takes both, and why skipping on either
|
|
435
|
+
// one alone is wrong.
|
|
436
|
+
if (!this.childManifestGate.shouldApply(child.childId, child.incarnation, params)) {
|
|
437
|
+
if (this.childManifestGate.sampleDue()) {
|
|
438
|
+
logger.debug('UDS child re-registered with an unchanged manifest — skipped', {
|
|
439
|
+
meta: {
|
|
440
|
+
nodeId: childNodeId,
|
|
441
|
+
incarnation: child.incarnation,
|
|
442
|
+
skipped: this.childManifestGate.skippedSince(),
|
|
443
|
+
sampleEvery: exports.CHILD_MANIFEST_SKIP_SAMPLE,
|
|
444
|
+
},
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
424
449
|
// The UDS connection is the only thing that can tell two generations of
|
|
425
450
|
// the same runner apart — carry its incarnation into the registry as
|
|
426
451
|
// the owner of every registration this manifest makes.
|
|
@@ -434,6 +459,11 @@ class MoleculerService {
|
|
|
434
459
|
registry.onChildGone((childId, incarnation) => {
|
|
435
460
|
const hubNodeId = this.brokerSafe.nodeID;
|
|
436
461
|
const childNodeId = `${hubNodeId}/${childId}`;
|
|
462
|
+
// The successor's first register must be a FIRST register: leaving the
|
|
463
|
+
// record behind would let a same-incarnation reconnect (mixed-version
|
|
464
|
+
// child, or a socket that came back) be skipped against a manifest the
|
|
465
|
+
// registry no longer holds.
|
|
466
|
+
this.childManifestGate.forget(childId);
|
|
437
467
|
logger.info('UDS child gone — removing from registry', {
|
|
438
468
|
meta: { childId, incarnation },
|
|
439
469
|
});
|
|
@@ -1161,6 +1191,84 @@ exports.MoleculerService = MoleculerService;
|
|
|
1161
1191
|
function childOwnerToken(childNodeId, incarnation) {
|
|
1162
1192
|
return `${childNodeId}#${incarnation}`;
|
|
1163
1193
|
}
|
|
1194
|
+
/**
|
|
1195
|
+
* One skipped-re-register line per this many skips.
|
|
1196
|
+
*
|
|
1197
|
+
* A gate nobody can count is indistinguishable from a child that stopped
|
|
1198
|
+
* re-registering, and those two want opposite investigations. A line per skip
|
|
1199
|
+
* would reproduce exactly the volume the gate exists to remove.
|
|
1200
|
+
*/
|
|
1201
|
+
exports.CHILD_MANIFEST_SKIP_SAMPLE = 25;
|
|
1202
|
+
/** Canonical, order-insensitive text for a child manifest. */
|
|
1203
|
+
function childManifestFingerprint(params) {
|
|
1204
|
+
const addons = params.addons
|
|
1205
|
+
.map((addon) => `${addon.addonId}:${[...addon.capabilities].sort().join(',')}`)
|
|
1206
|
+
.sort();
|
|
1207
|
+
return `${params.nodeId}|${addons.join('|')}`;
|
|
1208
|
+
}
|
|
1209
|
+
/**
|
|
1210
|
+
* Skips a child re-registration that carries nothing new.
|
|
1211
|
+
*
|
|
1212
|
+
* ## What it prevents
|
|
1213
|
+
*
|
|
1214
|
+
* `LocalChildClient.updateCaps()` re-sends the complete `register` frame on the
|
|
1215
|
+
* SAME socket whenever a child re-publishes its cap set. Measured on the live
|
|
1216
|
+
* hub 2026-08-25: **246 full manifest rebuilds in 30 minutes with zero runner
|
|
1217
|
+
* respawns**, every one carrying the same `incarnation` as the one before it
|
|
1218
|
+
* (provider-homeassistant alone: 70). `applyNodeManifest` is diff-based, so the
|
|
1219
|
+
* registry ends in the same state — the RESULT is idempotent, the WORK is not.
|
|
1220
|
+
* Each pass re-stores the manifest, builds two `appliedKeys` maps over every cap
|
|
1221
|
+
* of every hosted addon, and prints a line, on the one thread that also answers
|
|
1222
|
+
* every settings read, every UDS handshake and every cross-runner cap call
|
|
1223
|
+
* (D181).
|
|
1224
|
+
*
|
|
1225
|
+
* ## Why the key is BOTH incarnation and manifest
|
|
1226
|
+
*
|
|
1227
|
+
* Incarnation alone would skip a legitimate `updateCaps` — device-restore adds
|
|
1228
|
+
* device-scoped native caps on the same connection, which is the case the
|
|
1229
|
+
* re-register path was built for. Manifest alone would skip a RESPAWN that came
|
|
1230
|
+
* back with an identical cap set, and a respawn must always re-apply: the owner
|
|
1231
|
+
* token is `childOwnerToken(nodeId, incarnation)`, so skipping it would leave
|
|
1232
|
+
* every provider owned by the dead generation and the successor's disconnect
|
|
1233
|
+
* would unregister nothing.
|
|
1234
|
+
*/
|
|
1235
|
+
class ChildManifestGate {
|
|
1236
|
+
applied = new Map();
|
|
1237
|
+
skipped = 0;
|
|
1238
|
+
sinceSample = 0;
|
|
1239
|
+
/** True when this registration carries something the registry does not have. */
|
|
1240
|
+
shouldApply(childId, incarnation, params) {
|
|
1241
|
+
const fingerprint = childManifestFingerprint(params);
|
|
1242
|
+
const previous = this.applied.get(childId);
|
|
1243
|
+
if (previous !== undefined && previous.incarnation === incarnation) {
|
|
1244
|
+
if (previous.fingerprint === fingerprint) {
|
|
1245
|
+
this.skipped += 1;
|
|
1246
|
+
this.sinceSample += 1;
|
|
1247
|
+
return false;
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
this.applied.set(childId, { incarnation, fingerprint });
|
|
1251
|
+
return true;
|
|
1252
|
+
}
|
|
1253
|
+
/** Drop a child's record — its next register is a first register again. */
|
|
1254
|
+
forget(childId) {
|
|
1255
|
+
this.applied.delete(childId);
|
|
1256
|
+
}
|
|
1257
|
+
/** How many have been skipped since the last call. Reading RESETS it. */
|
|
1258
|
+
skippedSince() {
|
|
1259
|
+
const n = this.skipped;
|
|
1260
|
+
this.skipped = 0;
|
|
1261
|
+
return n;
|
|
1262
|
+
}
|
|
1263
|
+
/** True once every {@link CHILD_MANIFEST_SKIP_SAMPLE} skips. */
|
|
1264
|
+
sampleDue() {
|
|
1265
|
+
if (this.sinceSample < exports.CHILD_MANIFEST_SKIP_SAMPLE)
|
|
1266
|
+
return false;
|
|
1267
|
+
this.sinceSample = 0;
|
|
1268
|
+
return true;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
exports.ChildManifestGate = ChildManifestGate;
|
|
1164
1272
|
/**
|
|
1165
1273
|
* E1: Adapt a child's UDS `ChildCapDescriptor[]` into a `RegisterNodeParams`
|
|
1166
1274
|
* that `onRegisterNode` / `applyNodeManifest` can consume.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/server",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.155",
|
|
4
4
|
"private": false,
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"@camstack/addon-auth": "1.2.30",
|
|
39
39
|
"@camstack/addon-decoder-nodeav": "1.2.26",
|
|
40
40
|
"@camstack/addon-notifiers": "1.2.31",
|
|
41
|
-
"@camstack/addon-pipeline": "1.2.
|
|
41
|
+
"@camstack/addon-pipeline": "1.2.121",
|
|
42
42
|
"@camstack/addon-pipeline-orchestrator": "1.2.104",
|
|
43
|
-
"@camstack/addon-post-analysis": "1.2.
|
|
43
|
+
"@camstack/addon-post-analysis": "1.2.119",
|
|
44
44
|
"@camstack/sdk": "1.2.30",
|
|
45
|
-
"@camstack/system": "1.2.
|
|
46
|
-
"@camstack/types": "1.2.
|
|
45
|
+
"@camstack/system": "1.2.123",
|
|
46
|
+
"@camstack/types": "1.2.103",
|
|
47
47
|
"@camstack/ui-library": "1.2.70",
|
|
48
48
|
"@fastify/compress": "^9.0.0",
|
|
49
49
|
"@fastify/cookie": "^11.0.2",
|