Repository navigation
The ingest pass and loom code describe skip the description writer on the fake LLM
#1679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
orshih6
wants to merge
4
commits into
ClickHouse:main
Choose a base branch
from
orshih6:contribot/issue-1557
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+129
−2
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3b85794
The ingest pass and `loom code describe` skip the description writer …
orshih6 062ebc3
Merge branch 'main' into contribot/issue-1557
orshih6 6b6eb2c
The describe CLI guard test patches llm_is_fake so its injected clien…
orshih6 a17587c
The marked-chunk describe test patches llm_is_fake so its injected cl…
orshih6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| """The description writer never runs on the fake LLM client. | ||
|
|
||
| With `llm.provider = fake` (or a keyed provider whose key is absent, which falls | ||
| back to the fake client) the fake's echo would be stored as the chunk's `llm` | ||
| description and embedded. The ingest pass gives those chunks structural context | ||
| instead, and `loom code describe` refuses to start.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import argparse | ||
| from types import SimpleNamespace | ||
| from typing import Any | ||
|
|
||
| import pytest | ||
|
|
||
| from server.code.app.index import pass_stream | ||
| from server.code.app.index.pass_budget import CodeIngestResult | ||
| from server.llm import client as llm_client | ||
| from server.settings import settings | ||
|
|
||
|
|
||
| def _stream() -> pass_stream.CommitStream: | ||
| cfg = SimpleNamespace( | ||
| org="o", namespace="ns", path_prefixes=(), embed_reuse_from=None, git_dir="/nowhere" | ||
| ) | ||
| return pass_stream.CommitStream(cfg, None, "head", "base", ["sha"], CodeIngestResult()) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def prepare_env(monkeypatch: pytest.MonkeyPatch) -> None: | ||
| async def under_cap(*_a: Any) -> bool: | ||
| return False | ||
|
|
||
| async def no_denylist(*_a: Any) -> None: | ||
| return None | ||
|
|
||
| monkeypatch.setattr(settings, "code_context_description_enabled", True) | ||
| monkeypatch.setattr("server.observability.budget.namespace_over_cap", under_cap) | ||
| monkeypatch.setattr("server.code.app.index.denylist.load_denylist", no_denylist) | ||
| monkeypatch.setattr("server.embedding.embedder.get_embedder", lambda: object()) | ||
|
|
||
|
|
||
| def _no_client() -> Any: | ||
| raise AssertionError("the description writer must not build a client") | ||
|
|
||
|
|
||
| async def test_a_fake_provider_describes_nothing( | ||
| monkeypatch: pytest.MonkeyPatch, prepare_env: None | ||
| ) -> None: | ||
| monkeypatch.setattr(settings, "llm_provider", "fake") | ||
| monkeypatch.setattr(llm_client, "get_llm_client", _no_client) | ||
| stream = _stream() | ||
| ctx = await stream._prepare() | ||
| assert ctx["describe"] is False | ||
| assert ctx["llm"] is None | ||
| assert stream.result.note == "describe skipped: the llm provider is fake" | ||
|
|
||
|
|
||
| async def test_a_keyed_provider_without_its_key_describes_nothing( | ||
| monkeypatch: pytest.MonkeyPatch, prepare_env: None | ||
| ) -> None: | ||
| monkeypatch.setattr(settings, "llm_provider", "anthropic") | ||
| monkeypatch.setattr(llm_client, "provider_key_missing", lambda _p: True) | ||
| monkeypatch.setattr(llm_client, "get_llm_client", _no_client) | ||
| ctx = await _stream()._prepare() | ||
| assert ctx["describe"] is False | ||
| assert ctx["llm"] is None | ||
|
|
||
|
|
||
| async def test_a_real_provider_still_describes( | ||
| monkeypatch: pytest.MonkeyPatch, prepare_env: None | ||
| ) -> None: | ||
| real = object() | ||
| monkeypatch.setattr(llm_client, "llm_is_fake", lambda: False) | ||
| monkeypatch.setattr(llm_client, "get_llm_client", lambda: real) | ||
| ctx = await _stream()._prepare() | ||
| assert ctx["describe"] is True | ||
| assert ctx["llm"] is real | ||
|
|
||
|
|
||
| async def test_the_describe_cli_refuses_a_fake_provider( | ||
| monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str] | ||
| ) -> None: | ||
| from server.cli import code_maintenance | ||
|
|
||
| async def no_connect(*_a: Any) -> None: | ||
| raise AssertionError("refused before connecting") | ||
|
|
||
| monkeypatch.setattr(settings, "llm_provider", "fake") | ||
| monkeypatch.setattr(llm_client, "get_llm_client", _no_client) | ||
| monkeypatch.setattr(code_maintenance, "connect_code_plane", no_connect) | ||
| assert await code_maintenance._describe(argparse.Namespace()) == 2 | ||
| assert "fake llm" in capsys.readouterr().err |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.