nw-ab-critique-dimensi…
Review dimensions for validating agent quality - template compliance, safety, testing, and priority validation
TLA+ formal verification for design correctness and PBT pipeline integration
$ npx -y skills add nWave-ai/nWave --skill nw-tlaplus-verification --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/nw-tlaplus-verificationContext preview
The summary Claude sees to decide when to auto-load this skill.
TLA+ formal verification for design correctness and PBT pipeline integration
name: nw-tlaplus-verification agent: nw-functional-software-crafter description: TLA+ formal verification for design correctness and PBT pipeline integration user-invocable: false disable-model-invocation: true
When and how to use TLA+ for design verification. Complements PBT (which verifies implementation).
Is the risk in the DESIGN or the IMPLEMENTATION?
|
+-- Design risk (protocol correctness, distributed coordination, concurrency)
| -> Does the system involve concurrent or distributed state?
| Yes -> Use TLA+ for design verification
| Then use PBT to verify implementation matches design
| No -> PBT alone is likely sufficient
|
+-- Implementation risk (edge cases, serialization, data transforms)
| -> Use PBT alone
|
+-- Both
-> TLA+ validates design, PBT validates implementationTLA+ describes **what** a system should do, not how. A specification consists of:
TLC model checker exhaustively explores all reachable states within bounded model. If invariant violated, TLC provides counterexample trace -- shortest path from initial state to violation.
PlusCal is imperative-looking language transpiling to TLA+. Most programmers find it easier to learn first.
(* --algorithm Transfer
variables accounts = [a |-> 100, b |-> 100];
process Transfer \in 1..2
variables from, to, amount;
begin
Pick:
from := "a"; to := "b"; amount := 50;
Check:
if accounts[from] >= amount then
Debit:
accounts[from] := accounts[from] - amount;
Credit:
accounts[to] := accounts[to] + amount;
end if;
end process;
end algorithm; *)
\* Invariant: total money is conserved
MoneyConserved == accounts["a"] + accounts["b"] = 200**Labels** define atomicity boundaries. Everything between two labels executes atomically. Concurrency interleavings happen at label boundaries.
PlusCal limitation: can't express all TLA+ patterns (complex fairness, some non-determinism forms). Start with PlusCal, switch to raw TLA+ when needed.
1. Write spec in PlusCal or TLA+ 2. Configure model: concrete values for constants, invariants to check 3. Run TLC: exhaustive breadth-first exploration of all reachable states 4. If violation found: TLC provides counterexample trace (shortest path to violation) 5. Fix design, re-check 6. Gradually increase model parameters (more nodes, more messages)
SPECIFICATION Spec
CONSTANT
Nodes = {n1, n2, n3}
MaxMessages = 4
INVARIANT
MoneyConserved
NoDoubleDeliveryState space grows O(constants^variables). 3 nodes = ~1,000 states; 4 nodes = ~100,000. Most bugs manifest with 2-3 nodes.
Mitigation:
Network as set of in-flight messages. Send adds to set, receive removes. Unreliable network: messages removed without receipt (loss) or kept after receipt (duplication).
Variables represent memory locations. Locks modeled as variables indicating holding process.
Node crash: non-deterministic removal from active set. Volatile state lost, persistent retained. Restart: rejoin with fresh volatile state.
Nodes propose, vote, become leader when majority achieved. Safety: at most one leader per term.
Two-phase commit: resource managers prepare, transaction manager commits when all prepared. Safety: no partial commits.
**Safety** ("nothing bad happens"): Expressed as invariants. Violated by finite counterexample trace. Example: "Two processes never hold the same lock."
**Liveness** ("something good eventually happens"): Requires fairness assumptions. Cannot be violated by finite prefix. Example: "Every request eventually gets a response."
Start with safety. Add liveness after safety established.
Key integration point between formal verification and testing:
1. **TLA+ specification**: Identify invariants, safety properties, state machine transitions 2. **Model check with TLC**: Verify design correctness 3. **Implementation phase**: Code the verified design 4. **PBT phase**: Translate TLA+ invariants into PBT properties
Properties discovered during TLA+ become PBT test oracles:
TLA+ invariants are exhaustive. PBT samples. If TLA+ proves A, B, and C, your PBT must check all three.
| TLA+ Catches (Design) | PBT Catches (Implementation) | |----------------------|----------------------------| | Protocol deadlocks | Off-by-one
AI agents that guide you from idea to working code, with human judgment at every gate. nWave runs inside Claude Code. It breaks feature delivery into seven waves (discover, diverge, discuss, design, devops, distill, deliver).
Repo: nWave-ai/nWave
Review dimensions for validating agent quality - template compliance, safety, testing, and priority validation
Review dimensions for validating agent quality - template compliance, safety, testing, and priority validation
Review dimensions for acceptance test quality - happy path bias, GWT compliance, business language purity, coverage completeness, walking skeleton…
Detailed 5-phase workflow for creating agents - from requirements analysis through validation and iterative refinement
5-layer testing approach for agent validation including adversarial testing, security validation, and prompt injection resistance
Architectural style selection decision matrices, trade-off analysis, structural enforcement rules, and combination patterns. Load when choosing or evaluating…