@camstack/server 1.2.153 → 1.2.154

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 the three `spawnRunnerPlan`
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 plans (see the two call sites), not
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
- // Pass 1 — infrastructure builtins. A failed REQUIRED infra cap
782
- // aborts boot: nothing downstream can run without storage/settings.
783
- for (const infra of system_1.INFRA_CAPABILITIES) {
784
- const addonId = this.findAddonForCapability(infra.name, allIds);
785
- if (addonId) {
786
- const entry = this.addonEntries.get(addonId);
787
- // Only core builtins boot in-process here. A non-core addon that
788
- // happens to provide an infra cap (e.g. an alternate
789
- // storage-provider) lives in its own runner — never in-process.
790
- if (!entry || entry.initialized || !isCoreBuiltin(addonId))
791
- continue;
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.initializeAddon(addonId);
794
- this.wireCapabilities(addonId);
795
- }
796
- catch (error) {
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
- else if (infra.required) {
814
- throw new Error(`No addon provides required infrastructure capability "${infra.name}"`);
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
- // Pass 3 — core builtins that declare no capabilities at all.
849
- for (const id of allIds) {
850
- const entry = this.addonEntries.get(id);
851
- if (entry && !entry.initialized && isCoreBuiltin(id)) {
852
- try {
853
- await this.initializeAddon(id);
854
- this.wireCapabilities(id);
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
- catch (error) {
857
- const msg = (0, types_1.errMsg)(error);
858
- this.emitAddonLifecycleEvent('addon.error', id, {
859
- error: msg,
860
- phase: 'init',
861
- });
862
- this.logger.error('Core builtin failed to initialize -- skipping', {
863
- tags: { addonId: id },
864
- meta: { error: msg },
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
- // Isolated consumers (snapshot), now that storage / settings / logging
870
- // are resident. Infra isolates already spawned above.
871
- if (isolatedConsumerIds.length > 0) {
872
- this.logger.info('Spawning isolated system builtins', {
873
- meta: { addonIds: isolatedConsumerIds },
874
- });
875
- await spawnRunnerPlan(this.buildAddonGroupPlan(isolatedConsumerIds));
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/server",
3
- "version": "1.2.153",
3
+ "version": "1.2.154",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist",
@@ -42,8 +42,8 @@
42
42
  "@camstack/addon-pipeline-orchestrator": "1.2.104",
43
43
  "@camstack/addon-post-analysis": "1.2.118",
44
44
  "@camstack/sdk": "1.2.30",
45
- "@camstack/system": "1.2.121",
46
- "@camstack/types": "1.2.102",
45
+ "@camstack/system": "1.2.122",
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",