Class: RosettAi::Thor::Tasks::Provenance
- Inherits:
-
Thor
- Object
- Thor
- RosettAi::Thor::Tasks::Provenance
- Defined in:
- lib/rosett_ai/thor/tasks/provenance.rb
Overview
Thor task for AI provenance tracking commands.
Instance Method Summary collapse
Instance Method Details
#init ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/rosett_ai/thor/tasks/provenance.rb', line 33 def init store = build_store store.init say "Created #{store.path}", :green rescue RosettAi::ProvenanceError => e say_status 'error', e., :red exit RosettAi::ExitCodes::GENERAL end |
#log ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/rosett_ai/thor/tasks/provenance.rb', line 136 def log store = build_store entries = store.read['entries'].reverse entries = entries.select { |e| e['ai_role'] == [:role] } if [:role] if entries.empty? say 'No provenance entries found', :yellow else print_entries(entries) end rescue RosettAi::ProvenanceError => e say_status 'error', e., :red exit RosettAi::ExitCodes::GENERAL end |
#show(commit = nil) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/rosett_ai/thor/tasks/provenance.rb', line 95 def show(commit = nil) store = build_store entries = if [:file] store.entries_for_file([:file]) elsif commit store.entries_for_commit(commit) else say_status 'error', 'Provide a commit SHA or --file path', :red exit RosettAi::ExitCodes::GENERAL end if entries.empty? say 'No provenance entries found', :yellow else print_entries(entries) end rescue RosettAi::ProvenanceError => e say_status 'error', e., :red exit RosettAi::ExitCodes::GENERAL end |
#validate ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/rosett_ai/thor/tasks/provenance.rb', line 58 def validate store = build_store data = store.read entry_count = data['entries'].size violations = store.verify_chain if violations.empty? say "#{entry_count} entries validated, hash chain intact", :green else violations.each { |v| say_status 'error', v, :red } exit RosettAi::ExitCodes::VALIDATION end rescue RosettAi::ProvenanceError => e say_status 'error', e., :red exit RosettAi::ExitCodes::GENERAL end |