mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-16 03:49:26 +00:00
chore(p0): drop never-enabled hunter tools, test-only functions and receiver delivery
Off every active line (PATHFINDER-2026-10-13/03-unified-proposal.md, cuts). Deleted: the four hunter tools no caller enables (read_definition, entry_points, flows, obligations) with their schemas and dispatch, the dead mapping branch of find_refs; 20 functions whose only caller was one test (mapping task records, compute_ranking_metrics, build_quick_hunter_prompt, validate_evidence_transition, should_fuse, harness processors, rank_targets_with_model, model/report slice rendering, taxonomy hierarchical/related, config_value.verdict, taint.verdict, roles.load_roles, features.language_of and build_for_scan, folds.leave_one_*, features.recorded_case, search BatchExecutor and the three __main__ shims, delivery.put_input); the receiver delivery mode of the plane. push_inputs.py moved to benchmarks/push. memory.purge stays: the live-S3 test cleanup uses it. Net: 2,730 lines deleted, 207 added. 473 targeted tests passed; 3,282 tests collect. breadth.toml records the removals. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
f5a904b7f2
commit
f63703a604
+4
-68
@@ -1,100 +1,36 @@
|
||||
import json
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
from openultrasast.config import load_config
|
||||
from openultrasast.harness import (
|
||||
HarnessContractError,
|
||||
HarnessEvent,
|
||||
HarnessRuntime,
|
||||
HarnessTraceWriter,
|
||||
ProcessorSpec,
|
||||
write_harness_config,
|
||||
)
|
||||
from openultrasast.harness import HarnessRuntime, HarnessTraceWriter, write_harness_config
|
||||
|
||||
|
||||
@dataclass
|
||||
class RecordingProcessor:
|
||||
spec: ProcessorSpec
|
||||
|
||||
def handle(self, event: HarnessEvent, state: dict[str, Any]) -> dict[str, Any]:
|
||||
return {"seen_stage": event.stage}
|
||||
|
||||
|
||||
@dataclass
|
||||
class BadWriteProcessor:
|
||||
spec: ProcessorSpec
|
||||
|
||||
def handle(self, event: HarnessEvent, state: dict[str, Any]) -> dict[str, Any]:
|
||||
return {"undeclared": event.event_type}
|
||||
|
||||
|
||||
def test_runtime_emits_stage_events_and_processor_state(tmp_path: Path) -> None:
|
||||
def test_runtime_emits_stage_events(tmp_path: Path) -> None:
|
||||
trace_path = tmp_path / "events.jsonl"
|
||||
processor = RecordingProcessor(ProcessorSpec(name="recorder", version="1", handles=("stage_start",), writes=("seen_stage",)))
|
||||
runtime = HarnessRuntime(
|
||||
scan_id="scan-1",
|
||||
config=load_config(None),
|
||||
trace_writer=HarnessTraceWriter(trace_path),
|
||||
processors=[processor],
|
||||
)
|
||||
|
||||
result = runtime.run_stage("preprocess", lambda: "ok")
|
||||
|
||||
events = [json.loads(line) for line in trace_path.read_text().splitlines()]
|
||||
assert result == "ok"
|
||||
assert runtime.state["seen_stage"] == "preprocess"
|
||||
assert [event["event_type"] for event in events] == ["stage_start", "stage_start", "stage_end"]
|
||||
assert events[1]["payload"] == {"changed_state": ["seen_stage"], "processor": "recorder"}
|
||||
assert [event["event_type"] for event in events] == ["stage_start", "stage_end"]
|
||||
|
||||
|
||||
def test_strict_contract_mode_rejects_undeclared_writes(tmp_path: Path) -> None:
|
||||
processor = BadWriteProcessor(ProcessorSpec(name="bad", version="1", handles=("stage_start",), writes=()))
|
||||
runtime = HarnessRuntime(
|
||||
scan_id="scan-1",
|
||||
config=load_config(None),
|
||||
trace_writer=HarnessTraceWriter(tmp_path / "events.jsonl"),
|
||||
processors=[processor],
|
||||
)
|
||||
|
||||
with pytest.raises(HarnessContractError, match="undeclared writes"):
|
||||
runtime.emit("stage_start", "rank", {})
|
||||
|
||||
|
||||
def test_warn_contract_mode_records_degradation(tmp_path: Path) -> None:
|
||||
processor = BadWriteProcessor(ProcessorSpec(name="bad", version="1", handles=("stage_start",), writes=()))
|
||||
runtime = HarnessRuntime(
|
||||
scan_id="scan-1",
|
||||
config=load_config(None),
|
||||
trace_writer=HarnessTraceWriter(tmp_path / "events.jsonl"),
|
||||
processors=[processor],
|
||||
contract_mode="warn",
|
||||
)
|
||||
|
||||
runtime.emit("stage_start", "rank", {})
|
||||
|
||||
assert "undeclared writes" in runtime.state["degradations"][0]
|
||||
assert '"status": "degraded"' in (tmp_path / "events.jsonl").read_text()
|
||||
|
||||
|
||||
def test_harness_config_serializes_models_processors_and_prompt_hashes(tmp_path: Path) -> None:
|
||||
def test_harness_config_serializes_models_and_prompt_hashes(tmp_path: Path) -> None:
|
||||
config_path = tmp_path / "openultrasast.toml"
|
||||
config_path.write_text('[models]\nranker = "openrouter/ranker"\n')
|
||||
processor = RecordingProcessor(ProcessorSpec(name="recorder", version="2026-01-01", handles=("stage_start",), writes=("seen_stage",)))
|
||||
output = tmp_path / "harness.json"
|
||||
|
||||
write_harness_config(
|
||||
config=load_config(config_path),
|
||||
processors=[processor],
|
||||
contract_mode="strict",
|
||||
path=output,
|
||||
prompts={"ranker": "score files"},
|
||||
)
|
||||
|
||||
payload = json.loads(output.read_text())
|
||||
assert payload["model_roles"]["ranker"] == "openrouter/ranker"
|
||||
assert payload["processor_versions"] == {"recorder": "2026-01-01"}
|
||||
assert len(payload["prompt_hashes"]["ranker"]) == 64
|
||||
|
||||
Reference in New Issue
Block a user