openc3 7.5.1 → 7.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 (169) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -0
  3. data/bin/openc3cli +82 -5
  4. data/data/config/_params.yaml +3 -0
  5. data/data/config/command_modifiers.yaml +5 -3
  6. data/data/config/default_plugins.yaml +1 -0
  7. data/data/config/interface_modifiers.yaml +17 -1
  8. data/data/config/item_modifiers.yaml +24 -1
  9. data/data/config/microservice.yaml +15 -1
  10. data/data/config/parameter_modifiers.yaml +4 -4
  11. data/data/config/plugins.yaml +511 -3
  12. data/data/config/settings.yaml +17 -0
  13. data/data/config/target.yaml +53 -0
  14. data/data/config/telemetry.yaml +58 -2
  15. data/data/config/widgets.yaml +30 -0
  16. data/lib/openc3/accessors/accessor.rb +14 -2
  17. data/lib/openc3/accessors/binary_accessor.rb +25 -5
  18. data/lib/openc3/api/CLAUDE.md +1 -0
  19. data/lib/openc3/api/api.rb +1 -0
  20. data/lib/openc3/api/cmd_api.rb +9 -1
  21. data/lib/openc3/api/interface_api.rb +7 -2
  22. data/lib/openc3/api/limits_api.rb +93 -41
  23. data/lib/openc3/api/router_api.rb +7 -2
  24. data/lib/openc3/api/settings_api.rb +4 -1
  25. data/lib/openc3/api/shared_resource_api.rb +107 -0
  26. data/lib/openc3/api/tlm_api.rb +10 -0
  27. data/lib/openc3/interfaces/http_client_interface.rb +84 -27
  28. data/lib/openc3/interfaces/protocols/preidentified_protocol.rb +6 -2
  29. data/lib/openc3/interfaces/tcpip_server_interface.rb +205 -125
  30. data/lib/openc3/io/json_api.rb +2 -10
  31. data/lib/openc3/io/json_api_object.rb +2 -10
  32. data/lib/openc3/logs/packet_log_writer.rb +8 -3
  33. data/lib/openc3/microservices/decom_common.rb +4 -1
  34. data/lib/openc3/microservices/decom_microservice.rb +52 -6
  35. data/lib/openc3/microservices/interface_decom_common.rb +13 -0
  36. data/lib/openc3/microservices/interface_microservice.rb +50 -11
  37. data/lib/openc3/microservices/limits_group_microservice.rb +513 -0
  38. data/lib/openc3/microservices/log_microservice.rb +22 -8
  39. data/lib/openc3/microservices/microservice.rb +8 -2
  40. data/lib/openc3/microservices/multi_microservice.rb +76 -22
  41. data/lib/openc3/microservices/queue_microservice.rb +29 -24
  42. data/lib/openc3/migrations/20260704000000_default_bridge.rb +1 -2
  43. data/lib/openc3/migrations/20261103000001_limits_group_backfill.rb +193 -0
  44. data/lib/openc3/models/bridge_model.rb +3 -3
  45. data/lib/openc3/models/cvt_model.rb +3 -1
  46. data/lib/openc3/models/host_interface_microservice_model.rb +4 -4
  47. data/lib/openc3/models/interface_model.rb +27 -7
  48. data/lib/openc3/models/microservice_group.rb +167 -0
  49. data/lib/openc3/models/microservice_model.rb +88 -2
  50. data/lib/openc3/models/panel_model.rb +109 -0
  51. data/lib/openc3/models/plugin_model.rb +1006 -26
  52. data/lib/openc3/models/plugin_store_model.rb +6 -1
  53. data/lib/openc3/models/protected_storage_model.rb +64 -0
  54. data/lib/openc3/models/queue_model.rb +19 -10
  55. data/lib/openc3/models/scope_model.rb +80 -3
  56. data/lib/openc3/models/setting_model.rb +2 -2
  57. data/lib/openc3/models/shared_resource_model.rb +381 -0
  58. data/lib/openc3/models/target_model.rb +324 -68
  59. data/lib/openc3/operators/microservice_operator.rb +76 -9
  60. data/lib/openc3/operators/operator.rb +29 -0
  61. data/lib/openc3/packets/commands.rb +16 -16
  62. data/lib/openc3/packets/limits.rb +2 -0
  63. data/lib/openc3/packets/packet.rb +75 -4
  64. data/lib/openc3/packets/packet_config.rb +152 -13
  65. data/lib/openc3/packets/packet_item.rb +35 -14
  66. data/lib/openc3/packets/packet_item_limits.rb +67 -6
  67. data/lib/openc3/packets/parsers/limits_parser.rb +69 -2
  68. data/lib/openc3/packets/parsers/packet_item_parser.rb +6 -0
  69. data/lib/openc3/packets/parsers/packet_parser.rb +45 -0
  70. data/lib/openc3/packets/parsers/state_parser.rb +1 -1
  71. data/lib/openc3/script/CLAUDE.md +1 -0
  72. data/lib/openc3/script/api_shared.rb +17 -9
  73. data/lib/openc3/script/calendar.rb +18 -6
  74. data/lib/openc3/script/commands.rb +11 -9
  75. data/lib/openc3/script/critical_cmd.rb +22 -2
  76. data/lib/openc3/script/metadata.rb +30 -4
  77. data/lib/openc3/script/plugins.rb +8 -0
  78. data/lib/openc3/script/script.rb +8 -24
  79. data/lib/openc3/script/web_socket_api.rb +23 -17
  80. data/lib/openc3/system/system.rb +9 -3
  81. data/lib/openc3/top_level.rb +17 -0
  82. data/lib/openc3/topics/command_topic.rb +7 -1
  83. data/lib/openc3/topics/decom_interface_topic.rb +9 -3
  84. data/lib/openc3/topics/discovery_topic.rb +84 -0
  85. data/lib/openc3/topics/limits_event_topic.rb +236 -17
  86. data/lib/openc3/topics/telemetry_decom_topic.rb +12 -3
  87. data/lib/openc3/topics/topic.rb +2 -1
  88. data/lib/openc3/utilities/authentication.rb +67 -16
  89. data/lib/openc3/utilities/cli_generator.rb +117 -25
  90. data/lib/openc3/utilities/client_ip_header_filter.rb +38 -0
  91. data/lib/openc3/utilities/config_overlay.rb +24 -1
  92. data/lib/openc3/utilities/cosmos_rails_formatter.rb +18 -10
  93. data/lib/openc3/utilities/hardware_discovery.rb +279 -0
  94. data/lib/openc3/utilities/limits_rollup.rb +81 -0
  95. data/lib/openc3/utilities/local_mode.rb +48 -5
  96. data/lib/openc3/utilities/questdb_client.rb +130 -22
  97. data/lib/openc3/utilities/reingest_job.rb +12 -3
  98. data/lib/openc3/utilities/running_script.rb +206 -49
  99. data/lib/openc3/utilities/script.rb +24 -12
  100. data/lib/openc3/utilities/script_env.rb +164 -0
  101. data/lib/openc3/utilities/script_message_signing.rb +133 -0
  102. data/lib/openc3/utilities/store_autoload.rb +32 -1
  103. data/lib/openc3/utilities/store_queued.rb +5 -1
  104. data/lib/openc3/version.rb +6 -6
  105. data/templates/command_validator/command_validator.py +9 -9
  106. data/templates/{tool_react/pnpm-workspace.yaml → panel/.prettierrc.cjs} +7 -5
  107. data/templates/panel/Rakefile +24 -0
  108. data/templates/panel/package.json +17 -0
  109. data/templates/{tool_angular → panel}/pnpm-workspace.yaml +5 -0
  110. data/templates/panel/src/Panel.js +52 -0
  111. data/templates/panel/src/Panel.vue +60 -0
  112. data/templates/panel/src/panelSdk.js +24 -0
  113. data/templates/panel/vite-Panel.config.js +43 -0
  114. data/templates/tool_vue/package.json +3 -3
  115. data/templates/widget/package.json +2 -2
  116. metadata +24 -56
  117. data/templates/tool_angular/.editorconfig +0 -16
  118. data/templates/tool_angular/.gitignore +0 -44
  119. data/templates/tool_angular/.vscode/extensions.json +0 -4
  120. data/templates/tool_angular/.vscode/launch.json +0 -20
  121. data/templates/tool_angular/.vscode/tasks.json +0 -42
  122. data/templates/tool_angular/angular.json +0 -111
  123. data/templates/tool_angular/extra-webpack.config.js +0 -8
  124. data/templates/tool_angular/package.json +0 -48
  125. data/templates/tool_angular/src/app/app-routing.module.ts +0 -15
  126. data/templates/tool_angular/src/app/app.component.html +0 -22
  127. data/templates/tool_angular/src/app/app.component.scss +0 -18
  128. data/templates/tool_angular/src/app/app.component.spec.ts +0 -29
  129. data/templates/tool_angular/src/app/app.component.ts +0 -52
  130. data/templates/tool_angular/src/app/app.module.ts +0 -30
  131. data/templates/tool_angular/src/app/custom-overlay-container.ts +0 -17
  132. data/templates/tool_angular/src/app/empty-route/empty-route.component.ts +0 -7
  133. data/templates/tool_angular/src/app/openc3-api.d.ts +0 -1
  134. data/templates/tool_angular/src/assets/.gitkeep +0 -0
  135. data/templates/tool_angular/src/environments/environment.prod.ts +0 -3
  136. data/templates/tool_angular/src/environments/environment.ts +0 -16
  137. data/templates/tool_angular/src/favicon.ico +0 -0
  138. data/templates/tool_angular/src/index.html +0 -13
  139. data/templates/tool_angular/src/main.single-spa.ts +0 -40
  140. data/templates/tool_angular/src/single-spa/asset-url.ts +0 -12
  141. data/templates/tool_angular/src/single-spa/single-spa-props.ts +0 -8
  142. data/templates/tool_angular/src/styles.scss +0 -1
  143. data/templates/tool_angular/tsconfig.app.json +0 -13
  144. data/templates/tool_angular/tsconfig.json +0 -33
  145. data/templates/tool_angular/tsconfig.spec.json +0 -14
  146. data/templates/tool_react/.eslintrc +0 -7
  147. data/templates/tool_react/.gitignore +0 -71
  148. data/templates/tool_react/.prettierignore +0 -8
  149. data/templates/tool_react/babel.config.json +0 -29
  150. data/templates/tool_react/jest.config.js +0 -12
  151. data/templates/tool_react/package.json +0 -51
  152. data/templates/tool_react/src/openc3-tool_name.js +0 -24
  153. data/templates/tool_react/src/root.component.js +0 -88
  154. data/templates/tool_react/src/root.component.test.js +0 -9
  155. data/templates/tool_react/webpack.config.js +0 -27
  156. data/templates/tool_svelte/.gitignore +0 -71
  157. data/templates/tool_svelte/.prettierignore +0 -8
  158. data/templates/tool_svelte/.prettierrc.js +0 -5
  159. data/templates/tool_svelte/babel.config.js +0 -12
  160. data/templates/tool_svelte/build/smui.css +0 -1
  161. data/templates/tool_svelte/jest.config.js +0 -9
  162. data/templates/tool_svelte/package.json +0 -49
  163. data/templates/tool_svelte/pnpm-workspace.yaml +0 -20
  164. data/templates/tool_svelte/rollup.config.js +0 -74
  165. data/templates/tool_svelte/src/App.svelte +0 -42
  166. data/templates/tool_svelte/src/App.test.js +0 -9
  167. data/templates/tool_svelte/src/theme/_smui-theme.scss +0 -25
  168. data/templates/tool_svelte/src/tool_name.js +0 -17
  169. data/templates/widget/LICENSE.md +0 -20
@@ -0,0 +1,164 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2026 OpenC3, Inc.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is distributed in the hope that it will be useful,
7
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
8
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9
+ # See LICENSE.md for more details.
10
+ #
11
+ # This file may also be used under the terms of a commercial license
12
+ # if purchased from OpenC3, Inc.
13
+
14
+ require 'openc3/utilities/bucket'
15
+ require 'openc3/utilities/logger'
16
+ OpenC3.require_file 'openc3/utilities/store'
17
+
18
+ module OpenC3
19
+ # Environment handling for the child processes that execute user scripts
20
+ # (script runs and suite analysis)
21
+ module ScriptEnv
22
+ # Not used by script processes so never passed to them
23
+ UNUSED_VARS = [
24
+ # This actually contains the password via redis://openc3:XXXXXXXX@openc3-redis:6379
25
+ 'ANYCABLE_REDIS_URL',
26
+ 'OPENC3_TSDB_USERNAME',
27
+ 'OPENC3_TSDB_PASSWORD',
28
+ 'KC_DB_USERNAME',
29
+ 'KC_DB_PASSWORD',
30
+ 'KEYCLOAK_ADMIN',
31
+ 'KEYCLOAK_ADMIN_PASSWORD',
32
+ ]
33
+ # Cleared by script processes once they have connected
34
+ CLEARED_VARS = [
35
+ 'OPENC3_BUCKET_USERNAME',
36
+ 'OPENC3_BUCKET_PASSWORD',
37
+ 'OPENC3_REDIS_USERNAME',
38
+ 'OPENC3_REDIS_PASSWORD',
39
+ 'OPENC3_API_PASSWORD',
40
+ 'OPENC3_SERVICE_PASSWORD',
41
+ ] + UNUSED_VARS
42
+
43
+ # Variables users may not set through the global Environment or the
44
+ # per-script environment. Global entries apply to every user's scripts, so
45
+ # these are the names that would let one user run code in, or redirect the
46
+ # credentials of, another user's script process. Keep this list to names
47
+ # that matter: script code can already read its own credentials, and an
48
+ # overly broad list (e.g. a RUBY or PYTHON prefix) breaks ordinary user
49
+ # variables. Matched case-insensitively.
50
+ RESERVED_PREFIXES = %w[
51
+ OPENC3_
52
+ LD_
53
+ BUNDLE
54
+ AWS_
55
+ ].freeze
56
+ RESERVED_NAMES = %w[
57
+ PATH HOME
58
+ RUBYOPT RUBYLIB RUBYGEMS_GEMDEPS GEM_HOME GEM_PATH
59
+ PYTHONPATH PYTHONHOME PYTHONUSERBASE PYTHONSTARTUP PYTHONWARNINGS
60
+ PYTHONBREAKPOINT PYTHONINSPECT PYTHONPYCACHEPREFIX VIRTUAL_ENV
61
+ GCONV_PATH OPENSSL_CONF OPENSSL_MODULES OPENSSL_ENGINES
62
+ BASH_ENV ENV IFS
63
+ HTTP_PROXY HTTPS_PROXY ALL_PROXY NO_PROXY
64
+ HOSTALIASES LOCALDOMAIN RES_OPTIONS
65
+ SSL_CERT_FILE SSL_CERT_DIR REQUESTS_CA_BUNDLE CURL_CA_BUNDLE
66
+ ].freeze
67
+ # Reserved-prefix names that only change script output, not how the
68
+ # script connects or loads code. Script Runner sends OPENC3_FULL_BACKTRACE
69
+ # when "Enable Stack Traces" is checked.
70
+ ALLOWED_NAMES = %w[OPENC3_FULL_BACKTRACE].freeze
71
+ VALID_NAME = /\A[A-Za-z_][A-Za-z0-9_]*\z/
72
+
73
+ # Returns an error message if key can't be set by users, nil if it can
74
+ def self.key_error(key)
75
+ return "Environment variable name must be a String" unless key.is_a?(String)
76
+ unless VALID_NAME.match?(key)
77
+ return "Environment variable name '#{key}' must contain only letters, digits and underscores and not start with a digit"
78
+ end
79
+
80
+ upcased = key.upcase
81
+ return nil if ALLOWED_NAMES.include?(upcased)
82
+ if RESERVED_NAMES.include?(upcased) or RESERVED_PREFIXES.any? { |prefix| upcased.start_with?(prefix) }
83
+ return "Environment variable '#{key}' is reserved by COSMOS and can not be set for scripts"
84
+ end
85
+
86
+ return nil
87
+ end
88
+
89
+ def self.allowed_key?(key)
90
+ return key_error(key).nil?
91
+ end
92
+
93
+ # Copy user environment entries ([{ 'key' => , 'value' => }, ...]) into a
94
+ # ChildProcess environment, skipping reserved names. Returns the hash of
95
+ # entries applied.
96
+ def self.apply_user_entries(environment, entries, source:, scope: nil)
97
+ applied = {}
98
+ (entries || []).each do |entry|
99
+ key = entry.respond_to?(:key?) ? entry['key'] : nil
100
+ error = key_error(key)
101
+ if error
102
+ Logger.warn("Ignoring #{source} environment variable: #{error}", scope: scope)
103
+ next
104
+ end
105
+ # nil unsets the variable in the ChildProcess environment
106
+ value = entry['value']
107
+ value = value.to_s unless value.nil?
108
+ environment[key] = value
109
+ applied[key] = value
110
+ end
111
+ return applied
112
+ end
113
+
114
+ # Secrets the script process needs, delivered over stdin instead of its
115
+ # environment. Removing a variable from ENV does not change
116
+ # /proc/<pid>/environ, which keeps the environment the process started with,
117
+ # so anything passed in the environment stays readable by user code.
118
+ # Maps the variable name in the script process to the variable it is read from
119
+ # in the spawning process.
120
+ STDIN_SECRET_VARS = {
121
+ 'OPENC3_REDIS_USERNAME' => 'OPENC3_SR_REDIS_USERNAME',
122
+ 'OPENC3_REDIS_PASSWORD' => 'OPENC3_SR_REDIS_PASSWORD',
123
+ 'OPENC3_BUCKET_USERNAME' => 'OPENC3_SR_BUCKET_USERNAME',
124
+ 'OPENC3_BUCKET_PASSWORD' => 'OPENC3_SR_BUCKET_PASSWORD',
125
+ }.freeze
126
+
127
+ # Removed from the environment of every spawned script process. The API
128
+ # credentials and STDIN_SECRET_VARS are delivered over stdin instead.
129
+ SPAWN_SCRUBBED_VARS = (UNUSED_VARS + [
130
+ 'SECRET_KEY_BASE',
131
+ 'OPENC3_SERVICE_PASSWORD',
132
+ 'OPENC3_API_PASSWORD',
133
+ 'OPENC3_API_TOKEN',
134
+ # Scripts authenticate as the user who ran them, never as an API client
135
+ 'OPENC3_API_CLIENT_SECRET',
136
+ ] + STDIN_SECRET_VARS.keys + STDIN_SECRET_VARS.values).freeze
137
+
138
+ # Unset SPAWN_SCRUBBED_VARS in a ChildProcess environment (nil unsets the
139
+ # variable rather than inheriting it from this process)
140
+ def self.scrub_spawn_environment(environment)
141
+ SPAWN_SCRUBBED_VARS.each { |key| environment[key] = nil }
142
+ end
143
+
144
+ # The STDIN_SECRET_VARS values to send to the script process, omitting unset ones
145
+ def self.stdin_secrets
146
+ STDIN_SECRET_VARS.each_with_object({}) do |(child_key, parent_key), secrets|
147
+ value = ENV.fetch(parent_key, nil)
148
+ secrets[child_key] = value if value
149
+ end
150
+ end
151
+
152
+ # Called in the script process before any user code runs. This only removes
153
+ # the variables from ENV, so secrets must not be passed in the environment
154
+ # at spawn (see STDIN_SECRET_VARS).
155
+ def self.clear_credentials
156
+ # Load the bucket client code to ensure we authenticate outside ENV vars
157
+ Bucket.getClient()
158
+ # Preload Store and remove Redis secrets from ENV
159
+ Store.instance
160
+ EphemeralStore.instance
161
+ CLEARED_VARS.each { |key| ENV.delete(key) }
162
+ end
163
+ end
164
+ end
@@ -0,0 +1,133 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2026 OpenC3, Inc.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is free software; you can modify and/or redistribute it
7
+ # under the terms of the GNU Affero General Public License
8
+ # as published by the Free Software Foundation; version 3 with
9
+ # attribution addendums as found in the LICENSE.md
10
+ #
11
+ # This file may also be used under the terms of a commercial license
12
+ # if purchased from OpenC3, Inc.
13
+
14
+ require 'json'
15
+ require 'openssl'
16
+ require 'securerandom'
17
+
18
+ module OpenC3
19
+ # HMAC-SHA256 signing of script control messages.
20
+ #
21
+ # CROSS-LANGUAGE CONTRACT: the Python twin (openc3/script_message_signing.py)
22
+ # must produce byte-identical output. Signed string is:
23
+ #
24
+ # canonical(payload) + ":" + nonce
25
+ #
26
+ # canonical(payload) is JSON, UTF-8, non-ASCII NOT escaped, object keys
27
+ # sorted bytewise (recursively), no insignificant whitespace. So
28
+ # canonical("stop") is "\"stop\"" including the quotes. The exact matching
29
+ # Python call is:
30
+ # json.dumps(obj, sort_keys=True, separators=(",", ":"), ensure_ascii=False)
31
+ #
32
+ # Signed payloads may contain only String, Integer, true/false, nil, Array
33
+ # and Hash. Floats are rejected (ArgumentError) because their text form
34
+ # differs between languages. sign may also raise on binary-encoded
35
+ # (ascii-8bit) strings containing high bytes; verify returns false for them.
36
+ #
37
+ # sig = lowercase hex(HMAC_SHA256(signing_key, signed string))
38
+ # Uppercase-hex sigs are rejected by verify.
39
+ # nonce = 32 lowercase hex chars (16 random bytes)
40
+ # Envelope: { "payload" => ..., "nonce" => ..., "sig" => ... }
41
+ module ScriptMessageSigning
42
+ # Redis hash holding each running script's signing key, indexed by script id.
43
+ # The name must not start with "running-script": the scriptrunner Redis ACL
44
+ # grants ~running-script* and scripts must never read these keys.
45
+ def self.keys_hash(scope)
46
+ "script-signing-keys__#{scope}"
47
+ end
48
+
49
+ def self.canonical(payload)
50
+ JSON.generate(sort_keys(payload))
51
+ end
52
+
53
+ def self.sign(signing_key, payload)
54
+ nonce = SecureRandom.hex(16)
55
+ { 'payload' => payload, 'nonce' => nonce, 'sig' => compute_sig(signing_key, payload, nonce) }
56
+ end
57
+
58
+ # Pure signature check. Replay protection is the caller's concern.
59
+ # Returns false (never raises) on any malformed input or mismatch.
60
+ def self.verify(signing_key, envelope)
61
+ return false unless envelope.is_a?(Hash)
62
+ return false if signing_key.to_s.empty?
63
+ return false unless envelope.key?('payload')
64
+ nonce = envelope['nonce']
65
+ sig = envelope['sig']
66
+ return false unless nonce.is_a?(String) && !nonce.empty?
67
+ return false unless sig.is_a?(String) && !sig.empty?
68
+ expected = compute_sig(signing_key, envelope['payload'], nonce)
69
+ return false unless sig.bytesize == expected.bytesize
70
+ OpenSSL.fixed_length_secure_compare(sig, expected)
71
+ rescue StandardError
72
+ false
73
+ end
74
+
75
+ # Bounded FIFO set of seen nonces for replay protection.
76
+ class NonceCache
77
+ DEFAULT_MAX = 10_000
78
+
79
+ def initialize(max = DEFAULT_MAX)
80
+ @max = max
81
+ @set = {}
82
+ end
83
+
84
+ def include?(nonce)
85
+ @set.key?(nonce)
86
+ end
87
+
88
+ def add(nonce)
89
+ return if @set.key?(nonce)
90
+ @set.shift while @set.size >= @max # Hash preserves insertion order: oldest first
91
+ @set[nonce] = true
92
+ end
93
+
94
+ def size
95
+ @set.size
96
+ end
97
+ end
98
+
99
+ # Parse and verify a raw JSON control message and enforce replay protection.
100
+ # Returns [accepted, payload]. Never raises. payload is nil when the
101
+ # envelope is invalid; on a replay it is the payload but accepted is false.
102
+ def self.accept?(signing_key, raw_json, seen_nonces)
103
+ envelope = JSON.parse(raw_json, allow_nan: true)
104
+ return [false, nil] unless verify(signing_key, envelope)
105
+ nonce = envelope['nonce']
106
+ return [false, envelope['payload']] if seen_nonces.include?(nonce)
107
+ seen_nonces.add(nonce)
108
+ [true, envelope['payload']]
109
+ rescue StandardError
110
+ [false, nil]
111
+ end
112
+
113
+ def self.compute_sig(signing_key, payload, nonce)
114
+ OpenSSL::HMAC.hexdigest('SHA256', signing_key.to_s, "#{canonical(payload)}:#{nonce}")
115
+ end
116
+ private_class_method :compute_sig
117
+
118
+ def self.sort_keys(obj)
119
+ case obj
120
+ when Hash
121
+ # UTF-8 byte order == Unicode code-point order, so bytewise (Ruby) and code-point (Python) key sorting produce identical canonical output.
122
+ obj.map { |k, v| [k.to_s, sort_keys(v)] }.sort_by { |k, _| k.b }.to_h
123
+ when Array
124
+ obj.map { |v| sort_keys(v) }
125
+ when Float
126
+ raise ArgumentError, 'unsupported Float in signed payload'
127
+ else
128
+ obj
129
+ end
130
+ end
131
+ private_class_method :sort_keys
132
+ end
133
+ end
@@ -100,6 +100,14 @@ module OpenC3
100
100
  db_shard
101
101
  end
102
102
 
103
+ # Drops a target's cached db_shard so the next db_shard_for_target reads it
104
+ # from the store, e.g. after the target is reinstalled on another db_shard.
105
+ def self.clear_db_shard_for_target(target_name, scope: "DEFAULT")
106
+ @@db_shard_cache_mutex.synchronize do
107
+ @@db_shard_cache.delete("#{scope}__#{target_name}")
108
+ end
109
+ end
110
+
103
111
  # Get the singleton instance
104
112
  def self.instance(pool_size = 100, db_shard: 0)
105
113
  # Logger.level = Logger::DEBUG
@@ -130,9 +138,30 @@ module OpenC3
130
138
  @redis_key = ENV.fetch('OPENC3_REDIS_PASSWORD', nil)
131
139
  hostname = ENV['OPENC3_REDIS_HOSTNAME'].to_s.gsub("SHARDNUM", db_shard.to_s)
132
140
  @redis_url = "redis://#{hostname}:#{ENV.fetch('OPENC3_REDIS_PORT', 6379)}"
141
+ @pool_size = pool_size
133
142
  @redis_pool = StoreConnectionPool.new(size: pool_size) { build_redis() }
134
143
  end
135
144
 
145
+ attr_reader :pool_size
146
+
147
+ # Grow the connection pool to at least pool_size connections. A MULTI
148
+ # microservice calls this before starting its children because each child
149
+ # holds a connection while it reads its topics, and a thread that can't get
150
+ # one within the pool timeout dies. Connections are still only opened as
151
+ # they are needed.
152
+ def ensure_pool_size(pool_size)
153
+ @@instance_mutex.synchronize do
154
+ return if @pool_size >= pool_size
155
+
156
+ old_pool = @redis_pool
157
+ @redis_pool = StoreConnectionPool.new(size: pool_size) { build_redis() }
158
+ @pool_size = pool_size
159
+ # Close the old pool's idle connections. It stays usable (reload, not
160
+ # shutdown) in case another thread was about to use it.
161
+ old_pool.reload { |redis| redis.close }
162
+ end
163
+ end
164
+
136
165
  # cap/base for the equal-jitter reconnect backoff (seconds)
137
166
  REDIS_BACKOFF_CAP = 5.0
138
167
  REDIS_BACKOFF_BASE = 0.625
@@ -319,6 +348,7 @@ module OpenC3
319
348
  super(pool_size, db_shard: db_shard)
320
349
  hostname = ENV['OPENC3_REDIS_EPHEMERAL_HOSTNAME'].to_s.gsub("SHARDNUM", db_shard.to_s)
321
350
  @redis_url = "redis://#{hostname}:#{ENV.fetch('OPENC3_REDIS_EPHEMERAL_PORT', 6380)}"
351
+ @pool_size = pool_size
322
352
  @redis_pool = StoreConnectionPool.new(size: pool_size) { build_redis() }
323
353
  end
324
354
  end
@@ -327,7 +357,8 @@ end
327
357
  class Redis
328
358
  def xtrim_minid(key, minid, approximate: true, limit: nil)
329
359
  args = [:xtrim, key, :MINID, (approximate ? '~' : '='), minid]
330
- args.concat([:LIMIT, limit]) if limit
360
+ # XTRIM only accepts LIMIT together with the ~ modifier
361
+ args.concat([:LIMIT, limit]) if limit and approximate
331
362
  send_command(args)
332
363
  end
333
364
  end
@@ -41,10 +41,14 @@ module OpenC3
41
41
  end
42
42
 
43
43
  # Set the update interval on every db_shard instance, including ones created later
44
- def self.set_update_interval_all_shards(interval)
44
+ # @param fastest [Boolean] Only change the interval if it is faster than one set
45
+ # before, so microservices sharing a process all flush at least as often as they asked
46
+ def self.set_update_interval_all_shards(interval, fastest: false)
45
47
  return unless interval > 0.0
46
48
 
47
49
  @@instance_mutex.synchronize do
50
+ return if fastest and @update_interval and @update_interval <= interval
51
+
48
52
  @update_interval = interval
49
53
  (@instances || []).compact.each { |the_instance| the_instance.set_update_interval(interval) }
50
54
  end
@@ -1,14 +1,14 @@
1
1
  # encoding: ascii-8bit
2
2
 
3
- OPENC3_VERSION = '7.5.1'
3
+ OPENC3_VERSION = '7.6.0'
4
4
  module OpenC3
5
5
  module Version
6
6
  MAJOR = '7'
7
- MINOR = '5'
8
- PATCH = '1'
7
+ MINOR = '6'
8
+ PATCH = '0'
9
9
  OTHER = ''
10
- BUILD = 'e3c5693f00248aa4cb1833dad3aaeeaabb6fd581'
10
+ BUILD = '3c2224e18d6b811c2cab8d177d1aa892453aae21'
11
11
  end
12
- VERSION = '7.5.1'
13
- GEM_VERSION = '7.5.1'
12
+ VERSION = '7.6.0'
13
+ GEM_VERSION = '7.6.0'
14
14
  end
@@ -1,4 +1,4 @@
1
- from openc3.packets.command_validator import CommandValidator
1
+ from openc3.packets.command_validator import CommandValidator, CommandValidatorResult
2
2
  # Using the OpenC3 API requires the following imports:
3
3
  from openc3.api import tlm, wait_check
4
4
 
@@ -7,8 +7,8 @@ from openc3.api import tlm, wait_check
7
7
  class <%= validator_class %>(CommandValidator):
8
8
  # Called before a command is sent
9
9
  # @param command [Packet] The command object containing all the command details
10
- # @return [list] First element is True/False/None for success/failure/unknown,
11
- # second element is an optional message string
10
+ # @return [CommandValidatorResult] (result, message) where result is True/False/None
11
+ # for success/failure/unknown and message is an optional string
12
12
  def pre_check(self, command):
13
13
  # Add your pre-command validation logic here
14
14
  # Example:
@@ -20,16 +20,16 @@ class <%= validator_class %>(CommandValidator):
20
20
  # self.count = tlm("TARGET PACKET COUNT")
21
21
  #
22
22
  # if some_condition:
23
- # return [False, "Command validation failed: reason"]
23
+ # return CommandValidatorResult(False, "Command validation failed: reason")
24
24
 
25
25
  # Return True to indicate Success, False to indicate Failure,
26
26
  # and None to indicate Unknown. The second value is the optional message.
27
- return [True, None]
27
+ return CommandValidatorResult(True, None)
28
28
 
29
29
  # Called after a command is sent
30
30
  # @param command [Packet] The command object containing all the command details
31
- # @return [list] First element is True/False/None for success/failure/unknown,
32
- # second element is an optional message string
31
+ # @return [CommandValidatorResult] (result, message) where result is True/False/None
32
+ # for success/failure/unknown and message is an optional string
33
33
  def post_check(self, command):
34
34
  # Add your post-command validation logic here
35
35
  # Example:
@@ -38,10 +38,10 @@ class <%= validator_class %>(CommandValidator):
38
38
  # wait_check(f"TARGET PACKET COUNT > {self.count}", 5) # Wait up to 5 seconds
39
39
  #
40
40
  # if some_condition:
41
- # return [False, "Post-command validation failed: reason"]
41
+ # return CommandValidatorResult(False, "Post-command validation failed: reason")
42
42
  #
43
43
  # Wait for telemetry
44
44
 
45
45
  # Return True to indicate Success, False to indicate Failure,
46
46
  # and None to indicate Unknown. The second value is the optional message.
47
- return [True, None]
47
+ return CommandValidatorResult(True, None)
@@ -1,3 +1,4 @@
1
+ /*
1
2
  # Copyright 2026 OpenC3, Inc.
2
3
  # All Rights Reserved.
3
4
  #
@@ -8,9 +9,10 @@
8
9
  #
9
10
  # This file may also be used under the terms of a commercial license
10
11
  # if purchased from OpenC3, Inc.
12
+ */
11
13
 
12
- minimumReleaseAge: 1440 # 1 day
13
- minimumReleaseAgeExclude:
14
- # we control these packages, so we don't need to wait to consume them
15
- - '@openc3/js-common'
16
- - '@openc3/vue-common'
14
+ module.exports = {
15
+ singleQuote: true,
16
+ semi: false,
17
+ bracketSpacing: true,
18
+ }
@@ -0,0 +1,24 @@
1
+ PLUGIN_NAME = Dir['*.gemspec'][0].split('.')[0..-2].join('.')
2
+
3
+ task :require_version do
4
+ unless ENV['VERSION']
5
+ puts "VERSION is required: rake build VERSION=X.Y.Z"
6
+ exit 1
7
+ end
8
+ end
9
+
10
+ task :build => [:require_version] do
11
+ _, platform, *_ = RUBY_PLATFORM.split("-")
12
+ if platform == 'mswin32' or platform == 'mingw32'
13
+ puts "Warning: Building gem on Windows will lose file permissions"
14
+ end
15
+ # Build the panel and gem using sh built into Rake:
16
+ # https://rubydoc.info/gems/rake/FileUtils#sh-instance_method
17
+ sh('pnpm', 'run', 'build')
18
+ sh('gem', 'build', PLUGIN_NAME)
19
+ sh('openc3cli validate *.gem') do |ok, status|
20
+ if !ok && status.exitstatus == 127 # command not found
21
+ puts "Install the openc3 gem to validate! (gem install openc3)"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "<%= panel_name %>",
3
+ "version": "7.6.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "build": "vite build -c vite-<%= panel_name %>.config.js"
8
+ },
9
+ "devDependencies": {
10
+ "@vitejs/plugin-vue": "^6.0.1",
11
+ "prettier": "^3.3.3",
12
+ "sass": "^1.80.4",
13
+ "vite": "^7.2.1",
14
+ "vite-plugin-style-inject": "^0.0.1",
15
+ "vue": "^3.5.13"
16
+ }
17
+ }
@@ -14,3 +14,8 @@ minimumReleaseAgeExclude:
14
14
  # we control these packages, so we don't need to wait to consume them
15
15
  - '@openc3/js-common'
16
16
  - '@openc3/vue-common'
17
+
18
+ # Build scripts these dependencies don't need (same as COSMOS itself)
19
+ allowBuilds:
20
+ '@parcel/watcher': false
21
+ esbuild: false
@@ -0,0 +1,52 @@
1
+ /*
2
+ # Copyright 2026 OpenC3, Inc.
3
+ # All Rights Reserved.
4
+ #
5
+ # This program is distributed in the hope that it will be useful,
6
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
7
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8
+ # See LICENSE.md for more details.
9
+ #
10
+ # This file may also be used under the terms of a commercial license
11
+ # if purchased from OpenC3, Inc.
12
+ */
13
+
14
+ import { setSdk } from './panelSdk'
15
+ import <%= panel_name %> from './<%= panel_name %>.vue'
16
+
17
+ // The <%= panel_type %> panel type. Dashboards calls this with the panel SDK
18
+ // and adds the type it returns to the panel type picker. Dashboard files then
19
+ // use it like the built-in types:
20
+ //
21
+ // PANEL <%= panel_type %> 0 0 3 3 "Title"
22
+ // ITEM INST HEALTH_STATUS TEMP1
23
+ // SETTING DECIMALS 2
24
+ // END
25
+ export default (sdk) => {
26
+ setSdk(sdk)
27
+ return {
28
+ label: '<%= panel_label %>',
29
+ description: 'One telemetry value with its limits status',
30
+ // Any Material Design Icon: https://pictogrammers.com/library/mdi/
31
+ icon: 'mdi-puzzle-outline',
32
+ component: <%= panel_name %>,
33
+ // What the panel dialog edits: 'items', 'targets', 'command' or 'screen'
34
+ content: 'items',
35
+ maxItems: 1,
36
+ // Width and height for a new panel, in grid cells
37
+ defaults: { w: 3, h: 3 },
38
+ // SETTINGs this panel understands. Each one parses, saves and shows in
39
+ // the panel dialog; read it with sdk.option(panel, NAME).
40
+ options: [
41
+ {
42
+ name: 'DECIMALS',
43
+ type: 'number',
44
+ label: 'Decimal places',
45
+ default: null,
46
+ min: 0,
47
+ max: 10,
48
+ help: 'Leave empty to use the item format',
49
+ },
50
+ ],
51
+ }
52
+ }
@@ -0,0 +1,60 @@
1
+ <!--
2
+ # Copyright 2026 OpenC3, Inc.
3
+ # All Rights Reserved.
4
+ #
5
+ # This program is distributed in the hope that it will be useful,
6
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
7
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8
+ # See LICENSE.md for more details.
9
+ #
10
+ # This file may also be used under the terms of a commercial license
11
+ # if purchased from OpenC3, Inc.
12
+ -->
13
+
14
+ <template>
15
+ <div
16
+ class="d-flex flex-column flex-grow-1 align-center justify-center ga-1 pa-2"
17
+ :class="{ 'cursor-pointer': !!openDetails }"
18
+ :tabindex="openDetails ? 0 : undefined"
19
+ @click="showDetails()"
20
+ @keydown.enter="showDetails()"
21
+ >
22
+ <div class="d-flex align-center ga-2">
23
+ <StatusSymbol :level="first.level" :size="16" />
24
+ <span class="text-medium-emphasis text-caption">{{ first.label }}</span>
25
+ </div>
26
+ <div :class="['value', { 'text-disabled': first.stale }]">
27
+ {{ text }}
28
+ <span class="text-body-2 text-medium-emphasis">{{ first.units }}</span>
29
+ </div>
30
+ </div>
31
+ </template>
32
+
33
+ <script setup>
34
+ import { computed } from 'vue'
35
+ import { sdk } from './panelSdk'
36
+
37
+ // Every panel gets its PANEL ... END block as `panel`
38
+ const props = defineProps({
39
+ panel: { type: Object, required: true },
40
+ })
41
+
42
+ // Polls the panel's ITEMs and reports its status to the dashboard.
43
+ // itemStates has one entry per item: label, text, number, units, level,
44
+ // stale and limits; first is the first one. See the custom panels guide.
45
+ const { first, showDetails, openDetails } = sdk.useTlmPanel(props)
46
+ const { StatusSymbol } = sdk.components
47
+
48
+ const text = computed(() => {
49
+ const decimals = sdk.option(props.panel, 'DECIMALS')
50
+ if (decimals === null || first.value.number === null) return first.value.text
51
+ return first.value.number.toFixed(decimals)
52
+ })
53
+ </script>
54
+
55
+ <style scoped>
56
+ .value {
57
+ font-size: 32px;
58
+ font-weight: 500;
59
+ }
60
+ </style>
@@ -0,0 +1,24 @@
1
+ /*
2
+ # Copyright 2026 OpenC3, Inc.
3
+ # All Rights Reserved.
4
+ #
5
+ # This program is distributed in the hope that it will be useful,
6
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
7
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8
+ # See LICENSE.md for more details.
9
+ #
10
+ # This file may also be used under the terms of a commercial license
11
+ # if purchased from OpenC3, Inc.
12
+ */
13
+
14
+ // The Dashboards panel SDK: composables, option readers, formatting and
15
+ // building blocks shared with the built-in panels. Dashboards passes it to
16
+ // each panel's entry file when it loads the panel, so it's filled in before
17
+ // any panel component is set up. Shared by every panel in this plugin.
18
+ //
19
+ // https://docs.openc3.com/docs/guides/custom-panels
20
+ export const sdk = {}
21
+
22
+ export function setSdk(value) {
23
+ Object.assign(sdk, value)
24
+ }