

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
12345# Property-Based Testing Rules67## Overview89These property-based testing (PBT) rules are cross-cutting constraints that apply across applicable AI-DLC phases. They ensure that code with identifiable properties is tested using property-based techniques, complementing (not replacing) traditional example-based tests.1011Property-based testing defines invariants that must hold for all valid inputs, then uses a framework to generate random inputs and search for counterexamples. When a failure is found, the framework shrinks the input to a minimal reproducing case. This approach uncovers edge cases and subtle bugs that example-based testing routinely misses.1213**Enforcement**: At each applicable stage, the model MUST verify compliance with these rules before presenting the stage completion message to the user.1415### Blocking PBT Finding Behavior1617A **blocking PBT finding** means:181. The finding MUST be listed in the stage completion message under a "PBT Findings" section with the PBT rule ID and description192. The stage MUST NOT present the "Continue to Next Stage" option until all blocking findings are resolved203. The model MUST present only the "Request Changes" option with a clear explanation of what needs to change214. The finding MUST be logged in `aidlc-docs/audit.md` with the PBT rule ID, description, and stage context2223If a PBT rule is not applicable to the current project or unit (e.g., PBT-06 when no stateful components exist), mark it as **N/A** in the compliance summary — this is not a blocking finding.2425### Default Enforcement2627All rules in this document are **blocking** by default. If any rule's verification criteria are not met, it is a blocking PBT finding — follow the blocking finding behavior defined above.2829### Partial Enforcement Mode3031If the user selected **Partial** enforcement during opt-in, only rules PBT-02, PBT-03, PBT-07, PBT-08, and PBT-09 are enforced. All other rules are treated as advisory (non-blocking). Log the enforcement mode in `aidlc-docs/aidlc-state.md` under `## Extension Configuration`.3233### Verification Criteria Format3435Verification items in this document are plain bullet points describing compliance checks. Each item should be evaluated as compliant or non-compliant during review.3637---3839## Rule PBT-01: Property Identification During Design4041**Rule**: Every unit containing business logic, data transformations, or algorithmic operations MUST be analyzed for testable properties during the Functional Design stage. The analysis MUST identify which of the following property categories apply:4243| Category | Description | Example |44|---|---|---|45| Round-trip | An operation paired with its inverse yields the original value | serialize → deserialize = identity |46| Invariant | A transformation preserves some measurable characteristic | sort preserves collection size and elements |47| Idempotence | Applying an operation twice yields the same result as once | dedup(dedup(list)) = dedup(list) |48| Commutativity | Different operation orderings produce the same result | add(a, b) = add(b, a) |49| Oracle | A reference implementation or simplified model can verify results | optimized algorithm vs brute-force |50| Induction | A property proven for smaller inputs extends to larger ones | recursive structures, divide-and-conquer |51| Easy verification | The result is hard to compute but easy to check | maze solver output can be walked to verify |5253The identified properties MUST be documented in the functional design artifacts for the unit, and carried forward into code generation as PBT test requirements.5455**Verification**:56- Functional design artifacts include a "Testable Properties" section listing identified properties per component57- Each identified property references one of the categories above58- Components with no identifiable properties are explicitly marked as "No PBT properties identified" with a brief rationale59- The property list is referenced during code generation planning6061---6263## Rule PBT-02: Round-Trip Properties6465**Rule**: Any operation that has a logical inverse MUST have a property-based test verifying the round-trip. This includes but is not limited to:66- Serialization / deserialization (JSON, XML, Protobuf, binary formats)67- Encoding / decoding (Base64, URL encoding, compression)68- Parsing / formatting (date parsing, number formatting, template rendering with structured input)69- Encryption / decryption (where key is available)70- Database write / read (for the data transformation layer, not the I/O itself)71- Any pair of functions where `f_inverse(f(x)) = x` for all valid `x`7273The property-based test MUST generate random valid inputs using a domain-appropriate generator (see PBT-07) and assert that the round-trip produces a value equal to the original input.7475**Verification**:76- Every serialization/deserialization pair has a round-trip property test77- Every encoding/decoding pair has a round-trip property test78- Every parsing/formatting pair has a round-trip property test (or documents why the transformation is lossy)79- Round-trip tests use generated inputs, not hardcoded examples80- Lossy transformations (e.g., float formatting with precision loss) document the acceptable deviation and test within tolerance8182---8384## Rule PBT-03: Invariant Properties8586**Rule**: Functions with documented invariants MUST have property-based tests verifying those invariants hold across generated inputs. Common invariants include:87- **Size preservation**: output collection has the same size as input (e.g., map, sort)88- **Element preservation**: output contains exactly the same elements as input, possibly reordered (e.g., sort, shuffle)89- **Ordering guarantees**: output satisfies an ordering constraint (e.g., sort produces non-decreasing order)90- **Range constraints**: output values fall within a defined range (e.g., normalize produces values in [0, 1])91- **Type preservation**: output type matches expected type for all valid inputs92- **Business rule invariants**: domain-specific rules that must always hold (e.g., "account balance never goes negative after a valid transaction", "discount never exceeds item price")9394**Verification**:95- Each documented invariant has a corresponding property-based test96- Invariant tests generate a wide range of inputs including boundary values97- Business rule invariants identified in functional design are covered by PBT98- Invariant tests do not duplicate exact assertions from example-based tests — they test the general rule, not specific cases99100---101102## Rule PBT-04: Idempotency Properties103104**Rule**: Any operation that claims or requires idempotency MUST have a property-based test proving it. The test MUST verify that `f(f(x)) = f(x)` for all valid generated inputs. This applies to:105- API endpoints documented as idempotent (PUT, DELETE)106- Data normalization or sanitization functions107- Cache population operations108- Deduplication logic109- Configuration application (applying config twice should not change state)110- Message processing in at-least-once delivery systems111112**Verification**:113- Every operation documented as idempotent has a PBT asserting `f(f(x)) = f(x)`114- Idempotency tests use domain-appropriate generators (not just primitives)115- For stateful operations, the test verifies observable state equivalence after single vs repeated application116117---118119## Rule PBT-05: Oracle and Model-Based Testing120121**Rule**: When a reference implementation, simplified model, or known-correct algorithm exists, property-based tests MUST compare the system under test against the oracle. This applies to:122- Optimized algorithms replacing a known brute-force version123- Refactored code replacing legacy implementations124- Parallel/concurrent implementations compared against sequential versions125- Custom implementations of well-known algorithms (sorting, searching, graph traversal)126- New query engines compared against a reference database127128The property-based test MUST generate random valid inputs and assert that the system under test produces equivalent results to the oracle for all generated inputs.129130**Verification**:131- When a reference implementation exists (or can be trivially written), an oracle PBT is present132- Oracle tests generate diverse inputs covering normal, boundary, and adversarial cases133- Equivalence is defined precisely (exact equality, structural equality, or documented tolerance)134- If no oracle exists, this rule is marked N/A with rationale135136---137138## Rule PBT-06: Stateful Property Testing139140**Rule**: Components that manage mutable state MUST be evaluated for stateful property testing. Stateful PBT generates random sequences of commands (operations) against the system and verifies that invariants hold after each step. This applies to:141- In-memory caches and data stores142- State machines and workflow engines143- Queue and buffer implementations144- Session management systems145- Shopping carts, order pipelines, and similar stateful business objects146- Any component where the result of an operation depends on prior operations147148Stateful PBT MUST:149- Define a simplified model (reference state) that mirrors the system under test150- Generate random sequences of valid commands (add, remove, update, query, etc.)151- Execute each command against both the real system and the model152- Assert that observable state or query results match between system and model after each command153- Test sequences of varying lengths, including empty sequences154155**Verification**:156- Stateful components identified in functional design have stateful PBT or document why it is not applicable157- A simplified model is defined for comparison158- Command generators produce valid operation sequences with realistic parameter distributions159- Invariants are checked after each command in the sequence, not just at the end160- If no stateful components exist, this rule is marked N/A161162---163164## Rule PBT-07: Generator Quality165166**Rule**: Property-based tests MUST use domain-specific generators that produce realistic, structured inputs — not just primitive types. Poor generators (e.g., random strings for email fields, unbounded integers for age fields) produce meaningless test cases and miss real bugs.167168Generator requirements:169- **Domain types**: Custom generators MUST be created for domain objects (e.g., User, Order, Transaction) that respect business constraints (valid email format, positive amounts, valid date ranges)170- **Constrained primitives**: Numeric generators MUST be constrained to realistic ranges where the domain requires it171- **Structured data**: Generators for complex inputs (nested objects, lists of domain objects) MUST produce structurally valid data172- **Edge case inclusion**: Generators SHOULD be configured to include boundary values (empty collections, zero, maximum values, Unicode strings) alongside normal values173- **Reusability**: Domain generators SHOULD be defined as reusable test utilities, not duplicated across test files174175**Verification**:176- No PBT uses only raw primitive generators (e.g., `st.integers()` alone) for domain-typed parameters177- Custom generators exist for domain objects used in PBT178- Generators respect documented business constraints (e.g., positive amounts, valid formats)179- Generator definitions are centralized and reusable where multiple tests share the same domain types180181---182183## Rule PBT-08: Shrinking and Reproducibility184185**Rule**: All property-based tests MUST support shrinking and deterministic reproducibility.186187- **Shrinking**: When a property fails, the PBT framework MUST automatically reduce the failing input to a minimal reproducing case. Tests MUST NOT disable or bypass the framework's shrinking mechanism unless there is a documented technical reason (e.g., shrinking is incompatible with external service calls in integration tests).188- **Reproducibility**: Every PBT run MUST be reproducible via a seed value. The seed MUST be logged on failure so that the exact failing scenario can be replayed. CI configurations MUST either use a fixed seed for deterministic runs or log the random seed on every run for post-failure reproduction.189- **CI integration**: PBT MUST be included in the project's CI pipeline. Flaky PBT failures (tests that pass on retry without code changes) MUST be investigated, not suppressed.190191**Verification**:192- PBT framework's shrinking is enabled (not overridden or disabled)193- Test output on failure includes the seed value and the shrunk minimal failing input194- CI configuration logs the seed for every PBT run or uses a fixed seed195- No PBT is excluded from CI without documented justification196- Flaky PBT failures are tracked and investigated, not silently retried197198---199200## Rule PBT-09: Framework Selection201202**Rule**: The project MUST select and configure an appropriate property-based testing framework for its primary language(s). The framework MUST support:203- Custom generators / strategies for domain types204- Automatic shrinking of failing cases205- Seed-based reproducibility206- Integration with the project's existing test runner207208Recommended frameworks by language (non-exhaustive):209210| Language | Framework | Notes |211|---|---|---|212| Python | Hypothesis | Mature, excellent shrinking, Django integration |213| JavaScript / TypeScript | fast-check | Integrates with Jest, Vitest, Mocha |214| Java | jqwik | JUnit 5 integration, stateful testing support |215| Kotlin | Kotest Property Testing | Kotest framework integration |216| Scala | ScalaCheck | SBT integration, widely adopted |217| Rust | proptest | Macro-based, good shrinking |218| Go | rapid | Lightweight, idiomatic Go |219| Haskell | QuickCheck | The original PBT framework |220| C# / .NET | FsCheck | Works with xUnit, NUnit |221| Erlang / Elixir | PropEr / StreamData | OTP-aware, stateful testing |222223The selected framework MUST be documented in the tech stack decisions and included as a project dependency.224225**Verification**:226- A PBT framework is selected and documented in tech stack decisions227- The framework is included in project dependencies (package.json, pom.xml, requirements.txt, etc.)228- The framework supports custom generators, shrinking, and seed-based reproducibility229- If the project uses multiple languages, each language with PBT-applicable code has a framework selected230231---232233## Rule PBT-10: Complementary Testing Strategy234235**Rule**: Property-based tests MUST complement, not replace, example-based tests. The two approaches serve different purposes:236237- **Example-based tests**: Document specific known scenarios, regression cases, and business-critical edge cases with explicit expected values. They serve as executable documentation of concrete behavior.238- **Property-based tests**: Verify general invariants across a wide input space. They find unknown edge cases and validate that properties hold universally.239240Requirements:241- Critical business scenarios identified in user stories or requirements MUST have explicit example-based tests, even if a PBT covers the same property242- PBT MUST NOT be the sole test for any business-critical path — at least one example-based test must pin the expected behavior for key scenarios243- When a PBT discovers a failing case, the shrunk minimal example SHOULD be added as a permanent example-based regression test244- Test documentation MUST clearly distinguish between example-based and property-based tests (separate test files, test classes, or clearly named test functions)245246**Verification**:247- Business-critical paths have both example-based and property-based tests248- PBT is not used as the only test coverage for any critical feature249- Test files or test classes clearly separate or label PBT vs example-based tests250- Regression tests from PBT-discovered failures are captured as permanent example-based tests251252---253254## Enforcement Integration255256These rules are cross-cutting constraints that apply to the following AI-DLC stages:257258| Stage | Applicable Rules | Enforcement |259|---|---|---|260| Functional Design | PBT-01 | Property identification must appear in design artifacts |261| NFR Requirements | PBT-09 | Framework selection must be included in tech stack decisions |262| Code Generation (Planning) | PBT-01 through PBT-10 | Code generation plan must include PBT test steps for identified properties |263| Code Generation (Generation) | PBT-02 through PBT-08, PBT-10 | Generated tests must include PBT alongside example-based tests |264| Build and Test | PBT-08 | Test execution instructions must include PBT with seed logging and CI integration |265266At each applicable stage:267- Evaluate all PBT rule verification criteria against the artifacts produced268- Include a "PBT Compliance" section in the stage completion summary listing each rule as compliant, non-compliant, or N/A269- If any rule is non-compliant, this is a blocking PBT finding — follow the blocking finding behavior defined in the Overview270- Include PBT rule references in design documentation and test instructions271272---273274## Appendix: Property Category Quick Reference275276For developers and AI models identifying properties during Functional Design (PBT-01):277278| Pattern Name | Formal Term | Test Shape | When to Use |279|---|---|---|---|280| There and back again | Invertible function | `f_inv(f(x)) == x` | Serialization, encoding, parsing |281| Some things never change | Invariant | `measure(f(x)) == measure(x)` | Sort, map, filter, transform |282| The more things change, the more they stay the same | Idempotence | `f(f(x)) == f(x)` | Normalization, dedup, cache writes |283| Different paths, same destination | Commutativity | `f(g(x)) == g(f(x))` | Arithmetic, set operations, independent transforms |284| Solve a smaller problem first | Structural induction | Property on `x` implies property on `x + element` | Recursive structures, lists, trees |285| Hard to prove, easy to verify | Verification | `verify(solve(x)) == true` | Solvers, optimizers, search algorithms |286| The test oracle | Reference comparison | `f(x) == oracle(x)` | Optimized vs brute-force, refactored vs legacy |287288Source: Property category taxonomy adapted from Scott Wlaschin's "Choosing properties for property-based testing" ([fsharpforfunandprofit.com](https://fsharpforfunandprofit.com/posts/property-based-testing-2/)).289
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| nota-america/forgecat-agent-profilesprofiles/addyosmani/agent-skills/for-cursor/.cursor/rules/cmd-build.mdc · 51 | Cursor rules | no sections | 16/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/addyosmani/agent-skills/for-cursor/.cursor/rules/cmd-code-simplify.mdc · 51 | Cursor rules | testing-strategy | 30/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/addyosmani/agent-skills/for-cursor/.cursor/rules/cmd-plan.mdc · 51 | Cursor rules | no sections | 16/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/addyosmani/agent-skills/for-cursor/.cursor/rules/cmd-review.mdc · 51 | Cursor rules | no sections | 16/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/addyosmani/agent-skills/for-cursor/.cursor/rules/cmd-ship.mdc · 51 | Cursor rules | testing-strategygitdeploymentdo-not | 61/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/addyosmani/agent-skills/for-cursor/.cursor/rules/cmd-spec.mdc · 51 | Cursor rules | no sections | 16/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/addyosmani/agent-skills/for-cursor/.cursor/rules/cmd-test.mdc · 51 | Cursor rules | no sections | 16/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/addyosmani/agent-skills/for-forgecat/AGENTS.md · 51 | AGENTS.md | lint-formatstylearchdo-not | 73/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/addyosmani/agent-skills/for-forgecat/CLAUDE.md · 51 | CLAUDE.md | teststylearchagent-behaviour | 70/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/anthropics/claude-code/anthropics_claude-code_ralph-wiggum/for-cursor/.cursor/rules/cmd-cancel-ralph.mdc · 51 | Cursor rules | no sections | 16/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/anthropics/claude-code/anthropics_claude-code_ralph-wiggum/for-cursor/.cursor/rules/cmd-help.mdc · 51 | Cursor rules | no sections | 54/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/anthropics/claude-code/anthropics_claude-code_ralph-wiggum/for-cursor/.cursor/rules/cmd-ralph-loop.mdc · 51 | Cursor rules | no sections | 22/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/anthropics/claude-plugins-official/anthropics_claude-plugins-official_agent-sdk-dev/for-cursor/.cursor/rules/cmd-new-sdk-app.mdc · 51 | Cursor rules | setupstylearchdocs | 76/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/anthropics/claude-plugins-official/anthropics_claude-plugins-official_claude-md-management/for-cursor/.cursor/rules/cmd-revise-claude-md.mdc · 51 | Cursor rules | agent-behaviour | 50/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/anthropics/claude-plugins-official/anthropics_claude-plugins-official_code-review/for-cursor/.cursor/rules/cmd-code-review.mdc · 51 | Cursor rules | testing-strategygit | 35/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/anthropics/claude-plugins-official/anthropics_claude-plugins-official_commit-commands/for-cursor/.cursor/rules/cmd-clean_gone.mdc · 51 | Cursor rules | no sections | 60/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/anthropics/claude-plugins-official/anthropics_claude-plugins-official_commit-commands/for-cursor/.cursor/rules/cmd-commit-push-pr.mdc · 51 | Cursor rules | stylegit | 44/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/anthropics/claude-plugins-official/anthropics_claude-plugins-official_commit-commands/for-cursor/.cursor/rules/cmd-commit.mdc · 51 | Cursor rules | style | 44/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/anthropics/claude-plugins-official/anthropics_claude-plugins-official_example-plugin/for-cursor/.cursor/rules/cmd-example-command.mdc · 51 | Cursor rules | lint-formatstyleagent-behaviour | 58/100 | today | |
| nota-america/forgecat-agent-profilesprofiles/anthropics/claude-plugins-official/anthropics_claude-plugins-official_feature-dev/for-cursor/.cursor/rules/cmd-feature-dev.mdc · 51 | Cursor rules | stylearchgit | 56/100 | today |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 14 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 46 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 14 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 14 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 14 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 14 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 14 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 14 days ago | |
| bybren-llc/safe-agentic-workflow.cursor/rules/10-backend-python.mdc · 399 | Cursor rules | testlint-formatstylegit+4 | 97/100 | today |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/nota-america-forgecat-agent-profiles-profiles-awslabs-aidlc-workflows-for-cursor-cursor-rules-rule-property-based-testing)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.