fix(pipeline): handle ALTER migrations and auto-init fingerprint registry#156
Open
tipich wants to merge 1 commit into
Open
fix(pipeline): handle ALTER migrations and auto-init fingerprint registry#156tipich wants to merge 1 commit into
tipich wants to merge 1 commit into
Conversation
…stry
Two unrelated but small gaps in /understand that show up on Laravel
projects, bundled to keep the noise down:
Gap 1 — ALTER migrations produce orphan nodes
file-analyzer.md only knew about CREATE-shape SQL migrations. A
Laravel `Schema::table('users', ...)` (and the equivalent Rails
`change_table` / Django `AddField`) emitted a bare file: node with
no migrates edge to the existing table: node it was modifying, so
the table picked up an orphan sibling on every ALTER. Added an
explicit ORM migrations section with CREATE vs ALTER guidance plus
two new rows in the Edge Signal Quick Reference table.
Gap 2 — buildFingerprintStore required hidden setup
SKILL.md Phase 7 step 2.5 documents a two-arg call:
const store = await buildFingerprintStore(root, paths);
…but the actual signature required a fully-initialized PluginRegistry
and a git commit hash, so callers crashed with
TypeError: Cannot read properties of undefined (reading 'analyzeFile')
at fingerprint.js:168. Made `registry` and `gitCommitHash` optional
and lazy: an empty/missing registry gets all built-in parsers plus
the tree-sitter plugin auto-registered (10 code languages, WASM
init awaited), and a missing commit hash is resolved via
`git rev-parse HEAD` in the project root (falls back to "unknown"
if not a git repo). Existing 4-arg callers are unaffected; the
function is now async to match the documented `await`.
Tests
- 3 new tests in fingerprint-autoinit.test.ts use the real
filesystem (no fs mock) to cover the zero-config contract, real
TS/Python structural extraction, and the "caller-provided registry
wins" path.
- All 673 core tests green. Pre-existing extract-structure.test.mjs
skill failure is on main and unrelated.
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.
Summary
Two small, unrelated gaps in
/understandthat both surface on Laravel projects. Bundled into one PR because the diff is tiny and the two fixes are independent — easy to back out either side.Gap 1 — ALTER migrations produce orphan
table:nodesagents/file-analyzer.mdonly described how to handle CREATE-shape SQL migrations. A LaravelSchema::table('users', ...)migration (and the equivalent Railschange_table/ DjangoAddField) emitted a barefile:node with nomigratesedge to the existingtable:node it was modifying. Each ALTER added an orphan sibling table node to the graph.Measured impact on one Aeropax (Laravel 13) regen: 8 orphan ALTER-migration
table:nodes after a full incremental pipeline pass.Fix: added an explicit ORM migration files section to the Non-code edge creation guidance, distinguishing CREATE shape (
Schema::create,create_table,CreateModel) from ALTER shape (Schema::table,change_table,AddField/RemoveField/AlterField). The ALTER case emits only themigratesedge to the existing table node — no duplicatetable:node. Also added two rows to the Edge Signal Quick Reference table for fast pattern matching.Gap 2 —
buildFingerprintStorerequired hidden setup the skill doc didn't mentionskills/understand/SKILL.mdPhase 7 step 2.5 documents:…but the actual signature was
(projectDir, filePaths, registry, gitCommitHash)— sync, with both extra args required. Following the doc gave:…because
registrywasundefined. Result:fingerprints.jsonsilently failed to regen on Phase 7, leaving the baseline stale.Fix: option (A) from the proposal — auto-init inside
buildFingerprintStore.registryandgitCommitHashare now optional.registryis missing OR empty, the function constructs one and registers all built-in non-code parsers (registerAllParsers) plus aTreeSitterPluginwithbuiltinLanguageConfigs(the 10 supported code languages, WASM grammars awaited).gitCommitHashis missing, the function shells out togit rev-parse HEADinprojectDir; falls back to\"unknown\"if not a git repo or git is unavailable.asyncto match the documentedawaitand to allow the tree-sitter WASM init. Callers that already pass a populated registry are untouched — auto-registration only fires on an empty registry.Updated SKILL.md to call out that the 2-argument form is the supported standalone path and that 3rd/4th args remain available for explicit-control / CI scenarios.
Test plan
pnpm --filter @understand-anything/core buildclean (no TS errors).pnpm --filter @understand-anything/core test— 673 tests, all green (previously 670; added 3 new infingerprint-autoinit.test.ts).fingerprint.test.tsmocksnode:fs, so the smoke test had to live separately). It covers:{ version: \"1.0.0\", files: { ... }, gitCommitHash: \"unknown\" }outside a git repo).function/classsignatures for both TypeScript and Python sample files (this is the direct regression test for theanalyzeFile undefinedcrash)./understandagainstC:\dev\aeropaxshould drop orphan ALTER-migration count from 8 → 0 and produce a freshfingerprints.json.Pre-existing failure
pnpm --filter @understand-anything/skill testhas one pre-existing failure inextract-structure.test.mjs(1 fail / 43 pass onmain; 1 fail / 44 pass on this branch). Verified onmain— unrelated to these changes.Out of scope
config()runtime-string orphans, 24 markdown→code document orphans, 268 legacy file orphans) — bigger investigations, separate tasks.skills/understand/frameworks/— the new guidance infile-analyzer.mdis framework-agnostic and covers Rails / Django / Laravel uniformly. A dedicatedlaravel.mdcan come later if it justifies its own prompt.