Tyapkin
Demo

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.

Capkin extension previewsimulated CAP IR playback

Multi-path risk policy run

Один Capkin contract, три исполняемых пути: позитивный approval, badlist rejection и review-required для крупной суммы без EnhancedKyc.

Что происходит сейчас

Выбери путь: approved, badlist rejection или review-required.

Capkin source

three scenarios, one contract

risk-gated-swap.featureextension-bound
01Feature: Risk-gated cross-network DEX swap
03 Background:
04 Given machine RiskGatedSwapbound
05 And principal DEXbound
06 And principal Compliancebound
07 And principal RiskOraclebound
08 And capability DEX may commit SwapInputbound
09 And capability RiskOracle may commit WalletRiskObservationbound
10 And capability Compliance may evaluate SwapPolicybound
11 And capability DEX may commit SwapExecutionOutputbound
13 Scenario: Swap is approved when wallet, network and risk policy pass
14 Given DEX commits SwapInputbound
15 And RiskOracle commits WalletRiskObservationbound
16 When Compliance evaluates guard SwapPolicybound
17 And the policy requires network to be one of Ethereum, Base, Arbitrumbound
18 And the policy rejects wallet when it is in Badlistbound
19 And the policy rejects transfer when RiskScore exceeds 70bound
20 And the policy rejects transfer when AmountUsd exceeds 10000 without EnhancedKycbound
21 Then the machine transitions from Requested to Approvedbound
22 And DEX may commit SwapExecutionOutputbound
23 And the trace proof verifies every commitmentbound
24 And the trace proof verifies exactly 6 commitmentsbound
26 Scenario: Swap is rejected when wallet is badlisted
27 Given DEX commits SwapInput
28 And RiskOracle commits WalletRiskObservation
29 When Compliance evaluates guard SwapPolicy
30 And the policy rejects wallet when it is in Badlist
31 Then the machine transitions from Requested to Rejected
32 And the trace proof verifies every commitment
34 Scenario: Swap requires enhanced KYC for large transfer
35 Given DEX commits SwapInput
36 And RiskOracle commits WalletRiskObservation
37 When Compliance evaluates guard SwapPolicy
38 And the policy rejects transfer when AmountUsd exceeds 10000 without EnhancedKyc
39 Then the machine transitions from Requested to ReviewRequired
40 And the trace proof verifies every commitment
Execution playback

Wallet чистый, network разрешен, risk ниже лимита.

01

Bind contract

Compiler связывает RiskGatedSwap, principals и capabilities.

02

Verify capabilities

DEX, RiskOracle и Compliance получают строго объявленные полномочия.

03

Commit SwapInput

DEX фиксирует вход: Ethereum, wallet, amountUsd=4200.

04

Commit risk observation

RiskOracle фиксирует RiskScore=31 и отсутствие badlist hit.

05

Evaluate SwapPolicy

Compliance запускает составной guard.

06

Network allowlist passes

Ethereum входит в разрешенный список Ethereum/Base/Arbitrum.

07

Badlist predicate passes

Wallet не найден в Badlist.

08

Risk predicate passes

RiskScore=31 не превышает лимит 70.

09

Amount predicate passes

AmountUsd=4200 не требует EnhancedKyc.

10

Transition approved

CAP machine переходит Requested -> Approved.

11

Commit SwapExecutionOutput

DEX выпускает output только после Approved.

12

Verify proof obligations

Verifier проверяет every commitment и exact commitment count.

CAP projection

simulated compiled trace output

machineRiskGatedSwap
scenarioPolicy passes
stateApproved
proofevery commitment + exactly 6 commitments
fresh commitmentswaiting for run

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 commitments

Intended 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 trace

Extension 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 commitment
Scenario: 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 commitment

Build Plan

  1. Extend Capkin Step Expressions for policy predicates.
  2. Add typed CAP IR nodes for PolicyPredicate and GuardComposition.
  3. Extend protobuf contract shape.
  4. Add Rust runtime fixtures for approved, rejected and review paths.
  5. Render the scenario in the docs live playback UI.

On this page