@petukhovart/agent-view 0.8.0 → 0.8.2

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.
@@ -1,258 +1,286 @@
1
- ---
2
- name: verify-recipe
3
- description: "Generates a concrete, command-by-command agent-view recipe for verifying a feature or bugfix. Use when the developer wants to write a verify-recipe.md, create a verification plan, build an agent-view recipe, or produce a verify checklist for a change they shipped. Triggers on: write a verify-recipe, write verification steps, generate verify steps for the feature/bug I just shipped/fixed, make a verify-recipe.md, what should I run to verify X, create a verification plan, agent-view recipe for this fix, verify checklist for this feature. Does NOT execute the checks — it authors the plan. For running checks against a live app, use the verify skill instead."
4
- allowed-tools: Read, Write, Bash(agent-view *)
5
- ---
6
-
7
- # Verification Recipe Generator
8
-
9
- You help the developer author a disciplined, cheapest-first verification recipe for a feature they shipped or a bug they fixed. You do not run the checks — you produce a `.claude/verify-recipes/<slug>.md` file that any AI coding agent can execute later.
10
-
11
- ## What this produces
12
-
13
- A file at `.claude/verify-recipes/<kebab-slug>.md` with three precondition phases plus the verification body:
14
-
15
- - **MANUAL PRECONDITIONS** — only what `agent-view` physically cannot do (rare; usually empty)
16
- - **BRINGUP** — idempotent setup steps the verify-runner executes itself: `if <state-check> is falsy → run actions → wait for state to settle`. Drives the app from auth screen / fresh shell / mid-state into the exact state the recipe needs. Re-runs cost almost nothing because each step skips when its condition is already met.
17
- - **MACHINE PRECONDITIONS** — pure state queries that confirm Bringup actually settled. No actions here. Any false → runner aborts.
18
- - **EVIDENCE COMMANDS** — ordered `agent-view` calls, cheapest first, each annotated with what it proves.
19
- - **POSITIVE-CASE ASSERTIONS** + **REGRESSION CHECKS** + optional **DESIGN CONFORMANCE**.
20
-
21
- Create the directory if missing: `mkdir -p .claude/verify-recipes`
22
-
23
- ## Why three precondition phases
24
-
25
- | Phase | Who runs it | What it does | Idempotent? |
26
- |---|---|---|---|
27
- | `## Manual Preconditions` | Human (or main agent) | Only what `agent-view` physically can't (USB token, hardware setup, multi-machine state) | n/a |
28
- | `## Bringup` | verify-runner | `if state-check is falsy → action → wait`. Logins, mounting widgets, navigation — anything `agent-view` can do deterministically | YES (per step) |
29
- | `## Machine Preconditions` | verify-runner | Pure `eval` / `dom --filter` state queries. NO actions. | trivially |
30
-
31
- **Why split Bringup from Machine Preconditions?** A failure tells you a different thing in each:
32
- - A failed Bringup post-condition bringup spec is wrong (e.g., `selectLocationAndFly` doesn't exist; "Войти" button text changed). Author error.
33
- - A failed Machine Precondition after Bringup succeeded bringup THINKS it set up the state but the state isn't there (e.g., login appeared to succeed but the user role is wrong, the app is in a degraded mode). Real environment issue.
34
- - A failed Evidence Command after both passed real bug in the verified feature.
35
-
36
- Without the split, all three look like "step N failed" and the developer can't tell which.
37
-
38
- **Why keep Manual at all?** Some things really can't be automated cheaply: physical USB-key auth, multi-machine setups, long-running data migrations. List them — but be honest, this section should usually be empty.
39
-
40
- ## Methodology
41
-
42
- Frame the recipe with **hard-debug** discipline. Apply this chain in authoring mode:
43
-
44
- 1. Start from the broadest possible starting state — recipe should run from auth screen, from logged-in shell, or from "already in the feature" without modification.
45
- 2. Convert vague expectations ("looks right") into measurable signals ("`store.user.role === 'admin'`").
46
- 3. Prefer the cheapest tool that can answer the question a value check costs ~50 tokens, a screenshot costs ~6 000.
47
- 4. Include at least one negative-case check (the old symptom must no longer appear).
48
- 5. Include at least one regression check (an adjacent flow must still work).
49
- 6. **Bringup steps must be conditional + idempotent.** Every action wrapped in `if <state-check> is falsy`. Every action followed by `wait for <post-condition> to be truthy`. Re-running the recipe must be a no-op when the app is already ready.
50
-
51
- ## Tool-cost decision tree
52
-
53
- Pick the first row that can answer the question. Only go lower when the row above can't:
54
-
55
- | Question | Command | Why it's cheapest |
56
- |---|---|---|
57
- | Element exists / has specific text / role | `agent-view dom --filter "<text>" --depth 2` | Structured text, zero vision tokens |
58
- | App state, store value, computed flag | `agent-view eval "<expr>"` | Returns the value directly; DOM inference is wasteful and fragile |
59
- | What changed between action and final state | `agent-view watch "<expr>" --until "<condition>"` or `--max-changes 1` | `eval` shows the snapshot; `watch` shows the trajectory |
60
- | SharedWorker / ServiceWorker internal state | `agent-view eval --target <name> "<expr>"` | Workers have no DOM; this is the only path |
61
- | Did this action throw or warn silently? | `agent-view console --clear` before, `agent-view console --level error,warn` after | Catches uncaught exceptions and network failures invisible to DOM |
62
- | Layout, spacing, visual regression | `agent-view screenshot --scale 0.5` | Last resort — the only tool that sees pixels, but costs ~6 000 tokens |
63
- | Canvas / WebGL scene state | `agent-view scene --diff` | DOM is empty for canvas apps |
64
-
65
- **Anti-patterns to reject:**
66
- - Putting UI clicks (`click`, `fill`) in `## Machine Preconditions`. Actions go in `## Bringup`. Machine Preconditions are state queries only.
67
- - Bringup steps without an IF condition (unconditional actions). They break idempotency re-running a "click Login" step when already logged in fails. Always wrap.
68
- - Bringup steps without a post-condition wait. Without it, the runner advances before the action settled, and the next step's IF check sees stale state.
69
- - Manual Preconditions for anything `agent-view` can do. Drag widget into cell? Often there's a programmatic API — interview the developer for it before defaulting to Manual.
70
- - Hardcoded credentials in Bringup commands. Use env-var references (`"$AGENTVIEW_PASSWORD"`) never inline a password, even for dev/masterkey accounts. Recipes get committed to git.
71
- - Opening Evidence Commands with a screenshot to "see the state" — use `dom --filter` or `eval` first.
72
- - "Check that it looks right" every Evidence assertion must be a concrete pass/fail criterion. The single legitimate exception is the `## Design Conformance` section.
73
- - Inventing design reference paths (`.figma-refs/...`) when the developer did not provide them. No refs no Design Conformance section.
74
-
75
- ## Workflow
76
-
77
- ### Step 1 gather context (interview the developer)
78
-
79
- When invoked, ask in plain text. Wait for response before continuing.
80
-
81
- **Block A — what's being verified:**
82
-
83
- 1. What was shipped or fixed? (feature name or bug description)
84
- 2. What was the original symptom or expected behavior?
85
- 3. Any known failure mode or edge case to cover?
86
-
87
- **Block B bringup: how the runner gets the app into a state where verification makes sense:**
88
-
89
- 4. **Authentication** does the app require login before the feature is reachable? If yes:
90
- - What identifies "logged out" vs "logged in" in JS state? (e.g., `typeof window.__dev`, `!!store.user`)
91
- - Login flow: which fields/buttons (`fill --filter "..."`, `click --filter "..."`) and what credentials? **Use an env-var, never inline.** Suggest a name like `AGENTVIEW_PASSWORD` and tell the user to `export` it in their shell or `.env.local`.
92
- 5. **UI mode / view requirements** — does the feature live behind a specific app mode/view that must be active before it appears (e.g., "map view, not settings panel"; "edit mode, not view mode"; "modal X must be open")? For each:
93
- - State check that proves this mode is active (e.g., `document.querySelector('.cesium-widget') !== null` for map mode).
94
- - Action(s) to enter this mode if not active. Prefer programmatic API (e.g., `eval "store.setMode('map')"`) over UI clicks. If only UI works, list the click sequence.
95
- 6. **Setup actions** — beyond modes, what other setup must happen (drag widget into cell, navigate camera to a location, open a dialog)? For each:
96
- - Programmatic API if it exists (e.g., `gis-widget-root.selectLocationAndFly(uuid)`, `workspace.addWidget(...)`). Prefer this — much more reliable than UI automation.
97
- - State check that proves the setup happened.
98
- - Wait timing: how long does this take to settle? (camera animation, async data load).
99
-
100
- If the developer doesn't know whether a programmatic API exists, ask them to point you at the relevant store/composable/component file — you can read it and find one (or confirm none).
101
-
102
- **Block C — verification body and visual:**
103
-
104
- 7. State assertions for the verified feature itself — JS expressions that prove it works (separate from bringup setup checks).
105
- 8. **(Optional) Design references** local image paths to compare screenshots against (Figma exports, hand-off PNGs). **Only local files are supported.** If none skip the Design Conformance section.
106
-
107
- ### Step 2 draft the recipe
108
-
109
- Use the answers to produce a recipe in this format:
110
-
111
- ````markdown
112
- # Verify: <feature or fix name>
113
-
114
- Generated: <date>
115
- Scope: <one sentence describing what this covers>
116
-
117
- ## Manual Preconditions
118
- <!-- ONLY for things agent-view physically cannot do. Usually empty. -->
119
- <!-- The verify-runner does NOT execute these. -->
120
- (none — bringup handles everything)
121
-
122
- ## Bringup
123
- <!-- The verify-runner executes these. Each step is conditional + idempotent: skipped if already in target state. -->
124
- <!-- Format per step: -->
125
- <!-- ### B<N>. <one-line title> -->
126
- <!-- - if `<eval>` is `<falsy criterion>`: -->
127
- <!-- <action command 1> -->
128
- <!-- <action command 2> -->
129
- <!-- wait for `<post-condition eval>` to be `<truthy criterion>`, timeout <Ns> -->
130
-
131
- ### B1. Login if on auth screen
132
- - if `agent-view eval "typeof window.__dev"` is not `"object"`:
133
- agent-view fill --window $W --filter "Логин" "root"
134
- agent-view fill --window $W --filter "Пароль" "$AGENTVIEW_PASSWORD"
135
- agent-view click --window $W --filter "Войти"
136
- wait for `agent-view eval "typeof window.__dev"` to be `"object"`, timeout 15s
137
-
138
- ### B2. Mount the GIS widget if not mounted
139
- - if `agent-view eval "!!window.__dev.pinia._s.get('gis-widget-root')?.cesiumReadyFlag"` is `false`:
140
- agent-view eval "window.__dev.pinia._s.get('workspace').addWidget({type:'gis', cell:0})"
141
- wait for `agent-view eval "!!window.__dev.pinia._s.get('gis-widget-root')?.cesiumReadyFlag"` to be `true`, timeout 10s
142
-
143
- ### B3. Exit settings mode if active
144
- - if `agent-view eval "document.querySelector('.cesium-widget') !== null"` is `false`:
145
- agent-view click --window $W --filter "Готово"
146
- wait for `agent-view eval "document.querySelector('.cesium-widget') !== null"` to be `true`, timeout 5s
147
-
148
- ### B4. Fly to first sublocation
149
- - if `agent-view eval "!!window.__dev.pinia._s.get('gis-widget-root')?.selectedLocation"` is `false`:
150
- agent-view eval --await "window.__dev.pinia._s.get('gis-widget-root').selectLocationAndFly(window.__dev.mwStore.nvgn.sublocations.value[0].id)"
151
- wait for `agent-view eval "(()=>{const w=document.querySelector('.cesium-widget'); const cw=Object.values(w).find(v=>v?.scene); return Math.round(window.Cesium.Cartographic.fromCartesian(cw.scene.camera.position).height);})()"` to be `< 5000`, timeout 30s
152
-
153
- ### B5. Snapshot for the report (always runs)
154
- agent-view screenshot --window $W --scale 0.25
155
-
156
- ## Machine Preconditions
157
- <!-- Pure state checks. NO actions. The verify-runner aborts with `precondition_failed` if any return false. -->
158
- - `agent-view eval "typeof window.__dev"` must be `"object"`
159
- - `agent-view eval "!!window.__dev.pinia._s.get('gis-widget-root')?.cesiumReadyFlag"` → must be `true`
160
- - `agent-view eval "document.querySelector('.cesium-widget') !== null"` must be `true`
161
- - `agent-view eval "!!window.__dev.pinia._s.get('gis-widget-root')?.selectedLocation"` must be `true`
162
- - `agent-view eval "({locations:window.__dev.mwStore.nvgn.locations.value.length, sublocations:window.__dev.mwStore.nvgn.sublocations.value.length, zones:window.__dev.mwStore.nvgn.zones.value.length, objects:window.__dev.mwStore.nvgn.objects.value.length})"` → all four counts must be `> 0`
163
-
164
- ## Narrowed Signal
165
- <!-- The one measurable thing that proves the verified feature works -->
166
- `<agent-view command>` must return `<expected value>`.
167
-
168
- ## Evidence Commands
169
-
170
- ### 1. <What this proves>
171
- ```bash
172
- agent-view <command>
173
- ```
174
- Expected: <concrete criterion — value, text, absence of error>
175
- Cost: ~<N> tokens
176
-
177
- ### 2. ...
178
-
179
- ## Positive-Case Assertions
180
- - [ ] <criterion>
181
- - [ ] <criterion>
182
-
183
- ## Regression Checks
184
- - [ ] <adjacent flow> `agent-view <command>` `<expected>`
185
-
186
- ## Design Conformance
187
- <!-- Include ONLY if the developer provided design refs in question 8. -->
188
-
189
- | Step Label | Screenshot Command | Expected Reference |
190
- |---|---|---|
191
- | <area name e.g. "filter panel collapsed"> | `agent-view screenshot --crop "<area>" --scale 0.5` | `<absolute path to expected PNG/JPEG>` |
192
-
193
- Tolerance: `normal` (default).
194
-
195
- ## Anti-patterns avoided
196
- - <note any recipe-specific traps, e.g. "B4 relies on `selectLocationAndFly` from gis-widget-root verified to exist as of <date>; if it's removed, B4 falls back to Manual Precondition">
197
- ````
198
-
199
- ### Step 3 save the file
200
-
201
- Determine a kebab-slug from the feature/fix name. Save to `.claude/verify-recipes/<slug>.md`. Create the directory first if it doesn't exist. Confirm the path to the developer.
202
-
203
- ### Step 4credentials warning (if Bringup contains login)
204
-
205
- If Bringup includes a login step:
206
-
207
- > Recipe uses `$AGENTVIEW_PASSWORD` for login. Make sure that env var is set in your shell or `.env.local` before running verify (`export AGENTVIEW_PASSWORD=<value>`). The recipe never contains the literal password.
208
-
209
- If the developer insisted on inlining a literal password earlier, warn:
210
-
211
- > ⚠️ Recipe contains a literal password on line N. This will be committed to git. Consider replacing with `$AGENTVIEW_PASSWORD` (env-var). Want me to convert it now? (yes/no)
212
-
213
- ### Step 5 — offer dry-run validation
214
-
215
- After saving, ask:
216
-
217
- > The recipe is saved at `<path>`. Is the app running? If yes, I can spawn `verify-runner` in `dry_run` mode — it'll execute Bringup + Machine Preconditions + the first Evidence Command (~10-20 commands total). That validates the recipe isn't broken before you commit a full run. Want me to run the dry-run? (yes/no)
218
-
219
- If yes:
220
- 1. Get the window id with `agent-view discover`.
221
- 2. Spawn `verify-runner` via the Agent tool with `mode: dry_run`, the recipe path, and the window id.
222
- 3. Read the JSON report.
223
- 4. **`status: bringup_failed`** → relay `failed_bringup_step` and the post-condition's actual value. Suggest revising the bringup step (most often: action commands wrong, programmatic API doesn't exist, or post-condition criterion mistuned).
224
- 5. **`status: precondition_failed`** bringup ran but state isn't there. Either bringup is incomplete, or a state check is overly strict. Show both bringup outcome and the failing precondition.
225
- 6. **`status: completed` and dry-run passed** → recipe is healthy. Confirm and stop.
226
-
227
- If no confirm path and stop.
228
-
229
- ## Worked example: GIS feature with full bringup automation
230
-
231
- **Developer input:**
232
- > Verifying selective filter changes (commits 0c5f1b1ee, 4d0c89467, 4c99c1591) in the GIS widget. App requires login (root/masterkey via middleware). GIS widget mounts via `workspace.addWidget({type:'gis', cell:0})`. Camera flies via `gis-widget-root.selectLocationAndFly(id)`. Map view is the default after widget mount.
233
-
234
- **Recipe produced:**
235
-
236
- (see the template above — it's already the worked example for this scenario)
237
-
238
- **Saved to:** `.claude/verify-recipes/nvgn-gis-improvements.md`
239
-
240
- **Dry-run output (first run after auth screen):**
241
- ```
242
- status: completed
243
- mode: dry_run
244
- bringup: 5 steps, 12 commands, 18s — B1 (login) + B2 (mount) + B4 (fly) all triggered; B3 skipped (already map mode); B5 screenshot saved
245
- machine_preconditions: 5/5 passed
246
- steps: 1/1 passed
247
- ```
248
-
249
- **Dry-run output (second run, app already in target state):**
250
- ```
251
- status: completed
252
- mode: dry_run
253
- bringup: 5 steps, 5 commands (4 IF-checks + 1 screenshot), 3s — all 4 conditional steps skipped_already_ready
254
- machine_preconditions: 5/5 passed
255
- steps: 1/1 passed
256
- ```
257
-
258
- This is what idempotent bringup buys you: 5x speedup on re-runs, zero manual intervention either way.
1
+ ---
2
+ name: verify-recipe
3
+ description: "Generates a concrete, command-by-command agent-view recipe for verifying a feature or bugfix. Use when the developer wants to write a verify-recipe.md, create a verification plan, build an agent-view recipe, or produce a verify checklist for a change they shipped. Triggers on: write a verify-recipe, write verification steps, generate verify steps for the feature/bug I just shipped/fixed, make a verify-recipe.md, what should I run to verify X, create a verification plan, agent-view recipe for this fix, verify checklist for this feature. Does NOT execute the checks — it authors the plan. For running checks against a live app, use the verify skill instead."
4
+ allowed-tools: Read, Write, Bash(agent-view *)
5
+ ---
6
+
7
+ # Verification Recipe Generator (rigor edition)
8
+
9
+ You help the developer author a disciplined, cheapest-first verification recipe for a feature they shipped or a bug they fixed. You do not run the checks — you produce a `.claude/verify-recipes/<slug>.md` file that any AI coding agent can execute later.
10
+
11
+ This edition is hardened against the failure mode of "construction-validated only" recipes that pass while real bugs sit in plain sight in the same data. See `## Bug-class invariants` and `## Discipline rules`.
12
+
13
+ ## What this produces
14
+
15
+ A file at `.claude/verify-recipes/<kebab-slug>.md` containing:
16
+
17
+ - **REPRO STEPS** — exact state the app must be in before checks run.
18
+ - **NARROWED SIGNAL** — the measurable indicator that proves success or failure.
19
+ - **EVIDENCE COMMANDS** ordered `agent-view` calls, cheapest first.
20
+ - **POSITIVE-CASE ASSERTIONS** — what "pass" looks like for each command.
21
+ - **BUG-CLASS INVARIANTS** *(required)* — properties that must hold across all states the recipe touches, not just the action-result state.
22
+ - **ROUND-TRIP CHECKPOINT** *(required when the feature touches persistence or mutable structure)* — a save-and-reload (or equivalent) comparison.
23
+ - **REGRESSION CHECKS** adjacent paths that must not have broken.
24
+ - **DESIGN CONFORMANCE** *(optional)* — reference image comparisons.
25
+
26
+ Create the directory if missing: `mkdir -p .claude/verify-recipes`
27
+
28
+ ## Methodology
29
+
30
+ Frame the recipe with **hard-debug** discipline: REPRO → narrowed signal → minimize scope → root-cause check → fix verification.
31
+
32
+ 1. Start from a reproducible starting state, not "open the app and poke around".
33
+ 2. Convert vague expectations ("looks right") into measurable signals (`store.user.role === 'admin'`).
34
+ 3. Prefer the cheapest tool that can answer the question a value check costs ~50 tokens, a screenshot costs ~6 000.
35
+ 4. Include at least one negative-case check (the old symptom must no longer appear).
36
+ 5. Include at least one regression check (an adjacent flow must still work).
37
+ 6. **Construction-only verification is not enough.** For any non-trivial feature, add invariant checks (see next section) and a round-trip checkpoint.
38
+
39
+ ## Bug-class invariants (required section in every recipe)
40
+
41
+ The recipe must include an `## Invariants` section listing properties that hold *regardless of how state was reached*. These catch bugs that construction-only tests cannot see, because the bug lives in the gap between what the model says and what the user sees / what persistence preserves.
42
+
43
+ Pick at least one invariant from each applicable class. Skip a class only if it provably cannot apply to the feature.
44
+
45
+ ### Class A UI Model
46
+ For every visible representation of state (tree, list, panel, breadcrumb, overlay, badge, count):
47
+ - **Count parity:** `count(DOM rows of kind X) === count(model nodes of kind X)`.
48
+ - **Hierarchy parity:** for any parent/child relationship the model expresses, the DOM must mirror it. A flat-rendered DOM of a nested model is a UI bug, not a model bug.
49
+ - **Text parity:** the label shown in the UI for a node must equal `model.get(nodeId).name` (or whichever field the UI claims to display).
50
+
51
+ Encode this as a single `eval` that returns a JSON struct so a single failed comparison is unambiguous:
52
+
53
+ ```bash
54
+ agent-view eval "var model=<source-of-truth>;var dom=<measurement>;JSON.stringify({modelCount:model.size, domCount:dom.length, match:model.size===dom.length})"
55
+ ```
56
+
57
+ If `match: false` that is a FAIL. Do not rationalize a DOM/model count mismatch as "label reuse" or "the breadcrumb counts too" without confirming the matched elements' bounding boxes and DOM ancestry first.
58
+
59
+ ### Class B Round-trip
60
+ For any feature that creates / mutates persisted structure:
61
+ - `state deserialize(serialize(state))` (model survives save→load with bit-identical structure for the projected fields).
62
+ - `world(child) === origWorld(child)` immediately after a wrap/unwrap action (the wrapping must not silently shift the wrapped element).
63
+ - Reloading the page (`agent-view eval "location.reload()"`) and re-reading the same state must produce an identical signature.
64
+
65
+ A round-trip discrepancy that the save serializer silently "fixes" is a model bug, not a save-format bug. Live-vs-persisted divergence between actions and reloads is a class-B failure even if save/load round-trips cleanly with itself.
66
+
67
+ ### Class CReversibility & identity
68
+ - Every user-facing command produces exactly one `commandHistory` entry (`canUndo→true`; one `undo()` fully reverses).
69
+ - `undo` then `redo` produces an identical state to "do once".
70
+ - The set of nodes after `do undo → redo` equals the set after one `do`. Compare full IDs, not counts — a swap of one node for another with the same name is a real bug.
71
+
72
+ ### Class DNo phantom state
73
+ - For each visible entity the user can interact with, there exists exactly one corresponding model node.
74
+ - For each model node, there exists at most one corresponding UI entity in each view.
75
+ - An entity that appears in two views (e.g. tree and canvas) must have the same identity in both (the same `nodeId` resolves both).
76
+
77
+ This class is the one most often missed. Verify it explicitly when the feature changes structure.
78
+
79
+ ### Class E Config conformance (rendering vs. configured constraint)
80
+
81
+ Class A compares model to DOM. Class E compares the **rendered output** (DOM bounds, canvas geometry, computed styles, layout sizes) to an **explicit configuration value** the system declares it must respect. This is the home for invariants that have no DOM counterpart to diff against they assert against a config the user (or product) chose.
82
+
83
+ Typical examples adapt names to the project:
84
+
85
+ - **Snap/grid:** every shape's bounding box must satisfy `x % gridSize === 0` (and same for `y / width / height`). Read `gridSize` from the live config (`store.gridSettings.gridSize`, `theme.grid.size`, `viewport.snap`, …); do not hardcode.
86
+ - **Viewport bounds:** elements declared "viewport-contained" must have `getBoundingClientRect()` within the viewport rect.
87
+ - **Z-order / layering:** elements declared "above modals" must have computed `z-index` above the modal's. Compare against the configured layer table, not a literal number.
88
+ - **Spacing / density tokens:** if the design system declares a spacing scale, computed `margin` / `padding` must be a multiple of the base token.
89
+ - **Theme tokens:** computed colors / fonts must match the active theme's declared values, not literal hex codes.
90
+
91
+ Generic helper shape:
92
+
93
+ ```bash
94
+ agent-view eval "var cfg=<read live config value>; var items=<measure rendered items>; var off=items.filter(function(it){return !<conforms(it, cfg)>}); JSON.stringify({cfg:cfg, total:items.length, offCount:off.length, sample:off.slice(0,3)})"
95
+ ```
96
+
97
+ Expected: `offCount: 0`. A non-zero count means the renderer ignored a config the system promised to honor — that is a real bug class, even if the model is internally consistent and round-trips cleanly. Bugs of the form "element is half a pixel off the grid", "modal renders behind the toast", "freshly-created group is not snapped" all live here and fall between the other classes.
98
+
99
+ When generating recipes, ask: *what config values does this feature claim to respect?* Each one is one Class-E invariant. If the answer is "none" — say so explicitly in the recipe, so a future reader doesn't wonder why the class is absent.
100
+
101
+ ## Discipline rules
102
+
103
+ These rules govern how the recipe is *executed* — they must appear verbatim in the recipe's `## Discipline` section so the executor cannot forget them.
104
+
105
+ 1. **A failed `Expected:` line is FAIL, not "actually fine".** Rationalizations belong in the bug report after the run, not inline in the run log. If the actual output disagrees with the expected line, mark `FAIL` and continue to the next step; do not edit the expected line, do not invent a "label reuse" or "convention" explanation that makes the discrepancy disappear from the count.
106
+
107
+ 2. **Prefer model-vs-DOM mismatches as the bug, not as noise.** When a Class-A invariant fails, the default hypothesis is "the UI renderer is wrong", not "the DOM filter matched something extra". To rule out the latter, query bounding boxes and ancestor chains for every match; if the matches turn out to be sibling rows in the same list, the renderer is the bug.
108
+
109
+ 3. **Defensive eval reads.** Every read of `node.transform.x` (or any model field) must include a sentinel: `isFinite(value)` or `value !== undefined`. A silent `NaN`/`null` from a renamed field looks like a real `0` in arithmetic and will fail-pass the assertion.
110
+
111
+ 4. **No hardcoded literal IDs.** All node IDs in evals must be resolved by role at runtime (e.g. "the first group at root", "the line at root not inside any group"). Hardcoded prefixes silently degrade the recipe to no-op when the scene differs.
112
+
113
+ 5. **The reload checkpoint is not optional.** For any recipe that touches mutable structure, include at least one `location.reload()` between an action and a re-measurement. Compare the projected signature before and after; differences are real bugs, not "fixed-up on save".
114
+
115
+ 6. **Compose, do not narrate.** Final report is `pass / fail / requires_visual_review` counts plus one-line failure reasons. Do not paste raw stdout. Do not include prose justifications in the per-step output.
116
+
117
+ 7. **`requires_visual_review` is an executor verdict, not an authoring shortcut.** When generating the recipe, draft every step so it executes through `agent-view`. Do not write `requires_visual_review` as the planned status of a step just because the path looks tricky (event delegation, canvas hit-test, file dialog, etc.) — first encode the cheapest sub-check that *can* run programmatically (e.g. "no console error during the action", "model state changed", "command history advanced by one"). The `requires_visual_review` label is set by the *executor* at run time, only after at least one genuine attempt to drive the action via agent-view failed for a reason they record. Authoring the recipe with `requires_visual_review` prebaked is what lets real regressions sit unobserved.
118
+
119
+ ## Tool-cost decision tree
120
+
121
+ Pick the first row that can answer the question. Only go lower when the row above can't:
122
+
123
+ | Question | Command | Why it's cheapest |
124
+ |---|---|---|
125
+ | Element exists / has specific text / role | `agent-view dom --filter "<text>" --depth 2` | Structured text, zero vision tokens |
126
+ | Count of matching elements | `agent-view dom --filter X --count` | Single integer, zero tree tokens |
127
+ | App state, store value, computed flag | `agent-view eval "<expr>"` | Returns the value directly; DOM inference is wasteful and fragile |
128
+ | What changed between action and final state | `agent-view watch "<expr>" --until "<condition>"` or `--max-changes 1` | `eval` shows the snapshot; `watch` shows the trajectory |
129
+ | SharedWorker / ServiceWorker internal state | `agent-view eval --target <name> "<expr>"` | Workers have no DOM |
130
+ | Did this action throw or warn silently? | `agent-view console --clear` before, `agent-view console --level error,warn` after | Catches uncaught exceptions invisible to DOM |
131
+ | Layout, spacing, visual regression | `agent-view screenshot --scale 0.5` | Last resort only tool that sees pixels (~6 000 tokens) |
132
+ | Canvas / WebGL scene state | `agent-view scene --diff` | DOM is empty for canvas apps |
133
+
134
+ **Anti-patterns to reject:**
135
+ - Opening with a screenshot to "see the state" — use `dom --filter` or `eval` first.
136
+ - Using `eval` when `dom --filter` answers the question.
137
+ - Assertions that depend on transient state without `watch --until` to stabilize first.
138
+ - "Check that it looks right" — every assertion must be a concrete pass/fail criterion. Single legitimate exception: `## Design Conformance`.
139
+ - Inventing design reference paths (`.figma-refs/...`) when the developer did not provide them.
140
+ - **Treating SG (or any model layer) as the sole source of truth.** Model is one of several representations; the bug may live in the gap between model and UI. The recipe must check the gap explicitly.
141
+
142
+ ## Workflow
143
+
144
+ ### Step 1 gather context
145
+
146
+ Ask in plain text (no tool calls yet):
147
+
148
+ 1. What was shipped or fixed?
149
+ 2. What was the original symptom or expected behavior?
150
+ 3. Any known failure mode or edge case to cover?
151
+ 4. Does this feature touch persisted structure (YAML, IndexedDB, server)? If yes mandatory round-trip section.
152
+ 5. Which views render this state (tree, panel, list, canvas, breadcrumb)? Each named view → one UI-≡-Model invariant in Class A.
153
+ 6. Which **configured constraints** does this feature claim to respect (grid/snap, viewport, z-order/layer table, spacing tokens, theme tokens, density)? Each named constraint → one Class-E invariant. If none — say so explicitly.
154
+ 7. *(Optional)* Local design reference images? Local files only.
155
+
156
+ Wait for the response before continuing.
157
+
158
+ ### Step 2 derive invariants before drafting commands
159
+
160
+ Before writing any `agent-view` call, list the invariants the feature must satisfy. For each, write one sentence in the form:
161
+ > "After any sequence of allowed actions, `<measurable property>` must hold."
162
+
163
+ This list seeds the `## Invariants` section. If you cannot articulate three invariants for a non-trivial feature, the feature is under-specified — ask the developer for clarification.
164
+
165
+ ### Step 3 draft the recipe
166
+
167
+ ```markdown
168
+ # Verify: <feature or fix name>
169
+
170
+ Generated: <date>
171
+ Scope: <one sentence>
172
+
173
+ ## Repro Steps
174
+ 1. <Exact starting state>
175
+ 2. <Action(s) that trigger the behavior under test>
176
+
177
+ ## Narrowed Signal
178
+ `<agent-view command>` must return `<expected value>`.
179
+
180
+ ## Invariants
181
+ <!-- Required. List each invariant the feature must maintain. -->
182
+
183
+ - **A1 (UI≡Model — <view name>):** `<eval expression that returns {model: N, dom: M, match: bool}>` must return `match: true`.
184
+ - **A2 (Hierarchy):** For each model node with `parentId === X`, its UI row must be a DOM-descendant of the UI row of `X`.
185
+ - **B1 (Round-trip):** After `location.reload()`, the projected signature `<projection>` is identical to the pre-reload signature.
186
+ - **B2 (No silent wrap-shift):** After `<wrap-creating action>`, `getWorldTransform(child).x === origWorldX(child)` for every wrapped child.
187
+ - **C1 (Single undo):** After `<action>`, `commandHistory.canUndo === true` and one `undo()` produces a signature identical to the pre-action signature.
188
+ - **D1 (No phantoms):** For each visible UI row of kind `<X>`, there exists exactly one model node it resolves to via its `nodeId` data-attribute (or the equivalent identifier).
189
+ - **E1 (Config conformance <constraint name>):** Every rendered `<entity>` must satisfy `<conforms(rendered, configValue)>`, where `<configValue>` is read live from `<config source>` (do not hardcode). `offCount: 0` is required.
190
+
191
+ ## Discipline
192
+
193
+ 1. A failed `Expected:` line is FAIL, not "actually fine".
194
+ 2. UI-vs-model mismatches are the bug; confirm by ancestry/bbox before dismissing.
195
+ 3. Every `node.field` read in eval must be sentinel-checked (`isFinite` / `!== undefined`).
196
+ 4. No hardcoded literal IDs; resolve by role at runtime.
197
+ 5. Reload checkpoint is mandatory when the feature touches mutable structure.
198
+ 6. Report `pass / fail / requires_visual_review` per step; failure prose belongs in the bug report only.
199
+ 7. Do not pre-bake `requires_visual_review` as the planned status of a step. Every step ships with an executable `agent-view` path (at minimum a console-error gate around the action). The executor sets `requires_visual_review` only after a real attempt fails for a recorded reason.
200
+
201
+ ## Evidence Commands
202
+
203
+ ### 0. Setupcapture baseline signature
204
+ ```bash
205
+ agent-view eval "<signature expression projection of all structural fields>"
206
+ ```
207
+ Stash the output as `BASELINE_SIG`.
208
+
209
+ ### 1. <What this proves>
210
+ ```bash
211
+ agent-view <command>
212
+ ```
213
+ Expected: <concrete criterion>
214
+ Cost: ~<N> tokens
215
+
216
+ ### 2. ... (one per action / invariant pair)
217
+
218
+ ### N. Round-trip checkpoint (if applicable)
219
+ ```bash
220
+ agent-view eval "location.reload()"
221
+ # wait for app to come back
222
+ agent-view eval "<same signature expression as step 0>"
223
+ ```
224
+ Expected: identical to `BASELINE_SIG` after the action's expected effect is accounted for. Diff any drift.
225
+
226
+ ## Positive-Case Assertions
227
+ - [ ] <criterion>
228
+
229
+ ## Regression Checks
230
+ - [ ] <adjacent flow> — `agent-view <command>` → `<expected>`
231
+
232
+ ## Design Conformance
233
+ <!-- Optional. Include ONLY if developer provided design refs. -->
234
+
235
+ | Step Label | Screenshot Command | Expected Reference |
236
+ |---|---|---|
237
+ | <area name> | `agent-view screenshot --crop "<area>" --scale 0.5` | `<absolute path>` |
238
+
239
+ Tolerance: `normal`.
240
+
241
+ ## Anti-patterns avoided
242
+ - <recipe-specific traps>
243
+ ```
244
+
245
+ ### Step 4 — save the file
246
+
247
+ Determine a kebab-slug. Save to `.claude/verify-recipes/<slug>.md`. Create the directory first.
248
+
249
+ Confirm the path to the developer.
250
+
251
+ ## Worked example: "added group component to scene editor"
252
+
253
+ **Developer input:**
254
+ > Added a group component that wraps multiple scene elements. Ctrl+G groups selected elements; Ctrl+Shift+G ungroups. Groups appear in the left tree panel as collapsible nodes. Groups are persisted in YAML.
255
+
256
+ **Recipe excerpt (Invariants + Round-trip — the parts that catch the bugs construction-only recipes miss):**
257
+
258
+ ```markdown
259
+ ## Invariants
260
+
261
+ - **A1 (UI≡Model, tree count):**
262
+ ```
263
+ agent-view eval "var sg=window.__editorCore.sceneGraph;var modelCount=0;sg.nodes.forEach(function(n){if(n.componentType==='group')modelCount++});var domCount=[...document.querySelectorAll('[role=treeitem]')].filter(function(e){return e.textContent.includes('Группа')}).length;JSON.stringify({modelCount:modelCount, domCount:domCount, match:modelCount===domCount})"
264
+ ```
265
+ must return `match: true`.
266
+
267
+ - **A2 (Tree hierarchy):**
268
+ ```
269
+ agent-view eval "var sg=window.__editorCore.sceneGraph;var violations=[];sg.nodes.forEach(function(n,id){if(n.componentType==='group'){n.childrenIds.forEach(function(cid){var domChild=document.querySelector('[data-node-id=\"'+cid+'\"]');var domParent=document.querySelector('[data-node-id=\"'+id+'\"]');if(domChild&&domParent&&!domParent.contains(domChild))violations.push({c:cid,p:id})})}});JSON.stringify({violations:violations.length})"
270
+ ```
271
+ must return `violations: 0`.
272
+
273
+ - **B1 (Round-trip after Ctrl+G + reload):**
274
+ Capture signature, dispatch Ctrl+G, capture signature, reload, capture signature. The post-reload signature must equal the post-Ctrl+G signature *projected to the persisted fields*. Drift in `transform.x` of any wrapped child means the wrap path did not normalize coords.
275
+
276
+ - **B2 (No silent wrap-shift):**
277
+ Before Ctrl+G: capture `getWorldTransform(child).x` for each leaf. After Ctrl+G: re-capture. Difference must be 0 (within float epsilon). Non-zero means the wrap action shifted the child in world space — a regression.
278
+
279
+ - **C1 (Single undo):**
280
+ After Ctrl+G, `commandHistory.canUndo === true`. After one `undo()`, signature equals pre-Ctrl+G signature exactly.
281
+
282
+ - **D1 (No phantom group rows):**
283
+ Same eval as A1; if the result is `modelCount: 1, domCount: 2`, that is a phantom-row bug. Confirm by `agent-view eval "[...document.querySelectorAll('span')].filter(e=>e.textContent==='Группа'&&e.children.length===0).map(e=>{var r=e.getBoundingClientRect();return{x:r.x,y:r.y}})"` — two adjacent rows in the same column = phantom.
284
+ ```
285
+
286
+ This single example pair (A1 + D1 + B1 + B2) catches the three bugs from the 4.7 grouping session that the construction-only recipes missed.