rubik 0.14.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.
- checksums.yaml +4 -4
- data/ATTRIBUTION.md +1 -1
- data/CHANGELOG.md +89 -1
- data/lib/rubik/adapter/node.rb +4 -1
- data/lib/rubik/ast/fallback_cleaner.rb +6 -1
- data/lib/rubik/ast/ruby_extractor.rb +12 -6
- data/lib/rubik/buffer/manager.rb +15 -10
- data/lib/rubik/buffer/snapshot.rb +103 -35
- data/lib/rubik/config/scoped.rb +12 -5
- data/lib/rubik/connect/models_dev.rb +4 -2
- data/lib/rubik/connect/wizard.rb +9 -1
- data/lib/rubik/diagnostics/collector.rb +25 -2
- data/lib/rubik/llm/client.rb +19 -0
- data/lib/rubik/llm/connection_pool.rb +7 -1
- data/lib/rubik/llm/formatter.rb +8 -2
- data/lib/rubik/llm/router.rb +8 -0
- data/lib/rubik/lsp/client.rb +233 -18
- data/lib/rubik/lsp/document_store.rb +6 -0
- data/lib/rubik/lsp/manager.rb +14 -0
- data/lib/rubik/lsp/transport.rb +17 -0
- data/lib/rubik/orchestrator/continuation_manager.rb +54 -2
- data/lib/rubik/orchestrator/goal_session.rb +10 -10
- data/lib/rubik/orchestrator/goal_wait.rb +15 -9
- data/lib/rubik/orchestrator/loop.rb +31 -28
- data/lib/rubik/orchestrator/subagent/instance.rb +22 -4
- data/lib/rubik/orchestrator/subagent/lifecycle.rb +25 -25
- data/lib/rubik/orchestrator/subagent/messaging.rb +5 -1
- data/lib/rubik/orchestrator/subagent/narration.rb +2 -1
- data/lib/rubik/orchestrator/subagent/notices.rb +6 -2
- data/lib/rubik/orchestrator/subagent/questioner.rb +42 -4
- data/lib/rubik/orchestrator/subagent/reaper.rb +50 -19
- data/lib/rubik/orchestrator/subagent/supervisor.rb +11 -0
- data/lib/rubik/orchestrator/tool_call_id.rb +8 -4
- data/lib/rubik/orchestrator/turn_executor/subagent_channel.rb +21 -5
- data/lib/rubik/orchestrator/turn_executor/user_channel.rb +15 -2
- data/lib/rubik/platform/process.rb +32 -7
- data/lib/rubik/platform/sanitize.rb +17 -18
- data/lib/rubik/platform.rb +27 -0
- data/lib/rubik/plugin/storage.rb +17 -11
- data/lib/rubik/prompt/doctrine.rb +3 -2
- data/lib/rubik/repl/commands/base.rb +7 -3
- data/lib/rubik/repl/commands/buffer.rb +6 -2
- data/lib/rubik/repl/commands/session.rb +11 -1
- data/lib/rubik/repl/input_execution.rb +3 -3
- data/lib/rubik/repl/service_catalog.rb +6 -2
- data/lib/rubik/repl/turn_recorder.rb +4 -1
- data/lib/rubik/runtime/manifest_store.rb +7 -2
- data/lib/rubik/runtime/task_manager.rb +13 -10
- data/lib/rubik/sandbox/driver/base.rb +34 -0
- data/lib/rubik/sandbox/driver/bubblewrap.rb +2 -0
- data/lib/rubik/sandbox/driver/docker.rb +8 -0
- data/lib/rubik/sandbox/driver/podman.rb +8 -0
- data/lib/rubik/sandbox/driver/process.rb +9 -12
- data/lib/rubik/security/path_policy.rb +28 -3
- data/lib/rubik/session/recorder.rb +14 -2
- data/lib/rubik/storage/store.rb +7 -0
- data/lib/rubik/tools/builtins/exec.rb +7 -1
- data/lib/rubik/tools/builtins/interactive.rb +5 -2
- data/lib/rubik/tools/builtins/lsp.rb +28 -2
- data/lib/rubik/tools/builtins/send_message.rb +7 -2
- data/lib/rubik/tools/preflight_runner.rb +4 -1
- data/lib/rubik/ui/dialog.rb +5 -1
- data/lib/rubik/ui/renderer.rb +4 -1
- data/lib/rubik/version.rb +1 -1
- metadata +1 -1
|
@@ -101,11 +101,36 @@ module Rubik
|
|
|
101
101
|
write_targets.concat(ast.write_paths.to_a) if ast.respond_to?(:write_paths)
|
|
102
102
|
|
|
103
103
|
write_targets.uniq.each do |wp|
|
|
104
|
-
|
|
104
|
+
if critical_path?(wp)
|
|
105
|
+
@audit.log_audit("blocked_command", command: cmd_str, reason: "critical_path_write", path: wp)
|
|
106
|
+
raise BlockedWriteError.new(
|
|
107
|
+
"Command write to critical path blocked: #{wp} in `#{cmd_str}`",
|
|
108
|
+
kind: :critical_path_write,
|
|
109
|
+
blocked_command: cmd_str,
|
|
110
|
+
path: wp
|
|
111
|
+
)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Symlink re-check (fail-closed, issue #590): the lexical test above
|
|
115
|
+
# cannot see `evil -> .git/config`, so `echo x > evil` would sail
|
|
116
|
+
# through while naming nothing critical. Resolve each write target
|
|
117
|
+
# exactly like verify_path_write! does and re-check the resolution;
|
|
118
|
+
# a nil resolution (symlink loop / permission wall) fails closed.
|
|
119
|
+
resolved = Rubik::Platform.resolved_path(wp, strict: true)
|
|
120
|
+
if resolved.nil?
|
|
121
|
+
@audit.log_audit("blocked_command", command: cmd_str, reason: "path_resolution_failed", path: wp)
|
|
122
|
+
raise BlockedWriteError.new(
|
|
123
|
+
"Command write blocked: path could not be safely resolved: #{wp} in `#{cmd_str}`",
|
|
124
|
+
kind: :critical_path_write,
|
|
125
|
+
blocked_command: cmd_str,
|
|
126
|
+
path: wp
|
|
127
|
+
)
|
|
128
|
+
end
|
|
129
|
+
next unless critical_path?(resolved)
|
|
105
130
|
|
|
106
|
-
@audit.log_audit("blocked_command", command: cmd_str, reason: "
|
|
131
|
+
@audit.log_audit("blocked_command", command: cmd_str, reason: "critical_path_write_symlink", path: wp, resolved: resolved)
|
|
107
132
|
raise BlockedWriteError.new(
|
|
108
|
-
"Command write to critical path blocked: #{wp} in `#{cmd_str}`",
|
|
133
|
+
"Command write to critical path blocked (symlink-resolved): #{wp} -> #{resolved} in `#{cmd_str}`",
|
|
109
134
|
kind: :critical_path_write,
|
|
110
135
|
blocked_command: cmd_str,
|
|
111
136
|
path: wp
|
|
@@ -78,7 +78,19 @@ module Rubik
|
|
|
78
78
|
record("repl_command", { "command" => cmd, "output" => output })
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
# Durability barrier for copies of the live JSONL (issue #598): records
|
|
82
|
+
# are opened, written and closed per event, so there is no buffered
|
|
83
|
+
# writer to flush — this fsync barrier guarantees a save copy taken
|
|
84
|
+
# afterwards never observes a torn tail.
|
|
85
|
+
def flush
|
|
86
|
+
return unless @session_file && File.exist?(@session_file)
|
|
87
|
+
|
|
88
|
+
File.open(@session_file, "a", &:fsync)
|
|
89
|
+
rescue StandardError
|
|
90
|
+
nil
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def switch_session_file(target_file, cleanup_empty_current: true, parent_session_id: nil)
|
|
82
94
|
if cleanup_empty_current && @session_file && File.exist?(@session_file) && File.expand_path(@session_file) != File.expand_path(target_file)
|
|
83
95
|
begin
|
|
84
96
|
lines = File.readlines(@session_file).reject { |l| l.strip.empty? }
|
|
@@ -111,7 +123,7 @@ module Rubik
|
|
|
111
123
|
end
|
|
112
124
|
|
|
113
125
|
record("session_resumed", {
|
|
114
|
-
"parent_session_id" => File.basename(target_file, ".jsonl"),
|
|
126
|
+
"parent_session_id" => parent_session_id || File.basename(target_file, ".jsonl"),
|
|
115
127
|
"resumed_at" => Time.now.iso8601
|
|
116
128
|
})
|
|
117
129
|
end
|
data/lib/rubik/storage/store.rb
CHANGED
|
@@ -345,6 +345,13 @@ module Rubik
|
|
|
345
345
|
end
|
|
346
346
|
|
|
347
347
|
def meta_set_ref(meta, name, id)
|
|
348
|
+
# One ref-name guard for BOTH alias-creation paths (issue #602):
|
|
349
|
+
# put(ref:) previously skipped the validation set_ref enforces, so
|
|
350
|
+
# an alias with separators/unicode could reach meta.json and yield a
|
|
351
|
+
# permanently unreadable refs route.
|
|
352
|
+
name = name.to_s
|
|
353
|
+
raise ArgumentError, "invalid ref name '#{name}'" unless name.match?(REF_PATTERN)
|
|
354
|
+
|
|
348
355
|
refs = (meta["refs"] ||= {})
|
|
349
356
|
refs[name] = id
|
|
350
357
|
meta["updated_at"] = Time.now.utc.iso8601
|
|
@@ -219,7 +219,13 @@ module Rubik
|
|
|
219
219
|
# contract through BOTH dispatch paths — no display-text parsing.
|
|
220
220
|
def command_result(cmd, res, duration_ms:)
|
|
221
221
|
exit_code = res[:exit_code]
|
|
222
|
-
|
|
222
|
+
# Explicit timeout flag plumbed through the whole chain
|
|
223
|
+
# (popen_capture → sandbox drivers → runner, issue #597-3), so a
|
|
224
|
+
# legitimate timeout(1) exit 124 no longer reads as a runner kill.
|
|
225
|
+
# The legacy exit-code inference remains ONLY for result hashes that
|
|
226
|
+
# genuinely do not carry the flag (pre-plumbing producers outside the
|
|
227
|
+
# sandbox driver chain).
|
|
228
|
+
timed_out = res.key?(:timed_out) ? res[:timed_out] == true : exit_code.to_i == 124
|
|
223
229
|
status_text = res[:ok] ? "OK" : "EXIT #{exit_code}"
|
|
224
230
|
shell_tag = res[:shell] ? " (#{res[:shell]})" : ""
|
|
225
231
|
out = "[#{status_text}]#{shell_tag} #{res[:output]}"
|
|
@@ -131,14 +131,17 @@ module Rubik
|
|
|
131
131
|
def validate_question(q_data, index:)
|
|
132
132
|
return ToolOutput.error("Invalid question #{index}: item must be an object with 'question' and 'options' properties.") unless q_data.is_a?(Hash)
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
# Question text and options are model-controlled; strip CSI/OSC
|
|
135
|
+
# escapes (issue #592) so prompt-injected sequences cannot reach the
|
|
136
|
+
# raw terminal through the dialog card or the echoed response.
|
|
137
|
+
q_text = Rubik::UI::Capability.strip_ansi((q_data["question"] || q_data[:question]).to_s.strip)
|
|
135
138
|
raw_options = q_data["options"] || q_data[:options]
|
|
136
139
|
is_multi = q_data["is_multi_select"] || q_data[:is_multi_select] || false
|
|
137
140
|
|
|
138
141
|
return ToolOutput.error("Invalid question #{index}: question text cannot be blank.") if q_text.empty?
|
|
139
142
|
return ToolOutput.error("Invalid question #{index}: must provide an array of selectable options.") unless raw_options.is_a?(Array)
|
|
140
143
|
|
|
141
|
-
options = raw_options.map(
|
|
144
|
+
options = raw_options.map { |o| Rubik::UI::Capability.strip_ansi(o.to_s.strip) }.reject(&:empty?).uniq
|
|
142
145
|
return ToolOutput.error("Invalid question #{index}: must provide at least 2 distinct non-empty selectable options.") if options.size < 2
|
|
143
146
|
|
|
144
147
|
{ question: q_text, options: options, is_multi: is_multi }
|
|
@@ -110,8 +110,22 @@ module Rubik
|
|
|
110
110
|
|
|
111
111
|
if path.empty?
|
|
112
112
|
all = mgr.all_diagnostic_snapshots
|
|
113
|
-
total_issues = all.values.sum { |snapshot| snapshot[:diagnostics].size }
|
|
114
113
|
pending = all.values.count { |snapshot| snapshot[:state] == :pending }
|
|
114
|
+
# Pull-capable servers (diagnosticProvider) never push
|
|
115
|
+
# publishDiagnostics; pending-heavy workspaces trigger a bounded
|
|
116
|
+
# pull refresh (issue #583) instead of reporting "pending" forever.
|
|
117
|
+
if pending.positive? && mgr.respond_to?(:refresh_pending_diagnostic_snapshots)
|
|
118
|
+
mgr.refresh_pending_diagnostic_snapshots
|
|
119
|
+
deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + diagnostic_refresh_timeout
|
|
120
|
+
loop do
|
|
121
|
+
all = mgr.all_diagnostic_snapshots
|
|
122
|
+
pending = all.values.count { |snapshot| snapshot[:state] == :pending }
|
|
123
|
+
break if pending.zero? || Process.clock_gettime(Process::CLOCK_MONOTONIC) >= deadline
|
|
124
|
+
|
|
125
|
+
sleep 0.05
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
total_issues = all.values.sum { |snapshot| snapshot[:diagnostics].size }
|
|
115
129
|
unversioned = all.values.count { |snapshot| snapshot[:state] == :unversioned }
|
|
116
130
|
if total_issues.zero?
|
|
117
131
|
if pending.positive?
|
|
@@ -145,7 +159,7 @@ module Rubik
|
|
|
145
159
|
end
|
|
146
160
|
else
|
|
147
161
|
snapshot = if mgr.respond_to?(:wait_for_diagnostics)
|
|
148
|
-
mgr.wait_for_diagnostics(path, timeout:
|
|
162
|
+
mgr.wait_for_diagnostics(path, timeout: diagnostic_refresh_timeout)
|
|
149
163
|
else
|
|
150
164
|
mgr.diagnostics_snapshot_for(path)
|
|
151
165
|
end
|
|
@@ -176,6 +190,18 @@ module Rubik
|
|
|
176
190
|
end
|
|
177
191
|
end
|
|
178
192
|
end
|
|
193
|
+
|
|
194
|
+
private
|
|
195
|
+
|
|
196
|
+
# Bounded wait after workspace-wide diagnostic pulls (issue #583);
|
|
197
|
+
# reuses lsp.feedback_timeout (config/defaults.rb) so the tool never
|
|
198
|
+
# hangs on a wedged server.
|
|
199
|
+
def diagnostic_refresh_timeout
|
|
200
|
+
timeout = effective_lsp_manager&.config&.fetch("lsp.feedback_timeout", nil)
|
|
201
|
+
timeout.is_a?(Numeric) && timeout.positive? ? timeout.to_f : 0.5
|
|
202
|
+
rescue StandardError
|
|
203
|
+
0.5
|
|
204
|
+
end
|
|
179
205
|
end
|
|
180
206
|
|
|
181
207
|
class LSPHoverTool < BaseLSPTool
|
|
@@ -24,6 +24,10 @@ module Rubik
|
|
|
24
24
|
properties: {
|
|
25
25
|
recipient: { type: "string", description: "The recipient subagent conversation ID (e.g. 'subagent-1')" },
|
|
26
26
|
message: { type: "string", description: "The message content to deliver" },
|
|
27
|
+
in_reply_to: { type: "string",
|
|
28
|
+
description: "Question id this message answers — REQUIRED when replying to a subagent " \
|
|
29
|
+
"ask_question notification (echo the question_id from the notification); " \
|
|
30
|
+
"omit for ordinary steering" },
|
|
27
31
|
steps: { type: "integer", description: "Optional additional step budget to grant alongside message" }
|
|
28
32
|
},
|
|
29
33
|
required: ["recipient", "message"]
|
|
@@ -63,11 +67,12 @@ module Rubik
|
|
|
63
67
|
return ToolOutput.error("Missing required parameter 'message'.") if msg.empty?
|
|
64
68
|
|
|
65
69
|
steps = args["steps"] || args[:steps]
|
|
70
|
+
in_reply_to = args["in_reply_to"] || args[:in_reply_to]
|
|
66
71
|
sender = subagent_sender_id
|
|
67
72
|
delivered = if sender
|
|
68
|
-
sup.send_message(recipient, msg, additional_steps: steps, _sender_id: sender)
|
|
73
|
+
sup.send_message(recipient, msg, additional_steps: steps, _sender_id: sender, in_reply_to: in_reply_to)
|
|
69
74
|
else
|
|
70
|
-
sup.send_message(recipient, msg, additional_steps: steps)
|
|
75
|
+
sup.send_message(recipient, msg, additional_steps: steps, in_reply_to: in_reply_to)
|
|
71
76
|
end
|
|
72
77
|
return delivery_text(recipient) if delivered == true
|
|
73
78
|
return queued_text(recipient, steps) if delivered == :queued
|
|
@@ -247,7 +247,10 @@ module Rubik
|
|
|
247
247
|
end
|
|
248
248
|
|
|
249
249
|
def kill_child(pid)
|
|
250
|
-
|
|
250
|
+
# kill_tree (not a bare KILL): handler code under verification may
|
|
251
|
+
# have spawned subprocesses that a direct-child-only kill would
|
|
252
|
+
# orphan (issue #597).
|
|
253
|
+
Rubik::Platform.kill_tree(pid)
|
|
251
254
|
Process.wait(pid)
|
|
252
255
|
rescue StandardError
|
|
253
256
|
nil
|
data/lib/rubik/ui/dialog.rb
CHANGED
|
@@ -83,9 +83,13 @@ module Rubik
|
|
|
83
83
|
def render_card(question, multi: false)
|
|
84
84
|
return unless @shell&.output
|
|
85
85
|
|
|
86
|
+
# The question is model-authored; strip CSI/OSC escapes before they
|
|
87
|
+
# are painted (issue #592) — Frame.draw strips only for width
|
|
88
|
+
# measurement, so raw sequences would reach the terminal.
|
|
89
|
+
safe_question = Capability.strip_ansi(question.to_s)
|
|
86
90
|
subtitle = multi ? "Multi-Select (Space: Select/Deselect · Enter: Confirm)" : "Single-Select (Arrow keys: Navigate · Enter: Confirm)"
|
|
87
91
|
card = Frame.draw(
|
|
88
|
-
[@theme.paint(
|
|
92
|
+
[@theme.paint(safe_question, :bold), @theme.paint(subtitle, :dim)],
|
|
89
93
|
theme: @theme,
|
|
90
94
|
title: @theme.paint("#{@theme.glyph(:action)} AGENT QUESTION", :accent)
|
|
91
95
|
)
|
data/lib/rubik/ui/renderer.rb
CHANGED
|
@@ -105,7 +105,10 @@ module Rubik
|
|
|
105
105
|
if level >= Rubik::REPL::StepFormatter::LEVEL_VERBOSE
|
|
106
106
|
"#{header} #{@theme.paint(Rubik::Platform.safe_json_generate(args), :dim)}"
|
|
107
107
|
else
|
|
108
|
-
|
|
108
|
+
# Tool args are model-controlled; strip CSI/OSC escapes the same way
|
|
109
|
+
# the sibling render paths do (issue #592) so prompt-injected
|
|
110
|
+
# sequences cannot reach the raw terminal.
|
|
111
|
+
summary = pretty_storage_arg(Rubik::UI::Capability.strip_ansi(@legacy.primary_arg_value(args).to_s))
|
|
109
112
|
summary.empty? ? header : "#{header} #{theme_dim_dash(summary)}"
|
|
110
113
|
end
|
|
111
114
|
end
|
data/lib/rubik/version.rb
CHANGED