mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-20 00:11:37 +00:00
* feat(cobol): migrate COBOL to scope-based resolution (regex provider) Migrate COBOL to scope-based registry resolution, validating the parse-source-agnostic contract — COBOL uses regex, not tree-sitter, but implements the same LanguageProvider interface via emitScopeCaptures. Phase 1-5 complete per #941 DoD. New files: languages/cobol/captures.ts — emitScopeCaptures wrapping regex tagger languages/cobol/interpret.ts — import/type-binding/receiver hooks languages/cobol/index.ts — barrel export languages/cobol/scope-resolver.ts — ScopeResolver wiring (9 fields, 3 toggles) Modified files: languages/cobol.ts — wire 4 scope-resolution hooks registry.ts — register cobolScopeResolver registry-primary-flag.ts — document REGISTRY_PRIMARY_COBOL Fixtures: 17 fixture files, 30 test cases across 11 required classes test/integration/resolvers/cobol-scope.test.ts Tests: 24/24 pass (default + REGISTRY_PRIMARY_COBOL=0) tsc: zero cobol-specific errors Shadow mode (GITNEXUS_SHADOW_MODE=1): zero crashes Regex perf: 10K-line file in 408ms (threshold: 2000ms) NOT added to MIGRATED_LANGUAGES — REGISTRY_PRIMARY_COBOL env var only. * chore(cobol): add COBOL to MIGRATED_LANGUAGES * fix(cobol): revert MIGRATED_LANGUAGES flip, fix JSDoc dup, fix arityCompatibility * fix(standalone): wire standalone providers into scope-extractor for registry-primary (COBOL Ring 3 flip) - Gate cobolPhase with isRegistryPrimary() guard to prevent double emission - Wire standalone providers (parseStrategy !== 'tree-sitter') with emitScopeCaptures into parse-worker via extractParsedFile bridge - Add COBOL to MIGRATED_LANGUAGES in registry-primary-flag.ts - Fix Module scope range in captures.ts to use full program bounds (was just PROGRAM-ID line, causing scope containment failures) - Update cobol.test.ts grand totals to be mode-aware - Wrap legacy exact-count assertions in if (!isPrimary) - Fix cobol-scope.test.ts fixture path to use __dirname (was process.cwd()) Tests: REGISTRY_PRIMARY_COBOL=0: 83/83 pass (59 legacy + 24 capture) REGISTRY_PRIMARY_COBOL=1: 28/28 pass (4 mode-aware + 24 capture) * test(cobol): restore original test assertions, add mode-aware describe blocks alongside - Remove if (!isPrimary) wrapper from legacy assertions - Keep ALL 59 original tests intact and running unconditionally - Add new 'scope-resolution mode' describe block alongside legacy tests - New block uses isPrimary to check for scope-resolution capture output - Legacy tests run against cobolPhase output (skipGraphPhases=true) - Mode-aware tests validate standalone provider wiring in registry-primary mode * fix(test): use result.graph instead of result.parsedFiles in scope-mode test - PipelineResult has no parsedFiles field; use graph.nodes instead - Use toBe strict equality (not.toBeNull()) per review feedback - Object.keys for node count as suggested by reviewer * test(cobol): add COBOL pipeline benchmark following PHP benchmark structure - Generate synthetic COBOL codebases at 100/250/500 file scales - Each file has 1 PROGRAM-ID, N paragraphs, cross-file CALLs, COPY books - Measures wall-clock time, peak heap, node/edge counts - SkipIf(!GITNEXUS_BENCH) — run with GITNEXUS_BENCH=1 - Prints table with scaling ratios and linearity assertions * fix(bench): remove COPY from paragraphs, add REGISTRY_PRIMARY_COBOL note - COPY statements belong only in DATA DIVISION (already present there) - Revert copyLine inside paragraph blocks to idiomatic COBOL - Add header note about =1 mode producing ~0 node/edge counts * fix(bench): restore COPY in paragraphs for preprocessing stress - COPY in paragraph blocks exercises the preprocessor expansion path more heavily than DATA DIVISION only placement. * fix(bench): constant 3 paragraphs per program, add 1000-files scale, relax threshold to 4x - Fixed paragraphsPerProgram to constant 3 for consistent scaling - Added 1000-file scale to benchmark - Raised assertion threshold to 4x to accommodate 100-250 step * fix: skip standalone providers in scope-resolution phase when registry-primary scopeResolutionPhase was reading all COBOL files from disk and running scope-resolution for standalone providers that don't emit graph edges yet. Added a guard: if provider.languageProvider.parseStrategy === 'standalone', skip it entirely. Saves 68s at 1000 files in =1 mode. * fix: remove COBOL isRegistryPrimary gate, suppress standalone IMPORTS double-emission - Remove the isRegistryPrimary gate in cobolPhase so it runs in both modes, keeping cobolPhase as the sole COBOL graph-edge producer. - Add a guard in runScopeResolution to skip emitImportEdges for standalone providers (parseStrategy === 'standalone'), preventing scope-resolution from duplicating IMPORTS edges already produced by cobolPhase. - Scope-resolution still runs for standalone providers (capture extraction, model finalization, reference resolution) — only edge emission is skipped. - Both modes: 60/60 cobol.test.ts, 24/24 cobol-scope.test.ts. * fix: 4 review fixes — dead code removal, memory cleanup, benchmark comment, standalone-bridge test 1. Remove dead standalone guard in run.ts (phase.ts:164 is canonical). 2. Filter standalone preExtractedByPath entries in phase.ts (memory leak). 3. Update benchmark comment: cobolPhase runs in both modes. 4. Add unit test proving extractParsedFile works for COBOL standalone provider. Revert PipelineResult.parsedFiles — not needed with unit test approach. * perf(cobol): memoize copybook preprocessing; make benchmark measure file-count scaling The COBOL pipeline benchmark reported superlinear (quadratic) scaling, but the pipeline itself is O(n) in file count. The superlinearity was a fixture artifact: every program COPYed all floor(fileCount/5) copybooks in WORKING-STORAGE, so emitted data-item nodes — and total work — grew O(n^2). Verified empirically: node count grew ~2x per file-doubling; with constant per-program fan-out it grows exactly 1x (linear), and 0/3 adversarial audits could refute the O(n) conclusion. - benchmark: each program now COPYs a constant 3 shared copybooks so the benchmark measures true file-count scaling. Add a deterministic node-ratio assertion that fails if the O(n^2) copy-all fan-out is reintroduced. - processor: memoize preprocessed copybook content per processCobol call so each copybook is preprocessed once, not once per COPY site (O(programs x copybooks) -> O(copybooks)). Safe: REPLACING is applied later by the expander on the cached pre-REPLACING content. Verified: 246 COBOL tests pass; benchmark scales linearly (node ratio 1.0); tsc clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Gergő Magyar <gergomagyar@icloud.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| fixtures | ||
| helpers | ||
| integration | ||
| unit | ||
| utils | ||