Skip to content
cccskills
FreePublished on GitHub

formal-spec-z3-verifier

Expert guide for mathematical formal verification, SMT solver constraints (Z3, Dafny, TLA+), invariant theorem proving for FinTech billing state machines, RBAC/ABAC authorization, and zero-violation architecture / Panduan ahli verifikasi formal matematis, SMT solver (Z3, Dafny, TLA+), pembuktian invarian state machine billing FinTech, otorisasi RBAC/ABAC, dan arsitektur zero-violation.

The English summary is being prepared. Showing the original description.

roedyrustam/vibes-plug114 stars(GitHub 114 + cccskills 0)
Works withPostgreSQL

Run score Not tested

See how to install

Files included (1)

  • SKILL.md9.6 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

formal-spec-z3-verifier — vibes-plug Skill

English | Bahasa Indonesia


<a name="english"></a>

English

Orchestration & Integration

  • FinTech & SaaS Billing: saas-billing, doku-payment-gateway, payment-gateway-expert
  • Identity & Authorization Proofs: authentication-identity-expert, zero-trust-secret-vault
  • Database & Constraint Enforcement: database-orm-expert, spec-driven-development-expert
  • Testing & Mutation Verification: property-mutation-testing-expert, autonomous-tdd-debugger, anti-slop
  • Lifecycle & Governance: brainstorming, zero-to-prod-orchestrator, session-memory-manager

Description

Production guide for applying formal methods, mathematical specifications, and SMT (Satisfiability Modulo Theories) solvers (Z3, Dafny, TLA+) to mission-critical software systems. Proves zero-invariant violation across double-entry ledger bookkeeping, billing subscription state machines, multi-tenant isolation boundaries, and cryptographic key lifecycle models.

Trigger Conditions

Activate this skill when:

  • Designing financial ledgers, wallets, or payment gateway state transition graphs.
  • Verifying complex RBAC/ABAC permission rules to guarantee that privilege escalation is mathematically impossible.
  • Modeling concurrent or distributed state machines where race conditions could cause state desynchronization.
  • Formulating formal invariant specifications prior to backend ORM and database schema generation.

Core Concepts & Patterns

1. Invariant Specification Matrix

System DomainMathematical InvariantSolver Check
Double-Entry FinTech Ledger$\sum \text{Debits} - \sum \text{Credits} = 0 \land \forall a, \text{balance}(a) \ge 0$Prove balance preservation across all concurrent transactions
SaaS Billing State Machine$\text{State} \in { \text{Trial}, \text{Active}, \text{PastDue}, \text{Canceled} }$ with strict monotonic transitionsProve unreachable illegal transition (e.g. Canceled $\to$ Active without Payment)
Multi-Tenant Authorization$\forall r \in \text{Resources}, \text{TenantId}(r) = \text{Session}(\text{TenantId})$Prove satisfiability of data leakage equals $\emptyset$

2. Financial Ledger Invariant Verifier (Z3 TypeScript/Python Pattern)

export interface LedgerEntry {
  accountId: string;
  debit: number;
  credit: number;
}

export interface VerificationResult {
  isSound: boolean;
  counterExample?: string;
  message: string;
}

export class LedgerFormalVerifier {
  public static verifyTransactionBalance(entries: LedgerEntry[]): VerificationResult {
    if (entries.length < 2) {
      return {
        isSound: false,
        message: 'A valid double-entry transaction must contain at least two entries.'
      };
    }

    let totalDebit = 0;
    let totalCredit = 0;

    for (const entry of entries) {
      if (entry.debit < 0 || entry.credit < 0) {
        return {
          isSound: false,
          counterExample: JSON.stringify(entry),
          message: 'Negative debit or credit amounts violate non-negative entry invariant.'
        };
      }
      if (entry.debit > 0 && entry.credit > 0) {
        return {
          isSound: false,
          counterExample: JSON.stringify(entry),
          message: 'Single entry cannot contain both debit and credit amounts simultaneously.'
        };
      }
      totalDebit += entry.debit;
      totalCredit += entry.credit;
    }

    const delta = Math.abs(totalDebit - totalCredit);
    if (delta > 0.0001) {
      return {
        isSound: false,
        counterExample: `Debits: ${totalDebit}, Credits: ${totalCredit}, Discrepancy: ${delta}`,
        message: 'Double-entry balance invariant violated: Debits must strictly equal Credits.'
      };
    }

    return {
      isSound: true,
      message: 'Ledger invariant mathematically verified: Zero discrepancy.'
    };
  }
}

3. State Machine Transition Guard Validation

Before implementing database enum updates, model the allowable state graph as an adjacency matrix with strict precondition guards:

[Trial] ────────► [Active] ────────► [PastDue]
  │                  │                  │
  │                  ▼                  ▼
  └─────────────► [Canceled] ◄──────────┘

Any edge attempting to move from Canceled directly back to Active without passing through the Checkout/Re-subscribe gate is blocked by formal proof.


Best Practices

  1. Specify Invariants Before Schema Generation: Formulate formal invariants (e.g. balance conservation, role hierarchy) before creating tables or ORM migrations.
  2. Search for Counterexamples Actively: Run SMT solvers in negation mode (prove NOT invariant) to discover edge-case input values that break assertions.
  3. Bind Formal Guards into Database Constraints: Translate proven invariants into PostgreSQL CHECK constraints, foreign keys, and atomic database triggers.
  4. Never Rely Solely on Unit Tests for FinTech: Unit tests only test known examples ($O(N)$); formal verification tests all possible states ($O(\infty)$).

Common Pitfalls to Avoid

Anti-PatternCritical RiskEngineering Remedy
Floating point arithmetic for currencyInexact decimal rounding creates ledger driftEnforce integer cents/satoshis with strict SMT bounds
Unconstrained state transitionsIllegitimate subscription access without paymentModel transition matrix with formal guard preconditions
Relying on application-layer checks aloneRace condition during concurrent API calls bypasses checkPair formal proof with database atomic constraints & row locks

<a name="bahasa-indonesia"></a>

Bahasa Indonesia

Integrasi Orkestrasi

  • FinTech & Billing SaaS: saas-billing, doku-payment-gateway, payment-gateway-expert
  • Pembuktian Identitas & Otorisasi: authentication-identity-expert, zero-trust-secret-vault
  • Database & Penegakan Constraint: database-orm-expert, spec-driven-development-expert
  • Pengujian & Verifikasi Mutasi: property-mutation-testing-expert, autonomous-tdd-debugger, anti-slop
  • Siklus Hidup & Tata Kelola: brainstorming, zero-to-prod-orchestrator, session-memory-manager

Deskripsi

Panduan produksi untuk menerapkan metode formal, spesifikasi matematis, dan SMT (Satisfiability Modulo Theories) solver (seperti Z3, Dafny, TLA+) pada sistem perangkat lunak misi kritis. Membuktikan ketiadaan pelanggaran invarian (zero-invariant violation) pada pembukuan entri ganda FinTech, transisi siklus langganan SaaS, batas isolasi multi-tenant, dan hierarki akses.

Kondisi Pemicu

Aktifkan skill ini ketika:

  • Merancang buku besar keuangan (ledger), dompet digital, atau state machine gateway pembayaran.
  • Memverifikasi aturan perizinan RBAC/ABAC untuk memastikan eskalasi hak akses secara matematis mustahil terjadi.
  • Memodelkan state machine konkuren atau terdistribusi di mana race condition dapat memicu desinkronisasi.
  • Menyusun spesifikasi invarian formal sebelum membuat skema database dan ORM.

Konsep Inti & Pola Praktik

1. Pembuktian Invarian Buku Besar FinTech

Setiap transaksi keuangan wajib mematuhi aturan entri ganda:

  1. Konservasi Nilai: Jumlah total debit harus sama persis dengan jumlah total kredit ($\sum \text{Debit} = \sum \text{Kredit}$).
  2. Ketiadaan Nilai Negatif: Tidak boleh ada nilai debit atau kredit di bawah nol.
  3. Penyimpanan Integer: Nilai moneter wajib disimpan dalam satuan terkecil (misalnya sen atau rupiah penuh) tanpa floating point.

2. Verifikasi Transisi State Langganan

Pastikan tidak ada alur ilegal dalam sistem langganan:

  • Akun yang sudah Canceled tidak boleh berubah menjadi Active tanpa melewati proses verifikasi pembayaran baru (Re-checkout).
  • Status PastDue harus otomatis membatasi akses fitur premium sesuai aturan masa tenggang (grace period).

Praktik Terbaik

  1. Spesifikasikan Invarian Sebelum Menulis Kode: Tentukan rumus matematis invarian sebelum membuat tabel database atau API route.
  2. Cari Counter-Example Secara Aktif: Gunakan solver untuk mencari kondisi tepi (corner cases) yang berpotensi melanggar asumsi sistem.
  3. Terjemahkan Invarian ke Constraint SQL: Terapkan hasil pembuktian ke dalam CHECK constraint PostgreSQL dan atomic locks.
  4. Hindari Floating Point untuk Uang: Gunakan bilangan bulat (integer) untuk mencegah kebocoran saldo akibat pembulatan desimal.

Jebakan Umum yang Harus Dihindari

Praktik BurukDampak BurukSolusi Rekayasa
Menggunakan tipe data float untuk saldo keuanganSelisih sen akibat rounding error yang menumpukGunakan tipe integer (satuan sen) dengan validasi solver
Mengizinkan transisi state tanpa validasi prasyaratPengguna mendapat akses gratis setelah membatalkan langgananBuktikan matriks transisi dengan formal state graph
Validasi hanya di lapisan aplikasiTransaksi paralel dapat menembus pengecekan (race condition)Gabungkan bukti formal dengan kunci transaksi database (SELECT FOR UPDATE)

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

A2A agent protocol interoperability, Agent Cards, and MCP bridging / Protokol agen A2A, Agent Cards, dan integrasi MCP.

The English summary is being prepared. Showing the original description.

roedyrustam/vibes-plug114Updated Oct 27, 2026

Expert guide for automated and manual Web Accessibility (a11y) testing — axe-core, Pa11y, Playwright a11y, screen reader testing, and WCAG 2.2 Level AA/AAA compliance / Panduan ahli pengujian aksesibilitas web.

The English summary is being prepared. Showing the original description.

roedyrustam/vibes-plug114Updated Oct 27, 2026

Web accessibility testing with axe-core, Playwright, and WCAG 2.2 / Pengujian aksesibilitas web axe-core, Playwright, dan WCAG 2.2.

The English summary is being prepared. Showing the original description.

roedyrustam/vibes-plug114Updated Oct 27, 2026

Expert guide for intelligent model cascading and routing — complexity-scored task routing from Flash/Haiku to Sonnet/Opus/Astra, dynamic escalation with quality gates, 40-60% token cost reduction while maintaining output quality / Panduan ahli untuk kaskade dan routing model cerdas — routing tugas berbasis skor kompleksitas dari Flash/Haiku ke Sonnet/Opus/Astra, eskalasi dinamis dengan gerbang kualitas, pengurangan biaya token 40-60% dengan kualitas output terjaga.

The English summary is being prepared. Showing the original description.

roedyrustam/vibes-plug114Updated Oct 27, 2026

Model cascading & complexity-scored routing (Grok, Gemini, Claude) / Routing kaskade model & scoring kompleksitas (Grok, Gemini, Claude).

The English summary is being prepared. Showing the original description.

roedyrustam/vibes-plug114Updated Oct 27, 2026

Affective computing, emotion AI, and multimodal sentiment analysis / Komputasi afektif, AI emosional, dan analisis sentimen multimodal.

The English summary is being prepared. Showing the original description.

roedyrustam/vibes-plug114Updated Oct 27, 2026

See all skills by roedyrustam

Report a problem with this skill