Skip to content

feat(consciousness): timer/autonomic integration and stall detection (BRO-457)#52

Merged
broomva merged 1 commit intomainfrom
feature/bro-457-timer-autonomic-stall
Apr 5, 2026
Merged

feat(consciousness): timer/autonomic integration and stall detection (BRO-457)#52
broomva merged 1 commit intomainfrom
feature/bro-457-timer-autonomic-stall

Conversation

@broomva
Copy link
Copy Markdown
Owner

@broomva broomva commented Apr 5, 2026

Summary

  • Add AutonomicSignal { ruling } variant to ConsciousnessEvent for receiving context-pressure rulings from the autonomic subsystem
  • Implement handle_autonomic_signal() that sets needs_compaction flag on Compress/Emergency rulings, which injects [Context pressure: compact] into the next agent cycle's system prompt
  • Add stall detection in run_agent_cycle: tracks events_emitted across iterations, breaks after 3 consecutive no-progress ticks, emits consciousness.stall_detected Custom event
  • Add stall_counter and needs_compaction fields to ConsciousnessState
  • Two new integration tests: stall_detection_breaks_stuck_loop and autonomic_signal_sets_compaction_flag

Test plan

  • cargo check -p arcand passes
  • cargo clippy -p arcand passes (zero warnings)
  • cargo test -p arcand passes (70 tests: 51 unit + 10 canonical API + 9 consciousness)
  • cargo test --workspace passes (full workspace)
  • New test stall_detection_breaks_stuck_loop verifies actor completes without hanging
  • New test autonomic_signal_sets_compaction_flag verifies signal processing without mode change

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added stall detection that automatically breaks execution loops when no progress is detected.
    • Introduced autonomic signals to trigger context optimization when needed.
    • System prompt now dynamically adapts based on context pressure.
  • Tests

    • Added integration tests for stall detection and signal handling.

@linear
Copy link
Copy Markdown

linear bot commented Apr 5, 2026

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 5, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR extends the consciousness actor with two new capabilities: an AutonomicSignal event for triggering compaction behavior, and a stall detection mechanism that monitors event emission in the agent execute loop. When stalls are detected, the system emits a custom event and breaks the cycle early. The compaction flag is conditionally appended to the system prompt when triggered.

Changes

Cohort / File(s) Summary
Stall Detection & Autonomic Signal Handling
crates/arcand/src/consciousness.rs
Added AutonomicSignal { ruling: String } event variant. Extended ConsciousnessState with stall_counter and needs_compaction fields. Implemented stall detection in agent execute loop by tracking events_emitted changes; if no change detected for 3 consecutive iterations, cycle breaks and emits a Custom external event. When needs_compaction is set, "[Context pressure: compact]" is appended to system prompt before calling tick_on_branch.
Feature Integration Tests
crates/arcand/tests/consciousness_test.rs
Added stall_detection_breaks_stuck_loop test verifying the actor returns to Idle after detecting and breaking a stall. Added autonomic_signal_sets_compaction_flag test sending AutonomicSignal events with "Compress" and "Breathe" rulings and verifying actor state remains Idle.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A consciousness awakens with a signal so clear,
When cycles grow sticky and nothing moves here,
Three ticks with no progress? Time to break free!
Compress the context, breathe naturally,
The rabbit detects what was once unseen. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the main changes: adding timer/autonomic integration and stall detection to the consciousness system, with clear reference to the tracking issue.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/bro-457-timer-autonomic-stall

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…(BRO-457)

Add AutonomicSignal event variant to the consciousness actor for receiving
context-pressure rulings (Compress/Emergency) from the autonomic subsystem.
When elevated pressure is detected, set a needs_compaction flag that injects
a "[Context pressure: compact]" hint into the next agent cycle's system prompt.

Add stall detection to run_agent_cycle: track events_emitted across iterations
and break the loop after 3 consecutive ticks with no progress, emitting a
consciousness.stall_detected Custom event for observability.

Two new integration tests: stall_detection_breaks_stuck_loop and
autonomic_signal_sets_compaction_flag.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@broomva broomva force-pushed the feature/bro-457-timer-autonomic-stall branch from 1920ef8 to 800f598 Compare April 5, 2026 02:16
@broomva broomva merged commit 2e54e27 into main Apr 5, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant