rubik 0.10.0 → 0.12.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 +117 -1
- data/lib/rubik/ast/extractor.rb +2 -1
- data/lib/rubik/ast/treesitter_extractor.rb +2 -1
- data/lib/rubik/benchmark/vakanuvis_adoption.rb +2 -1
- data/lib/rubik/buffer/manager.rb +3 -3
- data/lib/rubik/config/deep_ops.rb +3 -1
- data/lib/rubik/config/defaults.rb +8 -8
- data/lib/rubik/config/schema.rb +7 -0
- data/lib/rubik/config/secret_policy.rb +20 -10
- data/lib/rubik/config/store.rb +2 -1
- data/lib/rubik/config.rb +3 -3
- data/lib/rubik/context/ignore_rules.rb +193 -0
- data/lib/rubik/context/scanner.rb +46 -161
- data/lib/rubik/llm/anthropic.rb +2 -1
- data/lib/rubik/llm/client.rb +28 -206
- data/lib/rubik/llm/connection_pool.rb +104 -0
- data/lib/rubik/llm/formatter.rb +4 -1
- data/lib/rubik/llm/ollama.rb +2 -1
- data/lib/rubik/llm/openai_compatible.rb +2 -1
- data/lib/rubik/llm/registry.rb +3 -2
- data/lib/rubik/llm/router.rb +6 -1
- data/lib/rubik/llm/sse_parser.rb +113 -0
- data/lib/rubik/lsp/circuit_breaker.rb +98 -0
- data/lib/rubik/lsp/client_provisioner.rb +49 -0
- data/lib/rubik/lsp/manager.rb +55 -88
- data/lib/rubik/mcp/manager.rb +39 -14
- data/lib/rubik/mcp/proxy_tool.rb +2 -2
- data/lib/rubik/mcp/transport/stdio.rb +3 -2
- data/lib/rubik/orchestrator/auto_apply.rb +4 -3
- 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_state.rb +6 -2
- data/lib/rubik/orchestrator/loop.rb +30 -6
- data/lib/rubik/orchestrator/lsp_feedback.rb +1 -1
- data/lib/rubik/orchestrator/provider_resolver.rb +12 -0
- data/lib/rubik/orchestrator/step_executor.rb +2 -1
- data/lib/rubik/orchestrator/subagent/notices.rb +2 -2
- data/lib/rubik/orchestrator/subagent/step_runner.rb +7 -0
- data/lib/rubik/orchestrator/subagent/transcript_formatter.rb +2 -1
- data/lib/rubik/platform/filesystem.rb +2 -2
- data/lib/rubik/platform/io_drain.rb +3 -1
- data/lib/rubik/plugin/storage.rb +8 -8
- data/lib/rubik/repair/loop.rb +1 -1
- data/lib/rubik/repl/config_wiring.rb +5 -3
- data/lib/rubik/repl/input_execution.rb +147 -7
- data/lib/rubik/repl/lifecycle.rb +1 -1
- data/lib/rubik/repl/shell.rb +9 -1
- data/lib/rubik/repl/tee_io.rb +2 -1
- data/lib/rubik/runtime/ast_service.rb +2 -1
- data/lib/rubik/runtime/fiber.rb +1 -0
- data/lib/rubik/runtime/manager.rb +4 -1
- data/lib/rubik/runtime/overlay_storage.rb +17 -17
- data/lib/rubik/runtime/task_manager.rb +4 -4
- data/lib/rubik/sandbox/driver/base.rb +7 -0
- data/lib/rubik/sandbox/driver/docker.rb +1 -4
- data/lib/rubik/sandbox/driver/podman.rb +1 -0
- data/lib/rubik/sandbox/runner.rb +6 -5
- data/lib/rubik/security/audit_log.rb +2 -1
- data/lib/rubik/security/classifier/classifier.rb +2 -0
- data/lib/rubik/security/command_gate.rb +11 -152
- data/lib/rubik/security/guard.rb +1 -1
- data/lib/rubik/security/secret_store.rb +32 -3
- data/lib/rubik/security/segment_report.rb +161 -0
- data/lib/rubik/session/recorder.rb +2 -1
- data/lib/rubik/skills/manager.rb +2 -1
- data/lib/rubik/storage/store.rb +4 -1
- data/lib/rubik/storage/transcript_indexer.rb +3 -2
- data/lib/rubik/storage/vakanuvis.rb +2 -1
- data/lib/rubik/tools/builtins/goal_ledger.rb +12 -1
- data/lib/rubik/tools/builtins/synthesis.rb +3 -3
- data/lib/rubik/tools/preflight_runner.rb +2 -1
- data/lib/rubik/tools/registry.rb +36 -16
- data/lib/rubik/tools/uri_resolver.rb +3 -2
- data/lib/rubik/ui/capability.rb +7 -4
- data/lib/rubik/ui/markdown_stream.rb +1 -0
- data/lib/rubik/ui/renderer.rb +4 -2
- data/lib/rubik/version.rb +1 -1
- data/lib/rubik.rb +3 -3
- metadata +8 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f668c26bd4967d506b511a23d21f1a9afe91cc0c94b6d007b39e4dd1d4102e7e
|
|
4
|
+
data.tar.gz: b4d12df2cc31b33e86a97c5a1a2f050f42bbc612169eb54d36a96d238f9b5445
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4072b8c92a9f9990227c1b72996a48942fd1008a849bf9e6d6ff74c80f1448dbd10d5409158e85e1c7c5ae54463f69b0b9a68b07a542a87cb51a837e8bee4751
|
|
7
|
+
data.tar.gz: 5a9679b4f592d999e9602af4758327347f7bf5a84eee8e0b70bb5591830eab73a65dfcc1cf7bb78ae171b2e4b32bea9ef52c8ce6f704d9806db9d440e5cef9fc
|
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,600+ 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,6 +6,120 @@ 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
|
+
## [0.12.0] - 2026-11-17
|
|
10
|
+
|
|
11
|
+
The retry-and-resume minor: the LLM transport's hardcoded rate-limit and 5xx
|
|
12
|
+
retry budgets become typed, operator-tunable `llm.*` knobs threaded end to
|
|
13
|
+
end into both agent loops, and an error-interrupted REPL turn keeps its tool
|
|
14
|
+
history and resumes on the same Loop instead of forcing the model to
|
|
15
|
+
re-discover terrain from a summary — while a robustness round protects the
|
|
16
|
+
storage config from redaction, rolls back failed persists, hardens the
|
|
17
|
+
sandbox drivers against catastrophic fallbacks, scrubs the MCP server
|
|
18
|
+
environment, sanitizes terminal-escape output, and fixes goal token
|
|
19
|
+
double-counting.
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- **Operator-tunable LLM retry budgets (`llm.max_retries`, `max_429_retries`,
|
|
24
|
+
`backoff_base`, `max_wall_clock`, `rate_limit_max_delay`):** the transport
|
|
25
|
+
layer's hardcoded rate-limit and transient-5xx constants become typed
|
|
26
|
+
defaults tunable globally or per provider (English and Turkish
|
|
27
|
+
configuration guides updated), threaded through the transport and both
|
|
28
|
+
agent loops (root loop and subagent step runner) via a helper that passes
|
|
29
|
+
only explicitly-set values so existing callers keep their built-in
|
|
30
|
+
defaults; the Retry-After delay clamp is configurable end to end with the
|
|
31
|
+
old ceiling preserved as the fallback.
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- **Failed free-text turns merge their tool history into conversation memory
|
|
36
|
+
(#511):** a mid-run LLM error no longer drops the in-turn tool messages —
|
|
37
|
+
the path-independent merge contract is wired into all three failure rescue
|
|
38
|
+
bodies (LLM error, unexpected error, ^C) with the outcome text leading the
|
|
39
|
+
window.
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
|
|
43
|
+
- **An error-interrupted free-text turn resumes on the same Loop (#511):** the
|
|
44
|
+
REPL stashes the surviving Loop and an exact-match resume intent
|
|
45
|
+
("devam et"/"continue"/…) continues from the interrupted step counter with
|
|
46
|
+
a `<turn_resumed>` marker instead of spawning a fresh Loop; resume-intent
|
|
47
|
+
parsing is linear-time (CodeQL polynomial ReDoS) with a length-form slice
|
|
48
|
+
guard.
|
|
49
|
+
- **Fiber retry resurrection, goal token double-count, and resume
|
|
50
|
+
history/stash (#528):** the runtime retry path can no longer resurrect a
|
|
51
|
+
disposed fiber, goal tokens are counted once, and loop history cursors use
|
|
52
|
+
`ObjectSpace::WeakMap` so completed Loops are not retained.
|
|
53
|
+
- **Terminal escapes sanitized, conflict FrozenError, SSE UTF-8, router enum,
|
|
54
|
+
fence tags (#530):** a robustness sweep across ui/buffer/llm/repair.
|
|
55
|
+
- **MCP proxy collisions, server restart on re-add, env scrubbing, and
|
|
56
|
+
registry alias ownership (#527).**
|
|
57
|
+
- **Storage config protected from redaction, failed persists rolled back,
|
|
58
|
+
digit hash lookup and atomic_write fixed (#529):** session-only semantics
|
|
59
|
+
are preserved when a disk persist fails.
|
|
60
|
+
- **Catastrophic fallback regex enforced and sandbox drivers hardened
|
|
61
|
+
(#526):** `/$x`-style patterns are classified as system paths and
|
|
62
|
+
`resolved_path_under?` is reused.
|
|
63
|
+
|
|
64
|
+
## [0.11.0] - 2026-11-16
|
|
65
|
+
|
|
66
|
+
The schema-grammar minor: the goal-ledger stops teaching its schema through
|
|
67
|
+
failure — the bounded-retry protocol's rejection hints no longer carry the
|
|
68
|
+
only copy of the grammar, which is now derived from `Ledger::PRODUCTION_SCHEMA`
|
|
69
|
+
and surfaced on every static model-facing surface — while the extraction wave
|
|
70
|
+
keeps sweeping (an SSE parser and connection pool out of the LLM client, a
|
|
71
|
+
segment report out of the command gate, a circuit breaker out of the LSP
|
|
72
|
+
manager, an ignore-rules value object out of the context scanner), duplicated
|
|
73
|
+
invariants collapse onto single homes, the remaining `Kernel#warn` sites move
|
|
74
|
+
onto `Rubik::Log`, and the secret-store backends get hardened against IO
|
|
75
|
+
failures.
|
|
76
|
+
|
|
77
|
+
### Added
|
|
78
|
+
|
|
79
|
+
- **Goal-ledger schema grammar on static surfaces (#494):** a single-line
|
|
80
|
+
grammar summary derived from `Ledger::PRODUCTION_SCHEMA` (schema SSOT, never
|
|
81
|
+
hand-written) now appears in the `update_goal_ledger` tool description, as a
|
|
82
|
+
state-independent `<vocabulary>` element on the Sigma XML page, and in the
|
|
83
|
+
patch-budget-exhausted feedback — so a model no longer has to burn its
|
|
84
|
+
rejection budget to learn the status enum, the required id, or the
|
|
85
|
+
section-append rule. The exhaustion contract stays verbatim and rejection
|
|
86
|
+
reasons are deliberately not cached.
|
|
87
|
+
|
|
88
|
+
### Changed
|
|
89
|
+
|
|
90
|
+
- **Remaining `Kernel#warn` call sites migrate onto `Rubik::Log` (#510):**
|
|
91
|
+
all user-facing diagnostic emissions route through the sanctioned
|
|
92
|
+
`Log.warn(:subsystem, message)` seam with message content (including
|
|
93
|
+
`[WARN]`/`[SECURITY]`/`[DEPRECATION]`/`[BOOTSTRAP]` prefixes) preserved
|
|
94
|
+
verbatim; only the two sanctioned `$stderr` sites remain.
|
|
95
|
+
- **SegmentReport extracted from CommandGate (#508).**
|
|
96
|
+
- **SSEParser and ConnectionPool split out of the LLM client (#505).**
|
|
97
|
+
- **IgnoreRules value object extracted from the context Scanner (#498).**
|
|
98
|
+
- **LSP circuit breaker and client provisioning extracted from Manager
|
|
99
|
+
(#497).**
|
|
100
|
+
- **Duplicated invariants single-homed (#502):** SSEParser's two drain loops
|
|
101
|
+
collapse into `drain_complete_events(final:)`, `post_stream_json` reuses
|
|
102
|
+
`parse_and_validate_uri`, the MCP D5 boot gate resolves through one
|
|
103
|
+
`boot_gate_open?` predicate, the Scanner's reserved-root rejections back
|
|
104
|
+
onto one `reserved_root?`, and the two EXTENSION_MAPs get cross-reference
|
|
105
|
+
comments so their deliberate divergence stays explicit.
|
|
106
|
+
|
|
107
|
+
### Fixed
|
|
108
|
+
|
|
109
|
+
- **Isolated `capability.rb` loads require `repl/tee_io` (#509):** an isolated
|
|
110
|
+
load no longer NameErrors.
|
|
111
|
+
- **Three small goal-ledger and secret-policy defects (#496):** XmlRender
|
|
112
|
+
escapes the finding `source_step` attribute (a corrupted suspend row could
|
|
113
|
+
inject raw text into the conversation-history XML), `Ledger#update`
|
|
114
|
+
validates patches inside the monitor, and SecretPolicy drops an unreachable
|
|
115
|
+
store-failure guard.
|
|
116
|
+
- **SecretStore command backends hardened against IO failures (#495):**
|
|
117
|
+
`IOError`/`SystemCallError` convert to `SecretStore::Error`, the stdin
|
|
118
|
+
payload travels through `Platform.write_until` with a 5s deadline instead of
|
|
119
|
+
parking `Config#set` on a full pipe buffer, the Linux backend clears prior
|
|
120
|
+
items before storing (a re-set secret previously resolved to a corrupted
|
|
121
|
+
concatenation), and the macOS reader keeps significant whitespace.
|
|
122
|
+
|
|
9
123
|
## [0.10.0] - 2026-11-15
|
|
10
124
|
|
|
11
125
|
The secret-store minor: provider credentials leave the config files for the
|
|
@@ -1670,7 +1784,9 @@ installation section.
|
|
|
1670
1784
|
- Context: serialized index mutations, snapshot-outside-lock reconcile,
|
|
1671
1785
|
streaming-first truncation.
|
|
1672
1786
|
|
|
1673
|
-
[Unreleased]: https://github.com/ozgurulukir/rubik/compare/v0.
|
|
1787
|
+
[Unreleased]: https://github.com/ozgurulukir/rubik/compare/v0.12.0...HEAD
|
|
1788
|
+
[0.12.0]: https://github.com/ozgurulukir/rubik/compare/v0.11.0...v0.12.0
|
|
1789
|
+
[0.11.0]: https://github.com/ozgurulukir/rubik/compare/v0.10.0...v0.11.0
|
|
1674
1790
|
[0.10.0]: https://github.com/ozgurulukir/rubik/compare/v0.9.1...v0.10.0
|
|
1675
1791
|
[0.9.1]: https://github.com/ozgurulukir/rubik/compare/v0.9.0...v0.9.1
|
|
1676
1792
|
[0.9.0]: https://github.com/ozgurulukir/rubik/compare/v0.8.1...v0.9.0
|
data/lib/rubik/ast/extractor.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../log"
|
|
3
4
|
require_relative "extraction_result"
|
|
4
5
|
require_relative "ruby_extractor"
|
|
5
6
|
require_relative "go_extractor"
|
|
@@ -66,7 +67,7 @@ module Rubik
|
|
|
66
67
|
# language extractor claims (:unavailable, legacy Ruby parse).
|
|
67
68
|
fallback_result(file_path, content, ext)
|
|
68
69
|
rescue StandardError, ScriptError => e
|
|
69
|
-
warn "[WARN] Extraction failed for #{file_path}: #{e.class}: #{e.message}" if ENV["RUBIK_DEBUG"]
|
|
70
|
+
Rubik::Log.warn(:ast, "[WARN] Extraction failed for #{file_path}: #{e.class}: #{e.message}") if ENV["RUBIK_DEBUG"]
|
|
70
71
|
ExtractionResult.new(symbols: [], status: :failed, source: :none, detail: "#{e.class}: #{e.message}")
|
|
71
72
|
end
|
|
72
73
|
|
|
@@ -7,6 +7,7 @@ rescue LoadError
|
|
|
7
7
|
TREE_SITTER_AVAILABLE = false
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
+
require_relative "../log"
|
|
10
11
|
require_relative "extraction_result"
|
|
11
12
|
require_relative "treesitter/base_walker"
|
|
12
13
|
require_relative "treesitter/python_walker"
|
|
@@ -94,7 +95,7 @@ module Rubik
|
|
|
94
95
|
|
|
95
96
|
ExtractionResult.new(symbols: symbols, status: :ok, source: :tree_sitter)
|
|
96
97
|
rescue StandardError, SystemStackError, ScriptError => e
|
|
97
|
-
warn "[WARN] TreeSitter extraction failed for #{file_path}: #{e.message}" if ENV["RUBIK_DEBUG"]
|
|
98
|
+
Rubik::Log.warn(:ast, "[WARN] TreeSitter extraction failed for #{file_path}: #{e.message}") if ENV["RUBIK_DEBUG"]
|
|
98
99
|
failed_result("#{e.class}: #{e.message}")
|
|
99
100
|
end
|
|
100
101
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "tmpdir"
|
|
4
4
|
require "fileutils"
|
|
5
|
+
require_relative "../log"
|
|
5
6
|
require_relative "../errors"
|
|
6
7
|
require_relative "../storage/vakanuvis"
|
|
7
8
|
require_relative "../tools/builtins/storage"
|
|
@@ -347,7 +348,7 @@ module Rubik
|
|
|
347
348
|
# Windows EBUSY/ENOTEMPTY (AV tarayıcı, indeksleyici) cleanup'ı
|
|
348
349
|
# patlatabilir — cleanup hatası tabloyu ve işlenen hatayı
|
|
349
350
|
# MaskeleMEsin; tüm benchmark'ı da abort etmesin.
|
|
350
|
-
warn " [vakanuvis-adoption] cleanup failed for #{root}: #{e.class}: #{e.message}"
|
|
351
|
+
Rubik::Log.warn(:benchmark, " [vakanuvis-adoption] cleanup failed for #{root}: #{e.class}: #{e.message}")
|
|
351
352
|
end
|
|
352
353
|
end
|
|
353
354
|
end
|
data/lib/rubik/buffer/manager.rb
CHANGED
|
@@ -183,7 +183,7 @@ module Rubik
|
|
|
183
183
|
@buffer.delete(rel_path)
|
|
184
184
|
@dirty_files.delete(rel_path)
|
|
185
185
|
@original_hashes.delete(rel_path)
|
|
186
|
-
@last_conflicts.
|
|
186
|
+
@last_conflicts = @last_conflicts.reject { |c| c == rel_path }.freeze
|
|
187
187
|
end
|
|
188
188
|
|
|
189
189
|
if from_disk
|
|
@@ -210,7 +210,7 @@ module Rubik
|
|
|
210
210
|
@buffer.delete(rel_path)
|
|
211
211
|
@dirty_files.delete(rel_path)
|
|
212
212
|
@original_hashes.delete(rel_path)
|
|
213
|
-
@last_conflicts.
|
|
213
|
+
@last_conflicts = @last_conflicts.reject { |c| c == rel_path }.freeze
|
|
214
214
|
@event_bus&.emit(:buffer_discarded, path: rel_path)
|
|
215
215
|
rel_path
|
|
216
216
|
end
|
|
@@ -286,7 +286,7 @@ module Rubik
|
|
|
286
286
|
rel = path.byteslice((root_size + 1)..-1)
|
|
287
287
|
rel = rel.tr("\\", "/") if File::ALT_SEPARATOR
|
|
288
288
|
|
|
289
|
-
if rel.start_with?(".git")
|
|
289
|
+
if rel == ".git" || rel.start_with?(".git/")
|
|
290
290
|
Find.prune if File.directory?(path)
|
|
291
291
|
next
|
|
292
292
|
end
|
|
@@ -7,7 +7,9 @@ module Rubik
|
|
|
7
7
|
"security", "sandbox", "plugins", "mcp", "lsp", "project", "test", "linter", "adapter",
|
|
8
8
|
# Provider specs carry credentials and endpoints; an untrusted
|
|
9
9
|
# project must not be able to inject either.
|
|
10
|
-
"providers"
|
|
10
|
+
"providers",
|
|
11
|
+
# Storage root/project slug must not be redirected by an untrusted workspace.
|
|
12
|
+
"storage"
|
|
11
13
|
].freeze
|
|
12
14
|
|
|
13
15
|
private
|
|
@@ -5,19 +5,19 @@ require_relative "../platform"
|
|
|
5
5
|
module Rubik
|
|
6
6
|
class Config
|
|
7
7
|
module Defaults
|
|
8
|
+
# llm.* transport-resilience fallbacks, reused by both orchestrator seams.
|
|
9
|
+
LLM_RETRY_DEFAULTS = { "max_retries" => 2, "max_429_retries" => 5, "backoff_base" => 0.2,
|
|
10
|
+
"max_wall_clock" => 120, "rate_limit_max_delay" => 60 }.freeze
|
|
11
|
+
|
|
8
12
|
DEFAULT_CONFIG = {
|
|
9
13
|
"llm" => {
|
|
10
|
-
"stream" => true,
|
|
11
|
-
"
|
|
12
|
-
"open_timeout" => 15,
|
|
13
|
-
"default_max_output_tokens" => 4096,
|
|
14
|
-
"capture_reasoning" => true,
|
|
15
|
-
"auto_continue_on_length" => true,
|
|
16
|
-
"max_auto_continues" => 3,
|
|
14
|
+
"stream" => true, "stream_timeout" => 120, "open_timeout" => 15, "default_max_output_tokens" => 4096,
|
|
15
|
+
"capture_reasoning" => true, "auto_continue_on_length" => true, "max_auto_continues" => 3,
|
|
17
16
|
# Plan 90 bridge (loop.rb): nil = not sent; non-nil reasoning_effort also flips reasoning_model?.
|
|
18
17
|
"thinking_budget_ratio" => nil, # Anthropic thinking budget share (0.0-0.8) -> opts[:thinking_budget_ratio]
|
|
19
18
|
"reasoning_effort" => nil, # OpenAI reasoning effort "low"|"medium"|"high" -> opts[:reasoning_effort]
|
|
20
|
-
"headers" => {}
|
|
19
|
+
"headers" => {},
|
|
20
|
+
**LLM_RETRY_DEFAULTS
|
|
21
21
|
},
|
|
22
22
|
"model" => { "provider" => "ollama", "name" => "qwen2.5-coder:7b", "endpoint" => "http://localhost:11434" },
|
|
23
23
|
"models" => {
|
data/lib/rubik/config/schema.rb
CHANGED
|
@@ -14,6 +14,13 @@ module Rubik
|
|
|
14
14
|
"llm.capture_reasoning" => { type: :boolean },
|
|
15
15
|
"llm.auto_continue_on_length" => { type: :boolean },
|
|
16
16
|
"llm.max_auto_continues" => { type: :integer, min: 0 },
|
|
17
|
+
# HTTP transport retry budgets (llm/client.rb post_json). 0 disables
|
|
18
|
+
# a budget; backoff_base is seconds; max_wall_clock bounds all retries.
|
|
19
|
+
"llm.max_retries" => { type: :integer, min: 0 },
|
|
20
|
+
"llm.max_429_retries" => { type: :integer, min: 0 },
|
|
21
|
+
"llm.backoff_base" => { type: :float, min: 0.0 },
|
|
22
|
+
"llm.max_wall_clock" => { type: :integer, min: 0 },
|
|
23
|
+
"llm.rate_limit_max_delay" => { type: :integer, min: 0 },
|
|
17
24
|
"llm.thinking_budget_ratio" => { type: :float, min: 0.0, max: 0.8, nullable: true },
|
|
18
25
|
"llm.reasoning_effort" => { type: :enum, allowed: ["low", "medium", "high"], nullable: true },
|
|
19
26
|
"agent.max_steps" => { type: :integer, min: 1 },
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../log"
|
|
3
4
|
require_relative "../security/secret_store"
|
|
4
5
|
|
|
5
6
|
module Rubik
|
|
@@ -84,10 +85,10 @@ module Rubik
|
|
|
84
85
|
|
|
85
86
|
if store_error
|
|
86
87
|
# gh-style degradation: the write proceeds with plaintext plus a
|
|
87
|
-
# loud warning
|
|
88
|
-
#
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
# loud warning. Project scope never reaches this fallback with
|
|
89
|
+
# the plaintext guard closed — that refusal happens up front,
|
|
90
|
+
# before the store loop, so a store failure here can only mean
|
|
91
|
+
# the override was open.
|
|
91
92
|
warn_secret_store_fallback(store_error, scope)
|
|
92
93
|
return { info: plaintext_fallback_info }
|
|
93
94
|
end
|
|
@@ -122,11 +123,20 @@ module Rubik
|
|
|
122
123
|
# of an api_key path also drops its stored secret(s) — both scopes'
|
|
123
124
|
# names, so neither keyring entry outlives its reference. Best-effort
|
|
124
125
|
# — never masks res.
|
|
125
|
-
def cleanup_stored_secret(key, res, persist)
|
|
126
|
-
return unless
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
def cleanup_stored_secret(key, res, persist, old_val: nil)
|
|
127
|
+
return unless res[:ok] && persisting?(persist)
|
|
128
|
+
|
|
129
|
+
keys_to_delete = if secret_key?(key)
|
|
130
|
+
[key.to_s]
|
|
131
|
+
elsif old_val.is_a?(Hash)
|
|
132
|
+
collect_secret_leaves(key, old_val).map(&:first)
|
|
133
|
+
else
|
|
134
|
+
[]
|
|
135
|
+
end
|
|
136
|
+
keys_to_delete.each do |secret_path|
|
|
137
|
+
Rubik::Security::SecretStore.delete(secret_path)
|
|
138
|
+
Rubik::Security::SecretStore.delete("#{secret_path}.project")
|
|
139
|
+
end
|
|
130
140
|
rescue Rubik::Security::SecretStore::Error
|
|
131
141
|
nil
|
|
132
142
|
end
|
|
@@ -185,7 +195,7 @@ module Rubik
|
|
|
185
195
|
def warn_secret_store_fallback(error, scope)
|
|
186
196
|
msg = "OS secret store unavailable (#{error.message}); plaintext kept in #{scope} config"
|
|
187
197
|
@warnings << msg
|
|
188
|
-
warn "[WARN] #{msg}" if ENV["RUBIK_DEBUG"]
|
|
198
|
+
Rubik::Log.warn(:config, "[WARN] #{msg}") if ENV["RUBIK_DEBUG"]
|
|
189
199
|
end
|
|
190
200
|
|
|
191
201
|
def plaintext_fallback_info
|
data/lib/rubik/config/store.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require "yaml"
|
|
4
4
|
require "yaml/store"
|
|
5
5
|
require "fileutils"
|
|
6
|
+
require_relative "../log"
|
|
6
7
|
require_relative "pruner"
|
|
7
8
|
|
|
8
9
|
module Rubik
|
|
@@ -38,7 +39,7 @@ module Rubik
|
|
|
38
39
|
begin
|
|
39
40
|
FileUtils.mkdir_p(File.dirname(path))
|
|
40
41
|
rescue SystemCallError => e
|
|
41
|
-
warn "[WARN] Failed to create config directory #{File.dirname(path)}: #{e.message}" if ENV["RUBIK_DEBUG"]
|
|
42
|
+
Rubik::Log.warn(:config, "[WARN] Failed to create config directory #{File.dirname(path)}: #{e.message}") if ENV["RUBIK_DEBUG"]
|
|
42
43
|
end
|
|
43
44
|
YAML::Store.new(path, true)
|
|
44
45
|
end
|
data/lib/rubik/config.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "monitor"
|
|
4
|
+
require_relative "log"
|
|
4
5
|
require_relative "config/defaults"
|
|
5
6
|
require_relative "config/deep_ops"
|
|
6
7
|
require_relative "config/store"
|
|
@@ -21,7 +22,6 @@ module Rubik
|
|
|
21
22
|
|
|
22
23
|
DEFAULT_CONFIG = Defaults::DEFAULT_CONFIG
|
|
23
24
|
SENSITIVE_PROJECT_CONFIG_KEYS = DeepOps::SENSITIVE_PROJECT_CONFIG_KEYS
|
|
24
|
-
|
|
25
25
|
attr_reader :data, :warnings, :root_dir, :home_dir,
|
|
26
26
|
:defaults_layer, :global_layer, :project_layer, :env_layer, :session_layer
|
|
27
27
|
attr_accessor :event_bus
|
|
@@ -167,7 +167,7 @@ module Rubik
|
|
|
167
167
|
notify_change(key, new_val, old_val)
|
|
168
168
|
@event_bus&.emit(:config_deleted, key: key.to_s, old_val: old_val)
|
|
169
169
|
end
|
|
170
|
-
cleanup_stored_secret(key, res, persist)
|
|
170
|
+
cleanup_stored_secret(key, res, persist, old_val: old_val)
|
|
171
171
|
res
|
|
172
172
|
end
|
|
173
173
|
end
|
|
@@ -254,7 +254,7 @@ module Rubik
|
|
|
254
254
|
begin
|
|
255
255
|
entry[:callback].call(key_str, new_val, old_val)
|
|
256
256
|
rescue StandardError => e
|
|
257
|
-
warn "[WARN] Config listener failed for '#{key_str}': #{e.message}"
|
|
257
|
+
Rubik::Log.warn(:config, "[WARN] Config listener failed for '#{key_str}': #{e.message}")
|
|
258
258
|
@event_bus&.emit(:config_listener_error, key: key_str, error: e.message)
|
|
259
259
|
end
|
|
260
260
|
end
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rubik
|
|
4
|
+
module Context
|
|
5
|
+
# Frozen value object owning the entire "is this path in scope?" dialect
|
|
6
|
+
# of the context index: default ignore globs, the repo's own .gitignore,
|
|
7
|
+
# user excludes/includes, whole-subtree pruning, and the reserved runtime
|
|
8
|
+
# roots. Built once per scan root via .build, it answers three predicates
|
|
9
|
+
# — prune_dir?, ignore_file? / listed_file_ignored?, include_file? — so
|
|
10
|
+
# both listing strategies (Scanner#walk_dir and the git ls-files fast
|
|
11
|
+
# path) stay symmetric by consuming the same rules instead of each
|
|
12
|
+
# re-implementing the filter sequence.
|
|
13
|
+
class IgnoreRules
|
|
14
|
+
DEFAULT_IGNORES = [
|
|
15
|
+
".rubik/**",
|
|
16
|
+
".git/**",
|
|
17
|
+
# GitNexus parse cache: thousands of binary index files; indexing
|
|
18
|
+
# them is pure cost and their non-UTF-8 bytes are a grep hazard.
|
|
19
|
+
".gitnexus/**",
|
|
20
|
+
".ua/**",
|
|
21
|
+
".trash*/**",
|
|
22
|
+
"**/.trash*/**",
|
|
23
|
+
".turbo/**",
|
|
24
|
+
".sst/**",
|
|
25
|
+
".next/**",
|
|
26
|
+
".nuxt/**",
|
|
27
|
+
"node_modules/**",
|
|
28
|
+
"vendor/**",
|
|
29
|
+
"tmp/**",
|
|
30
|
+
"dist/**",
|
|
31
|
+
"build/**",
|
|
32
|
+
".cache/**",
|
|
33
|
+
"coverage/**",
|
|
34
|
+
# Multi-GB local model blobs; never project sources.
|
|
35
|
+
".ollama/**",
|
|
36
|
+
# Agent-harness state: transcripts, sessions, caches.
|
|
37
|
+
".zcode/**"
|
|
38
|
+
].freeze
|
|
39
|
+
|
|
40
|
+
# Subtrees whose ignore pattern is "<path>/**" (optionally with a
|
|
41
|
+
# "**/" prefix) are pruned whole when the stem's components occur
|
|
42
|
+
# contiguously in a directory's path. NOTE: this is intentionally
|
|
43
|
+
# STRONGER than the legacy per-file filter — Ruby's fnmatch treats a
|
|
44
|
+
# trailing `**` as a single segment, so patterns like "node_modules/**"
|
|
45
|
+
# historically rejected only first-level entries while deeper files
|
|
46
|
+
# leaked into the index. The walker applies the pattern's plain meaning
|
|
47
|
+
# (whole subtree ignored), matching real gitignore semantics.
|
|
48
|
+
PRUNABLE_PATTERN = %r{\A(?:\*\*/)?(.+)/\*\*\z}
|
|
49
|
+
# Also hard-rejected inside ignore_file?; pruned before descending.
|
|
50
|
+
# ROOT-anchored only (comps.first) to match the rg-side `!/X/**`
|
|
51
|
+
# globs — a nested `src/AppData` stays indexed.
|
|
52
|
+
HARD_PRUNE_ROOTS = [".git", ".rubik", ".ua", ".turbo", ".sst", ".next", ".nuxt", "AppData"].freeze
|
|
53
|
+
|
|
54
|
+
attr_reader :custom_includes
|
|
55
|
+
|
|
56
|
+
# `dir` is the scan root whose top-level .gitignore contributes
|
|
57
|
+
# patterns; excludes/includes come from the Scanner's accessors.
|
|
58
|
+
def self.build(dir:, custom_excludes: [], custom_includes: [])
|
|
59
|
+
new(DEFAULT_IGNORES + parse_gitignore(dir) + custom_excludes, custom_includes)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Reads one root's .gitignore: comments and blanks dropped, directory
|
|
63
|
+
# entries ("tmp/") widened to whole-subtree globs ("tmp/**").
|
|
64
|
+
def self.parse_gitignore(dir)
|
|
65
|
+
gitignore_path = File.join(dir, ".gitignore")
|
|
66
|
+
return [] unless File.exist?(gitignore_path)
|
|
67
|
+
|
|
68
|
+
patterns = File.readlines(gitignore_path, chomp: true).map(&:strip).reject do |line|
|
|
69
|
+
line.empty? || line.start_with?("#")
|
|
70
|
+
end
|
|
71
|
+
patterns.map do |pattern|
|
|
72
|
+
pattern.end_with?("/") ? "#{pattern}**" : pattern
|
|
73
|
+
end
|
|
74
|
+
rescue Errno::ENOENT, Errno::EACCES
|
|
75
|
+
[]
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# `patterns` is the merged ignore table; `custom_includes` the user's
|
|
79
|
+
# allow-list. Compilation happens eagerly here so the predicates are
|
|
80
|
+
# allocation-free lookups afterwards.
|
|
81
|
+
def initialize(patterns, custom_includes)
|
|
82
|
+
@patterns = patterns.freeze
|
|
83
|
+
@custom_includes = (custom_includes || []).freeze
|
|
84
|
+
# "<dir>/**" patterns pre-split into needle component arrays.
|
|
85
|
+
# Matching a directory then costs plain array compares — no
|
|
86
|
+
# per-ancestor regex evaluation and no re-splitting of the pattern's
|
|
87
|
+
# stem for every file visited.
|
|
88
|
+
@prunable_needles = @patterns.filter_map do |pattern|
|
|
89
|
+
next unless (m = PRUNABLE_PATTERN.match(pattern))
|
|
90
|
+
|
|
91
|
+
m[1].split("/")
|
|
92
|
+
end.freeze
|
|
93
|
+
@file_regexes = compile(@patterns).freeze
|
|
94
|
+
# The git fast path skips prunable subtree patterns with literal
|
|
95
|
+
# stems: its ancestor loop already pruned every directory segment
|
|
96
|
+
# through prune_dir?, so re-testing those globs per file is pure
|
|
97
|
+
# redundancy. Exotic stems (wildcards) stay in the per-file set.
|
|
98
|
+
@listed_file_regexes = compile(listed_file_patterns).freeze
|
|
99
|
+
freeze
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Should descent into a directory stop? `rel_comps` is the directory's
|
|
103
|
+
# path split on "/". Applies the hard-prune roots (root-anchored) and
|
|
104
|
+
# the whole-subtree globs (contiguous component match). The one
|
|
105
|
+
# predicate behind the walker's early pruning and the fast path's
|
|
106
|
+
# ancestor check.
|
|
107
|
+
def prune_dir?(rel_comps)
|
|
108
|
+
return true if HARD_PRUNE_ROOTS.include?(rel_comps.first)
|
|
109
|
+
|
|
110
|
+
@prunable_needles.any? { |needle| contiguous_components?(rel_comps, needle) }
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Walker-dialect file filter: reserved roots plus every ignore pattern
|
|
114
|
+
# (prunable ones included, with the documented legacy fnmatch drift).
|
|
115
|
+
def ignore_file?(rel)
|
|
116
|
+
reserved_root?(rel) || @file_regexes.any? { |r| pattern_match?(r, rel) }
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Fast-path-dialect file filter: same reserved roots, but prunable
|
|
120
|
+
# literal-stem subtree patterns are withheld because prune_dir? already
|
|
121
|
+
# covered their ancestors (see initialize).
|
|
122
|
+
def listed_file_ignored?(rel)
|
|
123
|
+
reserved_root?(rel) || @listed_file_regexes.any? { |r| pattern_match?(r, rel) }
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Include dialect: no include patterns means "everything is included";
|
|
127
|
+
# otherwise a file must match at least one pattern.
|
|
128
|
+
def include_file?(rel)
|
|
129
|
+
return true if @custom_includes.empty?
|
|
130
|
+
|
|
131
|
+
@custom_includes.any? { |pattern| pattern_match?(pattern, rel) }
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
private
|
|
135
|
+
|
|
136
|
+
def listed_file_patterns
|
|
137
|
+
@patterns.reject do |pat|
|
|
138
|
+
m = PRUNABLE_PATTERN.match(pat)
|
|
139
|
+
m && !m[1].include?("*") && !m[1].include?("?") && !m[1].include?("[")
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def contiguous_components?(haystack, needle)
|
|
144
|
+
return true if haystack == needle
|
|
145
|
+
return false if haystack.size < needle.size
|
|
146
|
+
|
|
147
|
+
(0..(haystack.size - needle.size)).any? do |offset|
|
|
148
|
+
haystack[offset, needle.size] == needle
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Runtime-owned roots are never indexed, whatever the ignore tables
|
|
153
|
+
# say — the one predicate behind both listing strategies (the git
|
|
154
|
+
# fast path and the generic walk).
|
|
155
|
+
def reserved_root?(rel)
|
|
156
|
+
rel == ".rubik" || rel.start_with?(".rubik/") || rel == ".git" || rel.start_with?(".git/")
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Translates a glob into a Regexp only where the mapping is exact: no
|
|
160
|
+
# character classes, no leading-slash anchoring, and `**` only ever a
|
|
161
|
+
# whole path segment (leading "**/", mid "/**/", trailing "/**").
|
|
162
|
+
# Anything else keeps the pattern string and pattern_match? falls back
|
|
163
|
+
# to File.fnmatch?, whose segment rules the Regexp form cannot express
|
|
164
|
+
# (fnmatch "a**b" never crosses "/" and "**/x" also matches bare "x").
|
|
165
|
+
def compile(ignore_patterns)
|
|
166
|
+
ignore_patterns.map do |pat|
|
|
167
|
+
simple_glob_regex(pat) || pat
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def simple_glob_regex(pat)
|
|
172
|
+
return nil if pat.empty? || pat.start_with?("/") || pat.include?("[")
|
|
173
|
+
return nil unless pat.split("/").all? { |seg| !seg.include?("*") || seg == "**" || !seg.include?("**") }
|
|
174
|
+
|
|
175
|
+
src = Regexp.escape(pat)
|
|
176
|
+
src = src.sub(%r{\A\\\*\\\*/}, "") # leading "**/": the (?:.*/)? wrapper matches zero dirs too
|
|
177
|
+
src = src.gsub("/\\*\\*/", "/(?:.*/)?") # mid "/**/": zero or more directories
|
|
178
|
+
src = src.gsub("\\*\\*", ".*") # trailing "/**" or lone "**"
|
|
179
|
+
src = src.gsub("\\*", "[^/]*").gsub("\\?", "[^/]")
|
|
180
|
+
Regexp.new("\\A(?:.*/)?#{src}\\z")
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def pattern_match?(pattern_or_regex, path)
|
|
184
|
+
if pattern_or_regex.is_a?(Regexp)
|
|
185
|
+
pattern_or_regex.match?(path)
|
|
186
|
+
else
|
|
187
|
+
File.fnmatch?(pattern_or_regex, path, File::FNM_PATHNAME | File::FNM_DOTMATCH) ||
|
|
188
|
+
File.fnmatch?("**/#{pattern_or_regex}", path, File::FNM_PATHNAME | File::FNM_DOTMATCH)
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|