feat(engine): persisted FQN index schema foundation (PR-01)#719
Open
shivasurya wants to merge 1 commit into
Open
feat(engine): persisted FQN index schema foundation (PR-01)#719shivasurya wants to merge 1 commit into
shivasurya wants to merge 1 commit into
Conversation
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. This report is generated by SafeDep Github App |
Pathfinder Report✅ No security findings on the changed files. This pull request is clean. Powered by Code Pathfinder. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #719 +/- ##
==========================================
+ Coverage 85.47% 85.49% +0.02%
==========================================
Files 192 195 +3
Lines 27523 27605 +82
==========================================
+ Hits 23524 23600 +76
- Misses 3107 3113 +6
Partials 892 892 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
edf1657 to
db99dae
Compare
Extend the experimental Go-only analysis cache into a language-agnostic on-disk index that later phases populate and query. This is the Phase 0 foundation of the rule-authoring toolchain; it ships no new query surface yet (that lands in PR-04). - Add fqn_index and call_sites tables (per tech-spec Section 2.1) plus their indices, alongside the existing Go cache tables, via a new schema.go. - Add a global schema_version stamp and an engine_version stamp in meta, with open-time auto-rebuild on mismatch. An absent stamp (a DB written by an older binary) is upgraded in place, not wiped, so warm Go caches survive the first upgrade. The engine version is only compared when known, so an auxiliary command cannot clobber another command's stamp. - The open path is two clear steps: applySchema (idempotent DDL) then reconcileVersions (rebuild/wipe decision + stamp), which also makes the invalidation paths directly testable. - ResolveIndexPath: default $HOME/.codepathfinder/<project-hash>.sqlite, --index-path override, CODEPATHFINDER_INDEX_PATH env var, parent dir created for every resolved path. Hash is the first 16 hex chars of SHA-256 over the cleaned absolute project root, so branches share one index. - scan: --index-path and --rebuild-index flags wired through; the resolved index path is logged at debug verbosity. The existing per-table version mechanism, Go callgraph cache tables, and scan output are unchanged. Added-code line coverage is ~95% (schema.go and metadata.go at 100%, index_path.go at 96%), with SQL-error paths exercised via injection (closed DB, dropped tables, name collisions). The handful of remaining lines are defensive error returns on a freshly opened DB. Behaviour verified end-to-end against a Go project: fresh create, warm reuse, rebuild, and engine-upgrade auto-rebuild. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
db99dae to
7926bf4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Stack: PR-01 of 14 (Rule Authoring Toolchain, Phase 0). First PR in the stack; nothing depends on it yet upstream.
What
Generalise the experimental Go-only SQLite analysis cache into a language-agnostic, persisted FQN index that later PRs populate (
fqn_indexin PR-02,call_sitesin PR-03) and query (pathfinder fqnin PR-04). No new user-facing query surface ships here; this is the schema + location + versioning foundation.Changes
schema.go(new):fqn_indexandcall_sitestables plus their indices (per tech-spec Section 2.1), created idempotently alongside the existing Go cache tables.applySchema/wipeDataTableshelpers.metadata.go(new):metakey/value accessors with a real "missing key" sentinel kept distinct from SQL errors, so an absent stamp is never confused with a backend failure.index_path.go(new): default location moves out of the project tree to$HOME/.codepathfinder/<project-hash>.sqlite(16 hex chars of SHA-256 over the cleaned absolute root, so branches share one index).--index-pathoverride andCODEPATHFINDER_INDEX_PATHenv var; the parent directory is created for every resolved path.analysis_cache.go: options-based constructor (OpenAnalysisCacheWithOptions), globalschema_version+engine_versionstamps, and open-time auto-rebuild on mismatch or--rebuild-index. An absent stamp (a DB written by an older binary) is upgraded in place rather than wiped, so existing warm Go caches survive the first upgrade. Engine version is only compared when known, so an auxiliary command cannot clobber another command's stamp.scan.go:--index-pathand--rebuild-indexflags; the resolved index path is logged at debug verbosity.OpenAnalysisCache(projectRoot)is retained as a thin wrapper so every existing caller and test keeps compiling. The per-table version mechanism, Go callgraph cache tables, and scan output are unchanged.Reconciliations vs the spec's illustrative code
metatable instead of introducing a separatemetadatatable (renaming would orphan existing DBs for no benefit).!= current), so existing caches upgrade gracefully instead of being wiped on the first run of the new binary.Verification
gradle buildGoclean;go test ./...green;golangci-lint runreports0 issues.schema.goandmetadata.goat 100% line coverage.--rebuild-indexrebuilds; an engine-version bump triggers[cache] rebuilding index: engine 1.0.0 -> 2.1.1and re-stamps.Note: the repo
lintGogradle task chainslintPython, which is red onmaindue to pre-existing black formatting in threepython-sdk/files. This PR touches zero Python files.🤖 Generated with Claude Code