1.9 KiB
Architecture
John Slop keeps detection and replacement behavior in a library. Executables are thin adapters responsible for argument parsing, presentation, and process exit statuses.
The current flow is:
path -> input stream -> Document -> analysis -> Analysis + Finding
-> replacement planner -> TextEdit
The main modules have deliberately narrow responsibilities:
configowns the validated embedded replacement catalog and input limits;inputstreams files, directory entries, and archive members as documents;detectorproduces explainable findings and bounded confidence;replacementproduces non-overlapping edits without performing I/O;modelcontains presentation-neutral domain values;errorexposes typed input failures for library consumers;src/bincontains the detector and the formatter/LSP adapters.
All source spans are zero-based UTF-8 byte ranges into the exact analyzed source snapshot. Presentation layers will convert those canonical spans to terminal or UTF-16 LSP coordinates at their boundaries. Archive sources retain both their outer path and inner member identity.
Public facade
The crate root exposes four entry points:
load_configresolves the configuration embedded in the current build;read_inputsreturns a streaming iterator of per-document results;analyze_sourcereturns findings and evidence confidence for UTF-8 text;plan_replacementsreturns safe edits against the same source snapshot.
Configuration files and precedence layers are a later milestone. Keeping these operations behind the facade lets those layers evolve without duplicating logic across the three binaries.
See ADR 0001 for the foundational contracts and ADR 0002 for traversal and archive safety decisions.