Class: KairosMcp::ActionLog

Inherits:
Object
  • Object
show all
Defined in:
lib/kairos_mcp/action_log.rb

Overview

ActionLog: Records actions for audit trail

This class has been refactored to use the Storage backend abstraction. By default, it uses FileBackend (file-based storage). When SQLite is enabled, it uses SqliteBackend.

Class Method Summary collapse

Class Method Details

.clear!Boolean

Clear all action logs

Returns:

  • (Boolean)

    Success status



45
46
47
# File 'lib/kairos_mcp/action_log.rb', line 45

def clear!
  storage_backend.clear_action_log!
end

.history(limit: 50) ⇒ Array<Hash>

Get action history

Parameters:

  • limit (Integer) (defaults to: 50)

    Maximum number of entries to return

Returns:

  • (Array<Hash>)

    Recent action log entries



38
39
40
# File 'lib/kairos_mcp/action_log.rb', line 38

def history(limit: 50)
  storage_backend.action_history(limit: limit)
end

.record(action:, skill_id: nil, details: nil) ⇒ Boolean

Record an action to the log

Parameters:

  • action (String)

    The action performed

  • skill_id (String, nil) (defaults to: nil)

    The skill ID involved

  • details (Hash, nil) (defaults to: nil)

    Additional details

Returns:

  • (Boolean)

    Success status



23
24
25
26
27
28
29
30
31
32
# File 'lib/kairos_mcp/action_log.rb', line 23

def record(action:, skill_id: nil, details: nil)
  entry = {
    timestamp: Time.now.iso8601,
    action: action,
    skill_id: skill_id,
    details: details
  }

  storage_backend.record_action(entry)
end

.reset_backend!Object

Reset the storage backend (useful for testing)



56
57
58
# File 'lib/kairos_mcp/action_log.rb', line 56

def reset_backend!
  @storage_backend = nil
end

.storage_backend=(backend) ⇒ Object

Set a custom storage backend (useful for testing or dependency injection)

Parameters:



62
63
64
# File 'lib/kairos_mcp/action_log.rb', line 62

def storage_backend=(backend)
  @storage_backend = backend
end

.storage_typeSymbol

Get the storage backend type

Returns:

  • (Symbol)

    :file or :sqlite



51
52
53
# File 'lib/kairos_mcp/action_log.rb', line 51

def storage_type
  storage_backend.backend_type
end