Class: KairosMcp::Tools::FormalizationHistory
- Inherits:
-
BaseTool
- Object
- BaseTool
- KairosMcp::Tools::FormalizationHistory
show all
- Defined in:
- lib/kairos_mcp/tools/formalization_history.rb
Instance Method Summary
collapse
Methods inherited from BaseTool
#initialize, #invoke_tool, #to_full_schema, #to_schema
Instance Method Details
#call(arguments) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/kairos_mcp/tools/formalization_history.rb', line 65
def call(arguments)
skill_id_filter = arguments['skill_id']
category_filter = arguments['category']
limit = (arguments['limit'] || 20).to_i
chain = KairosChain::Chain.new
decisions = []
chain.chain.each do |block|
next if block.index == 0
block.data.each do |data_item|
parsed = parse_decision(data_item)
next unless parsed
next if skill_id_filter && parsed[:skill_id] != skill_id_filter
next if category_filter && parsed[:formalization_category].to_s != category_filter
decisions << parsed.merge(block_index: block.index)
end
end
decisions.sort_by! { |d| d[:timestamp] || '' }.reverse!
decisions = decisions.first(limit)
if decisions.empty?
filters = []
filters << "skill_id=#{skill_id_filter}" if skill_id_filter
filters << "category=#{category_filter}" if category_filter
filter_msg = filters.empty? ? "" : " (filters: #{filters.join(', ')})"
return text_content("No formalization decisions found#{filter_msg}.")
end
output = "## Formalization Decisions (#{decisions.size})\n\n"
decisions.each_with_index do |d, i|
output += "### #{i + 1}. #{d[:skill_id]} — #{d[:result]}\n"
output += "- **Block**: ##{d[:block_index]}\n"
output += "- **Version**: #{d[:skill_version]}\n"
output += "- **Category**: #{d[:formalization_category]}\n"
output += "- **Source**: #{truncate(d[:source_text].to_s, 80)}\n"
output += "- **Rationale**: #{d[:rationale]}\n"
output += "- **Decided by**: #{d[:decided_by]}\n"
output += "- **Timestamp**: #{d[:timestamp]}\n"
output += "\n"
end
formalized_count = decisions.count { |d| d[:result].to_s == 'formalized' }
not_formalized_count = decisions.count { |d| d[:result].to_s == 'not_formalized' }
output += "---\n"
output += "**Summary**: #{formalized_count} formalized, #{not_formalized_count} not formalized\n"
text_content(output)
end
|
#category ⇒ Object
16
17
18
|
# File 'lib/kairos_mcp/tools/formalization_history.rb', line 16
def category
:chain
end
|
#description ⇒ Object
12
13
14
|
# File 'lib/kairos_mcp/tools/formalization_history.rb', line 12
def description
'View accumulated formalization decisions from the blockchain. Filter by skill_id or formalization_category to find patterns.'
end
|
#examples ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/kairos_mcp/tools/formalization_history.rb', line 24
def examples
[
{
title: 'View all formalization decisions',
code: 'formalization_history()'
},
{
title: 'Filter by skill',
code: 'formalization_history(skill_id: "core_safety")'
},
{
title: 'Filter by category',
code: 'formalization_history(category: "invariant")'
}
]
end
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/kairos_mcp/tools/formalization_history.rb', line 45
def input_schema
{
type: 'object',
properties: {
skill_id: {
type: 'string',
description: 'Filter by skill ID (optional)'
},
category: {
type: 'string',
description: 'Filter by formalization category: invariant, rule, guideline, policy, philosophy (optional)'
},
limit: {
type: 'integer',
description: 'Maximum number of decisions to return (default: 20)'
}
}
}
end
|
#name ⇒ Object
8
9
10
|
# File 'lib/kairos_mcp/tools/formalization_history.rb', line 8
def name
'formalization_history'
end
|
41
42
43
|
# File 'lib/kairos_mcp/tools/formalization_history.rb', line 41
def related_tools
%w[formalization_record skills_dsl_get chain_history]
end
|
20
21
22
|
# File 'lib/kairos_mcp/tools/formalization_history.rb', line 20
def usecase_tags
%w[formalization history decisions patterns audit provenance]
end
|