rubik 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ATTRIBUTION.md +1 -1
- data/CHANGELOG.md +250 -43
- data/README.md +5 -1
- data/lib/rubik/adapter/base.rb +21 -1
- data/lib/rubik/adapter/generic.rb +0 -14
- data/lib/rubik/adapter/node.rb +2 -0
- data/lib/rubik/adapter/process.rb +28 -67
- data/lib/rubik/ast/treesitter/zig_walker.rb +15 -2
- data/lib/rubik/benchmark/vakanuvis_adoption.rb +10 -3
- data/lib/rubik/buffer/apply_contract.rb +3 -3
- data/lib/rubik/buffer/apply_transaction.rb +165 -0
- data/lib/rubik/buffer/manager.rb +26 -120
- data/lib/rubik/cli/workspace_trust.rb +16 -0
- data/lib/rubik/config/deep_ops.rb +4 -1
- data/lib/rubik/config/defaults.rb +29 -3
- data/lib/rubik/config/schema.rb +8 -0
- data/lib/rubik/config/secret_policy.rb +197 -0
- data/lib/rubik/config/store.rb +14 -0
- data/lib/rubik/config.rb +11 -0
- data/lib/rubik/diagnostics/collector.rb +0 -9
- data/lib/rubik/errors.rb +15 -0
- data/lib/rubik/event_bus.rb +2 -1
- data/lib/rubik/kernel/dispatcher.rb +16 -11
- data/lib/rubik/kernel/unit.rb +4 -1
- data/lib/rubik/llm/registry.rb +12 -9
- data/lib/rubik/llm/router.rb +2 -5
- data/lib/rubik/log.rb +23 -1
- data/lib/rubik/lsp/client.rb +152 -445
- data/lib/rubik/lsp/document_store.rb +209 -0
- data/lib/rubik/lsp/manager.rb +14 -10
- data/lib/rubik/lsp/transport.rb +365 -0
- data/lib/rubik/mcp/boot_lifecycle.rb +6 -2
- data/lib/rubik/mcp/boot_run.rb +190 -0
- data/lib/rubik/mcp/client.rb +4 -3
- data/lib/rubik/mcp/manager.rb +46 -165
- data/lib/rubik/mcp/transport/stdio.rb +55 -10
- data/lib/rubik/orchestrator/auto_apply.rb +4 -3
- data/lib/rubik/orchestrator/continuation_manager.rb +3 -22
- data/lib/rubik/orchestrator/goal_session.rb +519 -0
- data/lib/rubik/orchestrator/loop.rb +28 -47
- data/lib/rubik/orchestrator/maestro_gate.rb +5 -7
- data/lib/rubik/orchestrator/provider_recovery.rb +4 -2
- data/lib/rubik/orchestrator/provider_resolver.rb +4 -2
- data/lib/rubik/orchestrator/resume_window.rb +96 -0
- data/lib/rubik/orchestrator/shell_deps.rb +16 -0
- data/lib/rubik/orchestrator/stream_manager.rb +2 -1
- data/lib/rubik/orchestrator/subagent/deferred_spec.rb +4 -1
- data/lib/rubik/orchestrator/subagent/instance.rb +11 -12
- data/lib/rubik/orchestrator/subagent/journal.rb +2 -1
- data/lib/rubik/orchestrator/subagent/lifecycle.rb +3 -1
- data/lib/rubik/orchestrator/subagent/questioner.rb +24 -7
- 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 +11 -3
- data/lib/rubik/orchestrator/subagent/teardown.rb +4 -0
- 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/orchestrator.rb +1 -0
- data/lib/rubik/platform/io_drain.rb +2 -1
- data/lib/rubik/platform/process.rb +144 -54
- data/lib/rubik/platform.rb +17 -1
- data/lib/rubik/plugin/manager.rb +2 -1
- data/lib/rubik/plugin/storage.rb +20 -29
- data/lib/rubik/repl/commands/agent_context.rb +9 -8
- data/lib/rubik/repl/commands/agent_execution.rb +20 -502
- 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 +6 -5
- data/lib/rubik/repl/commands/lsp.rb +3 -2
- data/lib/rubik/repl/commands/pruner.rb +2 -1
- data/lib/rubik/repl/commands/secrets.rb +151 -0
- data/lib/rubik/repl/commands/workspace.rb +60 -150
- data/lib/rubik/repl/commands/workspace_approval.rb +209 -0
- data/lib/rubik/repl/config_wiring.rb +3 -3
- data/lib/rubik/repl/hooks.rb +2 -1
- data/lib/rubik/repl/input_execution.rb +158 -76
- data/lib/rubik/repl/input_loop.rb +3 -2
- data/lib/rubik/repl/lifecycle.rb +82 -204
- data/lib/rubik/repl/notice_router.rb +319 -0
- data/lib/rubik/repl/paste_support.rb +3 -1
- data/lib/rubik/repl/presentation.rb +5 -3
- data/lib/rubik/repl/pruner/gate.rb +3 -1
- data/lib/rubik/repl/pruner/harness.rb +2 -1
- data/lib/rubik/repl/shell.rb +4 -3
- data/lib/rubik/repl/turn_recorder.rb +6 -5
- data/lib/rubik/runtime/discovery.rb +3 -2
- data/lib/rubik/runtime/loop_service.rb +4 -3
- data/lib/rubik/runtime/manifest_store.rb +124 -0
- data/lib/rubik/runtime/overlay_guard.rb +127 -0
- data/lib/rubik/runtime/overlay_storage.rb +269 -272
- data/lib/rubik/runtime/task_manager.rb +71 -27
- data/lib/rubik/runtime.rb +1 -0
- data/lib/rubik/sandbox/driver/docker.rb +5 -1
- data/lib/rubik/sandbox/runner.rb +16 -15
- data/lib/rubik/security/allowlist.rb +167 -0
- data/lib/rubik/security/audit_log.rb +72 -0
- data/lib/rubik/security/classifier/classifier.rb +8 -0
- data/lib/rubik/security/command_gate.rb +591 -0
- data/lib/rubik/security/guard.rb +94 -1077
- data/lib/rubik/security/path_policy.rb +117 -0
- data/lib/rubik/security/secret_store.rb +463 -0
- data/lib/rubik/security/synthesis_gate.rb +297 -0
- data/lib/rubik/security.rb +5 -0
- data/lib/rubik/session/manager.rb +7 -1
- data/lib/rubik/skills/manager.rb +2 -3
- data/lib/rubik/storage/ranking.rb +113 -0
- data/lib/rubik/storage/search.rb +49 -0
- data/lib/rubik/storage/store.rb +15 -112
- data/lib/rubik/storage/transcript_indexer.rb +2 -3
- data/lib/rubik/storage/vakanuvis/harness.rb +2 -3
- data/lib/rubik/tools/base.rb +22 -0
- data/lib/rubik/tools/builtins/files.rb +3 -15
- data/lib/rubik/tools/builtins/grep.rb +3 -9
- data/lib/rubik/tools/builtins/lifecycle.rb +96 -92
- data/lib/rubik/tools/builtins/synthesis.rb +3 -0
- data/lib/rubik/tools/lifecycle_rollbacks.rb +100 -0
- data/lib/rubik/tools/native_search.rb +2 -1
- data/lib/rubik/tools/truncator.rb +73 -36
- data/lib/rubik/ui/banner.rb +4 -3
- data/lib/rubik/ui/spinner.rb +3 -1
- data/lib/rubik/ui/statusline.rb +6 -5
- data/lib/rubik/version.rb +1 -1
- data/lib/rubik.rb +1 -2
- metadata +23 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../platform"
|
|
4
|
+
require_relative "../log"
|
|
5
|
+
|
|
6
|
+
module Rubik
|
|
7
|
+
module Runtime
|
|
8
|
+
# Guard/trust plane of the overlay storage (issue #447), single-homed here
|
|
9
|
+
# so Runtime::OverlayStorage stays the manifest/lifecycle coordinator:
|
|
10
|
+
#
|
|
11
|
+
# * Path containment: ensure_valid_overlay_dir! / ensure_contained_path! /
|
|
12
|
+
# safe_path_under? — the lexical + resolved containment policy over the
|
|
13
|
+
# overlay directories.
|
|
14
|
+
# * Trust/bootstrap screening: trust_mode?, bootstrap_opt_in? and
|
|
15
|
+
# screen_bootstrap_content — the fail-closed acceptance gate a sentinel
|
|
16
|
+
# file must pass before it is pinned into a manifest.
|
|
17
|
+
#
|
|
18
|
+
# Composition contract (the guard kwarg seam must keep working): the
|
|
19
|
+
# synthesis guard is NOT owned here — OverlayStorage forwards its own
|
|
20
|
+
# `guard:` kwarg at construction, so an injected guard (production: the
|
|
21
|
+
# service catalog's single operator-policy guard; tests: spies) is the
|
|
22
|
+
# one used, never bypassed. The lazy Rubik::Security::Guard default is
|
|
23
|
+
# deliberate (unchanged): overlay_storage.rb is a standalone-requireable
|
|
24
|
+
# file; security/guard loads only when screening actually happens, so no
|
|
25
|
+
# load-order audit is needed. Trust mode is likewise not re-read here:
|
|
26
|
+
# OverlayStorage injects the ManifestStore seam (issue #426) as a
|
|
27
|
+
# callable, so the plugin and overlay gates keep their single ENV read.
|
|
28
|
+
class OverlayGuard
|
|
29
|
+
# allowed_dirs: the [[overlay_dir, trusted_root], ...] table the storage
|
|
30
|
+
# derives from its own directory layout (it owns the layout; the guard
|
|
31
|
+
# owns the enforcement).
|
|
32
|
+
def initialize(allowed_dirs:, guard:, trust_mode:)
|
|
33
|
+
@allowed_dirs = allowed_dirs
|
|
34
|
+
@guard = guard
|
|
35
|
+
@trust_mode = trust_mode
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# ── Path containment (moved verbatim from OverlayStorage, issue #447) ──
|
|
39
|
+
|
|
40
|
+
def ensure_valid_overlay_dir!(dir)
|
|
41
|
+
valid = @allowed_dirs.any? do |allowed_dir, trusted_root|
|
|
42
|
+
Platform.path_equal?(dir, allowed_dir) && Platform.resolved_path_under?(dir, trusted_root)
|
|
43
|
+
end
|
|
44
|
+
return if valid
|
|
45
|
+
|
|
46
|
+
raise ArgumentError, "Invalid overlay directory: #{dir}"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def ensure_contained_path!(path, parent_dir)
|
|
50
|
+
raise ArgumentError, "Path traversal attempt detected: #{path}" unless safe_path_under?(path, parent_dir)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def safe_path_under?(path, parent_dir)
|
|
54
|
+
return false if path.nil? || parent_dir.nil?
|
|
55
|
+
|
|
56
|
+
ensure_valid_overlay_dir!(parent_dir)
|
|
57
|
+
|
|
58
|
+
# Lexical containment check first
|
|
59
|
+
return false unless Platform.path_under?(path, parent_dir)
|
|
60
|
+
|
|
61
|
+
# If path exists or parent exists, also check resolved path containment
|
|
62
|
+
return Platform.resolved_path_under?(path, parent_dir) if File.exist?(path) || File.exist?(parent_dir)
|
|
63
|
+
|
|
64
|
+
true
|
|
65
|
+
rescue StandardError
|
|
66
|
+
false
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# ── Trust / bootstrap screening (moved verbatim from OverlayStorage, issue #447) ──
|
|
70
|
+
|
|
71
|
+
# Ortak kaçış kapısı predicate'i: iki güvenlik kapısının (verify_integrity,
|
|
72
|
+
# verified_dir_entries) kopya ENV kontrolüyle sürünerek ayrışmasını engeller.
|
|
73
|
+
# Tek seam ManifestStore'da yaşar (issue #426); plugin tarafı da aynı kapıdan geçer.
|
|
74
|
+
def trust_mode?
|
|
75
|
+
@trust_mode.call
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# İlk-bootstrap açık rızası: manifest'siz dizindeki sentinel dosyaların ilk taramada
|
|
79
|
+
# kabul edilmesi ancak bu env ile mümkündür (kayıt kalıcıdır; sonraki açılışlar env'siz çalışır).
|
|
80
|
+
def bootstrap_opt_in?
|
|
81
|
+
ENV["RUBIK_BOOTSTRAP_OVERLAYS"] == "1"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Aday 07'den ertelenen güvenlik kalemi: manifestsız dizindeki sentinel
|
|
85
|
+
# dosya manifest'e yazılmadan önce synthesis guard'ından geçirilir.
|
|
86
|
+
# Reddedilen (veya taranamayan) dosya manifest'e YAZILMAZ — sonraki tarama
|
|
87
|
+
# yeniden tarar ve reddeder (sessiz heal, bozuk-manifest doktriniyle
|
|
88
|
+
# çelişir); load_all/load_tools'un mevcut :rejected atlaması devreye girer.
|
|
89
|
+
# Parse hatası guard içinde yutulur (çalıştırılamaz kod güvenlik olayı
|
|
90
|
+
# değil); guard'ın kendisi patlarsa da dosya fail-closed reddedilir —
|
|
91
|
+
# SystemStackError dahil: rakip içerikte derin yuvalama AST walk'ı
|
|
92
|
+
# taşırebilir, tek dosyanın reddiyesi tüm taramayı çökertmemeli.
|
|
93
|
+
# Bilinçli asimetri: dosyanın TAMAMI (Description/Schema başlığı dahil)
|
|
94
|
+
# taranır — sentez anında yalnızca kod taranıyordu. Kabul kapısı daha
|
|
95
|
+
# sıkı olmak güvenli yöndür; başlık metnine denk gelen nadir yanlış
|
|
96
|
+
# pozitif dosyayı makinede yeniden kayıtla çözülür.
|
|
97
|
+
# Emit doktrini (guard.rb run_synthesis_gate hükmü): güvenlik kararının
|
|
98
|
+
# tek kullanıcı-yüzü izi Log.warn ile yazılır — $VERBOSE=nil altında da
|
|
99
|
+
# yaşar (Log.emit $stderr.puts kullanır, Kernel#warn değil) ve varsayılan
|
|
100
|
+
# RUBIK_LOG_LEVEL=warn'da her zaman basılır (issue #452).
|
|
101
|
+
def screen_bootstrap_content(content, basename)
|
|
102
|
+
bootstrap_guard.verify_synthesis_safety!(content)
|
|
103
|
+
:ok
|
|
104
|
+
rescue Rubik::Security::BlockedWriteError => e
|
|
105
|
+
Rubik::Log.warn(:security, "[SECURITY] Bootstrap overlay '#{basename}' refused by synthesis guard: #{e.message}")
|
|
106
|
+
:rejected
|
|
107
|
+
rescue StandardError, ScriptError, SystemStackError => e
|
|
108
|
+
Rubik::Log.warn(:security, "[SECURITY] Bootstrap overlay '#{basename}' could not be screened (#{e.class}: #{e.message}); refusing.")
|
|
109
|
+
:rejected
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
private
|
|
113
|
+
|
|
114
|
+
# Bootstrap kabul taramasında kullanılacak guard: kwarg'la geçilen örnek
|
|
115
|
+
# (üretimde service catalog'un tek operatör-policy guard'ı) ya da lazy
|
|
116
|
+
# default. Lazy çözüm bilinçli: overlay_storage.rb standalone require
|
|
117
|
+
# edilebilen bir dosyadır; security/guard yalnızca tarama gerçekten
|
|
118
|
+
# gerektiğinde yüklenir, load-order denetimi gerekmez.
|
|
119
|
+
def bootstrap_guard
|
|
120
|
+
@bootstrap_guard ||= begin
|
|
121
|
+
require_relative "../security/guard"
|
|
122
|
+
@guard || Rubik::Security::Guard.new
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|