Complex Compliance Demo
Planned multi-level Capkin scenario for DEX risk, network policy and badlist guards.
Complex Compliance Demo
This page captures the next demo target. It is intentionally richer than the current MVP runtime: the goal is to validate the extension model before we wire every predicate into Rust fixtures. The blocks below are proposed syntax, not executable Capkin. The current compiler rejects these unregistered policy and exact-count phrases. Before implementation, each phrase needs a typed IR node, validator and runner binding; canonical Feature/Scenario IDs must then be registered.
Multi-path risk policy run
Один Capkin contract, три исполняемых пути: позитивный approval, badlist rejection и review-required для крупной суммы без EnhancedKyc.
Что происходит сейчас
Выбери путь: approved, badlist rejection или review-required.
three scenarios, one contract
Feature: Risk-gated cross-network DEX swap Background: Given machine RiskGatedSwapbound And principal DEXbound And principal Compliancebound And principal RiskOraclebound And capability DEX may commit SwapInputbound And capability RiskOracle may commit WalletRiskObservationbound And capability Compliance may evaluate SwapPolicybound And capability DEX may commit SwapExecutionOutputbound Scenario: Swap is approved when wallet, network and risk policy pass Given DEX commits SwapInputbound And RiskOracle commits WalletRiskObservationbound When Compliance evaluates guard SwapPolicybound And the policy requires network to be one of Ethereum, Base, Arbitrumbound And the policy rejects wallet when it is in Badlistbound And the policy rejects transfer when RiskScore exceeds 70bound And the policy rejects transfer when AmountUsd exceeds 10000 without EnhancedKycbound Then the machine transitions from Requested to Approvedbound And DEX may commit SwapExecutionOutputbound And the trace proof verifies every commitmentbound And the trace proof verifies exactly 6 commitmentsbound Scenario: Swap is rejected when wallet is badlisted Given DEX commits SwapInput And RiskOracle commits WalletRiskObservation When Compliance evaluates guard SwapPolicy And the policy rejects wallet when it is in Badlist Then the machine transitions from Requested to Rejected And the trace proof verifies every commitment Scenario: Swap requires enhanced KYC for large transfer Given DEX commits SwapInput And RiskOracle commits WalletRiskObservation When Compliance evaluates guard SwapPolicy And the policy rejects transfer when AmountUsd exceeds 10000 without EnhancedKyc Then the machine transitions from Requested to ReviewRequired And the trace proof verifies every commitmentWallet чистый, network разрешен, risk ниже лимита.
Bind contract
Compiler связывает RiskGatedSwap, principals и capabilities.
Verify capabilities
DEX, RiskOracle и Compliance получают строго объявленные полномочия.
Commit SwapInput
DEX фиксирует вход: Ethereum, wallet, amountUsd=4200.
Commit risk observation
RiskOracle фиксирует RiskScore=31 и отсутствие badlist hit.
Evaluate SwapPolicy
Compliance запускает составной guard.
Network allowlist passes
Ethereum входит в разрешенный список Ethereum/Base/Arbitrum.
Badlist predicate passes
Wallet не найден в Badlist.
Risk predicate passes
RiskScore=31 не превышает лимит 70.
Amount predicate passes
AmountUsd=4200 не требует EnhancedKyc.
Transition approved
CAP machine переходит Requested -> Approved.
Commit SwapExecutionOutput
DEX выпускает output только после Approved.
Verify proof obligations
Verifier проверяет every commitment и exact commitment count.
simulated compiled trace output
Scenario Shape
Feature: RiskGatedSwap
Background:
Given machine RiskGatedSwap
And principal DEX
And principal Compliance
And principal RiskOracle
And capability DEX may commit SwapInput
And capability RiskOracle may commit WalletRiskObservation
And capability Compliance may evaluate SwapPolicy
And capability DEX may commit SwapExecutionOutput
Scenario: CAPKIN-COMPLIANCE-APPROVE-001
Given DEX commits SwapInput
And RiskOracle commits WalletRiskObservation
When Compliance evaluates guard SwapPolicy
And the policy requires network to be one of Ethereum, Base, Arbitrum
And the policy rejects wallet when it is in Badlist
And the policy rejects transfer when RiskScore exceeds 70
And the policy rejects transfer when AmountUsd exceeds 10000 without EnhancedKyc
Then the machine transitions from Requested to Approved
And DEX may commit SwapExecutionOutput
And the trace proof verifies every commitment
And the trace proof verifies exactly 6 commitmentsIntended CAP Mapping
Machine:
RiskGatedSwap
Principals:
DEX
Compliance
RiskOracle
Inputs:
SwapInput
WalletRiskObservation
Guard:
SwapPolicy
Predicates:
network in [Ethereum, Base, Arbitrum]
wallet not in Badlist
RiskScore <= 70
AmountUsd <= 10000 OR EnhancedKyc == true
Transition:
Requested -> Approved
Output:
SwapExecutionOutput
Proof expectations:
every commitment verifies
exactly 6 commitments exist in traceExtension Requirements
This demo requires capkin-compliance to define:
{network}parameter type;{wallet}parameter type;{riskScore}parameter type;{amountUsd}parameter type;- policy predicate expressions;
- guard composition semantics;
- rejected transition semantics;
- proof expectations for exact commitment counts.
Negative Scenarios
The same feature should include rejected paths:
Scenario: CAPKIN-COMPLIANCE-REJECT-001
Given DEX commits SwapInput
And RiskOracle commits WalletRiskObservation
When Compliance evaluates guard SwapPolicy
And the policy rejects wallet when it is in Badlist
Then the machine transitions from Requested to Rejected
And the trace proof verifies every commitmentScenario: CAPKIN-COMPLIANCE-REVIEW-001
Given DEX commits SwapInput
And RiskOracle commits WalletRiskObservation
When Compliance evaluates guard SwapPolicy
And the policy rejects transfer when AmountUsd exceeds 10000 without EnhancedKyc
Then the machine transitions from Requested to ReviewRequired
And the trace proof verifies every commitmentBuild Plan
- Extend Capkin Step Expressions for policy predicates.
- Add typed CAP IR nodes for
PolicyPredicateandGuardComposition. - Extend protobuf contract shape.
- Add Rust runtime fixtures for approved, rejected and review paths.
- Render the scenario in the docs live playback UI.