rubik 0.1.6 → 0.3.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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/ATTRIBUTION.md +5 -1
  3. data/CHANGELOG.md +169 -0
  4. data/README.md +137 -255
  5. data/bin/rubik +9 -0
  6. data/lib/rubik/ast/extraction_result.rb +37 -0
  7. data/lib/rubik/ast/extractor.rb +35 -9
  8. data/lib/rubik/ast/graph.rb +27 -1
  9. data/lib/rubik/ast/treesitter/c_walker.rb +136 -28
  10. data/lib/rubik/ast/treesitter_extractor.rb +45 -17
  11. data/lib/rubik/buffer/apply_contract.rb +78 -0
  12. data/lib/rubik/buffer/manager.rb +61 -5
  13. data/lib/rubik/cli/workspace_trust.rb +78 -0
  14. data/lib/rubik/concurrency/event_loop.rb +56 -44
  15. data/lib/rubik/concurrency/scheduler.rb +7 -24
  16. data/lib/rubik/context/git_lister.rb +6 -1
  17. data/lib/rubik/context/scanner.rb +15 -3
  18. data/lib/rubik/kernel/init.rb +15 -0
  19. data/lib/rubik/mcp/transport/stdio.rb +14 -11
  20. data/lib/rubik/orchestrator/auto_apply.rb +1 -1
  21. data/lib/rubik/orchestrator/subagent/activation.rb +29 -4
  22. data/lib/rubik/orchestrator/subagent/builtin_types.rb +117 -0
  23. data/lib/rubik/orchestrator/subagent/dynamic_store.rb +119 -0
  24. data/lib/rubik/orchestrator/subagent/instance.rb +8 -36
  25. data/lib/rubik/orchestrator/subagent/journal.rb +77 -4
  26. data/lib/rubik/orchestrator/subagent/profile_contract.rb +187 -0
  27. data/lib/rubik/orchestrator/subagent/profile_snapshot.rb +72 -0
  28. data/lib/rubik/orchestrator/subagent/reuse.rb +2 -1
  29. data/lib/rubik/orchestrator/subagent/scoped_registry.rb +2 -0
  30. data/lib/rubik/orchestrator/subagent/spawn_transaction.rb +170 -0
  31. data/lib/rubik/orchestrator/subagent/start_gate.rb +98 -0
  32. data/lib/rubik/orchestrator/subagent/supervisor.rb +4 -67
  33. data/lib/rubik/orchestrator/subagent/type_definition.rb +84 -0
  34. data/lib/rubik/orchestrator/subagent/type_registry.rb +139 -159
  35. data/lib/rubik/orchestrator/turn_executor/subagent_channel.rb +4 -2
  36. data/lib/rubik/platform/process.rb +152 -3
  37. data/lib/rubik/plugin/manager.rb +148 -71
  38. data/lib/rubik/plugin/package_inventory.rb +84 -0
  39. data/lib/rubik/plugin/requires_dag.rb +40 -0
  40. data/lib/rubik/plugin/storage.rb +100 -14
  41. data/lib/rubik/prompt/context_builder.rb +54 -20
  42. data/lib/rubik/prompt/doctrine.rb +158 -22
  43. data/lib/rubik/prompt/token_estimator.rb +5 -3
  44. data/lib/rubik/prompt/tool_teachings.rb +19 -12
  45. data/lib/rubik/repl/commands/buffer.rb +28 -18
  46. data/lib/rubik/runtime/repair_probe.rb +98 -0
  47. data/lib/rubik/sandbox/driver/bubblewrap.rb +13 -59
  48. data/lib/rubik/sandbox/driver/docker.rb +14 -60
  49. data/lib/rubik/sandbox/driver/podman.rb +13 -56
  50. data/lib/rubik/sandbox/driver/process.rb +12 -64
  51. data/lib/rubik/security/blocked_guidance.rb +19 -0
  52. data/lib/rubik/security/guard.rb +116 -7
  53. data/lib/rubik/storage/store.rb +52 -11
  54. data/lib/rubik/tools/builtins/define_subagent.rb +69 -0
  55. data/lib/rubik/tools/builtins/lifecycle.rb +129 -136
  56. data/lib/rubik/tools/builtins/storage.rb +8 -5
  57. data/lib/rubik/tools/builtins/subagent.rb +20 -53
  58. data/lib/rubik/tools/builtins/synthesis.rb +6 -1
  59. data/lib/rubik/tools/builtins.rb +1 -0
  60. data/lib/rubik/tools/diagnostic_reporter.rb +2 -1
  61. data/lib/rubik/version.rb +1 -1
  62. metadata +15 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f281eb015bdfadb67a18d2a61972c2559f448a0458915393443a39c042b8a1d9
4
- data.tar.gz: dedd94f98ab0785e0688e256b8be35244d764c88ccbe87c9367836715c3c788d
3
+ metadata.gz: 14020218aa50674cdf508953465d4f31c285420979b8a9c518ef4d5e6f6ef300
4
+ data.tar.gz: caa28cd931b29aecf1de25e66d794a304f04ea0331e9b58f2b198c985488a8e2
5
5
  SHA512:
6
- metadata.gz: bcaf73fa4a12d8084af7b7e8ae5f1886e14c0f55f7e8817112addc073d17533fce0bc0959971fc18654d217efb24cadd0cdb4fa128c9c6980f49c0ff7c3255d3
7
- data.tar.gz: 7d5dfa25a399e9e2710d9cbd16ec7c5cb0cbc7b373c62dfd9b3eae76bc4505df08f1bb51f9d893715ca4045da61b9b25c0b8b9c835c4960549788a98fb256f0b
6
+ metadata.gz: 27fdbf68f5e00c88e87bdfe3ba33e837783b3b4a573ae3ccbd8db707fd7b320af8256c5a875811d33feaaf2118f18c701579266bdb2795d27815d0d0199d30b7
7
+ data.tar.gz: d050ff897cbe97a68399a31a28ca68e53f7edf7e894e097bbba338f722406975f397cd5fcd3fe21946c98d5c6a8a158f7193c04979d7878dcd985cdc524083b0
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 3,600+ unit, integration, and contract tests. |
124
+ | **`minitest`** | Ryan Davis & seattlerb | MIT | Fast, modular test suite powering Rubik's 3,700+ 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
 
@@ -146,3 +146,7 @@ SOFTWARE.
146
146
 
147
147
  Rubik itself is licensed under the **MIT License**.
148
148
  See the [`LICENSE`](LICENSE) file for the full license text.
149
+
150
+ ---
151
+
152
+ See the [documentation index](docs/index.md) or return to the [README](README.md).
data/CHANGELOG.md CHANGED
@@ -10,6 +10,175 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
10
10
 
11
11
  Nothing yet.
12
12
 
13
+ ## [0.3.0] - 2026-10-18
14
+
15
+ The subagent-governance minor: runtime-defined archetypes become
16
+ context-scoped and reversible, spawn turns transactional, outcomes
17
+ are measured, and the first interactive launch asks before trusting
18
+ a workspace. Prompt teachings and tool schemas are aligned against
19
+ the declared contracts.
20
+
21
+ ### Added
22
+
23
+ - **Context-scoped, reversible archetype registration (#175, closes
24
+ #171):** runtime `define_subagent` profiles are owned by an explicit
25
+ runtime context with LIFO revision stacks and context-bound disposal
26
+ inverses — disposing the owner pops the registration and restores
27
+ the prior profile; stale out-of-order cleanups remove only what they
28
+ own; built-ins stay reserved; re-registering a live archetype
29
+ requires `replace: true`; and nested profiles are owned and cleaned
30
+ up by the child context.
31
+ - **Workspace trust prompt (#183, closes #182):** interactive launches
32
+ in an untrusted workspace show the resolved path, explain Rubik's
33
+ file and command capabilities and the `buffer.model_can_apply:
34
+ false` limitation, and offer a per-workspace Trust and continue or
35
+ Exit choice (exit is the default); script and non-interactive
36
+ launches do not block on the prompt.
37
+ - **Validated subagent profile contracts (#177, closes #172):** custom
38
+ archetypes declare required coeffects and allowlisted capability
39
+ grants; profiles default to no write or nested-spawn grants; invalid
40
+ names, dependencies, grants and field limits return structured
41
+ validation errors before registration; custom tool filters derive
42
+ only from allowlisted grants.
43
+ - **Subagent profile outcomes and bounded prompt visibility (#179,
44
+ closes #174):** root prompts keep every built-in and show only the
45
+ eight newest active custom profiles; run journals record profile
46
+ identity and version, outcome, bounded redacted error summaries,
47
+ duration, step and tool-call counts, and provider-reported token
48
+ usage — missing token and cost data are marked unavailable, never
49
+ estimated.
50
+
51
+ ### Fixed
52
+
53
+ - **Subagent spawn is transactional (#178, closes #173):** required
54
+ coeffects are validated before the worker starts; a startup failure
55
+ rolls back the child context, scoped registry, kernel registration,
56
+ instance and generated ID; each instance pins an immutable profile
57
+ snapshot (redeploys keep the original); and honest spawn failures
58
+ reach the maestro.
59
+ - **The system prompt follows active tools and mode (#170, closes
60
+ #166):** teachings for gated tools are filtered when their
61
+ coeffects are unsatisfied, plan-only mode directs no tool calls or
62
+ synthesis, and read-only orientation vs delegated execution is
63
+ harmonized across rules and role headers.
64
+ - **Storage and Vakanüvis write rules are aligned (#169, closes
65
+ #165):** direct `storage put` targets work artifacts
66
+ (goal/plan/review/note) while durable `memory` cards and `wiki`
67
+ pages route through `vakanuvis` record/digest when available; the
68
+ tool declaration documents the contract and the coder prompt
69
+ surfaces durable lessons to the maestro.
70
+ - **Tool teachings match declared schemas (#168, closes #167):**
71
+ `replace_file_content` guidance drops the unadvertised aliases
72
+ (runtime tolerance preserved) and `synthesize_tool` requires
73
+ `params_schema` when the synthesized tool accepts arguments.
74
+
75
+ ### Changed
76
+
77
+ - **Documentation navigation:** user and developer guides reorganized
78
+ under `docs/`, README quickstart and feature summary refreshed, and
79
+ GitHub issue and pull request templates plus a code of conduct
80
+ added; provider and local model IDs refreshed across README,
81
+ configuration, command, API and first-session examples.
82
+ - **Process stream capture is consolidated (#180):**
83
+ `Rubik::Platform.popen_capture` centralizes Open3 startup,
84
+ concurrent stdout/stderr capture, exit-status mapping and timeout
85
+ process-tree termination; ProcessDriver, Bubblewrap, Docker and
86
+ Podman drivers share it.
87
+ - **Hot paths get cheaper:** `TokenEstimator.estimate_text` switches
88
+ to exact integer math with zero allocations (~7.8% on history
89
+ estimation, #181); `Store#search_ranked` ranking cuts allocations
90
+ by ~43% (#176).
91
+ - **Deps:** `tree_sitter_language_pack` bumps to 1.22.1 (#162); dev
92
+ rubocop to 1.92.0 (#163).
93
+
94
+ ## [0.2.0] - 2026-10-16
95
+
96
+ The first minor of the 0.2 era is a hardening minor: a reproducible
97
+ runtime validation harness with capacity proofs, a fail-closed
98
+ security posture across the command guard, transactional plugin
99
+ reload, and failure reporting that names what actually happened.
100
+
101
+ ### Added
102
+
103
+ - **Reproducible runtime validation harness (#160, closes #151):**
104
+ `bundle exec ruby dev/validate_runtime_capacity.rb` runs without
105
+ provider credentials and writes a dated report — environment, seed,
106
+ fixture sizes, raw metrics, resource checkpoints, thresholds and
107
+ verdicts. Nine lifecycle families soak for the configured 1,000
108
+ epochs (real subprocess shutdown, failed JSON-RPC handshake,
109
+ crash/recovery); two single-run probes cover in-flight
110
+ disable/re-enable and known-descendant cleanup. Missing
111
+ capabilities report INCONCLUSIVE (exit 2), failed thresholds FAIL
112
+ (exit 1). The soak also surfaced production fixes that ship here:
113
+ nonblocking IO hooks keep their return codes and minimum lengths,
114
+ select wakes only fibers interested in each readiness direction,
115
+ queued wakeups carry their park generation so stale events cannot
116
+ resume a later operation, and a crashed MCP pipe closes with the
117
+ process tree terminated before stdin (recursive descendant
118
+ discovery on Unix).
119
+
120
+ ### Fixed
121
+
122
+ - **Command classifier fails closed (#143):** a classifier crash or a
123
+ partial tree-sitter parse no longer downgrades to the catastrophic
124
+ regex gate — both raise structured blocks (`:classifier_error` /
125
+ `:parse_ambiguous`) with the crash cause audited; the catastrophic
126
+ regex keeps first refusal for precise destructive-shape reasons and
127
+ the operator allowlist stays the only valve. SECURITY.md's
128
+ fallback residual is updated to the fail-closed policy.
129
+ - **Plugins verify whole packages and reload transactionally
130
+ (#144):** directory-plugin manifests hash every regular file under
131
+ the package root (additions, deletions and modifications audited;
132
+ symlinks and special files are containment violations); legacy
133
+ entry-file-only manifests require explicit re-consent; and
134
+ `reload_plugin` discovers, verifies and prepares the replacement
135
+ before touching the running version — a failed reload leaves the
136
+ old version running instead of claiming success.
137
+ - **Runtime repair verifies before promoting (#145):** LSP candidates
138
+ must complete an isolated initialize handshake and other targets
139
+ run bounded argv probes that preserve the proposed arguments; live
140
+ promotion records inverses and unwinds the transaction on failure,
141
+ rolling back to the previously configured client (with an honest
142
+ report if restoration itself fails).
143
+ - **Buffer apply names its authority and its partial truth (#146):**
144
+ `buffer.model_can_apply` is honored in every registry rebuild
145
+ (branch workspaces included); a multi-file `apply!` failure raises
146
+ a structured `ApplyFailedError` carrying what reached disk, what
147
+ failed and what a retry still writes; retry is incremental and the
148
+ tool and `!apply` render one shared failure vocabulary — a partial
149
+ apply is never reported as "Successfully applied".
150
+ - **C++ extraction sees classes and reports parse status (#147):**
151
+ the shared C/C++ walker no longer crashes on unknown declarator
152
+ shapes — class/struct/union symbols, namespaces, in-class members
153
+ (definitions, declarations, ctors, operators) and templates are
154
+ recorded; the extractor returns a structured status
155
+ (`:ok`/`:partial`/`:failed`/`:unavailable`) and a failed reindex
156
+ keeps the file's previously indexed symbols instead of silently
157
+ deleting them.
158
+ - **Plugin reinstallation survives symlinked ancestors (#158):**
159
+ resolved-source × lexical-destination comparison could delete the
160
+ source before copying it; file identity now detects an
161
+ already-installed directory.
162
+ - **Unit tests are isolated from external network and terminal env
163
+ (#148):** handshake-deadline assertions no longer depend on cleanup
164
+ timing.
165
+
166
+ ### Changed
167
+
168
+ - **CI measures the platform matrix (#158):** four jobs — Linux Ruby
169
+ 3.4/4.0, macOS Ruby 4.0, Windows Ruby 4.0 — each install the gem
170
+ into an isolated GEM_HOME, run CLI/require smoke and all three
171
+ suite loaders, and publish evidence artifacts; README and TESTING
172
+ replace the universal green-run guarantee with commit-specific
173
+ evidence.
174
+ - **Docs calibrate absolute guarantees (#159):** README, SECURITY,
175
+ CONFIG, PLUGINS and SELF_EVOLUTION swap "zero-risk"-style claims
176
+ for concrete preconditions and bounded behavior (the full buffer
177
+ review gate is `auto_apply: manual` + `model_can_apply: false`).
178
+ - **Cold scan gets cheaper (#161):** integer-micros mtime math, a
179
+ backslash translation that runs only when backslashes exist, and
180
+ in-place dedup; the fast scan keeps bracket-class ignores intact.
181
+
13
182
  ## [0.1.6] - 2026-10-15
14
183
 
15
184
  The execution-contract release: subagent runs become first-class,