Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
docs(agents): split root guidance by agent role (#10157)
Alexander Eichhorn4aedd4dd8888
diff --git a/.agents/coordination.md b/.agents/coordination.mdnew file mode 100644index 0000000000..46346bfa56--- /dev/null+++ b/.agents/coordination.md@@ -0,0 +1,22 @@+# Coordinating a task++For the main agent. Implementers and reviewers need only root `AGENTS.md`, the scoped files for their paths, and their brief.++## Delegation++- Main agent investigates, plans, briefs, integrates, validates, reports. It owns shared contracts and completion.+- Brief each implementer: objective, owned files, applicable `AGENTS.md`, agreed interfaces, acceptance criteria, focused checks. Implementer returns a short report: files changed, checks run, open issues.+- One writer per file at a time. Tightly coupled changes go to one implementer; split only independently verifiable work.+- Implementers own meaningful tests for their changes; by default never split production code from its tests.+- Follow-up fixes from review findings or failing checks go back to an implementer, preferably the original one.++## Review++User instructions override defaults. Pick the tier without asking; say briefly why you spawn reviewers. Required checks and browser verification apply at every tier.++1. Review once per coherent candidate, after checks and after every writer finishes. No edits to a candidate under review. Give all reviewers the same fixed base, acceptance criteria, full task-owned diff (staged, unstaged, new files). Name unrelated changes. Focused briefs and entry points, not full conversation history.+2. Put the reviewer's rules in the brief, so no reviewer has to find them:+ - Focuses: (1) correctness, spec conformance; (2) architecture, operational safety, performance, needless complexity; (3) test value and gaps, product quality, UI accessibility. One reviewer covers all three; three reviewers split them.+ - Inspect independently, including needed callers/contracts. Read-only: no edits, commits, or delegation.+ - Findings need location, impact, and failure scenario or engineering cost. Style preference alone is not a blocker.+3. Resolve all material findings. Add useful regression coverage. Rerun affected checks. Clean review is final for an unchanged candidate. Later edits: list changes since the reviewed candidate; get blocker-only follow-up from affected reviewers on them and their consequences. Broaden review or change tier only when scope/risk changes materially.diff --git a/.github/AGENTS.md b/.github/AGENTS.mdindex 50cb186929..a69a6372b2 100644--- a/.github/AGENTS.md+++ b/.github/AGENTS.md@@ -7,6 +7,12 @@- Prefer package completion commands over duplicating them in YAML. Webv2 `pnpm check:release`: install Chromium and required Linux dependencies first.- Keep failure diagnostics with `always()` where fitting. Generated review/performance artifacts stay out of Git.- Hooks must match CI's Ruff version and config. Validation never rewrites formatting.-- Follow [the PR template](pull_request_template.md). Short summaries. Omit subagent counts, tiers, process narration.- Workflow changes neither configure hosted branch protection nor install local hooks. Verify before claiming either.- Windows ARM64 lock gate (`required-environments`, `scripts/check_platform_locks.py`) blocks by design. When a bump trips it: pin the last version with a win_arm64 wheel behind an ARM64 marker, drop an optional package there by marker with a degraded path and a `system-requirements.mdx` entry, or self-build it (procedure in `build-win-arm64-wheels.yml`'s header).++## Commits and pull requests++- Conventional Commits. Subject: short, outcome first, scoped by feature area (`fix(queue)`). Never write the frontend package name `webv2` anywhere in the message. Body: one to three factual lines of material changes; no repetition, no process narration.+- Use the configured Git author.+- The pre-commit hook stashes unstaged changes while it runs: commit only when no other agent writes to the same worktree.+- Follow [the PR template](pull_request_template.md): headings in order, every applicable section and its inline guidance. Omit only conditional sections. Tick only true checklist items. Short summaries. Omit subagent counts, tiers, process narration.diff --git a/AGENTS.md b/AGENTS.mdindex f177d3d450..daccb4634f 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -7,7 +7,7 @@## Find the right owner-Before editing, read every `AGENTS.md` along each target path. Scoped rules add to this file. Policy lives in `AGENTS.md`.+Before editing, read every `AGENTS.md` along each target path. Scoped rules add to this file. Policy lives in `AGENTS.md` files and the `.agents/` file they link.| Area | Guidance and source of truth || --- | --- |@@ -22,6 +22,12 @@ Before editing, read every `AGENTS.md` along each target path. Scoped rules addFrontend work targets **webv2**, served by default. `--webv2` is a compatibility alias; `--web-legacy` selects legacy web. UI investigations: verify build and launch target first. `frontend/api` owns generated OpenAPI/type artifacts.+Before these steps, read:++- Delegating work or running a milestone review: [.agents/coordination.md](.agents/coordination.md).+- Running Python tests: [tests/AGENTS.md](tests/AGENTS.md).+- Committing or opening a PR: [.github/AGENTS.md](.github/AGENTS.md).+## Engineering standard- Before designing: read implementations, callers, contracts, tests. Define observable outcome and validation. Reproduce bugs where feasible. Fix root causes. Rethink designs that pile up patches.@@ -32,19 +38,20 @@ Frontend work targets **webv2**, served by default. `--webv2` is a compatibility- Dependency and lockfile changes only on purpose. Never weaken assertions, gates, architecture policy, or performance budgets to pass. Explain existing failures and verification limits.- Keep architecture and reference docs matching the code. State current invariants, not migration history. Write paths from a stated root. Give the reason for a non-obvious rule.- Repo guidance beats external skill, plugin, workflow defaults: test boundaries follow existing owner interfaces and tests; reviews use the tiers below over the full task-owned diff, uncommitted files included; notes go in `.scratch/agents/<task>/`; commands use package-owned scripts and pnpm. No personal paths, no generic ceremony.+- Any webv2 UI change: verify changed interactions in the browser. Automated checks alone do not prove visual quality.-## Performance and efficiency+## Performance-- Check affected hot paths and immediate callers for repeated work, renders/subscriptions, waterfalls, queries, serialization/copies, unbounded collections, retained resources.-- Do clear, low-risk improvements in scope. Larger optimizations must serve the task. Note unrelated opportunities briefly; do not expand scope.-- Measure nontrivial optimizations and performance claims: existing budgets, representative fixtures, query counts, profiling, or focused benchmarks. Report material before/after and limits.-- Correctness and clarity first. Caching, memoization, concurrency, batching need understood invalidation, lifetimes, ordering, cost. No invented optimizations or benchmarks for a checklist.+- Check affected hot paths and immediate callers for repeated work, renders/subscriptions, waterfalls, queries, serialization/copies, unbounded collections, retained resources. Do clear, low-risk improvements in scope; larger ones only when the task needs them. Note unrelated opportunities briefly; do not expand scope.+- Correctness and clarity first. Measure nontrivial optimizations and performance claims (existing budgets, representative fixtures, query counts, profiling, focused benchmarks); report material before/after and limits. Caching, memoization, concurrency, batching need understood invalidation, lifetimes, ordering, cost. No invented optimizations or benchmarks for a checklist.-## Product quality+## Delegation-Polished desktop experience: deliberate layouts, responsive interactions, cohesive accessible controls, complete loading/empty/error/recovery states. Verify changed interactions in the browser. Automated checks alone do not prove visual quality.+Main agent may edit directly only when the whole task qualifies for self-review; otherwise delegate implementation. Harness without subagents: edit locally.-## Milestones and code review rules+Main agent owns machine-wide resources: dependency installs, generated API contracts, full suites and release gates, GPU/generation work, fixed-port servers, shared browser sessions. One webv2 performance gate per machine: it measures timing and binds fixed ports. Implementers run focused checks only, use spare ports, clean up temporary output, and never stash, reset, or check out in shared worktrees.++## Review and readinessMilestone = one coherent, commit-ready unit. Run relevant checks and self-review every change. Pick review depth by the whole task's behavior, blast radius, failure consequences. Not by file/line count or directory alone. Never split risky work to dodge review.@@ -54,48 +61,22 @@ Milestone = one coherent, commit-ready unit. Run relevant checks and self-review| **One independent reviewer** | Substantive feature, fix, refactor; bounded impact; no high-risk trigger || **Three independent reviewers** | Behavior changes touching authentication/authorization, account isolation, persisted-data compatibility/migrations, destructive operations, concurrency/resource lifecycles, shared API compatibility, inference numerics/device/memory, or substantial cross-owner architecture |-Review focuses: (1) correctness, spec conformance; (2) architecture, operational safety, performance, needless complexity; (3) test value and gaps, product quality, UI accessibility. One reviewer covers all three; three reviewers split them. User instructions override defaults. Pick the tier without asking; say briefly why you spawn reviewers. Required checks and browser verification apply at every tier.--1. Review once per coherent candidate, after checks and after every writer finishes. No edits to a candidate under review. Reviewers did not implement it. Give all reviewers the same fixed base, acceptance criteria, full task-owned diff (staged, unstaged, new files). Name unrelated changes. Focused briefs and entry points, not full conversation history.-2. Reviewers inspect independently, including needed callers/contracts. Read-only: no edits, commits, or delegation. Findings need location, impact, and failure scenario or engineering cost. Style preference alone is not a blocker.-3. Resolve all material findings. Add useful regression coverage. Rerun affected checks. Clean review is final for an unchanged candidate. Later edits: list changes since the reviewed candidate; get blocker-only follow-up from affected reviewers on them and their consequences. Broaden review or change tier only when scope/risk changes materially.-4. Never declare ready with material findings or unexplained failing gates. Report resolved findings, passed/failed/unavailable checks, remaining limits. PRs omit subagent counts, tiers, process narration.--Required independent review unavailable: self-review the matching focuses and tell the user. Ordinary low-risk self-review needs no disclaimer. Self-review is never independent, including review by an implementing agent.--## Delegated implementation--Main agent never edits repository files: every edit goes to an implementation subagent, so the main conversation keeps its context for planning, coordination, and review. Harness without subagents: edit locally.--- Main agent investigates, plans, briefs, integrates, validates, reports. It owns shared contracts and completion.-- Brief each implementer: objective, owned files, applicable `AGENTS.md`, agreed interfaces, acceptance criteria, focused checks. Implementer returns a short report: files changed, checks run, open issues.-- One writer per file at a time. Tightly coupled changes go to one implementer; split only independently verifiable work.-- Implementers own meaningful tests for their changes; by default never split production code from its tests.-- Follow-up fixes from review findings or failing checks go back to an implementer, preferably the original one.--Main agent also owns machine-wide resources: dependency installs, generated API contracts, full suites and release gates, GPU/generation work, fixed-port servers, shared browser sessions. Implementers run focused checks only, use spare ports, clean up temporary output, and never stash, reset, or check out in shared worktrees. Pre-commit hook stashes unstaged changes while it runs: commit only when no other agent writes to the same worktree. One webv2 performance gate per machine: it measures timing and binds fixed ports.+- Reviewers did not implement the change. Self-review is never independent, including review by an implementing agent. Required independent review unavailable: self-review the matching focuses and tell the user. Ordinary low-risk self-review needs no disclaimer.+- Never declare ready with material findings or unexplained failing gates. Report resolved findings, passed/failed/unavailable checks, remaining limits. PRs omit subagent counts, tiers, process narration.+- Readiness does not authorize commits or pushes. Follow the user's existing authorization. No automatic per-subtask commits.## Commands and environments- **pnpm 10** only, never npm/yarn. Package-owned lockfiles. Run pnpm from the package directory: Corepack picks pnpm's version from the current directory, so `pnpm -C <package>` from the root can get the wrong one. Node version from `.nvmrc`. Read package scripts; do not assume the root Makefile covers webv2.- Keep the existing Python/accelerator environment and `uv.lock`. Fresh test setup: `uv sync --locked --extra test`. Do not routinely replace accelerator backends.+- Once test dependencies exist, install hooks per checkout: `uv run --no-sync pre-commit install`. Committed config does not install hooks.- Root Python checks: `uv tool run [email protected] check <paths>`, `uv tool run [email protected] format --check <paths>`. 120 columns, absolute imports, configured vendored-code exclusions.-- Focused tests: `uv run --no-sync pytest <test-paths>`. Full CI: `uv run --no-sync pytest -n logical`. Hardware/quiet-machine timing tests: `-m slow` on dev machines; excluded by default and in CI. Isolation rules: `tests/AGENTS.md`.-- `-n logical` fits CI runners that own the machine. Dev box: cap workers (`-n 4`, or plain `pytest`). Set `OMP_NUM_THREADS` when a run must stay light. Never start a suite during a generation.-- `uv run --no-sync mypy scripts/invokeai-web.py` uses current exclusions. Optional diagnostic only: not a CI gate, not full type coverage.+- Focused tests: `uv run --no-sync pytest <test-paths>`. Never start a suite during a generation.- Pick checks by behavior. Run required milestone gates before review. Rerun unchanged checks only with a reason.-- Family E2E runs (`scripts/family_e2e`, guide: `docs/src/content/docs/development/Guides/family-e2e.mdx`) after changes to what a model computes or how it loads: model-manager loading, probing, configs; quantization; attention; model cache, working memory; invocations that run models; webv2 graph builders. Offer a run of the affected families, never start one unasked; none for docs-, test- or UI-only changes. Offer only where a manifest is set up; otherwise name the missing run under open limits in the final report. After a yes: run the base commit and `accept` it as reference (its bundle then reports BASELINE), then the branch, with `expect: changed` on the cases the PR is meant to change. PR description gets the `summary.md` table; attach the `bundle` zip. Until A/B runs exist, time differences under about 10 % between sessions are noise.-- Once test dependencies exist, install hooks per checkout: `uv run --no-sync pre-commit install`. Committed config does not install hooks.+- Family E2E runs (`scripts/family_e2e`) after changes to what a model computes or how it loads: model-manager loading, probing, configs; quantization; attention; model cache, working memory; invocations that run models; webv2 graph builders. None for docs-, test- or UI-only changes. Offer a run of the affected families, never start one unasked. Offer only where a manifest is set up; otherwise name the missing run under open limits in the final report. Procedure: `docs/src/content/docs/development/Guides/family-e2e.mdx`.## Scratch files and repository hygiene- Never commit plans, work logs, investigation notes, review transcripts, handoffs, under any filename. Optional scratch: `.scratch/agents/<task>/`. Never relabel scratch as durable docs.- Version durable docs of implemented architecture, decisions, APIs, setup.- Check staged diffs and new files for planning material. Ignore rules neither untrack files nor block force-adds. Never force-add planning artifacts. Never add `package-lock.json`/`yarn.lock`.--## Commits and pull requests--- Readiness does not authorize commits or pushes. Follow the user's existing authorization. No automatic per-subtask commits.-- Conventional Commits. Subject: short, outcome first, scoped by feature area (`fix(queue)`). Never write the frontend package name `webv2` anywhere in the message. Body: one to three factual lines of material changes; no repetition, no process narration.-- Use the configured Git author.-- Follow `.github/pull_request_template.md`: headings in order, every applicable section and its inline guidance. Omit only conditional sections. Tick only true checklist items.diff --git a/docs/src/content/docs/development/Guides/family-e2e.mdx b/docs/src/content/docs/development/Guides/family-e2e.mdxindex 57a799c596..4a0719cb60 100644--- a/docs/src/content/docs/development/Guides/family-e2e.mdx+++ b/docs/src/content/docs/development/Guides/family-e2e.mdx@@ -1,6 +1,6 @@---title: Family E2E Runs-lastUpdated: 2026-10-29+lastUpdated: 2026-11-05---`scripts/family_e2e` runs model families end to end through the HTTP API of a server it launches itself. Per case and size it records the image, the run time, the time per denoise step and the VRAM the server process used, measured at driver level. The report compares them with an explicitly accepted reference and with the previous run of the same profile.@@ -88,6 +88,16 @@ On Windows the background runner breaks away from the caller's job object, so aA resumed run skips every step that already has a final record and keeps the measures of the earlier sessions. Its new server starts with a cold model cache, so each case size with measures left first repeats its last warm-up, once. The manifest, the graphs, and the server's commit and dirty flag must not have changed since the run started; further edits to an already dirty checkout cannot be detected.+## Comparing a branch with its base++Use this to test a pull request that changes what a model computes or how it loads.++1. Run the base commit and `accept` it as the reference. Its bundle then reports `BASELINE`.+2. Run the branch, with `expect: changed` on the cases the pull request is meant to change.+3. Put the `summary.md` table in the pull request description and attach the `bundle` zip.++Until such a comparison exists, treat time differences under about 10 % between sessions as noise.+## Working-memory calibration`start --calibrate` measures what each model operation of the cases needs on this GPU. It runs where the rest of the tool does: on Windows, and on Linux with NVIDIA GPUs, where the server's probe reads the driver's figure through NVML too. Every step compiles its graph as a normal run does, then submits it to `POST /api/v2/models/i/{model}/working_memory/calibrate` with the case's `model` key instead of `enqueue_batch`, stating each model of the graph as the config the case was compiled from has it (`graph_models`, from the run's `case_models`); the server refuses a step whose models changed since. The server runs it with its working-memory probe, which records a window per estimated model operation in its calibration store (see "Calibration runs" in the [model manager architecture](/development/architecture/model-manager/#calibration-runs)). Warm-ups and measures alike are submitted, and every window is kept.diff --git a/invokeai/frontend/webv2/AGENTS.md b/invokeai/frontend/webv2/AGENTS.mdindex 5d5930fe3d..56294cdba0 100644--- a/invokeai/frontend/webv2/AGENTS.md+++ b/invokeai/frontend/webv2/AGENTS.md@@ -16,6 +16,7 @@ Shared generated API contracts and their CI gates: [../api/AGENTS.md](../api/AGE## React and product quality+- Polished desktop experience: deliberate layouts, responsive interactions, cohesive accessible controls, complete loading/empty/error/recovery states.- No direct `useEffect`. Derive during render, act in event handlers, fetch through Query, subscribe via external-store adapters.- `@platform/react/useMountEffect`: only mount/unmount registration with stable dependencies and complete cleanup. No changing-dependency refs, wrapper aliases, layout-effect evasions. Layout effects only for pre-paint DOM measurement.- Changing an effect's behavior: migrate it. No unrelated sweeps. Identity changes use store/runtime lifecycles or deliberate keyed remounts, without accidental state loss.diff --git a/tests/AGENTS.md b/tests/AGENTS.mdindex ec4a0604be..c0c2b89417 100644--- a/tests/AGENTS.md+++ b/tests/AGENTS.md@@ -6,6 +6,8 @@- Isolate paths, databases, accounts, clocks, seeds, environment, network behavior. Clean up subprocesses, listeners, patches, resources. Never use production model/database/output directories.- Cover affected rollback, revisions, cross-user isolation, retries, cancellation, bounds, cleanup. IndexedDB, Web Locks, focus, rendering belong in webv2 browser tests.- Use root pytest commands. CI runs one xdist worker per vCPU; windows-ffmpeg runs two. `--dist loadfile` in `addopts` keeps each file on one worker; file assignment and order are arbitrary. Each file sets up its own process-global state (e.g. JWT secret) and passes alone. Verify new files on their own.+- Full CI: `uv run --no-sync pytest -n logical`, which fits CI runners that own the machine. Dev box: cap workers (`-n 4`, or plain `pytest`). Set `OMP_NUM_THREADS` when a run must stay light.+- `uv run --no-sync mypy scripts/invokeai-web.py` uses current exclusions. Optional diagnostic only: not a CI gate, not full type coverage.- Default tests assert behavior, not throughput or latency under runner contention. Generous hang ceilings fine. CPU time tolerates contention better than wall time. Hardware/quiet-machine measurements need `slow`, excluded by default and in CI. Dev machines: `-m slow` for that lane, `-m ""` for everything.- Keep a test's run time to the work it checks; idle seconds add up across the suite, and the ffmpeg tests run on two workers in windows-ffmpeg. Check new files with `--durations=10`, which splits setup, call and teardown.- No real waits. Poll intervals, retry backoffs and grace periods belong in module-level constants that a fixture can shorten. The root `conftest.py` already shortens the download, installer and image-index queue polls, so a service's `stop()` in teardown returns at once. Shorten a retry backoff only in the tests that script its failures, as `_fake_move` in `test_model_install.py` does: the backoff is what lets a real Windows file handle close.