rubik 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ATTRIBUTION.md +1 -1
- data/CHANGELOG.md +143 -1
- data/lib/rubik/adapter/base.rb +2 -1
- data/lib/rubik/adapter/process.rb +28 -67
- data/lib/rubik/benchmark/vakanuvis_adoption.rb +10 -3
- data/lib/rubik/buffer/apply_contract.rb +3 -3
- data/lib/rubik/buffer/apply_transaction.rb +165 -0
- data/lib/rubik/buffer/manager.rb +26 -120
- data/lib/rubik/config/deep_ops.rb +4 -1
- data/lib/rubik/config/defaults.rb +6 -3
- data/lib/rubik/config/schema.rb +8 -0
- data/lib/rubik/config/secret_policy.rb +197 -0
- data/lib/rubik/config.rb +11 -0
- data/lib/rubik/diagnostics/collector.rb +0 -9
- data/lib/rubik/errors.rb +15 -0
- data/lib/rubik/event_bus.rb +2 -1
- data/lib/rubik/kernel/dispatcher.rb +12 -7
- data/lib/rubik/kernel/unit.rb +4 -1
- data/lib/rubik/llm/registry.rb +12 -9
- data/lib/rubik/llm/router.rb +2 -5
- data/lib/rubik/log.rb +21 -0
- data/lib/rubik/lsp/client.rb +77 -273
- data/lib/rubik/lsp/manager.rb +14 -10
- data/lib/rubik/lsp/transport.rb +365 -0
- data/lib/rubik/mcp/boot_lifecycle.rb +6 -2
- data/lib/rubik/mcp/boot_run.rb +190 -0
- data/lib/rubik/mcp/manager.rb +40 -163
- data/lib/rubik/mcp/transport/stdio.rb +4 -1
- data/lib/rubik/orchestrator/auto_apply.rb +4 -3
- data/lib/rubik/orchestrator/continuation_manager.rb +3 -22
- data/lib/rubik/orchestrator/goal_session.rb +53 -39
- data/lib/rubik/orchestrator/loop.rb +28 -47
- data/lib/rubik/orchestrator/maestro_gate.rb +5 -7
- data/lib/rubik/orchestrator/provider_recovery.rb +4 -2
- data/lib/rubik/orchestrator/provider_resolver.rb +4 -2
- data/lib/rubik/orchestrator/resume_window.rb +96 -0
- data/lib/rubik/orchestrator/shell_deps.rb +16 -0
- data/lib/rubik/orchestrator/stream_manager.rb +2 -1
- data/lib/rubik/orchestrator/subagent/deferred_spec.rb +4 -1
- data/lib/rubik/orchestrator/subagent/instance.rb +7 -12
- data/lib/rubik/orchestrator/subagent/lifecycle.rb +3 -1
- data/lib/rubik/orchestrator/subagent/questioner.rb +3 -1
- data/lib/rubik/orchestrator/subagent/reaper.rb +3 -5
- data/lib/rubik/orchestrator/subagent/resilience.rb +4 -2
- data/lib/rubik/orchestrator/subagent/result_archive.rb +0 -4
- data/lib/rubik/orchestrator/subagent/run_cycle.rb +2 -7
- data/lib/rubik/orchestrator/subagent/spawn_transaction.rb +11 -2
- data/lib/rubik/orchestrator/subagent/step_runner.rb +10 -2
- data/lib/rubik/orchestrator/subagent/type_definition.rb +0 -4
- data/lib/rubik/orchestrator/tool_timeout.rb +121 -1
- data/lib/rubik/platform/io_drain.rb +2 -1
- data/lib/rubik/platform/process.rb +144 -54
- data/lib/rubik/platform.rb +2 -1
- data/lib/rubik/plugin/manager.rb +2 -1
- data/lib/rubik/repl/commands/agent_context.rb +8 -7
- data/lib/rubik/repl/commands/agent_execution.rb +13 -32
- data/lib/rubik/repl/commands/agent_models.rb +4 -3
- data/lib/rubik/repl/commands/agent_providers.rb +43 -2
- data/lib/rubik/repl/commands/base.rb +47 -2
- data/lib/rubik/repl/commands/buffer.rb +5 -4
- data/lib/rubik/repl/commands/lsp.rb +2 -1
- data/lib/rubik/repl/commands/pruner.rb +2 -1
- data/lib/rubik/repl/commands/secrets.rb +151 -0
- data/lib/rubik/repl/commands/workspace.rb +60 -150
- data/lib/rubik/repl/commands/workspace_approval.rb +209 -0
- data/lib/rubik/repl/config_wiring.rb +3 -3
- data/lib/rubik/repl/hooks.rb +2 -1
- data/lib/rubik/repl/input_execution.rb +158 -76
- data/lib/rubik/repl/input_loop.rb +2 -1
- data/lib/rubik/repl/lifecycle.rb +59 -209
- data/lib/rubik/repl/notice_router.rb +319 -0
- data/lib/rubik/repl/paste_support.rb +3 -1
- data/lib/rubik/repl/presentation.rb +5 -3
- data/lib/rubik/repl/pruner/gate.rb +3 -1
- data/lib/rubik/repl/pruner/harness.rb +2 -1
- data/lib/rubik/repl/shell.rb +4 -3
- data/lib/rubik/repl/turn_recorder.rb +6 -5
- data/lib/rubik/runtime/discovery.rb +3 -2
- data/lib/rubik/runtime/loop_service.rb +4 -3
- data/lib/rubik/runtime/manifest_store.rb +9 -1
- data/lib/rubik/runtime/overlay_guard.rb +127 -0
- data/lib/rubik/runtime/overlay_storage.rb +92 -146
- data/lib/rubik/runtime/task_manager.rb +64 -25
- data/lib/rubik/sandbox/driver/docker.rb +5 -1
- data/lib/rubik/sandbox/runner.rb +16 -15
- data/lib/rubik/security/command_gate.rb +117 -93
- data/lib/rubik/security/guard.rb +6 -2
- data/lib/rubik/security/secret_store.rb +463 -0
- data/lib/rubik/security/synthesis_gate.rb +8 -11
- data/lib/rubik/session/manager.rb +7 -1
- data/lib/rubik/skills/manager.rb +2 -3
- data/lib/rubik/storage/search.rb +49 -0
- data/lib/rubik/storage/store.rb +13 -20
- data/lib/rubik/storage/vakanuvis/harness.rb +2 -3
- data/lib/rubik/tools/base.rb +22 -0
- data/lib/rubik/tools/builtins/files.rb +3 -15
- data/lib/rubik/tools/builtins/grep.rb +1 -6
- data/lib/rubik/tools/builtins/lifecycle.rb +6 -5
- data/lib/rubik/tools/lifecycle_rollbacks.rb +14 -1
- data/lib/rubik/tools/truncator.rb +48 -36
- data/lib/rubik/ui/banner.rb +4 -3
- data/lib/rubik/ui/spinner.rb +3 -1
- data/lib/rubik/ui/statusline.rb +6 -5
- data/lib/rubik/version.rb +1 -1
- data/lib/rubik.rb +1 -2
- metadata +13 -1
data/lib/rubik/repl/lifecycle.rb
CHANGED
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "../events"
|
|
4
4
|
require_relative "../log"
|
|
5
|
+
require_relative "../platform"
|
|
6
|
+
require_relative "../storage/layout"
|
|
5
7
|
require_relative "../orchestrator/subagent/notices"
|
|
6
8
|
require_relative "../prompt/conversation_rows"
|
|
7
9
|
require_relative "pending_notice_queue"
|
|
10
|
+
require_relative "notice_router"
|
|
8
11
|
|
|
9
12
|
module Rubik
|
|
10
13
|
module REPL
|
|
@@ -12,14 +15,27 @@ module Rubik
|
|
|
12
15
|
# (keeps shell.rb under the decoupling line-count gate). The Shell remains
|
|
13
16
|
# the coordinator: these methods depend on shell identity, so they live in
|
|
14
17
|
# an included module rather than in Composition (the pure builder).
|
|
18
|
+
#
|
|
19
|
+
# Issue #469: the notice-routing half (MCP boot notices, subagent event
|
|
20
|
+
# routing, reactive wakeup state) now lives in NoticeRouter; the methods
|
|
21
|
+
# below delegate to a lazily-created router so the public Shell surface
|
|
22
|
+
# (and the bare-Lifecycle test-double harnesses) stay unchanged. The
|
|
23
|
+
# router owns the queue/mutex/token concurrency state.
|
|
15
24
|
module Lifecycle
|
|
16
|
-
# Plan 109 Faz B: notice kinds worth interrupting the idle prompt
|
|
17
|
-
#
|
|
18
|
-
# (
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
#
|
|
25
|
+
# Plan 109 Faz B: notice kinds worth interrupting the idle prompt —
|
|
26
|
+
# vocabulary now owned by NoticeRouter; re-exported here because
|
|
27
|
+
# callers (and silence-contract tests) pin Rubik::REPL::Lifecycle::
|
|
28
|
+
# WAKE_KINDS.
|
|
29
|
+
WAKE_KINDS = NoticeRouter::WAKE_KINDS
|
|
30
|
+
|
|
31
|
+
# The notice-routing collaborator (issue #469): lazily created so bare
|
|
32
|
+
# Lifecycle test doubles (which set plain ivars, no constructor) keep
|
|
33
|
+
# working; the router reads host state live via instance_variable_get.
|
|
34
|
+
def notice_router
|
|
35
|
+
@notice_router ||= NoticeRouter.new(self)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Plan 1, Phase 1: assign built subsystems. Entries derive from the
|
|
23
39
|
# ServiceCatalog (the single declaration point): one loop assigns every
|
|
24
40
|
# injectable entry's ivar, then a second pass runs the per-entry
|
|
25
41
|
# after_inject hooks (injected-buffer post-wiring — which runs only on
|
|
@@ -56,11 +72,11 @@ module Rubik
|
|
|
56
72
|
def load_plugins(parts)
|
|
57
73
|
return unless @plugin_manager
|
|
58
74
|
|
|
59
|
-
Array(@config
|
|
60
|
-
if @config
|
|
75
|
+
Array(Rubik::Storage::Layout.config_get(@config, "plugins.load", [])).each { |g| @plugin_manager.load_plugin_gem(g, runtime_manager: @runtime_manager) }
|
|
76
|
+
if Rubik::Storage::Layout.config_get(@config, "plugins.autoload_dropin", true) && parts.respond_to?(:plugin_storage) && parts.plugin_storage
|
|
61
77
|
@plugin_manager.load_dropin_plugins(runtime_manager: @runtime_manager, storage: parts.plugin_storage)
|
|
62
78
|
end
|
|
63
|
-
aliases_cfg = @config
|
|
79
|
+
aliases_cfg = Rubik::Storage::Layout.config_get(@config, "plugins.aliases", {})
|
|
64
80
|
aliases_cfg.each { |s, f| @plugin_manager.register_alias(s, f) } if aliases_cfg.is_a?(Hash)
|
|
65
81
|
end
|
|
66
82
|
|
|
@@ -186,7 +202,7 @@ module Rubik
|
|
|
186
202
|
# '!context scan' (strong_only: false). Memoized so the scan reuses
|
|
187
203
|
# the assessment without a second git spawn.
|
|
188
204
|
def maybe_warn_huge_root!(strong_only: true)
|
|
189
|
-
return unless @config.nil? || @config
|
|
205
|
+
return unless @config.nil? || Rubik::Storage::Layout.config_get(@config, "context.huge_root_notice", true)
|
|
190
206
|
return if @huge_root_notice_shown
|
|
191
207
|
|
|
192
208
|
assessment = huge_root_assessment
|
|
@@ -196,11 +212,7 @@ module Rubik
|
|
|
196
212
|
return if guidance.empty?
|
|
197
213
|
|
|
198
214
|
@huge_root_notice_shown = true
|
|
199
|
-
|
|
200
|
-
@terminal_guard.print_safe_notice(guidance)
|
|
201
|
-
else
|
|
202
|
-
@output&.puts guidance
|
|
203
|
-
end
|
|
215
|
+
NoticeRouter.print_safe_notice_line(@terminal_guard, @output, guidance)
|
|
204
216
|
end
|
|
205
217
|
|
|
206
218
|
def huge_root_assessment
|
|
@@ -219,9 +231,8 @@ module Rubik
|
|
|
219
231
|
|
|
220
232
|
def huge_root_boot_scan_skipped?
|
|
221
233
|
return false unless huge_root_assessment.strong
|
|
222
|
-
return false unless @config.respond_to?(:fetch)
|
|
223
234
|
|
|
224
|
-
|
|
235
|
+
!Rubik::Storage::Layout.config_get(@config, "context.boot_scan_on_huge_root", false)
|
|
225
236
|
end
|
|
226
237
|
|
|
227
238
|
# Boot-time config observability (issue #399): Config#warnings
|
|
@@ -241,241 +252,79 @@ module Rubik
|
|
|
241
252
|
warnings.each do |w|
|
|
242
253
|
line = "⚠ Config: #{w}"
|
|
243
254
|
Rubik::Log.warn(:config, line)
|
|
244
|
-
|
|
245
|
-
@terminal_guard.print_safe_notice(line)
|
|
246
|
-
else
|
|
247
|
-
@output&.puts line
|
|
248
|
-
end
|
|
255
|
+
NoticeRouter.print_safe_notice_line(@terminal_guard, @output, line)
|
|
249
256
|
end
|
|
250
257
|
end
|
|
251
258
|
|
|
252
|
-
#
|
|
253
|
-
#
|
|
254
|
-
#
|
|
255
|
-
#
|
|
256
|
-
|
|
259
|
+
# --- Notice routing (issue #469): thin delegation to NoticeRouter ----
|
|
260
|
+
# The router owns the queue/mutex/token concurrency state; these
|
|
261
|
+
# delegators keep the historical Shell surface (and the bare-Lifecycle
|
|
262
|
+
# test-double harnesses that include this module) unchanged.
|
|
263
|
+
|
|
264
|
+
# Async MCP boot progress notices (mcp-async-boot D8). See
|
|
265
|
+
# NoticeRouter#wire_mcp_boot_notices!.
|
|
257
266
|
def wire_mcp_boot_notices!(async:)
|
|
258
|
-
|
|
259
|
-
return if @mcp_notice_tokens # idempotent re-wire
|
|
260
|
-
|
|
261
|
-
ctx = @runtime_manager&.context
|
|
262
|
-
return unless ctx.respond_to?(:on_dispose)
|
|
263
|
-
|
|
264
|
-
@mcp_notice_tokens = [
|
|
265
|
-
[:mcp_server_loaded, @event_bus.subscribe(:mcp_server_loaded) { |payload| print_mcp_boot_notice(:loaded, payload) }],
|
|
266
|
-
[:mcp_server_failed, @event_bus.subscribe(:mcp_server_failed) { |payload| print_mcp_boot_notice(:failed, payload) }]
|
|
267
|
-
]
|
|
268
|
-
ctx.on_dispose do
|
|
269
|
-
@mcp_notice_tokens&.each { |(event, token)| @event_bus.unsubscribe(event, token) }
|
|
270
|
-
@mcp_notice_tokens = nil
|
|
271
|
-
end
|
|
267
|
+
notice_router.wire_mcp_boot_notices!(async: async)
|
|
272
268
|
end
|
|
273
269
|
|
|
274
|
-
# Same kworker-thread contract as handle_subagent_event: no shell locks,
|
|
275
|
-
# drop silently when the UI is not up yet (an instant boot failure is
|
|
276
|
-
# still on stderr and in dmesg). Pure display line — never enters the
|
|
277
|
-
# conversation history and never wakes an idle turn.
|
|
278
270
|
def print_mcp_boot_notice(state, payload)
|
|
279
|
-
|
|
280
|
-
return unless payload.is_a?(Hash)
|
|
281
|
-
|
|
282
|
-
name = payload[:server]
|
|
283
|
-
line = if state == :loaded
|
|
284
|
-
"mcp: server '#{name}' ready (#{payload[:tools] || 0} tools)"
|
|
285
|
-
else
|
|
286
|
-
"mcp: server '#{name}' failed (#{payload[:error]})"
|
|
287
|
-
end
|
|
288
|
-
@terminal_guard&.print_safe_notice(line)
|
|
271
|
+
notice_router.print_mcp_boot_notice(state, payload)
|
|
289
272
|
end
|
|
290
273
|
|
|
291
274
|
def wire_subagent_events!
|
|
292
|
-
|
|
293
|
-
return if @subagent_event_tokens # idempotent re-wire (RenderService precedent)
|
|
294
|
-
|
|
295
|
-
# Inverse-by-construction: subscribe only where the unsubscribe
|
|
296
|
-
# inverse can be registered in the same breath (AGENTS.md §1A).
|
|
297
|
-
ctx = @runtime_manager&.context
|
|
298
|
-
return unless ctx.respond_to?(:on_dispose)
|
|
299
|
-
|
|
300
|
-
@subagent_notices_mutex = Mutex.new
|
|
301
|
-
@subagent_notices = []
|
|
302
|
-
# Plan 109: the idle-turn wake flag, eagerly initialized BEFORE any
|
|
303
|
-
# subscription exists so handlers never race its construction.
|
|
304
|
-
@pending_notice_queue = PendingNoticeQueue.new
|
|
305
|
-
tokens = Rubik::Orchestrator::Subagent::Notices::EVENTS.keys.map do |event|
|
|
306
|
-
[event, @event_bus.subscribe(event) { |payload| handle_subagent_event(event, payload) }]
|
|
307
|
-
end
|
|
308
|
-
tokens << [Rubik::Events::UNIT_STATE_CHANGED, @event_bus.subscribe(Rubik::Events::UNIT_STATE_CHANGED) { |payload| handle_unit_event(payload) }]
|
|
309
|
-
tokens << [Rubik::Events::SUBAGENT_MESSAGE_TO_PARENT, @event_bus.subscribe(Rubik::Events::SUBAGENT_MESSAGE_TO_PARENT) { |payload| handle_parent_message(payload) }]
|
|
310
|
-
@subagent_event_tokens = tokens
|
|
311
|
-
ctx.on_dispose do
|
|
312
|
-
@subagent_event_tokens&.each { |(event, token)| @event_bus.unsubscribe(event, token) }
|
|
313
|
-
@subagent_event_tokens = nil
|
|
314
|
-
end
|
|
275
|
+
notice_router.wire_subagent_events!
|
|
315
276
|
end
|
|
316
277
|
|
|
317
|
-
# ONE routing seam for subagent notices (Candidate 02, unified for
|
|
318
|
-
# Plan 109): bus event -> normalized notice -> channel-split
|
|
319
|
-
# delivery. Called on the kworker thread (bus dispatch is
|
|
320
|
-
# synchronous): Queue pushes, the standby Mutex, and the guard
|
|
321
|
-
# monitor only — no shell locks. Model channel (structured hash)
|
|
322
|
-
# enters the active loop queue and is rendered to XML at drain
|
|
323
|
-
# time; user channel (terminal line) is buffered to stdout while a
|
|
324
|
-
# loop is active and flushed at turn end. Between turns the notice
|
|
325
|
-
# is injected into @conversation_history, printed, and — when
|
|
326
|
-
# wake-worthy — queued to owe agent-0 an autonomous notice turn.
|
|
327
278
|
def handle_subagent_event(event_name, payload)
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
notice = Rubik::Orchestrator::Subagent::Notices.normalize(event_name, payload)
|
|
331
|
-
route_subagent_notice(notice) if notice
|
|
279
|
+
notice_router.handle_subagent_event(event_name, payload)
|
|
332
280
|
end
|
|
333
281
|
|
|
334
282
|
def handle_unit_event(payload)
|
|
335
|
-
|
|
336
|
-
return unless payload.is_a?(Hash)
|
|
337
|
-
|
|
338
|
-
type = payload[:type]&.to_sym
|
|
339
|
-
return unless [:process, :task].include?(type)
|
|
340
|
-
|
|
341
|
-
to_state = payload[:to_state]&.to_sym
|
|
342
|
-
return unless [:completed, :failed].include?(to_state)
|
|
343
|
-
|
|
344
|
-
route_subagent_notice({ kind: :task, id: payload[:unit_id], role: "Background Task", state: to_state.to_s, reason: payload[:reason] })
|
|
283
|
+
notice_router.handle_unit_event(payload)
|
|
345
284
|
end
|
|
346
285
|
|
|
347
286
|
def handle_parent_message(payload)
|
|
348
|
-
|
|
349
|
-
return unless payload.is_a?(Hash)
|
|
350
|
-
|
|
351
|
-
route_subagent_notice({ kind: :message, id: payload[:sender_id] || "subagent",
|
|
352
|
-
role: "Subagent", state: "message", reason: payload[:message].to_s })
|
|
287
|
+
notice_router.handle_parent_message(payload)
|
|
353
288
|
end
|
|
354
289
|
|
|
355
290
|
def route_subagent_notice(notice)
|
|
356
|
-
|
|
357
|
-
if @active_loop
|
|
358
|
-
@active_loop.enqueue_subagent_notice(notice) if @active_loop.respond_to?(:enqueue_subagent_notice)
|
|
359
|
-
@subagent_notices_mutex&.synchronize { @subagent_notices << line }
|
|
360
|
-
else
|
|
361
|
-
inject_subagent_notice_into_conversation_history!(notice)
|
|
362
|
-
if @terminal_guard
|
|
363
|
-
@terminal_guard.print_safe_notice(line)
|
|
364
|
-
else
|
|
365
|
-
@output.puts "\n#{line}"
|
|
366
|
-
end
|
|
367
|
-
# Wakeloop fix 2026-10-09: an event landing inside an AUTONOMOUS
|
|
368
|
-
# turn's idle-path windows (before @active_loop is set, or in the
|
|
369
|
-
# ensure tail after it is cleared) must not arm a follow-up wake —
|
|
370
|
-
# that is the probabilistic residue of the chained-auto-turn bug.
|
|
371
|
-
# History injection and the printed line above still happen (no
|
|
372
|
-
# loss); only the synthetic Enter is withheld. A fresh event at a
|
|
373
|
-
# genuinely idle prompt (@autonomous_turn false) wakes as designed.
|
|
374
|
-
request_reactive_wakeup!(notice) unless @autonomous_turn
|
|
375
|
-
end
|
|
291
|
+
notice_router.route_subagent_notice(notice)
|
|
376
292
|
end
|
|
377
293
|
|
|
378
|
-
# Plan 109 Faz B: the reactive wake composition — vocabulary policy
|
|
379
|
-
# (WAKE_KINDS), kill-switch (subagents.reactive_wakeup config),
|
|
380
|
-
# state (PendingNoticeQueue), mechanism (TerminalGuard#safe_wakeup!).
|
|
381
|
-
# Every wake-worthy enqueue attempts the kick (no empty->non-empty
|
|
382
|
-
# coalescing): a kick refused earlier (user typing / paste
|
|
383
|
-
# collection) must retry on the next event, or the wake would wait
|
|
384
|
-
# for a manual Enter. TerminalGuard re-verifies emptiness under its
|
|
385
|
-
# monitor, so a typing user is never disturbed, and a surplus
|
|
386
|
-
# injected Enter degrades to the :empty noop. Runs on the kworker
|
|
387
|
-
# thread: queue push and the guard monitor only.
|
|
388
294
|
def request_reactive_wakeup!(notice)
|
|
389
|
-
|
|
390
|
-
return unless notice.is_a?(Hash) && WAKE_KINDS.include?(notice[:kind])
|
|
391
|
-
|
|
392
|
-
pending_notice_queue.enqueue(notice)
|
|
393
|
-
@terminal_guard&.safe_wakeup!
|
|
295
|
+
notice_router.request_reactive_wakeup!(notice)
|
|
394
296
|
end
|
|
395
297
|
|
|
396
298
|
def reactive_wakeup_enabled?
|
|
397
|
-
|
|
299
|
+
notice_router.reactive_wakeup_enabled?
|
|
398
300
|
end
|
|
399
301
|
|
|
400
|
-
# Eager init happens in wire_subagent_events! (before any
|
|
401
|
-
# subscription exists); the lazy fallback keeps bare Lifecycle test
|
|
402
|
-
# doubles working (SubagentNoticeInbox mold).
|
|
403
302
|
def pending_notice_queue
|
|
404
|
-
|
|
303
|
+
notice_router.pending_notice_queue
|
|
405
304
|
end
|
|
406
305
|
|
|
407
306
|
def pending_wake_notices?
|
|
408
|
-
|
|
307
|
+
notice_router.pending_wake_notices?
|
|
409
308
|
end
|
|
410
309
|
|
|
411
310
|
def drain_pending_wake_notices!
|
|
412
|
-
|
|
311
|
+
notice_router.drain_pending_wake_notices!
|
|
413
312
|
end
|
|
414
313
|
|
|
415
|
-
# Staleness rule: any real turn's context already includes the
|
|
416
|
-
# idle-injected notices in @conversation_history — a surviving
|
|
417
|
-
# pending wake would turn the next stray Enter into a redundant
|
|
418
|
-
# notice turn.
|
|
419
314
|
def clear_pending_wake_notices!
|
|
420
|
-
|
|
315
|
+
notice_router.clear_pending_wake_notices!
|
|
421
316
|
end
|
|
422
317
|
|
|
423
318
|
def inject_subagent_notice_into_conversation_history!(notice)
|
|
424
|
-
|
|
425
|
-
@conversation_history ||= []
|
|
426
|
-
Rubik::Prompt::ConversationRows.append_notice!(@conversation_history, xml_payload)
|
|
319
|
+
notice_router.inject_subagent_notice_into_conversation_history!(notice)
|
|
427
320
|
end
|
|
428
321
|
|
|
429
322
|
def flush_subagent_notices!
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
notices = @subagent_notices_mutex.synchronize do
|
|
433
|
-
list = @subagent_notices.dup
|
|
434
|
-
@subagent_notices.clear
|
|
435
|
-
list
|
|
436
|
-
end
|
|
437
|
-
return if notices.empty?
|
|
438
|
-
|
|
439
|
-
if @terminal_guard
|
|
440
|
-
notices.each { |m| @terminal_guard.print_safe_notice(m) }
|
|
441
|
-
else
|
|
442
|
-
@output.puts ""
|
|
443
|
-
notices.each { |m| @output.puts m }
|
|
444
|
-
end
|
|
323
|
+
notice_router.flush_subagent_notices!
|
|
445
324
|
end
|
|
446
325
|
|
|
447
|
-
# Session review B3 (turn-loss fix): Loop's drain runs at the TOP of each
|
|
448
|
-
# step, so notices landing during the final step stranded in the loop
|
|
449
|
-
# inbox at turn end — the user channel flushed a line, but the model
|
|
450
|
-
# channel never entered history and no wake was owed (Plan 109's
|
|
451
|
-
# documented "late-notice asymmetry" accepted the loss; a live session
|
|
452
|
-
# showed it costs a whole turn). Called from execute_free_text's ensure
|
|
453
|
-
# AFTER @active_loop = nil: the notices are injected into
|
|
454
|
-
# @conversation_history (visible to the next turn) and wake-worthy kinds
|
|
455
|
-
# arm the reactive wake, exactly like the idle-path branch of
|
|
456
|
-
# route_subagent_notice. Runs on the turn thread. Per-notice rescue is
|
|
457
|
-
# the ensure block's own contract ("cleanup must never mask the
|
|
458
|
-
# in-flight exception") — and a raising notice must not strand its
|
|
459
|
-
# queue-mates that drain_all already popped.
|
|
460
|
-
#
|
|
461
|
-
# arm_wake: false keeps the model-channel delivery but does NOT fire a
|
|
462
|
-
# synthetic Enter (wakeloop fix 2026-10-09): an INTERRUPTED turn and an
|
|
463
|
-
# AUTONOMOUS notice turn settle instead of re-arming — otherwise every
|
|
464
|
-
# stranded notice chains another auto-turn (the prompt never returns)
|
|
465
|
-
# and the cycle survives Ctrl+C.
|
|
466
326
|
def deliver_stranded_loop_notices!(loop_instance, arm_wake: true)
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
loop_instance.subagent_notice_inbox.drain_all.each do |notice|
|
|
470
|
-
inject_subagent_notice_into_conversation_history!(notice)
|
|
471
|
-
request_reactive_wakeup!(notice) if arm_wake
|
|
472
|
-
rescue StandardError => e
|
|
473
|
-
# Load-bearing visibility (wakeloop fix 2026-10-09): this delivery
|
|
474
|
-
# is the fix's "no loss" guarantee, so a dropped notice may not
|
|
475
|
-
# vanish behind the ENV-gated debug_warn. Unconditional, non-raising.
|
|
476
|
-
Rubik::Log.warn(:repl, "stranded notice delivery failed (#{notice[:kind].inspect}): " \
|
|
477
|
-
"#{e.class}: #{e.message}")
|
|
478
|
-
end
|
|
327
|
+
notice_router.deliver_stranded_loop_notices!(loop_instance, arm_wake: arm_wake)
|
|
479
328
|
end
|
|
480
329
|
|
|
481
330
|
def reap_dead_kernel_units!
|
|
@@ -488,12 +337,13 @@ module Rubik
|
|
|
488
337
|
# Audit 1: ENV["RUBIK_DEBUG"]-gated logging for intentionally swallowed
|
|
489
338
|
# exceptions (convention from config/store.rb). Never raises.
|
|
490
339
|
#
|
|
491
|
-
#
|
|
492
|
-
#
|
|
340
|
+
# Delegates to Platform.debug_warn (issue #452): the platform channel is
|
|
341
|
+
# the ONE home of RUBIK_DEBUG-gated debug warnings — Log.debug is gated
|
|
342
|
+
# by RUBIK_LOG_LEVEL instead, so reusing the sanctioned platform sink
|
|
343
|
+
# keeps this channel's exact semantics ([WARN] prefix, audible under
|
|
344
|
+
# $VERBOSE=nil, silent unless RUBIK_DEBUG is set, error-isolated).
|
|
493
345
|
def debug_warn(msg)
|
|
494
|
-
|
|
495
|
-
rescue StandardError
|
|
496
|
-
nil
|
|
346
|
+
Rubik::Platform.debug_warn(msg)
|
|
497
347
|
end
|
|
498
348
|
end
|
|
499
349
|
end
|