Class: Nexo::ReadTracker
- Inherits:
-
Object
- Object
- Nexo::ReadTracker
- Defined in:
- lib/nexo/read_tracker.rb
Overview
A tiny per-chat memory of which files an agent has read and at what last-modified time, so Tools::WriteFile can refuse to overwrite a file the model never read — or one that changed underneath it — within a session.
Built once per chat in Agent#chat and threaded into both Tools::ReadFile (which records) and Tools::WriteFile (which enforces). Scope is clobber safety within a session only: no versioning, no locking, no VCS semantics.
Instance Method Summary collapse
-
#initialize ⇒ ReadTracker
constructor
Starts an empty tracker (an internal
path => mtimemap). -
#read?(path) ⇒ Boolean
Whether
pathhas been read in this session. -
#record(path, mtime) ⇒ Object
Records that
pathwas read when it had modification timemtime. -
#recorded_mtime(path) ⇒ Object
The mtime recorded when
pathwas read, ornilif it was never read.
Constructor Details
#initialize ⇒ ReadTracker
Starts an empty tracker (an internal path => mtime map).
13 14 15 |
# File 'lib/nexo/read_tracker.rb', line 13 def initialize @mtimes = {} end |
Instance Method Details
#read?(path) ⇒ Boolean
Whether path has been read in this session.
23 24 25 |
# File 'lib/nexo/read_tracker.rb', line 23 def read?(path) @mtimes.key?(path) end |
#record(path, mtime) ⇒ Object
Records that path was read when it had modification time mtime.
18 19 20 |
# File 'lib/nexo/read_tracker.rb', line 18 def record(path, mtime) @mtimes[path] = mtime end |
#recorded_mtime(path) ⇒ Object
The mtime recorded when path was read, or nil if it was never read.
28 29 30 |
# File 'lib/nexo/read_tracker.rb', line 28 def recorded_mtime(path) @mtimes[path] end |