rubik 0.9.1 → 0.11.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 +203 -1
- data/lib/rubik/adapter/base.rb +2 -1
- data/lib/rubik/adapter/process.rb +28 -67
- data/lib/rubik/ast/extractor.rb +2 -1
- data/lib/rubik/ast/treesitter_extractor.rb +2 -1
- data/lib/rubik/benchmark/vakanuvis_adoption.rb +12 -4
- 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 +198 -0
- data/lib/rubik/config/store.rb +2 -1
- data/lib/rubik/config.rb +13 -2
- data/lib/rubik/context/ignore_rules.rb +193 -0
- data/lib/rubik/context/scanner.rb +46 -161
- 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/client.rb +6 -200
- data/lib/rubik/llm/connection_pool.rb +104 -0
- data/lib/rubik/llm/registry.rb +13 -9
- data/lib/rubik/llm/router.rb +2 -5
- data/lib/rubik/llm/sse_parser.rb +110 -0
- data/lib/rubik/log.rb +21 -0
- data/lib/rubik/lsp/circuit_breaker.rb +98 -0
- data/lib/rubik/lsp/client.rb +77 -273
- data/lib/rubik/lsp/client_provisioner.rb +49 -0
- data/lib/rubik/lsp/manager.rb +67 -96
- 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 +55 -166
- data/lib/rubik/mcp/transport/stdio.rb +4 -1
- data/lib/rubik/orchestrator/auto_apply.rb +8 -6
- data/lib/rubik/orchestrator/continuation_manager.rb +3 -22
- data/lib/rubik/orchestrator/goal_ledger/ledger.rb +12 -1
- data/lib/rubik/orchestrator/goal_ledger/schema_vocabulary.rb +38 -0
- data/lib/rubik/orchestrator/goal_ledger/xml_render.rb +6 -1
- data/lib/rubik/orchestrator/goal_ledger.rb +1 -0
- data/lib/rubik/orchestrator/goal_session.rb +53 -39
- data/lib/rubik/orchestrator/loop.rb +28 -47
- data/lib/rubik/orchestrator/lsp_feedback.rb +1 -1
- 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/step_executor.rb +2 -1
- 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/notices.rb +2 -2
- 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/transcript_formatter.rb +2 -1
- 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 +5 -2
- 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/plugin/storage.rb +8 -8
- 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 +8 -6
- data/lib/rubik/repl/hooks.rb +2 -1
- data/lib/rubik/repl/input_execution.rb +162 -79
- data/lib/rubik/repl/input_loop.rb +2 -1
- data/lib/rubik/repl/lifecycle.rb +60 -210
- 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/tee_io.rb +2 -1
- data/lib/rubik/repl/turn_recorder.rb +6 -5
- data/lib/rubik/runtime/ast_service.rb +2 -1
- 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 +109 -163
- data/lib/rubik/runtime/task_manager.rb +64 -25
- data/lib/rubik/sandbox/driver/docker.rb +5 -1
- data/lib/rubik/sandbox/runner.rb +21 -19
- data/lib/rubik/security/audit_log.rb +2 -1
- data/lib/rubik/security/command_gate.rb +126 -243
- data/lib/rubik/security/guard.rb +7 -3
- data/lib/rubik/security/secret_store.rb +492 -0
- data/lib/rubik/security/segment_report.rb +161 -0
- data/lib/rubik/security/synthesis_gate.rb +8 -11
- data/lib/rubik/session/manager.rb +7 -1
- data/lib/rubik/session/recorder.rb +2 -1
- data/lib/rubik/skills/manager.rb +4 -4
- data/lib/rubik/storage/search.rb +49 -0
- data/lib/rubik/storage/store.rb +13 -20
- data/lib/rubik/storage/transcript_indexer.rb +3 -2
- data/lib/rubik/storage/vakanuvis/harness.rb +2 -3
- data/lib/rubik/storage/vakanuvis.rb +2 -1
- data/lib/rubik/tools/base.rb +22 -0
- data/lib/rubik/tools/builtins/files.rb +3 -15
- data/lib/rubik/tools/builtins/goal_ledger.rb +12 -1
- data/lib/rubik/tools/builtins/grep.rb +1 -6
- data/lib/rubik/tools/builtins/lifecycle.rb +6 -5
- data/lib/rubik/tools/builtins/synthesis.rb +3 -3
- data/lib/rubik/tools/lifecycle_rollbacks.rb +14 -1
- data/lib/rubik/tools/preflight_runner.rb +2 -1
- data/lib/rubik/tools/truncator.rb +48 -36
- data/lib/rubik/tools/uri_resolver.rb +3 -2
- data/lib/rubik/ui/banner.rb +4 -3
- data/lib/rubik/ui/capability.rb +1 -0
- 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 +4 -5
- metadata +20 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "English"
|
|
3
4
|
require "fileutils"
|
|
4
5
|
require "json"
|
|
6
|
+
require_relative "../log"
|
|
5
7
|
require_relative "replayer"
|
|
6
8
|
require_relative "../llm/message_sanitizer"
|
|
7
9
|
require_relative "../prompt/context_compactor"
|
|
@@ -160,7 +162,11 @@ module Rubik
|
|
|
160
162
|
|
|
161
163
|
begin
|
|
162
164
|
event = JSON.parse(line)
|
|
163
|
-
rescue JSON::ParserError
|
|
165
|
+
rescue JSON::ParserError => e
|
|
166
|
+
# A corrupt line is dropped from the replayed history — say so
|
|
167
|
+
# instead of losing the row in silence (persistence-path
|
|
168
|
+
# honesty; partial writes after a crash are the normal cause).
|
|
169
|
+
Rubik::Log.warn(:session, "session restore: dropping unparseable line #{$INPUT_LINE_NUMBER} from #{session_file} (#{e.class}: #{e.message.to_s.chars.first(80).join})")
|
|
164
170
|
next
|
|
165
171
|
end
|
|
166
172
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require "json"
|
|
4
4
|
require "fileutils"
|
|
5
5
|
require "time"
|
|
6
|
+
require_relative "../log"
|
|
6
7
|
require_relative "../platform"
|
|
7
8
|
require_relative "../security/redactor"
|
|
8
9
|
|
|
@@ -20,7 +21,7 @@ module Rubik
|
|
|
20
21
|
begin
|
|
21
22
|
FileUtils.mkdir_p(@sessions_dir)
|
|
22
23
|
rescue SystemCallError => e
|
|
23
|
-
warn "[WARN] Failed to create sessions directory #{@sessions_dir}: #{e.message}" if ENV["RUBIK_DEBUG"]
|
|
24
|
+
Rubik::Log.warn(:session, "[WARN] Failed to create sessions directory #{@sessions_dir}: #{e.message}") if ENV["RUBIK_DEBUG"]
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
filename = session_name || "session_#{Time.now.strftime('%Y%m%d_%H%M%S')}_#{Process.pid}_#{(Time.now.to_f * 1000).to_i % 1000}.jsonl"
|
data/lib/rubik/skills/manager.rb
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "monitor"
|
|
4
|
+
require_relative "../log"
|
|
4
5
|
require_relative "frontmatter"
|
|
6
|
+
require_relative "../storage/layout"
|
|
5
7
|
require_relative "storage"
|
|
6
8
|
require_relative "registry"
|
|
7
9
|
|
|
@@ -117,7 +119,7 @@ module Rubik
|
|
|
117
119
|
result.issues.each { |issue| Rubik::Platform.debug_warn("skill #{issue.path}: #{issue.field} #{issue.message}") }
|
|
118
120
|
true
|
|
119
121
|
rescue StandardError => e
|
|
120
|
-
warn "[rubik] skills reload failed (previous snapshot kept): #{e.class}: #{e.message}"
|
|
122
|
+
Rubik::Log.warn(:skills, "[rubik] skills reload failed (previous snapshot kept): #{e.class}: #{e.message}")
|
|
121
123
|
false
|
|
122
124
|
end
|
|
123
125
|
|
|
@@ -208,9 +210,7 @@ module Rubik
|
|
|
208
210
|
# fetch-with-default without the `|| default` idiom: an explicit
|
|
209
211
|
# config value of false/nil must survive (see Loop#safe_config hazard).
|
|
210
212
|
def fetch(key, default)
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
@config.fetch(key, default)
|
|
213
|
+
Rubik::Storage::Layout.config_get(@config, key, default)
|
|
214
214
|
end
|
|
215
215
|
|
|
216
216
|
# Encoding hygiene for File.read output reaching the model/history
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "folding"
|
|
4
|
+
|
|
5
|
+
module Rubik
|
|
6
|
+
module Storage
|
|
7
|
+
# The single home of the search scoring pipeline's pure text layer
|
|
8
|
+
# (issue #473): tokenization, haystack construction, per-record folded
|
|
9
|
+
# fields and the token-AND candidate gate. Every function here is pure
|
|
10
|
+
# over its inputs — no I/O, no cache, no Store state — so the scoring
|
|
11
|
+
# path is unit-testable without the filesystem. Store keeps persistence,
|
|
12
|
+
# the shared @records_cache memoization and corpus assembly; Ranking
|
|
13
|
+
# owns the BM25-lite math; Search owns everything that feeds it.
|
|
14
|
+
module Search
|
|
15
|
+
module_function
|
|
16
|
+
|
|
17
|
+
# Sorgu katlaması + tokenizasyonu (Folding.fold — TR I-sınıfı dahil
|
|
18
|
+
# tek katlama kuralı, folding.rb). Token-AND semantiğinin girdisi:
|
|
19
|
+
# her boşlukla ayrılmış terim, kaydın samanlığında geçmeli. Tek
|
|
20
|
+
# substring araması "ratelimit-lock regression 11/11" gibi doğal çok
|
|
21
|
+
# kelimeli sorguları 0 sonuçla bıraktığı için terimlere bölünür
|
|
22
|
+
# (js-tangram olay raporu 2026-10-04, olay #2); tek terimli sorgular
|
|
23
|
+
# eski davranışın birebir aynısı.
|
|
24
|
+
def tokens(query)
|
|
25
|
+
Folding.fold(query).split
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Arama samanlığı: title+body+tags, tek katlama. Kayıt kümesi
|
|
29
|
+
# paylaşımlı/frozen olduğundan sonuç da mutasyona kapalıdır
|
|
30
|
+
# (include?/scan/bytesize mutasyon yapmaz).
|
|
31
|
+
def haystack_of(record)
|
|
32
|
+
Folding.fold("#{record['title']}\n#{record['body']}\n#{Array(record['tags']).join("\n")}")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Sıralama katmanı için kayıt başına katlanmış [başlık, etiket] çifti
|
|
36
|
+
# (Ranking#field_tier_bonus'un alan kademeli bonus girdisi).
|
|
37
|
+
def folded_fields_of(record)
|
|
38
|
+
[Folding.fold(record["title"]), Folding.fold(Array(record["tags"]).join("\n"))]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Token-AND aday üretimi: her terim kaydın samanlığında geçmeli.
|
|
42
|
+
# Kayıt ve samanlık dizileri aynı sırada (each_index hizalı) olmalıdır;
|
|
43
|
+
# eşleşen kayıtların indekslerini döndürür.
|
|
44
|
+
def matching_indices(records, haystacks, tokens)
|
|
45
|
+
records.each_index.select { |i| tokens.all? { |token| haystacks[i].include?(token) } }
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
data/lib/rubik/storage/store.rb
CHANGED
|
@@ -10,6 +10,7 @@ require_relative "../uris"
|
|
|
10
10
|
require_relative "layout"
|
|
11
11
|
require_relative "folding"
|
|
12
12
|
require_relative "ranking"
|
|
13
|
+
require_relative "search"
|
|
13
14
|
|
|
14
15
|
module Rubik
|
|
15
16
|
module Storage
|
|
@@ -129,16 +130,16 @@ module Rubik
|
|
|
129
130
|
# kelimeli sorgular kelimesi kelimesine eşleşmediği için 0 sonuç
|
|
130
131
|
# dönüyordu (js-tangram olay raporu 2026-10-04, olay #2 — "indeks
|
|
131
132
|
# bayatlığı" değil, eşleştirme semantiğiydi). Tek terimli sorgular
|
|
132
|
-
# eski davranışın birebir aynısı.
|
|
133
|
-
|
|
133
|
+
# eski davranışın birebir aynısı. Tokenizasyon ve AND eşiği
|
|
134
|
+
# Search'te (issue #473) — burada yalnız corpus montajı.
|
|
135
|
+
tokens = Search.tokens(query)
|
|
134
136
|
return [] if tokens.empty?
|
|
135
137
|
|
|
136
138
|
@monitor.synchronize do
|
|
137
139
|
matched = resolve_types(type).flat_map do |t|
|
|
138
140
|
records = load_records(t)
|
|
139
141
|
haystacks = haystacks_for(t, records)
|
|
140
|
-
records
|
|
141
|
-
.map { |i| records[i] }
|
|
142
|
+
Search.matching_indices(records, haystacks, tokens).map { |i| records[i] }
|
|
142
143
|
end
|
|
143
144
|
matched.sort_by { |r| [r["type"].to_s, r["row"].to_i] }
|
|
144
145
|
end
|
|
@@ -159,7 +160,7 @@ module Rubik
|
|
|
159
160
|
# (herhangi bir terimi taşıyan kayıt) — fallback recall içindir;
|
|
160
161
|
# skorlama iki ducte de aynıdır, default davranış birebir korunur.
|
|
161
162
|
def search_ranked(query:, type: nil, require_all: true)
|
|
162
|
-
tokens =
|
|
163
|
+
tokens = Search.tokens(query)
|
|
163
164
|
return [] if tokens.empty?
|
|
164
165
|
|
|
165
166
|
@monitor.synchronize do
|
|
@@ -358,31 +359,23 @@ module Rubik
|
|
|
358
359
|
# tek katlama kuralı, folding.rb): parse cache girdisinde tembel
|
|
359
360
|
# memoize edilir — sorgu başına 1 MB'lık dizgi kurulumu tekrarlamaz.
|
|
360
361
|
# Kayıt kümesi paylaşımlı olduğundan samanlıklar da dondurulmuş
|
|
361
|
-
# paylaşılır (include?/scan/bytesize mutasyon yapmaz).
|
|
362
|
+
# paylaşılır (include?/scan/bytesize mutasyon yapmaz). Samanlık
|
|
363
|
+
# kurulumu Search'te (issue #473) — burada yalnız sorgu başına
|
|
364
|
+
# memoize disiplini.
|
|
362
365
|
def haystacks_for(type, records)
|
|
363
366
|
entry = @records_cache[type]
|
|
364
|
-
return records.map { |r| haystack_of(r) } unless entry
|
|
367
|
+
return records.map { |r| Search.haystack_of(r) } unless entry
|
|
365
368
|
|
|
366
|
-
entry[:haystacks] ||= records.map { |r| haystack_of(r) }.freeze
|
|
369
|
+
entry[:haystacks] ||= records.map { |r| Search.haystack_of(r) }.freeze
|
|
367
370
|
end
|
|
368
371
|
|
|
369
372
|
# PERF: Memoize folded title and tags per record in @records_cache
|
|
370
373
|
# to avoid re-folding and array joining on every search_ranked query.
|
|
371
374
|
def folded_fields_for(type, records)
|
|
372
375
|
entry = @records_cache[type]
|
|
373
|
-
unless entry
|
|
374
|
-
return records.map do |r|
|
|
375
|
-
[Folding.fold(r["title"]), Folding.fold(Array(r["tags"]).join("\n"))]
|
|
376
|
-
end
|
|
377
|
-
end
|
|
378
|
-
|
|
379
|
-
entry[:folded_fields] ||= records.map do |r|
|
|
380
|
-
[Folding.fold(r["title"]), Folding.fold(Array(r["tags"]).join("\n"))].freeze
|
|
381
|
-
end.freeze
|
|
382
|
-
end
|
|
376
|
+
return records.map { |r| Search.folded_fields_of(r) } unless entry
|
|
383
377
|
|
|
384
|
-
|
|
385
|
-
Folding.fold("#{record['title']}\n#{record['body']}\n#{Array(record['tags']).join("\n")}")
|
|
378
|
+
entry[:folded_fields] ||= records.map { |r| Search.folded_fields_of(r).freeze }.freeze
|
|
386
379
|
end
|
|
387
380
|
|
|
388
381
|
def resolve_types(type)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "json"
|
|
4
|
+
require_relative "../log"
|
|
4
5
|
require_relative "../security/redactor"
|
|
5
6
|
require_relative "../tools/truncator"
|
|
6
7
|
require_relative "../uris"
|
|
@@ -57,7 +58,7 @@ module Rubik
|
|
|
57
58
|
)
|
|
58
59
|
rescue StandardError => e
|
|
59
60
|
label = inst.respond_to?(:id) ? inst.id : inst.class
|
|
60
|
-
warn "[Storage] transcript index failed for #{label}: #{e.class}: #{e.message}"
|
|
61
|
+
Rubik::Log.warn(:storage, "[Storage] transcript index failed for #{label}: #{e.class}: #{e.message}")
|
|
61
62
|
end
|
|
62
63
|
|
|
63
64
|
# Task: transcript dosyasındaki İLK user satırı (seed'deki brif);
|
|
@@ -106,7 +107,7 @@ module Rubik
|
|
|
106
107
|
end
|
|
107
108
|
nil
|
|
108
109
|
rescue StandardError => e
|
|
109
|
-
warn "[Storage] transcript task read failed for #{file}: #{e.class}: #{e.message}"
|
|
110
|
+
Rubik::Log.warn(:storage, "[Storage] transcript task read failed for #{file}: #{e.class}: #{e.message}")
|
|
110
111
|
nil
|
|
111
112
|
end
|
|
112
113
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require "monitor"
|
|
4
4
|
require_relative "../../concurrency"
|
|
5
5
|
require_relative "../../events"
|
|
6
|
+
require_relative "../layout"
|
|
6
7
|
|
|
7
8
|
module Rubik
|
|
8
9
|
module Storage
|
|
@@ -103,8 +104,6 @@ module Rubik
|
|
|
103
104
|
Recall.recall(@store, query, types: types)
|
|
104
105
|
end
|
|
105
106
|
|
|
106
|
-
def auto_digest? = @auto_digest
|
|
107
|
-
|
|
108
107
|
def touched_topics = @monitor.synchronize { @touched_topics.to_a }
|
|
109
108
|
|
|
110
109
|
# record tool thread'inden, sweep worker'dan koşar — get-then-put
|
|
@@ -355,7 +354,7 @@ module Rubik
|
|
|
355
354
|
def event_key(payload) = "subagent.#{payload[:storage_id].to_s.empty? ? payload[:id] : payload[:storage_id]}.#{payload[:state]}"
|
|
356
355
|
|
|
357
356
|
def fetch_cfg(key, default)
|
|
358
|
-
|
|
357
|
+
Rubik::Storage::Layout.config_get(@config, key, default)
|
|
359
358
|
end
|
|
360
359
|
end
|
|
361
360
|
end
|
|
@@ -58,7 +58,7 @@ module Rubik
|
|
|
58
58
|
begin
|
|
59
59
|
Rubik::Log.warn(SUBSYSTEM, message)
|
|
60
60
|
rescue StandardError
|
|
61
|
-
warn(
|
|
61
|
+
Rubik::Log.warn(:vakanuvis, message.to_s)
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
|
|
@@ -84,6 +84,7 @@ module Rubik
|
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
+
require_relative "../log"
|
|
87
88
|
require_relative "vakanuvis/vocabulary"
|
|
88
89
|
require_relative "vakanuvis/annal_writer"
|
|
89
90
|
require_relative "vakanuvis/memory_steward"
|
data/lib/rubik/tools/base.rb
CHANGED
|
@@ -172,6 +172,28 @@ module Rubik
|
|
|
172
172
|
"No matching files found for '#{filter}'.#{hint}"
|
|
173
173
|
end
|
|
174
174
|
|
|
175
|
+
# One home for the traversal-refusal disclosure used by the index
|
|
176
|
+
# filter tools (list_files, grep_search): renders the blocked message
|
|
177
|
+
# with the tool's root as the primary allowed root plus the context
|
|
178
|
+
# index's additional roots, so the honest-disclosure list cannot
|
|
179
|
+
# drift between tools. `context_index` may be nil (index unavailable)
|
|
180
|
+
# or a duck-typed double without additional_roots.
|
|
181
|
+
def self.traversal_blocked_message(path, root_dir, context_index)
|
|
182
|
+
allowed = [{ path: root_dir, primary: true }]
|
|
183
|
+
context_index.additional_roots.each { |r| allowed << { path: r, primary: false } } if context_index.respond_to?(:additional_roots)
|
|
184
|
+
DiagnosticReporter.render_traversal_blocked(path, allowed_roots: allowed)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# One home for the fuzzy file-not-found disclosure used by the
|
|
188
|
+
# buffer-bound tools (read_file, replace_file_content): suggests the
|
|
189
|
+
# closest known files by basename match. The respond_to?(:all_files)
|
|
190
|
+
# guard keeps test doubles without the file indexer honest.
|
|
191
|
+
def self.file_not_found_message(buffer_manager, path)
|
|
192
|
+
known_files = buffer_manager.respond_to?(:all_files) ? buffer_manager.all_files : []
|
|
193
|
+
candidates = FuzzyMatcher.best_matches(File.basename(path), known_files.map { |f| File.basename(f) })
|
|
194
|
+
DiagnosticReporter.render_file_not_found(path, candidates: candidates)
|
|
195
|
+
end
|
|
196
|
+
|
|
175
197
|
def to_h
|
|
176
198
|
schema = @params_schema
|
|
177
199
|
if !@allow_additional_properties && schema.is_a?(Hash)
|
|
@@ -60,11 +60,7 @@ module Rubik
|
|
|
60
60
|
@buffer_manager.read(path)
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
unless content
|
|
64
|
-
known_files = @buffer_manager.respond_to?(:all_files) ? @buffer_manager.all_files : []
|
|
65
|
-
candidates = FuzzyMatcher.best_matches(File.basename(path), known_files.map { |f| File.basename(f) })
|
|
66
|
-
return ToolOutput.error(DiagnosticReporter.render_file_not_found(path, candidates: candidates))
|
|
67
|
-
end
|
|
63
|
+
return ToolOutput.error(BaseTool.file_not_found_message(@buffer_manager, path)) unless content
|
|
68
64
|
|
|
69
65
|
offset = param(args, :offset, type: :integer)
|
|
70
66
|
limit = param(args, :limit, type: :integer)
|
|
@@ -177,11 +173,7 @@ module Rubik
|
|
|
177
173
|
return ToolOutput.error(IndexMessages::INDEX_UNAVAILABLE_MESSAGE) unless idx
|
|
178
174
|
|
|
179
175
|
filter, error = BaseTool.normalize_path_filter(path_filter, @root_dir)
|
|
180
|
-
if error
|
|
181
|
-
allowed = [{ path: @root_dir, primary: true }]
|
|
182
|
-
idx.additional_roots.each { |r| allowed << { path: r, primary: false } } if idx.respond_to?(:additional_roots)
|
|
183
|
-
return ToolOutput.error(DiagnosticReporter.render_traversal_blocked(path_filter, allowed_roots: allowed))
|
|
184
|
-
end
|
|
176
|
+
return ToolOutput.error(BaseTool.traversal_blocked_message(path_filter, @root_dir, idx)) if error
|
|
185
177
|
|
|
186
178
|
# Tools never scan: an empty index answers honestly instead of
|
|
187
179
|
# triggering a synchronous full_scan inside the tool call.
|
|
@@ -273,11 +265,7 @@ module Rubik
|
|
|
273
265
|
return ToolOutput.error("Error: `replacement_content` parameter is required.") if replacement.nil?
|
|
274
266
|
|
|
275
267
|
content = @buffer_manager.read(path)
|
|
276
|
-
unless content
|
|
277
|
-
known_files = (@buffer_manager.respond_to?(:all_files) ? @buffer_manager.all_files : [])
|
|
278
|
-
candidates = FuzzyMatcher.best_matches(File.basename(path), known_files.map { |f| File.basename(f) })
|
|
279
|
-
return ToolOutput.error(DiagnosticReporter.render_file_not_found(path, candidates: candidates))
|
|
280
|
-
end
|
|
268
|
+
return ToolOutput.error(BaseTool.file_not_found_message(@buffer_manager, path)) unless content
|
|
281
269
|
|
|
282
270
|
has_crlf = content.to_s.include?("\r\n")
|
|
283
271
|
norm_file = content.to_s.gsub("\r\n", "\n")
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require_relative "../base"
|
|
4
4
|
require_relative "../output"
|
|
5
5
|
require_relative "../../coeffects"
|
|
6
|
+
require_relative "../../orchestrator/goal_ledger"
|
|
6
7
|
|
|
7
8
|
module Rubik
|
|
8
9
|
module Tools
|
|
@@ -16,12 +17,19 @@ module Rubik
|
|
|
16
17
|
class UpdateGoalLedgerTool < BaseTool
|
|
17
18
|
REQUIRES = [Rubik::Coeffects::GOAL_LEDGER].freeze
|
|
18
19
|
|
|
20
|
+
# Model-yüzü öğretim (SSOT türetme): item-grammar sözlüğü yüklenme
|
|
21
|
+
# anında Ledger::PRODUCTION_SCHEMA'dan türetilir — elle yazılan
|
|
22
|
+
# enum/required kopyası YOKTUR; şema değişirse description da değişir.
|
|
23
|
+
# Tükenme feedback'i de aynı sabiti paylaşır (schema_vocabulary).
|
|
24
|
+
GRAMMAR = Rubik::Orchestrator::GoalLedger::Ledger.schema_vocabulary
|
|
25
|
+
|
|
19
26
|
DECLARATION = Declaration.new(
|
|
20
27
|
name: "update_goal_ledger", aliases: ["ledger"],
|
|
21
28
|
description: "Update the structured goal ledger of the RUNNING !goal loop with an RFC 6902 " \
|
|
22
29
|
"JSON patch ({\"rev\": N, \"ops\": [{\"op\": \"add\"|\"replace\"|\"remove\", \"path\": \"/tasks/0/status\", \"value\": ...}]}). " \
|
|
23
30
|
"Read current state via read_file(path: 'rubik://goal/ledger') (or 'rubik://goal/ledger.json') and issue " \
|
|
24
31
|
"the patch against the rev it reports. Items carry 0-based indices (/tasks/0); append via /tasks/-. " \
|
|
32
|
+
"Item grammar: #{GRAMMAR}. " \
|
|
25
33
|
"Tasks and environment notes may carry declarative verify specs: {\"type\": \"file_exists\", \"path\": ...}, " \
|
|
26
34
|
"{\"type\": \"file_contains\", \"path\": ..., \"pattern\": ...}, or {\"type\": \"marker\", \"path\": ..., \"marker\": ...}. " \
|
|
27
35
|
"Rejections carry per-op fix hints; after the retry budget the ledger stays unchanged. A task status of " \
|
|
@@ -73,8 +81,11 @@ module Rubik
|
|
|
73
81
|
row = %(<goal_ledger_applied rev="#{result.rev}" uri="#{result.uri}" />)
|
|
74
82
|
ToolOutput.ok(result.uri ? row : %(<goal_ledger_applied rev="#{result.rev}" storage="unavailable (memory-only)" />))
|
|
75
83
|
when :exhausted
|
|
84
|
+
# Durum-bağımsız gramer hatırlatması (GRAMMAR): tükenme anında
|
|
85
|
+
# öğretmen susmasın — ama cache'lenmiş ret reason'ları DEĞİL
|
|
86
|
+
# (bayat teşhis bilgi zehridir; iyileşme yolu re-read'tir).
|
|
76
87
|
ToolOutput.error("patch budget exhausted (consecutive rejections); the ledger is unchanged at rev " \
|
|
77
|
-
"#{result.rev}. Goal work may continue — read rubik://goal/ledger when you next " \
|
|
88
|
+
"#{result.rev}. #{GRAMMAR} Goal work may continue — read rubik://goal/ledger when you next " \
|
|
78
89
|
"update state, and issue a valid patch against that rev.")
|
|
79
90
|
else
|
|
80
91
|
lines = result.reasons.map do |reason|
|
|
@@ -64,12 +64,7 @@ module Rubik
|
|
|
64
64
|
ext_filter = param(args, :extension, type: :stripped_string)
|
|
65
65
|
|
|
66
66
|
path_filter, outside_error = BaseTool.normalize_path_filter(path_filter, @root_dir)
|
|
67
|
-
if outside_error
|
|
68
|
-
allowed = [{ path: @root_dir, primary: true }]
|
|
69
|
-
idx = context_index
|
|
70
|
-
idx.additional_roots.each { |r| allowed << { path: r, primary: false } } if idx.respond_to?(:additional_roots)
|
|
71
|
-
return ToolOutput.error(DiagnosticReporter.render_traversal_blocked(param(args, :path), allowed_roots: allowed))
|
|
72
|
-
end
|
|
67
|
+
return ToolOutput.error(BaseTool.traversal_blocked_message(param(args, :path), @root_dir, context_index)) if outside_error
|
|
73
68
|
|
|
74
69
|
case_sensitive = param(args, :case_sensitive, default: false)
|
|
75
70
|
max_results = param(args, :max_results, type: :integer, default: 50)
|
|
@@ -5,6 +5,7 @@ require_relative "../output"
|
|
|
5
5
|
require_relative "../../runtime"
|
|
6
6
|
require_relative "../../runtime/repair_probe"
|
|
7
7
|
require_relative "../../buffer/apply_contract"
|
|
8
|
+
require_relative "../../storage/layout"
|
|
8
9
|
|
|
9
10
|
module Rubik
|
|
10
11
|
module Tools
|
|
@@ -93,9 +94,9 @@ module Rubik
|
|
|
93
94
|
private
|
|
94
95
|
|
|
95
96
|
def auto_apply_mode
|
|
96
|
-
return nil unless @shell.respond_to?(:config)
|
|
97
|
+
return nil unless @shell.respond_to?(:config)
|
|
97
98
|
|
|
98
|
-
@shell.config
|
|
99
|
+
Rubik::Storage::Layout.config_get(@shell.config, "buffer.auto_apply", "manual")
|
|
99
100
|
end
|
|
100
101
|
end
|
|
101
102
|
|
|
@@ -270,7 +271,7 @@ module Rubik
|
|
|
270
271
|
|
|
271
272
|
case target
|
|
272
273
|
when "lsp"
|
|
273
|
-
raise "LSP manager and config are required for live activation" unless @lsp_manager && @config
|
|
274
|
+
raise RepairRuntimeError, "LSP manager and config are required for live activation" unless @lsp_manager && @config
|
|
274
275
|
|
|
275
276
|
had_client = !@lsp_manager.clients[lang].nil?
|
|
276
277
|
# The manager owns its client table. Restore the old configured
|
|
@@ -281,10 +282,10 @@ module Rubik
|
|
|
281
282
|
))
|
|
282
283
|
@lsp_manager.stop_client(lang)
|
|
283
284
|
start_res = @lsp_manager.start_client(lang)
|
|
284
|
-
raise "Failed to start LSP server: #{start_res}" unless start_res.is_a?(Hash) && start_res[:ok]
|
|
285
|
+
raise RepairRuntimeError, "Failed to start LSP server: #{start_res}" unless start_res.is_a?(Hash) && start_res[:ok]
|
|
285
286
|
|
|
286
287
|
service = @lsp_manager.clients[lang]
|
|
287
|
-
raise "LSP manager reported success without an active client" unless service
|
|
288
|
+
raise RepairRuntimeError, "LSP manager reported success without an active client" unless service
|
|
288
289
|
when "test_runner", "linter"
|
|
289
290
|
if @adapter_registry
|
|
290
291
|
adapter = @adapter_registry.get(lang)
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
require "json"
|
|
4
4
|
require "stringio"
|
|
5
5
|
require "timeout"
|
|
6
|
+
require_relative "../../log"
|
|
6
7
|
require_relative "../base"
|
|
7
8
|
require_relative "../output"
|
|
8
9
|
require_relative "../preflight_runner"
|
|
9
10
|
require_relative "../../runtime"
|
|
10
|
-
|
|
11
11
|
module Rubik
|
|
12
12
|
module Tools
|
|
13
13
|
class SynthesizeCommandTool < BaseTool
|
|
@@ -118,7 +118,7 @@ module Rubik
|
|
|
118
118
|
out_ctx = if ctx
|
|
119
119
|
ctx
|
|
120
120
|
elsif @shell.respond_to?(:command_context)
|
|
121
|
-
warn "[rubik] custom command invoked without a dispatch CommandContext" unless ENV["RUBIK_TEST"]
|
|
121
|
+
Rubik::Log.warn(:tools, "[rubik] custom command invoked without a dispatch CommandContext") unless ENV["RUBIK_TEST"]
|
|
122
122
|
@shell.command_context
|
|
123
123
|
else
|
|
124
124
|
@shell.output
|
|
@@ -142,7 +142,7 @@ module Rubik
|
|
|
142
142
|
end
|
|
143
143
|
end
|
|
144
144
|
else
|
|
145
|
-
warn "[Synthesize] no runtime context; dispose inverse not registered for '!#{clean_name}'"
|
|
145
|
+
Rubik::Log.warn(:tools, "[Synthesize] no runtime context; dispose inverse not registered for '!#{clean_name}'")
|
|
146
146
|
end
|
|
147
147
|
end
|
|
148
148
|
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../errors"
|
|
4
|
+
|
|
3
5
|
# Named rollback objects for RepairRuntimeTool's promotion transaction
|
|
4
6
|
# (issue #427). Each replaces a former inline `on_dispose` closure, responds
|
|
5
7
|
# to #call and is executed in LIFO order by Context#dispose, keeping the
|
|
6
8
|
# rollback contract explicit and the promotion phase unit-testable.
|
|
7
9
|
module Rubik
|
|
8
10
|
module Tools
|
|
11
|
+
# Runtime-service promotion/rollback failure (issue #448): the repair
|
|
12
|
+
# plane's live-activation preconditions (builtins/lifecycle.rb) and this
|
|
13
|
+
# file's rollback restore raise this instead of bare RuntimeError.
|
|
14
|
+
# RepairRuntimeTool's promotion rescue converts it into a
|
|
15
|
+
# ToolOutput.error verbatim, and Context#dispose error-isolates the
|
|
16
|
+
# rollback inverse, so the class change is transparent to both
|
|
17
|
+
# consumers. Homed here (not builtins/lifecycle.rb) because the builtin
|
|
18
|
+
# file-size contract pins that page; the bottom require there loads this
|
|
19
|
+
# file, so the constant exists for every raise site.
|
|
20
|
+
class RepairRuntimeError < Rubik::Error; end
|
|
21
|
+
|
|
9
22
|
class RepairRuntimeTool
|
|
10
23
|
# Shared flag for the rollbacks of one promotion transaction: when a
|
|
11
24
|
# previous repair scope already owns the lifetime inverses for this key,
|
|
@@ -64,7 +77,7 @@ module Rubik
|
|
|
64
77
|
return unless had_client && !root_ctx.disposed?
|
|
65
78
|
|
|
66
79
|
restored = lsp_manager.start_client(lang)
|
|
67
|
-
raise "Previous LSP client could not be restarted: #{restored}" unless restored[:ok]
|
|
80
|
+
raise Rubik::Tools::RepairRuntimeError, "Previous LSP client could not be restarted: #{restored}" unless restored[:ok]
|
|
68
81
|
end
|
|
69
82
|
end
|
|
70
83
|
|
|
@@ -5,6 +5,7 @@ require "rbconfig"
|
|
|
5
5
|
require "stringio"
|
|
6
6
|
require "timeout"
|
|
7
7
|
|
|
8
|
+
require_relative "../log"
|
|
8
9
|
require_relative "../security/errors"
|
|
9
10
|
require_relative "../runtime/synthesized_tool_context"
|
|
10
11
|
|
|
@@ -234,7 +235,7 @@ module Rubik
|
|
|
234
235
|
# The spawn→in-process downgrade is a weaker isolation level (the
|
|
235
236
|
# caller re-executes the same code in this process), so the
|
|
236
237
|
# infrastructure failure must never vanish without a trace.
|
|
237
|
-
warn "[Preflight] subprocess verification failed (#{e.class}: #{e.message}); falling back to in-process"
|
|
238
|
+
Rubik::Log.warn(:tools, "[Preflight] subprocess verification failed (#{e.class}: #{e.message}); falling back to in-process")
|
|
238
239
|
kill_child(pid) if defined?(pid) && pid
|
|
239
240
|
:spawn_failed
|
|
240
241
|
ensure
|
|
@@ -92,45 +92,15 @@ module Rubik
|
|
|
92
92
|
|
|
93
93
|
case strategy_sym
|
|
94
94
|
when :head_only
|
|
95
|
-
|
|
96
|
-
kept_str
|
|
97
|
-
if kept_str.bytesize > max_c
|
|
98
|
-
kept_str = kept_str.byteslice(0, max_c)
|
|
99
|
-
kept_str = kept_str.scrub("") unless kept_str.valid_encoding?
|
|
100
|
-
end
|
|
101
|
-
kept_line_count = kept_str.empty? ? 0 : kept_str.lines(sep).size
|
|
102
|
-
omitted_lines = [lines.size - kept_line_count, 0].max
|
|
103
|
-
omitted_chars = [str.bytesize - kept_str.bytesize, 0].max
|
|
104
|
-
notice = "\n... [Truncated: omitted #{omitted_lines} lines / #{omitted_chars} chars] ...\n"
|
|
105
|
-
{ text: finalize(kept_str, notice, prefix: true), truncated: true,
|
|
106
|
-
omitted_lines: omitted_lines, omitted_chars: omitted_chars }
|
|
95
|
+
kept_str = clamp_head(lines.first(max_l).join, max_c)
|
|
96
|
+
window_result(str, kept_str, lines.size, sep, :short, prefix: true)
|
|
107
97
|
when :tail_only
|
|
108
|
-
|
|
109
|
-
kept_str
|
|
110
|
-
if kept_str.bytesize > max_c
|
|
111
|
-
kept_str = kept_str.byteslice(-max_c, max_c)
|
|
112
|
-
kept_str = kept_str.scrub("") unless kept_str.valid_encoding?
|
|
113
|
-
end
|
|
114
|
-
kept_line_count = kept_str.empty? ? 0 : kept_str.lines(sep).size
|
|
115
|
-
omitted_lines = [lines.size - kept_line_count, 0].max
|
|
116
|
-
omitted_chars = [str.bytesize - kept_str.bytesize, 0].max
|
|
117
|
-
notice = "\n... [Truncated: omitted #{omitted_lines} lines / #{omitted_chars} chars] ...\n"
|
|
118
|
-
{ text: finalize(kept_str, notice, prefix: false), truncated: true,
|
|
119
|
-
omitted_lines: omitted_lines, omitted_chars: omitted_chars }
|
|
98
|
+
kept_str = clamp_tail(lines.last(max_l).join, max_c)
|
|
99
|
+
window_result(str, kept_str, lines.size, sep, :short, prefix: false)
|
|
120
100
|
else # :head_tail
|
|
121
101
|
if max_l <= 1
|
|
122
|
-
|
|
123
|
-
kept_str
|
|
124
|
-
if kept_str.bytesize > max_c
|
|
125
|
-
kept_str = kept_str.byteslice(0, max_c)
|
|
126
|
-
kept_str = kept_str.scrub("") unless kept_str.valid_encoding?
|
|
127
|
-
end
|
|
128
|
-
kept_line_count = kept_str.empty? ? 0 : kept_str.lines(sep).size
|
|
129
|
-
omitted_lines = [lines.size - kept_line_count, 0].max
|
|
130
|
-
omitted_chars = [str.bytesize - kept_str.bytesize, 0].max
|
|
131
|
-
notice = "\n\n... [Truncated: #{omitted_lines} lines / #{omitted_chars} chars omitted to preserve token budget] ...\n\n"
|
|
132
|
-
return { text: finalize(kept_str, notice, prefix: true), truncated: true,
|
|
133
|
-
omitted_lines: omitted_lines, omitted_chars: omitted_chars }
|
|
102
|
+
kept_str = clamp_head(lines.first(max_l).join, max_c)
|
|
103
|
+
return window_result(str, kept_str, lines.size, sep, :budget, prefix: true)
|
|
134
104
|
end
|
|
135
105
|
|
|
136
106
|
head_lines_count = max_l / 2
|
|
@@ -190,6 +160,48 @@ module Rubik
|
|
|
190
160
|
prefix ? "#{str}#{notice}" : "#{notice}#{str}"
|
|
191
161
|
end
|
|
192
162
|
|
|
163
|
+
# Shared kept-window accounting for the single-window strategies
|
|
164
|
+
# (head_only, tail_only, and head_tail's degenerate max_l <= 1
|
|
165
|
+
# branch): omitted_lines/omitted_chars are derived from the ORIGINAL
|
|
166
|
+
# line count and the KEPT byte size. `style` selects one of the two
|
|
167
|
+
# sanctioned full-truncation notice spellings — byte-identical
|
|
168
|
+
# output is pinned by tests, so the format lives here and nowhere
|
|
169
|
+
# else. The kept window must already be clamped (and scrubbed once
|
|
170
|
+
# after its last byteslice) via clamp_head / clamp_tail.
|
|
171
|
+
def self.window_result(str, kept_str, total_lines, sep, style, prefix:)
|
|
172
|
+
kept_line_count = kept_str.empty? ? 0 : kept_str.lines(sep).size
|
|
173
|
+
omitted_lines = [total_lines - kept_line_count, 0].max
|
|
174
|
+
omitted_chars = [str.bytesize - kept_str.bytesize, 0].max
|
|
175
|
+
notice = if style == :budget
|
|
176
|
+
"\n\n... [Truncated: #{omitted_lines} lines / #{omitted_chars} chars omitted to preserve token budget] ...\n\n"
|
|
177
|
+
else
|
|
178
|
+
"\n... [Truncated: omitted #{omitted_lines} lines / #{omitted_chars} chars] ...\n"
|
|
179
|
+
end
|
|
180
|
+
{ text: finalize(kept_str, notice, prefix: prefix), truncated: true,
|
|
181
|
+
omitted_lines: omitted_lines, omitted_chars: omitted_chars }
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Post-byteslice head clamp: a byte-boundary cut can split a multibyte
|
|
185
|
+
# character at the cut edge. Dropping the partial sequence keeps the
|
|
186
|
+
# byte budget honest while the kept window stays valid UTF-8.
|
|
187
|
+
def self.clamp_head(str, max_c)
|
|
188
|
+
return str if str.bytesize <= max_c
|
|
189
|
+
|
|
190
|
+
clamped = str.byteslice(0, max_c)
|
|
191
|
+
clamped = clamped.scrub("") unless clamped.valid_encoding?
|
|
192
|
+
clamped
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# Tail clamp: same contract as clamp_head, slicing from the END of the
|
|
196
|
+
# window so the last lines survive.
|
|
197
|
+
def self.clamp_tail(str, max_c)
|
|
198
|
+
return str if str.bytesize <= max_c
|
|
199
|
+
|
|
200
|
+
clamped = str.byteslice(-max_c, max_c)
|
|
201
|
+
clamped = clamped.scrub("") unless clamped.valid_encoding?
|
|
202
|
+
clamped
|
|
203
|
+
end
|
|
204
|
+
|
|
193
205
|
# Canonical short-preview truncation for human/model-readable
|
|
194
206
|
# fragments: keep at most `limit` characters, then append one of the
|
|
195
207
|
# repo's two elision markers. `counted:` selects the spelling —
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "monitor"
|
|
4
|
+
require_relative "../log"
|
|
4
5
|
require_relative "../uris"
|
|
5
6
|
require_relative "../coeffects"
|
|
6
7
|
require_relative "../orchestrator/subagent/transcript_formatter"
|
|
@@ -77,8 +78,8 @@ module Rubik
|
|
|
77
78
|
# Sözleşme ihlali (adapter read ASLA nil döndürmez) — gramer
|
|
78
79
|
# reddinden AYRT edilir: nil'i dosya düzlemine düşürmek yanlış
|
|
79
80
|
# yönlendiren bir dosya-not-found üretirdi; dürüst hata basılır.
|
|
80
|
-
warn "[UriResolver] '#{scheme}' adapter violated the read contract (returned nil); " \
|
|
81
|
-
|
|
81
|
+
Rubik::Log.warn(:tools, "[UriResolver] '#{scheme}' adapter violated the read contract (returned nil); " \
|
|
82
|
+
"refusing to fall through to the file plane")
|
|
82
83
|
ToolOutput.error("rubik://#{scheme} read failed: the '#{scheme}' adapter returned no content " \
|
|
83
84
|
"(contract violation — see runtime log).")
|
|
84
85
|
end
|