@bleedingdev/modern-js-server-runtime-extensions 3.9.0-ultramodern.5 → 3.9.0-ultramodern.7

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.
Files changed (68) hide show
  1. package/README.md +5 -5
  2. package/dist/cjs/bff-policy/crossProjectPolicy.js +1 -11
  3. package/dist/cjs/contract-gate-snapshot-store/http-store.js +1 -8
  4. package/dist/cjs/telemetry/exporters.js +4 -4
  5. package/dist/cjs/telemetry/healthSetup.js +14 -18
  6. package/dist/cjs/telemetry/lifecycle.js +5 -5
  7. package/dist/cjs/telemetry/plugin.js +3 -4
  8. package/dist/cjs/telemetry/runtimeEndpoints.js +1 -7
  9. package/dist/cjs/telemetryCore.js +5 -5
  10. package/dist/esm/bff-policy/crossProjectPolicy.mjs +1 -11
  11. package/dist/esm/contract-gate-snapshot-store/http-store.mjs +1 -8
  12. package/dist/esm/telemetry/exporters.mjs +2 -2
  13. package/dist/esm/telemetry/healthSetup.mjs +14 -18
  14. package/dist/esm/telemetry/lifecycle.mjs +6 -6
  15. package/dist/esm/telemetry/plugin.mjs +3 -4
  16. package/dist/esm/telemetry/runtimeEndpoints.mjs +1 -7
  17. package/dist/esm/telemetryCore.mjs +1 -1
  18. package/dist/esm-node/bff-policy/crossProjectPolicy.mjs +1 -11
  19. package/dist/esm-node/contract-gate-snapshot-store/http-store.mjs +1 -8
  20. package/dist/esm-node/telemetry/exporters.mjs +2 -2
  21. package/dist/esm-node/telemetry/healthSetup.mjs +14 -18
  22. package/dist/esm-node/telemetry/lifecycle.mjs +6 -6
  23. package/dist/esm-node/telemetry/plugin.mjs +3 -4
  24. package/dist/esm-node/telemetry/runtimeEndpoints.mjs +1 -7
  25. package/dist/esm-node/telemetryCore.mjs +1 -1
  26. package/dist/types/bff-policy/crossProjectPolicy.d.ts +2 -11
  27. package/dist/types/telemetry/exporters.d.ts +1 -1
  28. package/dist/types/telemetry/healthSetup.d.ts +2 -4
  29. package/dist/types/telemetry/lifecycle.d.ts +2 -2
  30. package/dist/types/telemetry/runtimeEndpoints.d.ts +1 -3
  31. package/dist/types/telemetryCore.d.ts +1 -1
  32. package/dist/types-esm/bff-policy/crossProjectPolicy.d.mts +2 -11
  33. package/dist/types-esm/telemetry/exporters.d.mts +1 -1
  34. package/dist/types-esm/telemetry/healthSetup.d.mts +2 -4
  35. package/dist/types-esm/telemetry/lifecycle.d.mts +2 -2
  36. package/dist/types-esm/telemetry/runtimeEndpoints.d.mts +1 -3
  37. package/dist/types-esm/telemetryCore.d.mts +1 -1
  38. package/package.json +10 -10
  39. package/src/bff-policy/crossProjectPolicy.ts +7 -34
  40. package/src/contract-gate-snapshot-store/http-store.ts +1 -11
  41. package/src/telemetry/exporters.ts +1 -1
  42. package/src/telemetry/healthSetup.ts +16 -27
  43. package/src/telemetry/lifecycle.ts +7 -7
  44. package/src/telemetry/plugin.ts +2 -4
  45. package/src/telemetry/runtimeEndpoints.ts +0 -10
  46. package/src/telemetryCore.ts +1 -1
  47. package/tests/bff-policy/crossProjectPolicy.matrix.test.ts +0 -37
  48. package/tests/bff-policy/crossProjectPolicy.test.ts +26 -833
  49. package/tests/bff-policy/resolveCrossProjectPolicy.test.ts +0 -58
  50. package/tests/contractGateSnapshotStore.test.ts +0 -51
  51. package/tests/nativeErrorResponse.test.ts +0 -81
  52. package/tests/nativeServerAssembly.test.ts +34 -51
  53. package/tests/static-serving/static.test.ts +31 -20
  54. package/tests/telemetry.test.ts +0 -97
  55. package/tests/telemetryHealthMonitor.test.ts +0 -2
  56. package/tests/telemetryHealthObservation.test.ts +302 -0
  57. package/tests/telemetryLifecycle.test.ts +0 -54
  58. package/tests/telemetryRegistryQueueMatrix.test.ts +14 -110
  59. package/dist/cjs/telemetry/canaryCompatibility.js +0 -73
  60. package/dist/esm/telemetry/canaryCompatibility.mjs +0 -35
  61. package/dist/esm-node/telemetry/canaryCompatibility.mjs +0 -36
  62. package/dist/types/telemetry/canaryCompatibility.d.ts +0 -19
  63. package/dist/types-esm/telemetry/canaryCompatibility.d.mts +0 -19
  64. package/src/telemetry/canaryCompatibility.ts +0 -55
  65. package/tests/registration.test.ts +0 -27
  66. package/tests/static-serving/provider.test.ts +0 -83
  67. package/tests/telemetryAutopilot.test.ts +0 -993
  68. package/tests/telemetryCanaryCompatibility.test.ts +0 -152
@@ -98,8 +98,8 @@ function createVictoriaMetricsTelemetryExporter(options = {}) {
98
98
  }
99
99
  };
100
100
  }
101
- function maybeWarnLegacyOtlpEndpoint(endpoint) {
101
+ function warnOnMetricsOtlpEndpoint(endpoint) {
102
102
  if (!endpoint || !endpoint.includes('/v1/metrics')) return;
103
103
  console.warn(`[telemetry] OTLP endpoint "${endpoint}" looks like a metrics path. UltraModern telemetry exporter expects log-style envelopes (default: ${DEFAULT_OTLP_ENDPOINT}).`);
104
104
  }
105
- export { createOtlpTelemetryExporter, createVictoriaMetricsTelemetryExporter, maybeWarnLegacyOtlpEndpoint };
105
+ export { createOtlpTelemetryExporter, createVictoriaMetricsTelemetryExporter, warnOnMetricsOtlpEndpoint };
@@ -2,7 +2,6 @@ import "node:module";
2
2
  import { DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH, resolveContractGateSnapshotPath, resolveContractGateSnapshotStore } from "../contract-gate-snapshot-store/index.mjs";
3
3
  import { DEFAULT_RUNTIME_FALLBACK_FAILURE_HOLD_MS, DEFAULT_RUNTIME_FALLBACK_GATE_NAME, DEFAULT_RUNTIME_FALLBACK_MAX_BODY_BYTES, createRuntimeFallbackSignalRuntimeState, normalizeRequiredRuntimeFallbackSignalAuthConfig, normalizeRuntimeFallbackSignalAuthConfig, normalizeRuntimeFallbackTrustPolicy, resolveRuntimeFallbackSignalEndpoint } from "../runtimeFallbackSignal.mjs";
4
4
  import { TelemetryHealthMonitor } from "../telemetryCore.mjs";
5
- import { createTelemetryCanaryCompatibility } from "./canaryCompatibility.mjs";
6
5
  function emitHealthTransitionMetric(registry, evaluation) {
7
6
  try {
8
7
  registry.enqueueMetric({
@@ -17,36 +16,34 @@ function emitHealthTransitionMetric(registry, evaluation) {
17
16
  });
18
17
  } catch (_error) {}
19
18
  }
20
- const setupTelemetryHealthMonitoring = ({ registry, appDirectory, legacyHealthConfig })=>{
21
- if (!legacyHealthConfig?.enabled) return {};
22
- const contractGates = legacyHealthConfig.contractGates;
23
- const canaryCompatibility = createTelemetryCanaryCompatibility(registry);
19
+ const setupTelemetryHealthMonitoring = ({ registry, appDirectory, healthConfig })=>{
20
+ if (!healthConfig?.enabled) return {};
21
+ const contractGates = healthConfig.contractGates;
24
22
  const healthMonitor = new TelemetryHealthMonitor({
25
23
  registry,
26
- evaluationIntervalMs: legacyHealthConfig.evaluationIntervalMs,
27
- minConsecutiveHealthyEvaluations: legacyHealthConfig.minConsecutiveHealthyEvaluations,
28
- minConsecutiveFailedEvaluations: legacyHealthConfig.rollbackConsecutiveFailures,
29
- maxQueueUtilization: legacyHealthConfig.maxQueueUtilization,
30
- maxTotalDropped: legacyHealthConfig.maxTotalDropped,
31
- maxUnhealthyExporters: legacyHealthConfig.maxUnhealthyExporters,
24
+ evaluationIntervalMs: healthConfig.evaluationIntervalMs,
25
+ minConsecutiveHealthyEvaluations: healthConfig.minConsecutiveHealthyEvaluations,
26
+ minConsecutiveFailedEvaluations: healthConfig.minConsecutiveFailedEvaluations,
27
+ maxQueueUtilization: healthConfig.maxQueueUtilization,
28
+ maxTotalDropped: healthConfig.maxTotalDropped,
29
+ maxUnhealthyExporters: healthConfig.maxUnhealthyExporters,
32
30
  requiredContractGates: Object.keys(contractGates || {}),
33
31
  onTransition: (evaluation)=>{
34
32
  emitHealthTransitionMetric(registry, evaluation);
35
- canaryCompatibility.observe(evaluation);
36
33
  }
37
34
  });
38
35
  if (contractGates) healthMonitor.setContractGates(contractGates);
39
36
  let gateSnapshotStorePromise;
40
37
  let runtimeFallbackSignalConfig;
41
- const snapshotObservationEnabled = legacyHealthConfig.autopilot?.enabled ?? true;
38
+ const snapshotObservationEnabled = healthConfig.snapshotObservation?.enabled ?? true;
42
39
  if (snapshotObservationEnabled) {
43
- const gateSnapshotPath = resolveContractGateSnapshotPath(appDirectory, legacyHealthConfig.autopilot?.gateSnapshotPath);
40
+ const gateSnapshotPath = resolveContractGateSnapshotPath(appDirectory, healthConfig.snapshotObservation?.gateSnapshotPath);
44
41
  gateSnapshotStorePromise = resolveContractGateSnapshotStore({
45
42
  appDirectory,
46
43
  gateSnapshotPath: gateSnapshotPath || DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH,
47
- stateStore: legacyHealthConfig.autopilot?.stateStore
44
+ stateStore: healthConfig.snapshotObservation?.stateStore
48
45
  });
49
- const runtimeSignalConfig = legacyHealthConfig.autopilot?.runtimeFallbackSignal;
46
+ const runtimeSignalConfig = healthConfig.snapshotObservation?.runtimeFallbackSignal;
50
47
  if (runtimeSignalConfig?.enabled === true) runtimeFallbackSignalConfig = {
51
48
  endpoint: resolveRuntimeFallbackSignalEndpoint(runtimeSignalConfig.endpoint),
52
49
  gateName: runtimeSignalConfig.gateName?.trim() || DEFAULT_RUNTIME_FALLBACK_GATE_NAME,
@@ -58,10 +55,9 @@ const setupTelemetryHealthMonitoring = ({ registry, appDirectory, legacyHealthCo
58
55
  runtimeState: createRuntimeFallbackSignalRuntimeState()
59
56
  };
60
57
  }
61
- const runtimeStatusAuthConfig = runtimeFallbackSignalConfig?.auth ?? normalizeRuntimeFallbackSignalAuthConfig(legacyHealthConfig.autopilot?.runtimeFallbackSignal?.auth);
58
+ const runtimeStatusAuthConfig = runtimeFallbackSignalConfig?.auth ?? normalizeRuntimeFallbackSignalAuthConfig(healthConfig.snapshotObservation?.runtimeFallbackSignal?.auth);
62
59
  return {
63
60
  healthMonitor,
64
- canaryCompatibility,
65
61
  gateSnapshotStorePromise,
66
62
  runtimeFallbackSignalConfig,
67
63
  runtimeStatusAuthConfig
@@ -2,7 +2,7 @@ import "node:module";
2
2
  import { logger } from "@modern-js/utils";
3
3
  import { resolveContractGateSnapshotPath } from "../contract-gate-snapshot-store/index.mjs";
4
4
  import { ContractGateSnapshotObserver } from "../contractGateSnapshotObserver.mjs";
5
- import { createOtlpTelemetryExporter, createVictoriaMetricsTelemetryExporter, maybeWarnLegacyOtlpEndpoint } from "../telemetryCore.mjs";
5
+ import { createOtlpTelemetryExporter, createVictoriaMetricsTelemetryExporter, warnOnMetricsOtlpEndpoint } from "../telemetryCore.mjs";
6
6
  const activeTelemetryLaneClosers = new Set();
7
7
  let telemetryBeforeExitHookInstalled = false;
8
8
  const ensureTelemetryBeforeExitHook = ()=>{
@@ -14,7 +14,7 @@ const ensureTelemetryBeforeExitHook = ()=>{
14
14
  ])close().catch((error)=>logger.error(error));
15
15
  });
16
16
  };
17
- const registerTelemetryLifecycle = ({ api, registry, telemetryConfig, legacyHealthConfig, healthMonitor, gateSnapshotStorePromise, appDirectory })=>{
17
+ const registerTelemetryLifecycle = ({ api, registry, telemetryConfig, healthConfig, healthMonitor, gateSnapshotStorePromise, appDirectory })=>{
18
18
  let contractGateSnapshotObserver;
19
19
  let closePromise;
20
20
  const closeTelemetryLane = ()=>{
@@ -34,7 +34,7 @@ const registerTelemetryLifecycle = ({ api, registry, telemetryConfig, legacyHeal
34
34
  if (prepared || closePromise) return;
35
35
  prepared = true;
36
36
  if (telemetryConfig.exporters?.otlp?.enabled) {
37
- maybeWarnLegacyOtlpEndpoint(telemetryConfig.exporters.otlp.endpoint);
37
+ warnOnMetricsOtlpEndpoint(telemetryConfig.exporters.otlp.endpoint);
38
38
  await registry.register(createOtlpTelemetryExporter(telemetryConfig.exporters.otlp));
39
39
  }
40
40
  if (telemetryConfig.exporters?.victoriaMetrics?.enabled) await registry.register(createVictoriaMetricsTelemetryExporter(telemetryConfig.exporters.victoriaMetrics));
@@ -47,10 +47,10 @@ const registerTelemetryLifecycle = ({ api, registry, telemetryConfig, legacyHeal
47
47
  const gateSnapshotStore = await gateSnapshotStorePromise;
48
48
  contractGateSnapshotObserver = new ContractGateSnapshotObserver({
49
49
  monitor: healthMonitor,
50
- gateSnapshotPath: resolveContractGateSnapshotPath(appDirectory, legacyHealthConfig?.autopilot?.gateSnapshotPath),
50
+ gateSnapshotPath: resolveContractGateSnapshotPath(appDirectory, healthConfig?.snapshotObservation?.gateSnapshotPath),
51
51
  gateSnapshotStore,
52
- pollIntervalMs: legacyHealthConfig?.autopilot?.pollIntervalMs,
53
- gateStaleAfterMs: legacyHealthConfig?.autopilot?.gateStaleAfterMs
52
+ pollIntervalMs: healthConfig?.snapshotObservation?.pollIntervalMs,
53
+ gateStaleAfterMs: healthConfig?.snapshotObservation?.gateStaleAfterMs
54
54
  });
55
55
  }
56
56
  if (contractGateSnapshotObserver) await contractGateSnapshotObserver.start();
@@ -43,16 +43,15 @@ const injectTelemetryPlugin = ()=>({
43
43
  redactionKeys: telemetryConfig.redactionKeys,
44
44
  slo: resolveTelemetrySloOptions(telemetryConfig.slo)
45
45
  });
46
- const { healthMonitor, canaryCompatibility, gateSnapshotStorePromise, runtimeFallbackSignalConfig, runtimeStatusAuthConfig } = setupTelemetryHealthMonitoring({
46
+ const { healthMonitor, gateSnapshotStorePromise, runtimeFallbackSignalConfig, runtimeStatusAuthConfig } = setupTelemetryHealthMonitoring({
47
47
  registry,
48
48
  appDirectory,
49
- legacyHealthConfig: telemetryConfig.canary
49
+ healthConfig: telemetryConfig.health
50
50
  });
51
51
  if (runtimeFallbackSignalConfig) middlewares.push(createRuntimeFallbackSignalMiddleware(runtimeFallbackSignalConfig));
52
52
  middlewares.push(createRuntimeStatusMiddleware({
53
53
  registry,
54
54
  healthMonitor,
55
- canaryCompatibility,
56
55
  runtimeFallbackSignalConfig,
57
56
  runtimeStatusAuthConfig
58
57
  }));
@@ -84,7 +83,7 @@ const injectTelemetryPlugin = ()=>({
84
83
  api,
85
84
  registry,
86
85
  telemetryConfig,
87
- legacyHealthConfig: telemetryConfig.canary,
86
+ healthConfig: telemetryConfig.health,
88
87
  healthMonitor,
89
88
  gateSnapshotStorePromise,
90
89
  appDirectory
@@ -35,7 +35,7 @@ const createRuntimeFallbackSignalMiddleware = (signalConfig)=>({
35
35
  }
36
36
  }
37
37
  });
38
- const createRuntimeStatusMiddleware = ({ registry, healthMonitor, canaryCompatibility, runtimeFallbackSignalConfig, runtimeStatusAuthConfig })=>({
38
+ const createRuntimeStatusMiddleware = ({ registry, healthMonitor, runtimeFallbackSignalConfig, runtimeStatusAuthConfig })=>({
39
39
  name: 'telemetry-runtime-status',
40
40
  path: DEFAULT_RUNTIME_STATUS_ENDPOINT,
41
41
  method: 'get',
@@ -61,12 +61,6 @@ const createRuntimeStatusMiddleware = ({ registry, healthMonitor, canaryCompatib
61
61
  } : {
62
62
  enabled: false
63
63
  },
64
- canary: healthSnapshot && canaryCompatibility ? {
65
- enabled: true,
66
- ...canaryCompatibility.getStatusSnapshot(healthSnapshot)
67
- } : {
68
- enabled: false
69
- },
70
64
  runtimeFallbackSignal: runtimeFallbackSignalConfig ? {
71
65
  enabled: true,
72
66
  endpoint: runtimeFallbackSignalConfig.endpoint,
@@ -1,6 +1,6 @@
1
1
  import "node:module";
2
2
  export { toTelemetryEnvelope } from "./telemetry/envelope.mjs";
3
- export { createOtlpTelemetryExporter, createVictoriaMetricsTelemetryExporter, maybeWarnLegacyOtlpEndpoint } from "./telemetry/exporters.mjs";
3
+ export { createOtlpTelemetryExporter, createVictoriaMetricsTelemetryExporter, warnOnMetricsOtlpEndpoint } from "./telemetry/exporters.mjs";
4
4
  export { TelemetryHealthMonitor } from "./telemetry/healthMonitor.mjs";
5
5
  export { createTelemetryAwareMetrics } from "./telemetry/metrics.mjs";
6
6
  export { TelemetryRegistry } from "./telemetry/registry.mjs";
@@ -15,9 +15,7 @@
15
15
  * hook that derives the producer namespace from a VERIFIED channel (mTLS
16
16
  * peer identity, gateway-authenticated JWT claims, service-mesh headers
17
17
  * stripped at the edge, ...). Requests fail closed when a namespace allowlist
18
- * is configured without this hook unless `allowClientAssertedNamespace` is
19
- * explicitly enabled. That escape hatch keeps legacy local/demo ergonomics:
20
- * the client-asserted namespace must match the allowlist. When the hook is
18
+ * is configured without this hook. When the hook is
21
19
  * present, the client-asserted namespace must match the verified namespace
22
20
  * and the allowlist is checked against the verified value.
23
21
  *
@@ -62,12 +60,6 @@ export interface CrossProjectPolicyConfig {
62
60
  requireOperationSchemaHash?: boolean;
63
61
  requireOperationVersion?: boolean;
64
62
  allowedNamespaces?: string[];
65
- /**
66
- * Explicit local/demo escape hatch for legacy clients that only provide
67
- * client-built requestId namespaces. Defaults to false. Enabling this keeps
68
- * `allowedNamespaces` advisory and must not be used as authorization.
69
- */
70
- allowClientAssertedNamespace?: boolean;
71
63
  envelopeHeader?: string;
72
64
  operationContextHeader?: string;
73
65
  operationContextDetailHeader?: string;
@@ -84,8 +76,7 @@ export interface CrossProjectPolicyConfig {
84
76
  * `undefined` (identity could not be verified) denies the request.
85
77
  *
86
78
  * By default, `allowedNamespaces` requires this hook and fails closed
87
- * without it. Set `allowClientAssertedNamespace` only for local/demo
88
- * ergonomics where advisory client-asserted namespace checks are acceptable.
79
+ * without it.
89
80
  */
90
81
  verifyProducerIdentity?: (headers: Record<string, unknown>) => string | undefined;
91
82
  }
@@ -9,4 +9,4 @@ export interface VictoriaMetricsExporterOptions extends OtlpExporterOptions {
9
9
  }
10
10
  export declare function createOtlpTelemetryExporter(options?: OtlpExporterOptions): TelemetryExporter;
11
11
  export declare function createVictoriaMetricsTelemetryExporter(options?: VictoriaMetricsExporterOptions): TelemetryExporter;
12
- export declare function maybeWarnLegacyOtlpEndpoint(endpoint: string | undefined): void;
12
+ export declare function warnOnMetricsOtlpEndpoint(endpoint: string | undefined): void;
@@ -2,18 +2,16 @@ import type { ServerTelemetryUserConfig } from '@modern-js/runtime-extensions/se
2
2
  import { type ContractGateSnapshotStore } from '../contract-gate-snapshot-store/index.js';
3
3
  import { type RuntimeFallbackSignalAuthConfig, type RuntimeFallbackSignalConfig } from '../runtimeFallbackSignal.js';
4
4
  import { TelemetryHealthMonitor, TelemetryRegistry } from '../telemetryCore.js';
5
- import { type TelemetryCanaryCompatibility } from './canaryCompatibility.js';
6
5
  type SetupTelemetryHealthMonitoringOptions = {
7
6
  registry: TelemetryRegistry;
8
7
  appDirectory: string;
9
- legacyHealthConfig: ServerTelemetryUserConfig['canary'] | undefined;
8
+ healthConfig: ServerTelemetryUserConfig['health'] | undefined;
10
9
  };
11
10
  type SetupTelemetryHealthMonitoringResult = {
12
11
  healthMonitor?: TelemetryHealthMonitor;
13
- canaryCompatibility?: TelemetryCanaryCompatibility;
14
12
  gateSnapshotStorePromise?: Promise<ContractGateSnapshotStore>;
15
13
  runtimeFallbackSignalConfig?: RuntimeFallbackSignalConfig;
16
14
  runtimeStatusAuthConfig?: RuntimeFallbackSignalAuthConfig;
17
15
  };
18
- export declare const setupTelemetryHealthMonitoring: ({ registry, appDirectory, legacyHealthConfig, }: SetupTelemetryHealthMonitoringOptions) => SetupTelemetryHealthMonitoringResult;
16
+ export declare const setupTelemetryHealthMonitoring: ({ registry, appDirectory, healthConfig, }: SetupTelemetryHealthMonitoringOptions) => SetupTelemetryHealthMonitoringResult;
19
17
  export {};
@@ -9,10 +9,10 @@ type RegisterTelemetryLifecycleOptions = {
9
9
  api: TelemetryLifecycleApi;
10
10
  registry: TelemetryRegistry;
11
11
  telemetryConfig: ServerTelemetryUserConfig;
12
- legacyHealthConfig: ServerTelemetryUserConfig['canary'] | undefined;
12
+ healthConfig: ServerTelemetryUserConfig['health'] | undefined;
13
13
  healthMonitor?: TelemetryHealthMonitor;
14
14
  gateSnapshotStorePromise?: Promise<ContractGateSnapshotStore>;
15
15
  appDirectory: string;
16
16
  };
17
- export declare const registerTelemetryLifecycle: ({ api, registry, telemetryConfig, legacyHealthConfig, healthMonitor, gateSnapshotStorePromise, appDirectory, }: RegisterTelemetryLifecycleOptions) => void;
17
+ export declare const registerTelemetryLifecycle: ({ api, registry, telemetryConfig, healthConfig, healthMonitor, gateSnapshotStorePromise, appDirectory, }: RegisterTelemetryLifecycleOptions) => void;
18
18
  export {};
@@ -1,11 +1,9 @@
1
1
  import type { Context, ServerEnv } from '@modern-js/server-core';
2
2
  import { type RuntimeFallbackSignalAuthConfig, type RuntimeFallbackSignalConfig } from '../runtimeFallbackSignal.js';
3
3
  import type { TelemetryHealthMonitor, TelemetryRegistry } from '../telemetryCore.js';
4
- import type { TelemetryCanaryCompatibility } from './canaryCompatibility.js';
5
4
  type RuntimeStatusMiddlewareOptions = {
6
5
  registry: TelemetryRegistry;
7
6
  healthMonitor?: TelemetryHealthMonitor;
8
- canaryCompatibility?: TelemetryCanaryCompatibility;
9
7
  runtimeFallbackSignalConfig?: RuntimeFallbackSignalConfig;
10
8
  runtimeStatusAuthConfig?: RuntimeFallbackSignalAuthConfig;
11
9
  };
@@ -21,7 +19,7 @@ export declare const createRuntimeFallbackSignalMiddleware: (signalConfig: Runti
21
19
  error: string;
22
20
  }, 400 | 401 | 403 | 413 | 429 | 500, "json">)>;
23
21
  };
24
- export declare const createRuntimeStatusMiddleware: ({ registry, healthMonitor, canaryCompatibility, runtimeFallbackSignalConfig, runtimeStatusAuthConfig, }: RuntimeStatusMiddlewareOptions) => {
22
+ export declare const createRuntimeStatusMiddleware: ({ registry, healthMonitor, runtimeFallbackSignalConfig, runtimeStatusAuthConfig, }: RuntimeStatusMiddlewareOptions) => {
25
23
  name: string;
26
24
  path: string;
27
25
  method: 'get';
@@ -1,5 +1,5 @@
1
1
  export { type TelemetryEnvelope, type TelemetryExporter, type TelemetrySignalType, toTelemetryEnvelope, } from './telemetry/envelope.js';
2
- export { createOtlpTelemetryExporter, createVictoriaMetricsTelemetryExporter, maybeWarnLegacyOtlpEndpoint, type OtlpExporterOptions, type VictoriaMetricsExporterOptions, } from './telemetry/exporters.js';
2
+ export { createOtlpTelemetryExporter, createVictoriaMetricsTelemetryExporter, type OtlpExporterOptions, type VictoriaMetricsExporterOptions, warnOnMetricsOtlpEndpoint, } from './telemetry/exporters.js';
3
3
  export { type TelemetryContractGateStatus, type TelemetryHealthEvaluation, type TelemetryHealthFailure, type TelemetryHealthFailureReason, TelemetryHealthMonitor, type TelemetryHealthMonitorOptions, type TelemetryHealthState, type TelemetryHealthStatusSnapshot, type TelemetryHealthTransition, } from './telemetry/healthMonitor.js';
4
4
  export { createTelemetryAwareMetrics } from './telemetry/metrics.js';
5
5
  export { TelemetryRegistry } from './telemetry/registry.js';
@@ -15,9 +15,7 @@
15
15
  * hook that derives the producer namespace from a VERIFIED channel (mTLS
16
16
  * peer identity, gateway-authenticated JWT claims, service-mesh headers
17
17
  * stripped at the edge, ...). Requests fail closed when a namespace allowlist
18
- * is configured without this hook unless `allowClientAssertedNamespace` is
19
- * explicitly enabled. That escape hatch keeps legacy local/demo ergonomics:
20
- * the client-asserted namespace must match the allowlist. When the hook is
18
+ * is configured without this hook. When the hook is
21
19
  * present, the client-asserted namespace must match the verified namespace
22
20
  * and the allowlist is checked against the verified value.
23
21
  *
@@ -62,12 +60,6 @@ export interface CrossProjectPolicyConfig {
62
60
  requireOperationSchemaHash?: boolean;
63
61
  requireOperationVersion?: boolean;
64
62
  allowedNamespaces?: string[];
65
- /**
66
- * Explicit local/demo escape hatch for legacy clients that only provide
67
- * client-built requestId namespaces. Defaults to false. Enabling this keeps
68
- * `allowedNamespaces` advisory and must not be used as authorization.
69
- */
70
- allowClientAssertedNamespace?: boolean;
71
63
  envelopeHeader?: string;
72
64
  operationContextHeader?: string;
73
65
  operationContextDetailHeader?: string;
@@ -84,8 +76,7 @@ export interface CrossProjectPolicyConfig {
84
76
  * `undefined` (identity could not be verified) denies the request.
85
77
  *
86
78
  * By default, `allowedNamespaces` requires this hook and fails closed
87
- * without it. Set `allowClientAssertedNamespace` only for local/demo
88
- * ergonomics where advisory client-asserted namespace checks are acceptable.
79
+ * without it.
89
80
  */
90
81
  verifyProducerIdentity?: (headers: Record<string, unknown>) => string | undefined;
91
82
  }
@@ -9,4 +9,4 @@ export interface VictoriaMetricsExporterOptions extends OtlpExporterOptions {
9
9
  }
10
10
  export declare function createOtlpTelemetryExporter(options?: OtlpExporterOptions): TelemetryExporter;
11
11
  export declare function createVictoriaMetricsTelemetryExporter(options?: VictoriaMetricsExporterOptions): TelemetryExporter;
12
- export declare function maybeWarnLegacyOtlpEndpoint(endpoint: string | undefined): void;
12
+ export declare function warnOnMetricsOtlpEndpoint(endpoint: string | undefined): void;
@@ -2,18 +2,16 @@ import type { ServerTelemetryUserConfig } from '@modern-js/runtime-extensions/se
2
2
  import { type ContractGateSnapshotStore } from '../contract-gate-snapshot-store/index.mjs';
3
3
  import { type RuntimeFallbackSignalAuthConfig, type RuntimeFallbackSignalConfig } from '../runtimeFallbackSignal.mjs';
4
4
  import { TelemetryHealthMonitor, TelemetryRegistry } from '../telemetryCore.mjs';
5
- import { type TelemetryCanaryCompatibility } from './canaryCompatibility.mjs';
6
5
  type SetupTelemetryHealthMonitoringOptions = {
7
6
  registry: TelemetryRegistry;
8
7
  appDirectory: string;
9
- legacyHealthConfig: ServerTelemetryUserConfig['canary'] | undefined;
8
+ healthConfig: ServerTelemetryUserConfig['health'] | undefined;
10
9
  };
11
10
  type SetupTelemetryHealthMonitoringResult = {
12
11
  healthMonitor?: TelemetryHealthMonitor;
13
- canaryCompatibility?: TelemetryCanaryCompatibility;
14
12
  gateSnapshotStorePromise?: Promise<ContractGateSnapshotStore>;
15
13
  runtimeFallbackSignalConfig?: RuntimeFallbackSignalConfig;
16
14
  runtimeStatusAuthConfig?: RuntimeFallbackSignalAuthConfig;
17
15
  };
18
- export declare const setupTelemetryHealthMonitoring: ({ registry, appDirectory, legacyHealthConfig, }: SetupTelemetryHealthMonitoringOptions) => SetupTelemetryHealthMonitoringResult;
16
+ export declare const setupTelemetryHealthMonitoring: ({ registry, appDirectory, healthConfig, }: SetupTelemetryHealthMonitoringOptions) => SetupTelemetryHealthMonitoringResult;
19
17
  export {};
@@ -9,10 +9,10 @@ type RegisterTelemetryLifecycleOptions = {
9
9
  api: TelemetryLifecycleApi;
10
10
  registry: TelemetryRegistry;
11
11
  telemetryConfig: ServerTelemetryUserConfig;
12
- legacyHealthConfig: ServerTelemetryUserConfig['canary'] | undefined;
12
+ healthConfig: ServerTelemetryUserConfig['health'] | undefined;
13
13
  healthMonitor?: TelemetryHealthMonitor;
14
14
  gateSnapshotStorePromise?: Promise<ContractGateSnapshotStore>;
15
15
  appDirectory: string;
16
16
  };
17
- export declare const registerTelemetryLifecycle: ({ api, registry, telemetryConfig, legacyHealthConfig, healthMonitor, gateSnapshotStorePromise, appDirectory, }: RegisterTelemetryLifecycleOptions) => void;
17
+ export declare const registerTelemetryLifecycle: ({ api, registry, telemetryConfig, healthConfig, healthMonitor, gateSnapshotStorePromise, appDirectory, }: RegisterTelemetryLifecycleOptions) => void;
18
18
  export {};
@@ -1,11 +1,9 @@
1
1
  import type { Context, ServerEnv } from '@modern-js/server-core';
2
2
  import { type RuntimeFallbackSignalAuthConfig, type RuntimeFallbackSignalConfig } from '../runtimeFallbackSignal.mjs';
3
3
  import type { TelemetryHealthMonitor, TelemetryRegistry } from '../telemetryCore.mjs';
4
- import type { TelemetryCanaryCompatibility } from './canaryCompatibility.mjs';
5
4
  type RuntimeStatusMiddlewareOptions = {
6
5
  registry: TelemetryRegistry;
7
6
  healthMonitor?: TelemetryHealthMonitor;
8
- canaryCompatibility?: TelemetryCanaryCompatibility;
9
7
  runtimeFallbackSignalConfig?: RuntimeFallbackSignalConfig;
10
8
  runtimeStatusAuthConfig?: RuntimeFallbackSignalAuthConfig;
11
9
  };
@@ -21,7 +19,7 @@ export declare const createRuntimeFallbackSignalMiddleware: (signalConfig: Runti
21
19
  error: string;
22
20
  }, 400 | 401 | 403 | 413 | 429 | 500, "json">)>;
23
21
  };
24
- export declare const createRuntimeStatusMiddleware: ({ registry, healthMonitor, canaryCompatibility, runtimeFallbackSignalConfig, runtimeStatusAuthConfig, }: RuntimeStatusMiddlewareOptions) => {
22
+ export declare const createRuntimeStatusMiddleware: ({ registry, healthMonitor, runtimeFallbackSignalConfig, runtimeStatusAuthConfig, }: RuntimeStatusMiddlewareOptions) => {
25
23
  name: string;
26
24
  path: string;
27
25
  method: 'get';
@@ -1,5 +1,5 @@
1
1
  export { type TelemetryEnvelope, type TelemetryExporter, type TelemetrySignalType, toTelemetryEnvelope, } from './telemetry/envelope.mjs';
2
- export { createOtlpTelemetryExporter, createVictoriaMetricsTelemetryExporter, maybeWarnLegacyOtlpEndpoint, type OtlpExporterOptions, type VictoriaMetricsExporterOptions, } from './telemetry/exporters.mjs';
2
+ export { createOtlpTelemetryExporter, createVictoriaMetricsTelemetryExporter, type OtlpExporterOptions, type VictoriaMetricsExporterOptions, warnOnMetricsOtlpEndpoint, } from './telemetry/exporters.mjs';
3
3
  export { type TelemetryContractGateStatus, type TelemetryHealthEvaluation, type TelemetryHealthFailure, type TelemetryHealthFailureReason, TelemetryHealthMonitor, type TelemetryHealthMonitorOptions, type TelemetryHealthState, type TelemetryHealthStatusSnapshot, type TelemetryHealthTransition, } from './telemetry/healthMonitor.mjs';
4
4
  export { createTelemetryAwareMetrics } from './telemetry/metrics.mjs';
5
5
  export { TelemetryRegistry } from './telemetry/registry.mjs';
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.9.0-ultramodern.5",
20
+ "version": "3.9.0-ultramodern.7",
21
21
  "types": "./dist/types/index.d.ts",
22
22
  "main": "./dist/cjs/index.js",
23
23
  "exports": {
@@ -197,19 +197,19 @@
197
197
  "node": ">=26.7.0"
198
198
  },
199
199
  "dependencies": {
200
- "@modern-js/create-request": "npm:@bleedingdev/modern-js-create-request@3.9.0-ultramodern.5",
201
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.5",
202
- "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.5",
203
- "@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.5",
204
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.5",
205
- "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.5",
206
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.5",
200
+ "@modern-js/create-request": "npm:@bleedingdev/modern-js-create-request@3.9.0-ultramodern.7",
201
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.7",
202
+ "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.7",
203
+ "@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.7",
204
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.7",
205
+ "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.7",
206
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.7",
207
207
  "@swc/helpers": "^0.5.23",
208
208
  "reflect-metadata": "^0.2.2"
209
209
  },
210
210
  "devDependencies": {
211
- "@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.9.0-ultramodern.5",
212
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.5",
211
+ "@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.9.0-ultramodern.7",
212
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.7",
213
213
  "@rslib/core": "1.0.0",
214
214
  "@scripts/rstest-config": "2.66.0",
215
215
  "@types/node": "^26.4.1",
@@ -15,9 +15,7 @@
15
15
  * hook that derives the producer namespace from a VERIFIED channel (mTLS
16
16
  * peer identity, gateway-authenticated JWT claims, service-mesh headers
17
17
  * stripped at the edge, ...). Requests fail closed when a namespace allowlist
18
- * is configured without this hook unless `allowClientAssertedNamespace` is
19
- * explicitly enabled. That escape hatch keeps legacy local/demo ergonomics:
20
- * the client-asserted namespace must match the allowlist. When the hook is
18
+ * is configured without this hook. When the hook is
21
19
  * present, the client-asserted namespace must match the verified namespace
22
20
  * and the allowlist is checked against the verified value.
23
21
  *
@@ -79,7 +77,6 @@ export type CrossProjectPolicyViolation = {
79
77
  const DEFAULT_DENY_STATUS = 403;
80
78
  const NAMESPACE_ALLOWLIST_REQUIRES_VERIFIER_MESSAGE =
81
79
  'cross-project namespace allowlist requires verifyProducerIdentity';
82
- let hasWarnedAdvisoryNamespaceAllowlist = false;
83
80
 
84
81
  export interface CrossProjectPolicyConfig {
85
82
  enabled?: boolean;
@@ -89,12 +86,6 @@ export interface CrossProjectPolicyConfig {
89
86
  requireOperationSchemaHash?: boolean;
90
87
  requireOperationVersion?: boolean;
91
88
  allowedNamespaces?: string[];
92
- /**
93
- * Explicit local/demo escape hatch for legacy clients that only provide
94
- * client-built requestId namespaces. Defaults to false. Enabling this keeps
95
- * `allowedNamespaces` advisory and must not be used as authorization.
96
- */
97
- allowClientAssertedNamespace?: boolean;
98
89
  envelopeHeader?: string;
99
90
  operationContextHeader?: string;
100
91
  operationContextDetailHeader?: string;
@@ -111,8 +102,7 @@ export interface CrossProjectPolicyConfig {
111
102
  * `undefined` (identity could not be verified) denies the request.
112
103
  *
113
104
  * By default, `allowedNamespaces` requires this hook and fails closed
114
- * without it. Set `allowClientAssertedNamespace` only for local/demo
115
- * ergonomics where advisory client-asserted namespace checks are acceptable.
105
+ * without it.
116
106
  */
117
107
  verifyProducerIdentity?: (
118
108
  headers: Record<string, unknown>,
@@ -340,18 +330,6 @@ const createViolation = (
340
330
  status,
341
331
  });
342
332
 
343
- const warnAdvisoryNamespaceAllowlist = () => {
344
- if (hasWarnedAdvisoryNamespaceAllowlist) {
345
- return;
346
- }
347
- hasWarnedAdvisoryNamespaceAllowlist = true;
348
- console.warn(
349
- `[Modern.js BFF] ${NAMESPACE_ALLOWLIST_REQUIRES_VERIFIER_MESSAGE}. ` +
350
- 'allowClientAssertedNamespace=true will continue to evaluate allowlist ' +
351
- 'against client-asserted requestId namespaces only.',
352
- );
353
- };
354
-
355
333
  type ProducerIdentityVerifier = NonNullable<
356
334
  CrossProjectPolicyConfig['verifyProducerIdentity']
357
335
  >;
@@ -366,7 +344,6 @@ type CrossProjectPolicyEvaluationState = {
366
344
  requireOperationSchemaHash: boolean;
367
345
  requireOperationVersion: boolean;
368
346
  allowUnknownOperations: boolean;
369
- allowClientAssertedNamespace: boolean;
370
347
  verifyProducerIdentity?: ProducerIdentityVerifier;
371
348
  allowedNamespaces: string[];
372
349
  envelopeHeader: string;
@@ -401,7 +378,6 @@ const createCrossProjectPolicyEvaluationState = (
401
378
  requireOperationSchemaHash: policy.requireOperationSchemaHash ?? true,
402
379
  requireOperationVersion: policy.requireOperationVersion ?? true,
403
380
  allowUnknownOperations: policy.allowUnknownOperations ?? false,
404
- allowClientAssertedNamespace: policy.allowClientAssertedNamespace ?? false,
405
381
  verifyProducerIdentity:
406
382
  typeof policy.verifyProducerIdentity === 'function'
407
383
  ? policy.verifyProducerIdentity
@@ -440,14 +416,11 @@ const checkNamespaceAllowlistVerifier: CrossProjectPolicyCheck = state => {
440
416
  state.allowedNamespaces.length > 0 &&
441
417
  state.verifyProducerIdentity === undefined
442
418
  ) {
443
- if (!state.allowClientAssertedNamespace) {
444
- return createViolation(
445
- 'producer_identity_mismatch',
446
- NAMESPACE_ALLOWLIST_REQUIRES_VERIFIER_MESSAGE,
447
- state.status,
448
- );
449
- }
450
- warnAdvisoryNamespaceAllowlist();
419
+ return createViolation(
420
+ 'producer_identity_mismatch',
421
+ NAMESPACE_ALLOWLIST_REQUIRES_VERIFIER_MESSAGE,
422
+ state.status,
423
+ );
451
424
  }
452
425
  return undefined;
453
426
  };
@@ -8,16 +8,6 @@ import { CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION } from './types';
8
8
 
9
9
  const DEFAULT_HTTP_STORE_TIMEOUT_MS = 5_000;
10
10
 
11
- const BUILTIN_HTTP_STATE_STORE_MODULES = new Set([
12
- 'http',
13
- // historical aliases kept for config compatibility with the era when these
14
- // modules lived inside @modern-js/server-core.
15
- '@modern-js/server-core/http',
16
- '@modern-js/server-core/contract-gate-http-store',
17
- '@modern-js/server-runtime-extensions/http',
18
- '@modern-js/server-runtime-extensions/contract-gate-http-store',
19
- ]);
20
-
21
11
  const normalizeHttpStoreOptions = (
22
12
  options: Record<string, unknown> | undefined,
23
13
  ): ContractGateSnapshotHttpStoreOptions => {
@@ -149,7 +139,7 @@ export const tryResolveBuiltinSnapshotStore = (input: {
149
139
  stateStore: ContractGateSnapshotStoreUserConfig;
150
140
  }): ContractGateSnapshotStore | undefined => {
151
141
  const moduleName = input.stateStore.module.trim();
152
- if (!BUILTIN_HTTP_STATE_STORE_MODULES.has(moduleName)) {
142
+ if (moduleName !== 'http') {
153
143
  return undefined;
154
144
  }
155
145
 
@@ -153,7 +153,7 @@ export function createVictoriaMetricsTelemetryExporter(
153
153
  };
154
154
  }
155
155
 
156
- export function maybeWarnLegacyOtlpEndpoint(endpoint: string | undefined) {
156
+ export function warnOnMetricsOtlpEndpoint(endpoint: string | undefined) {
157
157
  if (!endpoint || !endpoint.includes('/v1/metrics')) {
158
158
  return;
159
159
  }