Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/quant_platform_kit/common/paper_execution_admission.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,13 @@ def evaluate_paper_execution_admission(
except (TypeError, ValueError):
return _halted(command, [PaperExecutionAdmissionFinding.RECEIPT_INVALID.value])

# ``decision_digest`` is the producer's immutable strategy-decision
# digest, calculated before the admission receipt is added to the command
# intent. The command ID then content-addresses the complete intent,
# including this receipt, so both directions are bound without a digest
# self-reference.
if receipt.decision_digest != command.decision_digest:
_append_finding(findings, PaperExecutionAdmissionFinding.COMMAND_BINDING_MISMATCH.value)
if receipt.strategy_profile != command.strategy_profile:
_append_finding(findings, PaperExecutionAdmissionFinding.COMMAND_BINDING_MISMATCH.value)
if receipt.effective_session != command.effective_date:
Expand Down
14 changes: 12 additions & 2 deletions tests/test_paper_execution_admission.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ def _receipt(
*,
disposition: PaperRiskAdmissionDisposition = PaperRiskAdmissionDisposition.ALLOW_NEW_RISK,
reason_codes: tuple[str, ...] = (),
decision_digest: str = "d" * 64,
) -> PaperRiskAdmissionReceipt:
release = _release_identity()
return build_paper_risk_admission_receipt(
strategy_profile="soxl_soxx_trend_income",
release_id=release["release_id"],
risk_policy_sha256=release["risk_policy_sha256"],
decision_digest="d" * 64,
decision_digest=decision_digest,
effective_session="2026-08-25",
disposition=disposition,
reason_codes=reason_codes,
Expand All @@ -61,7 +62,7 @@ def _command(
receipt: PaperRiskAdmissionReceipt | None = None,
include_receipt: bool = True,
execution_mode: str = "paper",
decision_digest: str = "sha256:decision-v1",
decision_digest: str = "d" * 64,
strategy_profile: str = "soxl_soxx_trend_income",
effective_date: str = "2026-08-25",
) -> ExecutionCommand:
Expand Down Expand Up @@ -194,6 +195,15 @@ def test_command_release_and_policy_bindings_are_exact(self) -> None:
(PaperExecutionAdmissionFinding.COMMAND_BINDING_MISMATCH.value,),
)

decision_mismatch = evaluate_paper_execution_admission(
command=_command(decision_digest="f" * 64),
expected_strategy_release=self.release,
)
self.assertEqual(
decision_mismatch.integrity_findings,
(PaperExecutionAdmissionFinding.COMMAND_BINDING_MISMATCH.value,),
)

release_receipt = _receipt().to_dict()
release_receipt["release_id"] = "other-p2-v3.20260824"
release_receipt["receipt_sha256"] = calculate_paper_risk_admission_receipt_sha256(release_receipt)
Expand Down