Class: RosettAi::Policy::ProtectedFiles

Inherits:
Object
  • Object
show all
Defined in:
lib/rosett_ai/policy/protected_files.rb

Overview

Manages the list of files that AI tools may read but not modify.

Protected files are compiled to engine-specific read-only annotations. Human override requires an explicit waiver in the policy configuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths: []) ⇒ ProtectedFiles

Returns a new instance of ProtectedFiles.

Parameters:

  • paths (Array<String>) (defaults to: [])

    relative file paths



16
17
18
# File 'lib/rosett_ai/policy/protected_files.rb', line 16

def initialize(paths: [])
  @paths = paths.map(&:freeze).freeze
end

Instance Attribute Details

#pathsObject (readonly)

Returns the value of attribute paths.



13
14
15
# File 'lib/rosett_ai/policy/protected_files.rb', line 13

def paths
  @paths
end

Instance Method Details

#empty?Boolean

Returns true if no files protected.

Returns:

  • (Boolean)

    true if no files protected



42
43
44
# File 'lib/rosett_ai/policy/protected_files.rb', line 42

def empty?
  @paths.empty?
end

#merge(other) ⇒ ProtectedFiles

Merges another protected files list (union of paths).

Parameters:

Returns:



32
33
34
# File 'lib/rosett_ai/policy/protected_files.rb', line 32

def merge(other)
  self.class.new(paths: (@paths + other.paths).uniq)
end

#protected?(path) ⇒ Boolean

Tests whether a file path is protected (read-only for AI).

Parameters:

  • path (String)

    relative file path

Returns:

  • (Boolean)

    true if the file is protected



24
25
26
# File 'lib/rosett_ai/policy/protected_files.rb', line 24

def protected?(path)
  @paths.include?(path)
end

#sizeInteger

Returns number of protected files.

Returns:

  • (Integer)

    number of protected files



37
38
39
# File 'lib/rosett_ai/policy/protected_files.rb', line 37

def size
  @paths.size
end