Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(init): keep size-skip notices and progress tips out of state degraded (#3272)
Aman6ba50aaeee6b
diff --git a/packages/cli/src/repowise/cli/ui/progress.py b/packages/cli/src/repowise/cli/ui/progress.pyindex 45675fbdc..fe0c9cbbc 100644--- a/packages/cli/src/repowise/cli/ui/progress.py+++ b/packages/cli/src/repowise/cli/ui/progress.py@@ -13,6 +13,11 @@ from rich.text import Textfrom repowise.cli.ui.brand import ERR, WARN, print_phase_header+# Message levels that mean "this run degraded". ``notice`` is deliberately not+# here: it is visible (warning-styled) but informational, e.g. a file skipped on+# size or a "this may take a while" tip.+_DEGRADING_LEVELS = frozenset({"warning", "error"})+# Top-level stage → (phase number, title, subtitle). The pipeline announces the# stage; how it is numbered and worded is the screen's business, and the screen# is the only side that knows generation and persistence follow.@@ -216,9 +221,15 @@ class RichProgressCallback:# 12,431 files", "Languages: …"), and rendering those in the same green# as "✓ Database updated" made green mean "the pipeline said something"# rather than "this succeeded".- style_map = {"warning": WARN, "error": ERR}+ #+ # ``notice`` is rendered with the warning style so it stays visible, but+ # it is not a degradation: size-skip lines and progress tips are+ # informational. Only ``warning`` and ``error`` are collected into+ # ``self.warnings``, which ``init`` persists as ``state["degraded"]`` and+ # the MCP server then reports on every reply.+ style_map = {"warning": WARN, "error": ERR, "notice": WARN}style = style_map.get(level, "")- if level in style_map:+ if level in _DEGRADING_LEVELS:self.warnings.append(redact_secrets(text))# Insight lines (indented with →) get special formattingif text.lstrip().startswith("→"):diff --git a/packages/core/src/repowise/core/pipeline/phases/ingestion.py b/packages/core/src/repowise/core/pipeline/phases/ingestion.pyindex b7e50790e..69854f752 100644--- a/packages/core/src/repowise/core/pipeline/phases/ingestion.py+++ b/packages/core/src/repowise/core/pipeline/phases/ingestion.py@@ -209,12 +209,12 @@ def _emit_traversal_summary("unreadable": "could not be read",}.get(skipped_source.reason, f"over the {ceiling_kb:,} KB limit")progress.on_message(- "warning",+ "notice",f" Not indexed: {skipped_source.path} "f"({skipped_source.size_kb:,} KB, {detail})",)if getattr(stats, "skipped_source_files_truncated", False):- progress.on_message("warning", " ...and more source files skipped on size")+ progress.on_message("notice", " ...and more source files skipped on size")if stats.lang_counts:ranked = sorted(stats.lang_counts.items(), key=lambda item: -item[1])@@ -635,12 +635,14 @@ async def _run_ingestion(# opaque "graph 0/1" spinner.if progress and len(file_infos) >= _SLOW_GRAPH_BUILD_FILES:# Reassurance before the longest silent stretch of the run, so it is- # warning-weight rather than another dim stat — which is also why it is+ # rendered warning-weight rather than another dim stat (a "notice", not+ # a "warning": it is not a degradation and must not be persisted into+ # state.json["degraded"]) — which is also why it is# gated: on a small repo the build is over in under a second, and a# yellow "this may take several minutes" there is a false alarm made# louder.progress.on_message(- "warning",+ "notice","Graph build can take several minutes on a first run. Safe to Ctrl-C — ""re-run 'repowise init --resume' to continue where it stopped.",)diff --git a/packages/core/src/repowise/core/pipeline/progress.py b/packages/core/src/repowise/core/pipeline/progress.pyindex 794c78912..9d45efd81 100644--- a/packages/core/src/repowise/core/pipeline/progress.py+++ b/packages/core/src/repowise/core/pipeline/progress.py@@ -90,7 +90,12 @@ class ProgressCallback(Protocol):...def on_message(self, level: str, text: str) -> None:- """Emit a free-form message. *level* is 'info', 'warning', or 'error'."""+ """Emit a free-form message.++ *level* is 'info', 'notice', 'warning', or 'error'. 'notice' is shown+ prominently but is not a degradation (size-skip lines, progress tips);+ only 'warning' and 'error' are persisted as ``state["degraded"]``.+ """...def on_stage(self, stage: str) -> None:@@ -114,7 +119,7 @@ class LoggingProgressCallback:logger.info("phase_done", phase=phase)def on_message(self, level: str, text: str) -> None:- getattr(logger, level, logger.info)(text)+ getattr(logger, "info" if level == "notice" else level, logger.info)(text)def on_stage(self, stage: str) -> None:logger.info("stage_start", stage=stage)diff --git a/packages/server/src/repowise/server/job_executor.py b/packages/server/src/repowise/server/job_executor.pyindex cb1fdb448..aa077ba36 100644--- a/packages/server/src/repowise/server/job_executor.py+++ b/packages/server/src/repowise/server/job_executor.py@@ -202,7 +202,8 @@ class JobProgressCallback:def on_message(self, level: str, text: str) -> None:if self._events is not None:self._events.add(level, text)- getattr(logger, level, logger.info)(text, job_id=self._job_id, phase=self._phase)+ log_level = "info" if level == "notice" else level+ getattr(logger, log_level, logger.info)(text, job_id=self._job_id, phase=self._phase)def _sync_job_status(self, *, force: bool = False) -> None:"""Fire-and-forget progress update in the current event loop.diff --git a/tests/unit/cli/test_progress_non_tty.py b/tests/unit/cli/test_progress_non_tty.pyindex db2ff068a..314011832 100644--- a/tests/unit/cli/test_progress_non_tty.py+++ b/tests/unit/cli/test_progress_non_tty.py@@ -285,3 +285,46 @@ def test_a_swallowed_pipeline_failure_is_now_reported(phase_fn: str) -> None:assert "skipped (boom)" in buf.getvalue()assert callback.warnings and "skipped (boom)" in callback.warnings[0]+++def test_notices_are_shown_but_not_recorded_as_degradation() -> None:+ """Size-skip lines and progress tips are informational, not degradations.++ ``init`` persists ``callback.warnings`` as ``state["degraded"]`` and the MCP+ server serves it on every reply, so a ``notice`` must render but never be+ collected (#3185).+ """+ console, buf = _non_tty_console()+ with Progress(TextColumn("{task.description}"), console=console) as bar:+ callback = RichProgressCallback(bar, console)+ callback.on_message("notice", " Not indexed: big.cs (9,745 KB, over the 2,048 KB limit)")+ callback.on_message("warning", "Execution flow tracing skipped (boom)")++ assert "Not indexed: big.cs" in buf.getvalue()+ assert callback.warnings == ["Execution flow tracing skipped (boom)"]+++def test_size_skipped_files_do_not_reach_state_degraded() -> None:+ """End to end through init's collection: a skipped large file leaves+ ``state["degraded"]`` empty, while a real degradation still lands there."""+ from repowise.core.ingestion.traverser import SkippedSourceFile+ from repowise.core.pipeline.phases.ingestion import _emit_traversal_summary++ class _Stats:+ total_paths_walked = 10+ lang_counts: ClassVar[dict] = {}+ skipped_source_files: ClassVar[list] = [+ SkippedSourceFile("src/TestData.g.cs", 9745, "over_max_size"),+ SkippedSourceFile("src/hw.h", 520, "minified"),+ ]+ skipped_source_files_truncated = True++ console, buf = _non_tty_console()+ with Progress(TextColumn("{task.description}"), console=console) as bar:+ callback = RichProgressCallback(bar, console)+ _emit_traversal_summary(callback, _Stats(), included=8)+ assert callback.warnings == []+ callback.on_message("warning", "Git indexing skipped: boom")++ assert "Not indexed: src/TestData.g.cs" in buf.getvalue()+ assert callback.warnings == ["Git indexing skipped: boom"]