rubik 0.15.3 → 0.15.4
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +45 -3
- data/lib/rubik/adapter/node.rb +3 -2
- data/lib/rubik/ast/extractor.rb +1 -1
- data/lib/rubik/ast/graph_extensions.rb +3 -1
- data/lib/rubik/ast/treesitter_extractor.rb +1 -1
- data/lib/rubik/buffer/manager.rb +5 -3
- data/lib/rubik/buffer/snapshot.rb +3 -2
- data/lib/rubik/concurrency/errors.rb +3 -1
- data/lib/rubik/config/coercion.rb +26 -0
- data/lib/rubik/config/env_loader.rb +1 -2
- data/lib/rubik/config/scoped.rb +5 -20
- data/lib/rubik/config/secret_policy.rb +3 -2
- data/lib/rubik/config/store.rb +5 -2
- data/lib/rubik/config.rb +7 -13
- data/lib/rubik/connect/models_dev.rb +13 -11
- data/lib/rubik/errors.rb +5 -4
- data/lib/rubik/event_bus.rb +0 -1
- data/lib/rubik/llm/client.rb +2 -1
- data/lib/rubik/llm/registry.rb +1 -1
- data/lib/rubik/lsp/client.rb +0 -9
- data/lib/rubik/lsp/transport.rb +2 -1
- data/lib/rubik/mcp/boot_run.rb +15 -14
- data/lib/rubik/mcp/errors.rb +3 -1
- data/lib/rubik/mcp/manager.rb +6 -6
- data/lib/rubik/orchestrator/auto_apply.rb +2 -1
- data/lib/rubik/orchestrator/goal_ledger/suspend_lifecycle.rb +4 -1
- data/lib/rubik/orchestrator/subagent/profile_snapshot.rb +4 -2
- data/lib/rubik/orchestrator/subagent/supervisor.rb +23 -8
- data/lib/rubik/orchestrator/tool_circuit_breaker.rb +3 -1
- data/lib/rubik/orchestrator/tool_timeout.rb +3 -2
- data/lib/rubik/platform/process.rb +104 -82
- data/lib/rubik/plugin/manager.rb +0 -1
- data/lib/rubik/plugin/package_inventory.rb +3 -1
- data/lib/rubik/repl/hooks.rb +0 -1
- data/lib/rubik/repl/interrupt_handler.rb +5 -1
- data/lib/rubik/repl/lifecycle.rb +1 -1
- data/lib/rubik/repl/terminal_guard.rb +0 -8
- data/lib/rubik/runtime/context.rb +3 -2
- data/lib/rubik/runtime/overlay_storage.rb +3 -3
- data/lib/rubik/runtime/repair_probe.rb +50 -21
- data/lib/rubik/runtime/task_manager.rb +81 -82
- data/lib/rubik/sandbox/runner.rb +1 -1
- data/lib/rubik/security/audit_log.rb +1 -1
- data/lib/rubik/security/classifier/matcher/options.rb +7 -1
- data/lib/rubik/security/classifier/matcher.rb +8 -3
- data/lib/rubik/security/classifier/models.rb +8 -0
- data/lib/rubik/security/command_gate.rb +105 -77
- data/lib/rubik/security/errors.rb +3 -1
- data/lib/rubik/security/secret_store.rb +12 -10
- data/lib/rubik/session/recorder.rb +11 -6
- data/lib/rubik/skills/frontmatter.rb +3 -1
- data/lib/rubik/storage/transcript_indexer.rb +9 -3
- data/lib/rubik/ui/capability.rb +4 -8
- data/lib/rubik/ui/io_probe.rb +24 -0
- data/lib/rubik/ui/spinner.rb +3 -2
- data/lib/rubik/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6e753f785813cc263fdc3709418aa6a59beec89dc8ef864856bee39538ac92d4
|
|
4
|
+
data.tar.gz: d2a7a1b3f5c936ebe07551a2f7f82432a2f24ad9af6829294eeca191358ab517
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cc1e2a7bf41523a4d3f963de96df925e6c4775605c95534285056f8b59d6fa58197fc2d78000fe5149943501b674e4e99d30a7ce26a4f77c0a499431f884d612
|
|
7
|
+
data.tar.gz: a92b81bcc221d686c21fdb092e0f10341863c4ca9ce7543e8367bb11298a21edc6c3021e55d1201117aaa3b1a00adf7ec18b4a409105a9c045a5f04b631d7c5d
|
data/CHANGELOG.md
CHANGED
|
@@ -6,7 +6,47 @@ commits, 2026-08-23 → 2026-10-09, see `git log`).
|
|
|
6
6
|
|
|
7
7
|
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
8
8
|
|
|
9
|
-
## [
|
|
9
|
+
## [0.15.4] - 2026-11-25
|
|
10
|
+
|
|
11
|
+
The taxonomy-and-tidiness patch: the unified `Rubik::Error` taxonomy finished
|
|
12
|
+
its sweep across `lib/`, config value handling was repaired and normalized
|
|
13
|
+
behind a single home, silent failure paths learned to surface, and a broad
|
|
14
|
+
quiet pass removed dead code, redundant log prefixes and unused requires.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **Config parsing (PR #663):** `RUBIK_LOG_LEVEL` no longer aliases
|
|
19
|
+
`ui.verbosity` behind the user's back, cyclic YAML aliases in typed scalar
|
|
20
|
+
values are rejected, tool-worker death is classified under `Rubik::Error`
|
|
21
|
+
so the orchestrator handles it like any other failure, and adapter/session
|
|
22
|
+
fallback causes are logged at debug level instead of vanishing.
|
|
23
|
+
- **UI load order (PR #648):** the coupling between capability detection and
|
|
24
|
+
the REPL `TeeIO` is resolved, so prompt echo no longer depends on
|
|
25
|
+
initialization order.
|
|
26
|
+
- **Observability (PR #655):** silent failure paths across session, config,
|
|
27
|
+
storage, connect and repl now surface instead of swallowing.
|
|
28
|
+
- **Security (PR #659):** catalog cache writes are hardened and secrets are
|
|
29
|
+
preserved when an atomic-rename fails mid-write.
|
|
30
|
+
- **Docs + listeners (PR #650):** model role doc keys are corrected and a
|
|
31
|
+
supervisor listener leak is cleaned up.
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- **Error taxonomy (PR #657, issue #652):** every `lib/` exception class now
|
|
36
|
+
hangs off `Rubik::Error`, so a single `rescue Rubik::Error` covers the tree;
|
|
37
|
+
the cancellation-refusal signal (`TaskCancelledError`) stays outside the
|
|
38
|
+
taxonomy on purpose, and profile validation keeps its load-bearing
|
|
39
|
+
`ArgumentError` parentage — both pinned by the new hygiene meta-test.
|
|
40
|
+
- **Refactors (PR #649/#654/#660/#661/#665):** `popen_capture` and task-manager
|
|
41
|
+
start decompose into phases, command-gate verification splits into named
|
|
42
|
+
phases returning argv analysis, MCP gains a public boot seam instead of
|
|
43
|
+
private sends, and config typed-value normalization gets a single home.
|
|
44
|
+
- **Hygiene (PR #651/#664/#662):** dead code removed, secret/buffer/ui
|
|
45
|
+
diagnostics logging centralized, redundant WARN prefixes dropped, the
|
|
46
|
+
translation banner aligned and unused logger requires removed.
|
|
47
|
+
- **Test pins (PR #656/#658):** the agent execution command-spine registration
|
|
48
|
+
and goal arg grammar, plus the MCP async boot slot/epoch seam mechanics,
|
|
49
|
+
are pinned with dedicated tests.
|
|
10
50
|
|
|
11
51
|
## [0.15.3] - 2026-11-24
|
|
12
52
|
|
|
@@ -1985,8 +2025,6 @@ installation section.
|
|
|
1985
2025
|
|
|
1986
2026
|
- Agent loop: token budget autonomy with auto-continuation, wait hints,
|
|
1987
2027
|
reactive wakeups, and structured failure notices (Plan 90, 109).
|
|
1988
|
-
[Unreleased]: https://github.com/ozgurulukir/rubik/compare/v0.15.3...HEAD
|
|
1989
|
-
[0.15.3]: https://github.com/ozgurulukir/rubik/compare/v0.15.2...v0.15.3
|
|
1990
2028
|
buffer with `!dmesg` (Plans 102–104).
|
|
1991
2029
|
- Tools: `ask_question` interactive dialog (Plan 92), async background task
|
|
1992
2030
|
manager with `manage_task` (Plan 93), native search with rg fallback,
|
|
@@ -2024,6 +2062,10 @@ installation section.
|
|
|
2024
2062
|
- Context: serialized index mutations, snapshot-outside-lock reconcile,
|
|
2025
2063
|
streaming-first truncation.
|
|
2026
2064
|
|
|
2065
|
+
[Unreleased]: https://github.com/ozgurulukir/rubik/compare/v0.15.4...HEAD
|
|
2066
|
+
[0.15.4]: https://github.com/ozgurulukir/rubik/compare/v0.15.3...v0.15.4
|
|
2067
|
+
[0.15.3]: https://github.com/ozgurulukir/rubik/compare/v0.15.2...v0.15.3
|
|
2068
|
+
[0.15.2]: https://github.com/ozgurulukir/rubik/compare/v0.15.1...v0.15.2
|
|
2027
2069
|
[0.15.1]: https://github.com/ozgurulukir/rubik/compare/v0.15.0...v0.15.1
|
|
2028
2070
|
[0.15.0]: https://github.com/ozgurulukir/rubik/compare/v0.14.0...v0.15.0
|
|
2029
2071
|
[0.14.0]: https://github.com/ozgurulukir/rubik/compare/v0.13.0...v0.14.0
|
data/lib/rubik/adapter/node.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "json"
|
|
4
4
|
require "shellwords"
|
|
5
|
+
require_relative "../log"
|
|
5
6
|
require_relative "base"
|
|
6
7
|
|
|
7
8
|
module Rubik
|
|
@@ -49,8 +50,8 @@ module Rubik
|
|
|
49
50
|
if target_script
|
|
50
51
|
return target_script == "test" ? "#{runner} test" : "#{runner} run #{target_script}"
|
|
51
52
|
end
|
|
52
|
-
rescue JSON::ParserError, SystemCallError
|
|
53
|
-
#
|
|
53
|
+
rescue JSON::ParserError, SystemCallError => e
|
|
54
|
+
Rubik::Log.debug(:adapter, "package.json unavailable (#{e.class}); using default test command")
|
|
54
55
|
end
|
|
55
56
|
end
|
|
56
57
|
|
data/lib/rubik/ast/extractor.rb
CHANGED
|
@@ -64,7 +64,7 @@ module Rubik
|
|
|
64
64
|
# language extractor claims (:unavailable, legacy Ruby parse).
|
|
65
65
|
fallback_result(file_path, content, ext)
|
|
66
66
|
rescue StandardError, ScriptError => e
|
|
67
|
-
Rubik::Log.warn(:ast, "
|
|
67
|
+
Rubik::Log.warn(:ast, "Extraction failed for #{file_path}: #{e.class}: #{e.message}") if ENV["RUBIK_DEBUG"]
|
|
68
68
|
ExtractionResult.new(symbols: [], status: :failed, source: :none, detail: "#{e.class}: #{e.message}")
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../errors"
|
|
4
|
+
|
|
3
5
|
module Rubik
|
|
4
6
|
module AST
|
|
5
7
|
class SymbolMap < Hash
|
|
@@ -109,7 +111,7 @@ module Rubik
|
|
|
109
111
|
end
|
|
110
112
|
|
|
111
113
|
class Graph
|
|
112
|
-
class AmbiguousSymbolError <
|
|
114
|
+
class AmbiguousSymbolError < Rubik::Error
|
|
113
115
|
attr_reader :query, :candidates
|
|
114
116
|
|
|
115
117
|
def initialize(query, candidates)
|
|
@@ -102,7 +102,7 @@ module Rubik
|
|
|
102
102
|
|
|
103
103
|
ExtractionResult.new(symbols: symbols, status: :ok, source: :tree_sitter)
|
|
104
104
|
rescue StandardError, SystemStackError, ScriptError => e
|
|
105
|
-
Rubik::Log.warn(:ast, "
|
|
105
|
+
Rubik::Log.warn(:ast, "TreeSitter extraction failed for #{file_path}: #{e.message}") if ENV["RUBIK_DEBUG"]
|
|
106
106
|
failed_result("#{e.class}: #{e.message}")
|
|
107
107
|
end
|
|
108
108
|
|
data/lib/rubik/buffer/manager.rb
CHANGED
|
@@ -8,12 +8,14 @@ require "monitor"
|
|
|
8
8
|
require_relative "apply_transaction"
|
|
9
9
|
require_relative "../storage/layout"
|
|
10
10
|
require_relative "diff"
|
|
11
|
+
require_relative "../errors"
|
|
12
|
+
require_relative "../log"
|
|
11
13
|
require_relative "../platform"
|
|
12
14
|
require_relative "../security/guard"
|
|
13
15
|
|
|
14
16
|
module Rubik
|
|
15
17
|
module Buffer
|
|
16
|
-
class InvalidPathError <
|
|
18
|
+
class InvalidPathError < Rubik::Error; end
|
|
17
19
|
|
|
18
20
|
# Mid-run apply failure with the partial-progress report (issue #146):
|
|
19
21
|
# the buffer is NOT a multi-file transaction — entries already written
|
|
@@ -21,7 +23,7 @@ module Rubik
|
|
|
21
23
|
# failure class (:write_failed or :containment_blocked); `cause` carries
|
|
22
24
|
# the underlying error. `pending` lists this run's entries that are
|
|
23
25
|
# still dirty (a retry writes only those).
|
|
24
|
-
class ApplyFailedError <
|
|
26
|
+
class ApplyFailedError < Rubik::Error
|
|
25
27
|
attr_reader :kind, :applied, :failed, :pending, :conflicts, :skipped
|
|
26
28
|
|
|
27
29
|
def initialize(message, kind:, applied: [], failed: nil, pending: [], conflicts: [], skipped: [])
|
|
@@ -245,7 +247,7 @@ module Rubik
|
|
|
245
247
|
begin
|
|
246
248
|
@snapshot_store&.create_snapshot(self)
|
|
247
249
|
rescue StandardError => e
|
|
248
|
-
warn "
|
|
250
|
+
Rubik::Log.warn(:buffer, "snapshot recording failed: #{e.class}: #{e.message}")
|
|
249
251
|
end
|
|
250
252
|
content
|
|
251
253
|
end
|
|
@@ -5,6 +5,7 @@ require "json"
|
|
|
5
5
|
require "fileutils"
|
|
6
6
|
require "securerandom"
|
|
7
7
|
require "monitor"
|
|
8
|
+
require_relative "../log"
|
|
8
9
|
require_relative "../platform"
|
|
9
10
|
|
|
10
11
|
module Rubik
|
|
@@ -180,7 +181,7 @@ module Rubik
|
|
|
180
181
|
path = entry[0]
|
|
181
182
|
File.delete(path)
|
|
182
183
|
rescue SystemCallError => e
|
|
183
|
-
warn "
|
|
184
|
+
Rubik::Log.warn(:buffer, "could not remove excess snapshot #{safe_basename(path)}: #{e.class}")
|
|
184
185
|
end
|
|
185
186
|
end
|
|
186
187
|
|
|
@@ -294,7 +295,7 @@ module Rubik
|
|
|
294
295
|
|
|
295
296
|
snapshot
|
|
296
297
|
rescue StandardError => e
|
|
297
|
-
warn "
|
|
298
|
+
Rubik::Log.warn(:buffer, "skipping unreadable snapshot #{safe_basename(path)}: #{e.class}: #{safe_message(e)}")
|
|
298
299
|
nil
|
|
299
300
|
end
|
|
300
301
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../errors"
|
|
4
|
+
|
|
3
5
|
module Rubik
|
|
4
6
|
module Concurrency
|
|
5
|
-
class Error <
|
|
7
|
+
class Error < Rubik::Error; end
|
|
6
8
|
|
|
7
9
|
# Raised into a fiber interrupted through the Ruby 4.0 fiber_interrupt
|
|
8
10
|
# hook (a safety net — a healthy boundary drains every fiber before
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rubik
|
|
4
|
+
class Config
|
|
5
|
+
# Single home for the typed-value pipeline shared by dotted-key writes and
|
|
6
|
+
# scoped overrides: parse scalars, coerce, validate, then handle whole
|
|
7
|
+
# sections. Included into Config so Scoped inherits the same interface.
|
|
8
|
+
module Coercion
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
def normalize_value(key, value)
|
|
12
|
+
typed = Schema.coerce(key, parse_scalar_value(value))
|
|
13
|
+
Schema.validate_value!(key, typed, strict: true)
|
|
14
|
+
return typed unless typed.is_a?(Hash)
|
|
15
|
+
|
|
16
|
+
typed = deep_dup(typed)
|
|
17
|
+
Schema.coerce_nested!(typed, key.to_s)
|
|
18
|
+
# Only spec'd sections validate their leaves — open sections
|
|
19
|
+
# (providers, adapter) accept arbitrary child keys silently.
|
|
20
|
+
section = DEFAULT_CONFIG[key.to_s]
|
|
21
|
+
validate_schema(typed, section, key.to_s) if section.is_a?(Hash) && !section.empty?
|
|
22
|
+
typed
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -15,8 +15,7 @@ module Rubik
|
|
|
15
15
|
module EnvLoader
|
|
16
16
|
LEGACY_MAP = {
|
|
17
17
|
"RUBIK_NATIVE" => "tools.native",
|
|
18
|
-
"RUBIK_TOOLS_CALL_TIMEOUT" => "tools.call_timeout"
|
|
19
|
-
"RUBIK_LOG_LEVEL" => "ui.verbosity"
|
|
18
|
+
"RUBIK_TOOLS_CALL_TIMEOUT" => "tools.call_timeout"
|
|
20
19
|
}.freeze
|
|
21
20
|
|
|
22
21
|
module_function
|
data/lib/rubik/config/scoped.rb
CHANGED
|
@@ -23,17 +23,10 @@ module Rubik
|
|
|
23
23
|
return unless overrides.is_a?(Hash)
|
|
24
24
|
|
|
25
25
|
overrides.each do |k, v|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# is as strict as set('ui.verbosity', 'x').
|
|
31
|
-
if typed.is_a?(Hash)
|
|
32
|
-
Schema.coerce_nested!(typed, k.to_s)
|
|
33
|
-
section = DEFAULT_CONFIG[k.to_s]
|
|
34
|
-
validate_schema(typed, section, k.to_s) if section.is_a?(Hash) && !section.empty?
|
|
35
|
-
end
|
|
36
|
-
deep_set_key(@overrides, k.to_s, typed)
|
|
26
|
+
# Hash overrides stringify keys before the shared pipeline so
|
|
27
|
+
# extend(ui: {verbosity: 'x'}) is as strict as set('ui.verbosity', 'x').
|
|
28
|
+
input = v.is_a?(Hash) ? deep_stringify_keys(v) : deep_dup(v)
|
|
29
|
+
deep_set_key(@overrides, k.to_s, normalize_value(k, input))
|
|
37
30
|
end
|
|
38
31
|
end
|
|
39
32
|
|
|
@@ -70,15 +63,7 @@ module Rubik
|
|
|
70
63
|
old_val = nil
|
|
71
64
|
res = @monitor.synchronize do
|
|
72
65
|
old_val = fetch(key)
|
|
73
|
-
typed_val =
|
|
74
|
-
typed_val = Schema.coerce(key, typed_val)
|
|
75
|
-
Schema.validate_value!(key, typed_val, strict: true)
|
|
76
|
-
if typed_val.is_a?(Hash)
|
|
77
|
-
typed_val = deep_dup(typed_val)
|
|
78
|
-
Schema.coerce_nested!(typed_val, key.to_s)
|
|
79
|
-
section = DEFAULT_CONFIG[key.to_s]
|
|
80
|
-
validate_schema(typed_val, section, key.to_s) if section.is_a?(Hash) && !section.empty?
|
|
81
|
-
end
|
|
66
|
+
typed_val = normalize_value(key, value)
|
|
82
67
|
deep_set_key(@overrides, key, typed_val)
|
|
83
68
|
should_notify = old_val != typed_val
|
|
84
69
|
new_val = typed_val
|
|
@@ -159,7 +159,8 @@ module Rubik
|
|
|
159
159
|
keys_to_delete.each do |secret_path|
|
|
160
160
|
Rubik::Security::SecretStore.delete(secret_name(secret_path, scope))
|
|
161
161
|
end
|
|
162
|
-
rescue Rubik::Security::SecretStore::Error
|
|
162
|
+
rescue Rubik::Security::SecretStore::Error => e
|
|
163
|
+
Rubik::Log.debug(:config, "secret cleanup during delete failed (#{e.class}: #{e.message})")
|
|
163
164
|
nil
|
|
164
165
|
end
|
|
165
166
|
|
|
@@ -217,7 +218,7 @@ module Rubik
|
|
|
217
218
|
def warn_secret_store_fallback(error, scope)
|
|
218
219
|
msg = "OS secret store unavailable (#{error.message}); plaintext kept in #{scope} config"
|
|
219
220
|
@warnings << msg
|
|
220
|
-
Rubik::Log.warn(:config,
|
|
221
|
+
Rubik::Log.warn(:config, msg)
|
|
221
222
|
end
|
|
222
223
|
|
|
223
224
|
def plaintext_fallback_info
|
data/lib/rubik/config/store.rb
CHANGED
|
@@ -39,7 +39,7 @@ module Rubik
|
|
|
39
39
|
begin
|
|
40
40
|
FileUtils.mkdir_p(File.dirname(path))
|
|
41
41
|
rescue SystemCallError => e
|
|
42
|
-
Rubik::Log.warn(:config, "
|
|
42
|
+
Rubik::Log.warn(:config, "Failed to create config directory #{File.dirname(path)}: #{e.message}") if ENV["RUBIK_DEBUG"]
|
|
43
43
|
end
|
|
44
44
|
YAML::Store.new(path, true)
|
|
45
45
|
end
|
|
@@ -126,7 +126,10 @@ module Rubik
|
|
|
126
126
|
if File.exist?(target_path)
|
|
127
127
|
begin
|
|
128
128
|
File.chmod(0o600, target_path)
|
|
129
|
-
rescue StandardError
|
|
129
|
+
rescue StandardError => e
|
|
130
|
+
# The config file may hold secret references; a chmod failure
|
|
131
|
+
# leaves it possibly world-readable with no other trace.
|
|
132
|
+
Rubik::Log.warn(:config, "[Config] 0600 chmod failed on #{target_path}: #{e.class}: #{e.message}")
|
|
130
133
|
nil
|
|
131
134
|
end
|
|
132
135
|
end
|
data/lib/rubik/config.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "monitor"
|
|
4
4
|
require_relative "log"
|
|
5
|
+
require_relative "config/coercion"
|
|
5
6
|
require_relative "config/defaults"
|
|
6
7
|
require_relative "config/deep_ops"
|
|
7
8
|
require_relative "config/store"
|
|
@@ -15,6 +16,7 @@ require_relative "config/scoped"
|
|
|
15
16
|
module Rubik
|
|
16
17
|
class Config
|
|
17
18
|
include Defaults
|
|
19
|
+
include Coercion
|
|
18
20
|
include DeepOps
|
|
19
21
|
include Store
|
|
20
22
|
include ModelCatalog
|
|
@@ -79,17 +81,7 @@ module Rubik
|
|
|
79
81
|
def set(key, value, persist: nil)
|
|
80
82
|
res, old_val, new_val = @monitor.synchronize do
|
|
81
83
|
old_val = fetch(key)
|
|
82
|
-
typed_val =
|
|
83
|
-
typed_val = Schema.coerce(key, typed_val)
|
|
84
|
-
Schema.validate_value!(key, typed_val, strict: true)
|
|
85
|
-
if typed_val.is_a?(Hash)
|
|
86
|
-
typed_val = deep_dup(typed_val)
|
|
87
|
-
Schema.coerce_nested!(typed_val, key.to_s)
|
|
88
|
-
# Only spec'd sections validate their leaves — open sections
|
|
89
|
-
# (providers, adapter) accept arbitrary child keys silently.
|
|
90
|
-
section = DEFAULT_CONFIG[key.to_s]
|
|
91
|
-
validate_schema(typed_val, section, key.to_s) if section.is_a?(Hash) && !section.empty?
|
|
92
|
-
end
|
|
84
|
+
typed_val = normalize_value(key, value)
|
|
93
85
|
|
|
94
86
|
policy = guard_secret_write(key, typed_val, persist)
|
|
95
87
|
return { ok: false, error: policy[:block] } if policy&.key?(:block)
|
|
@@ -186,7 +178,9 @@ module Rubik
|
|
|
186
178
|
else
|
|
187
179
|
if (trimmed.start_with?("[") && trimmed.end_with?("]")) || (trimmed.start_with?("{") && trimmed.end_with?("}"))
|
|
188
180
|
begin
|
|
189
|
-
|
|
181
|
+
# Aliases are disabled: a self-referential collection would survive
|
|
182
|
+
# the load and recurse forever in redact_secret_value on notify.
|
|
183
|
+
parsed = YAML.safe_load(trimmed, permitted_classes: [Symbol], aliases: false)
|
|
190
184
|
return parsed if parsed.is_a?(Array) || parsed.is_a?(Hash)
|
|
191
185
|
rescue Psych::Exception
|
|
192
186
|
# The whole safe_load failure family: SyntaxError for malformed
|
|
@@ -250,7 +244,7 @@ module Rubik
|
|
|
250
244
|
rescue StandardError => e
|
|
251
245
|
# A listener error may quote a nested secret even on a non-secret key (#622).
|
|
252
246
|
error_text = secret_key?(key_str) ? SecretPolicy::REDACTED_VALUE : Rubik::Security::Redactor.redact(e.message.to_s)
|
|
253
|
-
Rubik::Log.warn(:config, "
|
|
247
|
+
Rubik::Log.warn(:config, "Config listener failed for '#{key_str}': #{error_text}")
|
|
254
248
|
@event_bus&.emit(:config_listener_error, key: key_str, error: error_text)
|
|
255
249
|
end
|
|
256
250
|
end
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "fileutils"
|
|
4
4
|
require_relative "http"
|
|
5
|
+
require_relative "../platform"
|
|
5
6
|
|
|
6
7
|
module Rubik
|
|
7
8
|
module Connect
|
|
@@ -86,21 +87,22 @@ module Rubik
|
|
|
86
87
|
return nil unless providers.is_a?(Hash) && fetched_at.is_a?(Numeric)
|
|
87
88
|
|
|
88
89
|
{ providers: providers, fetched_at: fetched_at.to_i }
|
|
89
|
-
rescue StandardError
|
|
90
|
+
rescue StandardError => e
|
|
91
|
+
# A permanently broken cache would otherwise degrade every catalog
|
|
92
|
+
# fetch with zero diagnostics — the miss must stay observable.
|
|
93
|
+
Rubik::Log.debug(:connect, "[Connect] catalog cache read failed for #{path}: #{e.class}: #{e.message.to_s.chars.first(120).join}")
|
|
90
94
|
nil
|
|
91
95
|
end
|
|
92
96
|
|
|
93
|
-
#
|
|
94
|
-
# half-JSON cache behind for the stale path to trip on.
|
|
95
|
-
#
|
|
96
|
-
#
|
|
97
|
+
# Use the shared atomic primitive so a crash mid-write can never leave
|
|
98
|
+
# a half-JSON cache behind for the stale path to trip on. It also uses
|
|
99
|
+
# an O_EXCL random temp, so a pre-placed symlink cannot redirect the
|
|
100
|
+
# write and a failed write leaves no temp file behind.
|
|
97
101
|
def write_cache(path, providers, fetched_at)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
File.rename(tmp, path)
|
|
103
|
-
rescue StandardError
|
|
102
|
+
payload = JSON.generate({ "fetched_at" => fetched_at, "providers" => providers })
|
|
103
|
+
Rubik::Platform.atomic_write(path, payload)
|
|
104
|
+
rescue StandardError => e
|
|
105
|
+
Rubik::Log.debug(:connect, "[Connect] catalog cache write failed for #{path}: #{e.class}: #{e.message.to_s.chars.first(120).join}")
|
|
104
106
|
nil
|
|
105
107
|
end
|
|
106
108
|
|
data/lib/rubik/errors.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Rubik
|
|
4
|
-
# Root of the unified error taxonomy (issue #448):
|
|
5
|
-
# error class hangs off Rubik::Error so callers can rescue
|
|
6
|
-
# Standalone-requireable — submodule files that define
|
|
7
|
-
# this file instead of the full lib/rubik.rb entry
|
|
4
|
+
# Root of the unified error taxonomy (issue #448, completed by #652):
|
|
5
|
+
# every Rubik error class hangs off Rubik::Error so callers can rescue
|
|
6
|
+
# one class. Standalone-requireable — submodule files that define
|
|
7
|
+
# errors require this file instead of the full lib/rubik.rb entry
|
|
8
|
+
# point.
|
|
8
9
|
class Error < StandardError; end
|
|
9
10
|
|
|
10
11
|
# Shared state-machine violation vocabulary (issue #448): the per-module
|
data/lib/rubik/event_bus.rb
CHANGED
data/lib/rubik/llm/client.rb
CHANGED
|
@@ -4,6 +4,7 @@ require "net/http"
|
|
|
4
4
|
require "json"
|
|
5
5
|
require "time"
|
|
6
6
|
require "uri"
|
|
7
|
+
require_relative "../errors"
|
|
7
8
|
require_relative "../platform"
|
|
8
9
|
require_relative "../security/redactor"
|
|
9
10
|
require_relative "sse_parser"
|
|
@@ -19,7 +20,7 @@ module Rubik
|
|
|
19
20
|
# POINT — precedent: RateLimitError's retry_after: kwarg. Default is
|
|
20
21
|
# permanent (false); only the raise sites that provably saw a
|
|
21
22
|
# transport-class failure opt into transient.
|
|
22
|
-
class ClientError <
|
|
23
|
+
class ClientError < Rubik::Error
|
|
23
24
|
attr_reader :transient
|
|
24
25
|
|
|
25
26
|
def initialize(message, transient: false)
|
data/lib/rubik/llm/registry.rb
CHANGED
|
@@ -283,7 +283,7 @@ module Rubik
|
|
|
283
283
|
# resolve it lazily per build so keyring updates apply on refresh.
|
|
284
284
|
api_key = Rubik::Security::SecretStore.resolve(p_spec["api_key"])
|
|
285
285
|
if api_key.nil? && Rubik::Security::SecretStore.reference?(p_spec["api_key"].to_s)
|
|
286
|
-
Rubik::Log.warn(:llm, "
|
|
286
|
+
Rubik::Log.warn(:llm, "stored secret '#{p_spec['api_key'].delete_prefix(Rubik::Security::SecretStore::REFERENCE_PREFIX)}' " \
|
|
287
287
|
"could not be retrieved via #{Rubik::Security::SecretStore.backend_name}")
|
|
288
288
|
end
|
|
289
289
|
|
data/lib/rubik/lsp/client.rb
CHANGED
|
@@ -195,11 +195,6 @@ module Rubik
|
|
|
195
195
|
@transport.server_pid
|
|
196
196
|
end
|
|
197
197
|
|
|
198
|
-
def reconnect!
|
|
199
|
-
stop if running
|
|
200
|
-
start
|
|
201
|
-
end
|
|
202
|
-
|
|
203
198
|
def stop
|
|
204
199
|
return unless running || @transport.resources?
|
|
205
200
|
|
|
@@ -326,10 +321,6 @@ module Rubik
|
|
|
326
321
|
@document_store.all_diagnostics
|
|
327
322
|
end
|
|
328
323
|
|
|
329
|
-
def diagnostics
|
|
330
|
-
@document_store.all_diagnostics
|
|
331
|
-
end
|
|
332
|
-
|
|
333
324
|
def diagnostics_snapshot_for(file_path)
|
|
334
325
|
abs_path = normalized_document_path(file_path)
|
|
335
326
|
snapshot = @document_store.diagnostic_snapshot(abs_path)
|
data/lib/rubik/lsp/transport.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "open3"
|
|
4
4
|
require "json"
|
|
5
|
+
require_relative "../errors"
|
|
5
6
|
require_relative "../platform"
|
|
6
7
|
require_relative "../log"
|
|
7
8
|
|
|
@@ -23,7 +24,7 @@ module Rubik
|
|
|
23
24
|
# start (spawn): every resource the transport opens is retracted in LIFO
|
|
24
25
|
# order, and a failing inverse never aborts the unwind.
|
|
25
26
|
class Transport
|
|
26
|
-
class RequestError <
|
|
27
|
+
class RequestError < Rubik::Error
|
|
27
28
|
attr_reader :reason
|
|
28
29
|
|
|
29
30
|
def initialize(reason, message)
|
data/lib/rubik/mcp/boot_run.rb
CHANGED
|
@@ -9,13 +9,14 @@ module Rubik
|
|
|
9
9
|
# outcomes ledger is an explicit atom map (index -> :applied | :failed;
|
|
10
10
|
# absence = skipped or never ran — exactly what owes_stop? reads).
|
|
11
11
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
# connect_server, apply_connected_server,
|
|
15
|
-
# BootLifecycle claim, and the client() reader
|
|
16
|
-
# Every monitor-hold boundary and epoch gate below
|
|
17
|
-
# code relocated, not restructured: the
|
|
18
|
-
# in run's ensure choreography plus
|
|
12
|
+
# Boot seam: Manager exposes boot_apply_gate, tool_count and
|
|
13
|
+
# emit_mcp_event as public methods for this object; the remaining
|
|
14
|
+
# collaborators (add_server, connect_server, apply_connected_server,
|
|
15
|
+
# transition_server!, the BootLifecycle claim, and the client() reader)
|
|
16
|
+
# were already public. Every monitor-hold boundary and epoch gate below
|
|
17
|
+
# is the former inline code relocated, not restructured: the
|
|
18
|
+
# atomic-rollback doctrine lives in run's ensure choreography plus
|
|
19
|
+
# BootLifecycle's epoch machinery.
|
|
19
20
|
class BootRun
|
|
20
21
|
attr_reader :entries, :connected, :outcomes, :boot_epoch
|
|
21
22
|
|
|
@@ -70,7 +71,7 @@ module Rubik
|
|
|
70
71
|
# vanish behind an ENV["RUBIK_DEBUG"] gate; a misconfigured
|
|
71
72
|
# server must surface without debug mode.
|
|
72
73
|
Rubik::Log.warn(:mcp, "failed to load MCP server '#{sname}' (#{e.class}: #{e.message})")
|
|
73
|
-
@manager.
|
|
74
|
+
@manager.emit_mcp_event(:mcp_server_failed, :err, sname.to_s, error: e.message)
|
|
74
75
|
next
|
|
75
76
|
end
|
|
76
77
|
next unless auto_start
|
|
@@ -109,12 +110,12 @@ module Rubik
|
|
|
109
110
|
|
|
110
111
|
if slot[:ok]
|
|
111
112
|
begin
|
|
112
|
-
outcome = @manager.
|
|
113
|
-
|
|
113
|
+
outcome = @manager.boot_apply_gate(name_str, parsed_defn, @boot_epoch,
|
|
114
|
+
client: slot[:client], tools: slot[:tools])
|
|
114
115
|
@outcomes[index] = :applied if outcome == :applied
|
|
115
116
|
if outcome == :applied
|
|
116
|
-
@manager.
|
|
117
|
-
|
|
117
|
+
@manager.emit_mcp_event(:mcp_server_loaded, :info, name_str,
|
|
118
|
+
tools: @manager.tool_count(name_str))
|
|
118
119
|
end
|
|
119
120
|
rescue StandardError => e
|
|
120
121
|
# ENSURE-LOG (G3 round-1): one broken server config used to
|
|
@@ -125,7 +126,7 @@ module Rubik
|
|
|
125
126
|
# never double-stops it.
|
|
126
127
|
@outcomes[index] = :failed
|
|
127
128
|
Rubik::Log.warn(:mcp, "failed to load MCP server '#{name_str}' (#{e.class}: #{e.message})")
|
|
128
|
-
@manager.
|
|
129
|
+
@manager.emit_mcp_event(:mcp_server_failed, :err, name_str, error: e.message)
|
|
129
130
|
end
|
|
130
131
|
else
|
|
131
132
|
# Only our own epoch's mark may flip to :failed — a user
|
|
@@ -136,7 +137,7 @@ module Rubik
|
|
|
136
137
|
@manager.transition_server!(name_str, :failed, epoch: @boot_epoch)
|
|
137
138
|
error = slot[:error]
|
|
138
139
|
Rubik::Log.warn(:mcp, "failed to load MCP server '#{name_str}' (#{error.class}: #{error.message})")
|
|
139
|
-
@manager.
|
|
140
|
+
@manager.emit_mcp_event(:mcp_server_failed, :err, name_str, error: error.message)
|
|
140
141
|
end
|
|
141
142
|
end
|
|
142
143
|
end
|
data/lib/rubik/mcp/errors.rb
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../errors"
|
|
4
|
+
|
|
3
5
|
module Rubik
|
|
4
6
|
module MCP
|
|
5
|
-
class Error <
|
|
7
|
+
class Error < Rubik::Error; end
|
|
6
8
|
class ConnectionError < Error; end
|
|
7
9
|
class TimeoutError < Error; end
|
|
8
10
|
class ProtocolError < Error; end
|
data/lib/rubik/mcp/manager.rb
CHANGED
|
@@ -389,7 +389,9 @@ module Rubik
|
|
|
389
389
|
BootRun.new(self, servers_cfg, mcp_enabled).run
|
|
390
390
|
end
|
|
391
391
|
|
|
392
|
-
|
|
392
|
+
public
|
|
393
|
+
|
|
394
|
+
# Boot seam for BootRun (boot_run.rb): the D5 race gate, one monitor
|
|
393
395
|
# hold deciding :skipped vs :applied. Moved verbatim — the hold
|
|
394
396
|
# boundary, the @stopped/@statuses/@boot_marks epoch gate and the
|
|
395
397
|
# guarded writes inside are exactly the former inline block; BootRun
|
|
@@ -410,15 +412,13 @@ module Rubik
|
|
|
410
412
|
end
|
|
411
413
|
end
|
|
412
414
|
|
|
413
|
-
#
|
|
415
|
+
# Boot seam for BootRun: the advisory @tools count read for the
|
|
414
416
|
# :mcp_server_loaded event — the same unguarded read the inline phase
|
|
415
417
|
# performed (observability only, never a state decision).
|
|
416
418
|
def tool_count(name_str)
|
|
417
419
|
(@tools[name_str] || []).size
|
|
418
420
|
end
|
|
419
421
|
|
|
420
|
-
public
|
|
421
|
-
|
|
422
422
|
# Teardown (mcp-async-boot slice 3): arms the boot gate, drains an
|
|
423
423
|
# in-flight boot thread, then disables every server. The join happens
|
|
424
424
|
# OUTSIDE the monitor (G5): the boot thread takes @monitor in its apply
|
|
@@ -465,8 +465,6 @@ module Rubik
|
|
|
465
465
|
@monitor.synchronize { @tools.values.flatten }
|
|
466
466
|
end
|
|
467
467
|
|
|
468
|
-
private
|
|
469
|
-
|
|
470
468
|
# Boot observability door (mcp-async-boot D7): publish through the
|
|
471
469
|
# session event bus so the dispatcher's dmesg door records boot
|
|
472
470
|
# outcomes under the "mcp" subsystem. post (enqueue) — never emit
|
|
@@ -483,6 +481,8 @@ module Rubik
|
|
|
483
481
|
Rubik::Log.warn(:mcp, "failed to emit MCP event '#{event_name}' (#{e.class}: #{e.message})")
|
|
484
482
|
end
|
|
485
483
|
|
|
484
|
+
private
|
|
485
|
+
|
|
486
486
|
# Bounded drain of the boot thread. Mechanics live in
|
|
487
487
|
# Concurrency::Join (monotonic-deadline poll, never raises); the
|
|
488
488
|
# still-alive warn and the :mcp log channel stay here. Reads
|