SPDX-License-Identifier: AGPL-3.0-or-later¶
Commercial license available¶
© Concepts 1996–2026 Miroslav Šotek. All rights reserved.¶
© Code 2020–2026 Miroslav Šotek. All rights reserved.¶
ORCID: 0009-0009-3560-0851¶
Contact: www.anulum.li | protoscience@anulum.li¶
SCPN Phase Orchestrator — Autotune replay policy search API reference¶
Autotune Replay Policy Search¶
The replay policy-search API is the non-actuating bridge between deterministic candidate generation and future learner-backed autotune loops. It generates bounded candidates around a seed policy, delegates each candidate to a replay or simulation evaluator, and returns a reviewable proposal record.
The evaluator is deliberately supplied by the caller. Production integrations should connect it to replay buffers, dry-run simulation, or hardware-in-the-loop shadow evaluation before a proposal is considered for deployment.
from scpn_phase_orchestrator.autotune import (
AdaptiveReplayPolicySearchConfig,
KnobPolicyCandidate,
OfflinePolicySearchConfig,
PolicyProposalConfig,
RewardObservation,
SafetyConstraintConfig,
search_replay_policy,
)
seed = KnobPolicyCandidate(
K=0.2,
alpha=0.0,
zeta=0.05,
Psi=0.1,
channel_weights=(1.0, 0.8),
cross_channel_gains=(0.3, 0.5),
)
def replay(candidate: KnobPolicyCandidate) -> RewardObservation:
return RewardObservation(
coherence=0.82,
previous_coherence=0.74,
lyapunov_exponent=-0.015,
stl_robustness=0.08,
safety_cost=0.01,
)
result = search_replay_policy(
seed,
replay,
search_config=OfflinePolicySearchConfig(
K_step=0.05,
channel_weight_step=0.1,
cross_channel_gain_step=0.1,
max_abs_knob=1.0,
),
proposal_config=PolicyProposalConfig(
min_coherence=0.75,
safety_constraints=SafetyConstraintConfig(
max_lyapunov_exponent=0.0,
min_stl_robustness=0.0,
max_safety_cost=0.05,
require_lyapunov=True,
require_stl=True,
require_safety_cost=True,
),
),
)
audit_record = result.to_audit_record()
For bounded learner-style refinement without enabling live actuation, use the adaptive search wrapper. It repeatedly evaluates replay candidates around the best replay-scored candidate, decays the coordinate step sizes, and then applies the same final proposal gates across all replay observations:
from scpn_phase_orchestrator.autotune import search_adaptive_replay_policy
adaptive_result = search_adaptive_replay_policy(
seed,
replay,
adaptive_config=AdaptiveReplayPolicySearchConfig(
base_search_config=OfflinePolicySearchConfig(
K_step=0.05,
zeta_step=0.02,
max_abs_knob=1.0,
),
iterations=3,
step_decay=0.5,
),
proposal_config=PolicyProposalConfig(min_coherence=0.75),
)
adaptive_audit_record = adaptive_result.to_audit_record()
The result keeps the seed, generated candidates, and proposal together so audit logs can prove which replay-only candidates were evaluated before a policy was accepted or rejected.
When SafetyConstraintConfig is attached to PolicyProposalConfig, the search
will reject candidates that lack required Lyapunov or STL evidence, exceed the
configured Lyapunov exponent bound, violate the STL robustness floor, or exceed
the safety-cost ceiling. These gates run after replay scoring and before a
proposal is accepted, so the search cannot promote a high-reward candidate that
fails the explicit safety evidence contract.
Practical overview¶
This page is the control bridge between experimentation and controlled deployment:
- Generate candidates (bounded).
- Score in replay/simulation (comparative).
- Enforce safety gates (governance).
- Emit one auditable proposal record (promotion boundary).
The design is intentionally conservative because it prevents “good-scoring but unsafe” candidates from silently entering a deployment lane. This pattern is the same pattern used across safety-critical control stacks where model uncertainty and environmental shift can produce false positives.
Review and audit interpretation¶
Replay search is only as useful as its provenance. Keep the evaluator deterministic for a given seed and profile, and record search configurations so repeated runs can compare:
- candidate envelopes,
- proposal thresholds,
- safety boundary settings.
That evidence makes it possible to justify in review why a specific search depth or step size was chosen, and why rejected candidates were blocked.
Why this module exists in the control chain¶
This module is the non-actuating candidate-evaluation stage for the autotune path. Its output is a proposal record with explicit admission decisions, not a control command.
In practice:
- it produces bounded candidate candidates from a seed profile,
- evaluates those candidates through an external replay/adaptation function,
- enforces safety and stability gates,
- returns a single auditable record for downstream review and promotion.
That structure is the reason this page stays review-first: replay and offline validation complete before any policy path that may write to a physical actuator.
policy_search ¶
Replay-only policy search helpers for autotune candidates.
Classes¶
AdaptiveReplayPolicySearchConfig
dataclass
¶
AdaptiveReplayPolicySearchConfig(
base_search_config: OfflinePolicySearchConfig = OfflinePolicySearchConfig(),
iterations: int = 3,
step_decay: float = 0.5,
improvement_tolerance: float = 0.0,
min_step: float = 0.0,
)
Bounded adaptive search settings for replay-only autotune.
Methods:¶
__post_init__ ¶
Validate adaptive search bounds and canonical integer fields.
Source code in src/scpn_phase_orchestrator/autotune/policy_search.py
ReplayPolicySearchResult
dataclass
¶
ReplayPolicySearchResult(
seed: KnobPolicyCandidate,
candidates: tuple[KnobPolicyCandidate, ...],
proposal: AutotunePolicyProposal,
)
Replay-only policy-search result suitable for audit review.
Methods:¶
__post_init__ ¶
Validate the seed, generated candidates, and review proposal.
Source code in src/scpn_phase_orchestrator/autotune/policy_search.py
to_audit_record ¶
Return a serialisable search record.
Returns¶
dict[str, object] A serialisable search record.
Source code in src/scpn_phase_orchestrator/autotune/policy_search.py
AdaptiveReplayPolicySearchResult
dataclass
¶
AdaptiveReplayPolicySearchResult(
seed: KnobPolicyCandidate,
rounds: tuple[ReplayPolicySearchResult, ...],
proposal: AutotunePolicyProposal,
config: AdaptiveReplayPolicySearchConfig,
)
Multi-round replay-only policy-search result for audit review.
Methods:¶
__post_init__ ¶
Validate the multi-round adaptive replay-search record.
Source code in src/scpn_phase_orchestrator/autotune/policy_search.py
to_audit_record ¶
Return a serialisable adaptive-search record.
Returns¶
dict[str, object] A serialisable adaptive-search record.
Source code in src/scpn_phase_orchestrator/autotune/policy_search.py
Functions:¶
search_replay_policy ¶
search_replay_policy(
seed: KnobPolicyCandidate,
evaluator: ReplayPolicyEvaluator,
search_config: OfflinePolicySearchConfig | None = None,
reward_config: RewardConfig | None = None,
proposal_config: PolicyProposalConfig | None = None,
) -> ReplayPolicySearchResult
Generate, replay-evaluate, and propose an autotune policy.
The evaluator must be a replay or simulation adapter. This helper never applies control actions directly; it only turns candidate observations into the existing reviewable proposal record.
Parameters¶
seed : KnobPolicyCandidate Seed for the deterministic RNG. evaluator : ReplayPolicyEvaluator The objective evaluator. search_config : OfflinePolicySearchConfig | None The search configuration. reward_config : RewardConfig | None The reward configuration. proposal_config : PolicyProposalConfig | None The proposal configuration.
Returns¶
ReplayPolicySearchResult Generate, replay-evaluate, and propose an autotune policy.
Raises¶
TypeError If an argument has the wrong type. ValueError If the inputs are invalid or inconsistent.
Source code in src/scpn_phase_orchestrator/autotune/policy_search.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
search_adaptive_replay_policy ¶
search_adaptive_replay_policy(
seed: KnobPolicyCandidate,
evaluator: ReplayPolicyEvaluator,
adaptive_config: AdaptiveReplayPolicySearchConfig
| None = None,
reward_config: RewardConfig | None = None,
proposal_config: PolicyProposalConfig | None = None,
) -> AdaptiveReplayPolicySearchResult
Run bounded adaptive replay-only policy search.
Each round generates deterministic coordinate-search candidates around the current best replay candidate, then shrinks the coordinate step sizes. The final proposal is still built from replay observations and existing review gates; no candidate is applied directly.
Parameters¶
seed : KnobPolicyCandidate Seed for the deterministic RNG. evaluator : ReplayPolicyEvaluator The objective evaluator. adaptive_config : AdaptiveReplayPolicySearchConfig | None Adaptive-tuning configuration. reward_config : RewardConfig | None The reward configuration. proposal_config : PolicyProposalConfig | None The proposal configuration.
Returns¶
AdaptiveReplayPolicySearchResult Bounded adaptive replay-only policy search.
Raises¶
TypeError If an argument has the wrong type. ValueError If the inputs are invalid or inconsistent.
Source code in src/scpn_phase_orchestrator/autotune/policy_search.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |