rubik 0.9.1 → 0.10.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 +143 -1
- data/lib/rubik/adapter/base.rb +2 -1
- data/lib/rubik/adapter/process.rb +28 -67
- data/lib/rubik/benchmark/vakanuvis_adoption.rb +10 -3
- data/lib/rubik/buffer/apply_contract.rb +3 -3
- data/lib/rubik/buffer/apply_transaction.rb +165 -0
- data/lib/rubik/buffer/manager.rb +26 -120
- data/lib/rubik/config/deep_ops.rb +4 -1
- data/lib/rubik/config/defaults.rb +6 -3
- data/lib/rubik/config/schema.rb +8 -0
- data/lib/rubik/config/secret_policy.rb +197 -0
- data/lib/rubik/config.rb +11 -0
- data/lib/rubik/diagnostics/collector.rb +0 -9
- data/lib/rubik/errors.rb +15 -0
- data/lib/rubik/event_bus.rb +2 -1
- data/lib/rubik/kernel/dispatcher.rb +12 -7
- data/lib/rubik/kernel/unit.rb +4 -1
- data/lib/rubik/llm/registry.rb +12 -9
- data/lib/rubik/llm/router.rb +2 -5
- data/lib/rubik/log.rb +21 -0
- data/lib/rubik/lsp/client.rb +77 -273
- data/lib/rubik/lsp/manager.rb +14 -10
- data/lib/rubik/lsp/transport.rb +365 -0
- data/lib/rubik/mcp/boot_lifecycle.rb +6 -2
- data/lib/rubik/mcp/boot_run.rb +190 -0
- data/lib/rubik/mcp/manager.rb +40 -163
- data/lib/rubik/mcp/transport/stdio.rb +4 -1
- data/lib/rubik/orchestrator/auto_apply.rb +4 -3
- data/lib/rubik/orchestrator/continuation_manager.rb +3 -22
- data/lib/rubik/orchestrator/goal_session.rb +53 -39
- data/lib/rubik/orchestrator/loop.rb +28 -47
- data/lib/rubik/orchestrator/maestro_gate.rb +5 -7
- data/lib/rubik/orchestrator/provider_recovery.rb +4 -2
- data/lib/rubik/orchestrator/provider_resolver.rb +4 -2
- data/lib/rubik/orchestrator/resume_window.rb +96 -0
- data/lib/rubik/orchestrator/shell_deps.rb +16 -0
- data/lib/rubik/orchestrator/stream_manager.rb +2 -1
- data/lib/rubik/orchestrator/subagent/deferred_spec.rb +4 -1
- data/lib/rubik/orchestrator/subagent/instance.rb +7 -12
- data/lib/rubik/orchestrator/subagent/lifecycle.rb +3 -1
- data/lib/rubik/orchestrator/subagent/questioner.rb +3 -1
- data/lib/rubik/orchestrator/subagent/reaper.rb +3 -5
- data/lib/rubik/orchestrator/subagent/resilience.rb +4 -2
- data/lib/rubik/orchestrator/subagent/result_archive.rb +0 -4
- data/lib/rubik/orchestrator/subagent/run_cycle.rb +2 -7
- data/lib/rubik/orchestrator/subagent/spawn_transaction.rb +11 -2
- data/lib/rubik/orchestrator/subagent/step_runner.rb +10 -2
- data/lib/rubik/orchestrator/subagent/type_definition.rb +0 -4
- data/lib/rubik/orchestrator/tool_timeout.rb +121 -1
- data/lib/rubik/platform/io_drain.rb +2 -1
- data/lib/rubik/platform/process.rb +144 -54
- data/lib/rubik/platform.rb +2 -1
- data/lib/rubik/plugin/manager.rb +2 -1
- data/lib/rubik/repl/commands/agent_context.rb +8 -7
- data/lib/rubik/repl/commands/agent_execution.rb +13 -32
- data/lib/rubik/repl/commands/agent_models.rb +4 -3
- data/lib/rubik/repl/commands/agent_providers.rb +43 -2
- data/lib/rubik/repl/commands/base.rb +47 -2
- data/lib/rubik/repl/commands/buffer.rb +5 -4
- data/lib/rubik/repl/commands/lsp.rb +2 -1
- data/lib/rubik/repl/commands/pruner.rb +2 -1
- data/lib/rubik/repl/commands/secrets.rb +151 -0
- data/lib/rubik/repl/commands/workspace.rb +60 -150
- data/lib/rubik/repl/commands/workspace_approval.rb +209 -0
- data/lib/rubik/repl/config_wiring.rb +3 -3
- data/lib/rubik/repl/hooks.rb +2 -1
- data/lib/rubik/repl/input_execution.rb +158 -76
- data/lib/rubik/repl/input_loop.rb +2 -1
- data/lib/rubik/repl/lifecycle.rb +59 -209
- data/lib/rubik/repl/notice_router.rb +319 -0
- data/lib/rubik/repl/paste_support.rb +3 -1
- data/lib/rubik/repl/presentation.rb +5 -3
- data/lib/rubik/repl/pruner/gate.rb +3 -1
- data/lib/rubik/repl/pruner/harness.rb +2 -1
- data/lib/rubik/repl/shell.rb +4 -3
- data/lib/rubik/repl/turn_recorder.rb +6 -5
- data/lib/rubik/runtime/discovery.rb +3 -2
- data/lib/rubik/runtime/loop_service.rb +4 -3
- data/lib/rubik/runtime/manifest_store.rb +9 -1
- data/lib/rubik/runtime/overlay_guard.rb +127 -0
- data/lib/rubik/runtime/overlay_storage.rb +92 -146
- data/lib/rubik/runtime/task_manager.rb +64 -25
- data/lib/rubik/sandbox/driver/docker.rb +5 -1
- data/lib/rubik/sandbox/runner.rb +16 -15
- data/lib/rubik/security/command_gate.rb +117 -93
- data/lib/rubik/security/guard.rb +6 -2
- data/lib/rubik/security/secret_store.rb +463 -0
- data/lib/rubik/security/synthesis_gate.rb +8 -11
- data/lib/rubik/session/manager.rb +7 -1
- data/lib/rubik/skills/manager.rb +2 -3
- data/lib/rubik/storage/search.rb +49 -0
- data/lib/rubik/storage/store.rb +13 -20
- data/lib/rubik/storage/vakanuvis/harness.rb +2 -3
- data/lib/rubik/tools/base.rb +22 -0
- data/lib/rubik/tools/builtins/files.rb +3 -15
- data/lib/rubik/tools/builtins/grep.rb +1 -6
- data/lib/rubik/tools/builtins/lifecycle.rb +6 -5
- data/lib/rubik/tools/lifecycle_rollbacks.rb +14 -1
- data/lib/rubik/tools/truncator.rb +48 -36
- data/lib/rubik/ui/banner.rb +4 -3
- data/lib/rubik/ui/spinner.rb +3 -1
- data/lib/rubik/ui/statusline.rb +6 -5
- data/lib/rubik/version.rb +1 -1
- data/lib/rubik.rb +1 -2
- metadata +13 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "../tools/catalog"
|
|
4
4
|
require_relative "tool_history"
|
|
5
|
+
require_relative "../storage/layout"
|
|
5
6
|
|
|
6
7
|
module Rubik
|
|
7
8
|
module Orchestrator
|
|
@@ -29,14 +30,11 @@ module Rubik
|
|
|
29
30
|
!["start"].include?((tool_args["action"] || tool_args[:action]).to_s.downcase.strip)
|
|
30
31
|
|
|
31
32
|
# Kapıyı çalışma anında config'den oku (!config set ile operatör
|
|
32
|
-
# aç/kapa mümkün).
|
|
33
|
-
#
|
|
34
|
-
#
|
|
33
|
+
# aç/kapa mümkün). config_get (Storage::Layout) gerçek Config'in
|
|
34
|
+
# dotted fetch'ini ve düz Hash'in nested (dig) şeklini tek evde
|
|
35
|
+
# çözer.
|
|
35
36
|
cfg = @deps.shell&.config
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
raw = cfg.fetch("subagents.maestro_gate", nil)
|
|
39
|
-
raw = cfg.dig("subagents", "maestro_gate") if raw.nil? && cfg.respond_to?(:dig)
|
|
37
|
+
raw = Rubik::Storage::Layout.config_get(cfg, "subagents.maestro_gate", nil)
|
|
40
38
|
raw != false
|
|
41
39
|
end
|
|
42
40
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../storage/layout"
|
|
4
|
+
|
|
3
5
|
module Rubik
|
|
4
6
|
module Orchestrator
|
|
5
7
|
# Deep module (Candidate 03): the ONE home for provider-call recovery
|
|
@@ -70,14 +72,14 @@ module Rubik
|
|
|
70
72
|
# compaction call site: nil config, fetch-less objects, and null YAML
|
|
71
73
|
# sections all collapse to {}. One spelling replaces five.
|
|
72
74
|
def compaction_config(config)
|
|
73
|
-
cfg =
|
|
75
|
+
cfg = Rubik::Storage::Layout.config_get(config, COMPACTION_CONFIG_KEY, {})
|
|
74
76
|
cfg.is_a?(Hash) ? cfg : {}
|
|
75
77
|
end
|
|
76
78
|
|
|
77
79
|
# ── implementation details (not interface) ────────────────────────
|
|
78
80
|
|
|
79
81
|
def auto_recover?(config)
|
|
80
|
-
|
|
82
|
+
Rubik::Storage::Layout.config_get(config, AUTO_RECOVER_KEY, true)
|
|
81
83
|
end
|
|
82
84
|
|
|
83
85
|
def overflow_error?(err)
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../storage/layout"
|
|
4
|
+
|
|
3
5
|
module Rubik
|
|
4
6
|
module Orchestrator
|
|
5
7
|
# Provider-scoped configuration resolution for the orchestrator loop
|
|
@@ -50,7 +52,7 @@ module Rubik
|
|
|
50
52
|
def llm_config(key, default)
|
|
51
53
|
prov_key = registry_key
|
|
52
54
|
if prov_key.is_a?(String) && !prov_key.empty? && @config.respond_to?(:fetch)
|
|
53
|
-
val = @config
|
|
55
|
+
val = Rubik::Storage::Layout.config_get(@config, "providers.#{prov_key}.#{key}", nil)
|
|
54
56
|
return val unless val.nil?
|
|
55
57
|
end
|
|
56
58
|
|
|
@@ -60,7 +62,7 @@ module Rubik
|
|
|
60
62
|
# KeyError instead of falling through.
|
|
61
63
|
return default unless @config.respond_to?(:fetch)
|
|
62
64
|
|
|
63
|
-
@config
|
|
65
|
+
Rubik::Storage::Layout.config_get(@config, "llm.#{key}", default)
|
|
64
66
|
rescue StandardError
|
|
65
67
|
default
|
|
66
68
|
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../prompt"
|
|
4
|
+
require_relative "shell_deps"
|
|
5
|
+
|
|
6
|
+
module Rubik
|
|
7
|
+
module Orchestrator
|
|
8
|
+
# Loop-side resume window (issue #475, the Loop mirror of GoalSession's
|
|
9
|
+
# resume drive from #459). One collaborator owns the three concerns the
|
|
10
|
+
# resume path used to scatter across the run loop:
|
|
11
|
+
#
|
|
12
|
+
# 1. ctx.extend lifecycle — the §6 discipline: an in-process resume
|
|
13
|
+
# disposes the (already run()-disposed) old per-run sub-context
|
|
14
|
+
# BEFORE extending a fresh one, so repeated suspend/resume cycles do
|
|
15
|
+
# not leak dead children; the ensure-side close disposes exactly once.
|
|
16
|
+
# 2. Cross-process history prefix construction — the Σ-only window
|
|
17
|
+
# [system prompt] → [task] → [Σ row], shaped so the first resumed
|
|
18
|
+
# step's ledger refresh repositions (not duplicates) the Σ row.
|
|
19
|
+
# 3. goal_resumed marker stamping — downtime formatting and the
|
|
20
|
+
# 300-character reason discipline, testable without running a turn.
|
|
21
|
+
#
|
|
22
|
+
# System-prompt rendering and state fingerprinting stay on Loop (shared
|
|
23
|
+
# with run()'s prompt view, candidate 2 Phase 2); their VALUES are passed
|
|
24
|
+
# in, so this collaborator renders nothing itself.
|
|
25
|
+
class ResumeWindow
|
|
26
|
+
def initialize(deps)
|
|
27
|
+
@deps = ShellDeps.wrap(deps)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# ── ctx.extend lifecycle (§6) ─────────────────────────────────────
|
|
31
|
+
# In-process resume: the suspended run's sub-context is dead already
|
|
32
|
+
# (run()'s ensure disposed it) — dispose again defensively, then
|
|
33
|
+
# extend a fresh child for the resumed window.
|
|
34
|
+
def reopen_context!
|
|
35
|
+
@deps.reopen_run_context!
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Cross-process resume: a fresh Loop has no prior sub-context — just
|
|
39
|
+
# extend. Disposing first would be a no-op on nil, but the distinct
|
|
40
|
+
# entry point keeps the two resume paths' invariants explicit.
|
|
41
|
+
def open_context!
|
|
42
|
+
@deps.open_run_context!
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# ensure-side dispose of the window's sub-context.
|
|
46
|
+
def close_context!
|
|
47
|
+
@deps.dispose_run_context!
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# ── cross-process history prefix ──────────────────────────────────
|
|
51
|
+
# Builds [system-prompt row] → [task row] → [Σ row] on the loop's
|
|
52
|
+
# history. The system prompt CONTENT is supplied by the caller (Loop
|
|
53
|
+
# renders via its shared prompt view); this method owns the ordering
|
|
54
|
+
# and the Σ-row placement contract.
|
|
55
|
+
def build_cross_process_prefix!(goal_text:, ledger:, system_prompt:)
|
|
56
|
+
history << { role: "system", content: system_prompt }
|
|
57
|
+
history << { role: "user", content: Rubik::Prompt::ContextBuilder.format_user_task(goal_text) }
|
|
58
|
+
history << { role: "user", content: ledger.to_xml }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# ── goal_resumed marker ───────────────────────────────────────────
|
|
62
|
+
# Signature row (last link of the cross-process window): role "user"
|
|
63
|
+
# (EmergencyCompactor hard tier does not touch it), single-tag quoting
|
|
64
|
+
# discipline (ledger_row?/drift_row? mold). downtime is human-readable,
|
|
65
|
+
# "unknown" when unknowable. reason obeys the same 300-character
|
|
66
|
+
# discipline as the Σ stamp — 5xx bodies must not bloat history.
|
|
67
|
+
def stamp_resume_marker!(reason:, suspended_at:, attempt:)
|
|
68
|
+
esc = Rubik::Platform.method(:xml_escape)
|
|
69
|
+
history << { role: "user", content: "<goal_resumed downtime=\"#{esc.call(format_downtime(suspended_at))}\" " \
|
|
70
|
+
"reason=\"#{esc.call(reason.to_s.slice(0, 300))}\" attempt=\"#{attempt.to_i}\" " \
|
|
71
|
+
"steps_done=\"#{@deps.step_count}\" />" }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
private
|
|
75
|
+
|
|
76
|
+
def history
|
|
77
|
+
@deps.history
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# seconds → "45s" / "4m 12s" / "1h 03m"; honest "unknown" when the
|
|
81
|
+
# suspend time is unavailable (corrupt cross-process meta). Negative
|
|
82
|
+
# drift (clock skew) clamps to 0.
|
|
83
|
+
def format_downtime(suspended_at)
|
|
84
|
+
return "unknown" unless suspended_at.respond_to?(:to_i) && suspended_at.to_i.positive?
|
|
85
|
+
|
|
86
|
+
secs = [(Time.now - suspended_at).to_i, 0].max
|
|
87
|
+
mm, ss = secs.divmod(60)
|
|
88
|
+
hh, mm = mm.divmod(60)
|
|
89
|
+
return "#{hh}h #{mm.to_s.rjust(2, '0')}m" if hh.positive?
|
|
90
|
+
return "#{mm}m #{ss.to_s.rjust(2, '0')}s" if mm.positive?
|
|
91
|
+
|
|
92
|
+
"#{ss}s"
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -51,6 +51,22 @@ module Rubik
|
|
|
51
51
|
@loop.history = new_history
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
+
# ResumeWindow lifecycle commands (issue #475): Loop owns the
|
|
55
|
+
# @loop_context ivar; named commands instead of ivar reach-through,
|
|
56
|
+
# per the writes-policy note in the class comment.
|
|
57
|
+
def reopen_run_context!
|
|
58
|
+
dispose_run_context!
|
|
59
|
+
open_run_context!
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def open_run_context!
|
|
63
|
+
@loop.loop_context = @loop.runtime_manager&.context&.extend
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def dispose_run_context!
|
|
67
|
+
@loop.loop_context&.dispose
|
|
68
|
+
end
|
|
69
|
+
|
|
54
70
|
def reset_invalid_tools!
|
|
55
71
|
@loop.invalid_tool_count = 0
|
|
56
72
|
end
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "../llm/chunk_assembler"
|
|
4
4
|
require_relative "provider_recovery"
|
|
5
|
+
require_relative "../storage/layout"
|
|
5
6
|
|
|
6
7
|
module Rubik
|
|
7
8
|
module Orchestrator
|
|
@@ -88,7 +89,7 @@ module Rubik
|
|
|
88
89
|
capture_reasoning = if @deps.respond_to?(:safe_config)
|
|
89
90
|
@deps.safe_config("llm.capture_reasoning", true) != false
|
|
90
91
|
elsif @deps.respond_to?(:config) && @deps.config.respond_to?(:fetch)
|
|
91
|
-
@deps.config
|
|
92
|
+
Rubik::Storage::Layout.config_get(@deps.config, "llm.capture_reasoning", true) != false
|
|
92
93
|
else
|
|
93
94
|
true
|
|
94
95
|
end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../../errors"
|
|
3
4
|
require_relative "budget"
|
|
4
5
|
require_relative "notices"
|
|
5
6
|
require_relative "conversation_id"
|
|
@@ -19,7 +20,9 @@ module Rubik
|
|
|
19
20
|
# this spec — nil for explicitly detached work. A cancelled owner makes
|
|
20
21
|
# the claim loops drop the spec before it ever starts.
|
|
21
22
|
class DeferredSpec
|
|
22
|
-
|
|
23
|
+
# Unified taxonomy (issue #448): subclasses Rubik::StateError so a
|
|
24
|
+
# caller can rescue any guarded-transition tripwire with one class.
|
|
25
|
+
class StateError < Rubik::StateError; end
|
|
23
26
|
|
|
24
27
|
# The spec machine's every legal from->to edge (Lifecycle family
|
|
25
28
|
# doctrine: one guarded transition per state machine, fail-loud on
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "monitor"
|
|
4
|
+
require_relative "../../storage/layout"
|
|
4
5
|
require_relative "transcript_formatter"
|
|
5
6
|
require_relative "start_gate"
|
|
6
7
|
require_relative "storage_id"
|
|
@@ -73,21 +74,15 @@ module Rubik
|
|
|
73
74
|
@tool_registry = tool_registry
|
|
74
75
|
@provider = provider
|
|
75
76
|
@buffer_manager = buffer_manager
|
|
76
|
-
max_total_steps =
|
|
77
|
-
|
|
78
|
-
Budget::DEFAULT_MAX_TOTAL_STEPS
|
|
79
|
-
elsif config.respond_to?(:fetch)
|
|
80
|
-
config.fetch("subagents.max_total_steps", Budget::DEFAULT_MAX_TOTAL_STEPS)
|
|
81
|
-
else
|
|
82
|
-
Budget::DEFAULT_MAX_TOTAL_STEPS
|
|
83
|
-
end
|
|
77
|
+
max_total_steps = Rubik::Storage::Layout.config_get(config, "subagents.max_total_steps",
|
|
78
|
+
Budget::DEFAULT_MAX_TOTAL_STEPS)
|
|
84
79
|
@budget = Budget.new(max_steps: max_steps, max_total_steps: max_total_steps)
|
|
85
80
|
@root_dir = root_dir
|
|
86
81
|
@config = config
|
|
87
82
|
@event_bus = event_bus
|
|
88
83
|
@provider_gate = provider_gate
|
|
89
|
-
@context_limit = (context_limit || (@config
|
|
90
|
-
@max_output_tokens = (@config
|
|
84
|
+
@context_limit = (context_limit || Rubik::Storage::Layout.config_get(@config, "context.max_tokens", 32_768) || 32_768).to_i
|
|
85
|
+
@max_output_tokens = Rubik::Storage::Layout.config_get(@config, "llm.default_max_output_tokens", 4_096).to_i
|
|
91
86
|
|
|
92
87
|
@state = :pending
|
|
93
88
|
@history = []
|
|
@@ -258,7 +253,7 @@ module Rubik
|
|
|
258
253
|
end
|
|
259
254
|
|
|
260
255
|
def pause_and_await_budget_expansion!(wait_timeout = nil)
|
|
261
|
-
timeout = wait_timeout || (@config
|
|
256
|
+
timeout = wait_timeout || Rubik::Storage::Layout.config_get(@config, "subagents.budget_wait_timeout", 180) || 180
|
|
262
257
|
payload = nil
|
|
263
258
|
@monitor.synchronize do
|
|
264
259
|
return false unless executing?
|
|
@@ -299,7 +294,7 @@ module Rubik
|
|
|
299
294
|
|
|
300
295
|
def pause_on_error!(error, wait_timeout = nil)
|
|
301
296
|
timeout = wait_timeout ||
|
|
302
|
-
(@config
|
|
297
|
+
Rubik::Storage::Layout.config_get(@config, "subagents.error_wait_timeout", nil) ||
|
|
303
298
|
Resilience::DEFAULT_ERROR_WAIT_TIMEOUT
|
|
304
299
|
payload = nil
|
|
305
300
|
@monitor.synchronize do
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../../errors"
|
|
4
|
+
|
|
3
5
|
module Rubik
|
|
4
6
|
module Orchestrator
|
|
5
7
|
module Subagent
|
|
@@ -12,7 +14,7 @@ module Rubik
|
|
|
12
14
|
# public constants — adding a state means editing THIS file (plus the
|
|
13
15
|
# kernel STATE_MAP, held by contract test).
|
|
14
16
|
module Lifecycle
|
|
15
|
-
class StateError <
|
|
17
|
+
class StateError < Rubik::StateError; end
|
|
16
18
|
|
|
17
19
|
# Every legal from->to edge. A transition not listed here is a bug
|
|
18
20
|
# — fail loud with both endpoints in the message. :disposed is
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../../storage/layout"
|
|
4
|
+
|
|
3
5
|
module Rubik
|
|
4
6
|
module Orchestrator
|
|
5
7
|
module Subagent
|
|
@@ -79,7 +81,7 @@ module Rubik
|
|
|
79
81
|
def question_timeout(override = nil)
|
|
80
82
|
return override.to_f if override&.to_f&.positive?
|
|
81
83
|
|
|
82
|
-
(@config
|
|
84
|
+
Rubik::Storage::Layout.config_get(@config, "subagents.question_timeout", DEFAULT_QUESTION_TIMEOUT) ||
|
|
83
85
|
DEFAULT_QUESTION_TIMEOUT
|
|
84
86
|
end
|
|
85
87
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "../../platform"
|
|
4
|
+
require_relative "../../storage/layout"
|
|
4
5
|
|
|
5
6
|
module Rubik
|
|
6
7
|
module Orchestrator
|
|
@@ -71,15 +72,12 @@ module Rubik
|
|
|
71
72
|
end
|
|
72
73
|
|
|
73
74
|
def reap_grace_seconds
|
|
74
|
-
raw =
|
|
75
|
-
raw = 300 if raw.nil?
|
|
75
|
+
raw = Rubik::Storage::Layout.config_get(@config, "subagents.reap_finished_after", 300)
|
|
76
76
|
raw.to_f <= 0 ? nil : raw.to_f
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
def tombstone_limit
|
|
80
|
-
|
|
81
|
-
raw = 25 if raw.nil?
|
|
82
|
-
raw.to_i
|
|
80
|
+
Rubik::Storage::Layout.config_get(@config, "subagents.tombstone_limit", 25).to_i
|
|
83
81
|
end
|
|
84
82
|
|
|
85
83
|
# FIFO taşma: en eski mezar taşı evict edilir ve cleanup ile
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../../storage/layout"
|
|
4
|
+
|
|
3
5
|
module Rubik
|
|
4
6
|
module Orchestrator
|
|
5
7
|
module Subagent
|
|
@@ -41,10 +43,10 @@ module Rubik
|
|
|
41
43
|
|
|
42
44
|
def retry_transient(config: nil, gate: nil, max_retries: nil, backoff_base: nil, on_retry: nil, &block)
|
|
43
45
|
retries_limit = max_retries ||
|
|
44
|
-
(config
|
|
46
|
+
Rubik::Storage::Layout.config_get(config, "subagents.network_retry_count", nil) ||
|
|
45
47
|
DEFAULT_NETWORK_RETRIES
|
|
46
48
|
base_delay = backoff_base ||
|
|
47
|
-
(config
|
|
49
|
+
Rubik::Storage::Layout.config_get(config, "subagents.network_backoff_base", nil) ||
|
|
48
50
|
DEFAULT_BACKOFF_BASE
|
|
49
51
|
|
|
50
52
|
attempt = 0
|
|
@@ -116,10 +116,6 @@ module Rubik
|
|
|
116
116
|
end
|
|
117
117
|
end
|
|
118
118
|
|
|
119
|
-
def latest_run(storage_id)
|
|
120
|
-
@monitor.synchronize { (@entries[storage_id.to_s] || {}).keys.max }
|
|
121
|
-
end
|
|
122
|
-
|
|
123
119
|
# THE page rendering (tool action + rubik:// read share it, so the two
|
|
124
120
|
# access paths cannot drift). The continuation is the paginated API
|
|
125
121
|
# call — the reference itself always identifies the exact run.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "transcript_formatter"
|
|
4
4
|
require_relative "narration"
|
|
5
|
+
require_relative "../../storage/layout"
|
|
5
6
|
|
|
6
7
|
module Rubik
|
|
7
8
|
module Orchestrator
|
|
@@ -81,13 +82,7 @@ module Rubik
|
|
|
81
82
|
effective = @system_prompt && !@system_prompt.strip.empty? ? "#{base}\n\nCustom Instructions:\n#{@system_prompt}" : base
|
|
82
83
|
|
|
83
84
|
if @type_name == "self"
|
|
84
|
-
shell_pref =
|
|
85
|
-
@config.fetch("sandbox.shell", "auto")
|
|
86
|
-
elsif @config.is_a?(Hash)
|
|
87
|
-
@config["sandbox.shell"] || "auto"
|
|
88
|
-
else
|
|
89
|
-
"auto"
|
|
90
|
-
end
|
|
85
|
+
shell_pref = Rubik::Storage::Layout.config_get(@config, "sandbox.shell", "auto")
|
|
91
86
|
if defined?(Rubik::Sandbox::ShellResolver)
|
|
92
87
|
env_line = Rubik::Sandbox::ShellResolver.environment_line(shell_pref)
|
|
93
88
|
effective = "#{effective}\n\n#{env_line}" if env_line && !env_line.empty?
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../../errors"
|
|
4
|
+
require_relative "../../storage/layout"
|
|
5
|
+
|
|
3
6
|
module Rubik
|
|
4
7
|
module Orchestrator
|
|
5
8
|
module Subagent
|
|
@@ -17,6 +20,12 @@ module Rubik
|
|
|
17
20
|
Rubik::Coeffects::TASK_CANCELLATION
|
|
18
21
|
].freeze
|
|
19
22
|
|
|
23
|
+
# Start-gate release failure (issue #448): the worker start gate
|
|
24
|
+
# could not be released after a deferred activation — the spawn
|
|
25
|
+
# transaction rolls the instance back. Typed under Rubik::Error so
|
|
26
|
+
# callers can distinguish it from ordinary RuntimeError noise.
|
|
27
|
+
class StartGateReleaseError < Rubik::Error; end
|
|
28
|
+
|
|
20
29
|
def spawn(role:, prompt:, type_name: "research", system_prompt: nil,
|
|
21
30
|
parent_id: ConversationId::ROOT_ID, workspace: "inherit", model: "inherit",
|
|
22
31
|
max_steps: nil, provider: nil, depends_on: nil, reserved_id: nil, owner: nil)
|
|
@@ -114,7 +123,7 @@ module Rubik
|
|
|
114
123
|
prov, effective_model = resolve_provider_and_model(model)
|
|
115
124
|
prov = provider if provider
|
|
116
125
|
|
|
117
|
-
context_limit =
|
|
126
|
+
context_limit = Rubik::Storage::Layout.config_get(@config, "context.max_tokens", 32_768)
|
|
118
127
|
effective_steps = (max_steps || @default_max_steps).to_i
|
|
119
128
|
child_config = if @config.is_a?(Rubik::Config)
|
|
120
129
|
@config.extend(
|
|
@@ -141,7 +150,7 @@ module Rubik
|
|
|
141
150
|
def activate_and_release_subagent!(inst:, child_ctx:, owner:, activation_init:)
|
|
142
151
|
activate_instance!(inst, child_ctx: child_ctx, owner_token: owner,
|
|
143
152
|
init_supervisor: activation_init, defer_start: true)
|
|
144
|
-
raise "Subagent worker start gate could not be released." unless inst.release_start!
|
|
153
|
+
raise StartGateReleaseError, "Subagent worker start gate could not be released." unless inst.release_start!
|
|
145
154
|
end
|
|
146
155
|
|
|
147
156
|
def resolve_profile_snapshot(type_name:, role:, system_prompt:)
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "json"
|
|
4
|
+
require_relative "../../errors"
|
|
4
5
|
require_relative "../../prompt"
|
|
5
6
|
require_relative "../../platform"
|
|
6
7
|
require_relative "../../security/redactor"
|
|
7
8
|
require_relative "../../tools/truncator"
|
|
8
9
|
require_relative "../../uris"
|
|
9
10
|
require_relative "../provider_recovery"
|
|
11
|
+
require_relative "../../storage/layout"
|
|
10
12
|
require_relative "../auto_apply"
|
|
11
13
|
require_relative "../tool_call_id"
|
|
12
14
|
require_relative "../tool_history"
|
|
@@ -30,6 +32,12 @@ module Rubik
|
|
|
30
32
|
# spine (agent-turn-executor plan); this module keeps the invocation path, budget
|
|
31
33
|
# mechanics, and the subagent dispatch.
|
|
32
34
|
module StepRunner
|
|
35
|
+
# Provider contract violation (issue #448): the configured provider
|
|
36
|
+
# supports neither #complete nor #chat — a wiring bug, not a
|
|
37
|
+
# transient network condition. Typed under Rubik::Error so callers
|
|
38
|
+
# can distinguish it from ordinary RuntimeError noise.
|
|
39
|
+
class ProviderContractError < Rubik::Error; end
|
|
40
|
+
|
|
33
41
|
include ContextCompaction
|
|
34
42
|
include ToolDispatch
|
|
35
43
|
|
|
@@ -96,7 +104,7 @@ module Rubik
|
|
|
96
104
|
end
|
|
97
105
|
|
|
98
106
|
def auto_pause_on_error?
|
|
99
|
-
|
|
107
|
+
Rubik::Storage::Layout.config_get(@config, "subagents.auto_pause_on_network_error", true) != false
|
|
100
108
|
end
|
|
101
109
|
|
|
102
110
|
def invoke_provider(opts)
|
|
@@ -114,7 +122,7 @@ module Rubik
|
|
|
114
122
|
return @provider.complete(@history, effective_opts) if @provider.respond_to?(:complete)
|
|
115
123
|
return @provider.chat(@history, **effective_opts) if @provider.respond_to?(:chat)
|
|
116
124
|
|
|
117
|
-
raise "Provider #{@provider.class} does not support complete or chat"
|
|
125
|
+
raise ProviderContractError, "Provider #{@provider.class} does not support complete or chat"
|
|
118
126
|
ensure
|
|
119
127
|
@operations.finish(OperationTracker::MODEL)
|
|
120
128
|
end
|