Entropic 2.14.3
Local-first agentic inference engine
Loading...
Searching...
No Matches
entropic::FileAccessTracker Class Reference

Tracks file read state for read-before-write enforcement. More...

#include <entropic/mcp/servers/filesystem.h>

Public Member Functions

void record_read (const std::string &session, const std::string &path, size_t hash)
 Record that session read a file.
 
bool was_read (const std::string &session, const std::string &path) const
 Check whether session has read a file.
 
bool release_session (const std::string &session)
 Forget every read session recorded (gh#158).
 
std::size_t session_count () const
 Sessions currently holding recorded reads.
 

Detailed Description

Tracks file read state for read-before-write enforcement.

gh#158 (v2.13.0), two passes. First LOCKED: one FilesystemServer serves every unbound session on a handle, and concurrent_sessions defaults true, so read_file and write_file / edit_file reached one map from several run threads at once. Then re-scoped PER SESSION: a shared map let session B overwrite a file only session A had read. Reads are now recorded and consulted under the calling session's key, and released with that session's conversation (release_session).

Version
2.13.0

Definition at line 42 of file filesystem.h.

Member Function Documentation

◆ record_read()

void entropic::FileAccessTracker::record_read ( const std::string &  session,
const std::string &  path,
size_t  hash 
)

Record that session read a file.

Record that a session read a file, with its content hash.

Parameters
sessionSession key the read belongs to ("" = default).
pathCanonical file path.
hashContent hash at time of read. @threadsafety Safe from any thread (gh#158).
Version
2.13.0

The tracker is what makes read-before-write enforceable: write_file and edit_file refuse an existing file with no recorded read.

gh#158 (v2.13.0): recorded under the READING session's key, so the read unlocks that session's writes and nobody else's; the map is locked because concurrent sessions record from several run threads.

Parameters
sessionSession key the read belongs to.
pathCanonical file path.
hashContent hash at time of read. @req REQ-MCP-021 @req REQ-LOOP-009
Version
2.13.0 [reviewed]

Definition at line 56 of file filesystem.cpp.

◆ release_session()

bool entropic::FileAccessTracker::release_session ( const std::string &  session)

Forget every read session recorded (gh#158).

Forget every read a session recorded (gh#158).

Parameters
sessionSession key.
Returns
true when the session had recorded reads. @threadsafety Safe from any thread.
Version
2.13.0

Called when the session's conversation ends — the model no longer holds the content it read, so a later write must read again.

Parameters
sessionSession key.
Returns
true when the session had recorded reads. @req REQ-MCP-021 @req REQ-LOOP-009
Version
2.13.0

Definition at line 98 of file filesystem.cpp.

◆ session_count()

std::size_t entropic::FileAccessTracker::session_count ( ) const

Sessions currently holding recorded reads.

Sessions currently holding recorded reads (gh#158).

Returns
Session count.
Version
2.13.0
Returns
Session count. @req REQ-LOOP-009
Version
2.13.0

Definition at line 108 of file filesystem.cpp.

◆ was_read()

bool entropic::FileAccessTracker::was_read ( const std::string &  session,
const std::string &  path 
) const

Check whether session has read a file.

Check whether a session has read a file.

Parameters
sessionSession key asking.
pathCanonical file path.
Returns
true only when THIS session recorded a read of path. @threadsafety Safe from any thread (gh#158).
Version
2.13.0

gh#158 (v2.13.0): consults ONLY session's reads. A lookup never creates an entry, so asking on behalf of a session that read nothing does not grow the map.

Parameters
sessionSession key asking.
pathCanonical file path.
Returns
true when this session recorded a read of this path, regardless of whether the content has since changed. @req REQ-MCP-021 @req REQ-LOOP-009
Version
2.13.0 [reviewed]

Definition at line 79 of file filesystem.cpp.


The documentation for this class was generated from the following files: