Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(update): surface the two silent embedder degradations (#1370) (#2107)

Nehal kanak kuniyil thottathilc57b42a6b423
diff --git a/packages/cli/src/repowise/cli/commands/update_cmd/command.py b/packages/cli/src/repowise/cli/commands/update_cmd/command.py
index e1daf9d14..56577cf53 100644
--- a/packages/cli/src/repowise/cli/commands/update_cmd/command.py
+++ b/packages/cli/src/repowise/cli/commands/update_cmd/command.py
@@ -1712,7 +1712,7 @@ def run_update(
# Build the shared vector store once: reused by the supersession detector
# below and by the decision upsert in _persist (semantic dedup + search).
- decision_vector_store = _build_update_vector_store(repo_path, cfg)
+ decision_vector_store = _build_update_vector_store(repo_path, cfg, degraded)
# --- Two-pass decision evolution (Phase 3C), BEFORE page regeneration ----
# Cross-reference the diff + new commit bodies against existing decisions
diff --git a/packages/cli/src/repowise/cli/commands/update_cmd/incremental.py b/packages/cli/src/repowise/cli/commands/update_cmd/incremental.py
index 67f5b1e7b..b134474d0 100644
--- a/packages/cli/src/repowise/cli/commands/update_cmd/incremental.py
+++ b/packages/cli/src/repowise/cli/commands/update_cmd/incremental.py
@@ -13,7 +13,9 @@ from repowise.cli.helpers import console, run_async
from repowise.core.pipeline import PhaseTimings, timed
-def _build_update_vector_store(repo_path: Any, cfg: dict) -> Any | None:
+def _build_update_vector_store(
+ repo_path: Any, cfg: dict, degraded: list[str] | None = None
+) -> Any | None:
"""Build the shared page/decision vector store for the update path.
Phase-2 follow-up + Phase-3 requirement: ``repowise update`` historically
@@ -22,14 +24,19 @@ def _build_update_vector_store(repo_path: Any, cfg: dict) -> Any | None:
runs. We mirror ``init``'s store construction (LanceDB at
``.repowise/lancedb`` so previously-embedded decisions are matchable; the
in-memory store is a degraded fallback that only sees this run's vectors).
- Returns ``None`` on any failure — the decision upsert still works without it.
+ Returns ``None`` on any failure — the decision upsert still works without
+ it. A failure is recorded in *degraded* (when given) so the run's degraded
+ panel says why semantic dedup is off instead of silently skipping it
+ (issue #1370).
"""
try:
from repowise.cli.providers import build_embedder, build_vector_store, resolve_embedder
embedder = build_embedder(resolve_embedder(cfg.get("embedder")), repo_path)
return build_vector_store(repo_path, embedder)
- except Exception:
+ except Exception as exc:
+ if degraded is not None:
+ degraded.append(f"Decision vector store: {type(exc).__name__}: {exc}")
return None
diff --git a/packages/cli/src/repowise/cli/commands/update_cmd/persistence.py b/packages/cli/src/repowise/cli/commands/update_cmd/persistence.py
index d7f541dda..c43acd770 100644
--- a/packages/cli/src/repowise/cli/commands/update_cmd/persistence.py
+++ b/packages/cli/src/repowise/cli/commands/update_cmd/persistence.py
@@ -10,6 +10,7 @@ from __future__ import annotations
import contextlib
import os
+import sys
import time
from pathlib import Path
from typing import Any
@@ -1344,7 +1345,15 @@ def _full_rescore_interval_days() -> float:
try:
return max(0.0, float(raw))
except ValueError:
- pass
+ # Say it where the user will actually see it: a silently-ignored
+ # value makes the rescore cadence look deliberate when it is
+ # actually the default (issue #1370). stderr matches how
+ # build_embedder reports the same class of misconfiguration.
+ print(
+ f"REPOWISE_FULL_RESCORE_INTERVAL_DAYS={raw!r} is not a number; "
+ f"using the default {_FULL_RESCORE_INTERVAL_DAYS} days.",
+ file=sys.stderr,
+ )
return _FULL_RESCORE_INTERVAL_DAYS
diff --git a/tests/unit/cli/test_health_rescore_gate.py b/tests/unit/cli/test_health_rescore_gate.py
index 2a5482fde..537adaa96 100644
--- a/tests/unit/cli/test_health_rescore_gate.py
+++ b/tests/unit/cli/test_health_rescore_gate.py
@@ -10,12 +10,35 @@ from __future__ import annotations
import pytest
from repowise.cli.commands.update_cmd.persistence import (
+ _full_rescore_interval_days,
full_rescore_due,
health_analyzer_changed,
)
from repowise.core.analysis.health import HEALTH_ANALYZER_VERSION
+class TestRescoreIntervalEnv:
+ """REPOWISE_FULL_RESCORE_INTERVAL_DAYS parsing (issue #1370)."""
+
+ def test_valid_value_parses(self, monkeypatch, capsys) -> None:
+ monkeypatch.setenv("REPOWISE_FULL_RESCORE_INTERVAL_DAYS", "3.5")
+ assert _full_rescore_interval_days() == 3.5
+ assert capsys.readouterr().err == ""
+
+ def test_invalid_value_warns_on_stderr(self, monkeypatch, capsys) -> None:
+ """A malformed value must not silently default — say it out loud."""
+ monkeypatch.setenv("REPOWISE_FULL_RESCORE_INTERVAL_DAYS", "soon")
+ assert _full_rescore_interval_days() == 7.0
+ err = capsys.readouterr().err
+ assert "REPOWISE_FULL_RESCORE_INTERVAL_DAYS" in err
+ assert "soon" in err
+
+ def test_unset_uses_default_silently(self, monkeypatch, capsys) -> None:
+ monkeypatch.delenv("REPOWISE_FULL_RESCORE_INTERVAL_DAYS", raising=False)
+ assert _full_rescore_interval_days() == 7.0
+ assert capsys.readouterr().err == ""
+
+
class TestHealthAnalyzerChanged:
def test_absent_stamp_is_not_a_change(self):
"""A legacy state file must not read as drift.
diff --git a/tests/unit/cli/test_update_vector_store_degraded.py b/tests/unit/cli/test_update_vector_store_degraded.py
new file mode 100644
index 000000000..e9b5b5629
--- /dev/null
+++ b/tests/unit/cli/test_update_vector_store_degraded.py
@@ -0,0 +1,48 @@
+"""Tests for the update path's decision vector store (issue #1370).
+
+``_build_update_vector_store`` swallows failures and returns None so the
+decision upsert still works without a store — but the failure must land in
+the run's ``degraded`` list, or the panel says nothing while semantic dedup
+is silently off.
+"""
+
+from __future__ import annotations
+
+from unittest.mock import patch
+
+from repowise.cli.commands.update_cmd.incremental import _build_update_vector_store
+
+
+def test_failure_is_recorded_in_degraded() -> None:
+ """A store build failure must surface in the degraded list."""
+ degraded: list[str] = []
+ with patch(
+ "repowise.cli.providers.build_embedder",
+ side_effect=RuntimeError("boom"),
+ ):
+ assert _build_update_vector_store("/tmp/repo", {"embedder": "ollama"}, degraded) is None
+ assert any("Decision vector store" in d and "boom" in d for d in degraded)
+
+
+def test_failure_without_degraded_stays_silent() -> None:
+ """Callers without a degraded list keep the old silent contract."""
+ with patch(
+ "repowise.cli.providers.build_embedder",
+ side_effect=RuntimeError("boom"),
+ ):
+ assert _build_update_vector_store("/tmp/repo", {"embedder": "ollama"}) is None
+
+
+def test_success_returns_the_store() -> None:
+ """A healthy build returns the store and records nothing."""
+ degraded: list[str] = []
+ store = object()
+ with patch(
+ "repowise.cli.providers.build_embedder",
+ return_value=object(),
+ ), patch(
+ "repowise.cli.providers.build_vector_store",
+ return_value=store,
+ ):
+ assert _build_update_vector_store("/tmp/repo", {"embedder": "ollama"}, degraded) is store
+ assert degraded == []