-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: protocols audit follow-up (REVIEW + fold pass) #1869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
82133e0
964a407
c47abca
690d1d0
ec29efa
89d975b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||
| """Heuristic rubric grader -- rule-based, deterministic.""" | ||||||
|
|
||||||
| from datetime import UTC, datetime | ||||||
| from typing import TYPE_CHECKING, Protocol | ||||||
| from typing import TYPE_CHECKING | ||||||
|
|
||||||
| from pydantic import BaseModel, ConfigDict, Field | ||||||
|
|
||||||
|
|
@@ -20,32 +20,11 @@ | |||||
| from synthorg.core.types import NotBlankStr | ||||||
| from synthorg.engine.quality.verification import AtomicProbe | ||||||
| from synthorg.engine.workflow.handoff import HandoffArtifact | ||||||
| from synthorg.settings.bridge_configs import EngineBridgeConfig | ||||||
|
|
||||||
| logger = get_logger(__name__) | ||||||
|
|
||||||
|
|
||||||
| class _HeuristicGraderBridge(Protocol): | ||||||
| """Structural type for the EngineBridgeConfig quality_heuristic_* fields. | ||||||
|
|
||||||
| Local Protocol declaration keeps the grader module free of a | ||||||
| runtime import of ``settings.bridge_configs``. The fields are | ||||||
| exposed as ``@property`` so this Protocol matches frozen Pydantic | ||||||
| models (whose attributes are read-only); mypy validates the | ||||||
| attribute mapping in ``from_bridge_config``. | ||||||
| """ | ||||||
|
|
||||||
| @property | ||||||
| def quality_heuristic_pass_threshold(self) -> float: ... | ||||||
| @property | ||||||
| def quality_heuristic_pass_grade(self) -> float: ... | ||||||
| @property | ||||||
| def quality_heuristic_fail_grade(self) -> float: ... | ||||||
| @property | ||||||
| def quality_heuristic_confidence_ceiling(self) -> float: ... | ||||||
| @property | ||||||
| def quality_heuristic_confidence_bias(self) -> float: ... | ||||||
|
|
||||||
|
|
||||||
| class HeuristicGraderConfig(BaseModel): | ||||||
| """Operator-tunable thresholds + per-criterion grades for the heuristic grader. | ||||||
|
|
||||||
|
|
@@ -70,15 +49,13 @@ class HeuristicGraderConfig(BaseModel): | |||||
| confidence_bias: float = Field(default=0.1, ge=0.0, le=1.0) | ||||||
|
|
||||||
| @classmethod | ||||||
| def from_bridge_config( | ||||||
| cls, bridge: _HeuristicGraderBridge | ||||||
| ) -> HeuristicGraderConfig: | ||||||
| def from_bridge_config(cls, bridge: EngineBridgeConfig) -> HeuristicGraderConfig: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
| """Project the heuristic-grader subset out of an ``EngineBridgeConfig``. | ||||||
|
|
||||||
| Typed via the local ``_HeuristicGraderBridge`` Protocol so mypy | ||||||
| validates the attribute mapping without a runtime import of | ||||||
| ``settings.bridge_configs`` (which would cycle through the | ||||||
| engine namespace). | ||||||
| ``EngineBridgeConfig`` is imported under ``TYPE_CHECKING`` so the | ||||||
| grader module stays free of a runtime dependency on | ||||||
| ``settings.bridge_configs`` (which would cycle through the engine | ||||||
| namespace). | ||||||
| """ | ||||||
| return cls( | ||||||
| pass_threshold=bridge.quality_heuristic_pass_threshold, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |||||
| :class:`RoutingScorerConfig` (resolved at construction time). | ||||||
| """ | ||||||
|
|
||||||
| from typing import TYPE_CHECKING, Final, Protocol | ||||||
| from typing import TYPE_CHECKING, Final | ||||||
|
|
||||||
| from pydantic import BaseModel, ConfigDict, Field, model_validator | ||||||
|
|
||||||
|
|
@@ -23,6 +23,7 @@ | |||||
| if TYPE_CHECKING: | ||||||
| from synthorg.core.agent import AgentIdentity | ||||||
| from synthorg.engine.decomposition.models import SubtaskDefinition | ||||||
| from synthorg.settings.bridge_configs import EngineBridgeConfig | ||||||
|
|
||||||
| logger = get_logger(__name__) | ||||||
|
|
||||||
|
|
@@ -37,33 +38,6 @@ | |||||
| _WEIGHT_SUM_WARN_CEILING: Final[float] = 1.3 # lint-allow: magic-numbers -- ceiling | ||||||
|
|
||||||
|
|
||||||
| class _RoutingScorerBridge(Protocol): | ||||||
| """Structural type for the EngineBridgeConfig fields the scorer reads. | ||||||
|
|
||||||
| Declared locally to break the import cycle that would otherwise | ||||||
| pull ``settings.bridge_configs`` into the engine routing module. | ||||||
| The fields are exposed as ``@property`` so this Protocol matches | ||||||
| frozen Pydantic models (whose attributes are read-only). Mypy | ||||||
| validates the attribute mapping in ``from_bridge_config`` against | ||||||
| this Protocol; any caller passing an object missing one of the | ||||||
| fields gets a static type error rather than a runtime | ||||||
| ``AttributeError``. | ||||||
| """ | ||||||
|
|
||||||
| @property | ||||||
| def routing_weight_primary_skill(self) -> float: ... | ||||||
| @property | ||||||
| def routing_weight_secondary_skill(self) -> float: ... | ||||||
| @property | ||||||
| def routing_weight_tag_match_bonus(self) -> float: ... | ||||||
| @property | ||||||
| def routing_weight_role_match_bonus(self) -> float: ... | ||||||
| @property | ||||||
| def routing_weight_seniority_alignment_bonus(self) -> float: ... | ||||||
| @property | ||||||
| def routing_min_score(self) -> float: ... | ||||||
|
|
||||||
|
|
||||||
| class RoutingScorerConfig(BaseModel): | ||||||
| """Operator-tunable configuration for :class:`AgentTaskScorer`. | ||||||
|
|
||||||
|
|
@@ -116,13 +90,13 @@ def _check_weight_sum(self) -> RoutingScorerConfig: | |||||
| return self | ||||||
|
|
||||||
| @classmethod | ||||||
| def from_bridge_config(cls, bridge: _RoutingScorerBridge) -> RoutingScorerConfig: | ||||||
| def from_bridge_config(cls, bridge: EngineBridgeConfig) -> RoutingScorerConfig: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
| """Project the routing-scorer subset out of an ``EngineBridgeConfig``. | ||||||
|
|
||||||
| Typed via the local ``_RoutingScorerBridge`` Protocol so mypy | ||||||
| validates the attribute mapping without forcing a runtime | ||||||
| import of ``settings.bridge_configs`` (which would create a | ||||||
| cycle through the engine namespace). | ||||||
| ``EngineBridgeConfig`` is imported under ``TYPE_CHECKING`` so the | ||||||
| routing module stays free of a runtime dependency on | ||||||
| ``settings.bridge_configs`` (which would cycle through the engine | ||||||
| namespace). | ||||||
| """ | ||||||
| return cls( | ||||||
| primary_skill_weight=bridge.routing_weight_primary_skill, | ||||||
|
|
||||||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace hard-coded counts with
<!--RS:NAME-->runtime-stats markersThese new/updated numeric values are committed as literals in a public docs file. Please source them from
data/runtime_stats.yamlvia<!--RS:NAME-->markers to prevent drift.As per coding guidelines, “Numerics in README and public docs sourced from
data/runtime_stats.yamlvia<!--RS:NAME-->markers.”Also applies to: 410-434
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai resolve
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Post
@coderabbitai resolveor@coderabbitai approveas a new top-level PR comment. Resolve/approve commands are disabled for review-thread replies.