Class: RosettAi::Provenance::Entry
- Inherits:
-
Object
- Object
- RosettAi::Provenance::Entry
- Defined in:
- lib/rosett_ai/provenance/entry.rb
Overview
A single provenance entry recording AI involvement in a commit.
Each entry captures the commit SHA, contributor identity, AI tool used, the AI's role, and which files were involved.
Constant Summary collapse
- ALLOWED_ROLES =
[ 'AI-Generated-By', 'AI-Co-Author', 'AI-Assisted-By', 'AI-Reviewed-By' ].freeze
Instance Attribute Summary collapse
-
#ai_role ⇒ Object
readonly
Returns the value of attribute ai_role.
-
#ai_tool ⇒ Object
readonly
Returns the value of attribute ai_tool.
-
#commit ⇒ Object
readonly
Returns the value of attribute commit.
-
#contributor ⇒ Object
readonly
Returns the value of attribute contributor.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(commit:, contributor:, ai_tool:, ai_role:, files: [], timestamp: nil) ⇒ Entry
constructor
rubocop:disable Metrics/ParameterLists -- provenance entry requires all fields.
-
#to_h ⇒ Hash
Serializable representation for YAML output.
Constructor Details
#initialize(commit:, contributor:, ai_tool:, ai_role:, files: [], timestamp: nil) ⇒ Entry
rubocop:disable Metrics/ParameterLists -- provenance entry requires all fields
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rosett_ai/provenance/entry.rb', line 29 def initialize(commit:, contributor:, ai_tool:, ai_role:, files: [], timestamp: nil) validate_role!(ai_role) @commit = commit.freeze @contributor = contributor.freeze @ai_tool = ai_tool.freeze @ai_role = ai_role.freeze @files = files.freeze @timestamp = ( || Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')).freeze end |
Instance Attribute Details
#ai_role ⇒ Object (readonly)
Returns the value of attribute ai_role.
20 21 22 |
# File 'lib/rosett_ai/provenance/entry.rb', line 20 def ai_role @ai_role end |
#ai_tool ⇒ Object (readonly)
Returns the value of attribute ai_tool.
20 21 22 |
# File 'lib/rosett_ai/provenance/entry.rb', line 20 def ai_tool @ai_tool end |
#commit ⇒ Object (readonly)
Returns the value of attribute commit.
20 21 22 |
# File 'lib/rosett_ai/provenance/entry.rb', line 20 def commit @commit end |
#contributor ⇒ Object (readonly)
Returns the value of attribute contributor.
20 21 22 |
# File 'lib/rosett_ai/provenance/entry.rb', line 20 def contributor @contributor end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
20 21 22 |
# File 'lib/rosett_ai/provenance/entry.rb', line 20 def files @files end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
20 21 22 |
# File 'lib/rosett_ai/provenance/entry.rb', line 20 def @timestamp end |
Instance Method Details
#to_h ⇒ Hash
Returns serializable representation for YAML output.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rosett_ai/provenance/entry.rb', line 42 def to_h { 'commit' => @commit, 'timestamp' => @timestamp, 'contributor' => @contributor, 'ai_tool' => @ai_tool, 'ai_role' => @ai_role, 'files' => @files.map { |file| file.is_a?(Hash) ? file : file.to_h } } end |