@sylphx/sdk 0.13.9 → 0.15.0

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.
@@ -455,8 +455,34 @@ interface HealthScore {
455
455
  * `health.signal.factor`.
456
456
  */
457
457
  readonly signalFactors?: Record<string, number>;
458
+ /**
459
+ * Non-secret release/deployment identity for live-build verification.
460
+ *
461
+ * Additive to the ADR-111 wire shape: probe sidecars ignore it, while
462
+ * operators and deployment monitors can prove which immutable build is
463
+ * answering `/healthz` without needing access to the deploy control plane.
464
+ */
465
+ readonly release?: HealthRelease;
458
466
  readonly lastTickAt: string;
459
467
  }
468
+ /**
469
+ * Public, non-secret release identity attached to a health response.
470
+ *
471
+ * These fields intentionally mirror platform-injected runtime identity
472
+ * variables (`SYLPHX_*`) instead of arbitrary metadata. Health endpoints are
473
+ * commonly public, so this surface must stay provenance-focused and must not
474
+ * become a general key/value bag that can accidentally expose secrets.
475
+ */
476
+ interface HealthRelease {
477
+ readonly version?: string | null;
478
+ readonly commitSha?: string | null;
479
+ readonly imageDigest?: string | null;
480
+ readonly imageTag?: string | null;
481
+ readonly deploymentId?: string | null;
482
+ readonly buildId?: string | null;
483
+ readonly replicaId?: string | null;
484
+ }
485
+ type HealthReleaseInput = HealthRelease | (() => HealthRelease | null | undefined);
460
486
  /**
461
487
  * Wire format the sidecar's `app-poll.ts::parseAppHealthBody` consumes.
462
488
  *
@@ -543,6 +569,14 @@ interface SylphxHealthOptions {
543
569
  * adapter; the interface is public and stable so any backend works.
544
570
  */
545
571
  readonly history?: HistoryOption;
572
+ /**
573
+ * Optional non-secret release identity to include in every HealthSnapshot.
574
+ *
575
+ * Accepts a static object or a synchronous resolver. Resolver failures are
576
+ * swallowed: release metadata must never block the load-bearing health
577
+ * response.
578
+ */
579
+ readonly release?: HealthReleaseInput;
546
580
  }
547
581
 
548
582
  /**
@@ -1354,4 +1388,4 @@ interface SylphxHealth extends HealthEvaluator {
1354
1388
  }
1355
1389
  declare function sylphxHealth(opts?: SylphxHealthOptions): SylphxHealth;
1356
1390
 
1357
- export { type AsyncSignal, BAGGAGE_KEY_CAUSE, BAGGAGE_KEY_CHAIN, type CausalityHandle, type CausalityOption, type CausalityOptions, DEFAULT_CAUSE_THRESHOLD, DEFAULT_HISTORY_CAPACITY, type DependencyPingOptions, type ErrorRateOptions, type ErrorRateSignalHandle, type EventLoopLagOptions, type ExpressHealthMiddleware, type ExpressNextLike, type ExpressRequestLike, type ExpressResponseLike, type FastifyHealthPlugin, type FastifyInstanceLike, type FastifyReplyLike, type FetchHealthHandler, GENESIS_PREV_HASH, HealthError, type HealthEvaluator, type HealthScore, type HealthSnapshot, type HistoryEntry, type HistoryOption, type HistoryQuery, type HistoryRecorder, type HistoryRecorderOptions, type HistoryStore, type HonoContextLike, type HonoHealthMiddleware, type HonoNextLike, type InMemoryHistoryStoreOptions, MAX_CHAIN_LENGTH, type MemoryPressureOptions, EVENT_NAMES as OTEL_EVENT_NAMES, METRIC_NAMES as OTEL_METRIC_NAMES, SPAN_ATTRIBUTES as OTEL_SPAN_ATTRIBUTES, type OtelEmitter, type OtelEmitterOptions, type OtelOption, type OtelStaticAttributes, type PingSignalOptions, type QueueDepthOptions, type ScoringStrategy, type Signal, type SignalBase, type SignalReading, type SylphxHealth, type SylphxHealthOptions, type SyncSignal, type UnixSocketServerHandle, type UnixSocketServerOptions, type UpstreamCause, type VerificationResult, type WithHealthOptions, canonicalizeSignals, createCausalityHandle, createHistoryRecorder, createInMemoryHistoryStore, createNodeHandler, createOtelEmitter, createWebHandler, databaseSignal, defaultScoringStrategy, errorRateSignal, eventLoopLagSignal, memoryPressureSignal, pingSignal, queueDepthSignal, redisSignal, sylphxHealth, verifyChain, weightedProduct, withHealth };
1391
+ export { type AsyncSignal, BAGGAGE_KEY_CAUSE, BAGGAGE_KEY_CHAIN, type CausalityHandle, type CausalityOption, type CausalityOptions, DEFAULT_CAUSE_THRESHOLD, DEFAULT_HISTORY_CAPACITY, type DependencyPingOptions, type ErrorRateOptions, type ErrorRateSignalHandle, type EventLoopLagOptions, type ExpressHealthMiddleware, type ExpressNextLike, type ExpressRequestLike, type ExpressResponseLike, type FastifyHealthPlugin, type FastifyInstanceLike, type FastifyReplyLike, type FetchHealthHandler, GENESIS_PREV_HASH, HealthError, type HealthEvaluator, type HealthRelease, type HealthReleaseInput, type HealthScore, type HealthSnapshot, type HistoryEntry, type HistoryOption, type HistoryQuery, type HistoryRecorder, type HistoryRecorderOptions, type HistoryStore, type HonoContextLike, type HonoHealthMiddleware, type HonoNextLike, type InMemoryHistoryStoreOptions, MAX_CHAIN_LENGTH, type MemoryPressureOptions, EVENT_NAMES as OTEL_EVENT_NAMES, METRIC_NAMES as OTEL_METRIC_NAMES, SPAN_ATTRIBUTES as OTEL_SPAN_ATTRIBUTES, type OtelEmitter, type OtelEmitterOptions, type OtelOption, type OtelStaticAttributes, type PingSignalOptions, type QueueDepthOptions, type ScoringStrategy, type Signal, type SignalBase, type SignalReading, type SylphxHealth, type SylphxHealthOptions, type SyncSignal, type UnixSocketServerHandle, type UnixSocketServerOptions, type UpstreamCause, type VerificationResult, type WithHealthOptions, canonicalizeSignals, createCausalityHandle, createHistoryRecorder, createInMemoryHistoryStore, createNodeHandler, createOtelEmitter, createWebHandler, databaseSignal, defaultScoringStrategy, errorRateSignal, eventLoopLagSignal, memoryPressureSignal, pingSignal, queueDepthSignal, redisSignal, sylphxHealth, verifyChain, weightedProduct, withHealth };
@@ -1207,6 +1207,35 @@ function clampHealthFactor(value) {
1207
1207
  if (value > 1) return 1;
1208
1208
  return value;
1209
1209
  }
1210
+ var HEALTH_RELEASE_KEYS = [
1211
+ "version",
1212
+ "commitSha",
1213
+ "imageDigest",
1214
+ "imageTag",
1215
+ "deploymentId",
1216
+ "buildId",
1217
+ "replicaId"
1218
+ ];
1219
+ function resolveHealthRelease(input) {
1220
+ if (!input) return void 0;
1221
+ try {
1222
+ const value = typeof input === "function" ? input() : input;
1223
+ if (!value) return void 0;
1224
+ const release = {};
1225
+ for (const key of HEALTH_RELEASE_KEYS) {
1226
+ const raw = value[key];
1227
+ if (raw === null) {
1228
+ release[key] = null;
1229
+ } else if (typeof raw === "string") {
1230
+ const trimmed = raw.trim();
1231
+ if (trimmed.length > 0) release[key] = trimmed;
1232
+ }
1233
+ }
1234
+ return Object.keys(release).length > 0 ? release : void 0;
1235
+ } catch {
1236
+ return void 0;
1237
+ }
1238
+ }
1210
1239
  function sylphxHealth(opts = {}) {
1211
1240
  const signals = opts.signals && opts.signals.length > 0 ? [...opts.signals] : [eventLoopLagSignal({ degradedMs: 5e3, deadMs: 3e4, weight: 1 })];
1212
1241
  const scoringStrategy = opts.scoringStrategy ?? defaultScoringStrategy();
@@ -1234,10 +1263,12 @@ function sylphxHealth(opts = {}) {
1234
1263
  signalsMap[signal.name] = reading.value;
1235
1264
  signalFactors[signal.name] = reading.unknown === true ? 1 : clampHealthFactor(reading.healthFactor);
1236
1265
  }
1266
+ const release = resolveHealthRelease(opts.release);
1237
1267
  const result = {
1238
1268
  score,
1239
1269
  signals: signalsMap,
1240
1270
  signalFactors,
1271
+ ...release ? { release } : {},
1241
1272
  lastTickAt: now().toISOString()
1242
1273
  };
1243
1274
  lastScore = result;