Skip to content

feat: bind promotion runners to risk provenance - #294

Merged
Pigbibi merged 1 commit into
mainfrom
codex/qsl-p3-soxl-qpk-risk-provenance-20260805
Aug 5, 2026
Merged

feat: bind promotion runners to risk provenance#294
Pigbibi merged 1 commit into
mainfrom
codex/qsl-p3-soxl-qpk-risk-provenance-20260805

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • require an exact runner_kind="real" marker for promotion-runner registration and execution while preserving ordinary non-promotion test runners
  • bind promotion risk assessment to typed candidate/mandate provenance and preserve exactly-once RiskEngine.assess
  • add fail-closed proportional multi-asset sizing and reduce-only normalization validation
  • correct the exact synthetic evidence-package acceptance fixture with the required real-runner marker

Verification

  • focused: 89 passed, 73 subtests passed
  • corrected fixture: 1 passed
  • full: 893 passed, 1 skipped, 76 subtests passed
  • Ruff, compileall, direct imports, diff/scope/secret checks: PASS
  • offline package build (--no-isolation, /tmp): PASS

Boundaries

  • exact 10-path write set; no dependency or pin changes
  • no provider/data acquisition, real backtest, promotion decision, runtime, deploy, broker, order, capital, paper/shadow/live action

Co-Authored-By: Codex <noreply@openai.com>
@Pigbibi
Pigbibi merged commit f8a1444 into main Aug 5, 2026
1 check passed
@Pigbibi
Pigbibi deleted the codex/qsl-p3-soxl-qpk-risk-provenance-20260805 branch August 5, 2026 08:47

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7538d2b5d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

observed = float(observed_effective_exposure)
if (
not math.isfinite(cap)
or not 0.0 <= cap <= _BOOTSTRAP_EFFECTIVE_EXPOSURE_CAP

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow reduce-only validation to use mandate caps

The risk gate passes the mandate's effective_exposure_cap into this helper, and _mandate_fields accepts mandate caps up to 1.0. With this hard 0.50 bootstrap ceiling, a valid mandate such as cap=0.75 reducing an observed 1.0 exposure to a target 0.75 is marked invalid_reduce_only_normalization, so assess_with_evidence falls back to max(observed, target) and rejects with exposure errors instead of allowing the reduce-only transition. Use the mandate cap directly rather than the bootstrap constant here.

Useful? React with 👍 / 👎.

Comment on lines +239 to +242
"candidate_identity_sha256": self.candidate_identity_sha256,
"decision_digest_sha256": self.decision_digest_sha256,
"portfolio_snapshot_digest_sha256": self.portfolio_snapshot_digest_sha256,
"normalization_origin_digest_sha256": self.normalization_origin_digest_sha256,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bump the risk assessment contract version

Adding candidate_identity_sha256 and normalization_origin_digest_sha256 to the canonical RiskGateAssessment payload changes both the required receipt shape and the assessment_sha256 computation, but assess_with_evidence still emits qsl.risk_gate_assessment.v1. Consumers comparing or validating stored v1 receipts cannot distinguish old hashes from the new schema, so this should use a new contract version when these fields participate in the digest.

Useful? React with 👍 / 👎.

scope: str,
mandate_provenance: Mapping[str, Any] | None,
market_data: Mapping[str, Any],
candidate_identity: CandidateRiskIdentity | None = None,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Export the typed candidate identity from the risk facade

Mandated calls to assess_with_evidence now reject without a CandidateRiskIdentity, but the package facade in src/quant_platform_kit/risk/__init__.py still does not import or list that class in __all__. Callers using the existing quant_platform_kit.risk API can access assess_with_evidence but cannot construct the required typed identity from the same public surface, causing integrations to hit missing_candidate_identity unless they know to reach into risk.contracts.

Useful? React with 👍 / 👎.

Comment on lines +426 to 427
runner_kind = getattr(runner, "runner_kind", None)
if runner_kind != "real":

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep ordinary optimizer runners compatible

In the run_optimization path, _auto_register_runner is registering an ordinary BacktestRunner that is then used by run_grid_search, and that protocol only requires run(...); it does not include a runner_kind marker. With this exact check, existing real domain factories that predate the marker now raise RuntimeError before any non-promotion optimization can run, even though promotion execution is separately gated in BacktestOrchestrator.run_promotion.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant