close guardrail gaps and fix the scoring pipeline top to bottom
Constraint resolver: aggregate mass/footprint across a combo instead of pairwise-only checks, treat medium/atmosphere as agreement not supply/demand, reduce multi-provider checks by best/sum instead of AND-ing every provider, fail closed on unrecognized mutex values, add a propulsion-viability (thrust-to-weight) rule. Seed data updated to match (nuclear/solar-sail footprint floors, water-medium exclusions, explicit ground/gravity providers). Domain metric units were stored globally per metric name instead of per-domain, silently corrupting cost_efficiency for every domain but the first one seeded — fixed with a schema migration. Stub estimator's cost_efficiency/safety/availability/reliability were a backwards formula and flat constants; replaced with heuristics grounded in each entity's thrust_profile/energy_form/infrastructure. LLM estimate_physics() now receives each metric's unit and expected range instead of a bare name, fixing wildly miscalibrated estimates traced back to the prompt's own hardcoded example anchoring the model to the wrong order of magnitude. Sharpened the safety-estimation and plausibility-review prompts. Deduped provider parsing logic into llm/parsing.py. Web pipeline form can now pick an LLM provider per run instead of only via server env var. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,36 +1,10 @@
|
||||
"""Tests for the Ollama provider's parsing logic and registry wiring."""
|
||||
"""Tests for the Ollama provider's registry wiring."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from physcom.llm.providers.ollama import OllamaLLMProvider
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def provider():
|
||||
return OllamaLLMProvider()
|
||||
|
||||
|
||||
def test_parse_json_strips_fences(provider):
|
||||
text = '```json\n{"power_density": 500.0, "safety": 0.7}\n```'
|
||||
result = provider._parse_json(text, ["power_density", "safety"])
|
||||
assert result == {"power_density": 500.0, "safety": 0.7}
|
||||
|
||||
|
||||
def test_parse_json_falls_back_on_invalid(provider):
|
||||
result = provider._parse_json("not json", ["power_density", "safety"])
|
||||
assert result == {"power_density": 0.5, "safety": 0.5}
|
||||
|
||||
|
||||
def test_parse_verdict_plausible(provider):
|
||||
assert provider._parse_verdict("blah blah\nVERDICT: PLAUSIBLE") is True
|
||||
|
||||
|
||||
def test_parse_verdict_implausible(provider):
|
||||
assert provider._parse_verdict("blah blah\nVERDICT: IMPLAUSIBLE") is False
|
||||
|
||||
|
||||
def test_registry_builds_ollama_provider(monkeypatch):
|
||||
from physcom.llm.registry import build_llm_provider
|
||||
|
||||
|
||||
Reference in New Issue
Block a user