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, up to 100,000 values once aliases are expanded; 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.1

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.1
File Size Uploaded Provenance Actions
lattice_cli-0.4.1.tar.gz 38.4 kB With provenance Details for lattice_cli-0.4.1.tar.gz

Built distributions (wheels)

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

Total release size: 2.6 MB

Release files / lattice_cli-0.4.1.tar.gz

Download URL lattice_cli-0.4.1.tar.gz
Size 38.4 kB
Tags Source
SHA-256 checksum
How to use checksums
523bc8e55089c5451b7cbebc02b2edee095933e93edd4257eb136e07c96b2e5f
BLAKE2b-256 checksum
How to use checksums
dd53b32c0ccdac823b110aa7b5b605b09f4029bdb8f8d8c2bab2f33d04ed239f
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 5, 2026.

Transparency log

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

Download URL lattice_cli-0.4.1-cp311-abi3-win_amd64.whl
Size 229.1 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
15da4b21258ba61979b8e3eaa7834afd2f037603b7af08f8e6b6b742531da8ff
BLAKE2b-256 checksum
How to use checksums
fd1d3c14ba6587f6eba2a04bb0868d677b388ef47d9e8bfa5291d523a2fdd0e8
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 5, 2026.

Transparency log

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

Download URL lattice_cli-0.4.1-cp311-abi3-musllinux_1_2_x86_64.whl
Size 547.9 kB
Tags CPython 3.11 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
0459ac9370056af4336de54c8d944834e852ad9a34ab60187f89f005e9dab033
BLAKE2b-256 checksum
How to use checksums
38779dcd7c152fc558f9e9dc87c02da215c009f629f8f2d5286a6d0bebc477d0
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 5, 2026.

Transparency log

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

Download URL lattice_cli-0.4.1-cp311-abi3-musllinux_1_2_aarch64.whl
Size 508.7 kB
Tags CPython 3.11 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
8cd046cf9f8d1f2b4c827ae7ddca8fa5a3a762e45361e0a73b7c02b7531132ef
BLAKE2b-256 checksum
How to use checksums
7c30bd41f508265753746da9609e178e91cd660a6da2852805677eb0e9595d0c
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 5, 2026.

Transparency log

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

Download URL lattice_cli-0.4.1-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 336.8 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
ab817470e4dc8f4c6f3dcba9b3807147a0ecde33f8e1362946211f37da62da2d
BLAKE2b-256 checksum
How to use checksums
caba8a52370832d56efb3e340495ad70af3b29e6998b52c10014eaf9f8ad850e
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 5, 2026.

Transparency log

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

Download URL lattice_cli-0.4.1-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 330.1 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
8f2ef90ac9ad07bc55024a88b446d3a4a7136882d82b55efe44d671f9d2c6130
BLAKE2b-256 checksum
How to use checksums
10b0c00efe8e6a7463fbcd4cf64ec209d50edfe791eb29b6c6d74891d16f70cf
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 5, 2026.

Transparency log

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

Download URL lattice_cli-0.4.1-cp311-abi3-macosx_11_0_arm64.whl
Size 311.9 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e960cbd4d54fe38e06a47ac1c50cc98a26afc35c538ade6a9994e53ae52c5203
BLAKE2b-256 checksum
How to use checksums
6feffbf91eb56a84493ab2c1b5f3a67a374c2b7cd4e6999d187840edbf2c0c92
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 5, 2026.

Transparency log

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

Download URL lattice_cli-0.4.1-cp311-abi3-macosx_10_12_x86_64.whl
Size 321.8 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
9e5ab383394fc915d012e665dd8baca0de06437d6b87c80a8eb6be1455cb53cd
BLAKE2b-256 checksum
How to use checksums
f5c846477293f96de7eadccff6c58478abe42ee513eeccbc5218fc6c7661d614
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 5, 2026.

Transparency log

Security for lattice-cli 0.4.1

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.1.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 5, 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