Package org.egothor.methodatlas
Class AiCacheStore
java.lang.Object
org.egothor.methodatlas.AiCacheStore
Reads and writes the unified AI result cache as a JSON Lines file: one
AiCacheEntry per line.
JSON Lines is chosen over a single JSON array so the file streams, appends cleanly, and a single corrupt line degrades to one lost cache entry rather than an unreadable file. The format is independent of the stable per-method scan CSV (which cannot carry credential verdicts or a prompt signature) and of the separate credential CSV; it is the sole carrier of cache state.
This class is a stateless, thread-safe utility holder.
- Since:
- 4.1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanlooksLikeJsonLines(Path file) Returnstrueiffileappears to be a unified JSON-Lines cache rather than a legacy scan CSV, by inspecting the first non-whitespace byte.static List<AiCacheEntry> Reads all cache entries from a JSON-Lines file.static voidwrite(Path file, Collection<AiCacheEntry> entries) Writes cache entries to a JSON-Lines file, one entry per line, overwriting any existing file.
-
Method Details
-
looksLikeJsonLines
Returnstrueiffileappears to be a unified JSON-Lines cache rather than a legacy scan CSV, by inspecting the first non-whitespace byte.- Parameters:
file- path to inspect; nevernull- Returns:
truewhen the first non-blank character is an opening brace- Throws:
IOException- if the file cannot be read
-
read
Reads all cache entries from a JSON-Lines file. Blank lines are ignored and a single unparseable line is skipped (logged atFINE) so a partially corrupt cache never aborts a scan.- Parameters:
file- path to the cache file; nevernull- Returns:
- the parsed entries in file order; never
null; may be empty - Throws:
IOException- if the file cannot be read
-
write
Writes cache entries to a JSON-Lines file, one entry per line, overwriting any existing file. Parent directories are created if absent.- Parameters:
file- destination path; nevernullentries- entries to write; nevernull- Throws:
IOException- if the file cannot be written
-