From 30abb2f969f8d608584bed84b9062b201997dd75 Mon Sep 17 00:00:00 2001 From: Gergo Magyar Date: Thu, 4 Jun 2026 19:09:59 +0000 Subject: [PATCH] refactor(ingestion): remove dead worker-side ParsedFile extraction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After #2038 gated worker `ParsedFile` emission behind `!isScopeResolutionLanguage(language)`, and with all 16 SupportedLanguages registered in SCOPE_RESOLVERS, that gate was structurally always true — the worker already produced no ParsedFiles and scope-resolution re-extracts each file from source on the main thread (run.ts). Remove the now-dead machinery: - Drop both worker `extractParsedFile` call-sites (tree-sitter processFileGroup + the standalone-provider branch) and the `result.parsedFiles.push`. The standalone branch keeps fileCount/onFileProcessed per file. `result.parsedFiles` stays declared but empty (field removal deferred). - Remove the now-orphaned `scopeSourceKind` var + `ScopeCaptureSourceKind`/`extractParsedFile`/`isScopeResolutionLanguage` imports. - Delete the consumerless `migrated-languages.ts` (isScopeResolutionLanguage + SCOPE_RESOLUTION_LANGUAGES) and its drift-guard test — parse-worker was their only importer. Also improves AGENTS.md "shared ingestion code must not name languages" compliance. `extractParsedFile` and the scope-extractor-bridge stay (scope-resolution/run.ts + Vue resolver use them). Behavior-preserving: worker-sequential-parity passes before and after; tsc/eslint clean; no baseline/golden drift. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../pipeline/migrated-languages.ts | 32 --------- .../core/ingestion/workers/parse-worker.ts | 69 ++++--------------- .../migrated-languages.test.ts | 28 -------- 3 files changed, 12 insertions(+), 117 deletions(-) delete mode 100644 gitnexus/src/core/ingestion/scope-resolution/pipeline/migrated-languages.ts delete mode 100644 gitnexus/test/unit/scope-resolution/migrated-languages.test.ts diff --git a/gitnexus/src/core/ingestion/scope-resolution/pipeline/migrated-languages.ts b/gitnexus/src/core/ingestion/scope-resolution/pipeline/migrated-languages.ts deleted file mode 100644 index 82c714b3a..000000000 --- a/gitnexus/src/core/ingestion/scope-resolution/pipeline/migrated-languages.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Languages that resolve via the scope-resolution pipeline (RFC #909 Ring 3). - * - * Kept free of `ScopeResolver` imports so worker threads can gate - * `ParsedFile` emission without pulling in resolver implementations. - * Keep in sync with `SCOPE_RESOLVERS` in `registry.ts`. - */ - -import { SupportedLanguages } from 'gitnexus-shared'; - -export const SCOPE_RESOLUTION_LANGUAGES: ReadonlySet = new Set([ - SupportedLanguages.Python, - SupportedLanguages.CSharp, - SupportedLanguages.TypeScript, - SupportedLanguages.Go, - SupportedLanguages.Java, - SupportedLanguages.C, - SupportedLanguages.CPlusPlus, - SupportedLanguages.PHP, - SupportedLanguages.Rust, - SupportedLanguages.JavaScript, - SupportedLanguages.Kotlin, - SupportedLanguages.Ruby, - SupportedLanguages.Cobol, - SupportedLanguages.Swift, - SupportedLanguages.Dart, - SupportedLanguages.Vue, -]); - -export const isScopeResolutionLanguage = ( - lang: SupportedLanguages | null, -): lang is SupportedLanguages => lang !== null && SCOPE_RESOLUTION_LANGUAGES.has(lang); diff --git a/gitnexus/src/core/ingestion/workers/parse-worker.ts b/gitnexus/src/core/ingestion/workers/parse-worker.ts index 6ce8c20bb..565691986 100644 --- a/gitnexus/src/core/ingestion/workers/parse-worker.ts +++ b/gitnexus/src/core/ingestion/workers/parse-worker.ts @@ -96,8 +96,6 @@ import { import { extractTemplateArguments, templateArgumentsIdTag } from '../utils/template-arguments.js'; import type { LanguageProvider } from '../language-provider.js'; import type { ParsedFile } from 'gitnexus-shared'; -import { extractParsedFile, type ScopeCaptureSourceKind } from '../scope-extractor-bridge.js'; -import { isScopeResolutionLanguage } from '../scope-resolution/pipeline/migrated-languages.js'; import { extractLaravelRoutes, type ExtractedRoute } from '../route-extractors/laravel.js'; import { logger } from '../../logger.js'; @@ -835,38 +833,14 @@ const processBatch = ( const queryString = provider.treeSitterQueries; if (!queryString) { // Standalone providers (regex-based, no tree-sitter) that implement - // emitScopeCaptures feed into the scope-resolution pipeline via - // extractParsedFile directly — no tree-sitter involved. + // emitScopeCaptures resolve via the scope-resolution pipeline, which + // re-extracts from source on the main thread. if (provider.emitScopeCaptures) { - for (const file of langFiles) { - // #1983: skip building the ParsedFile for registry-primary - // (scope-resolution) languages — the scope-resolution phase - // re-extracts from source on the main thread, so the worker copy is - // unused work + retained RAM. COBOL is a standalone provider that is - // in SCOPE_RESOLUTION_LANGUAGES; its graph nodes come from cobolPhase, - // not from this ParsedFile, so gating here is safe. - const parsedFile = isScopeResolutionLanguage(language) - ? undefined - : extractParsedFile( - provider, - file.content, - file.path, - (message) => { - if (parentPort) { - parentPort.postMessage({ type: 'warning', message }); - } else { - logger.warn(message); - } - }, - undefined, // no cachedTree for standalone providers - ); - if (parsedFile !== undefined) { - result.parsedFiles.push(parsedFile); - } - // fileCount / progress fire per file regardless of whether a - // ParsedFile was produced — matching the tree-sitter branch (which - // increments fileCount outside the parsedFile gate). Otherwise gated - // COBOL files would vanish from worker progress counts. + // The worker no longer builds `ParsedFile`s for standalone providers + // either — scope-resolution re-extracts on the main thread, and for + // standalone COBOL the graph nodes come from cobolPhase, not this + // artifact (#1983). Count one unit of progress per file, as before. + for (let i = 0; i < langFiles.length; i++) { result.fileCount++; onFileProcessed?.(); } @@ -1107,14 +1081,12 @@ const processFileGroup = ( // Vue SFC preprocessing: extract