rubik 0.9.0 → 0.9.1
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 +108 -43
- data/README.md +5 -1
- data/lib/rubik/adapter/base.rb +19 -0
- data/lib/rubik/adapter/generic.rb +0 -14
- data/lib/rubik/adapter/node.rb +2 -0
- data/lib/rubik/ast/treesitter/zig_walker.rb +15 -2
- data/lib/rubik/cli/workspace_trust.rb +16 -0
- data/lib/rubik/config/defaults.rb +23 -0
- data/lib/rubik/config/store.rb +14 -0
- data/lib/rubik/kernel/dispatcher.rb +4 -4
- data/lib/rubik/log.rb +2 -1
- data/lib/rubik/lsp/client.rb +83 -180
- data/lib/rubik/lsp/document_store.rb +209 -0
- data/lib/rubik/mcp/client.rb +4 -3
- data/lib/rubik/mcp/manager.rb +6 -2
- data/lib/rubik/mcp/transport/stdio.rb +51 -9
- data/lib/rubik/orchestrator/goal_session.rb +505 -0
- data/lib/rubik/orchestrator/subagent/instance.rb +4 -0
- data/lib/rubik/orchestrator/subagent/journal.rb +2 -1
- data/lib/rubik/orchestrator/subagent/questioner.rb +21 -6
- data/lib/rubik/orchestrator/subagent/step_runner.rb +1 -1
- data/lib/rubik/orchestrator/subagent/teardown.rb +4 -0
- data/lib/rubik/orchestrator/subagent/transcript_formatter.rb +2 -1
- data/lib/rubik/orchestrator.rb +1 -0
- data/lib/rubik/platform.rb +15 -0
- data/lib/rubik/plugin/storage.rb +20 -29
- data/lib/rubik/repl/commands/agent_context.rb +1 -1
- data/lib/rubik/repl/commands/agent_execution.rb +7 -470
- data/lib/rubik/repl/commands/buffer.rb +1 -1
- data/lib/rubik/repl/commands/lsp.rb +1 -1
- data/lib/rubik/repl/input_loop.rb +1 -1
- data/lib/rubik/repl/lifecycle.rb +28 -0
- data/lib/rubik/runtime/manifest_store.rb +116 -0
- data/lib/rubik/runtime/overlay_storage.rb +247 -196
- data/lib/rubik/runtime/task_manager.rb +7 -2
- data/lib/rubik/runtime.rb +1 -0
- 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 +567 -0
- data/lib/rubik/security/guard.rb +88 -1075
- data/lib/rubik/security/path_policy.rb +117 -0
- data/lib/rubik/security/synthesis_gate.rb +300 -0
- data/lib/rubik/security.rb +5 -0
- data/lib/rubik/storage/ranking.rb +113 -0
- data/lib/rubik/storage/store.rb +2 -92
- data/lib/rubik/storage/transcript_indexer.rb +2 -3
- data/lib/rubik/tools/builtins/grep.rb +2 -3
- data/lib/rubik/tools/builtins/lifecycle.rb +90 -87
- data/lib/rubik/tools/builtins/synthesis.rb +3 -0
- data/lib/rubik/tools/lifecycle_rollbacks.rb +87 -0
- data/lib/rubik/tools/native_search.rb +2 -1
- data/lib/rubik/tools/truncator.rb +25 -0
- data/lib/rubik/version.rb +1 -1
- metadata +11 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4978b3f5f55209ac3558f5d2a82651b0e9f2d56571ebb33cb65a8b488f2689b0
|
|
4
|
+
data.tar.gz: 4b430b94ecdc22c7f5b75756f9bd23f0eadf544a0ecf760c8fa5a8c14c99bcc0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: acf9faccdcfdb6a344bfc3e1aa8b7f3c316d42a14b6c65766bf2d9b9c728378a312022c7b4195542abeb62fd7319af72d17cd207ec3b69435cbaa8d807bac94b
|
|
7
|
+
data.tar.gz: 88b8c7bd853a932860ad009a06e9f3e1b505e72049d4b09ac911f07fa0ecdaf6320b145dd1f67e2b48488c02fff4dae2b3562806e1b0601bf2e59c3c74233924
|
data/ATTRIBUTION.md
CHANGED
|
@@ -121,7 +121,7 @@ SOFTWARE.
|
|
|
121
121
|
| **`strings-ansi`** | Piotr Murach | MIT | ANSI-aware string truncation and alignment for REPL formatters. |
|
|
122
122
|
| **`reline`** | Hiroshi SHIBATA & Ruby Team | Ruby License / BSD-2-Clause | Line-editing, history navigation, autocompletion hooks, and headless terminal adaptation. |
|
|
123
123
|
| **`prism`** | Kevin Newton & Ruby Core Team | MIT | High-performance Ruby parsing and AST extraction ([`Rubik::AST::RubyExtractor`](lib/rubik/ast/ruby_extractor.rb)). |
|
|
124
|
-
| **`minitest`** | Ryan Davis & seattlerb | MIT | Fast, modular test suite powering Rubik's 4,
|
|
124
|
+
| **`minitest`** | Ryan Davis & seattlerb | MIT | Fast, modular test suite powering Rubik's 4,400+ unit, integration, and contract tests. |
|
|
125
125
|
| **`rubocop`** | Bozhidar Batsov & contributors | MIT | Static code analysis, style enforcement, and architectural hygiene gates. |
|
|
126
126
|
| **`benchmark`, `logger`, `pstore`, `reline`, `fiddle`** | Ruby core / rubygems teams | Ruby License / BSD-2-Clause | Ruby stdlib gems pinned explicitly in `rubik.gemspec` as they are unbundled from the default set in Ruby 3.4/3.5. |
|
|
127
127
|
|
data/CHANGELOG.md
CHANGED
|
@@ -6,7 +6,112 @@ commits, 2026-08-23 → 2026-10-09, see `git log`).
|
|
|
6
6
|
|
|
7
7
|
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
8
8
|
|
|
9
|
-
## [
|
|
9
|
+
## [0.9.1] - 2026-11-14
|
|
10
|
+
|
|
11
|
+
The hardening-and-single-homing patch: overlay commands seal their default
|
|
12
|
+
wrap and compare manifest hashes in constant time, the Guard god-file splits
|
|
13
|
+
into five deep modules with the allowlist gates failing closed, MCP stdio
|
|
14
|
+
spawns get host-runtime scrubbing and a per-server credential policy, the
|
|
15
|
+
parallel-stable test gate retires the capacity-flake adjudication burden
|
|
16
|
+
(#384) — and the single-homing wave collapses duplicated logic across the
|
|
17
|
+
BM25 ranker, LSP document store, goal session, preview truncation, and the
|
|
18
|
+
overlay kind adapter.
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- **MCP stdio credential policy (#429):** MCP stdio servers keep inheriting the
|
|
23
|
+
host environment (minus the bundler/Ruby runtime variables the spawn-hygiene
|
|
24
|
+
scrub already unsets) — a non-breaking default, since many real servers
|
|
25
|
+
legitimately need operator credentials. A per-server `inherit_env:` option
|
|
26
|
+
(default `true`) opts out: with `inherit_env: false`, variables matching
|
|
27
|
+
`/_(API_KEY|TOKEN|SECRET|PASSWORD)$/` (case-insensitive) are additionally
|
|
28
|
+
unset for that server's subprocess, leaving the sanitized base plus only its
|
|
29
|
+
explicit `env:` entries. Explicit `env:` entries always win in both modes.
|
|
30
|
+
The policy is documented in `docs/reference/environment.md`, the README
|
|
31
|
+
security notes, and the workspace-trust notice.
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- **Guard split into five deep modules (#413):** `AuditLog`, `PathPolicy`,
|
|
36
|
+
`Allowlist`, `CommandGate`, and `SynthesisGate` each own one security
|
|
37
|
+
concern while `Guard` stays the delegating composition root (explicit
|
|
38
|
+
delegating defs, no `method_missing`); historical `Guard::` constants
|
|
39
|
+
alias to the owning module, and every security-sensitive move is
|
|
40
|
+
verbatim.
|
|
41
|
+
- **Allowlist matching and its fail-closed valve single-homed (#401,
|
|
42
|
+
#425):** the token-prefix match collapses behind one `allowlist_match_argv?`
|
|
43
|
+
core feeding both AST and raw paths, the four verbatim fail-closed
|
|
44
|
+
allowlist evaluations in CommandGate delegate to one helper with identical
|
|
45
|
+
deny semantics, `Classifier::Engine.builtin_dangerous?` becomes the public
|
|
46
|
+
predicate, and the dead `DANGEROUS_SYSTEM_ROOTS` constant is deleted.
|
|
47
|
+
- **Overlay command/tool quadruplets parameterized behind a Kind adapter
|
|
48
|
+
(#419):** save/delete/load collapse onto shared skeletons with the 22
|
|
49
|
+
public methods unchanged, the corrupt-manifest fail-closed contract is
|
|
50
|
+
single-homed, and byte-exact header emission is pinned by new tests.
|
|
51
|
+
- **LSP DocumentStore extracted (#418):** the four per-document hashes and
|
|
52
|
+
the three hand-rolled restore-on-failed-send rollbacks collapse into one
|
|
53
|
+
snapshot/restore helper; the lock-order invariant is single-homed and
|
|
54
|
+
the `did_close`/`did_change` failed-send restore coverage gaps are
|
|
55
|
+
closed.
|
|
56
|
+
- **GoalSession extracted from agent_execution (#414):** the 21 `!goal`
|
|
57
|
+
lifecycle methods move byte-identical into `Orchestrator::GoalSession`
|
|
58
|
+
and the duplicated goal-shaped orchestrator-loop stanza folds into one
|
|
59
|
+
builder; the command file shrinks 712 → 249 LOC.
|
|
60
|
+
- **BM25 ranking extracted into Storage::Ranking (#415):** the scored-search
|
|
61
|
+
math (Okapi scoring, field-tier bonuses, ordering) moves behind one pure
|
|
62
|
+
entry point with `Store#search_ranked` keeping its exact contract; the
|
|
63
|
+
dead backward-compat hash branch is dropped.
|
|
64
|
+
- **Preview truncation markers single-homed in Truncator (#402):** six
|
|
65
|
+
modules carrying three drifting marker spellings delegate to new
|
|
66
|
+
`clip`/`clip_line` homes with byte-for-byte legacy output pinned.
|
|
67
|
+
- **Questioner poll replaced with a condition variable (#434):** the 100 ms
|
|
68
|
+
answer poll becomes an unsynchronized-free condition-variable wake, the
|
|
69
|
+
lifecycle repair tool's `execute` splits into discover/verify/promote
|
|
70
|
+
phases (#435), and plugin/overlay integrity records share one manifest
|
|
71
|
+
store (#436).
|
|
72
|
+
- **Parallel-stable test gate (#417):** `rake test:parallel:stable` and
|
|
73
|
+
`rake test:stable` select the timing-insensitive subset (383 of 404
|
|
74
|
+
unit files), parallel runs export `RUBIK_TEST_PERF_RELAX=1` so the
|
|
75
|
+
wall-clock budgets degrade to report-only warns, and bounded `wait_until`
|
|
76
|
+
waits replace raw sleeps — closing #384.
|
|
77
|
+
- **Toolchain bumps (#420, #422):** `tree_sitter_language_pack` 1.25.0
|
|
78
|
+
(with the ZigWalker teaching both grammar spellings across the pack
|
|
79
|
+
range) and `prism` 2.1.0.
|
|
80
|
+
- **Reference docs refreshed (#433):** `RUBIK_TRUST_WORKSPACE` and
|
|
81
|
+
`RUBIK_TEST_ROOT` join the environment table, and a stray duplicated
|
|
82
|
+
0.7.1 changelog block is removed.
|
|
83
|
+
|
|
84
|
+
### Fixed
|
|
85
|
+
|
|
86
|
+
- **MCP stdio spawn hygiene (#424):** stdio servers no longer inherit the
|
|
87
|
+
host bundler/Ruby runtime variables; the LSP scrub single-homes as
|
|
88
|
+
`Rubik::Platform.sanitized_spawn_env` with explicitly configured `env:`
|
|
89
|
+
entries merging on top and winning.
|
|
90
|
+
- **Overlay integrity comparisons (#431):** overlay manifest hashes are
|
|
91
|
+
compared in constant time via the same `secure_compare` helper the
|
|
92
|
+
plugin packages already used.
|
|
93
|
+
- **Probe-shape tokenization fails closed (#430):** a quote-corrupted
|
|
94
|
+
command can no longer tokenize as a read-only probe and ride the
|
|
95
|
+
safe-probe exemption; the fallback yields nil and the gate denies.
|
|
96
|
+
- **TaskManager guard fallback and adapter sink validation (#410):** a
|
|
97
|
+
TaskManager constructed without a Guard falls back to a fresh fail-closed
|
|
98
|
+
one, and custom test/format adapter commands are validated through the
|
|
99
|
+
guard at execution sinks, closing the promotion TOCTOU.
|
|
100
|
+
- **Default overlay command wrap sealed (#412):** bare-body overlay
|
|
101
|
+
commands wrap into a sealed 2-arity handler on the deny-list path, and
|
|
102
|
+
the arity-3 raw-shell trust model is documented at both sites.
|
|
103
|
+
- **Boot-time config warnings surfaced (#411):** accumulated config
|
|
104
|
+
warnings print once per boot through the REPL notices seam with a
|
|
105
|
+
mirrored stderr `Log.warn`, and `RETIRED_KEYS` emits the tailored
|
|
106
|
+
`network.allow` deprecation.
|
|
107
|
+
- **Dispatcher failure logs carry the error class (#432)** so a subscriber
|
|
108
|
+
or dmesg failure says what failed, not just that it failed.
|
|
109
|
+
- **Bare rescues narrowed, LSP handshake failure logged (#400):** five
|
|
110
|
+
bare `rescue` clauses no longer swallow Ctrl-C, and `Client#start`
|
|
111
|
+
emits the handshake failure cause before stopping.
|
|
112
|
+
- **test-unit `omit` swapped for minitest `skip` (#416):** all 18
|
|
113
|
+
capability-guarded call sites would have raised `NoMethodError` the
|
|
114
|
+
moment their guard fired; now they skip.
|
|
10
115
|
|
|
11
116
|
## [0.9.0] - 2026-11-09
|
|
12
117
|
|
|
@@ -265,47 +370,6 @@ anyway.
|
|
|
265
370
|
class; the mapping is byte-identical (backslash doubles, pipe gains a
|
|
266
371
|
backslash) and truncation can no longer split an escape sequence.
|
|
267
372
|
|
|
268
|
-
## [0.7.1] - 2026-11-04
|
|
269
|
-
the RECALL_* policy constants moved out of the Harness thread core into
|
|
270
|
-
a pure Recall module - Harness#recall is now a one-line delegate, the
|
|
271
|
-
verbatim first_body_line duplication between Harness and Orientation is
|
|
272
|
-
gone, and Orientation/DistillGate no longer reach into Harness constants.
|
|
273
|
-
|
|
274
|
-
- **Tool-output normalization single-homed:** the root StepExecutor and the
|
|
275
|
-
subagent ToolDispatch each carried a private copy of the carrier
|
|
276
|
-
classification (Result / status-duck / raw string), the error-prefix
|
|
277
|
-
lexicon and the truncation-knob fetch. Both planes now delegate to
|
|
278
|
-
`Rubik::Tools::ResultNormalizer`; the parity suite stays as anti-drift
|
|
279
|
-
insurance and a non-fetchable config object now warns once instead of
|
|
280
|
-
silently dropping operator-set truncation limits. Subagent-plane edge
|
|
281
|
-
cases (blank error first line, error?/failed? precedence) unified onto
|
|
282
|
-
the root behavior, pinned by tests.
|
|
283
|
-
|
|
284
|
-
- **Tool plane membership declared on the tool:** ScopedRegistry's
|
|
285
|
-
hand-maintained `ROOT_ONLY_TOOLS` / `BUFFER_BOUND_TOOLS` name lists now
|
|
286
|
-
project from the tools' own `Declaration`s (`root_only:`, `buffer_bound:`)
|
|
287
|
-
via `Catalog` — the same declaration→projection pattern the archetype
|
|
288
|
-
allowlists, spawn set, write gate and maestro gate already use.
|
|
289
|
-
|
|
290
|
-
### Fixed
|
|
291
|
-
|
|
292
|
-
- **Strict typed schema enforcement:** `Config#set`, `Scoped#set`, and
|
|
293
|
-
`Scoped` constructor overrides now reject values that violate
|
|
294
|
-
`Schema::DEFINITIONS` (previously the validation result was ignored —
|
|
295
|
-
e.g. `set("agent.max_steps", 0)` was silently accepted). The per-key
|
|
296
|
-
prompt-grace escape hatch is gone; the schema is the single validation
|
|
297
|
-
authority, including whole-section writes (nested leaves are coerced
|
|
298
|
-
first) and boot-time merged-tree validation. The stale
|
|
299
|
-
`buffer.auto_apply` enum gained the documented `on_test`/`on_finish`
|
|
300
|
-
modes, `sandbox.driver` became free-form (the driver registry is
|
|
301
|
-
plugin-extensible), and `tools.call_timeout` accepts `0` as its
|
|
302
|
-
documented off value.
|
|
303
|
-
- **Phantom legacy env mappings removed:** six `LEGACY_MAP` entries pointed
|
|
304
|
-
at config keys no consumer reads (their real consumers read ENV
|
|
305
|
-
directly), so their deprecation advice was false and the mapped values
|
|
306
|
-
tripped "Unknown config key" warnings. Only config-backed legacy
|
|
307
|
-
variables remain.
|
|
308
|
-
|
|
309
373
|
## [0.7.1] - 2026-11-04
|
|
310
374
|
|
|
311
375
|
An LSP maturity patch: the language-server integration comes back from
|
|
@@ -1465,7 +1529,8 @@ installation section.
|
|
|
1465
1529
|
- Context: serialized index mutations, snapshot-outside-lock reconcile,
|
|
1466
1530
|
streaming-first truncation.
|
|
1467
1531
|
|
|
1468
|
-
[Unreleased]: https://github.com/ozgurulukir/rubik/compare/v0.9.
|
|
1532
|
+
[Unreleased]: https://github.com/ozgurulukir/rubik/compare/v0.9.1...HEAD
|
|
1533
|
+
[0.9.1]: https://github.com/ozgurulukir/rubik/compare/v0.9.0...v0.9.1
|
|
1469
1534
|
[0.9.0]: https://github.com/ozgurulukir/rubik/compare/v0.8.1...v0.9.0
|
|
1470
1535
|
[0.8.1]: https://github.com/ozgurulukir/rubik/compare/v0.8.0...v0.8.1
|
|
1471
1536
|
[0.8.0]: https://github.com/ozgurulukir/rubik/compare/v0.7.1...v0.8.0
|
data/README.md
CHANGED
|
@@ -125,7 +125,11 @@ a dependency from source; see the [installation guide](docs/how-to/installation.
|
|
|
125
125
|
12. **Extensions · MCP servers.** Connect external stdio servers and expose
|
|
126
126
|
discovered tools through Rubik's registry. Lifecycle cleanup removes proxy
|
|
127
127
|
tools and attempts to stop child processes when the server is disconnected.
|
|
128
|
-
|
|
128
|
+
Spawn commands pass the same Guard gate as agent commands; servers inherit
|
|
129
|
+
the host environment (minus bundler/Ruby runtime variables) by default, and
|
|
130
|
+
a per-server `inherit_env: false` opts out of forwarding credential-shaped
|
|
131
|
+
variables. See [MCP commands](docs/reference/commands.md) and the
|
|
132
|
+
[environment reference](docs/reference/environment.md).
|
|
129
133
|
13. **Recovery · Live service repair.** Inspect runtime state, verify a
|
|
130
134
|
replacement command in a disposable context, then promote it without
|
|
131
135
|
restarting the process. Failed promotion or persistence unwinds session
|
data/lib/rubik/adapter/base.rb
CHANGED
|
@@ -5,6 +5,7 @@ require_relative "process"
|
|
|
5
5
|
require_relative "../platform"
|
|
6
6
|
require_relative "../runtime/discovery"
|
|
7
7
|
require_relative "../runtime/diagnostic_engine"
|
|
8
|
+
require_relative "../security/guard" unless defined?(Rubik::Security::Guard)
|
|
8
9
|
|
|
9
10
|
module Rubik
|
|
10
11
|
module Adapter
|
|
@@ -107,6 +108,7 @@ module Rubik
|
|
|
107
108
|
|
|
108
109
|
def resolve_test_cmd(root_dir = Dir.pwd, path: nil)
|
|
109
110
|
base = if @custom_test_cmd && !@custom_test_cmd.strip.empty?
|
|
111
|
+
validate_custom_command!(@custom_test_cmd)
|
|
110
112
|
@custom_test_cmd
|
|
111
113
|
else
|
|
112
114
|
discovered = if @config
|
|
@@ -135,6 +137,7 @@ module Rubik
|
|
|
135
137
|
|
|
136
138
|
def resolve_format_cmd(file_path)
|
|
137
139
|
if @custom_format_cmd && !@custom_format_cmd.strip.empty?
|
|
140
|
+
validate_custom_command!(@custom_format_cmd)
|
|
138
141
|
if @custom_format_cmd.include?("%s")
|
|
139
142
|
format(@custom_format_cmd, Shellwords.escape(file_path))
|
|
140
143
|
else
|
|
@@ -152,6 +155,22 @@ module Rubik
|
|
|
152
155
|
|
|
153
156
|
protected
|
|
154
157
|
|
|
158
|
+
# Validate a custom command string through the Security::Guard before it
|
|
159
|
+
# is ever interpolated into a shell string or executed. These commands
|
|
160
|
+
# are operator-supplied arbitrary shell commands; running them without
|
|
161
|
+
# classification is the exact RCE surface the adapters used to expose.
|
|
162
|
+
# Fail-closed: an unclassifiable or dangerous string raises
|
|
163
|
+
# BlockedWriteError rather than running. A subclass may pre-seed
|
|
164
|
+
# @validation_guard with the shared session guard (operator policy);
|
|
165
|
+
# the fresh fallback (silent audit, zero policy) serves standalone/test
|
|
166
|
+
# constructions only.
|
|
167
|
+
def validate_custom_command!(cmd_str, shell: nil)
|
|
168
|
+
return true if cmd_str.nil? || cmd_str.to_s.strip.empty?
|
|
169
|
+
|
|
170
|
+
(@validation_guard ||= Rubik::Security::Guard.new(audit_log_path: nil)).verify_command_safety!(cmd_str, shell: shell)
|
|
171
|
+
true
|
|
172
|
+
end
|
|
173
|
+
|
|
155
174
|
def default_test_cmd
|
|
156
175
|
nil
|
|
157
176
|
end
|
|
@@ -32,20 +32,6 @@ module Rubik
|
|
|
32
32
|
@custom_syntax_cmd = syntax_cmd
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
# Validate a custom command string through the Security::Guard before it
|
|
36
|
-
# is ever executed. These commands are operator-supplied arbitrary shell
|
|
37
|
-
# commands; running them without classification is the exact RCE surface
|
|
38
|
-
# this adapter used to expose. Fail-closed: an unclassifiable or dangerous
|
|
39
|
-
# string raises BlockedWriteError rather than running. The injected
|
|
40
|
-
# session guard carries operator policy; the fresh fallback (silent
|
|
41
|
-
# audit, zero policy) serves standalone/test constructions only.
|
|
42
|
-
def validate_custom_command!(cmd_str, shell: nil)
|
|
43
|
-
return true if cmd_str.nil? || cmd_str.to_s.strip.empty?
|
|
44
|
-
|
|
45
|
-
(@validation_guard ||= Rubik::Security::Guard.new(audit_log_path: nil)).verify_command_safety!(cmd_str, shell: shell)
|
|
46
|
-
true
|
|
47
|
-
end
|
|
48
|
-
|
|
49
35
|
def available?
|
|
50
36
|
Runtime::Discovery.binary_available?(@binary_name)
|
|
51
37
|
end
|
data/lib/rubik/adapter/node.rb
CHANGED
|
@@ -19,6 +19,7 @@ module Rubik
|
|
|
19
19
|
|
|
20
20
|
def resolve_test_cmd(root_dir = Dir.pwd, path: nil)
|
|
21
21
|
base = if @custom_test_cmd && !@custom_test_cmd.strip.empty?
|
|
22
|
+
validate_custom_command!(@custom_test_cmd)
|
|
22
23
|
@custom_test_cmd
|
|
23
24
|
else
|
|
24
25
|
base_node_test_cmd(root_dir)
|
|
@@ -99,6 +100,7 @@ module Rubik
|
|
|
99
100
|
|
|
100
101
|
def resolve_format_cmd(file_path)
|
|
101
102
|
if @custom_format_cmd && !@custom_format_cmd.strip.empty?
|
|
103
|
+
validate_custom_command!(@custom_format_cmd)
|
|
102
104
|
if @custom_format_cmd.include?("%s")
|
|
103
105
|
format(@custom_format_cmd, Shellwords.escape(file_path))
|
|
104
106
|
else
|
|
@@ -6,9 +6,22 @@ module Rubik
|
|
|
6
6
|
module AST
|
|
7
7
|
module TreeSitter
|
|
8
8
|
class ZigWalker < BaseWalker
|
|
9
|
-
|
|
9
|
+
# Zig grammar node kinds vary by grammar version: the pre-1.25
|
|
10
|
+
# tree_sitter_language_pack grammar used Decl/FnProto/ProtoDecl/
|
|
11
|
+
# FunctionDecl/function_definition; 1.25+ (official tree-sitter-zig)
|
|
12
|
+
# uses function_declaration. Keep every known spelling so the walker
|
|
13
|
+
# works across the supported pack range.
|
|
14
|
+
FN_KINDS = ["FnProto", "ProtoDecl", "FunctionDecl", "function_definition",
|
|
15
|
+
"function_declaration"].freeze
|
|
10
16
|
private_constant :FN_KINDS
|
|
11
17
|
|
|
18
|
+
# Top-level declaration kinds per grammar version: pre-1.25 exposed a
|
|
19
|
+
# single "Decl" node; 1.25+ splits into variable_declaration and
|
|
20
|
+
# function_declaration (struct/enum containers are regex-matched in
|
|
21
|
+
# walk_decl off the variable_declaration text).
|
|
22
|
+
DECL_KINDS = ["Decl", "variable_declaration", "function_declaration"].freeze
|
|
23
|
+
private_constant :DECL_KINDS
|
|
24
|
+
|
|
12
25
|
def walk(root_node)
|
|
13
26
|
symbols = []
|
|
14
27
|
return symbols unless root_node
|
|
@@ -59,7 +72,7 @@ module Rubik
|
|
|
59
72
|
(0...node.named_child_count).each do |i|
|
|
60
73
|
child = node.named_child(i)
|
|
61
74
|
case child.kind
|
|
62
|
-
when
|
|
75
|
+
when *DECL_KINDS
|
|
63
76
|
walk_decl(child, symbols)
|
|
64
77
|
else
|
|
65
78
|
walk_children(child, symbols, depth: depth + 1)
|
|
@@ -25,6 +25,10 @@ module Rubik
|
|
|
25
25
|
Rubik can read and modify workspace files and run foreground and background commands.
|
|
26
26
|
Some commands may run without a separate approval. OS sandboxing is disabled by default.
|
|
27
27
|
|
|
28
|
+
MCP stdio servers spawned here inherit this environment (minus bundler/Ruby runtime
|
|
29
|
+
variables), including credential-shaped variables, unless a server configures
|
|
30
|
+
`inherit_env: false`. Treat each server's env block as a credential-flow decision.
|
|
31
|
+
|
|
28
32
|
`buffer.model_can_apply: false` only restricts applying staged buffer changes; it does
|
|
29
33
|
not restrict shell commands.
|
|
30
34
|
NOTICE
|
|
@@ -60,6 +64,7 @@ module Rubik
|
|
|
60
64
|
def trust!(workspace, store_path: default_store_path)
|
|
61
65
|
FileUtils.mkdir_p(File.dirname(store_path), mode: 0o700)
|
|
62
66
|
workspace_path = File.realpath(workspace)
|
|
67
|
+
ensure_owner_only_store!(store_path)
|
|
63
68
|
store = YAML::Store.new(store_path, true)
|
|
64
69
|
store.transaction do
|
|
65
70
|
paths = Array(store[TRUSTED_WORKSPACES_KEY])
|
|
@@ -70,6 +75,17 @@ module Rubik
|
|
|
70
75
|
|
|
71
76
|
private
|
|
72
77
|
|
|
78
|
+
# YAML::Store creates a missing file with the process umask
|
|
79
|
+
# (typically 0644); the trust store must be owner-only from the first
|
|
80
|
+
# byte on disk, so it is pre-created at 0600 before the transaction
|
|
81
|
+
# opens it. Failure keeps the legacy best-effort chmod behavior.
|
|
82
|
+
def ensure_owner_only_store!(path)
|
|
83
|
+
FileUtils.touch(path) unless File.exist?(path)
|
|
84
|
+
File.chmod(0o600, path)
|
|
85
|
+
rescue SystemCallError
|
|
86
|
+
nil
|
|
87
|
+
end
|
|
88
|
+
|
|
73
89
|
def default_store_path
|
|
74
90
|
File.join(Platform.home_dir, ".rubik", "trusted_workspaces.yml")
|
|
75
91
|
end
|
|
@@ -219,6 +219,12 @@ module Rubik
|
|
|
219
219
|
"adapter" => {}
|
|
220
220
|
}.freeze
|
|
221
221
|
|
|
222
|
+
# Retired config keys (dotted key => guidance): validate_schema emits the
|
|
223
|
+
# tailored deprecation at boot; runtime set() keeps its own warn (config_wiring.rb).
|
|
224
|
+
RETIRED_KEYS = {
|
|
225
|
+
"network.allow" => "[DEPRECATION] Config key 'network.allow' is deprecated and has no effect. Use 'sandbox.allow_network' instead."
|
|
226
|
+
}.freeze
|
|
227
|
+
|
|
222
228
|
private
|
|
223
229
|
|
|
224
230
|
# Schema-backed keys must satisfy their spec wherever the merged tree is validated.
|
|
@@ -244,6 +250,8 @@ module Rubik
|
|
|
244
250
|
else
|
|
245
251
|
"Unknown config key '#{current_key}'."
|
|
246
252
|
end
|
|
253
|
+
# A retired key wins over the generic/fuzzy unknown-key line.
|
|
254
|
+
suggestion_msg = retired_key_warning(current_key, val) || suggestion_msg
|
|
247
255
|
|
|
248
256
|
raise ArgumentError, suggestion_msg if strict
|
|
249
257
|
|
|
@@ -253,6 +261,21 @@ module Rubik
|
|
|
253
261
|
end
|
|
254
262
|
end
|
|
255
263
|
end
|
|
264
|
+
|
|
265
|
+
# Tailored deprecation for a retired key (RETIRED_KEYS): an exact dotted
|
|
266
|
+
# hit, or a config-file section whose subtree carries a retired leaf
|
|
267
|
+
# ("network: {allow: true}" lands on unknown top-level 'network').
|
|
268
|
+
# nil falls through to the generic unknown-key line.
|
|
269
|
+
def retired_key_warning(current_key, val)
|
|
270
|
+
return RETIRED_KEYS[current_key] if RETIRED_KEYS.key?(current_key)
|
|
271
|
+
|
|
272
|
+
return nil unless val.is_a?(Hash)
|
|
273
|
+
|
|
274
|
+
retired_leaves = val.keys.filter_map { |child| RETIRED_KEYS["#{current_key}.#{child}"] }
|
|
275
|
+
return nil if retired_leaves.empty?
|
|
276
|
+
|
|
277
|
+
retired_leaves.join(" ")
|
|
278
|
+
end
|
|
256
279
|
end
|
|
257
280
|
end
|
|
258
281
|
end
|
data/lib/rubik/config/store.rb
CHANGED
|
@@ -67,6 +67,7 @@ module Rubik
|
|
|
67
67
|
nil
|
|
68
68
|
end
|
|
69
69
|
store = store_for(scope_sym)
|
|
70
|
+
ensure_owner_only!(target_path)
|
|
70
71
|
|
|
71
72
|
validation_error = nil
|
|
72
73
|
store.transaction do
|
|
@@ -136,6 +137,19 @@ module Rubik
|
|
|
136
137
|
|
|
137
138
|
private
|
|
138
139
|
|
|
140
|
+
# Provider api_key values persist in these stores, so the file must be
|
|
141
|
+
# owner-only from the first byte on disk. YAML::Store creates a missing
|
|
142
|
+
# file with the process umask (typically 0644); pre-creating at 0600
|
|
143
|
+
# closes the window before the first transaction opens it. A chmod
|
|
144
|
+
# failure keeps the legacy best-effort behavior instead of failing the
|
|
145
|
+
# save.
|
|
146
|
+
def ensure_owner_only!(path)
|
|
147
|
+
FileUtils.touch(path) unless File.exist?(path)
|
|
148
|
+
File.chmod(0o600, path)
|
|
149
|
+
rescue SystemCallError
|
|
150
|
+
nil
|
|
151
|
+
end
|
|
152
|
+
|
|
139
153
|
def ensure_rubik_directories
|
|
140
154
|
rubik_home = File.join(@home_dir, ".rubik")
|
|
141
155
|
["snapshots", "sessions", "commands", "tools"].each do |sub|
|
|
@@ -126,7 +126,7 @@ module Rubik
|
|
|
126
126
|
|
|
127
127
|
dispatch_event(item)
|
|
128
128
|
rescue StandardError => e
|
|
129
|
-
@logger&.error("Dispatcher worker error: #{e.message}")
|
|
129
|
+
@logger&.error("Dispatcher worker error: #{e.class}: #{e.message}")
|
|
130
130
|
end
|
|
131
131
|
end
|
|
132
132
|
|
|
@@ -140,11 +140,11 @@ module Rubik
|
|
|
140
140
|
listener.arity.zero? ? listener.call : listener.call(event.payload)
|
|
141
141
|
rescue StandardError => e
|
|
142
142
|
begin
|
|
143
|
-
@dmesg&.log(:kernel, :err, "Subscriber error on #{event.name}: #{e.message}")
|
|
143
|
+
@dmesg&.log(:kernel, :err, "Subscriber error on #{event.name}: #{e.class}: #{e.message}")
|
|
144
144
|
rescue StandardError
|
|
145
145
|
nil
|
|
146
146
|
end
|
|
147
|
-
@logger&.error("EventBus subscriber error on event '#{event.name}': #{e.message}")
|
|
147
|
+
@logger&.error("EventBus subscriber error on event '#{event.name}': #{e.class}: #{e.message}")
|
|
148
148
|
end
|
|
149
149
|
|
|
150
150
|
def log_to_dmesg(event)
|
|
@@ -160,7 +160,7 @@ module Rubik
|
|
|
160
160
|
end
|
|
161
161
|
@dmesg.log(event.subsystem, event.level, "event:#{event.name}", facility_id: fac_id, **safe_data)
|
|
162
162
|
rescue StandardError => e
|
|
163
|
-
@logger&.error("Dispatcher dmesg logging error: #{e.message}")
|
|
163
|
+
@logger&.error("Dispatcher dmesg logging error: #{e.class}: #{e.message}")
|
|
164
164
|
end
|
|
165
165
|
end
|
|
166
166
|
end
|
data/lib/rubik/log.rb
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Central leveled logging core (G6 early slice): one seam for runtime
|
|
4
4
|
# diagnostics, replacing ad-hoc Kernel#warn call sites as they are triaged
|
|
5
|
-
# (
|
|
5
|
+
# (bare-rescue/warn migration tracked in _plan/59-cekirdek-guvenligi-sentez-
|
|
6
|
+
# sandbox-bare-rescue-ve-moduler-testler.md and future audits). Single-line format
|
|
6
7
|
# follows the repo's [rubik] prefix convention. Emit is error-isolated: a
|
|
7
8
|
# logger must never raise, least of all from inside a rescue body.
|
|
8
9
|
#
|