mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-23 00:41:36 +00:00
* Initial plan * fix(analyze): preserve existing embeddings by default; add --drop-embeddings opt-out Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/da1da041-afcd-4d38-8a2f-39ca52a462ff Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com> * analyze: --force on embedded repo now regenerates embeddings (preserve+top-up) Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/e2759765-b8f6-453a-8c28-595439d23cb4 Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com> * analyze: wire dropEmbeddings into HTTP API; log cache-load failures; extract pure deriveEmbeddingMode + behavioral tests; sync GUARDRAILS.md Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/7d88e595-cbd8-47b2-ba4f-fb5b9a60cda4 Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>
54 lines
2.1 KiB
TypeScript
54 lines
2.1 KiB
TypeScript
/**
|
|
* Pure derivation of the embedding-mode flags for `runFullAnalysis`.
|
|
*
|
|
* Lives in its own module (no native imports) so the branching contract can
|
|
* be unit-tested without spinning up LadybugDB, tree-sitter, or any of the
|
|
* other side-effecting dependencies pulled in by `run-analyze.ts`.
|
|
*
|
|
* Semantics:
|
|
* --drop-embeddings -> wipe (skip cache load entirely)
|
|
* --embeddings -> load cache, restore, then generate
|
|
* --force + existing>0 -> load cache, restore, then generate (regenerate top-up)
|
|
* (default) + existing>0 -> preserve only (load + restore, no generation)
|
|
* any path with existing=0 -> no cache work, no preservation
|
|
*/
|
|
|
|
export interface EmbeddingModeInput {
|
|
force?: boolean;
|
|
embeddings?: boolean;
|
|
dropEmbeddings?: boolean;
|
|
}
|
|
|
|
export interface EmbeddingMode {
|
|
/** True when phase 4 should run the embedding generation pipeline. */
|
|
shouldGenerateEmbeddings: boolean;
|
|
/** True when we should load the cache to re-insert vectors after rebuild without generating new ones. */
|
|
preserveExistingEmbeddings: boolean;
|
|
/** True when `--force` upgraded a default analyze into a regeneration because the repo was already embedded. */
|
|
forceRegenerateEmbeddings: boolean;
|
|
/** True when we need to load cached embeddings from the existing DB before the rebuild. */
|
|
shouldLoadCache: boolean;
|
|
}
|
|
|
|
export function deriveEmbeddingMode(
|
|
options: EmbeddingModeInput,
|
|
existingEmbeddingCount: number,
|
|
): EmbeddingMode {
|
|
const hasExisting = existingEmbeddingCount > 0;
|
|
const drop = !!options.dropEmbeddings;
|
|
const explicit = !!options.embeddings;
|
|
const force = !!options.force;
|
|
|
|
const forceRegenerateEmbeddings = force && !explicit && !drop && hasExisting;
|
|
const preserveExistingEmbeddings =
|
|
!explicit && !drop && !forceRegenerateEmbeddings && hasExisting;
|
|
const shouldGenerateEmbeddings = explicit || forceRegenerateEmbeddings;
|
|
const shouldLoadCache = !drop && (shouldGenerateEmbeddings || preserveExistingEmbeddings);
|
|
|
|
return {
|
|
shouldGenerateEmbeddings,
|
|
preserveExistingEmbeddings,
|
|
forceRegenerateEmbeddings,
|
|
shouldLoadCache,
|
|
};
|
|
}
|