feat: add Super Alpha research, management and MCP workflows
Deploy production / deploy (push) Successful in 56s
Deploy production / deploy (push) Successful in 56s
This commit is contained in:
@@ -27,25 +27,47 @@ class SimulationSettings(Contract):
|
||||
maxPosition: Literal["ON", "OFF"] = "OFF"
|
||||
|
||||
|
||||
class SuperSimulationSettings(SimulationSettings):
|
||||
"""SUPER-only selection settings; platform metadata still determines availability."""
|
||||
|
||||
selectionHandling: Literal["POSITIVE", "NON_ZERO", "NON_NAN"]
|
||||
selectionLimit: int = Field(ge=1, le=100000, strict=True)
|
||||
componentActivation: Literal["IS", "OS"]
|
||||
|
||||
|
||||
class Candidate(Contract):
|
||||
client_item_id: str = Field(min_length=1, max_length=100)
|
||||
expression: str = Field(min_length=1, max_length=20000)
|
||||
settings: SimulationSettings
|
||||
alpha_type: Literal["REGULAR"] = "REGULAR"
|
||||
expression: str = Field(default="", max_length=20000)
|
||||
selection: str | None = Field(default=None, max_length=20000)
|
||||
combo: str | None = Field(default=None, max_length=20000)
|
||||
settings: SuperSimulationSettings | SimulationSettings
|
||||
alpha_type: Literal["REGULAR", "SUPER"] = "REGULAR"
|
||||
|
||||
@field_validator("expression")
|
||||
@field_validator("expression", "selection", "combo")
|
||||
@classmethod
|
||||
def nonempty(cls, value):
|
||||
value = value.strip()
|
||||
if not value:
|
||||
raise ValueError("表达式不能为空")
|
||||
return value
|
||||
return value.strip() if value is not None else None
|
||||
|
||||
@model_validator(mode="after")
|
||||
def typed_input(self):
|
||||
if self.alpha_type == "SUPER":
|
||||
if self.expression or not self.selection or not self.combo:
|
||||
raise ValueError("SUPER 必须提供非空 selection/combo,不能提供 regular expression")
|
||||
if not isinstance(self.settings, SuperSimulationSettings):
|
||||
raise ValueError("SUPER 必须提供 selectionHandling、selectionLimit、componentActivation")
|
||||
elif not self.expression or self.selection is not None or self.combo is not None or isinstance(self.settings, SuperSimulationSettings):
|
||||
raise ValueError("REGULAR 必须提供非空 expression,不能包含 SUPER 表达式或设置")
|
||||
return self
|
||||
|
||||
def platform_input(self):
|
||||
if self.alpha_type == "SUPER":
|
||||
return {"type": "SUPER", "selection": self.selection, "combo": self.combo,
|
||||
"settings": self.settings.model_dump()}
|
||||
return {"type": self.alpha_type, "regular": self.expression, "settings": self.settings.model_dump()}
|
||||
|
||||
|
||||
class Source(Contract):
|
||||
research_kind: str | None = Field(default=None, max_length=50)
|
||||
kind: str = Field(default="manual", min_length=1, max_length=100)
|
||||
reference: str | None = Field(default=None, max_length=200)
|
||||
batch_id: str | None = Field(default=None, max_length=200)
|
||||
@@ -54,6 +76,9 @@ class Source(Contract):
|
||||
research_id: str | None = Field(default=None, max_length=200)
|
||||
parent_run_id: str | None = Field(default=None, max_length=36)
|
||||
hypothesis: str | None = Field(default=None, max_length=2000)
|
||||
superalpha_plan_id: str | None = Field(default=None, max_length=36)
|
||||
superalpha_plan_version: int | None = Field(default=None, ge=1)
|
||||
selection_snapshot_ids: list[str] = Field(default_factory=list, max_length=100)
|
||||
|
||||
|
||||
class SourceOutput(Source):
|
||||
@@ -129,7 +154,7 @@ def fingerprint(payload: dict) -> str:
|
||||
|
||||
def group_key(candidate: dict):
|
||||
settings = candidate["settings"]
|
||||
return tuple(settings[k] for k in ("region", "delay", "language", "instrumentType"))
|
||||
return (candidate.get("alpha_type", "REGULAR"), *tuple(settings[k] for k in ("region", "delay", "language", "instrumentType")))
|
||||
|
||||
|
||||
class ReferenceInput(Contract):
|
||||
@@ -203,7 +228,10 @@ class ItemOutput(Contract):
|
||||
id: str
|
||||
client_item_id: str
|
||||
expression: str
|
||||
settings: SimulationSettings
|
||||
alpha_type: Literal["REGULAR", "SUPER"] = "REGULAR"
|
||||
selection: str | None = None
|
||||
combo: str | None = None
|
||||
settings: SuperSimulationSettings | SimulationSettings
|
||||
attempt_id: str
|
||||
platform_status: str
|
||||
collection_status: str
|
||||
|
||||
Reference in New Issue
Block a user