bp-rust
Rust ベストプラクティス。Plecto の fast path(native Rust)と wasmtime ホスト埋め込みの コード品質を保つ規約とパターン集(Edition 2024)。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Rust ベストプラクティス。Plecto の fast path(native Rust)と wasmtime ホスト埋め込みの コード品質を保つ規約とパターン集(Edition 2024)。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Plecto's core architecture — the two halves (native-Rust fast path / WASM extension plane), the WIT type contract between them, the deny-by-default capability boundary, the filter chain, typed decision/short-circuit, init vs per-request hooks, instance lifecycle, and host-held state.
Audits code for security vulnerabilities using OWASP Top 10:2025, OWASP ASVS 5.0, and the OWASP Secure Code Review Cheat Sheet, with Plecto-specific dimensions: WASM sandbox / capability boundary (deny-by-default, epoch metering, CVE-2022-39393 pooling leakage, OCI signature verification, untrusted multi-tenant filters) and L7 proxy / gateway risks (SSRF on upstream construction, TLS termination, request smuggling/splitting, header injection, rate-limit/WAF bypass). Produces a structured findings report (severity + OWASP/CWE/ASVS mapping + evidence + remediation).
Best practices for embedding wasmtime as Plecto's host: InstancePre + pooling allocator for fast per-worker instance reuse, epoch interruption + memory limits for metering, Linker-based deny-by-default host functions, Store-per-request lifecycle, async host calls, pooling zeroization (CVE-2022-39393), and OCI-artifact load + cosign signature verification.
Design and evolve Plecto's `plecto:filter` WIT world and host-API surface — the type contract between the native fast path and untrusted WASM filters. Covers worlds/interfaces, resources, the decision variant, minimal-capability host-API slicing, header bytes (list<u8>), the filter / filter-body world split (header-only vs buffered body), versioning/compat with frozen v0.1/v0.2 load-time adapters, and the projected stream<u8> + wasm32-wasip2 migration.
TypeScript / JavaScript ベストプラクティス。型安全性とコード品質を保つ規約。 Plecto では (1) Node ツーリング・統合テスト・wasm-bindgen の node_pkg 周り、 (2) jco / componentize-js で書く JS/TS 製 WASM フィルタ、の二用途に効く。
Runs an adversarial full review of a merge commit, PR, or branch range (AI-authored or not): Builder/Critic session separation, Spec+Diff-only critic input, parallel critic lanes (correctness, security, tests/CI), evidence-gated findings, and a structured merge verdict.
| name | bp-rust |
| description | Rust ベストプラクティス。Plecto の fast path(native Rust)と wasmtime ホスト埋め込みの コード品質を保つ規約とパターン集(Edition 2024)。 |
| when_to_use | .rs ファイルを編集・作成する時、listener / router / filter-chain dispatch / host-API / wasmtime 埋め込みなど Rust コンポーネントを実装する時。テスト実行・ファイル読み取りのみの 作業や、WASM フィルタを他言語(Go/JS/Python)で書く時は不要。 |
| paths | ["**/*.rs"] |
このスキルが発動したら、必要に応じて reference/rust.md を Read で読み込み、 記載されたベストプラクティス(DECREE)に従ってコードを書くこと。本体は要点のみ、詳細は reference に置く。
Plecto は二つの半身を持つ: fast path(接続・TLS・HTTP・ルーティング・LB・upstream の native Rust)と、
wasmtime ホスト(untrusted な WASM フィルタを安全に実行する埋め込み)。両者でこの規約を適用する。
wasmtime 固有の埋め込み詳細は wasmtime-host スキルへ、WIT 契約は wit-contract-design スキルへ委譲する。
edition = "2024" 必須。unsafe extern ブロック、RPIT lifetime capture(+ use<>)、
gen 予約語、if let 一時変数のドロップ順変更などの差異に注意。#[derive(thiserror::Error)] の
enum で型付きエラー(#[from] / #[source] でチェーン保持)。anyhow は main.rs / バイナリ
エントリポイントの Result<_, anyhow::Error> と .with_context(...) に限定。unwrap() / expect() / panic! / 添字アクセスのパニックを禁止。untrusted 入力には必ず ? か
明示的フォールバック。パニックは worker を巻き込んで可用性を壊す(プロキシは落ちてはいけない)。&str > String、&[T] > Vec<T> を引数に。ホット経路の
.clone() は禁止。ボディは可能な限りゼロコピー(Bytes / &[u8] / stream)で扱う。pub(crate)。クレート公開面(host-API trait など)
は意図的に最小化する(capability 境界の一部)。tokio、ログは tracing(println! / eprintln! 禁止)。
観測は wasi-otel / OTel をホスト側で集約(wasmtime-host 参照)。.await を持つ critical section で
ロックを跨がない。_ ワイルドカードより明示的なバリアント列挙。decision variant
(continue / modified / short-circuit)等の将来追加をコンパイル時に検出する。cargo clippy --all-targets --all-features -- -D warnings と
cargo fmt --all -- --check を通す。手動スタイル議論はしない。unsafe は最小化し、使うなら
// SAFETY: コメントと不変条件を必ず添える(#![deny(unsafe_op_in_unsafe_fn)])。完全なベストプラクティスは reference/rust.md。 セクション: Edition 2024 Essentials, Project Structure, Error Handling, Ownership & Borrowing, Async & tokio, Data-plane discipline (no panic / zero-copy), wasmtime host embedding pointers, Testing, Logging & Observability, Lints & Tooling。