mirror of
https://github.com/giancarloerra/socraticode.git
synced 2026-07-03 14:05:21 +02:00
e6ce32710a
Resolves #43. On Linux/Node combinations where one ast-grep grammar package's prebuilt parser binary is missing for the host architecture, the v1.8.3 loader silently failed to register every dynamic grammar in the batch, not just the broken one. registerDynamicLanguage iterates and accesses each module's lazy libraryPath getter; one throwing getter aborts the call atomically and zero grammars end up registered. Fix: pre-validate each grammar's libraryPath getter inside the per- grammar try/catch so a missing prebuild is contained to that grammar. Build the batch object with only the survivors and make ONE atomic registerDynamicLanguage call. Standard environments are unaffected because all grammars pass pre-validation. Affected environments lose only the unloadable grammar, the rest register cleanly. Also captures the actual error reason (the previous empty `catch {}` discarded it), bumps symbol- and import-extraction failure logs from debug to warn with one-shot dedupe per language, exposes loaded/failed grammars via a new getDynamicLanguageStatus() API, and renders an "AST grammars" block in codebase_graph_status output so users see loader state without enabling debug logging. Empirically verified against @ast-grep/napi@0.40.5 in a clean Node environment. Two probes confirmed the napi semantics: sequential register({A}); register({B}) calls are REPLACING (so per-language registration is broken), and batch register with one bad getter is ATOMIC (so pre-validation before the batch call is the only correct pattern). All 721 existing unit tests continue to pass unchanged. Adds 9 new tests for the loader status API; total 730 pass. typecheck and biome clean. CodeRabbit returned no findings on this diff. Co-authored-by: X-Adam <X-Adam@users.noreply.github.com>