Initial Open-SWE-Traces cleanup pipeline
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
"""Tests for deterministic static repair application and evidence preservation."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from swe_data_processing.repair import apply_static_repair
|
||||
|
||||
|
||||
def _plan() -> dict:
|
||||
return {
|
||||
"sample_id": "sample-1",
|
||||
"repair_decision": "APPLY_STATIC_REPAIR",
|
||||
"maximum_training_use": "ERROR_ANALYSIS",
|
||||
"invariants": {
|
||||
"resolved_unchanged": True,
|
||||
"tool_outputs_unchanged": True,
|
||||
"model_patch_unchanged": True,
|
||||
"reference_patch_unchanged": True,
|
||||
"no_synthetic_execution_result": True,
|
||||
},
|
||||
"operations": [
|
||||
{
|
||||
"op": "REWRITE_FINAL_SUMMARY",
|
||||
"target_turns": [5],
|
||||
"preconditions": ["Turn 5 is an assistant-only summary."],
|
||||
"replacement": "The build passed, but functional behavior remains unverified.",
|
||||
"reason": "Remove an unsupported success claim.",
|
||||
}
|
||||
],
|
||||
"requires_second_review": True,
|
||||
"summary": "Correct the final claim without changing execution evidence.",
|
||||
}
|
||||
|
||||
|
||||
def test_rewrite_summary_preserves_tool_output_and_patch() -> None:
|
||||
record = {
|
||||
"trajectory_id": "sample-1",
|
||||
"resolved": -1,
|
||||
"trajectory": [
|
||||
{"role": "system", "content": "system"},
|
||||
{"role": "user", "content": "issue"},
|
||||
{"role": "assistant", "content": "build", "tool_calls": []},
|
||||
{"role": "tool", "content": "build completed with exit code 0"},
|
||||
{"role": "assistant", "content": "All tests pass.", "tool_calls": []},
|
||||
],
|
||||
"metadata": {
|
||||
"model_patch": {"patch": "+++ b/src/a.py\n"},
|
||||
"reference_patch": {"patch": "+++ b/src/a.py\n"},
|
||||
},
|
||||
}
|
||||
repaired, diff = apply_static_repair(record, _plan())
|
||||
assert repaired["trajectory"][3] == record["trajectory"][3]
|
||||
assert repaired["trajectory"][4]["content"].startswith("The build passed")
|
||||
assert repaired["metadata"] == record["metadata"]
|
||||
assert diff["replaced_original_turn_ids"] == [5]
|
||||
Reference in New Issue
Block a user