Testing

From ianjamesburke/PLEXI · View interactive version

Testing is an AI agent skill from the GitHub repository ianjamesburke/PLEXI. Agent self-validation before push. Classifies the diff (host logic / host UI / PGAP app), runs the matching harness tests, generates headless render screenshots as evidence, and writes a Test Evidence block for the Ship Log that validate-pr uses to decide whether binary install can be skipped. Invok

How to use this skill

Skill file

Testing — Self-Validation Evidence

Use TESTING.md — The Gate to select phase- and risk-appropriate checks before pushing. Output is a **Test evidence:** block appended to the issue Ship Log entry (or the PR body when there is no linked issue). validate-pr reads that block to decide whether the PR needs a binary install or diff review only.

All commands run from the feature worktree.

Step 0 — Installable build

For the proven unembedded markdown-only local exemption, see TESTING.md; aggregate evidence requirements are separate. For a PR candidate, use the draft/candidate sequence in TESTING.md; its exact-head release and Clippy satisfy this step without duplicate compilation. Outside that flow run:

just build

Release build under -D warnings, the same path just pr-install takes. Complete it before ready status; focused checks may precede a draft push as TESTING.md specifies. cargo test omits cfg(not(test)) paths; bare cargo build includes them but does not reject dead-code warnings under the justfile's -D warnings (root AGENTS.md Traps). Its result is the first line of the Test Evidence block: just build: ok.

Then the strict lint gate through the managed Cargo recipe:

just clippy

just build does not run clippy; this is the only step that catches what CI's clippy job will reject (too_many_arguments, type_complexity, needless_borrow, ...). Fix the code, never #[allow]. Second line of the evidence block: clippy: ok.

Flaky Test Policy

A failing test is never dismissed as "flaky" without proof. The word "flaky" is a hypothesis, not a finding; treating it as a finding stops investigation prematurely.

Before a test can be called flaky:

  1. It must pass twice in isolation: cargo test --bin plexi <test_name> -- --exact
  2. If it passes in isolation but fails in the full suite → it has a concurrency bug. Find and fix the shared state.
  3. Even after confirming flakiness, file a GitHub issue — don't shrug it off in the Ship Log.

Ship Log rule: never write "test passed in isolation, likely flaky" as a conclusion. Write either:

Concurrency interference was the root cause of issue #2229. Tests shared config_dir() (a real $HOME subdir) across threads. The fix: HostHarness now auto-isolates every test into a per-test tempdir. Any new shared-state interference must be fixed the same way — not dismissed.

Step 1 — Classify the Diff

git diff --name-only origin/alpha...HEAD
git diff --name-only HEAD
git ls-files --others --exclude-standard

The first command classifies committed branch changes; the latter two include

the current pre-push worktree. Do not classify from origin/alpha...HEAD alone

when implementation is still uncommitted.

| Touched | Layer | Evidence required |

|---|---|---|

| src/ host logic (commands, effects, pane ops, CLI) | host | scoped cargo test --bin plexi |

| src/ egui layer (overlays, widgets, render, style) | host-ui | PlexiUiHarness test + screenshot |

| plugins/, sdk/python/ | pgap | relevant app/SDK checks; inspected render for visible changes |

| docs or skills | docs | path-specific gate classification and relevant documentation checks |

| scripts or config | infrastructure | focused checks and other gates required by TESTING.md |

A diff can hit multiple layers; produce evidence for each.

The docs-only classification is path-specific, because some markdown is code.

Markdown reachable from include_str! anywhere under src/ — shipped or

#[cfg(test)] — is compiled into the artifact or asserted on by a doc-sync

test, so it takes the layer of its including module and needs that layer's

evidence. Decide with the selector, never by eye:

bash scripts/scoped-tests.sh --gate $(git diff --name-only <base>...HEAD)

Exit 0 prints docs-only, no build only when every changed path is markdown

that is provably not embedded; exit 1 prints one reason per path (`embedded in

shipped code, embedded in a #[cfg(test)] doc-sync assertion, or not

markdown). The embedded set is computed from include_str! in src/` on every

call — never listed by hand — so a new include moves its target into the

required-gate set automatically.

Step 2 — Host Logic Evidence

Run the PR-push filters from scripts/scoped-tests.sh using the just test-host array invocation in TESTING.md — The Gate, which shares test-profile flags with just scene. The selector implements Step 1's classification; an empty result skips only the Rust test run. Script-specific checks and PGAP/UI evidence still apply. just build and just clippy apply unless the documented local markdown-only exemption is proven.

Follow TESTING.md — The Gate for phase requirements and the scoped evidence schema. Features and batches, including direct-to-alpha stabilization slices, follow the applicable scoped, build, Clippy and independent-validation rules there. The full host suite belongs only to the final combined candidate. Do not add a full-suite run at each integration or tester install. Hosted Rust checks remain deferred; unrelated checks still gate.

Record pass/fail counts and the selected filters. Verify each selected surface has actual matches; zero tests is not evidence. New AppRequest/HostEffect handlers must have a HostHarness test written first. Use -- --exact only with the fully-qualified test name. Evidence must identify the current attempt and diff; do not silently reuse an earlier full-suite run.

Step 3 — UI & App Evidence: Scenes and AppHarness

Host UI — TOML scenes

TOML scene files are the one way to test observable host UI behavior — overlays, widgets, portals, and real PGAP app processes through the production launch path. The runner (src/scenes.rs) executes them on PlexiUiHarness: fully headless wgpu Metal rendering.

just scene tests/scenes/<name>.toml              # run one scene; PNGs + SceneReport JSON to /tmp/plexi-scenes
just scene <file> /tmp/out 0                     # state-only: skip screenshot steps
bash scripts/cargo-with-lease.sh cargo test --bin plexi scene_suite               # all committed scenes (suite = true)

For affected observable behavior, select and run relevant scenes individually; justify when none applies. Escalate to the suite for broadly shared changes as described in TESTING.md.

For a new or changed overlay/widget/pane type: add a committed scene file under tests/scenes/ — it is automatically a regression test. Scenes that spawn real app processes set suite = false and run via just scene.

size = [1280.0, 800.0]

[[steps]]
open = { kind = "process", path = "plugins/dev/balls", as = "balls" }
[[steps]]
wait_app_frame = { target = "balls", timeout_s = 15.0 }
[[steps]]
assert = { target = "balls", pane_count = 1, lifecycle = "running", tree_contains = "balls" }
[[steps]]
shot = "balls.png"

For the canonical scene DSL reference, coverage map, assertions, and SceneReport

format, see src/testing/TESTING.md.

Python PGAP apps — AppHarness PNG renders

For visible plugins/ and sdk/python/ changes, use AppHarness for headless PNG validation. No running host or display required — it pipes draw commands to plexi --render via stdin and returns PNG bytes.

from plexi_sdk.testing import AppHarness, render_draw_commands

# Full app test — spawns the app subprocess, drives it over PGAP protocol
with AppHarness("plugins/my_app/app.py", width=800, height=600) as h:
    h.run(1)                             # step one render frame
    h.key("enter")                       # inject a key event
    h.run(1)                             # re-render
    h.save_snapshot("/tmp/snap.png")     # write PNG to disk for visual inspection
    h.assert_pixel(10, 10, "#1e1e2e")   # pixel assertion with default tolerance=4
    h.assert_no_overlap()               # assert no rects clip each other

# Direct render — when you already have a draw command list
png = render_draw_commands(cmds, width=800, height=600)

Every Python app ships with at least one AppHarness test in tests/apps/<app_name>_test.py. It must: run one frame, call save_snapshot, and assert at least one pixel or assert_no_overlap. This is the done condition for visual layout — not "it ran without crashing."

Read every generated PNG with the Read tool and confirm it shows the intended state (not an empty pane, error tile, or clipped element). A screenshot nobody looked at is not evidence.

Step 4 — Inspect the Screenshots

Read every generated PNG with the Read tool and confirm it shows the intended state — not an empty pane, error tile, or default fallback. A screenshot nobody looked at is not evidence.

Render realistic seeded content, not an empty state — an empty overlay or a

zero-turn assistant pane cannot show the bug you fixed. screenshot_assistant_conversation_bubbles

in src/ui_tests/tests/assistant.rs is the pattern: build real model state, open through the

real pane path (open_assistant_built / equivalent), screenshot, inspect.

After inspection, follow TESTING.md — Pre-Push Evidence to publish required images after opening the PR. Keep local PNGs until publication succeeds; never treat their temporary paths as durable evidence.

Step 5 — Write the Evidence Block

Append to the Ship Log entry for this attempt (issue body), or the PR description when there is no linked issue:

**Test evidence (attempt <N>):**
- just build / clippy: <pass, or proven markdown-only exemption with reason>
- Head: <full commit>; phase: <feature / batch / final>; affected behavior and risk: <summary>
- Checks: <commands and pass / fail counts, including actual Rust filters and matched counts; skipped or not applicable checks with reasons>
- Visual evidence: <durable link, source, capture context and exact head, or not applicable with reason>
- Conclusion: install skippable — full coverage | binary install required — <why> | docs-only, no build — no test evidence required

These conclusion rules are the single source of truth for install-skip. /implement-stint-v2 and /validate-pr consume the conclusion this block produces — they never re-derive it against their own criteria. If you are editing skip criteria anywhere else, you are editing the wrong file.

Conclusion rules:

PR channel. Headless parity proves schema semantics, not CLI execution or

eventual polling against a real host.

Guards

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.