GitNexus/gitnexus/test/unit
azizur100389 ee871419e1
feat(ingestion): GITNEXUS_INDEX_TEST_DIRS opt-in for __tests__ / __mocks__ (#771) (#1046)
* feat(ingestion): GITNEXUS_INDEX_TEST_DIRS opt-in for __tests__ / __mocks__ (#771)

The DEFAULT_IGNORE_LIST hardcodes __tests__ and __mocks__ as
auto-filtered directory names. The comment at ignore-service.ts:273
explicitly documents this as intentional — .gitnexusignore negation
cannot override hardcoded entries. That default is right for the
majority of users, but for Quality Engineering workflows where test
files are the primary index target (tracing coverage via CALLS
edges), there was no escape hatch short of patching the installed
package.

Add an opt-in env var mirroring the GITNEXUS_NO_GITIGNORE /
GITNEXUS_MAX_FILE_SIZE precedent:
`GITNEXUS_INDEX_TEST_DIRS=1` removes __tests__ / __mocks__ from the
effective ignore set. Scope is deliberately limited to these two
names — the issue asked for these specifically, and other
test-adjacent entries (__snapshots__, snapshots, fixtures, .jest)
remain auto-filtered unchanged. .gitnexusignore negation semantics
are not touched; the env var is the orthogonal escape hatch.

Implementation: new `isEffectivelyIgnoredDirectory` helper in
ignore-service.ts wraps the `DEFAULT_IGNORE_LIST.has(name)` check
with the env-var opt-out. Two call-sites swap: shouldIgnorePath
(affects filesystem walker and wiki generator) and
createIgnoreFilter.childrenIgnored (affects directory pruning
during traversal). `isHardcodedIgnoredDirectory` export unchanged —
its contract is "is in the raw list", which remains true for
__tests__ / __mocks__ regardless of env var state (locked in by a
test).

Default behaviour is byte-identical for users who don't set the env
var. 9 new unit tests cover default-unset, opt-in-set, scoped scope
(other hardcoded entries unaffected), and the scope-discipline
guard (future expansion beyond the two named dirs fails loudly).
Env state restored by afterEach to prevent leakage.

Closes #771.

* feat(ingestion): .gitnexusignore negation overrides hardcoded DEFAULT_IGNORE_LIST (#771)

Per @magyargergo's review feedback: rather than add a special-case
GITNEXUS_INDEX_TEST_DIRS env var to unlock __tests__ / __mocks__,
let .gitnexusignore use !pattern negation to override the hardcoded
DEFAULT_IGNORE_LIST — mirroring the .gitignore mental model users
already know.

Implementation:
- New private hasExplicitUnignore(ig, rel) helper that walks ancestor
  segments and uses ignore.test(path)'s `unignored` flag to detect
  explicit negation. Ancestor-walk is required because .gitignore
  negation propagates — !__tests__/ implicitly unignores every
  descendant, but ignore.test() only reports unignored: true on the
  directly-matched path.
- createIgnoreFilter.ignored() and .childrenIgnored() now check
  hasExplicitUnignore BEFORE applying the hardcoded DEFAULT_IGNORE_LIST.
  If any ancestor (or the path itself) was explicitly unignored in
  .gitnexusignore, the hardcoded block is bypassed.
- shouldIgnorePath stays pure hardcoded-list — the wiki generator and
  other callers without per-repo config context keep deterministic
  behavior. The #771 override lives only inside createIgnoreFilter,
  which IS called with config.

Dropped:
- GITNEXUS_INDEX_TEST_DIRS env var (superseded by the more general
  negation mechanism)
- isEffectivelyIgnoredDirectory helper
- Associated env-var help text and unit tests

Added:
- Tip in analyze --help pointing users at .gitnexusignore with
  !__tests__/ as the example
- 8 new unit tests covering default behaviour, directory-level
  negation, selective overrides, generalisation (!node_modules/),
  non-leakage across hardcoded entries, standard non-negation rules
  still layering on top, and preservation of shouldIgnorePath /
  isHardcodedIgnoredDirectory contracts

Default behaviour (no .gitnexusignore or no negation pattern) is
byte-identical to pre-#771. Users who want to index an auto-filtered
directory add a single !pattern line — no env var, no flag, no
re-install.

Closes #771.

* fix(ingestion): honour re-ignore rules after .gitnexusignore negation (#771)

When .gitnexusignore contains both `!__tests__/` and
`__tests__/generated/`, the parent negation previously short-circuited
and allowed the re-ignored child through. Consult `ig.ignores(rel)`
after `hasExplicitUnignore` so a more-specific rule in the same file
correctly re-ignores a subset — matching .gitignore's last-match-wins
semantics. Adds a compound-pattern test locking this in.
2026-04-23 13:49:06 +01:00
..
call-routing feat(ingestion): language-agnostic heritage extractor with config+factory pattern (#890) 2026-04-17 17:51:17 +01:00
group fix(group): bubble local-impact phase errors in groupImpact (#1004) (#1007) 2026-04-21 11:44:16 +01:00
import-resolution feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
mcp feat: cross-repo impact analysis (#794) — @repo MCP routing + group resources (#984) 2026-04-20 11:55:07 +01:00
model feat(shared): add scope-resolution types + constants (#910, RFC #909 Ring 1) (#949) 2026-04-18 12:55:09 +01:00
named-bindings refactor: SICP-informed LanguageProvider architecture (#488) 2026-03-24 13:42:39 +00:00
scope-resolution feat(csharp): migrate C# to registry-primary scope-resolution (Closes #934) (#1019) 2026-04-23 12:38:13 +01:00
shadow chore(shared): apply Ring 2 SHARED review follow-ups in one diff (#964) 2026-04-18 18:40:29 +01:00
ai-context.test.ts fix(cli): only match <!-- gitnexus:* --> markers at section position (#1041) (#1042) 2026-04-23 07:58:07 +01: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
ast-utils.test.ts feat(embeddings): AST-aware chunking with offset-based splitting (#889) 2026-04-16 22:55:04 +01: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 fix(fts): Don't cache failed FTS index ensure; invalidate on pool teardown (#1006) 2026-04-21 08:50:33 +01:00
call-extraction.test.ts feat(ingestion): language-agnostic call extractor with config+factory pattern (#877) 2026-04-16 11:45:30 +01: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 feat(python): scope-based call resolution + registry-primary flip + perf + generalization (RFC #909 Ring 3) (#980) 2026-04-21 15:50:00 +01:00
calltool-dispatch.test.ts feat(cli): Fingerprint indexed repos by remote URL to detect sibling-clone graph drift (#982) 2026-04-21 21:58:54 +01:00
chunker.test.ts feat(embeddings): structural chunking with data-driven CHUNKING_RULES dispatch (#987) 2026-04-20 08:25:31 +01: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: expose detect-changes in direct CLI (#892) 2026-04-20 17:12:25 +01:00
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 refactor(ingestion): split ImportSemantics into per-strategy hooks (Strategies 1-4) (#886) 2026-04-16 19:31:44 +01: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-chunking.test.ts feat(embeddings): structural chunking with data-driven CHUNKING_RULES dispatch (#987) 2026-04-20 08:25:31 +01:00
embedding-pipeline.test.ts feat(embeddings): structural chunking with data-driven CHUNKING_RULES dispatch (#987) 2026-04-20 08:25:31 +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 fix: detect React component paths before lowercasing (#260) 2026-04-19 07:10:36 +01: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(cli): Fingerprint indexed repos by remote URL to detect sibling-clone graph drift (#982) 2026-04-21 21:58:54 +01:00
git.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
graph.test.ts feat(python): scope-based call resolution + registry-primary flip + perf + generalization (RFC #909 Ring 3) (#980) 2026-04-21 15:50:00 +01:00
group-service-not-found.test.ts fix(group): surface friendly error when group name not found (#903 regression test) (#989) 2026-04-21 15:52:36 +01: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-extraction.test.ts feat(ingestion): language-agnostic heritage extractor with config+factory pattern (#890) 2026-04-17 17:51:17 +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 feat(ingestion): GITNEXUS_INDEX_TEST_DIRS opt-in for __tests__ / __mocks__ (#771) (#1046) 2026-04-23 13:49:06 +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
import-resolver-factory.test.ts fix(python): avoid local matches for external dotted imports (#899) 2026-04-17 11:35:59 +01:00
index-repo-command.test.ts feat(cli): Fingerprint indexed repos by remote URL to detect sibling-clone graph drift (#982) 2026-04-21 21:58:54 +01: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
lbug-embedding-hashes.test.ts feat(embeddings): AST-aware chunking with offset-based splitting (#889) 2026-04-16 22:55:04 +01:00
local-backend-maxbuffer.test.ts fix: ENOBUFS in detect_changes by setting maxBuffer on git/rg execFileSync (#957) 2026-04-18 15:58:31 +01:00
max-file-size.test.ts feat(ingestion): make large-file skip threshold configurable (#1044) 2026-04-23 11:07:37 +01: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 feat(python): scope-based call resolution + registry-primary flip + perf + generalization (RFC #909 Ring 3) (#980) 2026-04-21 15:50:00 +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
phase-timer.test.ts feat(search): per-phase timing instrumentation for the query pipeline (#953) 2026-04-18 16:30:07 +01: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
registry-primary-flag.test.ts feat(csharp): migrate C# to registry-primary scope-resolution (Closes #934) (#1019) 2026-04-23 12:38:13 +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(cli): gitnexus remove <target> to unindex a registered repo by name or path (#664) (#1003) 2026-04-21 11:52:59 +01:00
resolve-enclosing-owner.test.ts feat(ingestion): language-agnostic heritage extractor with config+factory pattern (#890) 2026-04-17 17:51:17 +01:00
resources.test.ts feat: cross-repo impact analysis (#794) — @repo MCP routing + group resources (#984) 2026-04-20 11:55:07 +01:00
route-tool-detection.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
ruby-self-call.test.ts feat(ingestion): language-agnostic heritage extractor with config+factory pattern (#890) 2026-04-17 17:51:17 +01: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(ingestion): language-agnostic variable extractor with config+factory pattern (#878) 2026-04-16 13:57:25 +01:00
security.test.ts feat: METHOD_IMPLEMENTS edges, overload disambiguation, MethodExtractor unification (#574) (#642) 2026-04-04 18:41:47 +01:00
semantic-chunk-search.test.ts feat(embeddings): AST-aware chunking with offset-based splitting (#889) 2026-04-16 22:55:04 +01:00
sequential-language-availability.test.ts fix(ingestion): Log skipped sequential parser languages (#1021) 2026-04-23 08:50:38 +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-jsonc.test.ts fix: preserve comments and config in opencode.json during setup (#998) 2026-04-22 17:21:56 +01: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
sibling-clone-drift.test.ts feat(cli): Fingerprint indexed repos by remote URL to detect sibling-clone graph drift (#982) 2026-04-21 21:58:54 +01: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 feat(ingestion): language-agnostic heritage extractor with config+factory pattern (#890) 2026-04-17 17:51:17 +01:00
text-generator.test.ts feat(embeddings): structural chunking with data-driven CHUNKING_RULES dispatch (#987) 2026-04-20 08:25:31 +01:00
tool-direct-cli.test.ts fix: expose detect-changes in direct CLI (#892) 2026-04-20 17:12:25 +01:00
tools.test.ts feat: cross-repo impact analysis (#794) — @repo MCP routing + group resources (#984) 2026-04-20 11:55:07 +01: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 feat(ingestion): language-agnostic variable extractor with config+factory pattern (#878) 2026-04-16 13:57:25 +01:00
type-env.test.ts feat(shared): add scope-resolution types + constants (#910, RFC #909 Ring 1) (#949) 2026-04-18 12:55:09 +01:00
utils.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
variable-extraction.test.ts feat(ingestion): language-agnostic variable extractor with config+factory pattern (#878) 2026-04-16 13:57:25 +01: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