rubik 0.8.0 → 0.9.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 +2 -2
- data/CHANGELOG.md +164 -1
- data/bin/rubik +15 -10
- data/lib/rubik/cli/workspace_trust.rb +1 -0
- data/lib/rubik/concurrency/worker.rb +143 -0
- data/lib/rubik/concurrency.rb +1 -0
- data/lib/rubik/config/deep_ops.rb +17 -0
- data/lib/rubik/config/defaults.rb +0 -1
- data/lib/rubik/config/schema.rb +0 -1
- data/lib/rubik/config.rb +7 -3
- data/lib/rubik/context/repo_context_reader.rb +27 -8
- data/lib/rubik/events.rb +18 -0
- data/lib/rubik/kernel/dispatcher.rb +19 -23
- data/lib/rubik/kernel/init.rb +22 -18
- data/lib/rubik/kernel/unit.rb +4 -3
- data/lib/rubik/orchestrator/auto_apply.rb +2 -0
- data/lib/rubik/orchestrator/budget_manager.rb +18 -2
- data/lib/rubik/orchestrator/goal_ledger/deep_ops.rb +41 -0
- data/lib/rubik/orchestrator/goal_ledger/drift.rb +2 -1
- data/lib/rubik/orchestrator/goal_ledger/ledger.rb +59 -59
- data/lib/rubik/orchestrator/goal_ledger/observation_projection.rb +29 -9
- data/lib/rubik/orchestrator/goal_ledger/patch.rb +10 -17
- data/lib/rubik/orchestrator/goal_ledger/suspend_lifecycle.rb +9 -41
- data/lib/rubik/orchestrator/goal_ledger/validator.rb +6 -20
- data/lib/rubik/orchestrator/goal_ledger/verifier.rb +3 -14
- data/lib/rubik/orchestrator/goal_ledger/xml_render.rb +21 -14
- data/lib/rubik/orchestrator/goal_state.rb +15 -15
- data/lib/rubik/orchestrator/loop.rb +62 -63
- data/lib/rubik/orchestrator/lsp_feedback.rb +7 -1
- data/lib/rubik/orchestrator/subagent/admission_policy.rb +161 -0
- data/lib/rubik/orchestrator/subagent/builtin_types.rb +3 -2
- data/lib/rubik/orchestrator/subagent/deferred_spec.rb +51 -2
- data/lib/rubik/orchestrator/subagent/dependency.rb +20 -20
- data/lib/rubik/orchestrator/subagent/execution_reads.rb +1 -1
- data/lib/rubik/orchestrator/subagent/journal.rb +3 -9
- data/lib/rubik/orchestrator/subagent/lifecycle.rb +10 -1
- data/lib/rubik/orchestrator/subagent/notices.rb +5 -4
- data/lib/rubik/orchestrator/subagent/paging.rb +49 -0
- data/lib/rubik/orchestrator/subagent/profile_contract.rb +4 -10
- data/lib/rubik/orchestrator/subagent/reaper.rb +1 -3
- data/lib/rubik/orchestrator/subagent/redeploy_transaction.rb +99 -0
- data/lib/rubik/orchestrator/subagent/result_archive.rb +12 -22
- data/lib/rubik/orchestrator/subagent/reuse.rb +37 -31
- data/lib/rubik/orchestrator/subagent/run_cycle.rb +22 -1
- data/lib/rubik/orchestrator/subagent/scoped_registry.rb +34 -2
- data/lib/rubik/orchestrator/subagent/spawn_transaction.rb +1 -1
- data/lib/rubik/orchestrator/subagent/supervisor.rb +6 -2
- data/lib/rubik/orchestrator/subagent/task_ownership.rb +2 -2
- data/lib/rubik/orchestrator/subagent/transcript_reader.rb +14 -13
- data/lib/rubik/orchestrator/subagent/type_registry.rb +19 -1
- data/lib/rubik/orchestrator/turn_executor/subagent_channel.rb +6 -1
- data/lib/rubik/orchestrator/turn_executor/user_channel.rb +6 -1
- data/lib/rubik/orchestrator/turn_executor.rb +2 -1
- data/lib/rubik/platform/path.rb +0 -1
- data/lib/rubik/prompt/context_builder.rb +24 -18
- data/lib/rubik/prompt/context_compactor.rb +31 -8
- data/lib/rubik/prompt/conversation_rows.rb +33 -0
- data/lib/rubik/prompt/doctrine.rb +4 -2
- data/lib/rubik/prompt/emergency_compactor.rb +5 -4
- data/lib/rubik/repl/commands/agent_execution.rb +13 -2
- data/lib/rubik/repl/commands/buffer.rb +4 -0
- data/lib/rubik/repl/commands/mcp.rb +5 -0
- data/lib/rubik/repl/commands/subagents.rb +7 -6
- data/lib/rubik/repl/commands/workspace.rb +22 -2
- data/lib/rubik/repl/config_wiring.rb +24 -7
- data/lib/rubik/repl/input_execution.rb +1 -1
- data/lib/rubik/repl/lifecycle.rb +3 -2
- data/lib/rubik/repl/pruner/harness.rb +52 -67
- data/lib/rubik/repl/pruner/rules.rb +3 -1
- data/lib/rubik/repl/pruner/service.rb +4 -9
- data/lib/rubik/repl/service_catalog.rb +1 -1
- data/lib/rubik/repl/synthesized_command_context.rb +3 -0
- data/lib/rubik/repl/turn_recorder.rb +5 -4
- data/lib/rubik/repl.rb +1 -0
- data/lib/rubik/runtime/context.rb +11 -1
- data/lib/rubik/runtime/discovery.rb +55 -0
- data/lib/rubik/runtime/fiber.rb +17 -5
- data/lib/rubik/runtime/manager.rb +19 -12
- data/lib/rubik/runtime/overlay_storage.rb +54 -23
- data/lib/rubik/runtime/repair_probe.rb +20 -2
- data/lib/rubik/runtime/sealed_coeffects.rb +58 -0
- data/lib/rubik/runtime/synthesized_command_context.rb +80 -0
- data/lib/rubik/runtime/synthesized_tool_context.rb +123 -0
- data/lib/rubik/runtime.rb +2 -0
- data/lib/rubik/security/classifier/classifier.rb +16 -8
- data/lib/rubik/security/classifier/commands/biome.yaml +49 -0
- data/lib/rubik/security/classifier/commands/bun.yaml +91 -0
- data/lib/rubik/security/classifier/commands/bundle.yaml +107 -0
- data/lib/rubik/security/classifier/commands/clang-format.yaml +21 -0
- data/lib/rubik/security/classifier/commands/clang.yaml +37 -0
- data/lib/rubik/security/classifier/commands/cmake.yaml +37 -0
- data/lib/rubik/security/classifier/commands/ctest.yaml +30 -0
- data/lib/rubik/security/classifier/commands/gcc.yaml +36 -0
- data/lib/rubik/security/classifier/commands/gem.yaml +104 -0
- data/lib/rubik/security/classifier/commands/gofmt.yaml +15 -0
- data/lib/rubik/security/classifier/commands/pnpm.yaml +8 -8
- data/lib/rubik/security/classifier/commands/python.yaml +18 -1
- data/lib/rubik/security/classifier/commands/python3.yaml +18 -1
- data/lib/rubik/security/classifier/commands/rake.yaml +60 -0
- data/lib/rubik/security/classifier/commands/rspec.yaml +42 -0
- data/lib/rubik/security/classifier/commands/rubocop.yaml +38 -0
- data/lib/rubik/security/classifier/commands/ruby.yaml +25 -0
- data/lib/rubik/security/classifier/commands/rustc.yaml +34 -0
- data/lib/rubik/security/classifier/commands/zig.yaml +77 -0
- data/lib/rubik/security/classifier/database.rb +12 -1
- data/lib/rubik/security/classifier/matcher.rb +17 -2
- data/lib/rubik/security/classifier/models.rb +3 -2
- data/lib/rubik/security/classifier.rb +5 -0
- data/lib/rubik/security/guard.rb +133 -39
- data/lib/rubik/storage/layout.rb +14 -3
- data/lib/rubik/storage/vakanuvis/harness.rb +49 -89
- data/lib/rubik/tools/base.rb +55 -7
- data/lib/rubik/tools/builtins/dmesg.rb +1 -1
- data/lib/rubik/tools/builtins/exec.rb +1 -2
- data/lib/rubik/tools/builtins/files.rb +3 -1
- data/lib/rubik/tools/builtins/goal_ledger.rb +10 -10
- data/lib/rubik/tools/builtins/grep.rb +2 -2
- data/lib/rubik/tools/builtins/interactive.rb +1 -3
- data/lib/rubik/tools/builtins/lifecycle.rb +1 -1
- data/lib/rubik/tools/builtins/lsp.rb +2 -2
- data/lib/rubik/tools/builtins/pruner.rb +1 -1
- data/lib/rubik/tools/builtins/runtime.rb +1 -1
- data/lib/rubik/tools/builtins/send_message.rb +14 -3
- data/lib/rubik/tools/builtins/skill.rb +1 -1
- data/lib/rubik/tools/builtins/storage.rb +1 -1
- data/lib/rubik/tools/builtins/subagent.rb +2 -1
- data/lib/rubik/tools/builtins/subagent_lifecycle.rb +5 -3
- data/lib/rubik/tools/builtins/symbols.rb +4 -4
- data/lib/rubik/tools/builtins/synthesis.rb +121 -64
- data/lib/rubik/tools/builtins/task.rb +1 -1
- data/lib/rubik/tools/builtins/unsynthesize.rb +38 -0
- data/lib/rubik/tools/builtins/vakanuvis.rb +1 -1
- data/lib/rubik/tools/catalog.rb +3 -0
- data/lib/rubik/tools/declaration.rb +6 -2
- data/lib/rubik/tools/preflight_runner.rb +107 -14
- data/lib/rubik/tools/registry.rb +2 -0
- data/lib/rubik/tools/uri_resolver.rb +3 -1
- data/lib/rubik/uris.rb +5 -1
- data/lib/rubik/version.rb +1 -1
- data/lib/rubik.rb +1 -0
- metadata +27 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dad89865cb319b5a3cbf571625db00622882f6a19a830f3aa8002f8aef6b082f
|
|
4
|
+
data.tar.gz: 36e44aa9a31892e84c3bd6b6ae0623d0f2cf90c28c0302e9eee57ff0f23947e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62e943b2e50537c0d18e1c0ecabbecae1b5323a6e15a6dedd2e0975d20fd95e2491df2b7479ab9a596db639c86e7f814909c5d21b1c0b1150aef82e8bd9267d5
|
|
7
|
+
data.tar.gz: 4bddb1287a07acb0d34310e2a6dc4926b1d60787c3a3da60eba5e51bb7f832d2b41136be9ea3ab245daefde011d5081c23c50b7cafebccdeb9eada8daa8f49f5
|
data/ATTRIBUTION.md
CHANGED
|
@@ -13,7 +13,7 @@ Rubik is built on the shoulders of giants. This document acknowledges and credit
|
|
|
13
13
|
- **License:** MIT License
|
|
14
14
|
- **Rubik Integration:**
|
|
15
15
|
- Ported to pure Ruby under [`lib/rubik/security/classifier/`](lib/rubik/security/classifier/).
|
|
16
|
-
- Includes the comprehensive command database (
|
|
16
|
+
- Includes the comprehensive command database (191 popular CLI tool definition YAML files under [`lib/rubik/security/classifier/commands/`](lib/rubik/security/classifier/commands/)).
|
|
17
17
|
- Adapted to use `tree-sitter` for AST parsing, and extended with first-class **PowerShell** (`pwsh`) cmdlet risk classification and execution policy checking.
|
|
18
18
|
|
|
19
19
|
```
|
|
@@ -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,300+ 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,167 @@ 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
|
+
## [Unreleased]
|
|
10
|
+
|
|
11
|
+
## [0.9.0] - 2026-11-09
|
|
12
|
+
|
|
13
|
+
The permission-architecture minor: subagent command permissions, the
|
|
14
|
+
synthesis security gate, and tool visibility are overhauled end to end
|
|
15
|
+
(F1-F8 command classifier, trust discovery, sealed contexts, admission
|
|
16
|
+
policy), the goal-ledger aligns SKILL.state with arXiv:2608.26263, context
|
|
17
|
+
assembly hardens its budget boundaries and injection defense — and the
|
|
18
|
+
single-homing wave continues (bounded-queue worker, event-name vocabulary,
|
|
19
|
+
sigma-row grammar, sealed-context deny-list each collapse to one owner).
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- **Subagent tool admission single-homed behind one policy (#393):** the
|
|
24
|
+
dynamic-origin vocabulary, risk ladder, per-plane rules, and capability
|
|
25
|
+
labels live in one `AdmissionPolicy` while the executor stays
|
|
26
|
+
`ScopedRegistry`; unknown planes raise at the boundary, every non-builtin
|
|
27
|
+
origin is ladder-gated on research/coder, a caller-provided `tool_filter`
|
|
28
|
+
is rejected up front (the installed-filter marker keeps re-registration
|
|
29
|
+
legal), and filter-less type_defs fail the label simulation loudly.
|
|
30
|
+
- **Subagent command permissions, synthesis security gate, and tool
|
|
31
|
+
visibility overhauled (#392):** the classifier command DB expands with 19
|
|
32
|
+
command families, workspace trust discovery and interactive approval land,
|
|
33
|
+
Ruby synthesis decouples from the shell classifier with
|
|
34
|
+
`SynthesizedCommandContext` sealed, preflight goes conditional, and the
|
|
35
|
+
2-arity sealed tool context arrives; the review round closed the sealed
|
|
36
|
+
`tool_registry`/`tools` escape, preflight verdict spoofing
|
|
37
|
+
(`exit!`/`SystemExit`/strict-boolean verdict), the nil-type_def silent
|
|
38
|
+
grant, and several silent downgrades that now warn.
|
|
39
|
+
- **Permission & authorization architecture hardening (F1-F8) (#391):**
|
|
40
|
+
synthesis forbidden capabilities block constant-aliasing escapes
|
|
41
|
+
(Kernel, File, ENV, ObjectSpace, Rubik, Fiber); `.rubik/**` joins
|
|
42
|
+
`Guard::DEFAULT_CRITICAL_PATTERNS` and untrusted project configs get
|
|
43
|
+
sensitive keys stripped; `RepairProbe` is confined to a diagnostic
|
|
44
|
+
whitelist behind `Guard#verify_command_safety!`; `rubik --trust` CLI flag
|
|
45
|
+
for trusted workspaces; `!mcp` mutating commands restricted for agent
|
|
46
|
+
callers; classifier Windows dangerous roots and HOME prefix detection
|
|
47
|
+
fixed with `critical_path?` verification on shell write paths; relative
|
|
48
|
+
traversal blocked in `BaseTool.normalize_path_filter`;
|
|
49
|
+
`buffer.model_can_apply` enforced with `!autoapply`/`!format` agent-caller
|
|
50
|
+
guards.
|
|
51
|
+
- **GoalLedger aligned with arXiv:2608.26263 (#389):** continuous
|
|
52
|
+
observation projection hooks `BudgetManager#evaluate_context_compaction!`
|
|
53
|
+
so banked tool observations are projected without waiting for ceiling
|
|
54
|
+
exhaustion, verbose assistant reasoning is pruned on banked calls,
|
|
55
|
+
deterministic RFC 6902 index attributes land on ledger list items,
|
|
56
|
+
`rubik://goal/ledger.json` exposes machine-readable state, `DeepOps#
|
|
57
|
+
deep_freeze` freezes in-place, and the declarative verification specs are
|
|
58
|
+
documented in system prompts.
|
|
59
|
+
|
|
60
|
+
### Changed
|
|
61
|
+
|
|
62
|
+
- **`network.allow` alias retired; buffer-sync writers derived from
|
|
63
|
+
Declarations (#397):** the deprecation listener names the
|
|
64
|
+
`sandbox.allow_network` replacement and SECURITY.md states honestly that
|
|
65
|
+
config-file entries are silently ignored; the LSP buffer-sync writer set
|
|
66
|
+
is derived from tool Declarations instead of a hand-maintained list.
|
|
67
|
+
- **Event-name vocabulary single-homed in a zero-require leaf (#396):**
|
|
68
|
+
`lib/rubik/events.rb` owns the bus event names; every emit/subscribe site
|
|
69
|
+
uses the shared symbols so names cannot drift from their single home.
|
|
70
|
+
- **Bounded-queue worker skeleton single-homed (#395):** atomic admission,
|
|
71
|
+
idempotent shutdown, busy accounting, and the guarded dispatch-failure net
|
|
72
|
+
live in `Rubik::Concurrency::Worker`; pruner and vakanuvis harnesses
|
|
73
|
+
migrate onto it.
|
|
74
|
+
- **Sigma-row grammar single home; verifier seam narrowed (#388):**
|
|
75
|
+
`GOAL_LEDGER_TAG`/`LEDGER_DRIFT_TAG` live in the prompt layer (consumed by
|
|
76
|
+
XmlRender, DriftNote, the injection-escape site, and the new
|
|
77
|
+
`drift_message?` predicate), the ledger's byte-for-byte reimplementations
|
|
78
|
+
are deleted, and `Verifier.at_step_boundary!` speaks values instead of
|
|
79
|
+
reaching through the loop object.
|
|
80
|
+
- **Max-steps terminal carries a structured reason (#387):** `reason:
|
|
81
|
+
:budget_exhausted` on the terminal hash; both consumers (goal
|
|
82
|
+
auto-continue, ask-continue) branch on the symbol instead of
|
|
83
|
+
substring-matching the English prose, so rewording can no longer dead the
|
|
84
|
+
`agent.goal_auto_continue_limit` knob.
|
|
85
|
+
- **Goal-ledger copy families consolidated (#385):** `stamp_row!`, a shared
|
|
86
|
+
`DeepOps` page, schema-derived seed/snapshot/load-check with a tripwire
|
|
87
|
+
test, and `Ledger.load` give the stamp, deep-copy discipline, and sigma
|
|
88
|
+
vocabulary single owners; dead `Verifier.stale?` and `Patch#raw_bytesize`
|
|
89
|
+
deleted; five degradation pins kept green through the refactor.
|
|
90
|
+
|
|
91
|
+
### Fixed
|
|
92
|
+
|
|
93
|
+
- **Context assembly, budget boundaries, and injection defense hardened
|
|
94
|
+
(F1-F9) (#390):** tool schema tokens reserved in compaction with unified
|
|
95
|
+
max_output_tokens resolution; dynamic system prompt fingerprinting with
|
|
96
|
+
in-place refresh on tool/skill/subagent changes; protocol files capped
|
|
97
|
+
(highest priority only, 8k tokens) with closing-tag sanitization; XML
|
|
98
|
+
escaping in custom command rendering; LSP diagnostics capped at 50 with
|
|
99
|
+
error-first priority; 'self' subagent inherits protocol XML and the
|
|
100
|
+
environment line; `sanitize_dialogue_turn` validates roles and neutralizes
|
|
101
|
+
unescaped pin tags from prior turns; `SystemCallError`/`EncodingError`
|
|
102
|
+
handled in git branch detection.
|
|
103
|
+
- **Suspend tokens assigned absolutely and reported honestly (#386):** the
|
|
104
|
+
transient-ClientError rescue passes real `orchestrator.total_tokens` into
|
|
105
|
+
the suspended terminal (was zero), `GoalState#suspend!` assigns absolutely
|
|
106
|
+
instead of additive `+=` so suspend→resume→suspend no longer
|
|
107
|
+
double-counts, and dead `GoalState#record_tokens!` is deleted.
|
|
108
|
+
|
|
109
|
+
## [0.8.1] - 2026-11-06
|
|
110
|
+
|
|
111
|
+
A reliability-and-single-homing patch: the kernel hardens the spatiotemporal
|
|
112
|
+
invariants (failure rollback, lock ordering, queue observability), the subagent
|
|
113
|
+
family converges on guarded state machines and truthful reporting for unborn
|
|
114
|
+
work, and five duplicated helpers (config_get, pagination window, coeffect
|
|
115
|
+
resolution, attention vocabulary, tombstone table) each collapse to one owner.
|
|
116
|
+
|
|
117
|
+
### Changed
|
|
118
|
+
|
|
119
|
+
- **Per-tool coeffect resolution unified behind `BaseTool#service` (#383):**
|
|
120
|
+
each builtin's private "fetch a service (or its subagent-plane fallback)"
|
|
121
|
+
dance now delegates to one Services-delegating helper, closing issue #368;
|
|
122
|
+
nil-guard on the fallback mock tightened in both `BaseTool#service` and
|
|
123
|
+
`SubagentToolHelpers`.
|
|
124
|
+
- **Shared pagination window extracted (ResultArchive ≅ TranscriptReader)
|
|
125
|
+
(#381):** the duplicated page-window slicing (offset/limit, ellipsis
|
|
126
|
+
framing) moved into one module closing issue #374; the predicate exposed
|
|
127
|
+
via `alias_method` to satisfy rubocop without renaming call sites.
|
|
128
|
+
- **Five `config_get` copies converged on `Layout.config_get` (#382):** the
|
|
129
|
+
string/symbol dotted-key access duplicated across five call sites now
|
|
130
|
+
delegates to one superset helper closing issue #373.
|
|
131
|
+
- **DeferredSpec transitions guarded like the family contract (#372):** the
|
|
132
|
+
raw `attr_accessor` written from six supervisor sites became a
|
|
133
|
+
`TRANSITIONS`-guarded machine (`mark_spawning!`/`requeue!`/`cancel!`,
|
|
134
|
+
fail-loud `StateError` on undeclared edges, same-state idempotency,
|
|
135
|
+
first-reason-wins cancellation), so an illegal edge can no longer fail
|
|
136
|
+
silently and `cancel_spec!`'s inline twin is gone.
|
|
137
|
+
- **Attention vocabulary derived from Lifecycle (#376):** the tool plane's
|
|
138
|
+
hand-copied "needs attention" state set moved beside `TRANSITIONS` in
|
|
139
|
+
`lifecycle.rb` (`PARKED_STATES`/`ATTENTION_STATES`, `parked?` recomposed
|
|
140
|
+
under one monitor acquisition); `TranscriptReader::ACTIVE_STATES` drops
|
|
141
|
+
its dead `:queued` entry — an Instance can never hold that state.
|
|
142
|
+
- **Tombstone table single-owned (#370):** the finished table is born in the
|
|
143
|
+
constructor alongside `@instances`/`@deferred` instead of relying on nine
|
|
144
|
+
defensive `@finished ||= {}`-style sites across seven files; semantics
|
|
145
|
+
unchanged.
|
|
146
|
+
|
|
147
|
+
### Fixed
|
|
148
|
+
|
|
149
|
+
- **Kernel & Runtime Composability & Resilience Hardening (F1-F5) (#380):**
|
|
150
|
+
- **Fiber Failure Reversibility (F1):** `ComponentFiber#activate!` now rolls back partial inverses on `Interrupt`, `SystemExit`, and non-`StandardError` signals before re-raising, eliminating leaked sub-contexts and unexecuted inverses.
|
|
151
|
+
- **Fail-Fast Provide on Disposed Context (F2):** `Context#provide` and `Manager#provide` now raise `ContextDisposedError` when invoked on a disposed context/manager instead of silently dropping services.
|
|
152
|
+
- **Context Dispose Lock-Order (F3):** `Context#dispose` now resolves `dmesg` outside `@monitor.synchronize`, preserving strict parent→child locking across context hierarchies and preventing latent deadlocks.
|
|
153
|
+
- **Monitor Scope Decoupling (F4):** `Init#kill_all`, `Init#reap_dead_units!`, and `Manager#dispose!` now take snapshots under the monitor and invoke external teardown/kills outside the lock, preventing blocking of supervisor inspection methods (`Init#get`, `Manager#active_fibers`).
|
|
154
|
+
- **Dispatcher Queue Watermark Observability (F5):** `Dispatcher#post` now emits a warning to the logger and `dmesg` when queue depth reaches high watermarks (`DEFAULT_WARN_QUEUE_DEPTH = 1000`), enhancing event queue visibility under high throughput.
|
|
155
|
+
- **Redeploy rolls back its transaction like spawn (#371):** a settle race
|
|
156
|
+
(reaper archive/kill between the redeployable? check and the guarded reset)
|
|
157
|
+
or any raise after the irreversible `redeploy_for!` mutation previously
|
|
158
|
+
leaked the freshly extended child context, a mutated instance, a registered
|
|
159
|
+
unit — and when `start_async` flipped then aborted, a `:running` zombie
|
|
160
|
+
holding a concurrency slot forever; the spawn-style rollback now covers it.
|
|
161
|
+
- **Queued and launching specs reported truthfully (#375):** `invoke_subagent`
|
|
162
|
+
no longer answers `:queued` for a requeue the cancelled-guard refused,
|
|
163
|
+
`send_message` to a queued spec names the deps and the real next actions
|
|
164
|
+
instead of "redeploy it" (false twice over), and the REPL list prints
|
|
165
|
+
"queued/launching (waiting on: ...)" instead of "ended (0.0s)" for a
|
|
166
|
+
mid-launch spec.
|
|
167
|
+
- **Deps:** `tree_sitter_language_pack` 1.22.1 → 1.23.1 (#379), rubocop dev
|
|
168
|
+
dep 1.92.1 → 1.92.2 (#378), CI `actions/cache` v4 → v6 (#377).
|
|
169
|
+
|
|
9
170
|
## [0.8.0] - 2026-11-05
|
|
10
171
|
|
|
11
172
|
A configuration-architecture minor: the write plane goes strict — typed
|
|
@@ -1304,7 +1465,9 @@ installation section.
|
|
|
1304
1465
|
- Context: serialized index mutations, snapshot-outside-lock reconcile,
|
|
1305
1466
|
streaming-first truncation.
|
|
1306
1467
|
|
|
1307
|
-
[Unreleased]: https://github.com/ozgurulukir/rubik/compare/v0.
|
|
1468
|
+
[Unreleased]: https://github.com/ozgurulukir/rubik/compare/v0.9.0...HEAD
|
|
1469
|
+
[0.9.0]: https://github.com/ozgurulukir/rubik/compare/v0.8.1...v0.9.0
|
|
1470
|
+
[0.8.1]: https://github.com/ozgurulukir/rubik/compare/v0.8.0...v0.8.1
|
|
1308
1471
|
[0.8.0]: https://github.com/ozgurulukir/rubik/compare/v0.7.1...v0.8.0
|
|
1309
1472
|
[0.7.1]: https://github.com/ozgurulukir/rubik/compare/v0.7.0...v0.7.1
|
|
1310
1473
|
[0.7.0]: https://github.com/ozgurulukir/rubik/compare/v0.6.0...v0.7.0
|
data/bin/rubik
CHANGED
|
@@ -13,7 +13,7 @@ require "optparse"
|
|
|
13
13
|
# inner handler has been left uninstalled -- always terminates the process, so
|
|
14
14
|
# the user is never stuck unable to exit.
|
|
15
15
|
trap("INT") do
|
|
16
|
-
|
|
16
|
+
warn "\n[rubik] Interrupted. Exiting."
|
|
17
17
|
exit!(130)
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -52,6 +52,10 @@ OptionParser.new do |opts|
|
|
|
52
52
|
options[:script] = file
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
opts.on("--trust", "Explicitly trust the current workspace") do
|
|
56
|
+
options[:trust] = true
|
|
57
|
+
end
|
|
58
|
+
|
|
55
59
|
opts.on("--no-color", "Disable ANSI colors, banner and spinner") do
|
|
56
60
|
ENV["NO_COLOR"] = "1"
|
|
57
61
|
end
|
|
@@ -61,21 +65,22 @@ OptionParser.new do |opts|
|
|
|
61
65
|
end
|
|
62
66
|
end.parse!
|
|
63
67
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
Rubik::CLI::WorkspaceTrust.trust!(Dir.pwd) if options[:trust]
|
|
69
|
+
|
|
70
|
+
workspace_trusted = options[:trust] ||
|
|
71
|
+
options[:script] ||
|
|
72
|
+
Rubik::CLI::WorkspaceTrust.authorize!(
|
|
73
|
+
workspace: Dir.pwd,
|
|
74
|
+
input: $stdin,
|
|
75
|
+
output: $stdout
|
|
76
|
+
)
|
|
70
77
|
Kernel.exit(0) unless workspace_trusted
|
|
71
78
|
|
|
72
79
|
shell = Rubik::REPL::Shell.new
|
|
73
80
|
|
|
74
81
|
if options[:continue]
|
|
75
82
|
res = shell.resume_session(options[:continue])
|
|
76
|
-
unless res[:ok]
|
|
77
|
-
warn "[Rubik] Warning: #{res[:error]}"
|
|
78
|
-
end
|
|
83
|
+
warn "[Rubik] Warning: #{res[:error]}" unless res[:ok]
|
|
79
84
|
end
|
|
80
85
|
|
|
81
86
|
if options[:script]
|
|
@@ -46,6 +46,7 @@ module Rubik
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def trusted?(workspace, store_path: default_store_path)
|
|
49
|
+
return true if ENV["RUBIK_TRUST_WORKSPACE"] == "1" && store_path == default_store_path
|
|
49
50
|
return false unless File.file?(store_path)
|
|
50
51
|
|
|
51
52
|
store = YAML::Store.new(store_path, true)
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "join"
|
|
4
|
+
|
|
5
|
+
module Rubik
|
|
6
|
+
module Concurrency
|
|
7
|
+
# Single home of the bounded-queue worker skeleton shared by the pruner
|
|
8
|
+
# and vakanuvis harnesses: one worker thread drains a bounded FIFO until
|
|
9
|
+
# a STOP marker, with atomic admission (stopped-check + push share one
|
|
10
|
+
# monitor critical section), idempotent shutdown, busy accounting and a
|
|
11
|
+
# last-ditch dispatch net. Mechanics only, per the join.rb contract: the
|
|
12
|
+
# host keeps its own monitor and log channel — the skeleton never
|
|
13
|
+
# allocates a lock and never logs directly.
|
|
14
|
+
#
|
|
15
|
+
# Host contract — state (host-initialized, skeleton-operated):
|
|
16
|
+
# @monitor / @queue / @worker — host-owned; domain state shares the monitor
|
|
17
|
+
# @stopped / @busy — skeleton-owned flags under @monitor
|
|
18
|
+
# plus private hooks: worker_max_queue (FIFO bound), worker_warn (log
|
|
19
|
+
# sink), worker_drop_accounted (overflow reconciliation),
|
|
20
|
+
# worker_dispatch_failed (net: receives kind, payload, error so the
|
|
21
|
+
# host reconciles its accounting), worker_before_join
|
|
22
|
+
# (pre-join teardown, default none) and handle_event (dispatch hook).
|
|
23
|
+
module Worker
|
|
24
|
+
# Queue terminator; drop-oldest must never swallow it (the worker would drain forever).
|
|
25
|
+
STOP = :__worker_stop__
|
|
26
|
+
|
|
27
|
+
# Shutdown grants the worker JOIN_TIMEOUT seconds to drain; the idle
|
|
28
|
+
# probe polls at a cadence that keeps teardown feeling immediate.
|
|
29
|
+
JOIN_TIMEOUT = 2
|
|
30
|
+
IDLE_POLL = 0.01
|
|
31
|
+
|
|
32
|
+
def stopped? = @monitor.synchronize { @stopped }
|
|
33
|
+
|
|
34
|
+
# Queue + in-flight count: incremented at admission, decremented when
|
|
35
|
+
# consumed or dropped — closes the accounting window pop would open.
|
|
36
|
+
def busy? = @monitor.synchronize { @busy.positive? }
|
|
37
|
+
|
|
38
|
+
def queue_size = @queue.size
|
|
39
|
+
|
|
40
|
+
# Idle probe: Join's mechanics are handle-shaped (join a thread), this
|
|
41
|
+
# is predicate-shaped (poll busy?) — same deadline discipline, own loop.
|
|
42
|
+
def wait_idle(timeout: 2.0)
|
|
43
|
+
deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + timeout
|
|
44
|
+
sleep IDLE_POLL while busy? && Process.clock_gettime(Process::CLOCK_MONOTONIC) < deadline
|
|
45
|
+
!busy?
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def shutdown
|
|
49
|
+
@monitor.synchronize do
|
|
50
|
+
return if @stopped
|
|
51
|
+
|
|
52
|
+
@stopped = true
|
|
53
|
+
@busy += 1 # the STOP marker counts as consumed work
|
|
54
|
+
@queue.push(STOP)
|
|
55
|
+
end
|
|
56
|
+
worker_before_join
|
|
57
|
+
outcome = Join.thread(@worker, timeout: JOIN_TIMEOUT)
|
|
58
|
+
if outcome == :timeout
|
|
59
|
+
# Thread#kill waits out the dying thread's unwind, so the in-flight
|
|
60
|
+
# ensure decrement runs before we return; busy then equals the
|
|
61
|
+
# unconsumed queue — lost work stays honestly counted (-1: the
|
|
62
|
+
# STOP marker itself is still queued).
|
|
63
|
+
worker_warn("worker did not stop in #{JOIN_TIMEOUT}s — killing with #{queue_size - 1} event(s) unprocessed")
|
|
64
|
+
@worker.kill
|
|
65
|
+
elsif outcome.is_a?(StandardError)
|
|
66
|
+
# Error-as-data: Join returns a dead-with-exception thread's error
|
|
67
|
+
# — teardown completes, the death is reported, never swallowed.
|
|
68
|
+
worker_warn("worker thread died: #{outcome.class}: #{outcome.message}")
|
|
69
|
+
end
|
|
70
|
+
@worker = nil
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Atomic admission: the stopped-check and the push share one critical
|
|
74
|
+
# section — an event racing shutdown either lands before STOP (and is
|
|
75
|
+
# consumed) or is refused; it can never straddle the marker and leak a
|
|
76
|
+
# busy increment behind an unconsumable item. The overflow hook fires
|
|
77
|
+
# OUTSIDE the monitor: a slow host reconcile (gate locks, log I/O) must
|
|
78
|
+
# never stall admission, shutdown or wait_idle.
|
|
79
|
+
def enqueue_event(kind, payload)
|
|
80
|
+
dropped = nil
|
|
81
|
+
@monitor.synchronize do
|
|
82
|
+
return false if @stopped
|
|
83
|
+
|
|
84
|
+
if @queue.size >= worker_max_queue
|
|
85
|
+
dropped = drop_oldest!
|
|
86
|
+
return false if dropped == STOP
|
|
87
|
+
end
|
|
88
|
+
@busy += 1
|
|
89
|
+
@queue.push([kind, payload])
|
|
90
|
+
end
|
|
91
|
+
worker_drop_accounted(dropped) if dropped
|
|
92
|
+
true
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
private
|
|
96
|
+
|
|
97
|
+
def worker_before_join; end
|
|
98
|
+
|
|
99
|
+
def run_worker
|
|
100
|
+
loop do
|
|
101
|
+
kind, payload = @queue.pop
|
|
102
|
+
break if kind == STOP
|
|
103
|
+
|
|
104
|
+
handle_event(kind, payload)
|
|
105
|
+
rescue StandardError => e
|
|
106
|
+
# A raise escaping handle_event's own rescue would kill the worker
|
|
107
|
+
# with queued events unconsumed; hand the item to the hook (the
|
|
108
|
+
# host reconciles its accounting) and keep draining. The net is
|
|
109
|
+
# itself guarded: when it runs, log/reconcile infrastructure is
|
|
110
|
+
# already failing and a second raise must not kill the worker.
|
|
111
|
+
begin
|
|
112
|
+
worker_dispatch_failed(kind, payload, e)
|
|
113
|
+
rescue StandardError
|
|
114
|
+
nil
|
|
115
|
+
end
|
|
116
|
+
ensure
|
|
117
|
+
@monitor.synchronize { @busy -= 1 }
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Make room for one admission (assumes @monitor held): pops the oldest
|
|
122
|
+
# item, decrements its busy increment, and returns it for the caller to
|
|
123
|
+
# hand to worker_drop_accounted outside the monitor. Returns STOP
|
|
124
|
+
# (marker re-pushed; the caller refuses rather than strand an event
|
|
125
|
+
# behind the terminator) or nil when the worker drained the queue
|
|
126
|
+
# between the size check and this pop (nothing dropped, unaccounted).
|
|
127
|
+
def drop_oldest!
|
|
128
|
+
item = @queue.pop(true)
|
|
129
|
+
if item == STOP
|
|
130
|
+
@queue.push(STOP)
|
|
131
|
+
return STOP
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
@busy -= 1
|
|
135
|
+
item
|
|
136
|
+
rescue ThreadError
|
|
137
|
+
# Worker drained between the size check and pop(true): no-op race
|
|
138
|
+
# loss — nothing was dropped, nothing to account.
|
|
139
|
+
nil
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
data/lib/rubik/concurrency.rb
CHANGED
|
@@ -6,6 +6,7 @@ require_relative "concurrency/event_loop"
|
|
|
6
6
|
require_relative "concurrency/scheduler"
|
|
7
7
|
require_relative "concurrency/boundary"
|
|
8
8
|
require_relative "concurrency/join"
|
|
9
|
+
require_relative "concurrency/worker"
|
|
9
10
|
require_relative "concurrency/fiber_timeout"
|
|
10
11
|
|
|
11
12
|
module Rubik
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
module Rubik
|
|
4
4
|
class Config
|
|
5
5
|
module DeepOps
|
|
6
|
+
SENSITIVE_PROJECT_CONFIG_KEYS = [
|
|
7
|
+
"security", "sandbox", "plugins", "mcp", "lsp", "project", "test", "linter", "adapter"
|
|
8
|
+
].freeze
|
|
9
|
+
|
|
6
10
|
private
|
|
7
11
|
|
|
8
12
|
def deep_dup(obj)
|
|
@@ -89,6 +93,19 @@ module Rubik
|
|
|
89
93
|
end
|
|
90
94
|
target[last_key] = value
|
|
91
95
|
end
|
|
96
|
+
|
|
97
|
+
def filter_untrusted_project_config(hash)
|
|
98
|
+
return hash unless hash.is_a?(Hash)
|
|
99
|
+
|
|
100
|
+
filtered = deep_dup(hash)
|
|
101
|
+
SENSITIVE_PROJECT_CONFIG_KEYS.each { |key| filtered.delete(key) }
|
|
102
|
+
if filtered["workspace"].is_a?(Hash)
|
|
103
|
+
["allow_external_writes", "allowed_external_dirs", "additional_roots"].each do |k|
|
|
104
|
+
filtered["workspace"].delete(k)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
filtered
|
|
108
|
+
end
|
|
92
109
|
end
|
|
93
110
|
end
|
|
94
111
|
end
|
|
@@ -72,7 +72,6 @@ module Rubik
|
|
|
72
72
|
"command_allowlist" => [], # operator-managed token-prefix entries (e.g. "node .gitnexus/run.cjs")
|
|
73
73
|
"allow_safe_probes" => true # `bash --version`-style version/help probes bypass the blocklist
|
|
74
74
|
},
|
|
75
|
-
"network" => { "allow" => false },
|
|
76
75
|
"buffer" => {
|
|
77
76
|
"auto_apply" => "manual",
|
|
78
77
|
"model_can_apply" => true,
|
data/lib/rubik/config/schema.rb
CHANGED
|
@@ -41,7 +41,6 @@ module Rubik
|
|
|
41
41
|
"sandbox.shell" => { type: :enum, allowed: ["auto", "bash", "powershell"] },
|
|
42
42
|
"security.allow_safe_probes" => { type: :boolean },
|
|
43
43
|
"security.command_allowlist" => { type: :array },
|
|
44
|
-
"network.allow" => { type: :boolean },
|
|
45
44
|
"buffer.auto_apply" => { type: :enum, allowed: ["manual", "on_test", "on_finish", "always"] },
|
|
46
45
|
"buffer.model_can_apply" => { type: :boolean },
|
|
47
46
|
"buffer.prompt_indicator" => { type: :boolean },
|
data/lib/rubik/config.rb
CHANGED
|
@@ -18,6 +18,7 @@ module Rubik
|
|
|
18
18
|
include ModelCatalog
|
|
19
19
|
|
|
20
20
|
DEFAULT_CONFIG = Defaults::DEFAULT_CONFIG
|
|
21
|
+
SENSITIVE_PROJECT_CONFIG_KEYS = DeepOps::SENSITIVE_PROJECT_CONFIG_KEYS
|
|
21
22
|
|
|
22
23
|
attr_reader :data, :warnings, :root_dir, :home_dir,
|
|
23
24
|
:defaults_layer, :global_layer, :project_layer, :env_layer, :session_layer
|
|
@@ -34,9 +35,7 @@ module Rubik
|
|
|
34
35
|
@event_bus = nil
|
|
35
36
|
@session_layer = {}
|
|
36
37
|
@defaults_layer = deep_dup(DEFAULT_CONFIG)
|
|
37
|
-
@global_layer = {}
|
|
38
|
-
@project_layer = {}
|
|
39
|
-
@env_layer = {}
|
|
38
|
+
@global_layer = @project_layer = @env_layer = {}
|
|
40
39
|
ensure_rubik_directories
|
|
41
40
|
@data = load_merged_config
|
|
42
41
|
end
|
|
@@ -283,6 +282,11 @@ module Rubik
|
|
|
283
282
|
@global_layer = {} unless @global_layer.is_a?(Hash)
|
|
284
283
|
@project_layer = load_yaml(project_config_path)
|
|
285
284
|
@project_layer = {} unless @project_layer.is_a?(Hash)
|
|
285
|
+
|
|
286
|
+
if @project_layer.any? && defined?(Rubik::CLI::WorkspaceTrust) && !Rubik::CLI::WorkspaceTrust.trusted?(@root_dir)
|
|
287
|
+
@project_layer = filter_untrusted_project_config(@project_layer)
|
|
288
|
+
end
|
|
289
|
+
|
|
286
290
|
@env_layer = EnvLoader.load_env(ENV, DEFAULT_CONFIG, @warnings)
|
|
287
291
|
@session_layer = {}
|
|
288
292
|
|
|
@@ -29,9 +29,10 @@ module Rubik
|
|
|
29
29
|
"Gemfile", "package.json", "Cargo.toml", "go.mod", "Makefile", "pyproject.toml", "Rakefile", "index.html", "README.md"
|
|
30
30
|
].freeze
|
|
31
31
|
|
|
32
|
-
def initialize(root_dir: Dir.pwd, protocol_candidates: DEFAULT_PROTOCOL_CANDIDATES)
|
|
32
|
+
def initialize(root_dir: Dir.pwd, protocol_candidates: DEFAULT_PROTOCOL_CANDIDATES, config: nil)
|
|
33
33
|
@root_dir = root_dir
|
|
34
34
|
@protocol_candidates = protocol_candidates
|
|
35
|
+
@config = config
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
# Returns a Hash with three keys, each pre-extracted and pre-rendered
|
|
@@ -53,17 +54,35 @@ module Rubik
|
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
# Render the matched protocol files into an XML block.
|
|
57
|
+
# Caps content to avoid blowing out the context window (F3) and neutralizes
|
|
58
|
+
# closing tags to prevent prompt injection.
|
|
56
59
|
def read_protocol_xml
|
|
57
60
|
files = find_protocol_files
|
|
58
61
|
return "" if files.empty?
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
selection = (@config&.fetch("context.protocol_selection", "first") || "first").to_s
|
|
64
|
+
effective_files = selection == "all" ? files : files.first(1)
|
|
65
|
+
max_tokens = (@config&.fetch("context.protocol_max_tokens", 8192) || 8192).to_i
|
|
66
|
+
max_chars = [max_tokens * 4, 4096].max
|
|
67
|
+
|
|
68
|
+
effective_files.map do |f|
|
|
69
|
+
raw_content = Rubik::Platform.read_text(f[:full_path]).strip
|
|
70
|
+
# Neutralize closing tags to prevent section breakout
|
|
71
|
+
content = raw_content.gsub("</protocol>", "</protocol>")
|
|
72
|
+
if content.length > max_chars
|
|
73
|
+
trunc = Rubik::Tools::Truncator.truncate(content, max_chars: max_chars, strategy: :head_tail)
|
|
74
|
+
<<~XML
|
|
75
|
+
<protocol source="#{f[:path]}" truncated="true">
|
|
76
|
+
#{trunc[:text]}
|
|
77
|
+
</protocol>
|
|
78
|
+
XML
|
|
79
|
+
else
|
|
80
|
+
<<~XML
|
|
81
|
+
<protocol source="#{f[:path]}">
|
|
82
|
+
#{content}
|
|
83
|
+
</protocol>
|
|
84
|
+
XML
|
|
85
|
+
end
|
|
67
86
|
end.join("\n").strip
|
|
68
87
|
end
|
|
69
88
|
|
data/lib/rubik/events.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rubik
|
|
4
|
+
# THE single home of the event bus's name vocabulary. Publishers and
|
|
5
|
+
# subscribers across layers (orchestrator, repl, storage, kernel) read
|
|
6
|
+
# these constants instead of redeclaring the names — a redeclaration is
|
|
7
|
+
# one rename away from a silently dead subscription. Zero requires, a
|
|
8
|
+
# dependency-free leaf like Coeffects/Uris: any layer can bind to the
|
|
9
|
+
# shared names without dragging another layer's logic in.
|
|
10
|
+
module Events
|
|
11
|
+
SUBAGENT_COMPLETED = :subagent_completed
|
|
12
|
+
SUBAGENT_MESSAGE_TO_PARENT = :subagent_message_to_parent
|
|
13
|
+
TURN_FINISHED = :turn_finished
|
|
14
|
+
GOAL_FINISHED = :goal_finished
|
|
15
|
+
GOAL_SUSPENDED = :goal_suspended
|
|
16
|
+
UNIT_STATE_CHANGED = :unit_state_changed
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -10,6 +10,7 @@ module Rubik
|
|
|
10
10
|
# subscriber error isolation.
|
|
11
11
|
class Dispatcher
|
|
12
12
|
STOP_MARKER = :__dispatcher_stop__
|
|
13
|
+
DEFAULT_WARN_QUEUE_DEPTH = 1000
|
|
13
14
|
|
|
14
15
|
Event = Struct.new(:name, :payload, :subsystem, :level, :facility_id, keyword_init: true)
|
|
15
16
|
Barrier = Struct.new(:queue)
|
|
@@ -44,6 +45,18 @@ module Rubik
|
|
|
44
45
|
subsystem: subsystem.to_sym, level: level, facility_id: facility_id
|
|
45
46
|
)
|
|
46
47
|
)
|
|
48
|
+
|
|
49
|
+
q_size = @queue.size
|
|
50
|
+
if q_size >= DEFAULT_WARN_QUEUE_DEPTH && (q_size % 500).zero?
|
|
51
|
+
msg = "Dispatcher event queue high watermark reached: #{q_size} pending events"
|
|
52
|
+
@logger&.warn(msg)
|
|
53
|
+
begin
|
|
54
|
+
@dmesg&.log(:kernel, :warn, msg, facility_id: "dispatcher", queue_size: q_size)
|
|
55
|
+
rescue StandardError
|
|
56
|
+
nil
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
47
60
|
true
|
|
48
61
|
end
|
|
49
62
|
|
|
@@ -92,29 +105,12 @@ module Rubik
|
|
|
92
105
|
end
|
|
93
106
|
alias dispose stop
|
|
94
107
|
|
|
95
|
-
def stopped?
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
def
|
|
100
|
-
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def worker_alive?
|
|
104
|
-
!@worker_thread.nil? && @worker_thread.alive?
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def subscribers(event_name)
|
|
108
|
-
@lock.synchronize { @listeners[event_name.to_sym].dup }
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
def all_subscribers
|
|
112
|
-
@lock.synchronize { @listeners.transform_values(&:dup) }
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
def queue_size
|
|
116
|
-
@queue.size
|
|
117
|
-
end
|
|
108
|
+
def stopped? = @lock.synchronize { @stopped }
|
|
109
|
+
def alive? = !stopped? && worker_alive?
|
|
110
|
+
def worker_alive? = !@worker_thread.nil? && @worker_thread.alive?
|
|
111
|
+
def subscribers(event_name) = @lock.synchronize { @listeners[event_name.to_sym].dup }
|
|
112
|
+
def all_subscribers = @lock.synchronize { @listeners.transform_values(&:dup) }
|
|
113
|
+
def queue_size = @queue.size
|
|
118
114
|
|
|
119
115
|
private
|
|
120
116
|
|