rubik 0.7.1 → 0.8.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/CHANGELOG.md +141 -1
- data/lib/rubik/ast/typescript_extractor.rb +2 -2
- data/lib/rubik/config/deep_ops.rb +14 -0
- data/lib/rubik/config/defaults.rb +5 -4
- data/lib/rubik/config/env_loader.rb +88 -0
- data/lib/rubik/config/model_catalog.rb +13 -0
- data/lib/rubik/config/pruner.rb +34 -0
- data/lib/rubik/config/schema.rb +163 -0
- data/lib/rubik/config/scoped.rb +108 -0
- data/lib/rubik/config/store.rb +19 -8
- data/lib/rubik/config.rb +129 -53
- data/lib/rubik/diagnostics/parser.rb +2 -2
- data/lib/rubik/orchestrator/step_executor.rb +12 -59
- data/lib/rubik/orchestrator/subagent/scoped_registry.rb +14 -23
- data/lib/rubik/orchestrator/subagent/spawn_transaction.rb +12 -2
- data/lib/rubik/orchestrator/subagent/tool_dispatch.rb +12 -49
- data/lib/rubik/orchestrator/turn_executor.rb +9 -4
- data/lib/rubik/repl/commands/workspace.rb +14 -8
- data/lib/rubik/repl/lifecycle.rb +11 -0
- data/lib/rubik/repl/service_catalog.rb +2 -1
- data/lib/rubik/sandbox/runner.rb +28 -13
- data/lib/rubik/storage/render.rb +1 -1
- data/lib/rubik/storage/vakanuvis/distill_gate.rb +3 -3
- data/lib/rubik/storage/vakanuvis/harness.rb +4 -65
- data/lib/rubik/storage/vakanuvis/orientation.rb +1 -2
- data/lib/rubik/storage/vakanuvis/recall.rb +84 -0
- data/lib/rubik/storage/vakanuvis.rb +1 -0
- data/lib/rubik/tools/base.rb +34 -0
- data/lib/rubik/tools/builtins/define_subagent.rb +6 -0
- data/lib/rubik/tools/builtins/dmesg.rb +4 -4
- data/lib/rubik/tools/builtins/files.rb +18 -24
- data/lib/rubik/tools/builtins/goal_ledger.rb +1 -1
- data/lib/rubik/tools/builtins/grep.rb +6 -6
- data/lib/rubik/tools/builtins/interactive.rb +6 -0
- data/lib/rubik/tools/builtins/lifecycle.rb +2 -1
- data/lib/rubik/tools/builtins/pruner.rb +1 -1
- data/lib/rubik/tools/builtins/send_message.rb +6 -0
- data/lib/rubik/tools/builtins/subagent.rb +12 -0
- data/lib/rubik/tools/builtins/vakanuvis.rb +1 -1
- data/lib/rubik/tools/catalog.rb +19 -0
- data/lib/rubik/tools/declaration.rb +15 -2
- data/lib/rubik/tools/result_normalizer.rb +115 -0
- data/lib/rubik/tools/truncator.rb +3 -3
- data/lib/rubik/version.rb +1 -1
- metadata +7 -1
|
@@ -379,6 +379,16 @@ module Rubik
|
|
|
379
379
|
ctx.out.puts "[Rubik::Allow] Added allowed external directory: #{expanded} (Mode: #{mode_str}) [#{Base.scope_label(scope)}]."
|
|
380
380
|
end
|
|
381
381
|
|
|
382
|
+
OPERATOR_ONLY_CONFIG_PREFIXES = [
|
|
383
|
+
"security.",
|
|
384
|
+
"sandbox.",
|
|
385
|
+
"subagents.",
|
|
386
|
+
"plugins.",
|
|
387
|
+
"lsp.servers.",
|
|
388
|
+
"workspace.allow_external_writes",
|
|
389
|
+
"tools.circuit_breaker."
|
|
390
|
+
].freeze
|
|
391
|
+
|
|
382
392
|
private_class_method def self.register_config_command(shell)
|
|
383
393
|
shell.register_command("config", description: "Get, set, or view runtime configuration (set|get|list|path)",
|
|
384
394
|
usage: USAGE_CONFIG, audience: :both) do |args, ctx|
|
|
@@ -407,14 +417,10 @@ module Rubik
|
|
|
407
417
|
val = clean_args[2..]&.join(" ")
|
|
408
418
|
if key.nil? || key.empty? || val.nil? || val.empty?
|
|
409
419
|
ctx.out.puts "Usage: !config set <key> <val> [--project|--global]"
|
|
410
|
-
elsif ctx.agent_caller && key.start_with?(
|
|
411
|
-
#
|
|
412
|
-
#
|
|
413
|
-
#
|
|
414
|
-
# concurrency, reap grace) exec_repl_command ile çözemez —
|
|
415
|
-
# kapı canlı config okur, self-unlock yolu bu yüzden kapalı.
|
|
416
|
-
ctx.out.puts "Security Error: keys under 'security.*' and 'sandbox.*' are operator-only " \
|
|
417
|
-
"(mutated via !allow-cmd / !allow-dir as the human operator)."
|
|
420
|
+
elsif ctx.agent_caller && OPERATOR_ONLY_CONFIG_PREFIXES.any? { |p| key.start_with?(p) }
|
|
421
|
+
# Security boundary: agents cannot alter security, sandbox, subagent governance,
|
|
422
|
+
# plugins (arbitrary code execution), LSP binary commands, or external write policies.
|
|
423
|
+
ctx.out.puts "Security Error: configuration key '#{key}' is operator-only and cannot be altered by autonomous agents."
|
|
418
424
|
else
|
|
419
425
|
res = ctx.config.set(key, val, persist: scope)
|
|
420
426
|
next if Base.report_persist_failure(ctx, res, scope)
|
data/lib/rubik/repl/lifecycle.rb
CHANGED
|
@@ -151,6 +151,17 @@ module Rubik
|
|
|
151
151
|
Rubik.runtime_manager = @runtime_manager
|
|
152
152
|
@overlay_storage.load_all(self, @runtime_manager)
|
|
153
153
|
@config_cleanups = ConfigWiring.wire(self)
|
|
154
|
+
if @runtime_manager&.context.respond_to?(:on_dispose)
|
|
155
|
+
@runtime_manager.context.on_dispose do
|
|
156
|
+
while (cleanup = @config_cleanups&.pop)
|
|
157
|
+
begin
|
|
158
|
+
cleanup.call
|
|
159
|
+
rescue StandardError => e
|
|
160
|
+
warn "[WARN] Config cleanup failed: #{e.message}"
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
154
165
|
# Phase 5 built the tool registry; the skill tool's epoch (its
|
|
155
166
|
# revertible registration + inverse) opens on the manager's own
|
|
156
167
|
# sub-context only after config wiring so enable/disable knobs react.
|
|
@@ -239,7 +239,8 @@ module Rubik
|
|
|
239
239
|
name: :sandbox_runner,
|
|
240
240
|
builder: lambda do |s|
|
|
241
241
|
Rubik::Sandbox::Runner.new(root_dir: s.root_dir, config: s[:config],
|
|
242
|
-
allowed_external_dirs: s[:allowed_ext_dirs], guard: s[:guard]
|
|
242
|
+
allowed_external_dirs: s[:allowed_ext_dirs], guard: s[:guard],
|
|
243
|
+
context: s[:runtime_manager]&.context)
|
|
243
244
|
end,
|
|
244
245
|
provide: Rubik::Coeffects::SANDBOX_RUNNER
|
|
245
246
|
),
|
data/lib/rubik/sandbox/runner.rb
CHANGED
|
@@ -8,11 +8,12 @@ require_relative "../platform"
|
|
|
8
8
|
module Rubik
|
|
9
9
|
module Sandbox
|
|
10
10
|
class Runner
|
|
11
|
-
attr_reader :root_dir, :driver, :allowed_external_dirs, :config, :guard
|
|
11
|
+
attr_reader :root_dir, :driver, :allowed_external_dirs, :config, :guard, :context
|
|
12
12
|
|
|
13
|
-
def initialize(root_dir: Dir.pwd, allow_network: false, driver: nil, config: nil, allowed_external_dirs: [], guard: nil)
|
|
13
|
+
def initialize(root_dir: Dir.pwd, allow_network: false, driver: nil, config: nil, allowed_external_dirs: [], guard: nil, context: nil)
|
|
14
14
|
@root_dir = File.expand_path(root_dir)
|
|
15
15
|
@config = config
|
|
16
|
+
@context = context
|
|
16
17
|
@preferred_driver = driver
|
|
17
18
|
# Shared session guard (Composition provides it). Injected into every
|
|
18
19
|
# driver_opts rebuild below so reconfigure! cycles never strand a
|
|
@@ -32,17 +33,31 @@ module Rubik
|
|
|
32
33
|
|
|
33
34
|
reconfigure!
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
@cleanups = []
|
|
37
|
+
if @config.respond_to?(:on_change)
|
|
38
|
+
@cleanups << @config.on_change("sandbox") { reconfigure! }
|
|
39
|
+
# Track explicit edits to the allow-list key itself. Once the user
|
|
40
|
+
# has set this key at any scope, the config becomes authoritative:
|
|
41
|
+
# reconfigure! recomputes config-sourced entries from scratch so
|
|
42
|
+
# REMOVING a dir actually shrinks the live allow-list (the previous
|
|
43
|
+
# union-based merge was monotonic and left stale dirs allowed).
|
|
44
|
+
@cleanups << @config.on_change("workspace.allowed_external_dirs") do
|
|
45
|
+
@allowed_dirs_config_touched = true
|
|
46
|
+
reconfigure!
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
@context.on_dispose { dispose } if @context.respond_to?(:on_dispose)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Unregisters accumulated configuration observers (AGENTS.md Ω Inverses).
|
|
54
|
+
def dispose
|
|
55
|
+
while (cleanup = @cleanups&.pop)
|
|
56
|
+
begin
|
|
57
|
+
cleanup.call
|
|
58
|
+
rescue StandardError => e
|
|
59
|
+
warn "[WARN] Sandbox::Runner cleanup failed: #{e.message}"
|
|
60
|
+
end
|
|
46
61
|
end
|
|
47
62
|
end
|
|
48
63
|
|
data/lib/rubik/storage/render.rb
CHANGED
|
@@ -38,7 +38,7 @@ module Rubik
|
|
|
38
38
|
return header << "_(empty — no #{type} entities yet)_\n" if summaries.empty?
|
|
39
39
|
|
|
40
40
|
summaries.each do |s|
|
|
41
|
-
title = s[:title].to_s.
|
|
41
|
+
title = s[:title].to_s.slice(0, 80).gsub(/[\\|]/) { |ch| "\\#{ch}" }
|
|
42
42
|
header << "| #{s[:row]} | `#{s[:id]}` | #{s[:status]} | #{s[:updated_at]} | #{title} |\n"
|
|
43
43
|
end
|
|
44
44
|
header
|
|
@@ -260,11 +260,11 @@ module Rubik
|
|
|
260
260
|
|
|
261
261
|
gap_ref = Vocabulary.recall_gap_ref(proposal["ref"])
|
|
262
262
|
# Review bulgusu 2: smoke, gerçek recall'ın GÖRÜNÜR penceresiyle
|
|
263
|
-
# koşulmalı — ilk RECALL_LIMIT kayıt. 6. sıradaki sayfa maestro'ya
|
|
263
|
+
# koşulmalı — ilk Recall::RECALL_LIMIT kayıt. 6. sıradaki sayfa maestro'ya
|
|
264
264
|
# görünmüyorsa iska sayılmalı (öz-onarım döngüsü kör kalmasın).
|
|
265
265
|
missed = checks.reject do |check|
|
|
266
|
-
active_recall_hits(gate.store, query: check, type:
|
|
267
|
-
.first(
|
|
266
|
+
active_recall_hits(gate.store, query: check, type: Recall::RECALL_TYPES)
|
|
267
|
+
.first(Recall::RECALL_LIMIT).any? { |r| r["id"] == page_id }
|
|
268
268
|
end
|
|
269
269
|
if missed.empty?
|
|
270
270
|
resolved = gate.store.get(type: "note", id: gap_ref)
|
|
@@ -13,10 +13,6 @@ module Rubik
|
|
|
13
13
|
class Harness
|
|
14
14
|
STOP = :__vakanuvis_stop__
|
|
15
15
|
MAX_QUEUE = 200
|
|
16
|
-
RECALL_LIMIT = 5
|
|
17
|
-
RECALL_FALLBACK_LIMIT = 3
|
|
18
|
-
RECALL_BODY_SLICE = 140
|
|
19
|
-
RECALL_TYPES = ["memory", "wiki"].freeze
|
|
20
16
|
# v2 §4-V4: damıtıcı kaynak disiplini — yalnız TAMAMLANMIŞ transcript'ler,
|
|
21
17
|
# damıtıcının kendisi Hariç (özyineleme kirliliği: canlı depoda transcript satırları 'vakanuvis' etiketi taşır).
|
|
22
18
|
SOURCE_TRANSCRIPT_LIMIT = 8
|
|
@@ -135,23 +131,10 @@ module Rubik
|
|
|
135
131
|
|
|
136
132
|
# ---- talep düzlemi (maestro aracı buraya delege eder; K7) ---------
|
|
137
133
|
|
|
138
|
-
#
|
|
139
|
-
#
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
def recall(query, types: RECALL_TYPES)
|
|
143
|
-
q = query.to_s.strip
|
|
144
|
-
raise ArgumentError, "recall: 'query' is required" if q.empty?
|
|
145
|
-
|
|
146
|
-
allowed = Array(types).map(&:to_s)
|
|
147
|
-
allowed = RECALL_TYPES if allowed.empty?
|
|
148
|
-
hits = DistillGate.active_recall_hits(@store, query: q, type: allowed).first(RECALL_LIMIT)
|
|
149
|
-
unless hits.empty?
|
|
150
|
-
header = "Recalled #{hits.size} entit#{hits.size == 1 ? 'y' : 'ies'} for '#{AnnalWriter.one_line(q, 80)}':"
|
|
151
|
-
return "#{header}\n#{hits.map { |r| recall_line(r) }.join("\n")}\nRead a full record with read_file(path: '<uri above>')."
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
relaxed_digest(q, allowed)
|
|
134
|
+
# Deterministik geri çağırma Recall düzleminde (recall.rb); burada
|
|
135
|
+
# yalnız delege — araç yüzeyi (K7) ve test ikizleri bu imzaya pinli.
|
|
136
|
+
def recall(query, types: Recall::RECALL_TYPES)
|
|
137
|
+
Recall.recall(@store, query, types: types)
|
|
155
138
|
end
|
|
156
139
|
|
|
157
140
|
def auto_digest? = @auto_digest
|
|
@@ -221,50 +204,6 @@ module Rubik
|
|
|
221
204
|
shown.join(", ")
|
|
222
205
|
end
|
|
223
206
|
|
|
224
|
-
# v2 §4-V2 + issue #99 P2: AND boşluğu tek tip körlük değil — en yakın
|
|
225
|
-
# kısmi eşleşmeler dürüstçe "(fallback)" damgasıyla sunulur (gerçek
|
|
226
|
-
# eşleşme değildir), transcript izleri kapsam ipucu olarak sayılır. Ne
|
|
227
|
-
# fallback ne transcript izi varsa bugünkü dil/terim yönlendirmesi birebir
|
|
228
|
-
# döner (keyword-AND'da en sık neden TR sorgu ↔ EN gövde uyuşmazlığıdır;
|
|
229
|
-
# yanlış "hemen yeniden kaydet" yönlendirmesi burada kesilir).
|
|
230
|
-
def relaxed_digest(query, allowed)
|
|
231
|
-
q = query.to_s.strip
|
|
232
|
-
# Süpersede edilmiş sayılar "en yakın kısmi eşleşme" olarak
|
|
233
|
-
# sunulmaz (review M1) — emekli bir sayfayı okumaya davet etmek,
|
|
234
|
-
# issue #100'ün "iki kopya, biri bozuk" bulgusunun aynısıdır.
|
|
235
|
-
relaxed = DistillGate.active_recall_hits(@store, query: q, type: allowed, require_all: false)
|
|
236
|
-
.first(RECALL_FALLBACK_LIMIT)
|
|
237
|
-
transcripts = @store.search(query: q, type: "transcript")
|
|
238
|
-
if relaxed.empty? && transcripts.empty?
|
|
239
|
-
return "No chronicled knowledge matches '#{AnnalWriter.one_line(q, 80)}'. Recall is keyword-AND: retry with fewer or other-language " \
|
|
240
|
-
"terms first (e.g. the TR/EN Keywords: lines). If the knowledge is genuinely missing, record it (vakanuvis action 'record') or queue a digest."
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
parts = []
|
|
244
|
-
# Başlık + read_file ayağı yalnız gerçek fallback izi varken
|
|
245
|
-
# basılır (review CR#1: "yukarıdaki uri" diyecek uri yokken
|
|
246
|
-
# olmayan bir talimat modele verilmesin).
|
|
247
|
-
unless relaxed.empty?
|
|
248
|
-
parts << "No exact keyword-AND match for '#{AnnalWriter.one_line(q, 80)}' — closest partial matches (fallback, not true matches):"
|
|
249
|
-
parts.concat(relaxed.map { |r| "- (fallback) #{recall_line(r)}" })
|
|
250
|
-
end
|
|
251
|
-
unless transcripts.empty?
|
|
252
|
-
parts << "#{transcripts.size} transcript entr#{transcripts.size == 1 ? 'y' : 'ies'} mention these terms — " \
|
|
253
|
-
"the raw session logs may hold it; queue a digest to compile them."
|
|
254
|
-
end
|
|
255
|
-
parts << "If none of these help, retry with fewer or other-language terms (the TR/EN Keywords: lines), " \
|
|
256
|
-
"record the knowledge, or queue a digest."
|
|
257
|
-
parts << "Read a full record with read_file(path: '<uri above>')." unless relaxed.empty?
|
|
258
|
-
parts.join("\n")
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
def first_body_line(record)
|
|
262
|
-
slice = record["body"].to_s.lines.map(&:strip).reject(&:empty?).first.to_s.slice(0, RECALL_BODY_SLICE)
|
|
263
|
-
slice.empty? ? "(no body)" : slice
|
|
264
|
-
end
|
|
265
|
-
|
|
266
|
-
def recall_line(record) = "- #{record['title']} [#{record['id']}] #{first_body_line(record)} — #{@store.uri_for(record['type'], record['id'])}"
|
|
267
|
-
|
|
268
207
|
# Abonelik geri alımı dispatcher'a aittir (§1A: subscribe'a verilen context'e
|
|
269
208
|
# unregister inverse'i kendisi bağlar); TURN aboneliği R7 knob'unun arkasındadır.
|
|
270
209
|
def subscribe_events
|
|
@@ -202,8 +202,7 @@ module Rubik
|
|
|
202
202
|
end
|
|
203
203
|
|
|
204
204
|
def first_body_line(record)
|
|
205
|
-
|
|
206
|
-
slice.empty? ? "(no body)" : slice
|
|
205
|
+
Recall.first_body_line(record)
|
|
207
206
|
end
|
|
208
207
|
|
|
209
208
|
# Aktif mem.* kartlarından deterministik [ref, row] sırasıyla en fazla
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rubik
|
|
4
|
+
module Storage
|
|
5
|
+
module Vakanuvis
|
|
6
|
+
# Deterministik geri çağırma düzlemi: sorgu → digest dizgisi. LLM'siz,
|
|
7
|
+
# iş parçacığı içermeyen saf politika + üslup — Harness'in iş parçacığı
|
|
8
|
+
# çekirdeğinden (kuyruk + worker + olay dağıtımı) ayrı evi. Tüm
|
|
9
|
+
# RECALL_* sabitlerinin SSOT'u: Orientation ve DistillGate buradan
|
|
10
|
+
# okur, Harness'e geri dokunmaz.
|
|
11
|
+
module Recall
|
|
12
|
+
RECALL_LIMIT = 5
|
|
13
|
+
RECALL_FALLBACK_LIMIT = 3
|
|
14
|
+
RECALL_BODY_SLICE = 140
|
|
15
|
+
RECALL_TYPES = ["memory", "wiki"].freeze
|
|
16
|
+
|
|
17
|
+
module_function
|
|
18
|
+
|
|
19
|
+
# Tam deterministik, LLM'siz: Store#search_ranked BM25-lite sırası +
|
|
20
|
+
# RECALL_TYPES kısıtı + ilk RECALL_LIMIT kayıt ⇒ aynı depo ⇒ aynı digest.
|
|
21
|
+
# type: dizisi (v2 §4-V8) transcript/note gibi arama dışı tipleri hiç parse
|
|
22
|
+
# etmez; sıralama politika kararına aittir — Store#search'in [type,row] sözleşmesi değişmez.
|
|
23
|
+
def recall(store, query, types: RECALL_TYPES)
|
|
24
|
+
q = query.to_s.strip
|
|
25
|
+
raise ArgumentError, "recall: 'query' is required" if q.empty?
|
|
26
|
+
|
|
27
|
+
allowed = Array(types).map(&:to_s)
|
|
28
|
+
allowed = RECALL_TYPES if allowed.empty?
|
|
29
|
+
hits = DistillGate.active_recall_hits(store, query: q, type: allowed).first(RECALL_LIMIT)
|
|
30
|
+
unless hits.empty?
|
|
31
|
+
header = "Recalled #{hits.size} entit#{hits.size == 1 ? 'y' : 'ies'} for '#{AnnalWriter.one_line(q, 80)}':"
|
|
32
|
+
return "#{header}\n#{hits.map { |r| recall_line(store, r) }.join("\n")}\nRead a full record with read_file(path: '<uri above>')."
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
relaxed_digest(store, q, allowed)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# v2 §4-V2 + issue #99 P2: AND boşluğu tek tip körlük değil — en yakın
|
|
39
|
+
# kısmi eşleşmeler dürüstçe "(fallback)" damgasıyla sunulur (gerçek
|
|
40
|
+
# eşleşme değildir), transcript izleri kapsam ipucu olarak sayılır. Ne
|
|
41
|
+
# fallback ne transcript izi varsa bugünkü dil/terim yönlendirmesi birebir
|
|
42
|
+
# döner (keyword-AND'da en sık neden TR sorgu ↔ EN gövde uyuşmazlığıdır;
|
|
43
|
+
# yanlış "hemen yeniden kaydet" yönlendirmesi burada kesilir).
|
|
44
|
+
def relaxed_digest(store, query, allowed)
|
|
45
|
+
q = query.to_s.strip
|
|
46
|
+
# Süpersede edilmiş sayılar "en yakın kısmi eşleşme" olarak
|
|
47
|
+
# sunulmaz (review M1) — emekli bir sayfayı okumaya davet etmek,
|
|
48
|
+
# issue #100'ün "iki kopya, biri bozuk" bulgusunun aynısıdır.
|
|
49
|
+
relaxed = DistillGate.active_recall_hits(store, query: q, type: allowed, require_all: false)
|
|
50
|
+
.first(RECALL_FALLBACK_LIMIT)
|
|
51
|
+
transcripts = store.search(query: q, type: "transcript")
|
|
52
|
+
if relaxed.empty? && transcripts.empty?
|
|
53
|
+
return "No chronicled knowledge matches '#{AnnalWriter.one_line(q, 80)}'. Recall is keyword-AND: retry with fewer or other-language " \
|
|
54
|
+
"terms first (e.g. the TR/EN Keywords: lines). If the knowledge is genuinely missing, record it (vakanuvis action 'record') or queue a digest."
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
parts = []
|
|
58
|
+
# Başlık + read_file ayağı yalnız gerçek fallback izi varken
|
|
59
|
+
# basılır (review CR#1: "yukarıdaki uri" diyecek uri yokken
|
|
60
|
+
# olmayan bir talimat modele verilmesin).
|
|
61
|
+
unless relaxed.empty?
|
|
62
|
+
parts << "No exact keyword-AND match for '#{AnnalWriter.one_line(q, 80)}' — closest partial matches (fallback, not true matches):"
|
|
63
|
+
parts.concat(relaxed.map { |r| "- (fallback) #{recall_line(store, r)}" })
|
|
64
|
+
end
|
|
65
|
+
unless transcripts.empty?
|
|
66
|
+
parts << "#{transcripts.size} transcript entr#{transcripts.size == 1 ? 'y' : 'ies'} mention these terms — " \
|
|
67
|
+
"the raw session logs may hold it; queue a digest to compile them."
|
|
68
|
+
end
|
|
69
|
+
parts << "If none of these help, retry with fewer or other-language terms (the TR/EN Keywords: lines), " \
|
|
70
|
+
"record the knowledge, or queue a digest."
|
|
71
|
+
parts << "Read a full record with read_file(path: '<uri above>')." unless relaxed.empty?
|
|
72
|
+
parts.join("\n")
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def first_body_line(record)
|
|
76
|
+
slice = record["body"].to_s.lines.map(&:strip).reject(&:empty?).first.to_s.slice(0, RECALL_BODY_SLICE)
|
|
77
|
+
slice.empty? ? "(no body)" : slice
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def recall_line(store, record) = "- #{record['title']} [#{record['id']}] #{first_body_line(record)} — #{store.uri_for(record['type'], record['id'])}"
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -89,6 +89,7 @@ require_relative "vakanuvis/annal_writer"
|
|
|
89
89
|
require_relative "vakanuvis/memory_steward"
|
|
90
90
|
require_relative "vakanuvis/wiki_skeleton"
|
|
91
91
|
require_relative "vakanuvis/distill_gate"
|
|
92
|
+
require_relative "vakanuvis/recall"
|
|
92
93
|
require_relative "vakanuvis/job"
|
|
93
94
|
require_relative "vakanuvis/gate"
|
|
94
95
|
require_relative "vakanuvis/harness"
|
data/lib/rubik/tools/base.rb
CHANGED
|
@@ -42,6 +42,40 @@ module Rubik
|
|
|
42
42
|
raise NotImplementedError
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
# One home for model-supplied argument access: every builtin used to
|
|
46
|
+
# re-roll the string/symbol key
|
|
47
|
+
# normalization (and its coercion) by hand — ~110 sites. Lookup
|
|
48
|
+
# semantics, kept byte-compatible with the old hand-rolled chains:
|
|
49
|
+
# keys are tried in order, string key before symbol key per key;
|
|
50
|
+
# first non-nil wins (false falls through like nil, matching the
|
|
51
|
+
# ||-chains). When `type:`
|
|
52
|
+
# is given the coercion applies to the resolved value AND to
|
|
53
|
+
# `default:` (so `type: :integer` on an absent key still yields 0,
|
|
54
|
+
# matching the old `(args[k] || args[sk]).to_i` idiom).
|
|
55
|
+
#
|
|
56
|
+
# param(args, :path, type: :stripped_string, default: "")
|
|
57
|
+
# param(args, :offset, type: :integer)
|
|
58
|
+
# param(args, :target_content, :old_content, :old_str, :target) # alias chain
|
|
59
|
+
# param(args, :reload, type: :flag) # == true
|
|
60
|
+
def param(args, *keys, type: nil, default: nil)
|
|
61
|
+
raw = nil
|
|
62
|
+
if args
|
|
63
|
+
keys.each do |key|
|
|
64
|
+
str = key.to_s
|
|
65
|
+
raw = args[str] || args[str.to_sym]
|
|
66
|
+
break unless raw.nil?
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
value = raw.nil? ? default : raw
|
|
70
|
+
case type
|
|
71
|
+
when :integer then value.to_i
|
|
72
|
+
when :string then value.to_s
|
|
73
|
+
when :stripped_string then value.to_s.strip
|
|
74
|
+
when :flag then value == true
|
|
75
|
+
else value
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
45
79
|
# Normalizes a model-supplied path filter against the tool's root
|
|
46
80
|
# directory: backslashes become slashes, "./" is stripped, and ABSOLUTE
|
|
47
81
|
# paths (C:/…, /…) are relativized when they sit inside the root.
|
|
@@ -42,6 +42,12 @@ module Rubik
|
|
|
42
42
|
@runtime_context = runtime_context
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
# Subagent-plane rebind (ScopedRegistry delegate): definitions register
|
|
46
|
+
# against the INSTANCE's supervisor, not the root turn's.
|
|
47
|
+
def rebind_to(ctx)
|
|
48
|
+
self.class.new(supervisor: resolve_supervisor(nil, ctx), runtime_context: ctx)
|
|
49
|
+
end
|
|
50
|
+
|
|
45
51
|
def execute(args = {})
|
|
46
52
|
sup = resolve_supervisor(@supervisor, @runtime_context)
|
|
47
53
|
return ToolOutput.error("SubagentSupervisor is not available in runtime context.") unless sup
|
|
@@ -51,10 +51,10 @@ module Rubik
|
|
|
51
51
|
ring = resolve_dmesg
|
|
52
52
|
return ToolOutput.error("Dmesg ring buffer is not available in runtime context.") unless ring
|
|
53
53
|
|
|
54
|
-
limit = (args
|
|
55
|
-
level = args
|
|
56
|
-
subsystem = args
|
|
57
|
-
since_seq = args
|
|
54
|
+
limit = param(args, :limit, type: :integer, default: 30)
|
|
55
|
+
level = param(args, :level)
|
|
56
|
+
subsystem = param(args, :subsystem)
|
|
57
|
+
since_seq = param(args, :since_seq)
|
|
58
58
|
|
|
59
59
|
records = ring.tail(limit, level: level, subsystem: subsystem, since_seq: since_seq)
|
|
60
60
|
return "No kernel events found matching criteria." if records.empty?
|
|
@@ -15,7 +15,7 @@ module Rubik
|
|
|
15
15
|
DECLARATION = Declaration.new(
|
|
16
16
|
name: "read_file", aliases: ["view_file", "read"],
|
|
17
17
|
description: "Read content of a file from buffer or disk with 1-based line numbers (optional 1-based offset and line limit for paging)",
|
|
18
|
-
risk: :read, archetypes: [:research, :coder],
|
|
18
|
+
risk: :read, archetypes: [:research, :coder], buffer_bound: true,
|
|
19
19
|
params_schema: {
|
|
20
20
|
type: "object",
|
|
21
21
|
properties: {
|
|
@@ -41,7 +41,7 @@ module Rubik
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def execute(args = {})
|
|
44
|
-
path = (args
|
|
44
|
+
path = param(args, :path, type: :stripped_string)
|
|
45
45
|
# rubik:// sevk tek yerde: UriResolver (bilinmeyen şema/gramer reddi
|
|
46
46
|
# nil döndürür ve buffer düzlemine düşer — bugünkü düşüş sözleşmesi).
|
|
47
47
|
virt = UriResolver.resolve(path, ctx: @runtime_context, buffer_manager: @buffer_manager)
|
|
@@ -52,9 +52,9 @@ module Rubik
|
|
|
52
52
|
path = clean.sub(%r{\A/([A-Za-z]:)}, '\1')
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
content = if args
|
|
55
|
+
content = if param(args, :reload, type: :flag)
|
|
56
56
|
@buffer_manager.read(path, reload: true)
|
|
57
|
-
elsif args
|
|
57
|
+
elsif param(args, :from_disk, type: :flag)
|
|
58
58
|
@buffer_manager.read(path, from_disk: true)
|
|
59
59
|
else
|
|
60
60
|
@buffer_manager.read(path)
|
|
@@ -66,8 +66,8 @@ module Rubik
|
|
|
66
66
|
return ToolOutput.error(DiagnosticReporter.render_file_not_found(path, candidates: candidates))
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
offset = (args
|
|
70
|
-
limit = (args
|
|
69
|
+
offset = param(args, :offset, type: :integer)
|
|
70
|
+
limit = param(args, :limit, type: :integer)
|
|
71
71
|
lines = content.lines
|
|
72
72
|
return "[empty file (0 lines)]" if lines.empty?
|
|
73
73
|
|
|
@@ -90,7 +90,7 @@ module Rubik
|
|
|
90
90
|
description: "Write full content to the in-memory buffer (does not write to disk until apply_buffer is called). " \
|
|
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
|
-
risk: :write, archetypes: [:coder], write_grant: true, maestro_blocked: true,
|
|
93
|
+
risk: :write, archetypes: [:coder], write_grant: true, maestro_blocked: true, buffer_bound: true,
|
|
94
94
|
params_schema: {
|
|
95
95
|
type: "object",
|
|
96
96
|
properties: {
|
|
@@ -106,8 +106,8 @@ module Rubik
|
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
def execute(args = {})
|
|
109
|
-
path = (args
|
|
110
|
-
content = args
|
|
109
|
+
path = param(args, :path, type: :stripped_string)
|
|
110
|
+
content = param(args, :content)
|
|
111
111
|
|
|
112
112
|
return ToolOutput.error("Error: `path` parameter is required.") if path.empty?
|
|
113
113
|
unless Rubik::Buffer::PathValidator.valid?(path)
|
|
@@ -170,8 +170,8 @@ module Rubik
|
|
|
170
170
|
end
|
|
171
171
|
|
|
172
172
|
def execute(args = {})
|
|
173
|
-
path_filter = args
|
|
174
|
-
ext_filter = args
|
|
173
|
+
path_filter = param(args, :path)
|
|
174
|
+
ext_filter = param(args, :extension)
|
|
175
175
|
idx = context_index
|
|
176
176
|
return ToolOutput.error(IndexMessages::INDEX_UNAVAILABLE_MESSAGE) unless idx
|
|
177
177
|
|
|
@@ -236,7 +236,7 @@ module Rubik
|
|
|
236
236
|
name: "replace_file_content", aliases: ["edit_file", "edit_chunk", "str_replace", "patch_file"],
|
|
237
237
|
description: "Replace an exact chunk of code within an existing file. Requires exact verbatim matching of target_content " \
|
|
238
238
|
"(including whitespace and indentation). Optional start_line and end_line narrow the search range.",
|
|
239
|
-
risk: :write, archetypes: [:coder], write_grant: true, maestro_blocked: true,
|
|
239
|
+
risk: :write, archetypes: [:coder], write_grant: true, maestro_blocked: true, buffer_bound: true,
|
|
240
240
|
params_schema: {
|
|
241
241
|
type: "object",
|
|
242
242
|
properties: {
|
|
@@ -258,18 +258,12 @@ module Rubik
|
|
|
258
258
|
end
|
|
259
259
|
|
|
260
260
|
def execute(args = {})
|
|
261
|
-
path = (args
|
|
262
|
-
target = args
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
args["new_content"] || args[:new_content] ||
|
|
268
|
-
args["new_str"] || args[:new_str] ||
|
|
269
|
-
args["replacement"] || args[:replacement]
|
|
270
|
-
start_line = args["start_line"] || args[:start_line]
|
|
271
|
-
end_line = args["end_line"] || args[:end_line]
|
|
272
|
-
allow_multiple = args["allow_multiple"] == true || args[:allow_multiple] == true
|
|
261
|
+
path = param(args, :path, type: :stripped_string)
|
|
262
|
+
target = param(args, :target_content, :old_content, :old_str, :target)
|
|
263
|
+
replacement = param(args, :replacement_content, :new_content, :new_str, :replacement)
|
|
264
|
+
start_line = param(args, :start_line)
|
|
265
|
+
end_line = param(args, :end_line)
|
|
266
|
+
allow_multiple = param(args, :allow_multiple, type: :flag)
|
|
273
267
|
|
|
274
268
|
return ToolOutput.error("Error: `path` parameter is required.") if path.empty?
|
|
275
269
|
return ToolOutput.error("Error: `target_content` parameter is required.") if target.nil?
|
|
@@ -27,7 +27,7 @@ module Rubik
|
|
|
27
27
|
"filesystem and it FAILED (the world drifted): re-inspect reality, then update the " \
|
|
28
28
|
"entry (including status) with a normal patch — a stale rev also means the ledger " \
|
|
29
29
|
"moved under you.",
|
|
30
|
-
risk: :write, archetypes: [], write_grant: false,
|
|
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: {
|
|
33
33
|
type: "object",
|
|
@@ -56,22 +56,22 @@ module Rubik
|
|
|
56
56
|
# Scrub before strip-driven string ops and result interpolation: an
|
|
57
57
|
# invalid-UTF-8 query (model transcription artifact) must not raise
|
|
58
58
|
# or leak broken bytes into the rendered tool output.
|
|
59
|
-
query = Rubik::Platform.safe_utf8((args
|
|
59
|
+
query = Rubik::Platform.safe_utf8(param(args, :query, type: :string)).strip
|
|
60
60
|
return ToolOutput.error("Query parameter is required.") if query.empty?
|
|
61
61
|
|
|
62
|
-
path_filter = (args
|
|
63
|
-
ext_filter = (args
|
|
62
|
+
path_filter = param(args, :path, type: :stripped_string)
|
|
63
|
+
ext_filter = param(args, :extension, type: :stripped_string)
|
|
64
64
|
|
|
65
65
|
path_filter, outside_error = BaseTool.normalize_path_filter(path_filter, @root_dir)
|
|
66
66
|
if outside_error
|
|
67
67
|
allowed = [{ path: @root_dir, primary: true }]
|
|
68
68
|
idx = context_index
|
|
69
69
|
idx.additional_roots.each { |r| allowed << { path: r, primary: false } } if idx.respond_to?(:additional_roots)
|
|
70
|
-
return ToolOutput.error(DiagnosticReporter.render_traversal_blocked(args
|
|
70
|
+
return ToolOutput.error(DiagnosticReporter.render_traversal_blocked(param(args, :path), allowed_roots: allowed))
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
case_sensitive = args
|
|
74
|
-
max_results = (args
|
|
73
|
+
case_sensitive = param(args, :case_sensitive, default: false)
|
|
74
|
+
max_results = param(args, :max_results, type: :integer, default: 50)
|
|
75
75
|
max_results = 50 if max_results <= 0
|
|
76
76
|
|
|
77
77
|
regex = regex_for(query, case_sensitive)
|
|
@@ -54,6 +54,12 @@ module Rubik
|
|
|
54
54
|
@runtime_context = runtime_context
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
# Subagent-plane rebind (ScopedRegistry delegate): a worker never pops a
|
|
58
|
+
# HUMAN dialog — it asks the maestro supervisor through the child ctx.
|
|
59
|
+
def rebind_to(ctx)
|
|
60
|
+
self.class.new(shell: nil, runtime_context: ctx)
|
|
61
|
+
end
|
|
62
|
+
|
|
57
63
|
def execute(args = {})
|
|
58
64
|
raw_questions = args["questions"] || args[:questions]
|
|
59
65
|
raw_questions = [args] if raw_questions.nil? && (args["question"] || args[:question])
|
|
@@ -16,7 +16,7 @@ module Rubik
|
|
|
16
16
|
DECLARATION = Declaration.new(
|
|
17
17
|
name: "apply_buffer", aliases: ["save_buffer", "commit_changes", "save"],
|
|
18
18
|
description: "Persist all pending in-memory file buffer modifications to disk immediately (skips files with external conflicts unless force: true)",
|
|
19
|
-
risk: :write, archetypes: [:coder], write_grant: true, maestro_blocked: false,
|
|
19
|
+
risk: :write, archetypes: [:coder], write_grant: true, maestro_blocked: false, buffer_bound: true,
|
|
20
20
|
params_schema: {
|
|
21
21
|
type: "object",
|
|
22
22
|
properties: {
|
|
@@ -357,6 +357,7 @@ module Rubik
|
|
|
357
357
|
"(file lists, counts, command outcomes) against your raw command output — context " \
|
|
358
358
|
"compaction can blur report details, and the final report must match observed evidence.",
|
|
359
359
|
risk: :execute, maestro_blocked: false, # the completion signal — handled before the gate; must stay direct
|
|
360
|
+
terminal: true, # dispatch planes route it before gates/malformed-args handling (Catalog.terminal?)
|
|
360
361
|
params_schema: { type: "object",
|
|
361
362
|
properties: { message: { type: "string",
|
|
362
363
|
description: "Final summary message for the user describing what was accomplished (optional)" } } }
|
|
@@ -27,7 +27,7 @@ module Rubik
|
|
|
27
27
|
"preserved): 'prune' (queue a forced prune now; returns a deterministic receipt, " \
|
|
28
28
|
"never blocks on the LLM), 'status' (window estimate vs ceiling, staged plan " \
|
|
29
29
|
"state, last receipt).",
|
|
30
|
-
risk: :write, archetypes: [], write_grant: false,
|
|
30
|
+
risk: :write, archetypes: [], write_grant: false, root_only: true,
|
|
31
31
|
maestro_blocked: false, # vakanüvis emsali: budayıcı düzlemi kökte doğrudan
|
|
32
32
|
params_schema: {
|
|
33
33
|
type: "object",
|
|
@@ -35,6 +35,12 @@ module Rubik
|
|
|
35
35
|
@runtime_context = runtime_context
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
# Subagent-plane rebind (ScopedRegistry delegate): the subagent-plane
|
|
39
|
+
# message must carry its REAL sender id to the maestro.
|
|
40
|
+
def rebind_to(ctx)
|
|
41
|
+
self.class.new(supervisor: resolve_supervisor(nil, ctx), runtime_context: ctx)
|
|
42
|
+
end
|
|
43
|
+
|
|
38
44
|
def execute(args = {})
|
|
39
45
|
sup = resolve_supervisor(@supervisor, @runtime_context)
|
|
40
46
|
return ToolOutput.error("SubagentSupervisor is not available in runtime context.") unless sup
|