Skip to main content

Lattice

Say you're testing a checkout flow. Users are signed in or guest. They have a coupon or not. The cart is empty, single-item, or multi-item. Shipping is standard, express, or pickup. Payment is card, Apple Pay, or PayPal. The site renders in light or dark mode.

Six knobs, a few settings each — 216 combinations. Real product surfaces have dozens of knobs and hundreds of thousands of combinations. And most production bugs are interaction bugs: the one where dark mode plus Apple Pay plus the new coupon breaks the order page, even though each piece works fine alone.

Nobody writes tests for 216 combinations. Nobody can write tests for 200,000. So humans and coding agents alike pick a handful of cases by gut feel, and the interaction bug ships.

Lattice is the way out. You list the knobs, the settings, and any rules ("Apple Pay isn't allowed for pickup orders"). Lattice gives back a short, deterministic list of scenarios that hits every pair of settings at least once. The six-knob example above collapses from 216 cases to about a dozen — enough to catch the overwhelming majority of interaction bugs without writing the universe.

The math behind this is old. It's what Hexawise and similar tools have been selling for years. What's new here is the packaging: schema in on stdin, rows out on stdout, deterministic, built for a coding agent to call while planning a feature or writing tests. The agent describes the surface, Lattice does the combinatorics, the agent turns each row into a test, a rendered screenshot, a fixture, or a step of plan review.

What this unlocks

Pre-code planning. An agent given a feature spec writes a plan that looks careful and treats interactions as an afterthought. Modeling the surface as a Lattice schema first — parameters, values, constraints — changes the plan. The agent isn't picking edges by gut feel; it has a deterministic list of combinations the design has to handle. Spec gaps surface during modeling, when they're still cheap to address, instead of during the first incident.

Writing tests. The failure mode isn't undertesting. Agents will happily generate fifty tests — overmocked, all hitting the same happy path, and on the next run, silently rewritten when one fails. An empirical study of 1.2M commits found agents add mocks at nearly 1.4x the human rate and reach almost exclusively for the basic mock primitive where humans spread across fakes, spies, and stubs. The rewrite-instead-of-fix instinct shows up in the Claude Code issue tracker under the name fix-fail-propose-new-fix: a fix breaks the live app, the unit suite still passes, so the agent files the symptoms as new bugs and proposes more fixes instead of reverting. The pattern is structural — it follows from handing an agent unilateral write access to the assertion it has to pass — not a quirk of any specific model.

Lattice doesn't solve the temptation; it removes the choice. The schema dictates the matrix. The rows dictate the assertions. An unsatisfied row is a case the design has to answer for — not a test to delete.

Same loop in both places: the agent describes the surface, Lattice does the combinatorics, the agent reasons over the rows. The schema is cheap. The coverage is defensible.

How it goes

  1. The agent writes a small JSON or YAML schema: parameters, values, constraints.
  2. Pipe it to lattice generate.
  3. Lattice returns the covering rows. Same schema and seed always produce the same rows.
  4. The agent maps each row to whatever it's evaluating — a test, a render, a fixture, a sandbox call.

The schema is the contract between agent and engine. The rows are the product. Lattice does not care whether the surface is a backend feature, an API, a state machine, a Rails partial, a design-system component, an email template, a config matrix, or a data-model slice — if it has dimensions, values, rules, and an evaluator, Lattice can cover it.

Project status: experimental 0.1. The CLI and agent skill bootstrap path work; the schema contract may still evolve as the project finds its first users.

Install For Agents

Start with docs/install.md when you want any coding agent or harness to adopt Lattice.

That page covers:

  • installing the lattice CLI with pipx, uvx, or pip
  • printing universal instructions with lattice agent instructions
  • installing a generic lattice-workflow skill into any harness directory with lattice agent install-skill <target>
  • installing Codex and Claude Code convenience skills with lattice agent bootstrap
  • adding an agent memory for when to reach for Lattice
  • running a smoke test over stdin

Why This Shape

Lattice is split into three small modules on purpose:

  • parser.py: the schema contract between a harness and the engine
  • constraints.py: deterministic feasibility and constraint reasoning
  • ipog.py: compiles the model for the Rust engine (rust/, built on the lattice-engine crate) and turns its rows into the coverage curve

That keeps the math isolated from OpenClaw, Hermes, Codex, xAI-backed agents, Claude Code, or any other harness wrapper.

CLI

# stdin-first, harness-friendly
cat schema.json | lattice validate
cat schema.json | lattice generate

# file input is optional and useful for debugging
lattice validate schema.yaml --format text
lattice generate schema.yaml --strength 3 --format table
lattice generate schema.yaml --strength 4 --progress --progress-every 25 > scenarios.json
lattice generate schema.yaml --strength 4 --stop-after-coverage 84 > prefix.json

# explicit machine-readable validation
lattice validate schema.json --format json

Supported output formats:

  • json
  • table
  • csv
  • summary
  • yaml (same content as json, for files people edit by hand)

generate defaults to JSON because the primary consumer is usually a coding harness. File-based schemas are supported, but the schema file is transport, not the product surface.

For long higher-strength runs, use --progress to stream coverage progress to stderr while keeping stdout clean for JSON, YAML, CSV, table, or summary output. --progress-every N controls how many generated scenarios pass between updates.

Use --stop-after-coverage PCT for prefix runs that stop after the first generated scenario reaching that cumulative coverage percentage. Use --max-rows N for a fixed-size prefix. If both are set, generation stops at whichever limit is reached first. --stop-after-coverage 100 is treated as a full run so rounded 100.0% coverage near the tail does not skip final rows.

Model Features

Lattice currently supports:

  • pairwise and t-way generation
  • JSON and YAML schema transport
  • invalid_pair
  • bidirectional
  • forward_dep
  • conditional
  • forced
  • higher_order
  • inline parameter weights
  • deterministic generation via --seed

Model true impossibilities as constraints before generation. Do not strip constraints and mark impossible rows downstream: that changes the coverage surface from valid interactions to an unconstrained cross-product. Use invalid_pair for two assignments that cannot coexist and higher_order when the invalid rule needs multiple antecedents.

conditional parameters are first-class schema features. The parser expands them into concrete parameter domains and the constraint engine enforces N/A semantics automatically.

A schema with two constraints:

model_name: checkout
strength: 2
parameters:
  payment_method: [credit_card, paypal, apple_pay]
  region: [US, UK, DE]
  browser:
    values: [chrome, safari, firefox]
    weights: [0.6, 0.3, 0.1]
constraints:
  - type: invalid_pair
    if: { parameter: payment_method, value: apple_pay }
    then_not: { parameter: browser, value: firefox }
  - type: conditional
    parameter: card_type
    values: [visa, mastercard]
    parent: payment_method
    applies_when: [credit_card]

Every constraint needs a type key. Run lattice agent instructions for an example of each type.

Values keep their text

Every value in a schema (the model name, parameter names and values, and constraint references) is used exactly as written. In YAML, unquoted 1.10, 0x1F, .inf or 2026-10-26T10:00:00Z stay as typed rather than being turned into numbers or dates. The exceptions:

  • Unquoted yes, no, on, off, true and false (lowercase, Capitalized or UPPERCASE) become true / false, and an empty value, ~ or null becomes null. Quote them ("yes") to keep the word.
  • JSON integers are written in plain decimal form (-0 becomes 0).

strength must be a whole number, and weights decimal numbers such as 0.7 or 1e-3. Anchors, aliases and << merge keys work; a key written twice, more than one YAML document, or a tag other than YAML's standard ones is an error.

Changed in 0.3.0: earlier versions converted unquoted numbers and dates, so 0x1F became 31, 1.10 became 1.1, and some values (.inf, timestamps) came out differently in the Ruby and Python implementations.

Performance

Generation runs in a Rust engine (the lattice-engine crate, shared with the Ruby gem), in two phases:

  1. Build. Rows are added greedily. Each row is the best of several candidates (--pool-size, default 16), and each candidate picks, value by value, whatever covers the most combinations still uncovered.
  2. Shrink. A row is removed and the gaps are repaired with tabu search, which changes values in the remaining rows without breaking any constraint or forced combination. This repeats while repairs succeed within a fixed step budget.

The budget is a number of steps, not a time limit, so the same schema and seed give the same rows on every machine. The rows come out ordered so each adds the most new coverage, which is why --max-rows and --stop-after-coverage cut the set short with as much coverage as possible.

Scenario counts against PICT 3.7, with default settings for both:

Model PICT Lattice 0.4 Lattice 0.3
13 parameters × 3 values 20 15 (best known) 22
100 × 2 16 10 (optimal) over 60 s
61 mixed (4^15 3^17 2^29) 40 30 over 60 s
12 × 6 70 60 88 (32 s)
30 × 5 66 55 over 60 s
20 × 10 218 192 over 60 s
Strength 3, 10 × 4 158 140 176 (27 s)

Each Lattice 0.4 run above takes 0.04–1.2 s on an Apple M-series laptop. PICT is faster (about 0.02 s) because it stops after the build phase.

Changed in 0.4.0: rows differ from 0.3.x for the same seed, and every example needs the same number of scenarios or fewer. --pool-size now sets the candidates per row; its default went from 50 to 16.

Platforms

Wheels include the compiled engine for macOS (Apple Silicon and Intel), Linux (x86-64 and ARM64, glibc and musl) and Windows (x86-64), one wheel per platform for every Python from 3.11. Other platforms build from the source distribution, which needs a Rust toolchain. Python running in the browser (Pyodide) isn't supported.

Using In Other Projects

The normal workflow in another repo is:

  1. install Lattice once into the Python environment your harness uses
  2. have the harness emit a schema on stdin
  3. call lattice validate
  4. call lattice generate
  5. consume the JSON output inside the harness

Example:

cat schema.json | lattice validate
cat schema.json | lattice generate

If you want an agent such as OpenClaw, Hermes, Codex, an xAI-backed harness, Claude Code, or a custom local agent to use the same workflow in another repo, start with docs/install.md, then see docs/using-in-other-projects.md.

Scope each schema to the thing being worked on: the feature, service, workflow, component, rendering surface, template family, config matrix, or behavior slice under active design or test work.

The shortest agent adoption path after install is:

lattice agent instructions
lattice agent bootstrap
lattice agent doctor

instructions works for any agent. bootstrap installs convenience skills only for known harnesses detected on the machine.

Harness Contract

Lattice is intentionally narrow. A harness owns extraction and interpretation; Lattice owns schema validation and deterministic row generation.

  • plan synthesis: harness extracts schema from a plan, Lattice generates scenarios, harness strengthens the plan
  • test synthesis: harness extracts schema from code/tests, Lattice generates scenarios, harness writes missing tests
  • variant coverage: harness extracts component, template, or design-system variants, Lattice generates rows, harness renders screenshots, a contact sheet, or visual diffs
  • evaluator coverage: harness extracts a config or sandbox matrix, Lattice generates rows, harness runs each row through the relevant evaluator

See docs/agent-handoff.md for the repository-level handoff shape. See docs/workflows.md for concrete agent usage patterns. See docs/case-studies.md for public audit examples and the standard for how to write them up. See docs/using-in-other-projects.md for portable installation and adoption. See docs/lattice-on-lattice.md for a worked example of Lattice testing its own agent bootstrap surface.

Skill

This repo includes a repo-local Codex skill at .codex/skills/lattice-workflow/, bundled Codex and Claude Code skill resources, and a generic skill resource for any harness that accepts a SKILL.md directory.

Use it when you want a coding harness to:

  • extract a schema from code, a spec, or a variant surface
  • validate the schema before generation
  • run Lattice deterministically
  • interpret the rows as design review scenarios, rendered variants, fixtures, or test cases

Examples

The examples/ directory contains eight end-to-end examples:

  • plan-mode-saved-search: plan -> schema -> generated scenarios
  • test-mode-checkout: code/test surface -> schema -> generated scenarios
  • three-way-notifications: strength-3 schema -> generated scenarios
  • lattice-self-test: Lattice generates a matrix for testing Lattice itself
  • agent-bootstrap-matrix: Lattice generates a matrix for testing agent skill bootstrap behavior
  • schema-guidance-matrix: Lattice generates a matrix for testing Lattice's schema discoverability guidance
  • component-variant-matrix: component/rendering surface -> schema -> generated visual review variants
  • httpx-query-param-merge: OSS audit example for a real HTTPX query-parameter interaction issue

Development

Building from a checkout needs a Rust toolchain (rustup); the engine comes from crates.io (lattice-engine).

python3 -m venv .venv && . .venv/bin/activate
pip install maturin pytest
maturin develop --release      # builds lattice._engine into the checkout
python -m pytest tests

Metadata

Release files for lattice-cli 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lattice-cli 0.4.0
File Size Uploaded Provenance Actions
lattice_cli-0.4.0.tar.gz 37.8 kB With provenance Details for lattice_cli-0.4.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for lattice-cli 0.4.0
File Actions
lattice_cli-0.4.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for lattice_cli-0.4.0-cp311-abi3-win_amd64.whl
lattice_cli-0.4.0-cp311-abi3-musllinux_1_2_x86_64.whl CPython 3.11 abi3 Linux musl 1.2+ x86-64 Details for lattice_cli-0.4.0-cp311-abi3-musllinux_1_2_x86_64.whl
lattice_cli-0.4.0-cp311-abi3-musllinux_1_2_aarch64.whl CPython 3.11 abi3 Linux musl 1.2+ ARM64 Details for lattice_cli-0.4.0-cp311-abi3-musllinux_1_2_aarch64.whl
lattice_cli-0.4.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details for lattice_cli-0.4.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
lattice_cli-0.4.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for lattice_cli-0.4.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
lattice_cli-0.4.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for lattice_cli-0.4.0-cp311-abi3-macosx_11_0_arm64.whl
lattice_cli-0.4.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for lattice_cli-0.4.0-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 2.6 MB

Release files / lattice_cli-0.4.0.tar.gz

Download URL lattice_cli-0.4.0.tar.gz
Size 37.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0bf0dd986ad443c46505a24f19d2d690a77af8235fdbb5bba83f49c96f3bbb8d
BLAKE2b-256 checksum
How to use checksums
456ebc4d817bc56936244ea69555bc5b1142fb67812b1f7da06e7e186500db8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / lattice_cli-0.4.0-cp311-abi3-win_amd64.whl

Download URL lattice_cli-0.4.0-cp311-abi3-win_amd64.whl
Size 228.6 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c09d9ce3fe3e60e1fb089632523a32a7f078585b508f070b22c85c37622c860c
BLAKE2b-256 checksum
How to use checksums
77b58b260905fcc1b3d89dad34eb1bd78f91043f208d5132ac4f9645806573c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / lattice_cli-0.4.0-cp311-abi3-musllinux_1_2_x86_64.whl

Download URL lattice_cli-0.4.0-cp311-abi3-musllinux_1_2_x86_64.whl
Size 547.3 kB
Tags CPython 3.11 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
5ded2e4591efb2c68a1e2a1bf8cce797b1179c4239f81df63bb4c83978b87773
BLAKE2b-256 checksum
How to use checksums
c46ee36eefb4d44dfafa717dcf392cd6c71ac40bac4af19447bbb660f8137617
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / lattice_cli-0.4.0-cp311-abi3-musllinux_1_2_aarch64.whl

Download URL lattice_cli-0.4.0-cp311-abi3-musllinux_1_2_aarch64.whl
Size 508.3 kB
Tags CPython 3.11 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
4fea33d97ae95625e12c327f78e64d0cd1d6c920c117153988fb42e1a17a6c69
BLAKE2b-256 checksum
How to use checksums
b3e89a1b2af5019d8af7990757d67cb9287ae34aa48854319901c76c5cb4a1cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / lattice_cli-0.4.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL lattice_cli-0.4.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 336.3 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
f28baa1d9fe7bf53b10c6c95383cc1072ba55bc07a0691ff79ab6c91a1dd24b4
BLAKE2b-256 checksum
How to use checksums
3146f380065a83f12334c0757f2a562986fdbbe0b74bae3d3773e4f2d718c553
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / lattice_cli-0.4.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL lattice_cli-0.4.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 329.8 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
79e3466ce2d1072a61ae0fedae88236f72e27448d8e575c17e006bb74f407edb
BLAKE2b-256 checksum
How to use checksums
5b94bfc1b5c857adc8d53e20190431d76b36e32e80fce86806ddf3a519b490b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / lattice_cli-0.4.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL lattice_cli-0.4.0-cp311-abi3-macosx_11_0_arm64.whl
Size 311.4 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
56a889473f3eb611a2d5e5cb299540076bbbeb96dbac807517bfe40887a2b4a1
BLAKE2b-256 checksum
How to use checksums
85c7234c9bd6539803294163aa92af1fd1b3dfe0ad50374f42bc475d6a675bb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / lattice_cli-0.4.0-cp311-abi3-macosx_10_12_x86_64.whl

Download URL lattice_cli-0.4.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 321.3 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
460f1b72e4e73b7475e44ea18c1146af30f4ce2250fe48f6b63da31b3cdfc9f9
BLAKE2b-256 checksum
How to use checksums
8198c23f096506ce57fb12588f47ce3d8640148b964f64f926bf5fda7bf0222e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Security for lattice-cli 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 8 files in this release have been uploaded with provenance metadata.

Select from 8 files

Attestation for lattice_cli-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page