lattice-cli 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. lattice_cli-0.1.0/LICENSE +176 -0
  2. lattice_cli-0.1.0/PKG-INFO +229 -0
  3. lattice_cli-0.1.0/README.md +201 -0
  4. lattice_cli-0.1.0/pyproject.toml +69 -0
  5. lattice_cli-0.1.0/setup.cfg +4 -0
  6. lattice_cli-0.1.0/src/lattice/__init__.py +5 -0
  7. lattice_cli-0.1.0/src/lattice/__main__.py +5 -0
  8. lattice_cli-0.1.0/src/lattice/agent.py +150 -0
  9. lattice_cli-0.1.0/src/lattice/cli.py +488 -0
  10. lattice_cli-0.1.0/src/lattice/constraints.py +391 -0
  11. lattice_cli-0.1.0/src/lattice/formatters.py +131 -0
  12. lattice_cli-0.1.0/src/lattice/ipog.py +308 -0
  13. lattice_cli-0.1.0/src/lattice/model.py +116 -0
  14. lattice_cli-0.1.0/src/lattice/parser.py +404 -0
  15. lattice_cli-0.1.0/src/lattice/resources/claude/lattice-workflow/SKILL.md +109 -0
  16. lattice_cli-0.1.0/src/lattice/resources/claude/lattice-workflow/references/modeling-rules.md +52 -0
  17. lattice_cli-0.1.0/src/lattice/resources/claude/lattice-workflow/references/worked-examples.md +59 -0
  18. lattice_cli-0.1.0/src/lattice/resources/codex/lattice-workflow/SKILL.md +118 -0
  19. lattice_cli-0.1.0/src/lattice/resources/codex/lattice-workflow/agents/openai.yaml +7 -0
  20. lattice_cli-0.1.0/src/lattice/resources/codex/lattice-workflow/references/modeling-rules.md +52 -0
  21. lattice_cli-0.1.0/src/lattice/resources/codex/lattice-workflow/references/worked-examples.md +59 -0
  22. lattice_cli-0.1.0/src/lattice/resources/generic/lattice-workflow/SKILL.md +124 -0
  23. lattice_cli-0.1.0/src/lattice/resources/generic/lattice-workflow/references/modeling-rules.md +52 -0
  24. lattice_cli-0.1.0/src/lattice/resources/generic/lattice-workflow/references/worked-examples.md +59 -0
  25. lattice_cli-0.1.0/src/lattice_cli.egg-info/PKG-INFO +229 -0
  26. lattice_cli-0.1.0/src/lattice_cli.egg-info/SOURCES.txt +37 -0
  27. lattice_cli-0.1.0/src/lattice_cli.egg-info/dependency_links.txt +1 -0
  28. lattice_cli-0.1.0/src/lattice_cli.egg-info/entry_points.txt +2 -0
  29. lattice_cli-0.1.0/src/lattice_cli.egg-info/requires.txt +4 -0
  30. lattice_cli-0.1.0/src/lattice_cli.egg-info/top_level.txt +1 -0
  31. lattice_cli-0.1.0/tests/test_agent_bootstrap_matrix.py +129 -0
  32. lattice_cli-0.1.0/tests/test_cli.py +374 -0
  33. lattice_cli-0.1.0/tests/test_constraints.py +46 -0
  34. lattice_cli-0.1.0/tests/test_examples.py +81 -0
  35. lattice_cli-0.1.0/tests/test_ipog.py +104 -0
  36. lattice_cli-0.1.0/tests/test_model.py +26 -0
  37. lattice_cli-0.1.0/tests/test_parser.py +75 -0
  38. lattice_cli-0.1.0/tests/test_schema_guidance_matrix.py +111 -0
  39. lattice_cli-0.1.0/tests/test_self_hosting_matrix.py +104 -0
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,229 @@
1
+ Metadata-Version: 2.4
2
+ Name: lattice-cli
3
+ Version: 0.1.0
4
+ Summary: Deterministic combinatorial coverage for agent workflows and constrained variant surfaces.
5
+ Author-email: Tyler Klose <tylerklose@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/tylerklose/lattice
8
+ Project-URL: Repository, https://github.com/tylerklose/lattice
9
+ Project-URL: Issues, https://github.com/tylerklose/lattice/issues
10
+ Keywords: coding-agents,combinatorial-testing,component-variants,pairwise-testing,test-generation,visual-testing,coverage
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Software Development :: Quality Assurance
20
+ Classifier: Topic :: Software Development :: Testing
21
+ Requires-Python: >=3.11
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: PyYAML<7,>=6
25
+ Provides-Extra: solver
26
+ Requires-Dist: ortools<10,>=9.10; extra == "solver"
27
+ Dynamic: license-file
28
+
29
+ # Lattice
30
+
31
+ 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.
32
+
33
+ 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.
34
+
35
+ 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.
36
+
37
+ 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.
38
+
39
+ 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.
40
+
41
+ ## What this unlocks
42
+
43
+ **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.
44
+
45
+ **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](https://arxiv.org/abs/2602.00409) 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](https://github.com/anthropics/claude-code/issues/51856) 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.
46
+
47
+ 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.
48
+
49
+ 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.
50
+
51
+ ## How it goes
52
+
53
+ 1. The agent writes a small JSON or YAML schema: parameters, values, constraints.
54
+ 2. Pipe it to `lattice generate`.
55
+ 3. Lattice returns the covering rows. Same schema and seed always produce the same rows.
56
+ 4. The agent maps each row to whatever it's evaluating — a test, a render, a fixture, a sandbox call.
57
+
58
+ 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.
59
+
60
+ 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.
61
+
62
+ ## Install For Agents
63
+
64
+ Start with [docs/install.md](docs/install.md) when you want any coding agent or harness to adopt Lattice.
65
+
66
+ That page covers:
67
+
68
+ - installing the `lattice` CLI with `pipx`, `uvx`, or `pip`
69
+ - printing universal instructions with `lattice agent instructions`
70
+ - installing a generic `lattice-workflow` skill into any harness directory with `lattice agent install-skill <target>`
71
+ - installing Codex and Claude Code convenience skills with `lattice agent bootstrap`
72
+ - adding an agent memory for when to reach for Lattice
73
+ - running a smoke test over stdin
74
+
75
+ ## Why This Shape
76
+
77
+ Lattice is split into three small modules on purpose:
78
+
79
+ - `parser.py`: the schema contract between a harness and the engine
80
+ - `constraints.py`: deterministic feasibility and constraint reasoning
81
+ - `ipog.py`: covering-array generation and coverage accounting
82
+
83
+ That keeps the math isolated from OpenClaw, Hermes, Codex, xAI-backed agents, Claude Code, or any other harness wrapper.
84
+
85
+ ## CLI
86
+
87
+ ```bash
88
+ # stdin-first, harness-friendly
89
+ cat schema.json | lattice validate
90
+ cat schema.json | lattice generate
91
+
92
+ # file input is optional and useful for debugging
93
+ lattice validate schema.yaml --format text
94
+ lattice generate schema.yaml --strength 3 --format table
95
+ lattice generate schema.yaml --strength 4 --progress --progress-every 25 > scenarios.json
96
+ lattice generate schema.yaml --strength 4 --stop-after-coverage 84 > prefix.json
97
+
98
+ # explicit machine-readable validation
99
+ lattice validate schema.json --format json
100
+ ```
101
+
102
+ Supported output formats:
103
+
104
+ - `json`
105
+ - `table`
106
+ - `csv`
107
+ - `summary`
108
+
109
+ `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.
110
+
111
+ For long higher-strength runs, use `--progress` to stream coverage progress to
112
+ stderr while keeping stdout clean for JSON, CSV, table, or summary output.
113
+ `--progress-every N` controls how many generated scenarios pass between
114
+ updates.
115
+
116
+ Use `--stop-after-coverage PCT` for prefix runs that stop after the first
117
+ generated scenario reaching that cumulative coverage percentage. Use
118
+ `--max-rows N` for a fixed-size prefix. If both are set, generation stops at
119
+ whichever limit is reached first. `--stop-after-coverage 100` is treated as a
120
+ full run so rounded `100.0%` coverage near the tail does not skip final rows.
121
+
122
+ ## Model Features
123
+
124
+ Lattice currently supports:
125
+
126
+ - pairwise and t-way generation
127
+ - JSON and YAML schema transport
128
+ - `invalid_pair`
129
+ - `bidirectional`
130
+ - `forward_dep`
131
+ - `conditional`
132
+ - `forced`
133
+ - `higher_order`
134
+ - inline parameter `weights`
135
+ - deterministic generation via `--seed`
136
+
137
+ Model true impossibilities as constraints before generation. Do not strip
138
+ constraints and mark impossible rows downstream: that changes the coverage
139
+ surface from valid interactions to an unconstrained cross-product. Use
140
+ `invalid_pair` for two assignments that cannot coexist and `higher_order` when
141
+ the invalid rule needs multiple antecedents.
142
+
143
+ `conditional` parameters are first-class schema features. The parser expands them into concrete parameter domains and the constraint engine enforces `N/A` semantics automatically.
144
+
145
+ ## Solver Notes
146
+
147
+ The current engine is deterministic and self-contained. If `ortools` is installed via the `solver` extra, Lattice can use CP-SAT feasibility checks for partial assignments; otherwise it falls back to the built-in backtracking solver.
148
+
149
+ Install in editable mode while developing:
150
+
151
+ ```bash
152
+ python3 -m pip install -e /path/to/lattice
153
+ ```
154
+
155
+ Install with the optional solver backend:
156
+
157
+ ```bash
158
+ python3 -m pip install -e "/path/to/lattice[solver]"
159
+ ```
160
+
161
+ ## Using In Other Projects
162
+
163
+ The normal workflow in another repo is:
164
+
165
+ 1. install Lattice once into the Python environment your harness uses
166
+ 2. have the harness emit a schema on stdin
167
+ 3. call `lattice validate`
168
+ 4. call `lattice generate`
169
+ 5. consume the JSON output inside the harness
170
+
171
+ Example:
172
+
173
+ ```bash
174
+ cat schema.json | lattice validate
175
+ cat schema.json | lattice generate
176
+ ```
177
+
178
+ 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](docs/install.md), then see [docs/using-in-other-projects.md](docs/using-in-other-projects.md).
179
+
180
+ 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.
181
+
182
+ The shortest agent adoption path after install is:
183
+
184
+ ```bash
185
+ lattice agent instructions
186
+ lattice agent bootstrap
187
+ lattice agent doctor
188
+ ```
189
+
190
+ `instructions` works for any agent. `bootstrap` installs convenience skills only for known harnesses detected on the machine.
191
+
192
+ ## Harness Contract
193
+
194
+ Lattice is intentionally narrow. A harness owns extraction and interpretation; Lattice owns schema validation and deterministic row generation.
195
+
196
+ - plan synthesis: harness extracts schema from a plan, Lattice generates scenarios, harness strengthens the plan
197
+ - test synthesis: harness extracts schema from code/tests, Lattice generates scenarios, harness writes missing tests
198
+ - variant coverage: harness extracts component, template, or design-system variants, Lattice generates rows, harness renders screenshots, a contact sheet, or visual diffs
199
+ - evaluator coverage: harness extracts a config or sandbox matrix, Lattice generates rows, harness runs each row through the relevant evaluator
200
+
201
+ See [docs/agent-handoff.md](docs/agent-handoff.md) for the repository-level handoff shape.
202
+ See [docs/workflows.md](docs/workflows.md) for concrete agent usage patterns.
203
+ See [docs/case-studies.md](docs/case-studies.md) for public audit examples and the standard for how to write them up.
204
+ See [docs/using-in-other-projects.md](docs/using-in-other-projects.md) for portable installation and adoption.
205
+ See [docs/lattice-on-lattice.md](docs/lattice-on-lattice.md) for a worked example of Lattice testing its own agent bootstrap surface.
206
+
207
+ ## Skill
208
+
209
+ 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.
210
+
211
+ Use it when you want a coding harness to:
212
+
213
+ - extract a schema from code, a spec, or a variant surface
214
+ - validate the schema before generation
215
+ - run Lattice deterministically
216
+ - interpret the rows as design review scenarios, rendered variants, fixtures, or test cases
217
+
218
+ ## Examples
219
+
220
+ The `examples/` directory contains eight end-to-end examples:
221
+
222
+ - `plan-mode-saved-search`: plan -> schema -> generated scenarios
223
+ - `test-mode-checkout`: code/test surface -> schema -> generated scenarios
224
+ - `three-way-notifications`: strength-3 schema -> generated scenarios
225
+ - `lattice-self-test`: Lattice generates a matrix for testing Lattice itself
226
+ - `agent-bootstrap-matrix`: Lattice generates a matrix for testing agent skill bootstrap behavior
227
+ - `schema-guidance-matrix`: Lattice generates a matrix for testing Lattice's schema discoverability guidance
228
+ - `component-variant-matrix`: component/rendering surface -> schema -> generated visual review variants
229
+ - `httpx-query-param-merge`: OSS audit example for a real HTTPX query-parameter interaction issue
@@ -0,0 +1,201 @@
1
+ # Lattice
2
+
3
+ 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.
4
+
5
+ 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.
6
+
7
+ 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.
8
+
9
+ 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.
10
+
11
+ 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.
12
+
13
+ ## What this unlocks
14
+
15
+ **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.
16
+
17
+ **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](https://arxiv.org/abs/2602.00409) 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](https://github.com/anthropics/claude-code/issues/51856) 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.
18
+
19
+ 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.
20
+
21
+ 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.
22
+
23
+ ## How it goes
24
+
25
+ 1. The agent writes a small JSON or YAML schema: parameters, values, constraints.
26
+ 2. Pipe it to `lattice generate`.
27
+ 3. Lattice returns the covering rows. Same schema and seed always produce the same rows.
28
+ 4. The agent maps each row to whatever it's evaluating — a test, a render, a fixture, a sandbox call.
29
+
30
+ 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.
31
+
32
+ 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.
33
+
34
+ ## Install For Agents
35
+
36
+ Start with [docs/install.md](docs/install.md) when you want any coding agent or harness to adopt Lattice.
37
+
38
+ That page covers:
39
+
40
+ - installing the `lattice` CLI with `pipx`, `uvx`, or `pip`
41
+ - printing universal instructions with `lattice agent instructions`
42
+ - installing a generic `lattice-workflow` skill into any harness directory with `lattice agent install-skill <target>`
43
+ - installing Codex and Claude Code convenience skills with `lattice agent bootstrap`
44
+ - adding an agent memory for when to reach for Lattice
45
+ - running a smoke test over stdin
46
+
47
+ ## Why This Shape
48
+
49
+ Lattice is split into three small modules on purpose:
50
+
51
+ - `parser.py`: the schema contract between a harness and the engine
52
+ - `constraints.py`: deterministic feasibility and constraint reasoning
53
+ - `ipog.py`: covering-array generation and coverage accounting
54
+
55
+ That keeps the math isolated from OpenClaw, Hermes, Codex, xAI-backed agents, Claude Code, or any other harness wrapper.
56
+
57
+ ## CLI
58
+
59
+ ```bash
60
+ # stdin-first, harness-friendly
61
+ cat schema.json | lattice validate
62
+ cat schema.json | lattice generate
63
+
64
+ # file input is optional and useful for debugging
65
+ lattice validate schema.yaml --format text
66
+ lattice generate schema.yaml --strength 3 --format table
67
+ lattice generate schema.yaml --strength 4 --progress --progress-every 25 > scenarios.json
68
+ lattice generate schema.yaml --strength 4 --stop-after-coverage 84 > prefix.json
69
+
70
+ # explicit machine-readable validation
71
+ lattice validate schema.json --format json
72
+ ```
73
+
74
+ Supported output formats:
75
+
76
+ - `json`
77
+ - `table`
78
+ - `csv`
79
+ - `summary`
80
+
81
+ `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.
82
+
83
+ For long higher-strength runs, use `--progress` to stream coverage progress to
84
+ stderr while keeping stdout clean for JSON, CSV, table, or summary output.
85
+ `--progress-every N` controls how many generated scenarios pass between
86
+ updates.
87
+
88
+ Use `--stop-after-coverage PCT` for prefix runs that stop after the first
89
+ generated scenario reaching that cumulative coverage percentage. Use
90
+ `--max-rows N` for a fixed-size prefix. If both are set, generation stops at
91
+ whichever limit is reached first. `--stop-after-coverage 100` is treated as a
92
+ full run so rounded `100.0%` coverage near the tail does not skip final rows.
93
+
94
+ ## Model Features
95
+
96
+ Lattice currently supports:
97
+
98
+ - pairwise and t-way generation
99
+ - JSON and YAML schema transport
100
+ - `invalid_pair`
101
+ - `bidirectional`
102
+ - `forward_dep`
103
+ - `conditional`
104
+ - `forced`
105
+ - `higher_order`
106
+ - inline parameter `weights`
107
+ - deterministic generation via `--seed`
108
+
109
+ Model true impossibilities as constraints before generation. Do not strip
110
+ constraints and mark impossible rows downstream: that changes the coverage
111
+ surface from valid interactions to an unconstrained cross-product. Use
112
+ `invalid_pair` for two assignments that cannot coexist and `higher_order` when
113
+ the invalid rule needs multiple antecedents.
114
+
115
+ `conditional` parameters are first-class schema features. The parser expands them into concrete parameter domains and the constraint engine enforces `N/A` semantics automatically.
116
+
117
+ ## Solver Notes
118
+
119
+ The current engine is deterministic and self-contained. If `ortools` is installed via the `solver` extra, Lattice can use CP-SAT feasibility checks for partial assignments; otherwise it falls back to the built-in backtracking solver.
120
+
121
+ Install in editable mode while developing:
122
+
123
+ ```bash
124
+ python3 -m pip install -e /path/to/lattice
125
+ ```
126
+
127
+ Install with the optional solver backend:
128
+
129
+ ```bash
130
+ python3 -m pip install -e "/path/to/lattice[solver]"
131
+ ```
132
+
133
+ ## Using In Other Projects
134
+
135
+ The normal workflow in another repo is:
136
+
137
+ 1. install Lattice once into the Python environment your harness uses
138
+ 2. have the harness emit a schema on stdin
139
+ 3. call `lattice validate`
140
+ 4. call `lattice generate`
141
+ 5. consume the JSON output inside the harness
142
+
143
+ Example:
144
+
145
+ ```bash
146
+ cat schema.json | lattice validate
147
+ cat schema.json | lattice generate
148
+ ```
149
+
150
+ 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](docs/install.md), then see [docs/using-in-other-projects.md](docs/using-in-other-projects.md).
151
+
152
+ 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.
153
+
154
+ The shortest agent adoption path after install is:
155
+
156
+ ```bash
157
+ lattice agent instructions
158
+ lattice agent bootstrap
159
+ lattice agent doctor
160
+ ```
161
+
162
+ `instructions` works for any agent. `bootstrap` installs convenience skills only for known harnesses detected on the machine.
163
+
164
+ ## Harness Contract
165
+
166
+ Lattice is intentionally narrow. A harness owns extraction and interpretation; Lattice owns schema validation and deterministic row generation.
167
+
168
+ - plan synthesis: harness extracts schema from a plan, Lattice generates scenarios, harness strengthens the plan
169
+ - test synthesis: harness extracts schema from code/tests, Lattice generates scenarios, harness writes missing tests
170
+ - variant coverage: harness extracts component, template, or design-system variants, Lattice generates rows, harness renders screenshots, a contact sheet, or visual diffs
171
+ - evaluator coverage: harness extracts a config or sandbox matrix, Lattice generates rows, harness runs each row through the relevant evaluator
172
+
173
+ See [docs/agent-handoff.md](docs/agent-handoff.md) for the repository-level handoff shape.
174
+ See [docs/workflows.md](docs/workflows.md) for concrete agent usage patterns.
175
+ See [docs/case-studies.md](docs/case-studies.md) for public audit examples and the standard for how to write them up.
176
+ See [docs/using-in-other-projects.md](docs/using-in-other-projects.md) for portable installation and adoption.
177
+ See [docs/lattice-on-lattice.md](docs/lattice-on-lattice.md) for a worked example of Lattice testing its own agent bootstrap surface.
178
+
179
+ ## Skill
180
+
181
+ 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.
182
+
183
+ Use it when you want a coding harness to:
184
+
185
+ - extract a schema from code, a spec, or a variant surface
186
+ - validate the schema before generation
187
+ - run Lattice deterministically
188
+ - interpret the rows as design review scenarios, rendered variants, fixtures, or test cases
189
+
190
+ ## Examples
191
+
192
+ The `examples/` directory contains eight end-to-end examples:
193
+
194
+ - `plan-mode-saved-search`: plan -> schema -> generated scenarios
195
+ - `test-mode-checkout`: code/test surface -> schema -> generated scenarios
196
+ - `three-way-notifications`: strength-3 schema -> generated scenarios
197
+ - `lattice-self-test`: Lattice generates a matrix for testing Lattice itself
198
+ - `agent-bootstrap-matrix`: Lattice generates a matrix for testing agent skill bootstrap behavior
199
+ - `schema-guidance-matrix`: Lattice generates a matrix for testing Lattice's schema discoverability guidance
200
+ - `component-variant-matrix`: component/rendering surface -> schema -> generated visual review variants
201
+ - `httpx-query-param-merge`: OSS audit example for a real HTTPX query-parameter interaction issue