feat(parser): reusable source-set framework#877
Conversation
|
This change is part of the following stack:
Change managed by git-spice. |
roborev: Combined Review (
|
2419b16 to
b2aa4b8
Compare
37dc43b to
f708cf2
Compare
roborev: Combined Review (
|
f708cf2 to
5c6be8e
Compare
roborev: Combined Review (
|
Introduce the SourceSet bases (JSONL, directory JSONL, single-file, multi-session container, sibling-metadata, SQLite fan-out), the functional with*() option set, the generic SourceSet provider/factory plumbing, and the virtual-path and source-identity helpers up front, so every provider migration constructs its source set through options instead of a struct literal.
SQLiteFanoutSourceSet had no production callers -- it was referenced only by its own definition and duplicated multiSessionContainerSourceSet. The package-level helpers it relied on (cleanJSONLRoots, addJSONLSource, sortJSONLSources, and friends) are defined and used elsewhere, so removing it orphans nothing.
… order pathIsUnderRoot took (path, root), reversing the root-first convention used by pathUnderRoot(root, candidate) and relUnder(dir, child). Its only caller already had root and path available, and pathUnderRoot has the same containment semantics (root==path is not "under"; rejects ".." escape; handles trailing separators via filepath.Clean). Drop the duplicate and repoint the caller so all containment checks share one root-first helper.
Providers whose transcript freshness depends on a sidecar file had no base-level hook: only the SiblingMetadataSourceSet wrapper handled companions, forcing a separate wrapper type instead of a plain option. Add withCompanionFiles(transcriptPath -> companions) so the JSONLSourceSet base folds companions into the three places they matter: their basenames join the watch-plan include globs, their size/mtime (and content when hashing is enabled) fold into the SourceFingerprint, and a changed companion path maps back to its owning transcript so a sidecar write re-parses the session. The wiring reuses the existing sibling-metadata helpers rather than adding a third independent sidecar mechanism.
writeSourceFile and the generic source-set tests were introduced by the qwenpaw migration but are framework-level helpers used by ~20 provider test files. Placing them on the source-set-framework branch lets every family branch build its tests.
The reusable source-set scaffolding (functional options, source-set constructors, and the generic source-set provider/factory) was unexported. Because providers don't consume it until higher branches in the stack, staticcheck's unused linter flagged ~62 of these symbols as dead at every mid-stack branch, and the always-run golangci-lint pre-commit hook failed on each such commit. Exporting the API makes the unused analyzer ignore them (it never reports exported identifiers), eliminating the spurious findings stack-wide with no import cycle.
5c6be8e to
0bf59bc
Compare
roborev: Combined Review (
|
filepath.Rel returns OS-native separators, so on Windows the JSONLSource RelPath came back with backslashes (nested\deleted.jsonl) while the rest of the parser keys, display paths, and tests use forward-slash relative paths. Normalize with filepath.ToSlash so RelPath is platform-stable; this is a no-op on Unix and fixes the Windows Go Test failure in TestJSONLSourceSetChangedPathClassifiesDeletedFiles.
roborev: Combined Review (
|
Adds the reusable source-set bases and functional options that concrete providers compose for discovery, lookup, fingerprinting, and changed-path classification. The framework symbols are exported so they can be consumed across the package without tripping unused-symbol lint at intermediate branches in the stack.
Also adds the
WithCompanionFilesoption, unifies the path-under-root helper onto a single root-first signature, and removes the deadSQLiteFanoutSourceSet.Where to look:
internal/parser/jsonl_source_set.go,single_file_source_set.go, and the source-set base types.