Class: KairosMcp::StateCommit::PendingChanges
- Inherits:
-
Object
- Object
- KairosMcp::StateCommit::PendingChanges
- Defined in:
- lib/kairos_mcp/state_commit/pending_changes.rb
Overview
PendingChanges: Tracks changes since last commit
This is a singleton-like class that accumulates changes and checks auto-commit trigger conditions.
Class Method Summary collapse
-
.add(layer:, action:, skill_id:, reason: nil, metadata: {}) ⇒ Object
Add a change to the pending list.
-
.all ⇒ Array<Hash>
Get all pending changes.
-
.by_action ⇒ Hash
Get changes grouped by action.
-
.by_layer ⇒ Hash
Get changes grouped by layer.
-
.check_trigger_conditions(config) ⇒ Hash
Check trigger conditions for auto-commit.
-
.clear! ⇒ Object
Clear all pending changes.
-
.count ⇒ Integer
Get pending changes count.
-
.includes_demotion? ⇒ Boolean
Check if there are any demotions.
-
.includes_l0_change? ⇒ Boolean
Check if there are any L0 changes.
-
.includes_promotion? ⇒ Boolean
Check if there are any promotions.
-
.l1_changes_count ⇒ Integer
Get L1 changes count.
-
.l2_changes_count ⇒ Integer
Get L2 changes count.
-
.summary ⇒ Hash
Get summary of pending changes.
-
.total_changes_count ⇒ Integer
Get total changes count.
Class Method Details
.add(layer:, action:, skill_id:, reason: nil, metadata: {}) ⇒ Object
Add a change to the pending list
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kairos_mcp/state_commit/pending_changes.rb', line 24 def add(layer:, action:, skill_id:, reason: nil, metadata: {}) @mutex.synchronize do @changes << { layer: layer.to_s, action: action.to_s, skill_id: skill_id.to_s, reason: reason, metadata: , timestamp: Time.now.iso8601 } end end |
.all ⇒ Array<Hash>
Get all pending changes
40 41 42 |
# File 'lib/kairos_mcp/state_commit/pending_changes.rb', line 40 def all @mutex.synchronize { @changes.dup } end |
.by_action ⇒ Hash
Get changes grouped by action
112 113 114 115 116 |
# File 'lib/kairos_mcp/state_commit/pending_changes.rb', line 112 def by_action @mutex.synchronize do @changes.group_by { |c| c[:action] } end end |
.by_layer ⇒ Hash
Get changes grouped by layer
103 104 105 106 107 |
# File 'lib/kairos_mcp/state_commit/pending_changes.rb', line 103 def by_layer @mutex.synchronize do @changes.group_by { |c| c[:layer] } end end |
.check_trigger_conditions(config) ⇒ Hash
Check trigger conditions for auto-commit
129 130 131 132 133 |
# File 'lib/kairos_mcp/state_commit/pending_changes.rb', line 129 def check_trigger_conditions(config) return { should_commit: false, trigger: nil } unless config @mutex.synchronize { _check_trigger_conditions(config) } end |
.clear! ⇒ Object
Clear all pending changes
52 53 54 |
# File 'lib/kairos_mcp/state_commit/pending_changes.rb', line 52 def clear! @mutex.synchronize { @changes = [] } end |
.count ⇒ Integer
Get pending changes count
47 48 49 |
# File 'lib/kairos_mcp/state_commit/pending_changes.rb', line 47 def count @mutex.synchronize { @changes.size } end |
.includes_demotion? ⇒ Boolean
Check if there are any demotions
73 74 75 |
# File 'lib/kairos_mcp/state_commit/pending_changes.rb', line 73 def includes_demotion? @mutex.synchronize { _includes_demotion? } end |
.includes_l0_change? ⇒ Boolean
Check if there are any L0 changes
59 60 61 |
# File 'lib/kairos_mcp/state_commit/pending_changes.rb', line 59 def includes_l0_change? @mutex.synchronize { _includes_l0_change? } end |
.includes_promotion? ⇒ Boolean
Check if there are any promotions
66 67 68 |
# File 'lib/kairos_mcp/state_commit/pending_changes.rb', line 66 def includes_promotion? @mutex.synchronize { _includes_promotion? } end |
.l1_changes_count ⇒ Integer
Get L1 changes count
80 81 82 |
# File 'lib/kairos_mcp/state_commit/pending_changes.rb', line 80 def l1_changes_count @mutex.synchronize { _l1_changes_count } end |
.l2_changes_count ⇒ Integer
Get L2 changes count
87 88 89 90 91 |
# File 'lib/kairos_mcp/state_commit/pending_changes.rb', line 87 def l2_changes_count @mutex.synchronize do @changes.count { |c| c[:layer] == 'L2' } end end |
.summary ⇒ Hash
Get summary of pending changes
121 122 123 |
# File 'lib/kairos_mcp/state_commit/pending_changes.rb', line 121 def summary @mutex.synchronize { _build_summary } end |
.total_changes_count ⇒ Integer
Get total changes count
96 97 98 |
# File 'lib/kairos_mcp/state_commit/pending_changes.rb', line 96 def total_changes_count count end |