Expand description
Incremental file reparse — used by mati reparse, edit-hook, and the MCP
server socket handler.
Steps:
- Read file from disk. Missing → add FileDeleted staleness signal, return.
- Detect language, construct WalkedFile, run parse_file().
- Parse failure → log warning, return Ok (graceful degradation P9).
- Fetch existing
file:<path>record. - No record → create Layer 0 stub, persist, return.
- Deserialize record.payload as FileRecord, compare structural fields.
- Nothing changed → return early (no write).
- Merge new analysis, preserve: purpose, gotcha_keys, decision_keys, change_frequency, last_author, is_hotspot.
- Apply staleness + cascade to linked gotchas (M-12-C).
- Write back.
Not recomputed here: Co-change cluster index. Clusters depend on
CoChanges edges which only change when mati init re-mines git history
after new commits. Incremental file edits do not affect cluster membership.
Functions§
- compute_
diff - Compute the structural diff between an old FileRecord and new analysis.
- reparse_
impl - Re-parse a single file and update its store record in place.
- reparse_
staged - Compute the reparse result without persisting. Returns the key and updated
Record to write, or
Noneif no write is needed (file missing, parse failure, or no structural changes).