rubik 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/ATTRIBUTION.md +1 -1
  3. data/CHANGELOG.md +122 -1
  4. data/lib/rubik/adapter/node.rb +4 -1
  5. data/lib/rubik/ast/c_extractor.rb +1 -1
  6. data/lib/rubik/ast/fallback_cleaner.rb +6 -1
  7. data/lib/rubik/ast/graph.rb +38 -57
  8. data/lib/rubik/ast/graph_extensions.rb +57 -15
  9. data/lib/rubik/ast/ruby_extractor.rb +16 -6
  10. data/lib/rubik/ast/treesitter/c_walker.rb +11 -3
  11. data/lib/rubik/buffer/manager.rb +38 -11
  12. data/lib/rubik/buffer/snapshot.rb +116 -28
  13. data/lib/rubik/cli/connect.rb +3 -5
  14. data/lib/rubik/config/defaults.rb +3 -7
  15. data/lib/rubik/config/env_guard.rb +43 -0
  16. data/lib/rubik/config/schema.rb +7 -1
  17. data/lib/rubik/config/scoped.rb +12 -5
  18. data/lib/rubik/config/secret_policy.rb +6 -5
  19. data/lib/rubik/config.rb +1 -1
  20. data/lib/rubik/connect/models_dev.rb +11 -0
  21. data/lib/rubik/connect/probes.rb +9 -2
  22. data/lib/rubik/connect/wizard.rb +117 -57
  23. data/lib/rubik/context/repo_context_reader.rb +8 -4
  24. data/lib/rubik/diagnostics/collector.rb +25 -2
  25. data/lib/rubik/llm/chunk_assembler.rb +12 -1
  26. data/lib/rubik/llm/client.rb +19 -0
  27. data/lib/rubik/llm/connection_pool.rb +7 -1
  28. data/lib/rubik/llm/formatter.rb +22 -2
  29. data/lib/rubik/llm/provider_key.rb +32 -0
  30. data/lib/rubik/llm/registry.rb +18 -2
  31. data/lib/rubik/llm/router.rb +27 -1
  32. data/lib/rubik/llm/session_header.rb +128 -0
  33. data/lib/rubik/llm/sse_parser.rb +57 -10
  34. data/lib/rubik/lsp/client.rb +244 -23
  35. data/lib/rubik/lsp/document_store.rb +6 -0
  36. data/lib/rubik/lsp/manager.rb +14 -0
  37. data/lib/rubik/lsp/transport.rb +34 -7
  38. data/lib/rubik/mcp/transport/stdio.rb +42 -4
  39. data/lib/rubik/orchestrator/continuation_manager.rb +68 -7
  40. data/lib/rubik/orchestrator/goal_ledger/ledger.rb +18 -2
  41. data/lib/rubik/orchestrator/goal_ledger/observation_projection.rb +13 -4
  42. data/lib/rubik/orchestrator/goal_ledger/validator.rb +46 -7
  43. data/lib/rubik/orchestrator/goal_ledger/verifier.rb +8 -1
  44. data/lib/rubik/orchestrator/goal_session.rb +14 -14
  45. data/lib/rubik/orchestrator/goal_wait.rb +15 -9
  46. data/lib/rubik/orchestrator/loop.rb +39 -39
  47. data/lib/rubik/orchestrator/provider_resolver.rb +29 -6
  48. data/lib/rubik/orchestrator/step_executor.rb +17 -2
  49. data/lib/rubik/orchestrator/subagent/instance.rb +46 -5
  50. data/lib/rubik/orchestrator/subagent/lifecycle.rb +25 -25
  51. data/lib/rubik/orchestrator/subagent/messaging.rb +5 -1
  52. data/lib/rubik/orchestrator/subagent/narration.rb +2 -1
  53. data/lib/rubik/orchestrator/subagent/notices.rb +7 -3
  54. data/lib/rubik/orchestrator/subagent/questioner.rb +42 -4
  55. data/lib/rubik/orchestrator/subagent/reaper.rb +70 -20
  56. data/lib/rubik/orchestrator/subagent/start_gate.rb +1 -1
  57. data/lib/rubik/orchestrator/subagent/step_runner.rb +7 -7
  58. data/lib/rubik/orchestrator/subagent/supervisor.rb +21 -3
  59. data/lib/rubik/orchestrator/tool_call_id.rb +8 -4
  60. data/lib/rubik/orchestrator/turn_executor/subagent_channel.rb +21 -5
  61. data/lib/rubik/orchestrator/turn_executor/user_channel.rb +40 -5
  62. data/lib/rubik/orchestrator/turn_executor.rb +24 -8
  63. data/lib/rubik/platform/filesystem.rb +52 -24
  64. data/lib/rubik/platform/process.rb +32 -7
  65. data/lib/rubik/platform/sanitize.rb +17 -18
  66. data/lib/rubik/platform.rb +27 -0
  67. data/lib/rubik/plugin/storage.rb +34 -8
  68. data/lib/rubik/prompt/context_builder.rb +2 -1
  69. data/lib/rubik/prompt/doctrine.rb +3 -2
  70. data/lib/rubik/repair/loop.rb +22 -2
  71. data/lib/rubik/repl/commands/agent_context.rb +1 -1
  72. data/lib/rubik/repl/commands/agent_execution.rb +20 -15
  73. data/lib/rubik/repl/commands/base.rb +7 -3
  74. data/lib/rubik/repl/commands/buffer.rb +21 -2
  75. data/lib/rubik/repl/commands/connect.rb +0 -1
  76. data/lib/rubik/repl/commands/lsp.rb +1 -1
  77. data/lib/rubik/repl/commands/plugins.rb +31 -31
  78. data/lib/rubik/repl/commands/session.rb +16 -6
  79. data/lib/rubik/repl/commands/workspace.rb +4 -4
  80. data/lib/rubik/repl/input_execution.rb +33 -32
  81. data/lib/rubik/repl/input_loop.rb +9 -4
  82. data/lib/rubik/repl/lifecycle.rb +1 -2
  83. data/lib/rubik/repl/notice_router.rb +11 -5
  84. data/lib/rubik/repl/paste_support.rb +1 -1
  85. data/lib/rubik/repl/prompt_grace.rb +3 -3
  86. data/lib/rubik/repl/service_catalog.rb +6 -2
  87. data/lib/rubik/repl/shell.rb +10 -2
  88. data/lib/rubik/repl/turn_recorder.rb +18 -4
  89. data/lib/rubik/runtime/context.rb +33 -27
  90. data/lib/rubik/runtime/manager.rb +23 -15
  91. data/lib/rubik/runtime/manifest_store.rb +7 -2
  92. data/lib/rubik/runtime/task_manager.rb +13 -10
  93. data/lib/rubik/sandbox/driver/base.rb +34 -0
  94. data/lib/rubik/sandbox/driver/bubblewrap.rb +60 -8
  95. data/lib/rubik/sandbox/driver/docker.rb +8 -0
  96. data/lib/rubik/sandbox/driver/podman.rb +8 -0
  97. data/lib/rubik/sandbox/driver/process.rb +29 -1
  98. data/lib/rubik/sandbox/runner.rb +9 -1
  99. data/lib/rubik/security/classifier/classifier.rb +147 -13
  100. data/lib/rubik/security/classifier/commands/docker.yaml +1 -1
  101. data/lib/rubik/security/classifier/commands/git.yaml +27 -1
  102. data/lib/rubik/security/classifier/commands/sed.yaml +3 -3
  103. data/lib/rubik/security/classifier/database.rb +2 -2
  104. data/lib/rubik/security/command_gate.rb +8 -1
  105. data/lib/rubik/security/path_policy.rb +28 -3
  106. data/lib/rubik/security/redactor.rb +62 -19
  107. data/lib/rubik/session/recorder.rb +27 -20
  108. data/lib/rubik/session/replayer.rb +29 -7
  109. data/lib/rubik/storage/store.rb +26 -5
  110. data/lib/rubik/tools/builtins/exec.rb +8 -2
  111. data/lib/rubik/tools/builtins/files.rb +8 -12
  112. data/lib/rubik/tools/builtins/grep.rb +3 -2
  113. data/lib/rubik/tools/builtins/interactive.rb +5 -2
  114. data/lib/rubik/tools/builtins/lsp.rb +59 -9
  115. data/lib/rubik/tools/builtins/send_message.rb +7 -2
  116. data/lib/rubik/tools/builtins/show_file.rb +1 -1
  117. data/lib/rubik/tools/builtins/synthesis.rb +4 -4
  118. data/lib/rubik/tools/preflight_runner.rb +4 -1
  119. data/lib/rubik/tools/result_normalizer.rb +1 -1
  120. data/lib/rubik/ui/banner.rb +3 -3
  121. data/lib/rubik/ui/dialog.rb +15 -8
  122. data/lib/rubik/ui/diff_viewer.rb +4 -4
  123. data/lib/rubik/ui/frame.rb +13 -3
  124. data/lib/rubik/ui/markdown_stream.rb +8 -2
  125. data/lib/rubik/ui/panel.rb +11 -11
  126. data/lib/rubik/ui/renderer.rb +10 -7
  127. data/lib/rubik/ui/spinner.rb +1 -1
  128. data/lib/rubik/ui/statusline.rb +3 -3
  129. data/lib/rubik/ui/theme.rb +1 -1
  130. data/lib/rubik/version.rb +1 -1
  131. metadata +4 -1
@@ -4,6 +4,8 @@ require "zlib"
4
4
  require "json"
5
5
  require "fileutils"
6
6
  require "securerandom"
7
+ require "monitor"
8
+ require_relative "../platform"
7
9
 
8
10
  module Rubik
9
11
  module Buffer
@@ -45,54 +47,140 @@ module Rubik
45
47
  class SnapshotStore
46
48
  attr_reader :storage_dir, :snapshots
47
49
 
48
- def initialize(storage_dir: File.join(ENV.fetch("HOME", nil), ".rubik", "snapshots", "default"))
50
+ # Issue #589: in-memory snapshots stay per-edit (undo granularity is
51
+ # untouched), but the whole-buffer deflate+disk persist is debounced to
52
+ # at most one write per interval — the IO is the expensive part and the
53
+ # files are durability artifacts, never read back by undo/rollback.
54
+ # 0 disables debouncing (the historical per-write persistence, still
55
+ # the default so standalone/test stores keep exact per-edit durability).
56
+ DEFAULT_MIN_INTERVAL = 0.0
57
+ # On-disk retention cap: once exceeded, the oldest snapshot files are
58
+ # rotated away (their undo reach is lost, same as an expired redo
59
+ # tail). Keeps a long session from accumulating unbounded snapshot
60
+ # files (issue #589).
61
+ DEFAULT_MAX_SNAPSHOTS = 200
62
+
63
+ def initialize(storage_dir: File.join(Rubik::Platform.home_dir, ".rubik", "snapshots", "default"),
64
+ min_interval: DEFAULT_MIN_INTERVAL,
65
+ max_snapshots: DEFAULT_MAX_SNAPSHOTS)
49
66
  @storage_dir = storage_dir
67
+ @min_interval = min_interval.to_f
68
+ @max_snapshots = [max_snapshots.to_i, 1].max
50
69
  @snapshots = []
51
70
  @current_index = -1
71
+ @last_file_write_at = nil
72
+ # The store is written from the manager's write path (outside the
73
+ # manager monitor, issue #589) and read by undo/rollback; guard its
74
+ # own index/file state independently.
75
+ @monitor = Monitor.new
76
+ # The state undo-to-beginning restores. Defaults to a clean
77
+ # buffer; consumers that snapshot a pre-existing dirty buffer
78
+ # (e.g. Repair::Loop) record that state explicitly so an aborted
79
+ # operation restores the pending edits instead of wiping them
80
+ # (issue #544).
81
+ @baseline = {}
52
82
  FileUtils.mkdir_p(@storage_dir)
53
83
  end
54
84
 
85
+ # Records the state that a full undo should restore. Call once,
86
+ # before the first snapshot, when the buffer already holds edits
87
+ # that must survive an aborted operation.
88
+ def record_baseline(buffer_manager)
89
+ @monitor.synchronize do
90
+ @baseline = buffer_manager.snapshot_state
91
+ end
92
+ end
93
+
55
94
  def create_snapshot(buffer_manager)
56
- return nil unless buffer_manager.dirty?
95
+ @monitor.synchronize do
96
+ return nil unless buffer_manager.dirty?
97
+
98
+ snapshot = Snapshot.new(files: buffer_manager.snapshot_state)
99
+
100
+ # Persist BEFORE any list mutation (issue #476 tranche 2): a failed
101
+ # disk write must leave the in-memory snapshot list untouched.
102
+ # Persistence is debounced (issue #589) — a skip inside the window
103
+ # costs only crash-durability granularity, never an undo step.
104
+ persist_snapshot(snapshot)
105
+
106
+ # Clamp the redo truncation: with @current_index == -1 the range
107
+ # [0..-1] is the WHOLE array, so a fresh snapshot after undoing
108
+ # to empty would be appended after stale snapshots and a later
109
+ # undo would resurrect the discarded edit (issue #544).
110
+ if @current_index < @snapshots.size - 1
111
+ @snapshots = @current_index.negative? ? [] : @snapshots[0..@current_index]
112
+ end
113
+
114
+ @snapshots << snapshot
115
+ @current_index = @snapshots.size - 1
116
+
117
+ rotate_expired_snapshots
118
+ snapshot
119
+ end
120
+ end
121
+
122
+ # Debounced persistence (issue #589): at most one deflate+binwrite per
123
+ # interval. Undo/rollback run from the in-memory snapshot list, so a
124
+ # skipped persist costs only crash-durability granularity, never an
125
+ # undo step.
126
+ def persist_snapshot(snapshot)
127
+ now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
128
+ return false if @min_interval.positive? && @last_file_write_at && now - @last_file_write_at < @min_interval
57
129
 
58
- snapshot = Snapshot.new(files: buffer_manager.snapshot_state)
59
130
  # Naming reflects the actual codec: this is Zlib::Deflate (RFC 1951),
60
131
  # NOT Zstandard despite the "z" prefix. "zst" was misleading and could
61
132
  # fool a tool into trying a zstd decompressor. Kept short to preserve
62
133
  # the existing file layout.
63
- file_path = File.join(@storage_dir, "#{snapshot.id}.zdeflate")
64
- File.binwrite(file_path, snapshot.compress)
65
-
66
- @snapshots = @snapshots[0..@current_index] if @current_index < @snapshots.size - 1
134
+ File.binwrite(File.join(@storage_dir, "#{snapshot.id}.zdeflate"), snapshot.compress)
135
+ @last_file_write_at = now
136
+ true
137
+ end
67
138
 
68
- @snapshots << snapshot
69
- @current_index = @snapshots.size - 1
70
- snapshot
139
+ # Retention cap (issue #589): drop the oldest snapshots beyond the cap
140
+ # and unlink their files. Only undo-unreachable entries may be dropped:
141
+ # @current_index is shifted so it keeps pointing at the same logical
142
+ # snapshot, and a shift below zero folds into the baseline restore.
143
+ def rotate_expired_snapshots
144
+ excess = @snapshots.size - @max_snapshots
145
+ return if excess <= 0
146
+
147
+ dropped = @snapshots.shift(excess)
148
+ @current_index -= excess
149
+ @current_index = -1 if @current_index.negative?
150
+ dropped.each do |snapshot|
151
+ File.delete(File.join(@storage_dir, "#{snapshot.id}.zdeflate"))
152
+ rescue SystemCallError
153
+ nil
154
+ end
71
155
  end
72
156
 
73
157
  def undo(buffer_manager)
74
- return false if @current_index.negative?
75
-
76
- if @current_index.zero?
77
- buffer_manager.restore_snapshot_state({})
78
- @current_index = -1
79
- return true
158
+ @monitor.synchronize do
159
+ return false if @current_index.negative?
160
+
161
+ if @current_index.zero?
162
+ buffer_manager.restore_snapshot_state(@baseline)
163
+ @current_index = -1
164
+ return true
165
+ end
166
+
167
+ @current_index -= 1
168
+ prev_snapshot = @snapshots[@current_index]
169
+ buffer_manager.restore_snapshot_state(prev_snapshot.files)
170
+ true
80
171
  end
81
-
82
- @current_index -= 1
83
- prev_snapshot = @snapshots[@current_index]
84
- buffer_manager.restore_snapshot_state(prev_snapshot.files)
85
- true
86
172
  end
87
173
 
88
174
  def rollback(snapshot_id, buffer_manager)
89
- target_idx = @snapshots.index { |s| s.id == snapshot_id }
90
- return false unless target_idx
91
-
92
- target_snapshot = @snapshots[target_idx]
93
- buffer_manager.restore_snapshot_state(target_snapshot.files)
94
- @current_index = target_idx
95
- true
175
+ @monitor.synchronize do
176
+ target_idx = @snapshots.index { |s| s.id == snapshot_id }
177
+ return false unless target_idx
178
+
179
+ target_snapshot = @snapshots[target_idx]
180
+ buffer_manager.restore_snapshot_state(target_snapshot.files)
181
+ @current_index = target_idx
182
+ true
183
+ end
96
184
  end
97
185
  end
98
186
  end
@@ -23,7 +23,6 @@ module Rubik
23
23
  end
24
24
  if argv.intersect?(["--session", "-s"])
25
25
  output.puts USAGE
26
- output.puts " rubik connect yalnızca kalıcı kapsamlara yazar; oturum-kapsamı için REPL içinde !provider add kullanın."
27
26
  output.puts " rubik connect writes persistent scopes only; use !provider add in the REPL for a session-scoped provider."
28
27
  return 1
29
28
  end
@@ -38,12 +37,11 @@ module Rubik
38
37
  result = wizard.run
39
38
 
40
39
  if result[:reason] == :non_interactive
41
- output.puts "Etkileşimsiz oturum — sihirbaz çalışamaz. 'rubik' ile REPL başlatıp !connect kullanın " \
42
- "veya !provider add <name> [type] <url> [--key=...] sözdizimini uygulayın."
43
- output.puts "Non-interactive session — start the REPL and run !connect, or use !provider add flags."
40
+ output.puts "Non-interactive session — the wizard cannot run. Start the REPL with 'rubik' and use !connect, " \
41
+ "or apply the !provider add <name> [type] <url> [--key=...] syntax."
44
42
  return 2
45
43
  end
46
- output.puts "Çıkmak için 'rubik' ile REPL'i başlatın / Start the REPL with 'rubik'." if result[:ok]
44
+ output.puts "Start the REPL with 'rubik'." if result[:ok]
47
45
  result[:ok] ? 0 : 1
48
46
  end
49
47
  end
@@ -1,10 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "../platform"
4
+ require_relative "env_guard"
4
5
 
5
6
  module Rubik
6
7
  class Config
7
8
  module Defaults
9
+ include EnvGuard
10
+
8
11
  # llm.* transport-resilience fallbacks, reused by both orchestrator seams.
9
12
  LLM_RETRY_DEFAULTS = { "max_retries" => 2, "max_429_retries" => 5, "backoff_base" => 0.2,
10
13
  "max_wall_clock" => 120, "rate_limit_max_delay" => 60 }.freeze
@@ -231,13 +234,6 @@ module Rubik
231
234
 
232
235
  private
233
236
 
234
- # Schema-backed keys must satisfy their spec wherever the merged tree is validated.
235
- def validate_typed_value!(key, value)
236
- return unless Schema::DEFINITIONS.key?(key.to_s)
237
-
238
- Schema.validate_value!(key, value, strict: true)
239
- end
240
-
241
237
  def validate_schema(config, schema = DEFAULT_CONFIG, prefix = "", strict: false)
242
238
  raise ArgumentError, "Configuration must be a Hash, got #{config.class}" unless config.is_a?(Hash)
243
239
 
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rubik
4
+ class Config
5
+ # Issue #561: typed-value validation shared by explicit writes and the
6
+ # boot-time env layer, plus the fail-soft env guard. Kept out of
7
+ # defaults.rb so the schema/default tables stay inside the file-size
8
+ # hygiene limit.
9
+ module EnvGuard
10
+ private
11
+
12
+ # Explicit writes (Config#set / Scoped#set) keep strict validation;
13
+ # boot-time env validation passes strict: false so a malformed RUBIK_*
14
+ # variable is dropped with a warning instead of crashing Config.new.
15
+ def validate_typed_value!(key, value, strict: true)
16
+ return true unless Schema::DEFINITIONS.key?(key.to_s)
17
+
18
+ Schema.validate_value!(key, value, strict: strict)
19
+ end
20
+
21
+ # Walk the env layer's typed leaves and remove any schema-backed value
22
+ # that fails its spec, recording a warning instead of raising. Mutates
23
+ # and returns the layer so the merged config never sees the rejected
24
+ # value (and cannot resurrect it on a later set).
25
+ def validate_env_layer!(layer, warnings, prefix = "")
26
+ return layer unless layer.is_a?(Hash)
27
+
28
+ layer.each_key do |key|
29
+ full = prefix.empty? ? key.to_s : "#{prefix}.#{key}"
30
+ val = layer[key]
31
+ if val.is_a?(Hash)
32
+ validate_env_layer!(val, warnings, full)
33
+ elsif Schema::DEFINITIONS.key?(full) && !validate_typed_value!(full, val, strict: false)
34
+ warnings << "[CONFIG] Ignoring invalid environment value '#{full}=#{val.inspect}'; " \
35
+ "using the configured default instead."
36
+ layer.delete(key)
37
+ end
38
+ end
39
+ layer
40
+ end
41
+ end
42
+ end
43
+ end
@@ -166,7 +166,13 @@ module Rubik
166
166
  when :integer
167
167
  val.strip =~ /^-?\d+$/ ? val.strip.to_i : val
168
168
  when :float
169
- val.strip =~ /^-?\d+(\.\d+)?$/ ? val.strip.to_f : val
169
+ # Accept leading-dot (.2), trailing-dot (2.) and exponent (1e-3,
170
+ # -2.5E+2) forms that Ruby's Float() understands.
171
+ val.strip =~ /\A[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?\z/ ? val.strip.to_f : val
172
+ when :array
173
+ # Comma-separated env values (e.g. "ls,cat") become a typed list;
174
+ # blank entries are dropped so trailing commas stay harmless.
175
+ val.strip.split(",").map(&:strip).reject(&:empty?)
170
176
  when :enum
171
177
  val.strip.downcase
172
178
  else
@@ -40,12 +40,19 @@ module Rubik
40
40
  def fetch(key, default = nil)
41
41
  @monitor.synchronize do
42
42
  keys = key.to_s.split(".")
43
- val = keys.reduce(@overrides) do |acc, k|
44
- break nil unless acc.is_a?(Hash) && acc.key?(k)
45
-
46
- acc[k]
43
+ # "Key present with nil" is distinct from "key absent" (issue #599):
44
+ # an explicit nil override shadows the parent instead of falling
45
+ # through to it.
46
+ node = @overrides
47
+ present = keys.all? do |k|
48
+ if node.is_a?(Hash) && node.key?(k)
49
+ node = node[k]
50
+ true
51
+ else
52
+ false
53
+ end
47
54
  end
48
- return val unless val.nil?
55
+ return node if present
49
56
 
50
57
  @parent.fetch(key, default)
51
58
  end
@@ -120,9 +120,10 @@ module Rubik
120
120
  end
121
121
 
122
122
  # Keyring hygiene for Config#delete: a successfully persisted delete
123
- # of an api_key path also drops its stored secret(s) — both scopes'
124
- # names, so neither keyring entry outlives its reference. Best-effort
125
- # — never masks res.
123
+ # of an api_key path also drops the stored secret for the scope being
124
+ # removed. The sibling scope's keyring entry is deliberately left
125
+ # intact — its config pointer still lives in the other layer and must
126
+ # keep resolving. Best-effort — never masks res.
126
127
  def cleanup_stored_secret(key, res, persist, old_val: nil)
127
128
  return unless res[:ok] && persisting?(persist)
128
129
 
@@ -133,9 +134,9 @@ module Rubik
133
134
  else
134
135
  []
135
136
  end
137
+ scope = persist.to_s.downcase.to_sym == :project ? :project : :global
136
138
  keys_to_delete.each do |secret_path|
137
- Rubik::Security::SecretStore.delete(secret_path)
138
- Rubik::Security::SecretStore.delete("#{secret_path}.project")
139
+ Rubik::Security::SecretStore.delete(secret_name(secret_path, scope))
139
140
  end
140
141
  rescue Rubik::Security::SecretStore::Error
141
142
  nil
data/lib/rubik/config.rb CHANGED
@@ -296,7 +296,7 @@ module Rubik
296
296
  @project_layer = filter_untrusted_project_config(@project_layer)
297
297
  end
298
298
 
299
- @env_layer = EnvLoader.load_env(ENV, DEFAULT_CONFIG, @warnings)
299
+ @env_layer = validate_env_layer!(EnvLoader.load_env(ENV, DEFAULT_CONFIG, @warnings), @warnings)
300
300
  @session_layer = {}
301
301
 
302
302
  warn_plaintext_project_secrets
@@ -37,6 +37,17 @@ module Rubik
37
37
  # field for "google" must NOT be used here.
38
38
  { id: "gemini", label: "Google (Gemini)", type: "openai_compatible", api: "https://generativelanguage.googleapis.com/v1beta/openai", catalog_id: "google",
39
39
  use_catalog_api: false },
40
+ # The models.dev catalog's own api for "opencode" is the CONSOLE
41
+ # endpoint (https://opencode.ai/inference/openai/v1), not the Go
42
+ # gateway — hence use_catalog_api: false (same pattern as Google).
43
+ # The /v1 tail is REQUIRED: normalize_endpoint only appends
44
+ # /chat/completions to a versioned tail, and a bare /openai tail
45
+ # would spell /openai/chat/completions (a 404 there). POSTs hard-400
46
+ # with MissingSessionID until providers.<key>.session_header carries
47
+ # x-opencode-session, so the row PRE-ANSWERS the wizard question:
48
+ # selecting the preset applies the header without prompting (ask_session_header).
49
+ { id: "opencode", label: "opencode (Go)", type: "openai_compatible", api: "https://opencode.ai/inference/go/openai/v1", catalog_id: "opencode", use_catalog_api: false,
50
+ session_header: "x-opencode-session" },
40
51
  { id: "ollama", label: "Ollama (yerel / local)", type: "ollama", api: "http://localhost:11434", catalog_id: nil }
41
52
  ].freeze
42
53
 
@@ -75,10 +75,17 @@ module Rubik
75
75
  { ok: false, auth_failed: false, reachable: false, models: [], note: res[:error].to_s }
76
76
  when :http_error
77
77
  if AUTH_STATUSES.include?(res[:status])
78
- { ok: false, auth_failed: true, reachable: true, models: [], note: "HTTP #{res[:status]} — anahtar reddedildi / key rejected" }
78
+ { ok: false, auth_failed: true, reachable: true, models: [], note: "HTTP #{res[:status]} — key rejected" }
79
79
  elsif NO_LISTING_STATUSES.include?(res[:status])
80
80
  { ok: true, auth_failed: false, reachable: true, models: [],
81
- note: "model listesi yayınlanmıyor (HTTP #{res[:status]}) — model adını elle girin / no model listing; enter the name manually" }
81
+ note: "no model listing (HTTP #{res[:status]}) — enter the name manually" }
82
+ elsif res[:status] == 400
83
+ # Honest scope: the 400 was observed on THIS GET probe; the
84
+ # session-header part is a "commonly means" hint, not a settled
85
+ # diagnosis — the wizard's failure menu owns the next move.
86
+ { ok: false, auth_failed: false, reachable: true, models: [],
87
+ note: "HTTP 400 — request-shape rejection; commonly means a gateway rejecting requests missing a session header " \
88
+ "(e.g. opencode: x-opencode-session) — not an auth failure" }
82
89
  else
83
90
  { ok: false, auth_failed: false, reachable: true, models: [], note: "HTTP #{res[:status]}" }
84
91
  end