mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-29 06:32:28 +00:00
Closes the remaining Windows SIGSEGV exposure flagged by the Codex adversarial review on PR #1433. Six pre-existing parser.parse(content) call sites bypassed parseSourceSafe and could crash the process on Windows when a contract IDL, route file, or embedding-target source exceeded 32 767 chars. Adds a lint rule so the regression vector closes permanently. Production code: - Relocate parseSourceSafe from ingestion/utils/ to core/tree-sitter/ so group/ and embeddings/ can import without crossing into ingestion internals. core/tree-sitter/ already houses parser-loader.ts and is the natural shared facade. All 11 existing importers updated; no shim left behind in the old location. - Route through parseSourceSafe in 5 group extractors (grpc, thrift, http-route, include, tree-sitter-scanner) and the embeddings ensureAndParse helper. - The seventh direct .parse() call in grpc-patterns/proto.ts:49 is a module-load grammar smoke test parsing a 36-char literal. Trivially safe by inspection, intentionally direct, filtered out by the lint rule via the string-literal-arg skip. Tests: - 5 caller-side regression tests with a vi.spyOn assertion on parseSourceSafe. The spy is what catches a regression: parser.parse on a 40 000-char input succeeds on Linux/macOS, so a "no throw" assertion alone would silently pass with the bypass reintroduced. - The vi.mock boilerplate is centralised in gitnexus/test/helpers/parse-source-safe-mock.ts, dynamic-imported inside each mock factory so vitest's hoister does not race the static import binding. Lint: - New custom ESLint rule gitnexus/require-safe-parse, scoped to gitnexus/src/core/**, fails on direct <parser>.parse(<non-literal>, ...) calls and auto-fixes them to parseSourceSafe(<parser>, ...). Skips JSON/URL/marked/Number/Math, string-literal first args (smoke tests), test files, and the helper itself. Auto-fix rewrites the call site only; the developer adds the import after tsc surfaces the missing identifier — same tradeoff as unused-imports/no-unused-imports. Plan: docs/plans/2026-05-10-001-fix-windows-parse-safety-group-and-embeddings-plan.md |
||
|---|---|---|
| .. | ||
| augmentation | ||
| embeddings | ||
| graph | ||
| group | ||
| ingestion | ||
| lbug | ||
| platform | ||
| search | ||
| tree-sitter | ||
| wiki | ||
| embedding-mode.ts | ||
| git-staleness.ts | ||
| logger.ts | ||
| run-analyze.ts | ||