GitNexus/gitnexus/test/integration
bluerose 89ffa71a52
feat(cli): add --embeddings-baseurl/-model/-auth-token/-dims flags to analyze (#2140)
* feat(cli): add --embeddings-baseurl/-model/-auth-token/-dims flags to analyze

Add four CLI flags to `gitnexus analyze` that configure a custom
OpenAI-compatible HTTP embedding endpoint by setting the
GITNEXUS_EMBEDDING_URL / _MODEL / _API_KEY / _DIMS env vars the HTTP
embedding client already reads. Flags override env vars; env vars keep
working as before. URLs are validated (http/https) and dims must be a
positive integer. Prints "Using custom embedding endpoint: <url>" when
a URL+model pair is configured, and warns when the flags are passed
without --embeddings. The new env keys are added to the analyze
snapshot/restore set so programmatic callers don't leak state. The
non-secret flags are also accepted from .gitnexusrc; the auth token is
intentionally CLI/env-only.

* fix(analyze): set GITNEXUS_EMBEDDING_DIMS from CLI flags before module import

schema.ts reads EMBEDDING_DIMS at module-load time via the static-import
chain (analyze.ts -> run-analyze.ts -> schema.ts). The previous approach
of setting the env var inside analyzeCommandImpl ran AFTER schema.ts had
already loaded with the default 384, causing "Expected: 384, Actual: 4096"
errors when using --embeddings-dims 4096.

Fix: use Commander's preAction hook to set GITNEXUS_EMBEDDING_* env vars
before the lazy import of analyze.ts triggers the schema.ts module load.

* fix(analyze): use hook callback arg instead of this in preAction

Commander v14 passes the command as first argument, not as this binding.

* refactor(cli): rename --embeddings-* analyze flags to singular --embedding-*

Aligns the custom embedding endpoint flags with the existing singular
tuning flags (--embedding-threads/--embedding-device): --embedding-base-url,
--embedding-model, --embedding-auth-token, --embedding-dims. Renames the
derived AnalyzeOptions fields and the .gitnexusrc KEY_SPECS keys to match.
Behavior-preserving; the GITNEXUS_EMBEDDING_* env vars are unchanged.

Refs #2140 review.

* fix(cli): validate and normalize --embedding-dims before module-load reads it

The preAction hook wrote GITNEXUS_EMBEDDING_DIMS unvalidated, so an invalid
value (abc/0/-5/0x10) threw from schema.ts during the lazy import — surfacing
as a raw unhandled rejection on the synchronous program.parse path instead of
a friendly error. And '1e3' slipped through: schema.ts parseInt froze the
vector column at FLOAT[1] while the impl's Number-based check accepted 1000,
so http-client requested 1000-dim vectors against a 1-dim column.

Extract a dependency-free normalizeEmbeddingDims helper (strict /^\d+$/ +
positive, trim-then-validate, canonicalized) shared by both the hook (CLI
path, before module-load) and analyzeCommandImpl (direct-call path). All three
readers — schema.ts, http-client, and this helper — now agree on one value,
and invalid input gets a clean message instead of a crash or a silent mismatch.

Refs #2140 review.

* fix(cli): mask credentials in the custom embedding endpoint confirmation

A base URL with userinfo (http://user:pass@host/v1) or a query token
(?api_key=…) passed the new-URL + http/https validation and was printed
verbatim in the 'Using custom embedding endpoint:' line, leaking the secret
to terminal scrollback and CI logs. Route it through the existing safeUrl()
(now exported from http-client) which strips userinfo + query, keeping
protocol/host/path. Single source of truth — no second sanitizer.

Refs #2140 review.

* fix(cli): drop the ineffective embeddingDims .gitnexusrc key

embeddingDims as a .gitnexusrc key silently did nothing: .gitnexusrc loads in
analyzeCommandImpl, AFTER the lazy import already ran schema.ts's module-load
read of GITNEXUS_EMBEDDING_DIMS, so a config value never sized the vector
column. Remove it (config now fails closed on the key, like the auth token);
URL/MODEL stay as config keys because they're read lazily at runtime. Dims
remains available via --embedding-dims or GITNEXUS_EMBEDDING_DIMS.

Refs #2140 review.

* refactor(cli): narrow the analyze preAction hook to GITNEXUS_EMBEDDING_DIMS

Only DIMS is read at module-load (schema.ts), so only it must be set before the
lazy import. URL/MODEL/API_KEY are read lazily at runtime, so analyzeCommandImpl
is their sole setter — and because the impl's env snapshot is taken AFTER this
hook ran, leaving those three in the hook leaked them past restore. Drop them
from the hook (the impl already sets+restores them), and capture/restore the
pre-hook DIMS baseline via a postAction hook so a CLI --embedding-dims override
no longer leaks into a later in-process program.parseAsync.

Refs #2140 review.

* fix(cli): gate the custom-endpoint confirmation on the embedding flags

The confirmation collapsed into one if/else chain that emits at most one
message reflecting the run's intent. Gating on embeddingsEnabled stops the
'Using custom embedding endpoint' line from printing on every analyze run when
GITNEXUS_EMBEDDING_URL+MODEL merely happen to be set in the environment, and
ordering the '--embeddings absent' note first removes the contradiction where
it printed alongside 'Using custom embedding endpoint'.

Refs #2140 review.

* test(cli): cover the custom embedding endpoint flags

Adds direct-call (analyzeCommandImpl path) coverage the original PR lacked:
URL validation (empty/invalid/non-http), model/token emptiness, dims
validation incl. the 1e3 regression, credential masking in the confirmation
line, confirmation gating (absent --embeddings; ambient env must not trigger
it), CLI-over-env precedence, and the GITNEXUS_EMBEDDING_* snapshot/restore
round-trip. Complements embedding-dims.test.ts and http-client-safe-url.test.ts.

Refs #2140 review.

* test(cli): e2e-cover the --embedding-dims crash path on the real CLI

The dims-validation fix lives in the commander preAction hook, which only
fires on the program.parse path; the direct analyzeCommand() unit tests bypass
it. Add a subprocess e2e (run via tsx, no build) asserting that invalid
--embedding-dims (abc/0/-5/1e3/3.5) produces the friendly flag-named error and
exit 1 — NOT the raw schema.ts module-load throw that the original bug
surfaced. Cases exit inside the hook (no repo/import/pipeline), so they're
deterministic and fast. Updates the unit-suite comment to point at it.

Refs #2140 review.

---------

Co-authored-by: Gergo Magyar <gergomagyar@icloud.com>
2026-06-13 14:01:12 +01:00
..
cfg feat(taint): interprocedural taint via function summaries over resolved CALLS (#2084) (#2179) 2026-06-13 07:04:14 +01:00
cli feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
group feat: add IncludeExtractor for C++ cross-repo include tracking (group) (#1156) 2026-05-09 09:31:59 +01:00
mcp feat(mcp): paginate list_repos to avoid client token truncation (#2119) (#2120) 2026-06-09 19:59:54 +01:00
optional-grammars feat(install): toolchain-free tree-sitter via vendored prebuilds (#2113) 2026-06-09 18:16:24 +01:00
resolvers fix(cpp): suppress deleted overload winners (#2094) 2026-06-10 18:41:30 +01:00
analyze-embedding-flags-e2e.test.ts feat(cli): add --embeddings-baseurl/-model/-auth-token/-dims flags to analyze (#2140) 2026-06-13 14:01:12 +01:00
analyze-heap-oom-e2e.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
analyze-wal-checkpoint-failure.test.ts fix(lbug): add WAL checkpoint-threshold control (#1772) 2026-05-22 14:46:49 +01:00
antigravity-hook-e2e.test.ts perf(hooks): cmdline-first Linux db-lock scan, drop the lsof fallback (#2180) (#2183) 2026-06-13 11:52:14 +01:00
api-impact-e2e.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
api-query.test.ts fix: Use Ladybug native read-only enforcement and prepared statement execution for Cypher query paths (#1655) 2026-05-18 06:54:24 +01:00
ast-helpers-object-literal-binding.test.ts feat(ingestion): Link object literal methods to exported bindings (#1718) 2026-05-21 17:18:27 +01:00
augmentation.test.ts fix(augment): add CONTAINS fallback when FTS indexes unavailable (#1476) 2026-05-11 16:39:10 +01:00
basicblock-roundtrip.test.ts feat(ingestion): M0 — taint/PDG substrate (schema + seams + spikes) (#2080) (#2092) 2026-06-08 18:56:10 +01:00
c-cpp-typedef-legacy-parse.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
class-impact-all-languages.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
cli-e2e.test.ts test(cli): make cli-e2e read-only + eval-server tests robust under load (#2000) 2026-06-03 21:50:22 +01:00
cobol-pipeline-benchmark.test.ts refactor(ingestion): delete legacy call-resolution DAG + heritage processor (RING4-1, #942) (#2023) 2026-06-04 11:07:37 +01:00
context-typed-property.test.ts fix(csharp): include generic typed properties in context and impact (#1399) 2026-05-09 09:07:24 +01:00
cpp-adl-benchmark.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
cpp-pipeline-benchmark.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
cross-file-binding.test.ts fix(ingestion): classify Python class methods as Method (#1102) 2026-04-27 09:04:50 +01:00
csharp-pipeline-benchmark.test.ts fix(csharp): eliminate global-namespace typeBindings O(files²) OOM (#1871) (#1954) 2026-05-31 18:21:07 +01:00
csharp-scope-capture-tripwire.test.ts perf(ingestion): linearize scope-capture across all languages + Python import resolution (O(n²)→O(n)) (#1918) 2026-05-30 19:44:22 +01:00
csv-pipeline.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
enrichment.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
expo-routes.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
fastapi-prefix-pipeline.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
filesystem-walker.test.ts fix(analyze): prevent cache-hit native workers from aborting (#1751) 2026-05-21 16:17:02 +01:00
go-multi-name-worker-metadata.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
go-pipeline-benchmark.test.ts fix(go): generic composite literal constructor inference (F33) (#1976) 2026-06-03 05:24:31 +01:00
grammar-introspection.test.ts feat(ingestion): tree-sitter node-type/field validation gate + remove dead literals (#1937) 2026-05-31 10:29:41 +01:00
grammar-literal-validation.test.ts feat(ingestion): tree-sitter node-type/field validation gate + remove dead literals (#1937) 2026-05-31 10:29:41 +01:00
has-method.test.ts feat(cpp): C/C++ MethodExtractor config with pure virtual detection (#617) 2026-04-01 18:07:11 +01:00
hooks-e2e.test.ts fix(hooks): resolve gitnexus on PATH with a pure-Node scan, all-OS (#1938) (#1980) 2026-06-03 03:19:49 +01:00
ignore-and-skip-e2e.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
impact-ambiguous-blast-radius.test.ts fix: stop impact()/route_map under-reporting blast radius (#2129, #1858, #1589/#1852) (#2136) 2026-06-10 11:25:48 +01:00
impact-epistemic-lower-bound.test.ts fix: stop impact()/route_map under-reporting blast radius (#2129, #1858, #1589/#1852) (#2136) 2026-06-10 11:25:48 +01:00
java-class-impact.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
js-array-method-callback-attribution.test.ts refactor(ingestion): delete legacy call-resolution DAG + heritage processor (RING4-1, #942) (#2023) 2026-06-04 11:07:37 +01:00
lbug-close-handle-release.test.ts fix(lbug): drain checkpoint result before close (#1506) 2026-05-12 14:03:45 +01:00
lbug-core-adapter.test.ts feat(taint): interprocedural taint via function summaries over resolved CALLS (#2084) (#2179) 2026-06-13 07:04:14 +01:00
lbug-lock-retry.test.ts fix(lbug): robust Windows lock acquisition for CI integration tests (#1430) 2026-05-08 11:58:01 +01:00
lbug-non-ascii-path.test.ts fix(lbug): resolve non-ASCII paths for KuzuDB on Windows (#1811) (#1817) 2026-05-25 21:28:12 +01:00
lbug-open-retry.test.ts fix(lbug): robust Windows lock acquisition for CI integration tests (#1430) 2026-05-08 11:58:01 +01:00
lbug-orphan-sidecar-recovery.test.ts fix(lbug): Recover gitnexus analyze from orphan LadybugDB sidecars when main DB file is missing (#1622) 2026-05-16 11:45:32 +01:00
lbug-pool-stability.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
lbug-pool.test.ts fix(parse): correct worker-pool docs drift + surface worker-side stack on crash (#2068) (#2070) 2026-06-08 07:20:12 +01:00
lbug-readonly-init.test.ts fix(lbug): skip init lock and filesystem mutations for read-only opens (#1783) (#1784) 2026-05-24 08:05:27 +01:00
lbug-vector-extension.test.ts fix(embeddings): create VECTOR index via conn.query, not the prepared path (#2114) 2026-06-10 07:59:37 +01:00
literal-collectors.test.ts feat(ingestion): tree-sitter node-type/field validation gate + remove dead literals (#1937) 2026-05-31 10:29:41 +01:00
local-backend-calltool.test.ts fix(mcp): rename query/cypher params so Claude Code can call them (#2186) 2026-06-13 10:24:16 +01:00
local-backend.test.ts fix: Use Ladybug native read-only enforcement and prepared statement execution for Cypher query paths (#1655) 2026-05-18 06:54:24 +01:00
local-symbol-pruner-pipeline.test.ts perf(ingestion): prune inert local value symbols (#2065) 2026-06-07 14:47:51 +01:00
markdown-processor-crlf.test.ts fix(markdown): handle CRLF line endings in section heading parser (#1469) 2026-05-14 08:58:58 +01:00
multi-branch-analyze.test.ts feat: multi-branch indexing and branch-scoped querying (#2106) (#2137) 2026-06-10 10:24:40 +01:00
object-literal-method-exports.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
object-literal-owner-resolution.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
orm-dataflow.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
parse-impl-chunk-concurrency.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
parse-impl-clone-skip.test.ts fix(parse): survive non-cloneable worker results so large-repo analyze doesn't crash (#2112) (#2135) 2026-06-10 13:47:22 +01:00
parse-impl-env-reads.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
parse-impl-large-fixture.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
parse-impl-progress-monotonic.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
parse-impl-quarantine-cache-skip.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
parsing.test.ts feat(ingestion): tree-sitter node-type/field validation gate + remove dead literals (#1937) 2026-05-31 10:29:41 +01:00
php-pipeline-benchmark.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
php-scope-capture-tripwire.test.ts perf(ingestion): linearize scope-capture across all languages + Python import resolution (O(n²)→O(n)) (#1918) 2026-05-30 19:44:22 +01:00
pipeline-graph-golden.test.ts fix(test): isolate cli-e2e from shared mini-repo fixture (#954) 2026-04-18 12:54:59 +01:00
pipeline.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
python-import-index-reuse.test.ts perf(ingestion): linearize scope-capture across all languages + Python import resolution (O(n²)→O(n)) (#1918) 2026-05-30 19:44:22 +01:00
python-scope-capture-tripwire.test.ts perf(ingestion): linearize scope-capture across all languages + Python import resolution (O(n²)→O(n)) (#1918) 2026-05-30 19:44:22 +01:00
qualified-class-lookups.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
query-compilation.test.ts [dart] Add call patterns for await, cascade, lambda, and widget-tree contexts (#801) 2026-04-13 11:21:11 +01:00
ruby-pipeline-benchmark.test.ts perf(ingestion): Linux-kernel-scale analysis — worker-pool parse + finalize O(n²) + scope-resolution memory wall (#1983) (#2038) 2026-06-06 22:46:34 +01:00
ruby-scope-capture-tripwire.test.ts perf(ingestion): linearize scope-capture across all languages + Python import resolution (O(n²)→O(n)) (#1918) 2026-05-30 19:44:22 +01:00
rust-pipeline-benchmark.test.ts feat(rust): Migrate Rust to scope-based resolution (RFC #909 Ring 3) (#1639) 2026-05-25 13:20:08 +01:00
rust-scope-capture-tripwire.test.ts perf(ingestion): linearize scope-capture across all languages + Python import resolution (O(n²)→O(n)) (#1918) 2026-05-30 19:44:22 +01:00
search-core.test.ts fix: Use Ladybug native read-only enforcement and prepared statement execution for Cypher query paths (#1655) 2026-05-18 06:54:24 +01:00
search-pool.test.ts fix(search): surface warning when FTS indexes are missing (#1418) 2026-05-08 17:05:18 +01:00
server-analyze.test.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
server-http-startup.test.ts fix(server): restore gitnexus serve startup under Express 5 (#1749) 2026-05-21 10:18:09 +01:00
setup-antigravity.test.ts feat(setup): implement antigravity integration setup and hook adapter… (#1730) 2026-05-25 14:46:17 +01:00
setup-skills.test.ts fix(setup): correct OpenCode skills install path in status message (#1386) 2026-05-07 14:27:49 +01:00
setup-uninstall-roundtrip.test.ts feat(cli): add gitnexus uninstall to reverse setup (#2060) (#2062) 2026-06-09 10:50:18 +01:00
shape-check-regression.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
skills-e2e.test.ts feat(csharp): migrate C# to registry-primary scope-resolution (Closes #934) (#1019) 2026-04-23 12:38:13 +01:00
spring-route-pipeline.test.ts feat(ingestion): Java Spring route annotation → Route node extraction (#2078) 2026-06-10 09:44:56 +01:00
staleness-and-stability.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
swift-scope-capture-tripwire.test.ts feat(swift): migrate Swift to scope-based registry resolution (#937) (#1948) 2026-05-31 16:56:47 +01:00
taint-explain.test.ts feat(taint): interprocedural taint via function summaries over resolved CALLS (#2084) (#2179) 2026-06-13 07:04:14 +01:00
tree-sitter-languages.test.ts fix(go): capture multi-name declarations (#2032) 2026-06-06 04:47:17 +01:00
vue-pipeline-benchmark.test.ts feat(vue): migrate Vue SFC to scope-based resolution (RFC #909 Ring 3, closes #940) (#1950) 2026-06-03 21:48:38 +01:00
worker-pool.test.ts fix(analyze): prevent cache-hit native workers from aborting (#1751) 2026-05-21 16:17:02 +01:00