@yarkivaev/scada 2.5.7 → 2.6.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.
Files changed (107) hide show
  1. package/README.md +136 -2
  2. package/charts/scada/templates/_helpers.tpl +18 -3
  3. package/charts/scada/templates/postgres.yaml +6 -0
  4. package/charts/scada/templates/rabbitmq-config.yaml +5 -1
  5. package/charts/scada/templates/rabbitmq.yaml +12 -1
  6. package/charts/scada/templates/supervisor-sink.yaml +5 -0
  7. package/charts/scada/values.schema.json +46 -1
  8. package/charts/scada/values.yaml +7 -0
  9. package/db/migrations/E0005__historical_telemetry_grants.sql +5 -0
  10. package/db/migrations/E0006__historical_telemetry.sql +64 -0
  11. package/db/migrations/E0007__metric_receipts.sql +7 -0
  12. package/db/migrations/E0008__metric_receipts_grants.sql +1 -0
  13. package/db/migrations/E0009__history_continuation.sql +20 -0
  14. package/db/migrations/E0010__history_admissions.sql +8 -0
  15. package/db/migrations/E0011__history_classifier_checkpoints.sql +18 -0
  16. package/db/migrations/E0012__external_history_grants.sql +4 -0
  17. package/db/migrations/E0013__history_staged_corrections.sql +104 -0
  18. package/db/migrations/E0014__history_correction_grants.sql +5 -0
  19. package/db/migrations/E0015__history_retention_frontier.sql +7 -0
  20. package/db/migrations/E0016__history_retention_grants.sql +1 -0
  21. package/index.js +7 -0
  22. package/package.json +5 -3
  23. package/src/application/control/agent.js +61 -0
  24. package/src/application/control/catalog.js +22 -0
  25. package/src/application/control/controlClient.js +75 -0
  26. package/src/application/control/controlStore.js +55 -0
  27. package/src/application/control/controller.js +22 -0
  28. package/src/application/control/executionSnapshot.js +32 -0
  29. package/src/application/control/index.js +7 -0
  30. package/src/application/control/localAssignment.js +13 -0
  31. package/src/application/control/schedule.js +103 -0
  32. package/src/application/control/snapshotFile.js +24 -0
  33. package/src/application/foldedMetricsSink.js +1 -0
  34. package/src/application/mcp/mcpResources.js +1 -1
  35. package/src/application/mcp/mcpSchema.js +8 -3
  36. package/src/application/runtime/additionalAdapters.js +13 -9
  37. package/src/application/runtime/deliveryQueue.js +62 -0
  38. package/src/application/runtime/deliverySessions.js +28 -0
  39. package/src/application/runtime/modbusDelivery.js +36 -0
  40. package/src/application/runtime/pipelineAdapters.js +12 -8
  41. package/src/application/runtime/queuedDelivery.js +25 -0
  42. package/src/application/runtime/runCollector.js +34 -3
  43. package/src/application/runtime/runtime.js +2 -2
  44. package/src/application/runtime/runtimeHealth.js +1 -1
  45. package/src/application/runtime/runtimeServices.js +6 -2
  46. package/src/application/runtime/streamTask.js +13 -4
  47. package/src/application/runtime/taskContext.js +1 -0
  48. package/src/application/runtime/taskSlot.js +2 -2
  49. package/src/application/runtime/telemetrySink.js +18 -0
  50. package/src/application/siteServer.js +19 -4
  51. package/src/application/siteTelemetry.js +2 -2
  52. package/src/application/supervisorSink.js +32 -12
  53. package/src/application/sync/siteSyncBind.js +2 -2
  54. package/src/bin/controller.js +8 -0
  55. package/src/infrastructure/http/edge/edgeApi.js +2 -0
  56. package/src/infrastructure/http/edge/routes/history/historyRoutes.js +33 -0
  57. package/src/infrastructure/http/plant/routes/measurementRead.js +3 -0
  58. package/src/infrastructure/ingest/db/migrate.js +16 -0
  59. package/src/infrastructure/ingest/db/migrationProfile.js +6 -1
  60. package/src/infrastructure/ingest/db/retainMetricReceipts.js +8 -0
  61. package/src/infrastructure/ingest/db/runRetention.js +2 -0
  62. package/src/infrastructure/ingest/mqtt/metricsTransformer.js +11 -2
  63. package/src/infrastructure/ingest/mqtt/modbusMqtt.js +1 -1
  64. package/src/infrastructure/ingest/mqtt/modbusPublish.js +2 -0
  65. package/src/infrastructure/ingest/mqtt/mqttMetrics.js +1 -1
  66. package/src/infrastructure/ingest/telemetry/amqpMetricsIngest.js +7 -3
  67. package/src/infrastructure/ingest/telemetry/centralEnvelope.js +46 -0
  68. package/src/infrastructure/ingest/telemetry/centralMetricsSink.js +64 -0
  69. package/src/infrastructure/ingest/telemetry/centralPoint.js +14 -0
  70. package/src/infrastructure/ingest/telemetry/centralPolicy.js +51 -0
  71. package/src/infrastructure/ingest/telemetry/centralQueueSession.js +29 -0
  72. package/src/infrastructure/ingest/telemetry/centralTelemetryPreflight.js +31 -0
  73. package/src/infrastructure/ingest/telemetry/foldingSink.js +3 -0
  74. package/src/infrastructure/ingest/telemetry/historyTelemetry.js +32 -0
  75. package/src/infrastructure/persistence/clickhouse/canonicalMetrics.js +26 -0
  76. package/src/infrastructure/persistence/clickhouse/changes.js +4 -2
  77. package/src/infrastructure/persistence/clickhouse/connection.js +6 -8
  78. package/src/infrastructure/persistence/clickhouse/holds.js +10 -7
  79. package/src/infrastructure/persistence/clickhouse/latest.js +1 -1
  80. package/src/infrastructure/persistence/clickhouse/metricsQuery.js +70 -0
  81. package/src/infrastructure/persistence/clickhouse/metricsRelation.js +110 -0
  82. package/src/infrastructure/persistence/clickhouse/nativeMetricPoints.js +26 -0
  83. package/src/infrastructure/persistence/clickhouse/nativeMetricsAdmission.js +91 -0
  84. package/src/infrastructure/persistence/clickhouse/nativeMetricsClock.js +9 -0
  85. package/src/infrastructure/persistence/clickhouse/nativeMetricsCompaction.js +82 -0
  86. package/src/infrastructure/persistence/clickhouse/nativeMetricsInsert.js +31 -0
  87. package/src/infrastructure/persistence/clickhouse/nativeMetricsOwnership.js +8 -0
  88. package/src/infrastructure/persistence/clickhouse/nativeMetricsSchema.js +44 -0
  89. package/src/infrastructure/persistence/clickhouse/pollTopicCursors.js +3 -1
  90. package/src/infrastructure/persistence/clickhouse/rises.js +4 -2
  91. package/src/infrastructure/persistence/clickhouse/samples.js +10 -0
  92. package/src/infrastructure/persistence/clickhouse/sensor.js +4 -0
  93. package/src/infrastructure/persistence/clickhouse/series.js +38 -21
  94. package/src/infrastructure/persistence/pg/history.js +169 -0
  95. package/src/infrastructure/persistence/pg/historyAdmission.js +81 -0
  96. package/src/infrastructure/persistence/pg/historyCheckpoint.js +56 -0
  97. package/src/infrastructure/persistence/pg/historyConfigure.js +28 -0
  98. package/src/infrastructure/persistence/pg/historyContext.js +65 -0
  99. package/src/infrastructure/persistence/pg/historyCorrection.js +34 -0
  100. package/src/infrastructure/persistence/pg/historyObservations.js +56 -0
  101. package/src/infrastructure/persistence/pg/historySeed.js +27 -0
  102. package/src/infrastructure/persistence/pg/metrics.js +5 -4
  103. package/src/infrastructure/persistence/pg/metricsInsertSql.js +12 -0
  104. package/src/infrastructure/persistence/runtime/deliverySpool.js +124 -0
  105. package/src/infrastructure/persistence/stateDataFromPool.js +2 -0
  106. package/src/infrastructure/streams/amqpSink/session.js +6 -0
  107. package/src/infrastructure/streams/amqpSource.js +17 -4
package/README.md CHANGED
@@ -208,7 +208,45 @@ SQL files in `db/migrations/` use profile prefixes:
208
208
  | `E*` | Edge only (metrics tables, retention) |
209
209
  | `C*` | Central only (central privileges, including segment DELETE) |
210
210
 
211
- Set `SINK_DB_PROFILE=central|edge`. Migrations run at supervisor-sink startup via `POSTGRES_ADMIN_URL`.
211
+ Set `SINK_DB_PROFILE=central|edge`. By default, migrations run at supervisor-sink
212
+ startup via `POSTGRES_ADMIN_URL` (`SUPERVISOR_MIGRATIONS=apply`).
213
+
214
+ After a separate administrative bootstrap has applied the image's complete
215
+ migration set, set `SUPERVISOR_MIGRATIONS=verify` and remove `POSTGRES_ADMIN_URL`
216
+ from the runtime container. Startup then uses only `POSTGRES_URL` to SELECT the
217
+ recorded versions in `public.schema_migrations`. It checks shared and selected
218
+ profile migrations, including privileged migrations, before starting consumers or
219
+ HTTP. An absent/inaccessible registry or any missing migration stops startup;
220
+ it never creates the registry or falls back to administrative credentials.
221
+ Collector task-state migration remains separately opt-in, as in apply mode.
222
+ This verifies migration records, not schema checksums or effective DML privileges.
223
+
224
+ The restricted runtime role needs database CONNECT, public schema USAGE,
225
+ `GRANT SELECT ON public.schema_migrations TO <runtime_role>`, and the DML/sequence
226
+ grants required by its enabled pipelines and APIs. It needs no schema CREATE,
227
+ registry INSERT, table ownership or elevated role attributes for verification.
228
+ Do not mount an administrative Secret into verify-mode runtime containers.
229
+ Complete each image's bootstrap and role grants before switching it; retain the
230
+ administrative identity only in the separate migration job. Use the exact main
231
+ commit whose mandatory checks passed before releasing a new image.
232
+
233
+ For chart-managed PostgreSQL, select this boundary with:
234
+
235
+ ```yaml
236
+ postgres:
237
+ migrationsMode: verify
238
+ secret: postgres-bootstrap
239
+ runtimeSecret: postgres-runtime
240
+ ```
241
+
242
+ `runtimeSecret` must differ from the bootstrap Secret and contain the restricted
243
+ connection string under `url`. The chart injects it as POSTGRES_URL, sets
244
+ SUPERVISOR_MIGRATIONS=verify, and omits POSTGRES_ADMIN_URL from both application
245
+ containers. Bootstrap credentials remain on PostgreSQL. Apply mode keeps the
246
+ legacy adminUrl reference; an optional runtimeSecret can separately supply its
247
+ POSTGRES_URL. With postgres.enabled=false, explicit application env values
248
+ continue to configure external databases without generated PostgreSQL settings.
249
+ Do not add administrative credentials through env/envFrom when selecting verify.
212
250
 
213
251
  ## Environment (supervisor-sink / siteServer)
214
252
 
@@ -216,7 +254,8 @@ Set `SINK_DB_PROFILE=central|edge`. Migrations run at supervisor-sink startup vi
216
254
  |----------|---------|
217
255
  | `STOMP_URL` | RabbitMQ STOMP broker |
218
256
  | `POSTGRES_URL` | Application DB user (`supervisor_sink`) |
219
- | `POSTGRES_ADMIN_URL` | Admin user for migrations |
257
+ | `POSTGRES_ADMIN_URL` | Admin user for apply-mode migrations; omit in verify mode |
258
+ | `SUPERVISOR_MIGRATIONS` | `apply` (default) or `verify`; other values fail startup |
220
259
  | `SINK_DB_PROFILE` | `central` or `edge` |
221
260
  | `SINK_PIPELINES` | `false` skips STOMP segment, decision, and alert consumers. The site container sets this and a `supervisor-sink` container keeps the default |
222
261
  | `SEGMENT_REPAIR_HISTORY_ON_START` | `false` preserves closed historical boundaries at ingest startup. Omitted or `true` retains the existing same-name gap repair. Live ingest and silent-open handling remain active. |
@@ -596,3 +635,98 @@ Silent Modbus backup sources use `MX210/<device>` freshness identities. AMQP tel
596
635
  ### MQTT publisher recovery
597
636
 
598
637
  An unexpected MQTT publisher close/offline/error retires the session and notifies `onFatal` once. Intentional `stop()` does not notify failure. Modbus runtime tasks propagate publisher failure to collector `/ready` and `/live` (503). Run the collector under its liveness supervisor: it must retire the failed executor and create a fresh one, which reconnects after the broker returns. Uncertain publications are not automatically replayed. Broker restart regression covers failed health, old poll cleanup, and confirmed fresh measurements from the replacement executor.
638
+
639
+ ### Central canonical telemetry, version 4
640
+
641
+ `CENTRAL_TELEMETRY_POLICY` is generated by the deployment DSL. Runtime capability
642
+ `centralTelemetryVersion === 4` rejects old bitmap/PG review configurations.
643
+ There is no PostgreSQL telemetry registry and no bitmap/custom aggregate storage.
644
+
645
+ All protected AMQP/MQTT/sync/external adapters publish immutable, bounded batches
646
+ to ONE durable RabbitMQ SAC queue, prefetch1, persistent mandatory confirms,
647
+ reject-publish overflow, no TTL/priorities. A failed unacked head is held in place.
648
+ Its frozen central `admittedAt` and per-topic policy survive retries. The worker
649
+ uses synchronous ClickHouse inserts and commits its bounded metadata counter
650
+ only after point/rejection writes, before source ACK.
651
+
652
+ Central point admission and endpoint publication use RowBinary to preserve Float64 values and UInt128 revisions exactly. The writer drains the complete synchronous ClickHouse response before committing the admission cursor.
653
+
654
+ Ordinary `scada.metrics_points_v4` rows use ReplacingMergeTree(revision), keyed by
655
+ (topic, original millisecond timestamp). Last durable admission wins, including
656
+ array order within a batch. The user removed the previous first-value rule.
657
+ Native versions prevent delayed old INSERTs overtaking a newer admitted value;
658
+ FINAL reads are correct before background merges too.
659
+
660
+ Default policy fields (all overridable for exact topics):
661
+
662
+ - compactWindowMs:60000; zero disables physical thinning.
663
+ - maxGapMs:30000; positive maximum interval in the merged sensor stream; exact-topic overrides are supported.
664
+ - historyWindowMs:604800000; seven days behind this topic's latest valid point.
665
+ - maxHistoryAgeMs:2592000000; thirty-day calendar cap at central admission.
666
+ - futureSkewMs:300000; far-future source clocks are rejected before watermarking.
667
+
668
+ A topic's sealed frontier advances monotonically, only at complete-window
669
+ boundaries. Previous production history seeds the initial watermark. A longer
670
+ configured window never reopens sealed history. Too-old/future observations go
671
+ to separately named TTL-bounded diagnostics before ACK and never alter canonical
672
+ history. No automatic old-history update, addition or deletion is accepted.
673
+
674
+ Recent observations retain all original timestamps. In a sealed constant-value
675
+ window, observations are split into continuity islands: a gap strictly greater than frozen maxGapMs starts a new island; equality remains continuous. Each island retains its first/last observations; a singleton stays once. In a window with
676
+ ANY different value, EVERY canonical point is retained, including short spikes,
677
+ returns and oscillations. There is no average, value tolerance or time rounding
678
+ that can hide an observed differing value. Overlapping policies/legacy windows
679
+ are conservatively retained.
680
+
681
+ Native background DELETE mutations physically remove equal interior points.
682
+ Two ordinary retained endpoint rows carry explicit constant-span/revision
683
+ certificates: an older differing INSERT cannot resurrect a deleted superseded
684
+ interior. Complete endpoint proofs are durable before deletion, with a read grace
685
+ on publication. Cleanup limits pending mutations; failures retain extra rows
686
+ and retry, never lose canonical values. This reduces actual stored observations,
687
+ not merely a SELECT result. There is no forever-full hidden raw copy.
688
+
689
+ `scada.metrics_read` is the canonical relation; `metrics_raw_read` exposes retained
690
+ point rows and cannot reconstruct deleted timestamps. Level changes/edges remain
691
+ available. Density-sensitive counts/minPoints use bounded
692
+ `clickhouseMetricsRawRange`, which explicitly rejects sealed constant ranges with
693
+ `SCADA_HISTORY_DENSITY_UNAVAILABLE` instead of silently computing from endpoints.
694
+ Graphs may clip constant coverage using derived display vertices, which are not
695
+ original observations. Edge raw history and local classifications are untouched.
696
+
697
+ Legacy scada.metrics stays readable and unchanged with precedence on overlapping
698
+ keys. Only missing additive schema falls back; permission/schema failures surface.
699
+ One authoritative read-after-write ClickHouse target is required. Serving reads
700
+ through lagging asynchronous replicas is unsupported. Atomic table comments pin
701
+ broker/vhost/queue/target; an independent domain cannot race the same data. Existing
702
+ v1/v2/v3 review schemas/envelopes require an explicit migration, not silent reuse.
703
+ Disable after activation and immutable queue argument changes fail closed.
704
+
705
+ No merge, deployment, running-database migration, package/image publication or
706
+ release is performed by opening or updating this PR.
707
+
708
+ Native v4 persists each observation's frozen `max_gap_ms`. Certificates prove continuous coverage for one island, so deletion and repeated cleanup never turn a certified interval into a false gap or join separate islands. Interleaved collectors are merged by logical topic and timestamp before detecting gaps. Mixed-value windows remain entirely retained. Chart downsampling groups by continuity before time buckets and emits explicit null separators; native numeric points carry `continuous` metadata so consumers do not infer false gaps from sparse certified endpoints. Holds may use certificates when requested gap is at least the stored threshold; stricter raw-density requests remain explicitly unavailable.
709
+
710
+ Older unpublished v3 native tables/envelopes require an explicit migration and are rejected; erased gap evidence cannot be recovered from their endpoints. No automatic upgrade or production migration runs in these PRs. Ordinary legacy `scada.metrics` remains readable and unmodified.
711
+
712
+ HTTP and display MCP results preserve continuity metadata and null separators. `sensor.samples(range)` uses the exact-density guard and returns actual observations for coverage analytics; unsupported raw readers fail explicitly. Two-point unthinned islands retain exact density. Frontends show isolated observations, and peak analytics ignore null separators.
713
+
714
+ ### Broker credential Secrets
715
+
716
+ Set `rabbitmq.definitionsSecret` to a separately provisioned Secret with the key
717
+ `definitions.json`; the chart then omits definitions from its ConfigMap. Set
718
+ `rabbitmq.runtimeSecret` for `AMQP_URL`, `STOMP_LOGIN` and `STOMP_PASSCODE`.
719
+ Other clients can reference the same or narrower Secrets explicitly. Anonymous
720
+ MQTT remains compatible by default; set `rabbitmq.extraConfig["mqtt.allow_anonymous"]`
721
+ to false only after all MQTT clients have authenticated credentials. A frozen
722
+ broker PodTemplate cannot adopt these mounts: unfreeze it for a controlled
723
+ restart while preserving the claim. Definitions import does not delete an
724
+ existing guest user; retire it explicitly after all dependent clients reconnect.
725
+
726
+ ### Collector recovery and durable delivery references
727
+
728
+ Collector health opens before local spool recovery; `/live` remains responsive and `/ready` stays negative until recovery and a saved/initial assignment are applied. Cached assignments start without waiting for the first network reconciliation. `COLLECTOR_RECOVERY_TIMEOUT_MS` defaults to 900000 and bounds local initialization; exceeding it terminates startup for the external supervisor. Validate recovery duration against measured queue capacity before activation.
729
+
730
+ Spooled destination descriptors retain secret references. Draining a recovered queue resolves the current secret for each logical recipient, so credential rotation does not freeze a password in queued observations. Source connection credentials are still resolved at resource construction. Scheduler updates preserve a potentially working replica until another matching reader reports fresh progress, except explicit current-generation failure.
731
+
732
+ Central canonical ingestion propagates the receiver session ownership predicate through schema initialization and admission. It checks ownership again after authoritative state/clock reads and before writes; a lost session cannot allocate a newer revision from a delayed SELECT. Already submitted old-revision inserts remain safe under canonical winner ordering.
@@ -63,26 +63,41 @@ volumeMode: Filesystem
63
63
  - name: POSTGRES_URL
64
64
  valueFrom:
65
65
  secretKeyRef:
66
- name: {{ .Values.postgres.secret }}
66
+ name: {{ default .Values.postgres.secret .Values.postgres.runtimeSecret }}
67
67
  key: url
68
+ {{- if eq .Values.postgres.migrationsMode "verify" }}
69
+ - name: SUPERVISOR_MIGRATIONS
70
+ value: "verify"
71
+ {{- else }}
68
72
  - name: POSTGRES_ADMIN_URL
69
73
  valueFrom:
70
74
  secretKeyRef:
71
75
  name: {{ .Values.postgres.secret }}
72
76
  key: adminUrl
73
77
  {{- end }}
78
+ {{- end }}
74
79
  {{- if .Values.rabbitmq.enabled }}
75
80
  - name: STOMP_URL
76
81
  value: {{ printf "stomp://%s-rabbitmq:61613" (include "scada.prefix" .) | quote }}
82
+ {{- if .Values.rabbitmq.runtimeSecret }}
83
+ {{- range $name := list "STOMP_LOGIN" "STOMP_PASSCODE" "AMQP_URL" }}
84
+ - name: {{ $name }}
85
+ valueFrom:
86
+ secretKeyRef:
87
+ name: {{ $.Values.rabbitmq.runtimeSecret | quote }}
88
+ key: {{ $name }}
89
+ {{- end }}
90
+ {{- else }}
77
91
  - name: STOMP_LOGIN
78
92
  value: guest
79
93
  - name: STOMP_PASSCODE
80
94
  value: guest
81
- - name: STOMP_HOST
82
- value: /
83
95
  - name: AMQP_URL
84
96
  value: {{ printf "amqp://guest:guest@%s-rabbitmq:5672" (include "scada.prefix" .) | quote }}
85
97
  {{- end }}
98
+ - name: STOMP_HOST
99
+ value: /
100
+ {{- end }}
86
101
  {{- if .Values.clickhouse.enabled }}
87
102
  - name: CLICKHOUSE_HOST
88
103
  value: {{ printf "%s-clickhouse" (include "scada.prefix" .) | quote }}
@@ -1,4 +1,10 @@
1
1
  {{- if .Values.postgres.enabled }}
2
+ {{- if eq .Values.postgres.migrationsMode "verify" }}
3
+ {{- $runtimeSecret := required "postgres.runtimeSecret is required in verify mode" .Values.postgres.runtimeSecret }}
4
+ {{- if eq $runtimeSecret .Values.postgres.secret }}
5
+ {{- fail "postgres.runtimeSecret must differ from bootstrap postgres.secret in verify mode" }}
6
+ {{- end }}
7
+ {{- end }}
2
8
  apiVersion: v1
3
9
  kind: Service
4
10
  metadata:
@@ -76,12 +76,15 @@ data:
76
76
  rabbitmq.conf: |
77
77
  load_definitions = /etc/rabbitmq/definitions.json
78
78
  mqtt.listeners.tcp.default = 1883
79
- mqtt.allow_anonymous = true
79
+ mqtt.allow_anonymous = {{ if hasKey (.Values.rabbitmq.extraConfig | default dict) "mqtt.allow_anonymous" }}{{ get .Values.rabbitmq.extraConfig "mqtt.allow_anonymous" }}{{ else }}true{{ end }}
80
80
  mqtt.vhost = /
81
81
  mqtt.exchange = scada.telemetry
82
82
  {{- range $key, $value := .Values.rabbitmq.extraConfig }}
83
+ {{- if ne $key "mqtt.allow_anonymous" }}
83
84
  {{ $key }} = {{ $value }}
84
85
  {{- end }}
86
+ {{- end }}
87
+ {{- if not .Values.rabbitmq.definitionsSecret }}
85
88
  definitions.json: |
86
89
  {{- if ne .Values.rabbitmq.definitions nil }}
87
90
  {{ .Values.rabbitmq.definitions | toPrettyJson | nindent 4 }}
@@ -89,3 +92,4 @@ data:
89
92
  {{ $definitions | toPrettyJson | nindent 4 }}
90
93
  {{- end }}
91
94
  {{- end }}
95
+ {{- end }}
@@ -1,4 +1,7 @@
1
1
  {{- if .Values.rabbitmq.enabled }}
2
+ {{- if and .Values.rabbitmq.definitionsSecret .Values.rabbitmq.podTemplate }}
3
+ {{- fail "rabbitmq.definitionsSecret requires the managed pod template; unfreeze storage templates for the controlled migration restart" }}
4
+ {{- end }}
2
5
  apiVersion: v1
3
6
  kind: Service
4
7
  metadata:
@@ -98,12 +101,20 @@ spec:
98
101
  - name: config
99
102
  mountPath: /etc/rabbitmq/rabbitmq.conf
100
103
  subPath: rabbitmq.conf
101
- - name: config
104
+ - name: {{ ternary "definitions" "config" (not (empty .Values.rabbitmq.definitionsSecret)) }}
102
105
  mountPath: /etc/rabbitmq/definitions.json
103
106
  subPath: definitions.json
104
107
  - name: data
105
108
  mountPath: /var/lib/rabbitmq
106
109
  volumes:
110
+ {{- with .Values.rabbitmq.definitionsSecret }}
111
+ - name: definitions
112
+ secret:
113
+ secretName: {{ . | quote }}
114
+ items:
115
+ - key: definitions.json
116
+ path: definitions.json
117
+ {{- end }}
107
118
  - name: config
108
119
  configMap:
109
120
  name: {{ include "scada.brokerConfigName" . }}
@@ -35,7 +35,12 @@ spec:
35
35
  {{- include "scada.linkEnv" . | nindent 12 }}
36
36
  {{- range .Values.env }}
37
37
  - name: {{ .name }}
38
+ {{- if .valueFrom }}
39
+ valueFrom:
40
+ {{- toYaml .valueFrom | nindent 16 }}
41
+ {{- else }}
38
42
  value: {{ .value | quote }}
43
+ {{- end }}
39
44
  {{- end }}
40
45
  readinessProbe:
41
46
  tcpSocket:
@@ -115,8 +115,47 @@
115
115
  "podTemplate": {
116
116
  "type": "object",
117
117
  "description": "Opaque PodTemplateSpec override for preserving existing storage pods during adoption; empty uses generated defaults."
118
+ },
119
+ "migrationsMode": {
120
+ "type": "string",
121
+ "enum": [
122
+ "apply",
123
+ "verify"
124
+ ]
125
+ },
126
+ "runtimeSecret": {
127
+ "type": "string"
118
128
  }
119
- }
129
+ },
130
+ "allOf": [
131
+ {
132
+ "if": {
133
+ "required": [
134
+ "enabled",
135
+ "migrationsMode"
136
+ ],
137
+ "properties": {
138
+ "enabled": {
139
+ "const": true
140
+ },
141
+ "migrationsMode": {
142
+ "const": "verify"
143
+ }
144
+ }
145
+ },
146
+ "then": {
147
+ "required": [
148
+ "runtimeSecret"
149
+ ],
150
+ "properties": {
151
+ "runtimeSecret": {
152
+ "type": "string",
153
+ "minLength": 1
154
+ }
155
+ }
156
+ }
157
+ }
158
+ ]
120
159
  },
121
160
  "rabbitmq": {
122
161
  "type": "object",
@@ -124,6 +163,12 @@
124
163
  "podTemplate": {
125
164
  "type": "object",
126
165
  "description": "Opaque PodTemplateSpec override for preserving existing storage pods during adoption; empty uses generated defaults."
166
+ },
167
+ "definitionsSecret": {
168
+ "type": "string"
169
+ },
170
+ "runtimeSecret": {
171
+ "type": "string"
127
172
  }
128
173
  }
129
174
  }
@@ -30,6 +30,10 @@ postgres:
30
30
  enabled: true
31
31
  image: postgres:16
32
32
  secret: scada-postgres
33
+ # apply preserves startup migrations; verify uses a separately bootstrapped DB.
34
+ migrationsMode: apply
35
+ # Required and distinct from secret in verify mode; contains only runtime url.
36
+ runtimeSecret: ""
33
37
  # Existing PVC: no PVC or volumeClaimTemplate is created.
34
38
  existingClaim: ""
35
39
  env: {}
@@ -56,6 +60,9 @@ rabbitmq:
56
60
  configName: ""
57
61
  rolloutOnConfigChange: false
58
62
  definitions: null
63
+ # Secure definitions are provisioned separately; passwords never enter ConfigMaps.
64
+ definitionsSecret: ""
65
+ runtimeSecret: ""
59
66
  plugins: [rabbitmq_stomp, rabbitmq_mqtt, rabbitmq_management]
60
67
  extraConfig: {}
61
68
  resources: {}
@@ -0,0 +1,5 @@
1
+ -- Review-only migration source. Applied only during a separately authorized deployment.
2
+ GRANT SELECT, INSERT, DELETE ON history_observations TO supervisor_sink;
3
+ GRANT SELECT, INSERT, UPDATE, DELETE ON history_work TO supervisor_sink;
4
+ GRANT SELECT, INSERT, DELETE ON history_topics TO supervisor_sink;
5
+ GRANT SELECT, INSERT, UPDATE ON history_annotations TO supervisor_sink;
@@ -0,0 +1,64 @@
1
+ CREATE TABLE IF NOT EXISTS history_observations (
2
+ machine TEXT NOT NULL,
3
+ channel TEXT NOT NULL,
4
+ time_ms BIGINT NOT NULL,
5
+ event_id TEXT NOT NULL,
6
+ value DOUBLE PRECISION NOT NULL,
7
+ received_at TIMESTAMPTZ NOT NULL DEFAULT now(),
8
+ PRIMARY KEY (machine, channel, time_ms),
9
+ UNIQUE (machine, event_id)
10
+ );
11
+ CREATE INDEX IF NOT EXISTS history_observations_time ON history_observations(machine,time_ms);
12
+ CREATE TABLE IF NOT EXISTS history_work (
13
+ id UUID PRIMARY KEY,
14
+ token UUID NOT NULL DEFAULT gen_random_uuid(),
15
+ machine TEXT NOT NULL,
16
+ from_ms BIGINT NOT NULL,
17
+ until_ms BIGINT NOT NULL,
18
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now()
19
+ );
20
+ CREATE INDEX IF NOT EXISTS history_work_machine ON history_work(machine, created_at);
21
+ CREATE TABLE IF NOT EXISTS history_annotations (
22
+ machine TEXT NOT NULL,
23
+ kind TEXT NOT NULL,
24
+ start_time TIMESTAMPTZ NOT NULL,
25
+ name TEXT NOT NULL,
26
+ end_time TIMESTAMPTZ,
27
+ duration DOUBLE PRECISION,
28
+ tags TEXT,
29
+ properties TEXT,
30
+ resolved BOOLEAN,
31
+ PRIMARY KEY(machine,kind,start_time,name)
32
+ );
33
+ CREATE TABLE IF NOT EXISTS history_topics (
34
+ machine TEXT NOT NULL,
35
+ topic TEXT NOT NULL,
36
+ channel TEXT NOT NULL,
37
+ bucket_ms BIGINT NOT NULL DEFAULT 30000 CHECK(bucket_ms > 0),
38
+ retention_days INTEGER NOT NULL DEFAULT 30 CHECK(retention_days > 0),
39
+ PRIMARY KEY(machine,topic)
40
+ );
41
+ CREATE OR REPLACE FUNCTION history_from_metric() RETURNS TRIGGER LANGUAGE plpgsql AS $$
42
+ DECLARE mapping RECORD; moment BIGINT; inserted INTEGER;
43
+ BEGIN
44
+ moment := floor(extract(epoch FROM NEW.ts)*1000)::bigint;
45
+ FOR mapping IN SELECT * FROM history_topics WHERE topic=NEW.topic LOOP
46
+ PERFORM pg_advisory_xact_lock(hashtextextended('history:'||mapping.machine,0));
47
+ INSERT INTO history_observations(machine,channel,time_ms,event_id,value)
48
+ VALUES(mapping.machine,mapping.channel,moment,md5(NEW.topic||':'||moment::text||':'||NEW.value::text),NEW.value)
49
+ ON CONFLICT DO NOTHING;
50
+ GET DIAGNOSTICS inserted = ROW_COUNT;
51
+ IF inserted > 0 AND NEW.ts >= now()-make_interval(days => mapping.retention_days) THEN
52
+ INSERT INTO history_work(id,machine,from_ms,until_ms)
53
+ VALUES(md5(mapping.machine||':'||(moment/mapping.bucket_ms)::text)::uuid,mapping.machine,moment,moment)
54
+ ON CONFLICT(id) DO UPDATE SET token=gen_random_uuid(),from_ms=least(history_work.from_ms,excluded.from_ms),until_ms=greatest(history_work.until_ms,excluded.until_ms);
55
+ END IF;
56
+ END LOOP;
57
+ RETURN NEW;
58
+ END $$;
59
+ DO $$ BEGIN
60
+ IF to_regclass('metrics') IS NOT NULL THEN
61
+ DROP TRIGGER IF EXISTS metrics_history ON metrics;
62
+ CREATE TRIGGER metrics_history AFTER INSERT ON metrics FOR EACH ROW EXECUTE FUNCTION history_from_metric();
63
+ END IF;
64
+ END $$;
@@ -0,0 +1,7 @@
1
+ -- Opt-in first-write-wins receipts survive receiver restart and raw metric retention.
2
+ CREATE TABLE IF NOT EXISTS metric_receipts (
3
+ topic TEXT NOT NULL,
4
+ ts TIMESTAMPTZ NOT NULL,
5
+ value DOUBLE PRECISION NOT NULL,
6
+ PRIMARY KEY(topic,ts)
7
+ );
@@ -0,0 +1 @@
1
+ GRANT SELECT, INSERT, DELETE ON metric_receipts TO supervisor_sink;
@@ -0,0 +1,20 @@
1
+ ALTER TABLE history_work ADD COLUMN IF NOT EXISTS cursor_ms BIGINT;
2
+ ALTER TABLE history_work ADD COLUMN IF NOT EXISTS end_ms BIGINT;
3
+ CREATE OR REPLACE FUNCTION history_from_metric() RETURNS TRIGGER LANGUAGE plpgsql AS $$
4
+ DECLARE mapping RECORD; moment BIGINT; inserted INTEGER;
5
+ BEGIN
6
+ moment := floor(extract(epoch FROM NEW.ts)*1000)::bigint;
7
+ FOR mapping IN SELECT * FROM history_topics WHERE topic=NEW.topic LOOP
8
+ PERFORM pg_advisory_xact_lock(hashtextextended('history:'||mapping.machine,0));
9
+ INSERT INTO history_observations(machine,channel,time_ms,event_id,value)
10
+ VALUES(mapping.machine,mapping.channel,moment,md5(NEW.topic||':'||moment::text||':'||NEW.value::text),NEW.value)
11
+ ON CONFLICT DO NOTHING;
12
+ GET DIAGNOSTICS inserted = ROW_COUNT;
13
+ IF inserted > 0 AND NEW.ts >= now()-make_interval(days => mapping.retention_days) THEN
14
+ INSERT INTO history_work(id,machine,from_ms,until_ms)
15
+ VALUES(md5(mapping.machine||':'||(moment/mapping.bucket_ms)::text)::uuid,mapping.machine,moment,moment)
16
+ ON CONFLICT(id) DO UPDATE SET token=gen_random_uuid(),cursor_ms=NULL,end_ms=NULL,from_ms=least(history_work.from_ms,excluded.from_ms),until_ms=greatest(history_work.until_ms,excluded.until_ms);
17
+ END IF;
18
+ END LOOP;
19
+ RETURN NEW;
20
+ END $$;
@@ -0,0 +1,8 @@
1
+ -- Temporary cross-database barriers contain identity/range only, never numeric payloads.
2
+ CREATE TABLE IF NOT EXISTS history_admissions (
3
+ event_id TEXT PRIMARY KEY,
4
+ topic TEXT NOT NULL,
5
+ time_ms BIGINT NOT NULL,
6
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now()
7
+ );
8
+ CREATE INDEX IF NOT EXISTS history_admissions_topic ON history_admissions(topic,time_ms);
@@ -0,0 +1,18 @@
1
+ CREATE TABLE IF NOT EXISTS history_classifiers (
2
+ machine TEXT PRIMARY KEY,
3
+ classifier_key TEXT NOT NULL
4
+ );
5
+ CREATE TABLE IF NOT EXISTS history_checkpoints (
6
+ machine TEXT NOT NULL,
7
+ classifier_key TEXT NOT NULL,
8
+ time_ms BIGINT NOT NULL,
9
+ state JSONB NOT NULL,
10
+ valid BOOLEAN NOT NULL DEFAULT true,
11
+ PRIMARY KEY(machine,classifier_key,time_ms)
12
+ );
13
+ -- Persistent source identity prevents interpreting legacy millisecond work as microseconds.
14
+ CREATE TABLE IF NOT EXISTS history_sources (
15
+ machine TEXT PRIMARY KEY,
16
+ source_id TEXT NOT NULL,
17
+ time_scale INTEGER NOT NULL CHECK(time_scale IN (1,1000))
18
+ );
@@ -0,0 +1,4 @@
1
+ GRANT SELECT, INSERT, DELETE ON history_admissions TO supervisor_sink;
2
+ GRANT SELECT, INSERT, UPDATE, DELETE ON history_classifiers TO supervisor_sink;
3
+ GRANT SELECT, INSERT, UPDATE, DELETE ON history_checkpoints TO supervisor_sink;
4
+ GRANT SELECT, INSERT ON history_sources TO supervisor_sink;
@@ -0,0 +1,104 @@
1
+ ALTER TABLE history_annotations ADD COLUMN IF NOT EXISTS consumed BOOLEAN DEFAULT true;
2
+ ALTER TABLE history_work ADD COLUMN IF NOT EXISTS generation UUID NOT NULL DEFAULT gen_random_uuid();
3
+ ALTER TABLE history_work ADD COLUMN IF NOT EXISTS correction_from BIGINT;
4
+ ALTER TABLE history_work ADD COLUMN IF NOT EXISTS correction_until BIGINT;
5
+ ALTER TABLE history_work ADD COLUMN IF NOT EXISTS classifier_checkpoint JSONB;
6
+ ALTER TABLE history_work ADD COLUMN IF NOT EXISTS started BOOLEAN NOT NULL DEFAULT false;
7
+ CREATE TABLE IF NOT EXISTS history_corrections (
8
+ work_id UUID NOT NULL REFERENCES history_work(id) ON DELETE CASCADE,
9
+ generation UUID NOT NULL,
10
+ machine TEXT NOT NULL,
11
+ kind TEXT NOT NULL,
12
+ name TEXT NOT NULL,
13
+ start_time TIMESTAMPTZ NOT NULL,
14
+ end_time TIMESTAMPTZ NOT NULL,
15
+ duration DOUBLE PRECISION NOT NULL,
16
+ options TEXT, tags TEXT, properties TEXT, resolved BOOLEAN,
17
+ PRIMARY KEY(work_id,generation,kind,start_time)
18
+ );
19
+ CREATE TABLE IF NOT EXISTS history_staged_checkpoints (
20
+ work_id UUID NOT NULL REFERENCES history_work(id) ON DELETE CASCADE,
21
+ generation UUID NOT NULL,
22
+ machine TEXT NOT NULL,
23
+ classifier_key TEXT NOT NULL,
24
+ time_ms BIGINT NOT NULL,
25
+ state JSONB NOT NULL,
26
+ PRIMARY KEY(work_id,generation,classifier_key,time_ms)
27
+ );
28
+ CREATE INDEX IF NOT EXISTS history_annotations_semantic ON history_annotations(machine,kind,name,start_time);
29
+
30
+ -- Invoker privileges, transactional caller fencing and original annotation extents are preserved.
31
+ CREATE OR REPLACE FUNCTION history_apply_correction(p_work UUID,p_machine TEXT,p_scale INTEGER,p_converged BOOLEAN)
32
+ RETURNS INTEGER LANGUAGE plpgsql AS $$
33
+ DECLARE w history_work%ROWTYPE; item history_corrections%ROWTYPE; owner history_annotations%ROWTYPE;
34
+ tail segments%ROWTYPE; lo TIMESTAMPTZ; hi TIMESTAMPTZ; a TIMESTAMPTZ; b TIMESTAMPTZ;
35
+ incoming JSONB; inherited JSONB; endpoint_cut BOOLEAN; inserted INTEGER := 0; keys TEXT[] := ARRAY['casting','cadence_rule','cadence_threshold_ms','casting_detected_at','source_interrupted'];
36
+ BEGIN
37
+ SELECT * INTO STRICT w FROM history_work WHERE id=p_work AND machine=p_machine;
38
+ IF p_converged THEN
39
+ FOR item IN SELECT * FROM history_corrections WHERE work_id=w.id AND generation=w.generation AND duration=0 LOOP
40
+ SELECT * INTO tail FROM segments WHERE machine=p_machine AND kind=item.kind AND name=item.name
41
+ AND start_time<=item.end_time AND end_time>item.end_time ORDER BY end_time DESC LIMIT 1;
42
+ IF FOUND THEN
43
+ UPDATE history_corrections SET end_time=tail.end_time,
44
+ duration=CASE WHEN tail.duration=0 THEN 0 ELSE extract(epoch FROM tail.end_time-item.start_time) END
45
+ WHERE work_id=w.id AND generation=w.generation AND kind=item.kind AND start_time=item.start_time;
46
+ END IF;
47
+ END LOOP;
48
+ END IF;
49
+ lo := 'epoch'::timestamptz+(w.correction_from/p_scale)*interval '1 millisecond';
50
+ hi := 'epoch'::timestamptz+(w.correction_until/p_scale)*interval '1 millisecond';
51
+ SELECT least(lo,COALESCE(min(start_time),lo)),greatest(hi,COALESCE(max(end_time),hi)) INTO lo,hi
52
+ FROM history_corrections WHERE work_id=w.id AND generation=w.generation;
53
+ INSERT INTO history_annotations(machine,kind,start_time,name,end_time,duration,tags,properties,resolved,consumed)
54
+ SELECT machine,kind,start_time,name,end_time,duration,tags,properties,resolved,consumed FROM segments
55
+ WHERE machine=p_machine AND kind='phase' AND start_time<=hi AND end_time>=lo
56
+ ON CONFLICT(machine,kind,start_time,name) DO UPDATE SET end_time=greatest(history_annotations.end_time,EXCLUDED.end_time),
57
+ duration=EXCLUDED.duration,tags=EXCLUDED.tags,properties=EXCLUDED.properties,resolved=EXCLUDED.resolved,consumed=EXCLUDED.consumed;
58
+ UPDATE segments SET end_time=lo,duration=greatest(0,extract(epoch FROM lo-start_time)),updated_at=clock_timestamp()
59
+ WHERE machine=p_machine AND kind='phase' AND start_time<lo AND end_time>lo;
60
+ DELETE FROM segments WHERE machine=p_machine AND kind='phase' AND start_time>=lo
61
+ AND (start_time<hi OR (start_time=hi AND end_time=hi));
62
+ FOR item IN SELECT * FROM history_corrections WHERE work_id=w.id AND generation=w.generation ORDER BY start_time LOOP
63
+ SELECT EXISTS(SELECT 1 FROM history_annotations WHERE machine=p_machine AND kind=item.kind AND name=item.name
64
+ AND start_time=item.end_time AND end_time=item.end_time) INTO endpoint_cut;
65
+ a := item.start_time;
66
+ FOR b IN SELECT cut FROM (
67
+ SELECT start_time AS cut FROM history_annotations WHERE machine=p_machine AND kind=item.kind
68
+ AND start_time>item.start_time AND start_time<item.end_time
69
+ UNION SELECT item.end_time
70
+ ) boundaries ORDER BY cut LOOP
71
+ SELECT * INTO owner FROM history_annotations WHERE machine=p_machine AND kind=item.kind AND name=item.name
72
+ AND start_time<=a AND start_time<=item.end_time AND end_time>=item.start_time ORDER BY start_time DESC LIMIT 1;
73
+ IF NOT FOUND THEN
74
+ SELECT * INTO owner FROM history_annotations WHERE machine=p_machine AND kind=item.kind AND name=item.name
75
+ AND start_time>a AND start_time<=item.end_time AND end_time>=item.start_time ORDER BY start_time LIMIT 1;
76
+ END IF;
77
+ incoming := COALESCE(NULLIF(NULLIF(item.properties,''),'null')::jsonb,'{}'::jsonb);
78
+ inherited := COALESCE(NULLIF(NULLIF(owner.properties,''),'null')::jsonb,'{}'::jsonb);
79
+ IF jsonb_typeof(incoming)<>'object' THEN incoming:='{}'::jsonb; END IF;
80
+ IF jsonb_typeof(inherited)<>'object' THEN inherited:='{}'::jsonb; END IF;
81
+ INSERT INTO segments(machine,kind,name,start_time,end_time,duration,options,tags,properties,resolved,consumed,updated_at)
82
+ VALUES(p_machine,item.kind,item.name,a,b,CASE WHEN item.duration=0 AND b=item.end_time AND NOT endpoint_cut THEN 0 ELSE extract(epoch FROM b-a) END,
83
+ item.options,COALESCE(owner.tags,item.tags),(incoming||(inherited-keys))::text,COALESCE(owner.resolved,item.resolved),COALESCE(owner.consumed,true),clock_timestamp())
84
+ ON CONFLICT(machine,kind,start_time) DO UPDATE SET name=EXCLUDED.name,end_time=EXCLUDED.end_time,duration=EXCLUDED.duration,
85
+ options=EXCLUDED.options,tags=EXCLUDED.tags,properties=EXCLUDED.properties,resolved=EXCLUDED.resolved,consumed=EXCLUDED.consumed,updated_at=EXCLUDED.updated_at;
86
+ inserted:=inserted+1; a:=b;
87
+ END LOOP;
88
+ -- A real user cut at the final singleton is retained; ordinary heartbeat ends are not cuts.
89
+ IF item.start_time<item.end_time AND endpoint_cut THEN
90
+ SELECT * INTO owner FROM history_annotations WHERE machine=p_machine AND kind=item.kind AND name=item.name AND start_time=item.end_time;
91
+ incoming := COALESCE(NULLIF(NULLIF(item.properties,''),'null')::jsonb,'{}'::jsonb);
92
+ inherited := COALESCE(NULLIF(NULLIF(owner.properties,''),'null')::jsonb,'{}'::jsonb);
93
+ IF jsonb_typeof(incoming)<>'object' THEN incoming:='{}'::jsonb; END IF;
94
+ IF jsonb_typeof(inherited)<>'object' THEN inherited:='{}'::jsonb; END IF;
95
+ INSERT INTO segments(machine,kind,name,start_time,end_time,duration,options,tags,properties,resolved,consumed)
96
+ VALUES(p_machine,item.kind,item.name,item.end_time,item.end_time,0,item.options,owner.tags,(incoming||(inherited-keys))::text,owner.resolved,COALESCE(owner.consumed,true))
97
+ ON CONFLICT(machine,kind,start_time) DO NOTHING;
98
+ END IF;
99
+ END LOOP;
100
+ INSERT INTO history_checkpoints(machine,classifier_key,time_ms,state,valid)
101
+ SELECT machine,classifier_key,time_ms,state,true FROM history_staged_checkpoints WHERE work_id=w.id AND generation=w.generation
102
+ ON CONFLICT(machine,classifier_key,time_ms) DO UPDATE SET state=EXCLUDED.state,valid=true;
103
+ RETURN inserted;
104
+ END $$;
@@ -0,0 +1,5 @@
1
+ GRANT SELECT, INSERT, UPDATE, DELETE ON history_corrections TO supervisor_sink;
2
+ GRANT SELECT, INSERT, UPDATE, DELETE ON history_staged_checkpoints TO supervisor_sink;
3
+ GRANT SELECT, INSERT, UPDATE, DELETE ON segments TO supervisor_sink;
4
+ REVOKE ALL ON FUNCTION history_apply_correction(UUID,TEXT,INTEGER,BOOLEAN) FROM PUBLIC;
5
+ GRANT EXECUTE ON FUNCTION history_apply_correction(UUID,TEXT,INTEGER,BOOLEAN) TO supervisor_sink;
@@ -0,0 +1,7 @@
1
+ -- O(number of raw backends), never a registry of measurements.
2
+ CREATE TABLE IF NOT EXISTS history_retention (
3
+ source_id TEXT PRIMARY KEY,
4
+ retained_from BIGINT NOT NULL
5
+ );
6
+ ALTER TABLE history_admissions ADD COLUMN IF NOT EXISTS admitted_at BIGINT;
7
+ ALTER TABLE history_annotations ADD COLUMN IF NOT EXISTS consumed BOOLEAN DEFAULT true;
@@ -0,0 +1 @@
1
+ GRANT SELECT, INSERT, UPDATE ON history_retention TO supervisor_sink;
package/index.js CHANGED
@@ -46,6 +46,11 @@ export { default as pgTimeline } from './src/infrastructure/persistence/pg/timel
46
46
  export { default as pgAlerts } from './src/infrastructure/persistence/pg/alerts.js';
47
47
  export { default as pgOperations } from './src/infrastructure/persistence/pg/operations.js';
48
48
  export { default as clickhouseConnection } from './src/infrastructure/persistence/clickhouse/connection.js';
49
+ export { rawMetricsRange as clickhouseMetricsRawRange } from './src/infrastructure/persistence/clickhouse/metricsRelation.js';
50
+ export { rawMetricsRelation as clickhouseMetricsRawRelation } from './src/infrastructure/persistence/clickhouse/metricsRelation.js';
51
+ export { default as clickhouseMetricsRelation } from './src/infrastructure/persistence/clickhouse/metricsRelation.js';
52
+ export const centralTelemetryVersion = 4;
53
+ export { default as centralTelemetryPolicy } from './src/infrastructure/ingest/telemetry/centralPolicy.js';
49
54
  export { default as clickhouseSensor } from './src/infrastructure/persistence/clickhouse/sensor.js';
50
55
  export { default as postgresPool } from './src/infrastructure/persistence/postgresPool.js';
51
56
  export { metricsSinkFromPool as pgMetricsSink } from './src/infrastructure/persistence/pg/metrics.js';
@@ -107,3 +112,5 @@ export { default as executeRelease } from './src/infrastructure/deploy/executeRe
107
112
  export { default as collectorProcesses } from './src/application/deploy/collectorProcesses.js';
108
113
 
109
114
  export { default as executeStages } from './src/infrastructure/deploy/executeStages.js';
115
+
116
+ export { default as historyPg, historyProtocol } from './src/infrastructure/persistence/pg/history.js';