fix(dsh): recognize configured native models and pin diagnosis selection
Core regression / Python 3.12 core, intervention UI and release configuration (push) Failing after 20s
Core regression / JavaScript syntax (push) Successful in 4s
Core regression / Python 3.12 core, intervention UI and release configuration (pull_request) Failing after 20s
Core regression / JavaScript syntax (pull_request) Successful in 3s
Core regression / Python 3.12 core, intervention UI and release configuration (push) Failing after 20s
Core regression / JavaScript syntax (push) Successful in 4s
Core regression / Python 3.12 core, intervention UI and release configuration (pull_request) Failing after 20s
Core regression / JavaScript syntax (pull_request) Successful in 3s
This commit is contained in:
1 parent
eba935e710
commit
8837587ce9
9 files changed
+149
-36
No files matched your search
@@ -90,16 +90,18 @@ def test_dpapi_host_configuration_is_available_without_writes(tmp_path):
|
||||
assert {path.name: path.read_bytes() for path in directory.iterdir()} == before
|
||||
|
||||
|
||||
def test_real_native_route_survives_corrupt_unused_host_metadata(tmp_path):
|
||||
@pytest.mark.parametrize('explicit_default', [True, False])
|
||||
def test_real_native_route_survives_corrupt_unused_host_metadata(tmp_path, explicit_default):
|
||||
directory = tmp_path / 'dsh'
|
||||
patch = directory / 'harness-home/profiles/dx-task/cordis.patch.yml'
|
||||
patch.parent.mkdir(parents=True)
|
||||
(directory / 'provider.json').write_text('{invalid-unused-host', encoding='utf8')
|
||||
patch.write_text(json.dumps([
|
||||
rows = [
|
||||
{'id': 'llm-pi-ai', 'config': {'providers': {'native': {'api': 'openai-completions',
|
||||
'baseURL': 'https://example.invalid/v1', 'apiKeyEnv': 'FIXTURE_NATIVE_KEY',
|
||||
'models': [{'id': 'fixture-model'}]}}}},
|
||||
{'id': 'agent-default-model', 'config': {'provider': 'native', 'model': 'fixture-model'}}]), encoding='utf8')
|
||||
{'id': 'agent-default-model', 'config': {'provider': 'native', 'model': 'fixture-model'}}]
|
||||
patch.write_text(json.dumps(rows if explicit_default else rows[:1]), encoding='utf8')
|
||||
credentials = directory / 'harness-home/.credentials.yaml'
|
||||
credentials.write_text(json.dumps({'version': 1, 'refs': {'FIXTURE_NATIVE_KEY': 'fake-native-key'}}), encoding='utf8')
|
||||
before = {path: path.read_bytes() for path in directory.rglob('*') if path.is_file()}
|
||||
@@ -107,6 +109,7 @@ def test_real_native_route_survives_corrupt_unused_host_metadata(tmp_path):
|
||||
assert result['available'] is True, result
|
||||
assert result['source'] == 'native'
|
||||
assert result['environment_refs'] == []
|
||||
assert result['model_selection'] == {'provider': 'native', 'model': 'fixture-model'}
|
||||
assert 'fake-native-key' not in json.dumps(result)
|
||||
assert {path: path.read_bytes() for path in directory.rglob('*') if path.is_file()} == before
|
||||
|
||||
@@ -131,6 +134,33 @@ def test_native_extra_child_fields_are_discarded(tmp_path, monkeypatch):
|
||||
assert 'fake-do-not-return' not in json.dumps(availability.check_availability(tmp_path))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('selection', [None, [], 7, {'provider': 'p'},
|
||||
{'provider': 'p', 'model': 'm', 'reasoningEffort': None}, {'provider': 'p', 'model': '\n'}])
|
||||
def test_invalid_native_model_route_is_rejected(tmp_path, monkeypatch, selection):
|
||||
credentials = tmp_path / 'dsh/harness-home/.credentials.yaml'
|
||||
credentials.parent.mkdir(parents=True)
|
||||
credentials.write_text('{}', encoding='utf8')
|
||||
output = {'available': True, 'code': 'available', 'source': 'native',
|
||||
'environment_refs': [], 'model_selection': selection}
|
||||
monkeypatch.setattr(availability.subprocess, 'run', lambda *a, **k:
|
||||
SimpleNamespace(returncode=0, stdout=json.dumps(output), stderr=''))
|
||||
result = availability.check_availability(tmp_path)
|
||||
assert result['available'] is (selection is None)
|
||||
|
||||
|
||||
def test_native_reasoning_selection_is_preserved_without_extra_fields(tmp_path, monkeypatch):
|
||||
credentials = tmp_path / 'dsh/harness-home/.credentials.yaml'
|
||||
credentials.parent.mkdir(parents=True)
|
||||
credentials.write_text('{}', encoding='utf8')
|
||||
output = {'available': True, 'code': 'available', 'source': 'native', 'environment_refs': [],
|
||||
'model_selection': {'provider': 'p', 'model': 'm', 'reasoningEffort': 'high', 'secret': 'do-not-return'}}
|
||||
monkeypatch.setattr(availability.subprocess, 'run', lambda *a, **k:
|
||||
SimpleNamespace(returncode=0, stdout=json.dumps(output), stderr=''))
|
||||
result = availability.check_availability(tmp_path)
|
||||
assert result['model_selection'] == {'provider': 'p', 'model': 'm', 'reasoningEffort': 'high'}
|
||||
assert 'do-not-return' not in json.dumps(result)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('output', ['secret not json', '{"available":true,"code":"secret"}'])
|
||||
def test_native_invalid_output_is_fixed_safe_message(tmp_path, monkeypatch, output):
|
||||
patch = tmp_path / 'dsh/harness-home/profiles/dx-task/cordis.patch.yml'
|
||||
|
||||
Reference in new issue
Block a user