feat(app): add PoolStrategy Protocol to application ports

This commit is contained in:
2026-07-12 22:34:47 -04:00
parent 0d0f275134
commit cd5c9c01fb
2 changed files with 49 additions and 1 deletions
+26 -1
View File
@@ -8,8 +8,9 @@ from typing import TYPE_CHECKING, Any, Protocol, runtime_checkable
if TYPE_CHECKING:
import numpy as np
from app.harness.pools import Pools
from app.tree.index import TreeIndex
from core.types import GeneratedQuestion
from core.types import GeneratedQuestion, PoolConfig
@runtime_checkable
@@ -144,3 +145,27 @@ class PromptBuilderFactory(Protocol):
skills_dir: Path | None = None,
prompts_dir: Path | None = None,
) -> PromptBuilderFn: ...
@runtime_checkable
class PoolStrategy(Protocol):
"""池构建策略端口。
应用层端口(非 core 层),因为返回类型 Pools 定义在 app/harness/pools.py。
两个具体策略(GlobalPoolStrategy / PerCategoryPoolStrategy)实现此接口。
"""
def build(
self,
questions: list[GeneratedQuestion],
correctness: dict[str, bool],
config: PoolConfig,
) -> Pools: ...
def build_incremental(
self,
new_task_types: list[str],
questions: list[GeneratedQuestion],
correctness: dict[str, bool],
config: PoolConfig,
) -> dict[str, dict[str, list[str]]]: ...