GitNexus/gitnexus/test/unit
Copilot 1df79c2eab
fix: content-hash staleness detection for embeddings and vector index creation on zero-node path (#831)
* Initial plan

* fix: stale vectors preserved on content edits and vector index missing after zero-node run

Issue 1: Add contentHash to EMBEDDING_SCHEMA and embedding pipeline.
- contentHash column persisted per CodeEmbedding row
- POST /api/embed queries nodeId+contentHash, compares per-node hash
- Stale rows (hash mismatch) are DELETE'd before re-embedding
- Legacy DBs without contentHash treated as stale (full re-embed)
- loadCachedEmbeddings and run-analyze cache restore include contentHash

Issue 2: createVectorIndex called unconditionally before zero-node early return.

Regression tests:
- contentHashForNode determinism and content-change detection
- EMBEDDING_SCHEMA includes contentHash STRING column
- Pipeline exports verified

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/1581c0c0-f359-4376-b47e-62d24a28fd2d

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* fix: use parameterized query for stale embedding DELETE, revert package-lock.json

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/1581c0c0-f359-4376-b47e-62d24a28fd2d

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* fix: address review feedback — config consistency, narrow catches, extract DB logic

Bug #1: Use finalConfig consistently in contentHashForNode (line 224 was
using raw `config` while line 307 used `finalConfig`). Cache precomputed
hashes in filter phase to avoid double computation (Perf #5).

Bug #2: Narrow catch in loadCachedEmbeddings to only fall back on
column/table-missing errors. Rethrow transient/connection errors.

Bug #3: Log non-trivial DELETE failures instead of silently swallowing.

Arch Violation #3: Extract fetchExistingEmbeddingHashes from api.ts into
lbug-adapter.ts. Server layer now calls a single adapter function instead
of re-implementing the DB query logic with nested try-catch.

Tests: Add config consistency test, note that fetchExistingEmbeddingHashes
tests require native module (run in CI).

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/b8c4f6b0-4095-4507-a15d-d8469793efac

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* fix: narrow Column error match to 'contentHash' in lbug-adapter fallback checks

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/b8c4f6b0-4095-4507-a15d-d8469793efac

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* fix: address production-readiness review — eliminate competing state, use schema constants, hard-fail on stale DELETE, add incremental filter tests

Gap A / Arch Violation 1: Remove duplicate vectorExtensionLoaded flag from
embedding-pipeline.ts — delegate to lbug-adapter's loadVectorExtension()
which owns the VECTOR extension lifecycle and resets on DB reconnect.

Arch Violation 2: Replace all hardcoded 'CodeEmbedding' and
'code_embedding_idx' strings in embedding-pipeline.ts and run-analyze.ts
with EMBEDDING_TABLE_NAME, EMBEDDING_INDEX_NAME, and CREATE_VECTOR_INDEX_QUERY
imported from schema.ts. Add EMBEDDING_INDEX_NAME export to schema.ts.

Gap B: Make DELETE failure for stale vectors a hard throw (not just a
warning). Continuing after failed DELETE risks Kuzu vector-index corruption
since the constraint requires DELETE-before-INSERT for vector-indexed
properties. "not found" / "does not exist" errors are still safe to ignore.

STALE_HASH_SENTINEL: Define a named constant in embedding types.ts for the
empty-string sentinel convention. Used consistently in lbug-adapter.ts and
run-analyze.ts so the invariant is self-documenting.

Tests: Add comprehensive unit tests for the incremental filter logic with
mocked embedder:
- New node → embedded
- Unchanged node (hash matches) → skipped
- Stale node (hash mismatch) → DELETE + re-embed
- STALE_HASH_SENTINEL → treated as stale
- Zero nodes after filter → createVectorIndex still called
- DELETE failure with non-trivial error → throws

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/b21edee7-c9c5-4742-947b-d0def4fb26aa

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* fix: tighten error classification — extract isMissingColumnOrTableError helper, remove broad pattern matching

- Extract isMissingColumnOrTableError() helper in lbug-adapter for
  consistent schema-error detection (replaces duplicate inline checks)
- Tighten 'contentHash' match: now requires 'property' AND 'contentHash'
  (Kuzu-specific pattern) instead of broad 'contentHash' substring
- Tighten DELETE error check: only ignore 'does not exist' (Kuzu's actual
  message), not broad 'not found' which could mask connection errors
- Fix test node ID/name/filePath consistency

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/b21edee7-c9c5-4742-947b-d0def4fb26aa

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* fix: CI failures and final review — move STALE_HASH_SENTINEL to schema, tighten error matching, fix test mocking, format

- Move STALE_HASH_SENTINEL from embeddings/types.ts to lbug/schema.ts
  (fixes inverted layer dependency: lbug should not import from embeddings)
- Tighten isMissingColumnOrTableError: replace broad msg.includes('not found')
  with /(table|column|property).*not found/i regex to avoid matching transient errors
- Add vi.resetModules() in test beforeEach for explicit module isolation
  (fixes vi.doMock not intercepting loadVectorExtension in CI)
- Skip precomputedHashes.set() on unchanged (return false) path
- Run prettier on all 5 files flagged by CI format check

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/e20311fd-4361-47b4-a137-9adc3e533b35

* fix: address remaining review nits — rename precomputedHashes, generalize error matcher, revert package-lock

- Rename precomputedHashes → computedStaleHashes (hashes are computed
  on-demand during filter, only cached for stale nodes being re-embedded)
- Remove contentHash-specific clause from isMissingColumnOrTableError —
  the regex /(table|column|property).*not found/i already covers it
- Revert package-lock.json ssh→https protocol change

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/e20311fd-4361-47b4-a137-9adc3e533b35

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>
2026-04-15 11:20:48 +01:00
..
call-routing feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
group [group/sync] Fix ManifestExtractor never called — config.links always produced 0 cross-links (#827) 2026-04-15 09:14:09 +01:00
import-resolution feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
model Extract registries into model/ module with SemanticModel interface (#786) 2026-04-12 01:06:55 +01:00
named-bindings refactor: SICP-informed LanguageProvider architecture (#488) 2026-03-24 13:42:39 +00:00
ai-context.test.ts feat: added skip-agents-md cli flag (#517) 2026-03-28 21:23:59 +00:00
analyze-api.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
analyze-job.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
api-graph-streaming.test.ts [codex] fix large repository graph loading (#732) 2026-04-09 17:40:24 +01:00
ast-cache.test.ts fix: guard createASTCache against zero maxSize to prevent LRU cache crash 2026-03-02 08:47:20 +00:00
binding-accumulator.test.ts refactor(pipeline): DAG-based phase architecture + container-logic extraction to LanguageProvider (#809) 2026-04-13 20:31:05 +01:00
bm25-search.test.ts refactor: migrate from KuzuDB to LadybugDB v0.15 (#275) 2026-03-15 15:53:01 +00:00
call-form.test.ts Extract registries into model/ module with SemanticModel interface (#786) 2026-04-12 01:06:55 +01:00
call-processor.test.ts Extract registries into model/ module with SemanticModel interface (#786) 2026-04-12 01:06:55 +01:00
calltool-dispatch.test.ts feat(group): add sync pipeline, CLI, MCP tools, and monorepo fixture 2026-04-02 00:40:31 +03:00
cli-commands.test.ts feat: configure eslint with unused import removal (#564) 2026-03-28 15:28:09 +00:00
cli-index-help.test.ts fix: address PR review — remove redundancies and add wiki help test 2026-03-25 11:39:37 +05:30
cobol-copy-expander.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
cobol-preprocessor.test.ts feat: configure eslint with unused import removal (#564) 2026-03-28 15:28:09 +00:00
cohesion-consistency.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
community-processor.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
compatible-stdio-transport.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
cors.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
cross-file-impl.test.ts refactor(pipeline): DAG-based phase architecture + container-logic extraction to LanguageProvider (#809) 2026-04-13 20:31:05 +01:00
cross-file.test.ts refactor(pipeline): DAG-based phase architecture + container-logic extraction to LanguageProvider (#809) 2026-04-13 20:31:05 +01:00
csv-escaping.test.ts refactor: migrate from KuzuDB to LadybugDB v0.15 (#275) 2026-03-15 15:53:01 +00:00
dart-import-resolver.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
dart-type-extractor.test.ts feat: configure eslint with unused import removal (#564) 2026-03-28 15:28:09 +00:00
embedder.test.ts test: add test suite with vitest (unit + integration + fixtures) 2026-03-01 20:07:02 +05:30
embedding-pipeline.test.ts fix: content-hash staleness detection for embeddings and vector index creation on zero-node path (#831) 2026-04-15 11:20:48 +01:00
entry-point-scoring.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
eval-formatters.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
expo-routes.test.ts feat: add Expo Router file-based route detection (#503) 2026-03-25 11:05:55 +00:00
extract-element-type-from-string.test.ts feat: Phase 6 type resolution — for-loop Tier 1c, pattern matching, container descriptors, 10-language coverage (#318) 2026-03-17 17:10:22 +00:00
extract-generic-type-args.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
fetch-reason-parsing.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
field-extraction.test.ts Extract registries into model/ module with SemanticModel interface (#786) 2026-04-12 01:06:55 +01:00
framework-detection.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
git-clone.test.ts Fix security issues and critical bugs found in code review (#709) 2026-04-10 05:20:29 +01:00
git-utils.test.ts feat: configure eslint with unused import removal (#564) 2026-03-28 15:28:09 +00:00
git.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
graph.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
has-method.test.ts feat: MethodExtractor configs for Python, PHP, Swift, Dart, Rust, Ruby (#624) 2026-04-03 16:11:31 +01:00
heritage-map.test.ts Extract registries into model/ module with SemanticModel interface (#786) 2026-04-12 01:06:55 +01:00
heritage-processor.test.ts Extract registries into model/ module with SemanticModel interface (#786) 2026-04-12 01:06:55 +01:00
hooks.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
http-embedder.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
hybrid-search.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
ignore-service.test.ts fix(ignore): respect negation patterns in .gitnexusignore (#654) 2026-04-06 08:32:47 +01:00
impact-batching-grouping.test.ts feat(group): add sync pipeline, CLI, MCP tools, and monorepo fixture 2026-04-02 00:40:31 +03:00
impact-confidence.test.ts feat: METHOD_IMPLEMENTS edges, overload disambiguation, MethodExtractor unification (#574) (#642) 2026-04-04 18:41:47 +01:00
import-processor.test.ts Extract registries into model/ module with SemanticModel interface (#786) 2026-04-12 01:06:55 +01:00
index-repo-command.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
ingestion-utils.test.ts feat: METHOD_IMPLEMENTS edges, overload disambiguation, MethodExtractor unification (#574) (#642) 2026-04-04 18:41:47 +01:00
isWriteQuery.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
jcl-parser.test.ts feat: configure eslint with unused import removal (#564) 2026-03-28 15:28:09 +00:00
language-skip.test.ts feat(ingestion): respect .gitignore and .gitnexusignore during file discovery (#231) 2026-03-16 13:26:20 +00:00
lazy-action.test.ts Improve MCP startup compatibility and lazy-load CLI commands (#207) 2026-03-07 07:47:09 +00:00
method-extraction.test.ts refactor(pipeline): DAG-based phase architecture + container-logic extraction to LanguageProvider (#809) 2026-04-13 20:31:05 +01:00
method-props.test.ts feat: same-arity overload disambiguation via type-hash suffix (#651) (#658) 2026-04-05 21:51:55 +01:00
mro-processor.test.ts fix: prevent stack overflow and memory exhaustion on large repo analysis (#814) 2026-04-13 20:08:49 +01:00
noise-filter.test.ts refactor: split global BUILT_IN_NAMES into per-language provider fields (#523) 2026-03-26 12:15:29 +00:00
parse-diff-hunks.test.ts fix: map diff hunks to symbol line ranges in detect_changes (#779) 2026-04-11 11:29:52 +01:00
parse-impl-fallback.test.ts refactor(pipeline): DAG-based phase architecture + container-logic extraction to LanguageProvider (#809) 2026-04-13 20:31:05 +01:00
parser-loader.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
pipeline-exports.test.ts test: add test suite with vitest (unit + integration + fixtures) 2026-03-01 20:07:02 +05:30
pipeline-runner.test.ts refactor(pipeline): DAG-based phase architecture + container-logic extraction to LanguageProvider (#809) 2026-04-13 20:31:05 +01:00
process-processor.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
receiver-extraction.test.ts Fix HTTP client vs Express route detection and Spring interface attribution (#780) 2026-04-11 11:24:47 +01:00
rel-csv-split.test.ts fix(lbug): wait for read stream close in splitRelCsvByLabelPair (Windows ENOTEMPTY) (#832) 2026-04-15 08:59:09 +01:00
repo-manager.test.ts feat: configure eslint with unused import removal (#564) 2026-03-28 15:28:09 +00:00
resolve-enclosing-owner.test.ts refactor(pipeline): DAG-based phase architecture + container-logic extraction to LanguageProvider (#809) 2026-04-13 20:31:05 +01:00
resources.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
route-tool-detection.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
run-analyze.test.ts feat: unify web and cli ingestion pipeline (#536) 2026-03-28 14:07:11 +00:00
schema.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
security.test.ts feat: METHOD_IMPLEMENTS edges, overload disambiguation, MethodExtractor unification (#574) (#642) 2026-04-04 18:41:47 +01:00
sequential-language-availability.test.ts Extract registries into model/ module with SemanticModel interface (#786) 2026-04-12 01:06:55 +01:00
server.test.ts feat: configure eslint with unused import removal (#564) 2026-03-28 15:28:09 +00:00
setup-codex.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
setup.test.ts fix(setup): prefer global gitnexus binary over npx for MCP config (#653) 2026-04-06 07:46:10 +01:00
shape-check.test.ts fix: shape_check false positives — quoted keys, DOM leaks, errorKeys (#501) 2026-03-26 05:43:37 +00:00
shared-type-extractors.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
skill-gen.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
skip-git-cli.test.ts feat: added skip-agents-md cli flag (#517) 2026-03-28 21:23:59 +00:00
staleness.test.ts feat(group): add group infrastructure and contract matching 2026-04-02 00:39:43 +03:00
stdout-silence.test.ts fix(mcp): unify stdout silencing to prevent embedder/pool-adapter conflicts (#645) 2026-04-04 11:56:49 +01:00
structure-processor.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
suffix-index-ambiguity.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
symbol-resolver.test.ts refactor(pipeline): DAG-based phase architecture + container-logic extraction to LanguageProvider (#809) 2026-04-13 20:31:05 +01:00
symbol-table.test.ts refactor(pipeline): DAG-based phase architecture + container-logic extraction to LanguageProvider (#809) 2026-04-13 20:31:05 +01:00
tools.test.ts feat(group): add sync pipeline, CLI, MCP tools, and monorepo fixture 2026-04-02 00:40:31 +03:00
topological-sort.test.ts refactor(pipeline): DAG-based phase architecture + container-logic extraction to LanguageProvider (#809) 2026-04-13 20:31:05 +01:00
transitive-include-closure.test.ts fix: resolve C/C++ cross-file calls through transitive #include chains (#816) 2026-04-14 09:39:17 +01:00
tree-sitter-queries.test.ts [dart] Add call patterns for await, cascade, lambda, and widget-tree contexts (#801) 2026-04-13 11:21:11 +01:00
type-env.test.ts Extract registries into model/ module with SemanticModel interface (#786) 2026-04-12 01:06:55 +01:00
utils.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
vue-sfc-extractor.test.ts feat(vue): Vue SFC support + destructured call result tracking (#604) 2026-04-03 14:18:55 +05:30
wiki-flags.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
wiki-llm-client.test.ts fix(wiki): Azure OpenAI compat and HTML viewer script injection (#618) 2026-04-01 21:30:43 +05:30
wildcard-synthesis.test.ts refactor(pipeline): DAG-based phase architecture + container-logic extraction to LanguageProvider (#809) 2026-04-13 20:31:05 +01:00