Module: OllamaAgent::State::TreeDigest

Defined in:
lib/ollama_agent/state/tree_digest.rb

Overview

Length-prefixed hashing for tree entries so adjacent path/content bytes cannot be confused across file boundaries (e.g. ‘lib/sample` + `.rbX` vs `lib/sample.rb` + `X`).

Class Method Summary collapse

Class Method Details

.append_entry(digest, relative_path, content) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/ollama_agent/state/tree_digest.rb', line 10

def append_entry(digest, relative_path, content)
  path = relative_path.to_s.b
  body = content.to_s.b
  digest.update([path.bytesize].pack("Q>"))
  digest.update(path)
  digest.update([body.bytesize].pack("Q>"))
  digest.update(body)
end