個人 GitHub 帳號下公開儲存庫的擁有者可以登入並驗證所有權,自行管理介紹,無需管理員核准。
登入並產生驗證檔案,在 30 分鐘內將其提交至此儲存庫的預設分支。其他分支或分叉儲存庫中的檔案無效。然後在下方檢查檔案,即可無需管理員核准直接管理專案。請保留檔案以維持管理權限。
如需登入,將前往登入頁面。登入後請回到此處,再次點擊所選的驗證按鈕。
在專案資料夾中執行 /nomorevibe verify,即可驗證所有權並自行管理介紹。
一分鐘完成驗證fast formal models that also check your code
翻譯準備中
取自儲存庫 README
正在載入完整 README。
檢視完整 README ↗Fast formal models that also check your code.
Find bugs in how your system behaves before they reach production. Snap Pea uses the P modeling language to explore different event orderings, failures and interactions—and report a reproducible trace when something breaks.
Use the same rules to check your design, validate events from your application tests, and check production logs. Helpers for Python, Rust, Go and Java bring those checks into your existing test suite.
Try the playground · Read the overview · Documentation
Two orders each want 2 units of stock. There are 3 available. Both read the stock before either reserves it, so both think there is enough. Together, they oversell.
A P model describes the service and the orders as state machines exchanging messages. A spec states the rule: stock must never go negative. Snap Pea explores message orderings until it finds the one that breaks that rule, then saves a trace you can replay. Changing the design to check and reserve in one operation fixes the bug.
The inventory example includes both designs. Its spec is also used by the application examples in all four languages.
snappea observe checks against your specs. See testing and production.You or an AI agent can write the model from a design document, rerun the checker after
changes, and carry the specs into implementation tests. Review the specs closely:
they state what the system must get right. snappea guide walks through that workflow,
with runnable examples (snappea guide examples); telling an agent "use P, snappea is
installed" is enough for it to find.
Install the prebuilt CLI on Linux or macOS; no Rust or Python required:
curl -fsSL https://raw.githubusercontent.com/crowecawcaw/snappea/main/scripts/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
snappea version
On Windows, in PowerShell:
irm https://raw.githubusercontent.com/crowecawcaw/snappea/main/scripts/install.ps1 | iex
The installers support Linux x86-64/ARM64 with glibc, macOS Intel/Apple silicon and Windows x86-64. See installation options for release archives, Cargo, version pinning and install locations.
With Git installed, try both inventory designs:
git clone https://github.com/crowecawcaw/snappea.git
cd snappea/examples/model
snappea tests
snappea check tcAtomicReserve
snappea check tcCheckThenReserve
The atomic design passes exhaustive checking. The model scopes coverage exceptions to check-then-reserve paths covered by the other test. The check-then-reserve design fails with exit status 1 because it oversells. The failure includes:
Assertion Failed: PSpec/inventory.p:27:7 reservation exceeds available stock
Replay: snappea replay PCheckerOutput/tcCheckThenReserve/bug.schedule
Run the printed replay command from the same directory to reproduce the bug. The
command line guide and
model-checking reference cover options, output and search strategies.
snappea check also runs model lints; snappea check lint runs them separately, and snappea check mutation runs only
mutation testing.
Each language helper records application events and checks them against P specs. Follow your language's guide for a complete example and test-framework setup.
| Language | Install | Guide and examples |
|---|---|---|
| Python | pip install pysnappea | pytest guide · Examples |
| Rust | cargo add snappea | Rust guide · Examples |
| Go | go get github.com/crowecawcaw/snappea | Go guide · Examples |
| Java | Maven io.github.crowecawcaw:snappea | Java setup, including native jars · Examples |
Snap Pea is a Rust implementation of the P toolchain that reads .p and .pproj
files directly. snappea provides concise output and parallel checking;
snappea-compat accepts upstream p options and reproduces its output formats.
In the Raft tutorial benchmark, checking 120 schedules takes 0.4 seconds with Snap Pea and 38 seconds with P 3.1.0, including compilation. See the benchmark methodology and comparison charts for context.
See coming from P, measured upstream parity and the full compatibility reference. PVerifier and foreign code written in C# or Java are not supported.
Early, but checks real models. Validation covers upstream's 424 compiler regression tests, 249 checker tests, tutorials, golden traces and PObserve outputs. Validation details explain what is checked.
See development for the crate layout, tests and benchmarks, and AGENTS.md for the project's goals and required checks. Report a bug if something breaks.
Licensed under either of Apache License, Version 2.0 or MIT license, at your option.
Parts of snappea, including the tests vendored in tests/upstream, are derived from
P and remain under
P's MIT license (Copyright (c) 2015 P Developers).
Unless you explicitly state otherwise, any contribution you submit for inclusion in this project, as defined in the Apache-2.0 license, is dual licensed as above, without any additional terms or conditions.