Generates **property-based tests** that use randomized input generation to validate invariants and contracts (rather than hand-picked examples). Triggers when the conversation involves: PBT frameworks (Hypothesis library for Python, fast-check for TypeScript, proptest for Rust, rapid for Go, RapidCheck for C++); concepts like invariants, contracts, round-trip symmetry, encode/decode, serialize/deserialize, generative testing, or shrinking; or requests to find edge cases that example-based tests miss — e.g., "find edge cases automatically", "test all possible inputs", "verify this property holds". Does NOT trigger for: writing regular example-based unit tests, debugging, CI/CD setup, UI/component testing, or integration/E2E testing. Identifies up to 7 property patterns (round-trip, idempotence, invariance, metamorphic, inverse, ordering, no-crash), designs input generators, writes property tests, and extracts regression tests from failures.
91
90%
Does it follow best practices?
Impact
94%
1.11xAverage score across 5 eval scenarios
Passed
No known issues
A TypeScript service evaluates access rules for users. The current Jest tests cover a few named roles, but customers can configure many rule sets and action strings. The security team wants broader automated coverage before shipping a refactor, especially around duplicate roles, empty rule sets, and async audit hooks.
Write tests for the code below. The tests should exercise many generated rule/user/action combinations and include any small test doubles you need for the async API.
Produce access.test.ts with Jest or Vitest tests. Produce NOTES.md summarizing the behavioral properties and how you configured the randomized checks.
=============== FILE: access.ts ===============
export interface User { id: string; roles: string[] }
export interface Rule { role: string; actions: string[] }
export function canAccess(user: User, action: string, rules: Rule[]): boolean {
return rules.some(rule => user.roles.includes(rule.role) && rule.actions.includes(action));
}
export async function auditedAccess(
user: User,
action: string,
rules: Rule[],
audit: (event: { userId: string; action: string; allowed: boolean }) => Promise<void>
): Promise<boolean> {
const allowed = canAccess(user, action, rules);
await audit({ userId: user.id, action, allowed });
return allowed;
}