Class: RosettAi::Thor::Tasks::Provenance

Inherits:
Thor
  • Object
show all
Defined in:
lib/rosett_ai/thor/tasks/provenance.rb

Overview

Thor task for AI provenance tracking commands.

Author:

  • hugo

  • claude

Instance Method Summary collapse

Instance Method Details

#initvoid

This method returns an undefined value.

Initialize the provenance file in the current project.



35
36
37
38
39
40
41
42
# File 'lib/rosett_ai/thor/tasks/provenance.rb', line 35

def init
  store = build_store
  store.init
  say "Created #{store.path}", :green
rescue RosettAi::ProvenanceError => e
  say_status 'error', e.message, :red
  exit RosettAi::ExitCodes::GENERAL
end

#logvoid

This method returns an undefined value.

Display the provenance log.



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/rosett_ai/thor/tasks/provenance.rb', line 144

def log
  store = build_store
  entries = store.read['entries'].reverse

  entries = entries.select { |e| e['ai_role'] == options[:role] } if options[:role]

  if entries.empty?
    say 'No provenance entries found', :yellow
  else
    print_entries(entries)
  end
rescue RosettAi::ProvenanceError => e
  say_status 'error', e.message, :red
  exit RosettAi::ExitCodes::GENERAL
end

#show(commit = nil) ⇒ void

This method returns an undefined value.

Display detailed information for the named item.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/rosett_ai/thor/tasks/provenance.rb', line 101

def show(commit = nil)
  store = build_store
  entries = if options[:file]
              store.entries_for_file(options[: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.message, :red
  exit RosettAi::ExitCodes::GENERAL
end

#validateArray<Hash>

Validate the input and return any errors.

Returns:

  • (Array<Hash>)


62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/rosett_ai/thor/tasks/provenance.rb', line 62

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.message, :red
  exit RosettAi::ExitCodes::GENERAL
end