with one click
porting
// Guides Go→Rust porting for Pluto. Invoke when asked to port, implement parity for, or translate a Go component.
// Guides Go→Rust porting for Pluto. Invoke when asked to port, implement parity for, or translate a Go component.
Iteratively review and fix a Pluto PR until it is "ideal" — drives the /review-pr multi-agent pipeline inside /ralph-loop, applying fixes between iterations and never posting inline comments. After the loop terminates, posts a single summary comment to the GitHub PR with everything that was resolved. Invoke as `/loop-review-pr <PR-number|PR-URL> [--max-iterations N]`.
Use when implementing, reviewing, debugging, or explaining Pluto Rust libp2p code: Node/P2PContext ownership, PlutoBehaviour composition, NetworkBehaviour and ConnectionHandler protocols, relay/force-direct/quic-upgrade behaviours, peerinfo/parsigex protocol handlers, DKG protocol handlers, and P2P tests.
General Rust conventions for Pluto. Use it once for understanding the codebase better.
Full multi-agent code review for a Pluto PR. Spawns parallel agents covering functional correctness, security, Rust style, and code quality, then posts all findings as isolated GitHub review comments and submits a final approve/request-changes verdict. Invoke as `/review-pr <PR-number>` or `/review-pr <GitHub-PR-URL>`.
Use when porting Charon components to understand Go codebase architecture, workflow, design patterns, or component responsibilities
Pluto-specific code review guidelines. Use as a general guideline when asked to conduct a code review.
| name | porting |
| description | Guides Go→Rust porting for Pluto. Invoke when asked to port, implement parity for, or translate a Go component. |
Before writing any code:
charon-guide for codebase location, version, and structure. Verify once per session if needed.charon/<path>:<line> (v1.7.1)Architecture context: See charon-guide skill for workflow components, design patterns, and package structure.
For each file in scope:
Do not guess. If behavior is unclear, ask.
List Go imports and map each to its Rust equivalent:
| Go import | Rust crate/module | Status |
|---|---|---|
encoding/json | serde_json | available |
crypto/sha256 | sha2 | available |
some/go/pkg | ??? | missing — needs decision |
Flag anything without a clear mapping before continuing.
List every function/type to port, in the same order as the Go source:
| Item | Go file:line | Complexity | Notes |
|---|---|---|---|
FooCmd | cmd/foo.go:12 | Low | CLI entrypoint |
parseBar | cmd/foo.go:45 | Medium | custom encoding |
BazType | pkg/baz/baz.go:8 | High | shared with DKG |
Complexity: Low = straightforward translation / Medium = non-trivial logic or encoding / High = protocol-level, crypto, or shared invariants.
For each item in the inventory:
### `parse_bar` (charon/cmd/foo.go:45)
Behavior:
- Accepts hex-encoded 32-byte key, returns decoded [u8; 32]
- Returns error "invalid key: <hex>" on bad input (match string exactly)
Rust target: `pluto/crates/core/src/foo.rs`
Edge cases:
- Empty string → error, not panic
- Odd-length hex → error from hex::decode, wrap in ModuleError
Invariants:
- Output length always 32 bytes
- Error string must match Go for CLI parity
Do not begin implementing until this plan is approved.
Follow rust-style skill conventions and AGENTS.md golden rules:
Examples where different implementation is acceptable:
defer → Rust RAII (Drop trait)sync.WaitGroup → Rust tokio::task::JoinSetcontext.Context → Rust CancellationToken + structured concurrencyDashMap or channels#[from] deriveKeep Go file open alongside. After each function, verify behavior matches before moving on.
Do not write Go-cross-reference comments in the Rust source:
// Mirrors X / // Mirror of Go's X// Equivalent to Go's X// Ports charon/<path> (vX.Y.Z)// Placeholder for go.eth2v1.Foo// foo — router.go:108 cross-refs on routes/fields/methods// router.go:NN line-number anchors anywhereReasons:
Doc comments should describe what the Rust item does and any non-obvious why (constraint, invariant, edge case). If you need to record the Go origin for your own bookkeeping while porting, do it in the plan or PR description, never the source.
For each ported item:
#[test_case] for parameterized cases#[tokio::test] for asyncMinimum bar: every error path exercised, every Go test translated.
Before marking work done, verify functional equivalence with Go implementation:
Use pluto-review skill for structured parity review format. Any deviations must be documented with justification.
| Go | Rust |
|---|---|
string | String / &str |
[]byte | Vec<u8> / &[u8] |
int64 / uint64 | i64 / u64 |
map[K]V | HashMap<K, V> |
[]T | Vec<T> |
*T (nullable) | Option<T> |
error | Result<T, E> |
go func() | tokio::spawn() |
chan T | tokio::sync::mpsc |