lattice-cli 0.1.0__py3-none-any.whl
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.
- lattice/__init__.py +5 -0
- lattice/__main__.py +5 -0
- lattice/agent.py +150 -0
- lattice/cli.py +488 -0
- lattice/constraints.py +391 -0
- lattice/formatters.py +131 -0
- lattice/ipog.py +308 -0
- lattice/model.py +116 -0
- lattice/parser.py +404 -0
- lattice/resources/claude/lattice-workflow/SKILL.md +109 -0
- lattice/resources/claude/lattice-workflow/references/modeling-rules.md +52 -0
- lattice/resources/claude/lattice-workflow/references/worked-examples.md +59 -0
- lattice/resources/codex/lattice-workflow/SKILL.md +118 -0
- lattice/resources/codex/lattice-workflow/agents/openai.yaml +7 -0
- lattice/resources/codex/lattice-workflow/references/modeling-rules.md +52 -0
- lattice/resources/codex/lattice-workflow/references/worked-examples.md +59 -0
- lattice/resources/generic/lattice-workflow/SKILL.md +124 -0
- lattice/resources/generic/lattice-workflow/references/modeling-rules.md +52 -0
- lattice/resources/generic/lattice-workflow/references/worked-examples.md +59 -0
- lattice_cli-0.1.0.dist-info/METADATA +229 -0
- lattice_cli-0.1.0.dist-info/RECORD +25 -0
- lattice_cli-0.1.0.dist-info/WHEEL +5 -0
- lattice_cli-0.1.0.dist-info/entry_points.txt +2 -0
- lattice_cli-0.1.0.dist-info/licenses/LICENSE +176 -0
- lattice_cli-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: lattice-workflow
|
|
3
|
+
description: Use when planning or testing behavior or variant surfaces with interacting states, roles, permissions, feature flags, modes, providers, optional fields, component props, rendering branches, template variants, config matrices, lifecycle states, combinatorial edge cases, pairwise coverage, or t-way coverage. Extract a Lattice schema, run the local Lattice CLI, and use generated rows to strengthen plans, tests, fixtures, rendered variants, or review matrices.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Lattice Workflow
|
|
7
|
+
|
|
8
|
+
Use this skill to keep the agent on the extraction and interpretation work while Lattice handles the combinatorics.
|
|
9
|
+
|
|
10
|
+
## When To Use It
|
|
11
|
+
|
|
12
|
+
Use this skill when the task is any of:
|
|
13
|
+
|
|
14
|
+
- derive a combinatorial model from a feature or PRD
|
|
15
|
+
- derive a test matrix from existing code
|
|
16
|
+
- derive a variant matrix from a component, partial, template, design-system story, or config surface
|
|
17
|
+
- convert edge cases into explicit parameter/value constraints
|
|
18
|
+
- generate pairwise or 3-way scenarios without hand-enumerating combinations
|
|
19
|
+
- render a compact visual review matrix instead of every possible variant
|
|
20
|
+
- review a plan involving roles, permissions, modes, providers, feature flags, optional fields, component props, rendering branches, template variants, config matrices, or lifecycle states
|
|
21
|
+
- find coverage gaps where bugs are likely to hide in interactions rather than single branches
|
|
22
|
+
|
|
23
|
+
Do not use this skill to invent pairwise combinations manually. The schema is the contract. The generated rows are the source of truth. The schema file is optional transport.
|
|
24
|
+
|
|
25
|
+
## Preflight
|
|
26
|
+
|
|
27
|
+
Before using this skill, check whether `lattice` is already installed:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
command -v lattice >/dev/null 2>&1 && lattice --help >/dev/null
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If that succeeds, use the installed command.
|
|
34
|
+
|
|
35
|
+
If it fails and you know the path to the Lattice source checkout, install it into the current Python environment:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
python3 -m pip install -e /path/to/lattice
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
To install or refresh this skill from the installed package:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
lattice agent bootstrap
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
If the skill was copied from a Lattice checkout, the agent setup page is available at `docs/install.md` in that checkout.
|
|
48
|
+
|
|
49
|
+
In this repository, the development fallback remains:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
cat schema.json | PYTHONPATH=src python3 -m lattice validate
|
|
53
|
+
cat schema.json | PYTHONPATH=src python3 -m lattice generate
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Workflow
|
|
57
|
+
|
|
58
|
+
1. Extract the schema.
|
|
59
|
+
First choose the scope. A schema should usually describe one coherent interaction surface: one feature, one workflow, one service behavior, one endpoint family, one rendering surface, one component's variant space, one template family, one config matrix, or one data-model interaction surface. Then choose parameters that represent independent decisions or state partitions inside that scope. Choose values that are meaningful partitions, not every literal in the codebase.
|
|
60
|
+
2. Encode constraints.
|
|
61
|
+
Prefer the smallest constraint type that matches the rule. Lattice supports exclusion-style constraints, not only conditional parameters: use `invalid_pair` when two assignments cannot coexist and `higher_order` when a combination only becomes invalid with multiple antecedents. Use `conditional` instead of hand-writing `N/A` values.
|
|
62
|
+
3. Validate before generation.
|
|
63
|
+
Prefer the installed `lattice` command with JSON or YAML on stdin:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
cat schema.json | lattice validate
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
If you are working inside this repository and the package is not installed yet, the fallback is:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cat schema.json | PYTHONPATH=src python3 -m lattice validate
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Use a temp file only if the harness needs one for debugging or tool interop.
|
|
76
|
+
4. Generate deterministic scenarios.
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
cat schema.json | lattice generate
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The development fallback in this repo is:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
cat schema.json | PYTHONPATH=src python3 -m lattice generate
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Default to pairwise unless the user explicitly asks for a higher strength.
|
|
89
|
+
5. Interpret the output.
|
|
90
|
+
In plan mode, turn rows into plan revisions, missing decisions, and review scenarios. In test mode, diff the rows against the existing tests and write the missing cases. In variant mode, turn rows into fixtures, rendered variants, screenshots, contact sheets, visual diff inputs, or review checklists.
|
|
91
|
+
|
|
92
|
+
In test mode, source expected behavior from intent — the user's request, a spec, a PRD, a ticket, or explicit reasoning about what the system *should* do. The code under test is evidence, not truth. If intent is ambiguous for a row, stop and ask the user. Do not silently encode current behavior and hedge with `bug_signal:`-style annotations: that produces characterization tests, which lock in the implementation (bugs included) instead of catching divergence from intent. The asymmetries Lattice is designed to expose disappear when the test suite mirrors the same mental model as the code.
|
|
93
|
+
|
|
94
|
+
## Modeling Rules
|
|
95
|
+
|
|
96
|
+
- Scope one schema to one interaction surface. Do not default to the whole app unless the app is genuinely small and the behavior or rendering surface is still coherent.
|
|
97
|
+
- Keep parameter names stable and implementation-adjacent.
|
|
98
|
+
- Use value partitions such as `present` and `absent`, not brittle prose.
|
|
99
|
+
- Avoid derived duplicate parameters. If one field is determined by another, represent that as a constraint.
|
|
100
|
+
- Add constraints only for true business or system rules. Do not use them to encode preferences.
|
|
101
|
+
- Do not strip true constraints to make generation easier, and do not generate nonsensical rows just to mark them invalid later. Encoding constraints changes the coverage universe to valid interactions, which is the point of using Lattice.
|
|
102
|
+
- If two assignments cannot coexist, use `invalid_pair`.
|
|
103
|
+
- If a parameter only matters under a parent value, use `conditional`.
|
|
104
|
+
- If a scenario must appear at least once, use `forced`.
|
|
105
|
+
- If a rule only breaks under multiple antecedents, use `higher_order`.
|
|
106
|
+
|
|
107
|
+
Read [references/modeling-rules.md](references/modeling-rules.md) when you need extraction heuristics or constraint selection guidance.
|
|
108
|
+
|
|
109
|
+
## Output Discipline
|
|
110
|
+
|
|
111
|
+
- Run `validate` before `generate`.
|
|
112
|
+
- Prefer stdin and JSON because another agent step usually consumes the output.
|
|
113
|
+
- Do not add or remove rows after generation.
|
|
114
|
+
- If validation fails, fix the schema instead of weakening the generation step.
|
|
115
|
+
- If generation emits rows that are impossible in the target system, stop and add the missing constraint rather than filtering or annotating those rows downstream.
|
|
116
|
+
- In test mode, assertions must reflect intended behavior, not observed behavior. Read intent from the spec, PRD, ticket, or user — never from the code under test. If intent is ambiguous, stop and ask.
|
|
117
|
+
|
|
118
|
+
Read [references/worked-examples.md](references/worked-examples.md) for concrete examples in this repo.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Lattice Workflow"
|
|
3
|
+
short_description: "Generate pairwise coverage for plans, tests, and variants"
|
|
4
|
+
default_prompt: "Use $lattice-workflow to model interacting states or variant dimensions, extract a Lattice schema, validate it, generate pairwise rows, and use the rows to strengthen the plan, tests, fixtures, or visual review."
|
|
5
|
+
|
|
6
|
+
policy:
|
|
7
|
+
allow_implicit_invocation: true
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Modeling Rules
|
|
2
|
+
|
|
3
|
+
Use this file when you are extracting a schema from code or prose and need tighter guardrails than the main skill body provides.
|
|
4
|
+
|
|
5
|
+
## Parameter Selection
|
|
6
|
+
|
|
7
|
+
- Scope one schema to one coherent behavior or rendering surface.
|
|
8
|
+
Good scopes: one feature, one service behavior, one workflow, one endpoint family, one state-machine slice, one component's variant space, one template family.
|
|
9
|
+
Bad default scope: the whole app.
|
|
10
|
+
- Model the decisions that change behavior, not every field in a payload.
|
|
11
|
+
- Prefer parameters that are visible in tests, UI branches, rendering branches, validation logic, template variants, component props, or feature flags.
|
|
12
|
+
- Split large raw domains into behavioral partitions.
|
|
13
|
+
Good: `pay_range = present|absent`
|
|
14
|
+
Bad: every exact salary string
|
|
15
|
+
- Avoid separate parameters for values that are already implied by another parameter unless the implication is partial and needs a constraint.
|
|
16
|
+
|
|
17
|
+
## Value Selection
|
|
18
|
+
|
|
19
|
+
- Values should be mutually exclusive and collectively useful for testing.
|
|
20
|
+
- Keep domains small and meaningful. Most parameters should land in the 2-5 value range.
|
|
21
|
+
- Normalize booleans as `true` and `false`.
|
|
22
|
+
- For optional subordinate parameters, let `conditional` introduce `N/A`. Do not hand-add `N/A` unless the schema genuinely needs it as a first-class value.
|
|
23
|
+
|
|
24
|
+
## Constraint Choice
|
|
25
|
+
|
|
26
|
+
- `invalid_pair`: two assignments cannot coexist
|
|
27
|
+
- `bidirectional`: one-to-one pairing; if A then B and if B then A
|
|
28
|
+
- `forward_dep`: A requires B, but B may appear elsewhere
|
|
29
|
+
- `conditional`: a child parameter only applies for some parent values
|
|
30
|
+
- `forced`: this assignment set must appear in at least one generated row
|
|
31
|
+
- `higher_order`: the invalid rule only appears when two or more antecedents are true
|
|
32
|
+
|
|
33
|
+
Choose the smallest expressive type. If a rule can be represented as `invalid_pair`, do not use `higher_order`.
|
|
34
|
+
|
|
35
|
+
Do not strip true constraints to get a smaller or easier unconstrained run. Do not generate nonsensical rows and mark them invalid downstream. Lattice's coverage accounting should run over valid interactions, so impossible combinations belong in the schema as `invalid_pair`, `forward_dep`, `bidirectional`, `conditional`, or `higher_order` constraints.
|
|
36
|
+
|
|
37
|
+
## Extraction Process
|
|
38
|
+
|
|
39
|
+
1. Choose the behavior or rendering surface you are modeling.
|
|
40
|
+
2. Start from branches, validations, and business rules inside that scope.
|
|
41
|
+
3. Convert prose like "only when", "must", "cannot", and "except" into candidate constraints.
|
|
42
|
+
4. Remove cosmetic parameters that do not affect behavior.
|
|
43
|
+
5. Check whether a missing value is really a separate partition or just noise.
|
|
44
|
+
6. Validate the schema.
|
|
45
|
+
7. Only after validation, generate scenarios.
|
|
46
|
+
|
|
47
|
+
## Interpretation
|
|
48
|
+
|
|
49
|
+
- Plan mode: each row becomes a review scenario or a missing decision in the plan.
|
|
50
|
+
- Test mode: each row becomes a candidate setup matrix. Source the expected behavior from intent — user request, spec, PRD, or ticket — not from the code under test. If you cannot determine intent for a row, stop and surface the ambiguity to the user. Do not encode the current behavior and label it `bug_signal:` to hedge: characterization tests pass for the wrong reasons and hide the asymmetries Lattice is designed to expose. Example: if a mailbox accepts a spoofed `From:` header today, the assertion is still "rejects spoofed sender" — let the test fail and fix the code, do not invert the assertion to match the bug.
|
|
51
|
+
- Variant mode: each row becomes a rendered variant, fixture, screenshot, visual diff input, contact-sheet item, or review checklist item.
|
|
52
|
+
- Generated rows are not test names by themselves. The agent still needs to map them to application-specific assertions.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Worked Examples
|
|
2
|
+
|
|
3
|
+
These examples live in the repo-level `examples/` directory.
|
|
4
|
+
|
|
5
|
+
## `examples/plan-mode-saved-search`
|
|
6
|
+
|
|
7
|
+
Use when the agent starts from a feature discussion or PRD and needs a review checklist.
|
|
8
|
+
|
|
9
|
+
- Input: `feature.md`
|
|
10
|
+
- Schema transport: `model.yaml`
|
|
11
|
+
- Output: `scenarios.json`
|
|
12
|
+
|
|
13
|
+
## `examples/test-mode-checkout`
|
|
14
|
+
|
|
15
|
+
Use when the agent starts from code and an existing test surface and needs missing cases.
|
|
16
|
+
|
|
17
|
+
- Input: `code-notes.md`
|
|
18
|
+
- Schema transport: `model.json`
|
|
19
|
+
- Output: `scenarios.json`
|
|
20
|
+
|
|
21
|
+
## `examples/three-way-notifications`
|
|
22
|
+
|
|
23
|
+
Use when pairwise is not enough and the user explicitly wants 3-way coverage.
|
|
24
|
+
|
|
25
|
+
- Input: `brief.md`
|
|
26
|
+
- Schema transport: `model.yaml`
|
|
27
|
+
- Output: `scenarios.json`
|
|
28
|
+
|
|
29
|
+
## `examples/component-variant-matrix`
|
|
30
|
+
|
|
31
|
+
Use when the agent starts from a visual component, rendering surface, template, or design-system story and needs compact review variants instead of every possible combination.
|
|
32
|
+
|
|
33
|
+
- Input: `brief.md`
|
|
34
|
+
- Schema transport: `model.yaml`
|
|
35
|
+
- Output: `scenarios.json`
|
|
36
|
+
|
|
37
|
+
## `examples/lattice-self-test`
|
|
38
|
+
|
|
39
|
+
Use when you want a meta example of the harness extracting a schema for Lattice's own CLI surface and then using generated rows to drive CLI smoke tests.
|
|
40
|
+
|
|
41
|
+
- Input: `brief.md`
|
|
42
|
+
- Schema transport: `model.yaml`
|
|
43
|
+
- Output: `scenarios.json`
|
|
44
|
+
|
|
45
|
+
## `examples/agent-bootstrap-matrix`
|
|
46
|
+
|
|
47
|
+
Use when you want a meta example of Lattice testing its own agent skill bootstrap behavior across harness detection, force/skip directives, target modes, and output formats.
|
|
48
|
+
|
|
49
|
+
- Input: `brief.md`
|
|
50
|
+
- Schema transport: `model.yaml`
|
|
51
|
+
- Output: `scenarios.json`
|
|
52
|
+
|
|
53
|
+
## `examples/schema-guidance-matrix`
|
|
54
|
+
|
|
55
|
+
Use when you want a meta example of Lattice testing its own schema-discoverability guidance across help text, agent instructions, installed skill files, and validation errors.
|
|
56
|
+
|
|
57
|
+
- Input: `brief.md`
|
|
58
|
+
- Schema transport: `model.yaml`
|
|
59
|
+
- Output: `scenarios.json`
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: lattice-workflow
|
|
3
|
+
description: Use when planning or testing behavior or variant surfaces with interacting states, roles, permissions, feature flags, modes, providers, optional fields, component props, rendering branches, template variants, config matrices, lifecycle states, combinatorial edge cases, pairwise coverage, or t-way coverage. Extract a Lattice schema, run the local Lattice CLI, and use generated rows to strengthen plans, tests, fixtures, rendered variants, or review matrices.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Lattice Workflow
|
|
7
|
+
|
|
8
|
+
Use this skill to keep the agent on the extraction and interpretation work while Lattice handles the combinatorics.
|
|
9
|
+
|
|
10
|
+
## When To Use It
|
|
11
|
+
|
|
12
|
+
Use this skill when the task is any of:
|
|
13
|
+
|
|
14
|
+
- derive a combinatorial model from a feature or PRD
|
|
15
|
+
- derive a test matrix from existing code
|
|
16
|
+
- derive a variant matrix from a component, partial, template, design-system story, or config surface
|
|
17
|
+
- convert edge cases into explicit parameter/value constraints
|
|
18
|
+
- generate pairwise or 3-way scenarios without hand-enumerating combinations
|
|
19
|
+
- render a compact visual review matrix instead of every possible variant
|
|
20
|
+
- review a plan involving roles, permissions, modes, providers, feature flags, optional fields, component props, rendering branches, template variants, config matrices, or lifecycle states
|
|
21
|
+
- find coverage gaps where bugs are likely to hide in interactions rather than single branches
|
|
22
|
+
|
|
23
|
+
Do not use this skill to invent pairwise combinations manually. The schema is the contract. The generated rows are the source of truth. The schema file is optional transport.
|
|
24
|
+
|
|
25
|
+
## Preflight
|
|
26
|
+
|
|
27
|
+
Before using this skill, check whether `lattice` is already installed:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
command -v lattice >/dev/null 2>&1 && lattice --help >/dev/null
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If that succeeds, use the installed command.
|
|
34
|
+
|
|
35
|
+
If it fails and you know the path to the Lattice source checkout, install it into the current Python environment:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
python3 -m pip install -e /path/to/lattice
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
To install or refresh a generic copy of this skill from the installed package:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
lattice agent install-skill /path/to/harness/skills/lattice-workflow
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
For harnesses that do not use skill directories, copy the output of:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
lattice agent instructions
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
into the harness memory, system instruction, rule file, or project instruction mechanism.
|
|
54
|
+
|
|
55
|
+
In this repository, the development fallback remains:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
cat schema.json | PYTHONPATH=src python3 -m lattice validate
|
|
59
|
+
cat schema.json | PYTHONPATH=src python3 -m lattice generate
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Workflow
|
|
63
|
+
|
|
64
|
+
1. Extract the schema.
|
|
65
|
+
First choose the scope. A schema should usually describe one coherent interaction surface: one feature, one workflow, one service behavior, one endpoint family, one rendering surface, one component's variant space, one template family, one config matrix, or one data-model interaction surface. Then choose parameters that represent independent decisions or state partitions inside that scope. Choose values that are meaningful partitions, not every literal in the codebase.
|
|
66
|
+
2. Encode constraints.
|
|
67
|
+
Prefer the smallest constraint type that matches the rule. Lattice supports exclusion-style constraints, not only conditional parameters: use `invalid_pair` when two assignments cannot coexist and `higher_order` when a combination only becomes invalid with multiple antecedents. Use `conditional` instead of hand-writing `N/A` values.
|
|
68
|
+
3. Validate before generation.
|
|
69
|
+
Prefer the installed `lattice` command with JSON or YAML on stdin:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cat schema.json | lattice validate
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
If you are working inside this repository and the package is not installed yet, the fallback is:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
cat schema.json | PYTHONPATH=src python3 -m lattice validate
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Use a temp file only if the harness needs one for debugging or tool interop.
|
|
82
|
+
4. Generate deterministic scenarios.
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
cat schema.json | lattice generate
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The development fallback in this repo is:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
cat schema.json | PYTHONPATH=src python3 -m lattice generate
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Default to pairwise unless the user explicitly asks for a higher strength.
|
|
95
|
+
5. Interpret the output.
|
|
96
|
+
In plan mode, turn rows into plan revisions, missing decisions, and review scenarios. In test mode, diff the rows against the existing tests and write the missing cases. In variant mode, turn rows into fixtures, rendered variants, screenshots, contact sheets, visual diff inputs, or review checklists.
|
|
97
|
+
|
|
98
|
+
In test mode, source expected behavior from intent — the user's request, a spec, a PRD, a ticket, or explicit reasoning about what the system *should* do. The code under test is evidence, not truth. If intent is ambiguous for a row, stop and ask the user. Do not silently encode current behavior and hedge with `bug_signal:`-style annotations: that produces characterization tests, which lock in the implementation (bugs included) instead of catching divergence from intent. The asymmetries Lattice is designed to expose disappear when the test suite mirrors the same mental model as the code.
|
|
99
|
+
|
|
100
|
+
## Modeling Rules
|
|
101
|
+
|
|
102
|
+
- Scope one schema to one interaction surface. Do not default to the whole app unless the app is genuinely small and the behavior or rendering surface is still coherent.
|
|
103
|
+
- Keep parameter names stable and implementation-adjacent.
|
|
104
|
+
- Use value partitions such as `present` and `absent`, not brittle prose.
|
|
105
|
+
- Avoid derived duplicate parameters. If one field is determined by another, represent that as a constraint.
|
|
106
|
+
- Add constraints only for true business or system rules. Do not use them to encode preferences.
|
|
107
|
+
- Do not strip true constraints to make generation easier, and do not generate nonsensical rows just to mark them invalid later. Encoding constraints changes the coverage universe to valid interactions, which is the point of using Lattice.
|
|
108
|
+
- If two assignments cannot coexist, use `invalid_pair`.
|
|
109
|
+
- If a parameter only matters under a parent value, use `conditional`.
|
|
110
|
+
- If a scenario must appear at least once, use `forced`.
|
|
111
|
+
- If a rule only breaks under multiple antecedents, use `higher_order`.
|
|
112
|
+
|
|
113
|
+
Read [references/modeling-rules.md](references/modeling-rules.md) when you need extraction heuristics or constraint selection guidance.
|
|
114
|
+
|
|
115
|
+
## Output Discipline
|
|
116
|
+
|
|
117
|
+
- Run `validate` before `generate`.
|
|
118
|
+
- Prefer stdin and JSON because another agent step usually consumes the output.
|
|
119
|
+
- Do not add or remove rows after generation.
|
|
120
|
+
- If validation fails, fix the schema instead of weakening the generation step.
|
|
121
|
+
- If generation emits rows that are impossible in the target system, stop and add the missing constraint rather than filtering or annotating those rows downstream.
|
|
122
|
+
- In test mode, assertions must reflect intended behavior, not observed behavior. Read intent from the spec, PRD, ticket, or user — never from the code under test. If intent is ambiguous, stop and ask.
|
|
123
|
+
|
|
124
|
+
Read [references/worked-examples.md](references/worked-examples.md) for concrete examples in this repo.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Modeling Rules
|
|
2
|
+
|
|
3
|
+
Use this file when you are extracting a schema from code or prose and need tighter guardrails than the main skill body provides.
|
|
4
|
+
|
|
5
|
+
## Parameter Selection
|
|
6
|
+
|
|
7
|
+
- Scope one schema to one coherent behavior or rendering surface.
|
|
8
|
+
Good scopes: one feature, one service behavior, one workflow, one endpoint family, one state-machine slice, one component's variant space, one template family.
|
|
9
|
+
Bad default scope: the whole app.
|
|
10
|
+
- Model the decisions that change behavior, not every field in a payload.
|
|
11
|
+
- Prefer parameters that are visible in tests, UI branches, rendering branches, validation logic, template variants, component props, or feature flags.
|
|
12
|
+
- Split large raw domains into behavioral partitions.
|
|
13
|
+
Good: `pay_range = present|absent`
|
|
14
|
+
Bad: every exact salary string
|
|
15
|
+
- Avoid separate parameters for values that are already implied by another parameter unless the implication is partial and needs a constraint.
|
|
16
|
+
|
|
17
|
+
## Value Selection
|
|
18
|
+
|
|
19
|
+
- Values should be mutually exclusive and collectively useful for testing.
|
|
20
|
+
- Keep domains small and meaningful. Most parameters should land in the 2-5 value range.
|
|
21
|
+
- Normalize booleans as `true` and `false`.
|
|
22
|
+
- For optional subordinate parameters, let `conditional` introduce `N/A`. Do not hand-add `N/A` unless the schema genuinely needs it as a first-class value.
|
|
23
|
+
|
|
24
|
+
## Constraint Choice
|
|
25
|
+
|
|
26
|
+
- `invalid_pair`: two assignments cannot coexist
|
|
27
|
+
- `bidirectional`: one-to-one pairing; if A then B and if B then A
|
|
28
|
+
- `forward_dep`: A requires B, but B may appear elsewhere
|
|
29
|
+
- `conditional`: a child parameter only applies for some parent values
|
|
30
|
+
- `forced`: this assignment set must appear in at least one generated row
|
|
31
|
+
- `higher_order`: the invalid rule only appears when two or more antecedents are true
|
|
32
|
+
|
|
33
|
+
Choose the smallest expressive type. If a rule can be represented as `invalid_pair`, do not use `higher_order`.
|
|
34
|
+
|
|
35
|
+
Do not strip true constraints to get a smaller or easier unconstrained run. Do not generate nonsensical rows and mark them invalid downstream. Lattice's coverage accounting should run over valid interactions, so impossible combinations belong in the schema as `invalid_pair`, `forward_dep`, `bidirectional`, `conditional`, or `higher_order` constraints.
|
|
36
|
+
|
|
37
|
+
## Extraction Process
|
|
38
|
+
|
|
39
|
+
1. Choose the behavior or rendering surface you are modeling.
|
|
40
|
+
2. Start from branches, validations, and business rules inside that scope.
|
|
41
|
+
3. Convert prose like "only when", "must", "cannot", and "except" into candidate constraints.
|
|
42
|
+
4. Remove cosmetic parameters that do not affect behavior.
|
|
43
|
+
5. Check whether a missing value is really a separate partition or just noise.
|
|
44
|
+
6. Validate the schema.
|
|
45
|
+
7. Only after validation, generate scenarios.
|
|
46
|
+
|
|
47
|
+
## Interpretation
|
|
48
|
+
|
|
49
|
+
- Plan mode: each row becomes a review scenario or a missing decision in the plan.
|
|
50
|
+
- Test mode: each row becomes a candidate setup matrix. Source the expected behavior from intent — user request, spec, PRD, or ticket — not from the code under test. If you cannot determine intent for a row, stop and surface the ambiguity to the user. Do not encode the current behavior and label it `bug_signal:` to hedge: characterization tests pass for the wrong reasons and hide the asymmetries Lattice is designed to expose. Example: if a mailbox accepts a spoofed `From:` header today, the assertion is still "rejects spoofed sender" — let the test fail and fix the code, do not invert the assertion to match the bug.
|
|
51
|
+
- Variant mode: each row becomes a rendered variant, fixture, screenshot, visual diff input, contact-sheet item, or review checklist item.
|
|
52
|
+
- Generated rows are not test names by themselves. The agent still needs to map them to application-specific assertions.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Worked Examples
|
|
2
|
+
|
|
3
|
+
These examples live in the repo-level `examples/` directory.
|
|
4
|
+
|
|
5
|
+
## `examples/plan-mode-saved-search`
|
|
6
|
+
|
|
7
|
+
Use when the agent starts from a feature discussion or PRD and needs a review checklist.
|
|
8
|
+
|
|
9
|
+
- Input: `feature.md`
|
|
10
|
+
- Schema transport: `model.yaml`
|
|
11
|
+
- Output: `scenarios.json`
|
|
12
|
+
|
|
13
|
+
## `examples/test-mode-checkout`
|
|
14
|
+
|
|
15
|
+
Use when the agent starts from code and an existing test surface and needs missing cases.
|
|
16
|
+
|
|
17
|
+
- Input: `code-notes.md`
|
|
18
|
+
- Schema transport: `model.json`
|
|
19
|
+
- Output: `scenarios.json`
|
|
20
|
+
|
|
21
|
+
## `examples/three-way-notifications`
|
|
22
|
+
|
|
23
|
+
Use when pairwise is not enough and the user explicitly wants 3-way coverage.
|
|
24
|
+
|
|
25
|
+
- Input: `brief.md`
|
|
26
|
+
- Schema transport: `model.yaml`
|
|
27
|
+
- Output: `scenarios.json`
|
|
28
|
+
|
|
29
|
+
## `examples/component-variant-matrix`
|
|
30
|
+
|
|
31
|
+
Use when the agent starts from a visual component, rendering surface, template, or design-system story and needs compact review variants instead of every possible combination.
|
|
32
|
+
|
|
33
|
+
- Input: `brief.md`
|
|
34
|
+
- Schema transport: `model.yaml`
|
|
35
|
+
- Output: `scenarios.json`
|
|
36
|
+
|
|
37
|
+
## `examples/lattice-self-test`
|
|
38
|
+
|
|
39
|
+
Use when you want a meta example of the harness extracting a schema for Lattice's own CLI surface and then using generated rows to drive CLI smoke tests.
|
|
40
|
+
|
|
41
|
+
- Input: `brief.md`
|
|
42
|
+
- Schema transport: `model.yaml`
|
|
43
|
+
- Output: `scenarios.json`
|
|
44
|
+
|
|
45
|
+
## `examples/agent-bootstrap-matrix`
|
|
46
|
+
|
|
47
|
+
Use when you want a meta example of Lattice testing its own agent skill bootstrap behavior across harness detection, force/skip directives, target modes, and output formats.
|
|
48
|
+
|
|
49
|
+
- Input: `brief.md`
|
|
50
|
+
- Schema transport: `model.yaml`
|
|
51
|
+
- Output: `scenarios.json`
|
|
52
|
+
|
|
53
|
+
## `examples/schema-guidance-matrix`
|
|
54
|
+
|
|
55
|
+
Use when you want a meta example of Lattice testing its own schema-discoverability guidance across help text, agent instructions, installed skill files, and validation errors.
|
|
56
|
+
|
|
57
|
+
- Input: `brief.md`
|
|
58
|
+
- Schema transport: `model.yaml`
|
|
59
|
+
- Output: `scenarios.json`
|