mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-18 20:49:28 +00:00
feat(learning-harness): chat endpoint independent of embeddings, with the DeepSeek adapter
Task 1.2. Detectors, the classifier's model tier, the proposer and the judge resolve one chat endpoint: an explicit override first, then the scripted client flag, then an endpoint named in the config, then DeepSeek, then OpenRouter. Prove-order retrieval keeps its own embedding endpoint untouched, because the chat provider we default to offers none. The adapter handles the provider's documented quirks: thinking is on by default there and silently ignores temperature, so it is disabled explicitly; the reasoning field is kept on the reply for the caller to replay across tool turns; JSON mode has no schema and occasionally returns empty content, so one retry is built in, never a loop; token log-probabilities are requested only when the caller wants them, and their mean is what lets the classifier abstain. Cost comes from the provider's own usage fields, cache hits priced separately, and a model with no recorded price reports no cost rather than a made-up one. The endpoint record deliberately holds no key, so it is safe to journal. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01T7XD7x5KonMdmGRkp63EQG
This commit is contained in:
co-authored by
Claude Opus 5
parent
289648338c
commit
944df86d12
@@ -33,6 +33,9 @@ class ModelConfig:
|
||||
hunter: str | None = None
|
||||
verifier: str | None = None
|
||||
patcher: str | None = None
|
||||
judge: str | None = None # second, independent judgement before anything is published as proven
|
||||
chat_base_url: str | None = None # chat endpoint; independent of the embedding endpoint
|
||||
chat_api_key_env: str | None = None # environment variable holding that endpoint's key
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -135,6 +138,19 @@ class VariantsConfig:
|
||||
max_mechanisms: int = 500
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class LearningConfig:
|
||||
# learning-harness: the classified detector set and its rounds.
|
||||
families_path: str | None = None # taxonomy file; the shipped ruleset when unset
|
||||
configs_dir: str = ".openultrasast/learning/configs"
|
||||
k_runs: int = 5 # runs per pair; a single run misses most real changes
|
||||
round_cost_cap_usd: float = 10.0
|
||||
minibatch: int = 8 # train pairs in a round's first stage
|
||||
detector_model: str | None = None
|
||||
judge_model: str | None = None
|
||||
cutoff_date: str | None = None # rows fixed after this date are reported as a separate slice
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ObligationsConfig:
|
||||
# authorization-obligations: the obligation checker in MAP (standard/deep only).
|
||||
@@ -160,6 +176,7 @@ class ResolvedConfig:
|
||||
regress: RegressConfig = RegressConfig()
|
||||
variants: VariantsConfig = VariantsConfig()
|
||||
obligations: ObligationsConfig = ObligationsConfig()
|
||||
learning: LearningConfig = LearningConfig()
|
||||
runs_dir: str = ".openultrasast/runs"
|
||||
|
||||
|
||||
@@ -186,6 +203,7 @@ def load_config(config_path: Path | None = None) -> ResolvedConfig:
|
||||
regress=_load_regress(data.get("regress", {})),
|
||||
variants=_load_variants(data.get("variants", {})),
|
||||
obligations=_load_obligations(data.get("obligations", {})),
|
||||
learning=_load_learning(data.get("learning", {})),
|
||||
runs_dir=os.environ.get("OPENULTRASAST_RUNS_DIR", ".openultrasast/runs"),
|
||||
)
|
||||
|
||||
@@ -210,6 +228,9 @@ def _load_models(value: object) -> ModelConfig:
|
||||
hunter=_string(data.get("hunter")),
|
||||
verifier=_string(data.get("verifier")),
|
||||
patcher=_string(data.get("patcher")),
|
||||
judge=_string(data.get("judge")),
|
||||
chat_base_url=_string(data.get("chat_base_url")),
|
||||
chat_api_key_env=_string(data.get("chat_api_key_env")),
|
||||
)
|
||||
|
||||
|
||||
@@ -357,6 +378,20 @@ def _load_variants(value: object) -> VariantsConfig:
|
||||
)
|
||||
|
||||
|
||||
def _load_learning(value: object) -> LearningConfig:
|
||||
data = _section(value)
|
||||
return LearningConfig(
|
||||
families_path=_string(data.get("families_path")),
|
||||
configs_dir=_string(data.get("configs_dir")) or LearningConfig.configs_dir,
|
||||
k_runs=_int_value(data.get("k_runs"), LearningConfig.k_runs),
|
||||
round_cost_cap_usd=_float_value(data.get("round_cost_cap_usd"), LearningConfig.round_cost_cap_usd),
|
||||
minibatch=_int_value(data.get("minibatch"), LearningConfig.minibatch),
|
||||
detector_model=_string(data.get("detector_model")),
|
||||
judge_model=_string(data.get("judge_model")),
|
||||
cutoff_date=_string(data.get("cutoff_date")),
|
||||
)
|
||||
|
||||
|
||||
def _load_obligations(value: object) -> ObligationsConfig:
|
||||
data = _section(value)
|
||||
return ObligationsConfig(
|
||||
|
||||
Reference in New Issue
Block a user