rubik 0.8.0 → 0.9.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 +2 -2
- data/CHANGELOG.md +164 -1
- data/bin/rubik +15 -10
- data/lib/rubik/cli/workspace_trust.rb +1 -0
- data/lib/rubik/concurrency/worker.rb +143 -0
- data/lib/rubik/concurrency.rb +1 -0
- data/lib/rubik/config/deep_ops.rb +17 -0
- data/lib/rubik/config/defaults.rb +0 -1
- data/lib/rubik/config/schema.rb +0 -1
- data/lib/rubik/config.rb +7 -3
- data/lib/rubik/context/repo_context_reader.rb +27 -8
- data/lib/rubik/events.rb +18 -0
- data/lib/rubik/kernel/dispatcher.rb +19 -23
- data/lib/rubik/kernel/init.rb +22 -18
- data/lib/rubik/kernel/unit.rb +4 -3
- data/lib/rubik/orchestrator/auto_apply.rb +2 -0
- data/lib/rubik/orchestrator/budget_manager.rb +18 -2
- data/lib/rubik/orchestrator/goal_ledger/deep_ops.rb +41 -0
- data/lib/rubik/orchestrator/goal_ledger/drift.rb +2 -1
- data/lib/rubik/orchestrator/goal_ledger/ledger.rb +59 -59
- data/lib/rubik/orchestrator/goal_ledger/observation_projection.rb +29 -9
- data/lib/rubik/orchestrator/goal_ledger/patch.rb +10 -17
- data/lib/rubik/orchestrator/goal_ledger/suspend_lifecycle.rb +9 -41
- data/lib/rubik/orchestrator/goal_ledger/validator.rb +6 -20
- data/lib/rubik/orchestrator/goal_ledger/verifier.rb +3 -14
- data/lib/rubik/orchestrator/goal_ledger/xml_render.rb +21 -14
- data/lib/rubik/orchestrator/goal_state.rb +15 -15
- data/lib/rubik/orchestrator/loop.rb +62 -63
- data/lib/rubik/orchestrator/lsp_feedback.rb +7 -1
- data/lib/rubik/orchestrator/subagent/admission_policy.rb +161 -0
- data/lib/rubik/orchestrator/subagent/builtin_types.rb +3 -2
- data/lib/rubik/orchestrator/subagent/deferred_spec.rb +51 -2
- data/lib/rubik/orchestrator/subagent/dependency.rb +20 -20
- data/lib/rubik/orchestrator/subagent/execution_reads.rb +1 -1
- data/lib/rubik/orchestrator/subagent/journal.rb +3 -9
- data/lib/rubik/orchestrator/subagent/lifecycle.rb +10 -1
- data/lib/rubik/orchestrator/subagent/notices.rb +5 -4
- data/lib/rubik/orchestrator/subagent/paging.rb +49 -0
- data/lib/rubik/orchestrator/subagent/profile_contract.rb +4 -10
- data/lib/rubik/orchestrator/subagent/reaper.rb +1 -3
- data/lib/rubik/orchestrator/subagent/redeploy_transaction.rb +99 -0
- data/lib/rubik/orchestrator/subagent/result_archive.rb +12 -22
- data/lib/rubik/orchestrator/subagent/reuse.rb +37 -31
- data/lib/rubik/orchestrator/subagent/run_cycle.rb +22 -1
- data/lib/rubik/orchestrator/subagent/scoped_registry.rb +34 -2
- data/lib/rubik/orchestrator/subagent/spawn_transaction.rb +1 -1
- data/lib/rubik/orchestrator/subagent/supervisor.rb +6 -2
- data/lib/rubik/orchestrator/subagent/task_ownership.rb +2 -2
- data/lib/rubik/orchestrator/subagent/transcript_reader.rb +14 -13
- data/lib/rubik/orchestrator/subagent/type_registry.rb +19 -1
- data/lib/rubik/orchestrator/turn_executor/subagent_channel.rb +6 -1
- data/lib/rubik/orchestrator/turn_executor/user_channel.rb +6 -1
- data/lib/rubik/orchestrator/turn_executor.rb +2 -1
- data/lib/rubik/platform/path.rb +0 -1
- data/lib/rubik/prompt/context_builder.rb +24 -18
- data/lib/rubik/prompt/context_compactor.rb +31 -8
- data/lib/rubik/prompt/conversation_rows.rb +33 -0
- data/lib/rubik/prompt/doctrine.rb +4 -2
- data/lib/rubik/prompt/emergency_compactor.rb +5 -4
- data/lib/rubik/repl/commands/agent_execution.rb +13 -2
- data/lib/rubik/repl/commands/buffer.rb +4 -0
- data/lib/rubik/repl/commands/mcp.rb +5 -0
- data/lib/rubik/repl/commands/subagents.rb +7 -6
- data/lib/rubik/repl/commands/workspace.rb +22 -2
- data/lib/rubik/repl/config_wiring.rb +24 -7
- data/lib/rubik/repl/input_execution.rb +1 -1
- data/lib/rubik/repl/lifecycle.rb +3 -2
- data/lib/rubik/repl/pruner/harness.rb +52 -67
- data/lib/rubik/repl/pruner/rules.rb +3 -1
- data/lib/rubik/repl/pruner/service.rb +4 -9
- data/lib/rubik/repl/service_catalog.rb +1 -1
- data/lib/rubik/repl/synthesized_command_context.rb +3 -0
- data/lib/rubik/repl/turn_recorder.rb +5 -4
- data/lib/rubik/repl.rb +1 -0
- data/lib/rubik/runtime/context.rb +11 -1
- data/lib/rubik/runtime/discovery.rb +55 -0
- data/lib/rubik/runtime/fiber.rb +17 -5
- data/lib/rubik/runtime/manager.rb +19 -12
- data/lib/rubik/runtime/overlay_storage.rb +54 -23
- data/lib/rubik/runtime/repair_probe.rb +20 -2
- data/lib/rubik/runtime/sealed_coeffects.rb +58 -0
- data/lib/rubik/runtime/synthesized_command_context.rb +80 -0
- data/lib/rubik/runtime/synthesized_tool_context.rb +123 -0
- data/lib/rubik/runtime.rb +2 -0
- data/lib/rubik/security/classifier/classifier.rb +16 -8
- data/lib/rubik/security/classifier/commands/biome.yaml +49 -0
- data/lib/rubik/security/classifier/commands/bun.yaml +91 -0
- data/lib/rubik/security/classifier/commands/bundle.yaml +107 -0
- data/lib/rubik/security/classifier/commands/clang-format.yaml +21 -0
- data/lib/rubik/security/classifier/commands/clang.yaml +37 -0
- data/lib/rubik/security/classifier/commands/cmake.yaml +37 -0
- data/lib/rubik/security/classifier/commands/ctest.yaml +30 -0
- data/lib/rubik/security/classifier/commands/gcc.yaml +36 -0
- data/lib/rubik/security/classifier/commands/gem.yaml +104 -0
- data/lib/rubik/security/classifier/commands/gofmt.yaml +15 -0
- data/lib/rubik/security/classifier/commands/pnpm.yaml +8 -8
- data/lib/rubik/security/classifier/commands/python.yaml +18 -1
- data/lib/rubik/security/classifier/commands/python3.yaml +18 -1
- data/lib/rubik/security/classifier/commands/rake.yaml +60 -0
- data/lib/rubik/security/classifier/commands/rspec.yaml +42 -0
- data/lib/rubik/security/classifier/commands/rubocop.yaml +38 -0
- data/lib/rubik/security/classifier/commands/ruby.yaml +25 -0
- data/lib/rubik/security/classifier/commands/rustc.yaml +34 -0
- data/lib/rubik/security/classifier/commands/zig.yaml +77 -0
- data/lib/rubik/security/classifier/database.rb +12 -1
- data/lib/rubik/security/classifier/matcher.rb +17 -2
- data/lib/rubik/security/classifier/models.rb +3 -2
- data/lib/rubik/security/classifier.rb +5 -0
- data/lib/rubik/security/guard.rb +133 -39
- data/lib/rubik/storage/layout.rb +14 -3
- data/lib/rubik/storage/vakanuvis/harness.rb +49 -89
- data/lib/rubik/tools/base.rb +55 -7
- data/lib/rubik/tools/builtins/dmesg.rb +1 -1
- data/lib/rubik/tools/builtins/exec.rb +1 -2
- data/lib/rubik/tools/builtins/files.rb +3 -1
- data/lib/rubik/tools/builtins/goal_ledger.rb +10 -10
- data/lib/rubik/tools/builtins/grep.rb +2 -2
- data/lib/rubik/tools/builtins/interactive.rb +1 -3
- data/lib/rubik/tools/builtins/lifecycle.rb +1 -1
- data/lib/rubik/tools/builtins/lsp.rb +2 -2
- data/lib/rubik/tools/builtins/pruner.rb +1 -1
- data/lib/rubik/tools/builtins/runtime.rb +1 -1
- data/lib/rubik/tools/builtins/send_message.rb +14 -3
- data/lib/rubik/tools/builtins/skill.rb +1 -1
- data/lib/rubik/tools/builtins/storage.rb +1 -1
- data/lib/rubik/tools/builtins/subagent.rb +2 -1
- data/lib/rubik/tools/builtins/subagent_lifecycle.rb +5 -3
- data/lib/rubik/tools/builtins/symbols.rb +4 -4
- data/lib/rubik/tools/builtins/synthesis.rb +121 -64
- data/lib/rubik/tools/builtins/task.rb +1 -1
- data/lib/rubik/tools/builtins/unsynthesize.rb +38 -0
- data/lib/rubik/tools/builtins/vakanuvis.rb +1 -1
- data/lib/rubik/tools/catalog.rb +3 -0
- data/lib/rubik/tools/declaration.rb +6 -2
- data/lib/rubik/tools/preflight_runner.rb +107 -14
- data/lib/rubik/tools/registry.rb +2 -0
- data/lib/rubik/tools/uri_resolver.rb +3 -1
- data/lib/rubik/uris.rb +5 -1
- data/lib/rubik/version.rb +1 -1
- data/lib/rubik.rb +1 -0
- metadata +27 -1
|
@@ -1,31 +1,39 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "monitor"
|
|
4
|
+
require_relative "../../concurrency"
|
|
5
|
+
require_relative "../../events"
|
|
4
6
|
|
|
5
7
|
module Rubik
|
|
6
8
|
module Storage
|
|
7
9
|
module Vakanuvis
|
|
8
|
-
# Düzlem 1 — Deterministik Çekirdek: tek worker thread + sınırlı FIFO
|
|
9
|
-
#
|
|
10
|
-
#
|
|
10
|
+
# Düzlem 1 — Deterministik Çekirdek: tek worker thread + sınırlı FIFO
|
|
11
|
+
# kuyruk (Concurrency::Worker iskeleti: atomik kabul, idempotent
|
|
12
|
+
# kapanış, busy sayımı ve son-çare ağı iskelettedir). Olay kapıları
|
|
13
|
+
# mevcut bus abonelikleridir (subagent tamamlanma + goal bitişi — K3);
|
|
14
|
+
# NE ZAMAN, NEREYE, NASIL yazılacağı burada kural tabanlıdır.
|
|
11
15
|
# Sessizlik sözleşmesi (§4.3): WAKE_KINDS dışında kalır, notice yaymaz —
|
|
12
16
|
# sadece dmesg/stderr. Ömür: ctx dispose'u LIFO ile kapatır (worker kill + abonelik geri alımı).
|
|
13
17
|
class Harness
|
|
14
|
-
|
|
18
|
+
include Concurrency::Worker
|
|
19
|
+
|
|
20
|
+
# STOP işareti iskeletin tek ev sahibinde; sabit adı kuyruk gözetimi
|
|
21
|
+
# ve test ikizleri için yaşar.
|
|
22
|
+
STOP = Concurrency::Worker::STOP
|
|
15
23
|
MAX_QUEUE = 200
|
|
16
24
|
# v2 §4-V4: damıtıcı kaynak disiplini — yalnız TAMAMLANMIŞ transcript'ler,
|
|
17
25
|
# damıtıcının kendisi Hariç (özyineleme kirliliği: canlı depoda transcript satırları 'vakanuvis' etiketi taşır).
|
|
18
26
|
SOURCE_TRANSCRIPT_LIMIT = 8
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
SUBAGENT_EVENT =
|
|
24
|
-
GOAL_EVENT =
|
|
25
|
-
TURN_EVENT =
|
|
26
|
-
# Askı kroniği
|
|
27
|
-
#
|
|
28
|
-
SUSPEND_EVENT =
|
|
27
|
+
# Olay adları Rubik::Events yaprağından okunur: yaprak sıfır
|
|
28
|
+
# require'lıdır (uris.rb gramer yaprağı öncülü) — depolama
|
|
29
|
+
# katmanı orchestrator mantığına bağımlı olmadan tek söz
|
|
30
|
+
# dağarcığına bağlanır; izolasyon doktrininin harfi bozulmaz.
|
|
31
|
+
SUBAGENT_EVENT = Rubik::Events::SUBAGENT_COMPLETED
|
|
32
|
+
GOAL_EVENT = Rubik::Events::GOAL_FINISHED
|
|
33
|
+
TURN_EVENT = Rubik::Events::TURN_FINISHED
|
|
34
|
+
# Askı kroniği: abonelik :goal akışına yazar; worker
|
|
35
|
+
# status=="suspended" ile ayırt eder.
|
|
36
|
+
SUSPEND_EVENT = Rubik::Events::GOAL_SUSPENDED
|
|
29
37
|
|
|
30
38
|
attr_reader :store, :config, :supervisor, :dmesg, :session_slug, :gate
|
|
31
39
|
|
|
@@ -74,61 +82,19 @@ module Rubik
|
|
|
74
82
|
self
|
|
75
83
|
end
|
|
76
84
|
|
|
77
|
-
def stopped? = @monitor.synchronize { @stopped }
|
|
78
|
-
|
|
79
|
-
# Dispose yolu: FIFO'daki her şey (STOP dahil öncesindeki olaylar) işlenir,
|
|
80
|
-
# sonra thread sonlanır. Kalan olay yarımda kalmaz; thread 2 saniyede durmazsa
|
|
81
|
-
# (yavaş bir flush/spawn içinde) kill gelir ve işlenemeyen olay sayısı dmesg'e düşer — sessiz kayıp yok.
|
|
82
|
-
def shutdown
|
|
83
|
-
@monitor.synchronize do
|
|
84
|
-
return if @stopped
|
|
85
|
-
|
|
86
|
-
@stopped = true
|
|
87
|
-
@busy += 1 # STOP işaretinin de işleniş sayılır
|
|
88
|
-
@queue.push(STOP)
|
|
89
|
-
end
|
|
90
|
-
begin
|
|
91
|
-
auto_digest_touched!(spawn: false)
|
|
92
|
-
rescue StandardError => e
|
|
93
|
-
Vakanuvis.log_via(@dmesg, :warn, "shutdown auto-digest failed (#{e.class}: #{e.message}) — worker teardown continues")
|
|
94
|
-
end
|
|
95
|
-
@worker&.join(2)
|
|
96
|
-
if @worker&.alive?
|
|
97
|
-
Vakanuvis.log_via(@dmesg, :warn, "worker did not stop in 2s — killing with #{queue_size} event(s) unprocessed")
|
|
98
|
-
@worker.kill
|
|
99
|
-
end
|
|
100
|
-
@worker = nil
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def wait_idle(timeout: 2.0)
|
|
104
|
-
deadline = Time.now + timeout
|
|
105
|
-
sleep 0.01 while busy? && Time.now < deadline
|
|
106
|
-
!busy?
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
# Kuyrukta + uçuştaki olay sayısı (push'ta artar, işlenince/düşürülünce azalır) — pop ile işaretleme arasındaki yarış penceresini kapatır.
|
|
110
|
-
def busy? = @monitor.synchronize { @busy.positive? }
|
|
111
|
-
|
|
112
85
|
# ---- olay giriş kapıları (kworker thread'inde çağrılır) -----------
|
|
113
86
|
|
|
87
|
+
# Atomik kabul (stopped-kontrol + push tek kritik bölümde) iskelette:
|
|
88
|
+
# kapanış yarışındaki olay ya STOP'tan önce düşer ve işlenir ya da
|
|
89
|
+
# reddedilir — arada kalan işleyeneksiz olay kalamaz.
|
|
114
90
|
def enqueue_event(kind, payload)
|
|
115
91
|
unless payload.is_a?(Hash)
|
|
116
92
|
Vakanuvis.log_via(@dmesg, :warn, "discarded non-hash #{kind} event (#{payload.class})")
|
|
117
93
|
return false
|
|
118
94
|
end
|
|
119
|
-
|
|
120
|
-
@monitor.synchronize do
|
|
121
|
-
return false if @stopped
|
|
122
|
-
|
|
123
|
-
drop_oldest! if @queue.size >= @max_queue
|
|
124
|
-
@busy += 1
|
|
125
|
-
@queue.push([kind, payload])
|
|
126
|
-
true
|
|
127
|
-
end
|
|
95
|
+
super
|
|
128
96
|
end
|
|
129
97
|
|
|
130
|
-
def queue_size = @queue.size
|
|
131
|
-
|
|
132
98
|
# ---- talep düzlemi (maestro aracı buraya delege eder; K7) ---------
|
|
133
99
|
|
|
134
100
|
# Deterministik geri çağırma Recall düzleminde (recall.rb); burada
|
|
@@ -215,37 +181,31 @@ module Rubik
|
|
|
215
181
|
@event_bus.subscribe(TURN_EVENT, context: @context) { |p| enqueue_event(:turn, p) } if @root_turns
|
|
216
182
|
end
|
|
217
183
|
|
|
218
|
-
#
|
|
219
|
-
|
|
220
|
-
def
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
end
|
|
231
|
-
rescue ThreadError
|
|
232
|
-
nil
|
|
184
|
+
# ---- Concurrency::Worker iskelet kancaları --------------------------
|
|
185
|
+
|
|
186
|
+
def worker_max_queue = @max_queue
|
|
187
|
+
|
|
188
|
+
def worker_warn(message) = Vakanuvis.log_via(@dmesg, :warn, message)
|
|
189
|
+
|
|
190
|
+
# Kapanış yolundaki son damıtım fırsatı (spawn yok — zombi doğum
|
|
191
|
+
# engeli); hata yalıtılmış: worker sökümü devam eder.
|
|
192
|
+
def worker_before_join
|
|
193
|
+
auto_digest_touched!(spawn: false)
|
|
194
|
+
rescue StandardError => e
|
|
195
|
+
Vakanuvis.log_via(@dmesg, :warn, "shutdown auto-digest failed (#{e.class}: #{e.message}) — worker teardown continues")
|
|
233
196
|
end
|
|
234
197
|
|
|
235
|
-
def
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
198
|
+
def worker_drop_accounted(_item)
|
|
199
|
+
@monitor.synchronize { @dropped += 1 }
|
|
200
|
+
Vakanuvis.log_via(@dmesg, :warn, "event queue overflow — dropped oldest (total: #{@dropped})")
|
|
201
|
+
end
|
|
239
202
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
ensure
|
|
247
|
-
@monitor.synchronize { @busy -= 1 }
|
|
248
|
-
end
|
|
203
|
+
def worker_dispatch_failed(kind, _payload, error)
|
|
204
|
+
# A dispatch-lost event must leave a chronicle trace — the same
|
|
205
|
+
# ledger as overflow drops, so the session annal cannot look
|
|
206
|
+
# complete when it is not.
|
|
207
|
+
@monitor.synchronize { @dropped += 1 }
|
|
208
|
+
Vakanuvis.log_via(@dmesg, :warn, "chronicler worker event dispatch failed (#{error.class}: #{error.message}) — #{kind} event lost, worker continues")
|
|
249
209
|
end
|
|
250
210
|
|
|
251
211
|
# TranscriptIndexer disiplini: kronikçinin kendi hatası akışı
|
|
@@ -383,7 +343,7 @@ module Rubik
|
|
|
383
343
|
@monitor.synchronize do
|
|
384
344
|
if @dropped.positive?
|
|
385
345
|
seq = @seq += 1
|
|
386
|
-
overflow = [["dropped.#{seq}", "- [#{seq}] #{@dropped} event(s) dropped — queue overflow (event=dropped.#{seq})"]]
|
|
346
|
+
overflow = [["dropped.#{seq}", "- [#{seq}] #{@dropped} event(s) dropped — queue overflow or dispatch failure (event=dropped.#{seq})"]]
|
|
387
347
|
@dropped = 0
|
|
388
348
|
end
|
|
389
349
|
end
|
data/lib/rubik/tools/base.rb
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
require "pathname"
|
|
4
4
|
require_relative "declaration"
|
|
5
|
+
require_relative "services" unless defined?(Rubik::Tools::Services)
|
|
6
|
+
require_relative "../coeffects" unless defined?(Rubik::Coeffects)
|
|
5
7
|
|
|
6
8
|
module Rubik
|
|
7
9
|
module Tools
|
|
@@ -76,6 +78,35 @@ module Rubik
|
|
|
76
78
|
end
|
|
77
79
|
end
|
|
78
80
|
|
|
81
|
+
# Single home for tool-side coeffect and service resolution (architecture
|
|
82
|
+
# review Candidate A2, issue #368). Unifies the 3 scattered tool-side
|
|
83
|
+
# dialects:
|
|
84
|
+
# 1. Coeffects.resolve(@runtime_context, KEY, @fallback)
|
|
85
|
+
# 2. @fallback || (ctx.respond_to?(:get) ? Coeffects.get(...) : nil)
|
|
86
|
+
# 3. @runtime_manager.context coeffect lookups
|
|
87
|
+
#
|
|
88
|
+
# Delegates directly to Tools::Services::COEFFECTS and Coeffects.get so
|
|
89
|
+
# no third resolution home is created. If the runtime context does not
|
|
90
|
+
# satisfy the coeffect, falls back to the explicitly passed `fallback`,
|
|
91
|
+
# or to an instance variable matching `@#{key}` if defined.
|
|
92
|
+
#
|
|
93
|
+
# task_mgr = service(:task_manager)
|
|
94
|
+
# harness = service(:pruner, @harness)
|
|
95
|
+
# asker = service(:subagent_question_asker)
|
|
96
|
+
def service(key, fallback = nil, ctx: nil)
|
|
97
|
+
effective_ctx = ctx || (defined?(@runtime_context) ? @runtime_context : nil)
|
|
98
|
+
effective_ctx ||= (@runtime_manager.context if defined?(@runtime_manager) && @runtime_manager.respond_to?(:context))
|
|
99
|
+
|
|
100
|
+
coeffect_key = Rubik::Tools::Services::COEFFECTS[key] || Rubik::Coeffects.canonical(key)
|
|
101
|
+
resolved = Rubik::Coeffects.get(effective_ctx, coeffect_key) if effective_ctx
|
|
102
|
+
return resolved unless nil.equal?(resolved)
|
|
103
|
+
|
|
104
|
+
return fallback unless nil.equal?(fallback)
|
|
105
|
+
|
|
106
|
+
ivar = :"@#{key}"
|
|
107
|
+
instance_variable_defined?(ivar) ? instance_variable_get(ivar) : nil
|
|
108
|
+
end
|
|
109
|
+
|
|
79
110
|
# Normalizes a model-supplied path filter against the tool's root
|
|
80
111
|
# directory: backslashes become slashes, "./" is stripped, and ABSOLUTE
|
|
81
112
|
# paths (C:/…, /…) are relativized when they sit inside the root.
|
|
@@ -98,18 +129,35 @@ module Rubik
|
|
|
98
129
|
return [sub_path, nil]
|
|
99
130
|
end
|
|
100
131
|
|
|
101
|
-
|
|
132
|
+
# Handle Windows drive letters portably across Linux, macOS and Windows
|
|
133
|
+
filter_drive = filter =~ %r{\A([A-Za-z]):(/.*)?\z} ? Regexp.last_match(1).upcase : nil
|
|
134
|
+
filter_path = filter_drive ? (Regexp.last_match(2) || "/") : filter
|
|
135
|
+
root_drive = norm_root =~ %r{\A([A-Za-z]):(/.*)?\z} ? Regexp.last_match(1).upcase : nil
|
|
136
|
+
root_path = root_drive ? (Regexp.last_match(2) || "/") : norm_root
|
|
137
|
+
|
|
138
|
+
outside = if (filter_drive && !root_drive) ||
|
|
139
|
+
(!filter_drive && root_drive && filter_path.start_with?("/")) ||
|
|
140
|
+
(filter_drive && root_drive && filter_drive != root_drive)
|
|
141
|
+
true
|
|
142
|
+
else
|
|
143
|
+
base_root = File.expand_path(root_path)
|
|
144
|
+
expanded = File.expand_path(filter_path, base_root)
|
|
145
|
+
rel_check = begin
|
|
146
|
+
Pathname.new(expanded).relative_path_from(Pathname.new(base_root)).to_s.tr("\\", "/")
|
|
147
|
+
rescue ArgumentError
|
|
148
|
+
nil
|
|
149
|
+
end
|
|
150
|
+
rel_check.nil? || rel_check == ".." || rel_check.start_with?("../")
|
|
151
|
+
end
|
|
102
152
|
|
|
103
|
-
rel = begin
|
|
104
|
-
Pathname.new(File.expand_path(filter)).relative_path_from(Pathname.new(File.expand_path(root_dir))).to_s.tr("\\", "/")
|
|
105
|
-
rescue ArgumentError
|
|
106
|
-
nil
|
|
107
|
-
end
|
|
108
|
-
outside = rel.nil? || rel == ".." || rel.start_with?("../")
|
|
109
153
|
if outside
|
|
110
154
|
return [nil, "Path '#{raw}' is outside the project workspace (#{root_dir}). " \
|
|
111
155
|
"Use a path relative to the project root, e.g. 'lib'."]
|
|
112
156
|
end
|
|
157
|
+
|
|
158
|
+
base_root = File.expand_path(root_path)
|
|
159
|
+
expanded = File.expand_path(filter_path, base_root)
|
|
160
|
+
rel = Pathname.new(expanded).relative_path_from(Pathname.new(base_root)).to_s.tr("\\", "/")
|
|
113
161
|
return ["", nil] if rel == "."
|
|
114
162
|
|
|
115
163
|
[rel, nil]
|
|
@@ -187,8 +187,7 @@ module Rubik
|
|
|
187
187
|
private
|
|
188
188
|
|
|
189
189
|
def execute_background(cmd)
|
|
190
|
-
task_mgr =
|
|
191
|
-
(@runtime_context.respond_to?(:get) ? Rubik::Coeffects.get(@runtime_context, Rubik::Coeffects::TASK_MANAGER) : nil)
|
|
190
|
+
task_mgr = service(:task_manager)
|
|
192
191
|
if task_mgr.nil?
|
|
193
192
|
return Rubik::Tools::Result.new(tool_name: "run_command", status: :error,
|
|
194
193
|
output: "TaskManager is not available to run commands in background.",
|
|
@@ -91,6 +91,7 @@ module Rubik
|
|
|
91
91
|
"For surgical edits to existing files, use replace_file_content instead. " \
|
|
92
92
|
"Use apply_buffer to persist the buffer to disk before running tests or tests will not see your changes.",
|
|
93
93
|
risk: :write, archetypes: [:coder], write_grant: true, maestro_blocked: true, buffer_bound: true,
|
|
94
|
+
buffer_sync_writer: true,
|
|
94
95
|
params_schema: {
|
|
95
96
|
type: "object",
|
|
96
97
|
properties: {
|
|
@@ -166,7 +167,7 @@ module Rubik
|
|
|
166
167
|
end
|
|
167
168
|
|
|
168
169
|
def context_index
|
|
169
|
-
|
|
170
|
+
service(:context_index, @context_index)
|
|
170
171
|
end
|
|
171
172
|
|
|
172
173
|
def execute(args = {})
|
|
@@ -237,6 +238,7 @@ module Rubik
|
|
|
237
238
|
description: "Replace an exact chunk of code within an existing file. Requires exact verbatim matching of target_content " \
|
|
238
239
|
"(including whitespace and indentation). Optional start_line and end_line narrow the search range.",
|
|
239
240
|
risk: :write, archetypes: [:coder], write_grant: true, maestro_blocked: true, buffer_bound: true,
|
|
241
|
+
buffer_sync_writer: true,
|
|
240
242
|
params_schema: {
|
|
241
243
|
type: "object",
|
|
242
244
|
properties: {
|
|
@@ -18,15 +18,15 @@ module Rubik
|
|
|
18
18
|
|
|
19
19
|
DECLARATION = Declaration.new(
|
|
20
20
|
name: "update_goal_ledger", aliases: ["ledger"],
|
|
21
|
-
description: "Update the structured goal ledger of the RUNNING !goal loop with
|
|
22
|
-
"JSON patch ({\"rev\": N, \"ops\": [{\"op\":
|
|
23
|
-
"Read
|
|
24
|
-
"patch against the rev it reports.
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
21
|
+
description: "Update the structured goal ledger of the RUNNING !goal loop with an RFC 6902 " \
|
|
22
|
+
"JSON patch ({\"rev\": N, \"ops\": [{\"op\": \"add\"|\"replace\"|\"remove\", \"path\": \"/tasks/0/status\", \"value\": ...}]}). " \
|
|
23
|
+
"Read current state via read_file(path: 'rubik://goal/ledger') (or 'rubik://goal/ledger.json') and issue " \
|
|
24
|
+
"the patch against the rev it reports. Items carry 0-based indices (/tasks/0); append via /tasks/-. " \
|
|
25
|
+
"Tasks and environment notes may carry declarative verify specs: {\"type\": \"file_exists\", \"path\": ...}, " \
|
|
26
|
+
"{\"type\": \"file_contains\", \"path\": ..., \"pattern\": ...}, or {\"type\": \"marker\", \"path\": ..., \"marker\": ...}. " \
|
|
27
|
+
"Rejections carry per-op fix hints; after the retry budget the ledger stays unchanged. A task status of " \
|
|
28
|
+
"`stale` means the harness re-checked that entry's verify predicate against the filesystem and it FAILED " \
|
|
29
|
+
"(the world drifted): re-inspect reality, then update the entry with a normal patch against the bumped rev.",
|
|
30
30
|
risk: :write, archetypes: [], write_grant: false, root_only: true,
|
|
31
31
|
maestro_blocked: false, # vakanüvis/pruner emsali: kök düzlem aracı
|
|
32
32
|
params_schema: {
|
|
@@ -53,7 +53,7 @@ module Rubik
|
|
|
53
53
|
"{\"rev\": N, \"ops\": [...]}.")
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
ledger =
|
|
56
|
+
ledger = service(:goal_ledger)
|
|
57
57
|
unless ledger
|
|
58
58
|
return ToolOutput.error("Goal ledger is not available: no running !goal loop (or goal.ledger.enabled=false). " \
|
|
59
59
|
"The ledger exists only while a goal loop runs; update it after each meaningful step.")
|
|
@@ -45,11 +45,11 @@ module Rubik
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def context_index
|
|
48
|
-
|
|
48
|
+
service(:context_index, @context_index)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def buffer_manager
|
|
52
|
-
|
|
52
|
+
service(:buffer_manager, @buffer_manager)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def execute(args = {})
|
|
@@ -88,9 +88,7 @@ module Rubik
|
|
|
88
88
|
# a subagent child context (ScopedRegistry rebind); the root-context
|
|
89
89
|
# instance stays nil here and keeps the human-dialog behavior.
|
|
90
90
|
def init0_asker
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
Rubik::Coeffects.get(@runtime_context, Rubik::Coeffects::SUBAGENT_QUESTION_ASKER)
|
|
91
|
+
service(:subagent_question_asker)
|
|
94
92
|
end
|
|
95
93
|
|
|
96
94
|
# One blocking round-trip for the whole batch: the maestro answers once and
|
|
@@ -330,7 +330,7 @@ module Rubik
|
|
|
330
330
|
private
|
|
331
331
|
|
|
332
332
|
def verify_binary(target, lang, proposed_cmd, sub_ctx, probe_args: nil)
|
|
333
|
-
Rubik::Runtime::RepairProbe.new(root_dir: @root_dir).verify(target, lang, proposed_cmd, sub_ctx, probe_args: probe_args)
|
|
333
|
+
Rubik::Runtime::RepairProbe.new(root_dir: @root_dir, guard: @guard).verify(target, lang, proposed_cmd, sub_ctx, probe_args: probe_args)
|
|
334
334
|
end
|
|
335
335
|
|
|
336
336
|
def command_provided?(command)
|
|
@@ -20,11 +20,11 @@ module Rubik
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def effective_lsp_manager
|
|
23
|
-
|
|
23
|
+
service(:lsp_manager, @lsp_manager)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def effective_buffer_manager
|
|
27
|
-
|
|
27
|
+
service(:buffer_manager, @buffer_manager)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
private
|
|
@@ -49,7 +49,7 @@ module Rubik
|
|
|
49
49
|
|
|
50
50
|
def execute(args = {})
|
|
51
51
|
action = (args["action"] || args[:action] || "status").to_s
|
|
52
|
-
harness =
|
|
52
|
+
harness = service(:pruner, @harness)
|
|
53
53
|
unless harness
|
|
54
54
|
return ToolOutput.error("Context pruner is not available: disabled by config " \
|
|
55
55
|
"(subagents.pruner.enabled=false) or the harness is not wired " \
|
|
@@ -63,7 +63,7 @@ module Rubik
|
|
|
63
63
|
cmds.sort.each { |name, meta| lines << " !#{name.ljust(16)} : #{meta[:description]}" }
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
task_mgr = (
|
|
66
|
+
task_mgr = service(:task_manager)
|
|
67
67
|
task_mgr ||= @shell.task_manager if @shell.respond_to?(:task_manager)
|
|
68
68
|
|
|
69
69
|
if ["all", "tasks"].include?(target) && task_mgr
|
|
@@ -72,6 +72,19 @@ module Rubik
|
|
|
72
72
|
return delivery_text(recipient) if delivered == true
|
|
73
73
|
return queued_text(recipient, steps) if delivered == :queued
|
|
74
74
|
|
|
75
|
+
# A dependency-queued (or launching) spec exists but has never run:
|
|
76
|
+
# "not found" is false, and the redeploy suggestion below would
|
|
77
|
+
# refuse the same id — the model needs the truthful next action.
|
|
78
|
+
if sup.respond_to?(:get) && (spec = sup.get(recipient)) && spec.respond_to?(:queued?) &&
|
|
79
|
+
(spec.queued? || spec.spawning?)
|
|
80
|
+
return ToolOutput.error(
|
|
81
|
+
"Subagent '#{recipient}' is dependency-queued (deps: #{spec.depends_on.join(', ')}) and will " \
|
|
82
|
+
"launch automatically when its predecessors settle. Messages cannot be buffered on an unborn " \
|
|
83
|
+
"spec — re-send after it launches, or kill it with manage_subagents(action: 'kill', " \
|
|
84
|
+
"conversation_id: '#{recipient}') if the wait is no longer worth it."
|
|
85
|
+
)
|
|
86
|
+
end
|
|
87
|
+
|
|
75
88
|
ToolOutput.error(
|
|
76
89
|
"Subagent '#{recipient}' not found or no longer active. If it recently finished, redeploy it with its " \
|
|
77
90
|
"context intact: manage_subagents(action: 'redeploy', conversation_id: '#{recipient}', prompt: '<task>') " \
|
|
@@ -84,9 +97,7 @@ module Rubik
|
|
|
84
97
|
# Subagent düzlemi (rebound araç): gönderen coeffect'i GERÇEK subagent
|
|
85
98
|
# id'sidir. Kök düzleminde sağlanmaz → Supervisor default'u kalır.
|
|
86
99
|
def subagent_sender_id
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
Rubik::Coeffects.get(@runtime_context, Rubik::Coeffects::SUBAGENT_SENDER_ID)
|
|
100
|
+
service(:subagent_sender_id)
|
|
90
101
|
end
|
|
91
102
|
|
|
92
103
|
# Kök alias'ına giden mesajın yanıtı kök kişisiyle konuşur ("the
|
|
@@ -45,7 +45,7 @@ module Rubik
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def execute(args = {})
|
|
48
|
-
manager =
|
|
48
|
+
manager = service(:skill_manager, @manager)
|
|
49
49
|
return ToolOutput.error("Error: skills manager is not available.") unless manager
|
|
50
50
|
return ToolOutput.error("Error: skills are disabled (skills.enabled = false).") unless manager.enabled?
|
|
51
51
|
|
|
@@ -102,7 +102,7 @@ module Rubik
|
|
|
102
102
|
# STORAGE_STORE coeffect'i (parent chain — subagent'lar buradan çözer)
|
|
103
103
|
# → config'e dayalı tembel fresh default (storage kapalıysa nil).
|
|
104
104
|
def resolve_store
|
|
105
|
-
resolved =
|
|
105
|
+
resolved = service(:storage_store, @store)
|
|
106
106
|
return resolved if resolved
|
|
107
107
|
|
|
108
108
|
@resolve_store ||= Rubik::Storage::Service.build(config: @config, root_dir: @root_dir)
|
|
@@ -16,6 +16,7 @@ module Rubik
|
|
|
16
16
|
module SubagentToolHelpers
|
|
17
17
|
def resolve_supervisor(supervisor, runtime_context)
|
|
18
18
|
return supervisor if supervisor
|
|
19
|
+
return service(:subagent_supervisor, ctx: runtime_context) if respond_to?(:service)
|
|
19
20
|
return nil unless runtime_context.respond_to?(:get)
|
|
20
21
|
|
|
21
22
|
Rubik::Coeffects.get(runtime_context, Rubik::Coeffects::SUBAGENT_SUPERVISOR)
|
|
@@ -99,7 +100,7 @@ module Rubik
|
|
|
99
100
|
# Task ownership (issue #125): the spawning context's token owns the new
|
|
100
101
|
# work (detached specs opt out per spec). Resolved at call time, so a
|
|
101
102
|
# nested subagent inherits its ancestor's task through its child ctx.
|
|
102
|
-
owner =
|
|
103
|
+
owner = service(:task_cancellation)
|
|
103
104
|
|
|
104
105
|
begin
|
|
105
106
|
results = sup.spawn_batch(specs, owner: owner)
|
|
@@ -113,8 +113,10 @@ module Rubik
|
|
|
113
113
|
|
|
114
114
|
# Blocked states that need maestro action before their chain proceeds
|
|
115
115
|
# (bug-llm-timeout-observability ④): a bare JSON list made a stalled
|
|
116
|
-
# subagent indistinguishable from a healthy one at a glance.
|
|
117
|
-
|
|
116
|
+
# subagent indistinguishable from a healthy one at a glance. The set
|
|
117
|
+
# itself is owned by Lifecycle (ATTENTION_STATES beside TRANSITIONS) —
|
|
118
|
+
# this file used to hand-copy it.
|
|
119
|
+
def attention_states = Rubik::Orchestrator::Subagent::Lifecycle::ATTENTION_STATES
|
|
118
120
|
|
|
119
121
|
# List with a prominent attention block: any blocked subagent is called
|
|
120
122
|
# out ABOVE the JSON with its state, last error, and the exact recovery
|
|
@@ -124,7 +126,7 @@ module Rubik
|
|
|
124
126
|
return "No active or tracked subagents." if instances.empty?
|
|
125
127
|
|
|
126
128
|
lines = []
|
|
127
|
-
attention = instances.select { |i|
|
|
129
|
+
attention = instances.select { |i| attention_states.include?(i.state.to_sym) }
|
|
128
130
|
if attention.any?
|
|
129
131
|
lines << "⚠ #{attention.size} subagent(s) need attention:"
|
|
130
132
|
attention.each do |i|
|
|
@@ -30,7 +30,7 @@ module Rubik
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def ast_graph
|
|
33
|
-
|
|
33
|
+
service(:ast_graph, @ast_graph)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def execute(args = {})
|
|
@@ -96,7 +96,7 @@ module Rubik
|
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
def ast_graph
|
|
99
|
-
|
|
99
|
+
service(:ast_graph, @ast_graph)
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
def execute(args = {})
|
|
@@ -146,7 +146,7 @@ module Rubik
|
|
|
146
146
|
end
|
|
147
147
|
|
|
148
148
|
def ast_graph
|
|
149
|
-
|
|
149
|
+
service(:ast_graph, @ast_graph)
|
|
150
150
|
end
|
|
151
151
|
|
|
152
152
|
def execute(args = {})
|
|
@@ -201,7 +201,7 @@ module Rubik
|
|
|
201
201
|
end
|
|
202
202
|
|
|
203
203
|
def ast_graph
|
|
204
|
-
|
|
204
|
+
service(:ast_graph, @ast_graph)
|
|
205
205
|
end
|
|
206
206
|
|
|
207
207
|
def execute(args = {})
|