fix(research): remove template scope constraints and migrate stored templates
Deploy production / deploy (push) Successful in 55s

This commit is contained in:
yuxuanhui
2026-09-20 10:17:07 +08:00
parent 34f1a4fa77
commit 07dd767c52
7 changed files with 190 additions and 4 deletions
+22
View File
@@ -585,3 +585,25 @@ async def test_native_bot_creates_template_and_immutable_version(app, logged_in)
assert conflict.value.status_code == 409
old = (await logged_in.get(f"/api/v1/research/assets/{created['id']}?version=1")).json()
assert old["content"]["description"] == "测试经济假设"
@pytest.mark.parametrize("candidate_settings", [{"region": "EUR"}, {"universe": "TOP1000"}, {"delay": 0}])
async def test_preparation_scope_must_still_match_candidate_settings(app, logged_in, research_input, candidate_settings):
body = expansion(research_input["id"])
body["input_ids"] = []
body["preparation_refs"] = [{"id": research_input["preparation_id"], "version": research_input["preparation_version"]}]
body["settings"].update(candidate_settings)
response = await logged_in.post("/api/v1/research/experiments", json=body)
assert response.status_code == 422 and "输入快照与研究范围不一致" in response.text
async with app.state.sessions() as db:
assert await db.scalar(select(func.count()).select_from(ResearchExperiment)) == 0
async def test_template_contract_rejects_removed_scope(logged_in):
from app.research.workspace_contracts import TemplateSpec
content = template() | {"scope": SCOPE}
response = await logged_in.post("/api/v1/research/assets", json={"kind": "template", "content": content})
assert response.status_code == 422, response.text
assert "scope" in response.text
assert "scope" not in TemplateSpec.model_json_schema()["properties"]