Class: RosettAi::Provenance::Entry

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(commit:, contributor:, ai_tool:, ai_role:, files: [], timestamp: nil) ⇒ Entry

rubocop:disable Metrics/ParameterLists -- provenance entry requires all fields

Parameters:

  • commit (String)

    git commit SHA

  • contributor (String)

    contributor name and email

  • ai_tool (String)

    AI tool identifier (e.g. "Claude Opus 4.6 (Anthropic)")

  • ai_role (String)
  • files (Array<Hash>) (defaults to: [])

    file-level source references

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

    ISO 8601 timestamp (defaults to now)



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 = (timestamp || Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')).freeze
end

Instance Attribute Details

#ai_roleObject (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_toolObject (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

#commitObject (readonly)

Returns the value of attribute commit.



20
21
22
# File 'lib/rosett_ai/provenance/entry.rb', line 20

def commit
  @commit
end

#contributorObject (readonly)

Returns the value of attribute contributor.



20
21
22
# File 'lib/rosett_ai/provenance/entry.rb', line 20

def contributor
  @contributor
end

#filesObject (readonly)

Returns the value of attribute files.



20
21
22
# File 'lib/rosett_ai/provenance/entry.rb', line 20

def files
  @files
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



20
21
22
# File 'lib/rosett_ai/provenance/entry.rb', line 20

def timestamp
  @timestamp
end

Instance Method Details

#to_hHash

Returns serializable representation for YAML output.

Returns:

  • (Hash)

    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