Files
ComfyAssets-ComfyUI_PromptM…/TESTING.md
T
Vito 6f02277a1c fix: small cleanup from the audit true-up (#662) (#665)
* refactor(api): one bounded JSON body reader for the API and images.py (#662)

images.py kept its own copy of the chunked, capped JSON object reader.
Both now use py/api/json_body.py; images.py keeps its 1 MiB cap and its
raising form for the thumbnail job.

* fix(api): refuse malformed bodies on the legacy prompt routes with a 400 (#662)

PUT /prompts/{id}, PUT /prompts/{id}/rating, POST and DELETE
/prompts/{id}/tags, POST /prompts/tags, PUT /tags/{tag}, POST /tags/merge
and POST /bulk/delete|tags|category read the body with the bounded JSON
reader /save uses and check field types, so a body that is not a JSON
object, or a field such as {"text": 123}, is a 400 instead of a 500.
A prompt id may still be a number or its text, as the legacy page sends
it; a boolean is refused (prompt_ids [true] deleted prompt 1).
POST /jobs/image-tags refuses a mode that is no text instead of a 500.

* refactor(inspect): both resolvers read PROVEN_VALUE_CATEGORIES (#662)

proves_value hard-coded the four tables in Python and in the browser.
Semantics.proves_value now reads the constant (class-keyed categories by
class, the rest by output slot), the browser resolver loops over its
mirrored copy in local-resolver-support.mjs, and
tests/test_proven_value_parity.py fails when that copy drifts. A test
patches the constant to show the resolver follows it.

* refactor: remove the write-only preview batch count and the test-only node search (#662)

AutoThumbnailWorker set self._batch in four places and never read it.
PromptManagerBase._search_prompts had no caller but its own tests: the
node UIs search through GET /prompt_manager/search. Prompt search itself
stays covered by the database and route tests.

* fix(tools): open libraries through the shared read-only URI helper (#662)

review_image_links, repair_foreign_links (twice) and workflow_text_digests
built their own file: URIs, which SQLite refuses for a library on a
Windows network share (file://server/share/...). They now use
database/sqlite_uri.readonly_uri; repair_foreign_links opens its own
read-write backup by path. The guard in tests/test_sqlite_uri.py scans
tools/ too and also catches a conditional ?mode=ro suffix.

* ci: bound the publish and Viewer.js update jobs by measured limits (#662)

publish.yml and viewerjs-update.yml had no timeout-minutes, and the
workflow guard listed only four workflows. The guard now reads every
workflow and recomputes both new limits from their comments: publish
5 min from its last three green runs; the Viewer.js update 18 min, from
an estimate of its never-run update path (the three measured nightly
runs found no release and give the 5-minute floor).

* docs: correct the redesign plan's CI and PR rules, renumber the second D205 (#662)

docs/application-redesign.md named a Python 3.10-3.13 matrix with macOS,
asked for PR screenshots and said Overview links the legacy metadata
page. It now names the 3.12 floor and the current Linux/Windows split,
asks for visual changes in words, and says the metadata page is reached
by address or from the legacy admin page. TESTING.md used D205 for both
#431 (saved instructions) and #620 (Library sorts); #620's entry is
D206 now.
2026-11-21 09:46:31 -08:00

594 KiB
Raw Permalink Blame History

Testing and merge confidence

Routine changes should merge after the required checks pass and the diff is reviewed. Add a regression test for each bug; prove it fails before the fix.

What runs

Layer Real components Replaced boundaries
Python tests Domain logic, SQLite, API handlers, filesystem checks ComfyUI host and ML runtimes where needed
JavaScript tests Frontend modules and controller methods DOM/network fixtures for focused edge cases
Viewer checks Production Viewer.js and frontend methods in Chromium desktop/touch Controlled images and page fixtures
Real ComfyUI Pinned CPU host, actual extension, node definitions, widgets, routes, SQLite and real execution lifecycle Stock UI cases isolate host writes; the execution suite queues deterministic test-only nodes without models
Page workflows Production HTML, startup, click handlers, HTTP routes, SQLite, PNG files, thumbnails ComfyUI host services and the tagging model

Page workflows cover save/edit/reload, duplicate-edit rejection, gallery image identity, Tags selection and viewer cleanup, delayed responses, auto-tag review and persistence, and infinite scrolling without replacing existing cards. Data safety workflows download and upload actual SQLite backups, verify restored prompts/tags/image links, reject corrupt uploads without changing live data, and exercise cancellation and network-failure recovery for restores and deletion. Duplicate cleanup verifies only the selected file disappears; prompt deletion verifies the other prompt and original image files survive. They run in Chromium, Firefox, WebKit, and Chromium touch emulation. No GPU, model downloads, running ComfyUI instance, or personal configuration is required. The server binds to localhost and creates disposable directories and a database; its reset endpoint exists only in the test harness.

Run locally

Use a Python environment containing requirements-dev.txt and Node.js 24:

python -m tests.run_suite -q        # what CI runs; see "Time limits and hangs"
npm ci --prefix tools/vendor --ignore-scripts
npx --prefix tools/vendor playwright install --with-deps chromium firefox webkit
npm run --prefix tools/vendor test
npm run --prefix tools/vendor test:coverage                                          # desktop Chromium: what the gate runs
npm run --prefix tools/vendor test:workflows -- --project firefox --project webkit --project touch   # what nightly runs

python -m unittest discover -s tests still works and finds the same tests; it just has no hang watchdog.

PM_TEST_PYTHON selects the Python executable; set it when Python is outside PATH. Every Playwright worker starts its own tests/browser/server.py --port 0, which binds a port the OS picks and prints it as PM_TEST_SERVER_PORT=<n>, with its own temp root and database (tests/browser/fixtures.mjs), so parallel workers and concurrent runs never share state. PM_TEST_WORKERS sets the worker count (default 1 under CI, otherwise a quarter of the CPUs, at most 8). Test servers are never reused across runs. The launcher holds each server's stdin open and the server (--exit-on-stdin-eof) shuts down cleanly, removing its temp root, when that pipe closes, so a worker killed without teardown leaves no server behind. A test that fails gets the stderr its server wrote during the test attached to the report as server-stderr (an aiohttp traceback behind a 500). Each worker also records its browser's own log (#513, tools/vendor/browser-logs.mjs): Playwright's pw:browser channel, kept as a 300-line tail without printing it unless DEBUG asks for it. A browser that exits abnormally writes one pm-browser-exit| browser pid=<n> exited: exitCode=<c>, signal=<s> line to the job log, and a test that fails on a closed or crashed target ("Target page, context or browser has been closed") gets the tail attached as browser-stderr.txt, which the uploaded test-results carry. tests/browser/browser-logs.spec.mjs kills a browser of its own on purpose, so each browser job logs that line once for it. A /__test__/.../reset still running after 2 s writes a report to the job log, passing test or not: every thread's stack taken while it waits, the default executor's threads and queue, the open connections and WAL size, then the total and how long each executor call queued and ran. Its lines start with pm-slow-reset| (tests/browser/slow_reset_watch.py). The report never reads a connection another thread is using: one that is busy inside SQLite would block that read with the GIL held and freeze the whole server.

The coverage run can be split the way CI splits it, and each shard keeps the raw V8 files it writes under coverage/js/raw:

PM_TEST_WORKERS=8 npm run --prefix tools/vendor test:coverage            # whole run, one report
npm run --prefix tools/vendor test:coverage:shard -- 1/4                 # node units, viewer suite, workflows 1/4
npm run --prefix tools/vendor test:coverage:shard -- 2/4                 # workflows 2/4 (likewise 3/4, 4/4)
npm run --prefix tools/vendor coverage:merge                             # report and baseline check of every raw file
npm run --prefix tools/vendor test:workflows -- --project webkit --shard 2/3

coverage:merge refuses an empty raw directory; it does not count shards, so run every shard first (CI's merge job checks all four arrived). Measured on a 32-CPU machine in the pinned image (2026-10-21): test:coverage takes about 5 minutes with 8 workers and 24 minutes with 1; all four projects, 8 workers, each test 3 times (6132 tests), 24 minutes. A CI-sized run (docker run --cpus=4, PM_TEST_WORKERS=3, all four projects once, 2044 tests) takes 25.5 minutes.

Specs must pass beside each other, not only alone. Wait for the page's own signal, never for time: a rendering frame (requestAnimationFrame) for layout work queued by a render or a scroll, a response or a visible state for data. A timer that "usually" covers a frame is a race on a loaded runner. Library virtualization specs settle with libraryObservation.settled() (two consecutive frames with no Library frame queued). To look for such races, repeat a spec under load (--workers 8 --repeat-each 10, and in the image with --cpus=1 or 2). CPU limits do not reproduce disk-bound timeouts (backup, restore). For those, throttle writes in the image: with rootful Docker on a host with cgroup v2, add --device-write-iops /dev/<disk>:20 to the docker run, where <disk> is the whole disk (not a partition) holding Docker's data root, because the test server keeps its database in the container's /tmp. On a plain partition, lsblk -no pkname "$(df --output=source "$(docker info -f '{{.DockerRootDir}}')" | tail -1)" prints it; on LVM or LUKS, lsblk -s walks down to the disk. A spec that waits on a timer then fails at its 5 s expect. A spec that waits on the response can still fail at the 30 s test timeout when several workers share the throttled disk; that means the disk is too slow for the test budget, not that the spec is wrong.

On unsupported Linux distributions, browser system dependencies may need manual installation. For a quick browser run, use test:workflows -- --project chromium.

CI runs the browser jobs inside the pinned image mcr.microsoft.com/playwright:v<@playwright/test version>-noble@sha256:<digest> (tests/vendor/browser-image.test.mjs keeps the tag in step with the lockfile). The digest is part of the pin, because Microsoft re-pushes tags: v1.64.1-noble moved from Node 24 to Node 26 on 2026-11-01 (#609). To bump it, change the tag and digest together and check the new image's Node against the Node 24 guard. Concept comparisons measure geometry, and geometry follows the fonts a browser falls back to: the concept names Inter, which neither the image nor a stock runner ships. On a plain ubuntu-latest runner the fallback is DejaVu Sans, whose wider metrics make the concept's own Tags table overflow a 390px viewport, so the 390px comparisons are only meaningful in the pinned image. To reproduce CI, run the suites in that image.

Managed real ComfyUI

The shared engine comes from an exact commit of ComfyAssets Toolkit, recorded in tools/vendor/package.json and its integrity-checked lockfile. The local adapter sets PromptManager's database/configuration and monitoring policy; source discovery, coverage mapping/gates and process lifecycle are shared code. KikoTools remains the reference and is unchanged by this integration.

Use a dedicated disposable ComfyUI checkout at the revision in tools/vendor/comfyui-runtime.json. With a separate Python environment, install that checkout's requirements, this repo's requirements-dev.txt, and the exact CPU torch/torchvision pins from the JSON (using PyTorch's CPU wheel index). Install Chromium using the Playwright command above, then run:

PM_COMFY_ROOT=/path/to/disposable/ComfyUI \
PM_TEST_PYTHON=/path/to/cpu-env/bin/python \
npm run --prefix tools/vendor test:comfyui

CI performs this setup automatically. PM_COMFY_URL can select another http://127.0.0.1:PORT/ address (default port 8189). This is an owned managed server: a running host is never reused. Do not point it at your live checkout. One port serves one run. The launcher refuses a port that is already in use and reports ready only when /system_stats names its own base directory, so two runs started together on 8189 fail at startup ("already in use" or "answered by a ComfyUI host this run did not start") instead of one run testing the other's host and losing it mid-test (ECONNREFUSED, ERR_CONNECTION_REFUSED, Network Error). Every test checks the answering host again. Agents sharing a machine give each run its own PM_COMFY_URL port. The launcher verifies the upstream SHA and clean tracked files, snapshots only tracked PromptManager files, and creates temporary user/input/output/database/ configuration/log directories. Personal untracked files are excluded. It runs CPU/offline with only PromptManager enabled and removes owned state on shutdown. The upstream checkout must also be disposable: ComfyUI may initialize local runtime files there. Browser host-settings writes are intercepted; actual PromptManager routes use the disposable host and database.

real-comfyui-reports retains startup logs, version attachments, screenshots and traces for 14 days. Update upstream/frontend/CPU pins together after reviewing and running both startup projects; never replace the SHA with a moving branch. Update the toolkit via an exact reviewed commit archive and commit both npm manifest and lockfile. No toolkit or npm installation is needed by end users.

Coverage and failures

Python CI enforces 85% combined statement/branch coverage. Frontend coverage merges Node V8 unit coverage with Chromium page-workflow coverage through c8. Every web/js/**/*.js and web/js/**/*.mjs file appears, including untouched files at zero coverage. The controller tests provide V8 filenames so their executed code is counted too.

tools/vendor/frontend-coverage-baseline.json holds a floor for every file and metric. CI rejects regressions, missing measurements, and new files without a reviewed baseline. These floors reflect current coverage, with two percentage points of allowance for runtime/timing differences; they do not claim 80% coverage of the large controllers. New files need at least 80% line coverage when added via the baseline updater. Raise floors with npm run --prefix tools/vendor coverage:update; it reruns the suites and cannot lower an existing floor. Review baseline changes like code changes.

npm run --prefix tools/vendor coverage:baseline-check runs in well under a second without a browser and fails, naming the files, when a measured web/js file has no baseline entry or the baseline lists a file that no longer exists. It uses the gate's own discoverSources, and npm test runs the same check, so run it before pushing a new or deleted frontend file instead of waiting for the frontend coverage jobs.

Frontend coverage is measured with desktop Chromium alone (#666): the gate's four frontend coverage (shard N/4) jobs and frontend coverage (merge) run on every pull request with a code change, including backend-only ones (see "The gate and the nightly run"). The phone-size touch project, Firefox and WebKit run nightly and add no coverage. Measured on main a1f74470 in the pinned image (2026-11-21): with the node units and Chromium alone, without touch, all 126 files met their floors; the closest were workspace/images-state.mjs branches (98.05 against 98) and workspace/viewer-state.mjs branches (95.06 against 95). Every browser job runs with PM_TEST_WORKERS: 3 (the public runners have 4 vCPUs). Each coverage shard runs test:coverage:shard -- N/4 (shard 1 also runs the node units and the viewer suite) and uploads its raw V8 files as coverage-raw-N (kept 3 days). The merge job downloads them, fails unless all four arrived with raw files and without clashing names, then runs coverage:merge (report plus baseline check). The vendor pins and the tooling tests run in their own job, tooling tests and pins. tests/vendor/ci-workflow.test.mjs checks this shape. GitHub artifacts named frontend-test-reports contain the merged HTML coverage and JSON summary; frontend-traces-shard-N hold the Chromium failure screenshots/traces and, from the nightly run, browser-traces-<browser>-shard-N the other projects' traces. Open traces with Playwright's show-trace tool.

Every npm ci first restores npm's download cache (~/.npm), keyed on the vendor lockfile and the job's pinned image tag (tests/vendor/ci-workflow.test.mjs checks the key names the same tag as the job's container.image). Without it, npm ci stalled for about 300 s (npm's fetch timeout) in most of the eight concurrent jobs; with a hit it takes 0 to 2 s. A lockfile change misses the cache once, so expect one slow run after it. Measured on PR #274 (run 39725176320 at cbc8a61, cache hit): the whole workflow took 8m38s, against about 33 minutes with one worker and no shards. Jobs: coverage shards 7m34s/6m04s/5m22s (tests 6m38s/4m53s/4m04s), merge 54s, firefox shards 7m57s/5m21s (tests 7m08s/4m34s), webkit shards 8m16s/5m03s (tests 7m26s/3m58s). Browser jobs keep a 20-minute limit: the slowest job is about 8.5 minutes, a cache miss adds up to 5 to npm ci, and runner speed varies (the first sharded run was cancelled at a 12-minute limit). Playwright shards by test count, whole files at a time, so shard 1 carries the slow concept-comparison specs (*-concept.spec.mjs, alphabetically first) and runs longer; the remedy, if it starts to matter, is more shards, not reordering.

The real-host suite covers both Classic and Nodes 2.0 startup, switching both ways, actual database prompt selection, execution-text serialization, workflow reload, widget/style cleanup, node schemas and standalone-page opening. It does not certify every existing feature, arbitrary host versions, GPU/model changes, cross-pack installation or visual design changes. Those still need targeted validation.

Time limits and hangs

CI and the pre-push hook run the Python suite as python -m tests.run_suite (-v, -q, -s START and -p PATTERN as in unittest discover); the gate runs it once, under coverage, as python -m coverage run -m tests.run_suite -v. The runner (tests/run_suite.py) discovers the same tests with the same sys.path and warning filters as python -m unittest discover -s tests, exits 0, 1, or 5 when no tests ran (Python 3.12+ behaviour, on every version), and adds a watchdog: it writes start: <test id> to stderr before every test, at every verbosity, and arms faulthandler.dump_traceback_later. If a test, its teardown, its event-loop shutdown or interpreter exit stops making progress, the stack of every thread goes to stderr (Timeout (0:02:00)! then Thread 0x... blocks) and the process exits non-zero.

  • PM_TEST_HANG_LIMIT (default 120 s) bounds each test from its start: line to the next one, including the class and module fixtures (tearDownClass, setUpModule, ...) that run in between. PM_TEST_SHUTDOWN_LIMIT (default 120 s) bounds the end of the run: the summary, non-daemon threads, atexit handlers and coverage's save. Both must be positive integers; anything else stops the runner with exit 2. 120 s stays below asyncio's 300 s wait for default-executor threads on Python 3.12 and 3.13 (3.10 and 3.11 wait without limit), so a hang in an IsolatedAsyncioTestCase loop shutdown is dumped inside the test that hung.
  • Reading a dump: the last start: line names the test. An ok after it means the test body passed and the hang came after it: in its teardown or event-loop shutdown (where IsolatedAsyncioTestCase joins executor threads), or in a class or module fixture before the next test; the stack shows which. A dump after the summary is a hang at interpreter exit. The dump shows thread stacks, not asyncio task stacks.
  • When the watchdog fires under coverage, that run's coverage data is lost; the job fails anyway and the dump is what matters.
  • PM_TEST_SLOWEST=N (off by default) lists the N slowest tests after the summary, each timed from its start: line to the next one like the hang limit. The Windows jobs (nightly.yml) set it to 40, so every run shows where its time went (#487). The list prints only when the run ends: a job GitHub cancels or a watchdog exit prints none, so read the timestamps between start: lines instead.
  • On the Windows runners TEMP sits on the OS disk C:, where a flush took about 6 ms and a test database's create-to-delete about 111 ms (D: 0.5 ms and 23 ms, macOS 19 ms). nightly.yml points TEMP/TMP at a folder under RUNNER_TEMP on D: before the suite. It switches 8.3 short names on for D: and spells the folder by its short name, as the runner's own TEMP was (C:\Users\RUNNER~1\...), logs it, and warns when there is none. A test that waits on a fixed busy timeout, a network name (\\server\share: use \\localhost\<missing share>) or a default TLS context (it reads the Windows certificate store) costs seconds there; the slowest list shows it.
  • On a Windows development machine (#636), give the suite a short TEMP (for example C:\t) or turn long paths on (HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled = 1). Under the default C:\Users\<user>\AppData\Local\Temp, the visual fixture's 182-character file name passes Windows' 260-character limit once a test nests its own temp folder, and the chronological-history reset answers 500. Three other differences from the CI runner are handled in the tests: a virtual environment's python.exe is a launcher that runs the real interpreter as a child, so a test that kills a server it started removes its folder with tests/process_cleanup.py's remove_when_released, which waits for that child to end (a handle the test process itself still holds never releases, so the bound still fails it); Git for Windows checks text files out with CRLF, so .gitattributes keeps the pinned vendored files byte for byte and a test that parses source text normalizes line endings; and a test that expects no ComfyUI nearby works two folders inside its temp folder, because the output-folder fallback looks two levels up.

Every job in ci.yml, nightly.yml, publish.yml and viewerjs-update.yml (#662) has timeout-minutes. The rule is ceil(1.5 x the slowest of three recent green runs) + 3 minutes, never under 5, timed as whole-job wall time; a matrix job takes its slowest leg. The three run ids, their times and the resulting limit are written in a comment above jobs:, one line per job id (python: 7m20s / 7m36s / 7m58s -> 15 min). A job that has no three green runs yet has an estimate <job id>: <why> -> N min line instead; replace it with the measurement once three green runs exist. tests/vendor/ci-workflow.test.mjs recomputes every measured limit from its line and checks that each job has exactly one line and uses its limit (#493). The 3 minutes leave room for one watchdog firing, so the dump prints before GitHub cancels the job. A job that hits its limit, or a watchdog dump, is a failure like any other: read the dump, find the blocking call, fix it. Never raise a limit or rerun to get green; a limit changes only with new measurements written next to it.

Browser jobs (#425): GitHub keeps no log of a job killed at its limit and skips its upload steps, so the page test step in each browser job (frontend coverage in ci.yml, page workflows in nightly.yml) has its own timeout-minutes, 2 below the job's. At the step limit GitHub sends SIGTERM, which would end Playwright without any report; under CI tools/vendor/running-tests-reporter.mjs catches the first one, prints Still running when the run ended (SIGTERM): N and one line per unfinished test (path relative to the suite's rootDir), then sends Playwright its own SIGINT, so the workers stop, the run ends interrupted and the blob report is written to tools/vendor/test-results/blob/. In the coverage job npm signals only frontend-coverage.mjs, which forwards SIGTERM and SIGINT to the child it is running (started in its own process group, so a group-wide signal still arrives once). Delivery is proven locally in the pinned image for a SIGTERM to the whole process group (timeout -s TERM). A SIGTERM to npm alone (timeout --foreground) reaches nothing: npm forwards it to the sh -c that runs the script, and that shell exits without passing it on. Delivery in CI, where the step runs through docker exec, is not yet observed; the next real step timeout will show it. That directory and the traces upload with if: always(); npx playwright merge-reports opens the blob. Each test keeps the 30 s default and there is no globalTimeout. One limit of this: it assumes the npm cache hits (a cold cache adds up to 5 minutes to npm ci, and the job limit can then still win). Local runs keep the list reporter only; reproduce with CI=1 timeout -s TERM 40 npm run --prefix tools/vendor test:workflows -- --project=firefox.

After a push

Follow the run for the commit you pushed, never an older one:

gh run list --commit <pushed sha> --workflow ci.yml       # the run id for that commit
gh run watch <run id> --exit-status                       # returns when the run ends
gh run view <run id> --json jobs                          # shows a job that already failed
gh run view --job <job id> --log-failed                   # that job's failed log, at once

Everything that can block the merge is in that one run (#666). Firefox, WebKit, touch, Python 3.13/3.14, Windows and real ComfyUI failures show up the next morning, as an open nightly: <job> failing issue and in gh run list --workflow nightly.yml; to see them before merging, run gh workflow run nightly.yml --ref <branch>.

Start fixing as soon as a failed log shows the cause, but push the fix only after the run for that commit has finished: pull-request runs use cancel-in-progress, so a push cancels the running jobs and can hide a second failure.

Background threads at exit

PromptManager's own background threads stop through one package teardown, _stop_background_work() in __init__.py (#301, #302). It runs once and works against one 10 s deadline. Each step gets the smaller of its own bound and the time left. The steps, in order:

  1. Refuse new previews (refuse_auto_thumbnails()), then detach the monitor's callbacks (Needs review recorder, preview queue, Images listing listener).
  2. ImageMonitor.stop_monitoring works against one 5 s deadline. Closing the image handler joins the image worker; watchdog's observer.stop() and the observer join get what is left, which can be 0 s. stop() joins watchdog's emitters without a limit, so it runs on a daemon thread and is waited for only until the deadline; a later stop waits for that same call (#561).
  3. stop_review_worker stops the Needs review worker (pm-review-recorder, 5 s, #659): it drops the queued and deferred paths (their count is logged; the next scan covers them), refuses every later queue_review_file and joins the thread, which finishes at most the file in hand. It always runs, so an image in hand cannot start the worker afterwards; it is reported as part review only when the worker started.
  4. close_auto_thumbnails(final=True) stops the preview worker (30 s), kills ffmpeg and shuts the interactive image pool down.
  5. shutdown_job_pool (utils/parallel.py) cancels the long-lived job pool's queued items and joins its threads (5 s; part workers, only when a job used the pool, #523).
  6. PromptTracker.shutdown stops the prompt cleanup thread (2 s).

A failing step, or a second Ctrl+C, is logged with its traceback and does not skip the later steps. A clean run logs one INFO line to PromptManager's log: Background work stopped in 0.4 s: monitor=ok thumbnails=ok tracker=ok. If any part is still running, one WARNING goes to the console: Background work not stopped in time (10.0 s): monitor. A Ctrl+C that lands between two steps (each step catches its own) is re-raised after the result is stored, with the parts not reached False, and the atexit callback is removed: the later steps are skipped, no summary line is logged, and a later call returns that result and runs nothing.

The observer is started from a short-lived daemon thread, so every thread it creates is a daemon (a thread inherits that flag from the thread that creates it). watchdog 7 on Windows starts a plain threading.Thread per watch for its ReadDirectoryChangesW reader; created from ComfyUI's main thread it would not be a daemon, and the interpreter waits for every such thread before it runs any atexit callback, so the teardown would never start (#561). tests/test_package_exit.py runs a child whose observer does both (a plain reader thread, a stop() that never returns) and requires its exit.

ComfyUI never runs aiohttp's on_cleanup hooks, because it never calls runner.cleanup(). So atexit is the live host's path. It runs on Ctrl+C (main.py catches KeyboardInterrupt and returns) and on a normal exit. The teardown is registered after the execution history hook, so at exit (newest first) it runs before the history writer's 2 s dispose. It also runs from on_cleanup on hosts that do run it (our test servers) and from the tests' package unload (cleanup_package), and it removes its own atexit callback. Nothing runs when the process is killed: SIGTERM, a ComfyUI-Manager restart through os.execv, a closed Windows console, or ComfyUI Desktop stopping its server. SQLite's WAL journal covers those.

Jobs running at exit (#376): before any atexit callback, Python joins every executor thread (concurrent.futures registers that join with threading._register_atexit). The package registers its own callback there (utils/exit_signal.install, after concurrent.futures, so it runs first): it sets the exit signal and kills the running encoder processes (shutdown_encoders, the ffmpeg that never sees Ctrl+C on Windows). The call in flight then stops at its next safe point: Job.cancelled is True, so every check a job already makes between files stops it, map_parallel starts no further item (ExitRequested), the scan walk stops between folders, LoRA import staging stops before its next sidecar (also for the legacy scan) and a tagging model download stops before its next chunk where huggingface_hub takes tqdm_class (1.x removes its temp file; 0.x hf_hub_download does not take it and finishes the file). Xet transfers ignore that checkpoint, so the hook also calls hub's own abort_xet_session when huggingface_hub is loaded. The trigger-word cache load (small JSON sidecars) has no checkpoint. No check sits inside a library write. That hook is CPython-internal; without it (or when it is refused) install returns False and exit waits for the call in flight, as before. tests/test_exit_cancel.py runs a child process with three such calls running and requires its exit within 15 s.

Stop contract: PromptTracker.shutdown(timeout), ReviewRecordingMixin.stop_review_worker(timeout) (final), ImageGenerationHandler.shutdown(timeout) (restartable), ImageGenerationHandler.close(timeout) (final: schedule() refuses and a sealed run's re-check is dropped) and ImageMonitor.stop_monitoring(timeout) each signal their thread and join it within the bound. They return True only when it ended, and log a warning naming the part when it did not. Called on their own thread, they only signal.

Test rules:

  • Every test that constructs a real PromptTracker, ImageGenerationHandler or ImageMonitor ends with its final stop and an assertion (tests/background_stops.py: close_handler, stop_monitor, stop_tracker). ReviewTestCase.tearDownAsync asserts stop_review_worker before its capture store and folder go. The stop comes before the folder and databases are removed. tearDown runs before addCleanup callbacks, so a class whose tearDown removes files stops the thread there.
  • A test waits for a state through an Event set by the code under test, or by a wrapper around it, with a 30 s ceiling. It never sleeps or polls for that state.
  • A test that asserts "still running" first waits for an entered event inside the held call, then stops with timeout=0.05.
  • A test that asserts a history writer's dispose()/close() is True right after queuing work drains first (drain_writer), or holds the write itself (#370).
  • Patch the module attribute of the code under test (for example utils.prompt_tracker.time, or the package's _clock), or patch with wraps=. Never replace a time or atexit function for the whole process.
  • tests/test_package_exit.py runs a child process that imports the package, leaves the image worker alive and returns. Its atexit reporter checks the teardown's result. This is the interpreter path ComfyUI takes after Ctrl+C, on all three OS.

Performance budgets

A spec performance budget gets two tests:

  • A structural test that always runs, on every OS/Python job and under the coverage tracer. It asserts counts, never time: SELECTs per request, the EXPLAIN QUERY PLAN of the hot query, cache builds on cold and warm requests, and calls of the sort key per cursor page. Example: test_filter_work_is_bounded in tests/test_api_workspace_images.py.
  • A wall-clock test that runs only with PROMPTMANAGER_PERF_BUDGET=1 and without a tracer (sys.gettrace() or a sys.monitoring tool). It skips otherwise. It warms up once, then measures three rounds and asserts the best round's p95; the failure message lists every timing. Example: test_filter_budget (Images filters, spec D12: p95 < 150 ms at 50,000 files and 20,000 links).

A hot SQLite read that returns many rows aggregates them into one step (json_group_array) instead of stepping once per row, so it does not wait for the GIL once per row while ComfyUI generates (#354, get_image_link_matches).

A metadata read never decodes pixels (#523). Pillow's PngImageFile.text loads every pixel to reach text chunks after IDAT; the scan (_extract_comfyui_metadata) and the image monitor (ComfyUIMetadataExtractor.extract_metadata) read PNG text through utils/png_text.py, which runs Pillow's own chunk handlers after the first IDAT and seeks over pixel data. The legacy .text read is the floor: tests/test_png_text.py compares both readers on every image under tests/fixtures, a curated corpus (text after IDAT, zTXt, iTXt, split IDAT, bad checksums, truncations, oversized text, APNG) and a seeded fuzz, and asserts that neither reader decodes pixels by patching ImageFile.load. The only reads that differ are files whose pixel data is undecodable or cut short: legacy found nothing, the walk keeps the text before the pixels. Animated PNGs still use .text.

WebP, AVIF and JPEG keep the same records in EXIF, not in text chunks. ComfyUI's SaveAnimatedWEBP writes prompt:{json} to EXIF tag 0x0110, then workflow:{json} and every other extra_pnginfo key to 0x010F and down; the AVIF writer uses that layout. utils/exif_text.py answers the png_text shape through Pillow's getexif(), and both metadata readers fall back to it when a file has no text chunks. Only a value shaped like a record counts (a key, a colon, then a JSON object, array or string), so camera EXIF stays out. tests/test_exif_text.py writes real still and animated WebP files, AVIF (where Pillow has it) and JPEG in that layout; tests/test_metadata_extraction.py and tests/test_api_core.py hold the two readers to it. No scan, monitor or gallery list collects .avif yet, so AVIF files are read correctly but never reach the readers; #652 tracks AVIF as a media type.

Image work runs on PromptManager's own threads (#523). glibc keeps each thread's malloc arena at its high-water mark, so image buffers spread over the default executor's threads stay resident. Interactive image work (view previews behind their gate, workspace card facts, both inspector routes) runs on the API's fixed pm-image pool (IMAGE_POOL_SIZE 3, _run_image, _map_image; card facts already cached answer without a trip; while the gate's 3 preview writes hold every thread, a card or inspector read waits for one of them, by design of the merged pool; after the package teardown the pool is not recreated and late calls use the default executor). Jobs (scan metadata and file facts, thumbnail and convert jobs, the legacy gallery generation, capture previews) run through map_parallel on one long-lived pm-worker pool of Worker threads, reused between jobs; a new Worker threads value replaces it (the teardown also joins a replaced pool still finishing), and a call made from a job thread runs inline. After a scan, thumbnail or convert job, or the legacy gallery generation, release_free_memory (utils/native_memory.py) calls glibc's malloc_trim(0) once; it does nothing on Windows, macOS and musl and never raises. No allocator setting changes. tests/test_image_pools.py asserts the thread of each read and write and the trim; tests/test_utils_parallel.py the pool's reuse, resize, nesting and shutdown. tools/perf/memory_drive.py (manual, Linux, never in CI) measures RSS, heap, threads and arenas under the #523 load against the disposable browser test server.

The perf budget job in .github/workflows/nightly.yml is the reference measurement: ubuntu-latest, one Python, no coverage, only the wall-clock tests. It runs nightly and on workflow_dispatch, never on pull requests, because shared-runner timing must not block a merge. Dispatch nightly.yml on a branch to measure before merging. Shared Windows runners do not run them; the structural tests cover portability. Run it locally with PROMPTMANAGER_PERF_BUDGET=1 python -m unittest tests.test_api_workspace_images.TestWorkspaceImages.test_filter_budget and quote the printed p95 in the PR body.

A red perf budget run means the code got slower: fix the code (or change the budget in the spec with a reason) in a follow-up PR. Never rerun it to green. It is not a required check: only gate is (.github/branch-protection.json).

Images listing cache (#348)

/prompt_manager/images/output, /prompt_manager/gallery/subfolders and POST /prompt_manager/gallery/rescan read one shared listing per output root (RootListing in py/api/gallery_listing.py, _listing in py/api/images.py). The tests are tests/test_gallery_listing.py (pure helpers) and TestSharedListing in tests/test_api_images.py (routes); they hold a walk open with a gated scan instead of sleeping.

  • Single flight. At most one walk per root runs at a time; every reader that needs that root while it runs waits for it (shielded, so a client that disconnects never cancels it). The walk, the comparison with the previous listing and both folder sets run in the executor (walk_root). A walk that finds the same (path, mtime) list keeps the previous list object, so the favorites lookup and the sort orders are not rebuilt.
  • 30 s background refresh. A listing older than REFRESH_AFTER (30 s) is served at once and one background walk replaces it. Files added or removed by hand therefore show up one open later than before; Rescan shows them at once.
  • Blocking invalidation after deletes. Duplicate cleanup and the legacy duplicate delete still call invalidate_gallery_cache(): the listing is dropped and the next read waits for a walk, so a deleted file is never listed. A walk running during the drop is discarded (the record's generation outlives every drop); a cold reader gives up with a 500 after 3 discarded walks in a row. Thumbnail writes (jobs, conversion, the legacy generate and clear routes) no longer drop the listing: thumbnail URLs are computed per request.
  • Startup warm-up. The root __init__.py registers api.warm_gallery_listings on the host's on_startup, which starts one background walk per root, and api.cleanup_gallery_listings on on_cleanup, which cancels running walks. A warm-up failure never stops startup; the first read retries.
  • Failures and Rescan. walk_root opens the root with os.scandir first, so a deleted or unreadable root fails the walk instead of listing nothing. A failed walk keeps the previous listing, logs one warning per streak of failures and is retried at most once per REFRESH_AFTER; a reader with no listing gets a 500. Rescan waits for a walk that started after the click (by walk number, not by clock), Rescans clicked during one walk share the next, and a failed walk is a 500 even when a previous listing exists.
  • New outputs (added without a walk, PR 2). The image monitor reports every settled output it accepts (by default .png .jpg .jpeg .webp .gif; videos only when their extension is in monitoring.extensions), linked or not, with its realpath, through set_output_listener. On its worker thread the API's notify_output_settled only does loop.call_soon_threadsafe(output_settled, path), and does nothing before the loop is known or after cleanup_gallery_listings. output_settled matches the path against each walk's resolved_root (normcase(realpath), computed in the executor; root_contains ends the match at a separator and ignores a Windows \\?\ or \\?\UNC\ prefix on either side).
  • The add. A root with a stored listing and no walk running gets the file added without a walk. relative_part slices the path below the root in its own case (Windows compares folded, slices the original); _run_adds places the pending files of one root in one executor batch (_patch_listing): _settled_entry applies the walk's filters (not a symlink or folder by lstat, _name_suffix in MEDIA_EXTENSIONS, no thumbnails folder, at most MAX_SCAN_DEPTH folders, every folder on the way listable by os.access, which on Windows ignores ACLs: a folder whose ACL denies listing is added there and corrected by the next walk). Where names fold case the stored spelling must match first, as the filters compare it: Windows through nt._getfinalpathname (its realpath keeps the given case when it cannot open the file), macOS through F_GETPATH on a non-blocking open (a FIFO never holds the executor); a case-insensitive mount on Linux is not checked and is corrected by the next walk. insert_entry builds a new list with the (Path, mtime) entry where the walk's newest-first sort puts it, replacing the same path's entry. add_folder copies both folder sets. The batch is stored only when no walk started and no drop happened while it ran (a walk started after the report lists the file itself); walked_at is untouched, so the 30 s refresh still walks and corrects any drift, and walk_root keeps the patched list object when that walk finds the same. Tests compare every added listing with a real walk (_walked).
  • When it walks instead. The root is marked dirty (mark_root_dirty, _mark_dirty) when the add cannot be exact: a walk is running (it may have passed the folder: the trailing walk), the path cannot be sliced, the lstat or the spelling read fails, the stored spelling differs, another file has the same mtime (a walk orders those by its visit order), the listing is at MAX_GALLERY_FILES, or the batch raised. A file the walk's filters exclude is neither added nor walked. A root without a listing, or a dropped one, is walked by its next read. A dirty root gets one background walk, no sooner than rewalk_interval = min(15, max(5, 5 × last walk's duration)) seconds after the previous walk started. _schedule_walk never arms a timer while a walk runs (the walk's end re-checks dirty: the trailing walk), arms at most one per root and never sooner than 0.5 s, and keeps the earlier deadline when the stale refresh and a dirty root both want one; every walk start (read, Rescan, warm-up or timer) cancels it and forgets the pending adds. A failed walk clears dirty; a cancelled walk starts no trailing walk. When the output roots change (reset_gallery_roots_cache) every record is retired: its timer is cancelled and no add, mark, timer or trailing walk touches it until a reader or the warm-up asks for that root again (the monitor keeps watching a removed root until restart). Tests patch REWALK_FLOOR/REWALK_CAP and run the pending timer's callback by hand (_fire) instead of waiting for it, and hold an add batch in the executor (_hold_adds) to race it with a walk, a drop or the cleanup.
  • Workspace caches after an add. A patched listing shares every unchanged entry object with the one before it, so listing_delta finds the change by identity (a walk builds new tuples and is rebuilt in full, as is any change of more than MAX_DELTA entries). The per-file values build only the added files (_workspace_listed_step), the newest order places them by bisection (_newest_step, only when the per-file cache still holds exactly the values this call built: a page read and the warm build run in executor threads at once, and an order labelled with older values than it holds would add a file twice), the favorites lookup is copied and extended (_favorite_listing_step, rebuilt when a key collides), and the other orders, wanted paths and locators rebuild lazily. On a synthetic 20,000-file listing a one-file add costs about 3 ms in the executor and 15 ms for the warm build, against about 155 ms + 80 ms for a walk and a full build (test_a_warm_build_after_an_add_builds_only_the_added_values counts the values built and the sort keys read).
  • Measuring it. tools/vendor/perf/images_load_probe.mjs is a maintainer tool, never run in CI. After npm ci --prefix tools/vendor and npx --prefix tools/vendor playwright install chromium, run node tools/vendor/perf/images_load_probe.mjs http://127.0.0.1:8188 against a running ComfyUI. It prints the time to the first decoded thumbnail, the time to network idle and the 10 slowest requests, from a fresh browser context each run.

Open pages across restarts and source changes (#430)

A page addresses a listed file as {root_index, root_scope, path}. The root scope is an HMAC over the root's index and canonical path, so the server refuses (409 source-changed) an action aimed at a root that was renumbered or replaced since the page listed it (a same-named ComfyUI_00001_.png sits in every output folder). Its key, and the listing cursors' key, derive from one random secret in workspace-scope.key beside the database (utils/workspace_keys.py; owner-only, 64 hex characters; never in config.json or the database, so no backup or export carries it; Move library copies it, best effort). A ComfyUI restart therefore keeps every scope and cursor an open page holds: tests/test_api_workspace_restart.py proves it with a second API on its own server and with two fresh interpreters on the same database. The key file is created with a temp file and os.link (of two first starts one file wins; without hard links O_EXCL), re-read after any write, replaced with a WARNING when corrupt, and a folder that cannot hold it gives that process a per-process key (one WARNING; open pages then refresh after a restart). Tests never write it outside their own temp folders.

The cursor is {"v": 2, "key"} with the listing scope (it hashes every absolute root) bound into its MAC only, never sent. Bump v whenever the key tuple's shape changes: a cursor now outlives a restart and an upgrade. A cursor the server cannot verify (another key, root list or filter set) answers 400 cursor-stale; Images then shows "The image collection changed. Refresh image collection to continue." and its Retry becomes Refresh image collection.

When a source really changed, POST /prompt_manager/images/rescope ({"target": {...}}, validated by media_target, index ≤ 4095) maps the held target to the first current root whose scope at the old index equals the held scope, and answers the file's current workspace descriptor; a removed or replaced root, another key or a foreign scope is 409 source-changed, a missing file 404 file-missing, a path leaving the root or a preview 403 (always no-store). Only the Images roots are mapped. Images (images-source-recovery.mjs) asks once per held (key, scope) pair, shared by the inspector (an inspection that turns refreshRequired with code: "source-changed"), the viewer (a media load error) and the Tag image dialog. Found under another index, nothing is kept by an old key (root_index:path could name another source's file): the viewer closes, the checks clear, a Source filter on the old index follows the file (another one falls back to All sources), only that file stays selected and the collection lists again; a manual Refresh forgets every pair. Not found, the existing visible Refresh stays. Browser tests: workspace-stale-source.spec.mjs (/__test__/sources/reverse and /__test__/scope-key/rotate, both undone by every reset); the manual-Refresh recovery specs in workspace-images.spec.mjs answer every rescope 409.

Registry package

comfy node publish zips the tracked files minus .comfyignore, so a new development file or folder at the root ships until it is listed there. tests/test_package_contents.py keeps each rule anchored to the root, checks that development paths are left out and that nothing ComfyUI needs at run time is. Git clones are unaffected.

Windows portability preflight

Before changing paths, SQLite, streams, restore or cleanup:

  • Follow the boundary's existing native canonical/identity contract; Path.resolve() alone does not fold Windows case. Keep lexical aliases distinct from resolved targets. Cover mixed case, drive and UNC spellings, plus foreign-namespace denial with an allowed native control. See Python's normcase documentation.
  • Close every owned database/model connection, worker and stream handle before unlink or TemporaryDirectory.cleanup(). Await worker/stream retirement. A SQLite with conn manages transactions, not connection closure, and addCleanup runs after teardown; use explicit finally cleanup when teardown removes files first.
  • Windows can reject unlink of an open file; Unix can remove its directory entry while the handle remains usable. Preserve the shared behavior assertions and exercise the actual native branch, then prove handle release and successful cleanup. Do not hide failures with blanket skips or retries. See Python's remove/unlink semantics.
  • Concurrent SQLite tests must not depend on how fast the host commits. Managed connections use WAL with synchronous=NORMAL (see configure_connection) so commits do not hold the write lock across a flush. Make real overlap deterministic (for example hold the first writer open with FirstWriterHold) and give peers that must all succeed the ordinary busy timeout; cross-thread handoffs wait on events with generous ceilings, never a short wall clock (#242).
  • Run native Windows CI early for these changes. Pull requests run only Linux, so start Windows on the branch with gh workflow run nightly.yml --ref <branch> (a branch run files no issues). Include a Windows impact and evidence note in the PR. All three Windows legs in that run, every Linux leg and every applicable exact-head check must pass before merge. Portable ntpath/PureWindowsPath controls do not establish native filesystem, locking or cleanup success.

The gate and the nightly run

A change is tested once, on its pull request (#666). There is no merge queue and a push to main runs no test. Three workflows:

Workflow Runs on Jobs
ci.yml (the gate) pull_request, workflow_dispatch change class; python 3.12 with coverage (85%) (the suite, once, under coverage); black and flake8; bandit (high severity); frontend modules (tests/js); tooling tests and pins (tests/vendor, vendor pins); frontend coverage (shard N/4) and frontend coverage (merge) (desktop Chromium page workflows with the per-file floors); package contents (a release only); gate
nightly.yml 03:17 UTC, workflow_dispatch page workflows (firefox|webkit|touch, shard N/3); py3.13/py3.14 on ubuntu-latest; py3.12-3.14 on windows-latest; native trash on a real mount; real ComfyUI compatibility; perf budget; report by issue
publish.yml push to main that changes pyproject.toml, workflow_dispatch publishes to the Registry when the version is new

gate is the only required check. It needs every other job of ci.yml and passes only when the classifier succeeded and each job did what the change class asks (below): the class's jobs succeeded and every other job was skipped. A failed, cancelled or wrongly skipped job fails it, and so does a class the classifier does not print. Because branch protection names only gate, adding or renaming a job never strands a pull request. Protection is strict: the branch must be up to date with main, so the commit the gate tested is the commit that merges. When main moved, press "Update branch" and the gate runs once more.

Only desktop Chromium blocks a merge (maintainer, 2026-11-21). Firefox, WebKit and the phone-size touch project are not first-class; with Python 3.13/3.14, Windows, the real mount, real ComfyUI and the wall-clock budget they run nightly on main. macOS is not tested in CI (maintainer, 2026-10-31, #571); its code stays and support is best-effort. The cost: a break only those can see is found the next morning, not before the merge. To see it before merging a risky change, run gh workflow run nightly.yml --ref <branch>.

Nightly reports by issue

Nothing waits for the nightly run, so it reports by issue (tools/ci/nightly_report.py, the report by issue job, the only job in CI with a write permission: issues: write). For each job of the run:

  • a failed or timed-out leg opens nightly: <job> failing, or comments on the open issue with that exact title, naming the run, the commit and the failed legs;
  • every leg green closes that issue with a comment naming the run;
  • a cancelled or skipped job changes nothing.

Shards of one browser are one job (nightly: page workflows (webkit) failing). Only a run of main reports; a manual run of a branch files nothing. A red nightly job is a failure like any other: read the log, fix the cause. It blocks no merge, and it is never rerun to green.

Flaky tests and quarantine

  • No retries in the gate. A retry hides a race. A gate test passes or fails on its one attempt (retries: 0 in both Playwright configs).

  • No rerun-to-green. A red job is read and fixed at its cause. The one exception is unchanged: a pure timeout with every test passing may be rerun.

  • A gate test that fails without a code cause is fixed or quarantined the same day. Open an issue, then tag the test with that issue, in exactly this spelling (tests/vendor/flake-policy.test.mjs checks it):

    test('closing the viewer never blocks the page', { tag: '@quarantine', annotation: { type: 'issue', description: '#613' } }, async ({ page }) => {
    

    The gate's page run passes --grep-invert @quarantine (tools/vendor/frontend-coverage.mjs), so the test no longer blocks a merge; the nightly run still runs it in Firefox, WebKit and touch. To run it in Chromium while fixing it: npm run --prefix tools/vendor test:workflows -- --project chromium --grep @quarantine. Remove the tag in the PR that fixes the test and closes the issue. A quarantined test adds no coverage, so a floor that depended on it fails the merge job: that is the signal to fix the test rather than leave it.

  • Nightly retries once (--retries 1). A test that fails and then passes does not turn its job red; tools/vendor/flaky-tests-reporter.mjs lists it in the job summary under "Flaky tests". Treat a test listed there twice as a bug to fix.

Nothing is quarantined today. Measured at the switch (the last 100 pull-request runs of the frontend workflow, 2026-10-31 to 2026-11-21): 9 failed. Six were caused by the pull request's own change (three coverage floors, a tooling test, a new test that failed in touch, a Playwright bump), one by a re-pushed image tag (fixed by the digest pin, #609), and two by Chromium tests that failed without a cause in the pull request; both were fixed at their cause (a production race, #611, and a spec that read a status before its save answered, #631).

Only changes that can affect code are tested (#639)

The table above is for a code change. ci.yml starts with a change class job that runs tools/ci/change_class.py over the files the pull request touches, and every other job runs for one class only:

Class Files What runs
inert Only .github/FUNDING.yml, SECURITY.md, images/, .github/ISSUE_TEMPLATE/ change class and gate: green in seconds.
docs Only README.md, README-legacy.md, assets/readme/, assets/brand/ (may include inert files) change class and gate: green in seconds.
release pyproject.toml alone, and in it only the version = "..." line rewritten The above and package contents (tests/test_package_contents.py).
code Anything else The whole gate.

A file on no list is code, and so is every case of doubt: no changed files, a manual run, a range git cannot read, a pyproject.toml change that is more than the version line. docs/ is code, because the browser suite compares production against docs/concepts/workspace/; TESTING.md is code, because the tooling tests read its tables; a test-only change is code. Before adding a file to a list, check that no shipped code opens it.

Two Python tests read the docs files (tests/test_brand_assets.py, tests/test_package_contents.py). CI no longer runs them for a docs change (maintainer, 2026-11-21: documentation and image changes run no tests), so a README or brand-asset edit that breaks one is caught by the pre-push hook, or else by the next code change's gate. Run python -m unittest tests.test_brand_assets tests.test_package_contents after editing those files.

The pre-push hook uses the same script: it skips the Python suite when the pushed commits are inert and runs it otherwise.

Required merge checks

.github/branch-protection.json records the required checks: the one context gate, with strict (the branch must be up to date with main). It reports on every pull request, whatever the change class. The same set lives in two places, and both must change together: the main ruleset (25960526) and the classic branch protection on main, which the manifest mirrors. GitHub requires the union of the two, so a context left in either one blocks every PR that does not report it. The ruleset has no merge_queue rule (#666). Merging is the squash button. It does not require an additional human approval.

A repository administrator applies the configuration, then verifies it:

gh api repos/ComfyAssets/ComfyUI_PromptManager/rulesets/25960526 \
  | jq '.rules[] | select(.type == "required_status_checks") | .parameters'

A PUT replaces the whole rules array, so edit the current ruleset in place. Keep the deletion and non_fast_forward rules, and give the context integration_id 15368 (GitHub Actions), so no other integration can post the required check. Save the current ruleset first; it is the rollback:

gh api repos/ComfyAssets/ComfyUI_PromptManager/rulesets/25960526 > ruleset-before.json
jq '{name, target, enforcement, conditions, bypass_actors, rules: [.rules[]
     | select(.type != "merge_queue")
     | if .type == "required_status_checks"
       then .parameters.required_status_checks = [{context: "gate", integration_id: 15368}]
          | .parameters.strict_required_status_checks_policy = true
       else . end]}' ruleset-before.json > ruleset-new.json
gh api --method PUT repos/ComfyAssets/ComfyUI_PromptManager/rulesets/25960526 --input ruleset-new.json

Then apply the manifest to the classic protection and read both back:

gh api --method PUT repos/ComfyAssets/ComfyUI_PromptManager/branches/main/protection \
  --input .github/branch-protection.json
gh api repos/ComfyAssets/ComfyUI_PromptManager/branches/main/protection/required_status_checks
gh api repos/ComfyAssets/ComfyUI_PromptManager/rules/branches/main

Update the manifest whenever the required context changes. Keep ci.yml free of path filters so the required check is never silently skipped.

Unified workspace

The opt-in /prompt_manager/workspace page opens the native Images workspace. Overview retains real /prompt_manager/stats counts. Both use the shipped toolkit. Existing admin, gallery and metadata URLs remain available while replacement workspaces are developed. Browser smoke tests in tests/browser/workspace.spec.mjs cover navigation/history, keyboard skip links, mobile layout, theme persistence/fallback, loading/retry and stale responses. The Images cases in tests/browser/workspace-images.spec.mjs additionally cover server-side filters, cursor append/retry, Grid/List/Masonry, bounded DOM, keyboard navigation, restored browsing context, Viewer.js cleanup and actual video playback. tests/test_api_workspace_images.py checks signed cursors, source identities, legacy compatibility and header-only dimensions. Frontend stream/layout units cover cancellation, malformed responses and bounded visibility lookup. These run automatically in the existing four-browser-project workflow and frontend coverage job. tests/comfyui/workspace.spec.mjs verifies the page against the managed host with both renderer startup configurations.

The shared inline and collection inspector reads the current rooted file's supported embedded records, exact generation facts and recorded or inferred prompt evidence. It renders in two concept surfaces (#249 D20–D22, D38). The Images side panel shows only the concept content: cover, title, filename, the evidence badge with a category chip naming its origin (D146), the + and − prompt blocks with copy and send, the tag chips in labelled sections after the negative prompt (D154: "Image tags · N" for the file's own image tags, D88, then "Prompt tags · N" or "Recipe tags · N" for the linked tags; image tags and the linked positive's own tags filter Images, D21), the six facts, and a footer with "Send to ComfyUI" and "Prompt history" only when prompt roles resolved or a link is saved; the sticky panel scrolls inside the window. The viewer's details (#viewer-details) repeat that content without the cover, then "File & provenance" (the honest file facts, the Prompt evidence line, Download original and, for a listed file, D38's "Show in folder" after the Path) and "Workflow & raw metadata" (raw records and their two downloads), then the pair send and Prompt history buttons. D22 words an empty positive explicitly and makes confirmed prompt text focusable. tests/browser/inspector-concept.spec.mjs compares both surfaces with the concept (see the D20–D39 notes under Images). tests/browser/full-inspector.spec.mjs covers original/metadata/workflow downloads, response limits, source changes, nested sending, matched dark/light and mobile geometry, and the loaded-collection viewer. viewer matches the concept shell and toolbar order measures the concept's #viewer-dialog shell, header copy, toolbar order and frame geometry in the concept and in production at 1600 and 390 pixels; its #249 D34 mapping keeps production's Download link, the appended position and reason lines, coarse 40px targets and the toolbar inside .viewer-left (Viewer.js's own .viewer-toolbar rule lifts the concept's across the dialog). The viewer never fetches another page or preloads all originals. Its explicit slideshow waits 3.5 seconds after image readiness, pauses at native video without advancing on ended, and resumes on a manually selected image only while prior intent remains. Pause/Stop, inspector reading/copy/download/send, hidden document, media failure, close, query/route disposal and pagehide cancel that intent; returning visibility or closing the sender does not resume it. Stop leaves native video playback alone. Video uses only the existing normalized gallerySettings autoplay/mute/loop values, read without writes; denied/malformed storage falls back to autoplay off, mute on and loop on. Rejected autoplay keeps native controls usable.

The inspector does not establish historical file identity, infer run membership, edit image tags, export all EXIF, or load/execute a workflow. Saved vocabulary is labelled by its recipe or positive-prompt scope. Limited raw evidence is omitted atomically, with JSON exports unavailable and the rooted original still downloadable. The inspection API uses one bounded read with per-record budgets: role records (prompt, parameters, the pair execution record) share 2 MiB and exceeding it fails the read; the workflow record has its own 4 MiB and past it only the workflow becomes record format limited (no raw text, graph limited, roles and facts unaffected); other text chunks are skipped unread; byte-identical duplicates are accepted within a bounded read budget, while differing duplicates (and any duplicate role record over that budget) still fail. Other read bounds are unchanged: 8 MiB non-PNG header, 10,000 PNG chunks and a three-second ffprobe (per probe, at most two probes). Video containers are read through one shared carrier selector (utils/video_metadata.select_video_carrier, used by the inspector and by the admin scan): carriers are, in order, the per-key tags that current savers write (prompt, workflow, parameters, comfyassets_prompt_pairs, each original-text; Matroska upper-cased names fold on our side), then the old VideoHelperSuite comment JSON envelope, then description (object values are reserialized-json; envelope keys are matched exactly, as the legacy readers did, never folded). The first carrier holding a role key wins, otherwise the first holding a workflow, and carriers never merge. Two per-key tags folding to one key are a duplicate record: byte-identical ones are one record, differing ones fail the read. ffprobe is asked for exactly those six tags. Its JSON output escapes tag text (at most doubling it), so the stdout bounds are sized so that only the decoded per-record budgets above can fail or limit a record, and a video reads exactly as the identical PNG: the first probe allows twice the role and workflow budgets plus 64 KiB of envelope (12 MiB + 64 KiB); past that the inspector probes once more without the workflow tag within twice the role budget plus 64 KiB (4 MiB + 64 KiB) and the per-key workflow becomes limited, while an envelope over that bound still fails the read because it cannot be split. The admin scan reads the same carrier with the default resolver profile, so a per-key video links like the same graph in a PNG; the live monitor processes images only (unchanged, see the follow-up below) (tests/test_utils_video_metadata.py, tests/test_api_admin.py TestScanReadsVideos, tests/test_api_prompt_inspector.py test_video_*, tests/test_inspection_response.py TestVideoProbeBoundsMatchPngBudgets; the real-container round trips skip without ffmpeg). Resolution under INSPECTION_PROFILE bounds work, not graph size: 2,000 visits per candidate chain, 20,000 in total, 64 link/JSON-container levels, 100,000 resolved characters, and a two 20,000-node ceilings: one over the top-level entries of the API prompt, and one over the workflow graph's UI nodes plus subgraph-definition nodes (past it the workflow graph and its facts become limited). The serialized response stays under 8 MiB by omitting, in order, the workflow graph, then the prompt graph, then all raw records atomically. Retry does not raise these limits. Ingestion (scan, live monitor, admin import) and queue-time run counting keep the default profile, including its 500-node gate. Only INSPECTION_PROFILE reads the node semantics table web/js/inspection-semantics.json (at most 1 MiB and eight nesting levels, loaded on first use). With it, SamplerCustomAdvanced follows its guider link (through Reroutes) to CFGGuider (positive and negative) or BasicGuider (positive only; the negative is absent, "Guider has no negative input"). Any other guider, such as DualCFGGuider, is unsupported-node. Conditioning is traced through the table's pass-throughs (FluxGuidance, ReferenceLatent, the ConditioningSet* nodes, ControlNet apply nodes, InpaintModelConditioning and WanImageToVideo by output slot). ConditioningZeroOut is an explicit empty text with source zeroed-conditioning. easy ifElse with a literal boolean follows that branch only; with a linked boolean both branches are traced, equal texts resolve and different texts make the sampler ambiguous with one candidate per choice (at most 32, else work-limit). A value is proven (#657, rgthree's Any Switch (rgthree), strategy first-present, which outputs its first input that is not None) only by a literal or a traced path whose every node is a PromptManager node, a class the resolver handles in code (Reroute, StringConcatenate, Text Concatenate, the default string adapters) or an entry of the table's encoders, strings, conditioning or composites (PROVEN_VALUE_CATEGORIES). That allowlist is a rule for every future table entry: a class that can return None (a selector, an unknown node, a runtime, facts or lineage class) never goes into those four categories, and a test pins them. Both resolvers read the constant (Semantics.proves_value; the browser's copy in local-resolver-support.mjs), and tests/test_proven_value_parity.py fails when the browser copy drifts from it (#662). Otherwise the switch offers one candidate per distinct outcome of its inputs, and no PromptManager path is preferred. When a sampler is ambiguous, Inspect still shows a role every candidate resolves alike (same text, recipe and left-out parts) as resolved (#658); resolution.state stays ambiguous, so pair actions and ingestion are unchanged. ConditioningCombine/Concat/Average resolve only when every part has the same text, otherwise unresolved with composite naming the node (but see the added-conditioning floor below for a later stage). Results that depend on a forced choice are never memoized. A FaceDetailer (detailer-stage) is a sampler stage: the samplers reached through its image ancestry are compared with it. Equal texts resolve with the detailer as the sampler; different texts are ambiguous with multistage-differs and one candidate per stage; an unreadable stage makes the chain unresolved. Unanchored, a sampler whose output only feeds detailers (or previews) is not a candidate of its own. A sampler's latent ancestry is walked through every link input of non-sampler nodes within the same visit and depth budgets: with no earlier sampler it is a single stage whatever the origin (VAEEncode, EmptyLatentBatch, EmptyFlux2LatentImage, EmptyHunyuanLatentVideo, SetLatentNoiseMask, InpaintModelConditioning or WanImageToVideo slot 2). Pass-through lineage (#304 follow-up, maintainer option B, 2026-10-23): the table's lineage section lists the outputs whose image or latent continues one input's (VAEDecode/VAEDecodeTiled samples, VAEEncode/ VAEEncodeTiled pixels, ImageUpscaleWithModel, ImageScale, ImageScaleBy, ImageScaleToTotalPixels image, LatentUpscale/LatentUpscaleBy samples, cg-image-filter Image Filter slot 0 images and slot 1 latents; a selection of the same batch), plus Reroutes. Lineage describes no prompt, so its classes are not claimed by a prompt category. When the latent walk finds exactly one earlier sampler and the latent descends from that sampler's output slot 0 only through lineage nodes (a hires-fix or refiner chain, img2img from an in-graph decode, a direct latent link), the two stages are compared like a detailer and its upstream stage: equal role texts resolve with the later sampler named, different texts are ambiguous multistage-differs with one candidate per stage, and an unreadable earlier stage makes the chain unresolved with that stage's reason. Unanchored, the earlier sampler is judged inside the chain when its output reaches no other file output. A size or resolution node reading the same image beside the lineage (a ResolutionCalculator feeding ImageScale width and height) is allowed, since the walk then still finds only that sampler. Any other earlier sampler, or one reached only through an unlisted image node, stays unresolved "Multistage sampler ancestry is ambiguous". Added-conditioning floor: a later stage whose own positive fails only as composite keeps its earlier stages' shared pair ("A later stage adds conditioning to the base prompt", naming the earlier stage's sampler) when that positive reaches, through Reroutes and conditioning pass-throughs, a composite the table marks additive (ConditioningCombine, ConditioningConcat; never ConditioningAverage, which can weight a part away), one of its parts is exactly the earlier stages' positive text, and its negative text equals theirs. This is the three-stage Flux run whose UltimateSDUpscale combines the PromptManager prompt with a style-trigger encoder: legacy linked the PromptManager text and every stage is conditioned on it. The positive is always labelled (maintainer ruling): its source is added-conditioning (D126; with a D125 omission too, runtime-parts-omitted-and-added-conditioning) and its provenance names the composite (added_by), whatever the added text is; no length heuristic. A combine without the base text, a different negative, or different earlier stages stay as they were (composite or multistage-differs). An image-edit batch (several samplers with distinct prompts, one shared saver prefix) stays ambiguous, and text generated at run time stays untraceable (tests/test_resolver_pass_through.py on synthetic shapes from tests/passthrough_graphs.py; the browser port is compared on the named select-* chain cases and passthrough_fuzz_cases). Ingestion keeps the default profile's historical latent rule (D1), so the admin scan still reaches these files through its legacy-parser fallback. Run-time PromptManager parts (maintainer option A, 2026-10-23): LoraManager's TriggerWord Toggle is a runtime class (its output is the LoRA's trigger words as filtered at run time). A PromptManager (or PromptManagerPair) prepend_text or append_text linked directly to a runtime node is left out: the text is the node's own, combined with any other literal or traced part exactly as before, the side's source is runtime-parts-omitted, and a resolved pair's reason is "Text added at run time, such as trigger words, is not included". The prompt block shows that line under the text (D125; the evidence badge stays "Workflow inferred"). The label follows the text through encoders, concatenations and chained PromptManagers: a side is labelled when any node on its traced path left a part out, and its provenance lists those PromptManager nodes (omitted_parts). Comparisons include what a text leaves out, so a prompt that left out a part never equals a complete one (a branch with the toggle and one without stay ambiguous; such stages are multistage-differs). Only classes in the table's runtime list are left out, never another runtime-value source (a JoinStringMulti with a linked list flag stays runtime-value). The toggle's output is never computed. A run-time node further upstream (inside a concatenation), a run-time main text, or an unknown feeder keep their outcome (runtime-value or unsupported-node). This is what legacy linked for the June hires-fix runs (TestRunTimePromptManagerParts, the select-runtime-* parity cases); an unlisted node with sampler-shaped inputs (positive, negative, guider, latent_image, a pipe, video embeds, custom-sampler parts, or a model link together with conditioning, neg_conditioning, samples or latent) is unsupported-node naming it, here and in a detailer's image ancestry; a latent that is not a link or reaches its own sampler is malformed; running out of budget is work-limit or depth-limit, never single stage. Each sampler's walk runs once per resolution; selector branch runs share it and other candidates are charged its visit cost. A UI workflow node whose type is a list or an object (read only for the overwritten PromptManager check) is skipped like a non-object node, since it can be neither a subgraph instance nor a PromptManager node, so a prompt that resolves still resolves and the other nodes still feed the check; a list or object class_type is never a preview output. Before #286 both raised and the inspect route answered 500 (test_unhashable_* in tests/test_api_prompt_inspector.py, the workflow-type-* golden cases on both sides). Text encoders: single encoders (the Qwen image encoders, TextEncodeQwenImage21 slot 0 prompt and slot 1 negative_prompt, KikoTextEncode) read one string input unchanged. parts-equal encoders (CLIPTextEncodeSDXL, Flux, SD3) resolve when every part is identical or exactly one part is non-empty (exact "", whitespace is text); otherwise composite. String sources reproduce the pinned KJNodes code from literal settings only: StringConstant is its string; StringConstantMultiline with a literal true strip_newlines is replace("\n", "").strip(); JoinStringMulti keeps string_1 (even empty), appends string_2..string_N (N = inputcount) after the literal delimiter unless missing or exactly "", and ignores later inputs. A linked setting is unsupported-node; a list output (return_list true or linked) and PromptSearchList are runtime-value ("Text is decided at run time"), never one list item. Every intermediate text is length-checked and charged to the scanned-character budget. If the table cannot be loaded, graph inspection is unresolved ("Inspection node semantics are unavailable") and ingestion is unaffected, because it never imports the table. Unknown nodes pass through (#381, maintainer-approved 2026-10-27; no per-node inventory): an output whose class the table, its facts, lineage and the code's adapters never name is read through, not refused. A text input is its text (the legacy encoder rule, so RegexReplace or LoRAfromText show their input text), except that a string output of a node with a seed input (seed, noise_seed, sampling_mode.seed) and no linked conditioning/positive/negative input is generated at run time (a language model such as TextGenerate, a wildcard): runtime-value naming it. Else, at output slot 0 or 1 of a node with a positive or negative input, only positive (slot 1, negative) is followed, nothing when it is not linked; else a linked conditioning alone; else every linked input except the table's pass_through.skip_inputs (core type inputs: model, clip, vae, image, latent, ...), each traced with kind any. A followed input with no text adds nothing; limits and selector choices propagate; another failure (runtime-value, composite, malformed) blocks, unless a PromptManager node was reached: this repository's own nodes are authoritative, and then only their texts count. One distinct text resolves; several make the sampler ambiguous "Several prompts reach the sampler" with one candidate per distinct outcome, in input order (at most 32, else work-limit). A PromptManagerPair's execution record is what ran: while its inputs are checked against it, a walk through an unknown node that fails, diverges or passes text through is unverifiable and never overrides the record. No text at all is unsupported-node naming the outermost unknown node. An unlisted output of a listed class (a sampler, a loader, a lineage node) stays unsupported-node, so the walk never reads another stage's prompt. INSPECTION_RESOLVER_VERSION is 2 for this rule; ingestion keeps the default profile (RESOLVER_VERSION 1). The legacy parity gate (tests/test_legacy_parity_gate.py) records, per corpus (the generation-params vectors, the inspection parity fixtures, the local resolver golden and selection cases, the unknown-node shapes in tests/unknown_node_graphs.py), every graph whose inspection positive equals the legacy parser's; a graph may join that list (python3 -m tests.test_legacy_parity_gate --write), never leave it. A graph may read differently from legacy only when LEGACY_WRONG there states why (legacy's first-sampler pick on a branch the file name identifies). Saver anchoring (#381): an inspected file's name (path.name on the server, the chosen file's name locally) anchors an unanchored inspection on the one node whose filename_prefix (literal, or traced as a string) has a last path part that makes the file's stem <prefix>_<digits> with an optional trailing _. That node's linked inputs are walked like a detailer's image ancestry, through any image node, and the listed samplers found are the candidates. No match, several matches, a walk that fails or no sampler found means no anchor: nothing is guessed and the file stays "several possible prompts". Ingestion ignores file names. Shared-conditioning stages: in a sampler's latent walk, an earlier sampler reading the very same conditioning links (positive and negative, or a guider; compared by node ID text and slot) is the same prompt, not an unattributed stage, when it is a plain first stage: not a detailer, no prompt override set, and no listed sampler in its own latent ancestry (else it stays unattributed) (tests/test_resolver_saver_anchor.py, shapes in tests/saver_anchor_graphs.py from the maintainer's gpu_unlock_bench, dataset and ANIMA runs; browser parity through the anchor-* cases, which carry __file_name). Recorded run history (#386): both inspect routes (Images and a history occurrence) ask database.run_attribution.recorded_output inside the file's stat window. It answers only for a file that exactly one recorded run reported and that was written during that run (the #342 rules): the one output node that run reported it from (none when several did) and, per sampler anchor, the effective texts PromptManager recorded at execution (a role only inferred from the graph is none). Only when the file alone leaves the prompt open (ambiguous or unresolved) the inspector resolves again anchored on that node (recorded_saver_id, walked like a file-name match; a file name naming a different saver contradicts history and anchors nothing), and keeps that result only when history's saver chose its samplers (recorded_anchor) and it names the positive (resolved, or a guider with no negative); its graph-inferred sides read recorded-run ("Recorded run" badge, ranked below every "Workflow inferred" source). Still open at the one sampler that saver leads to, with that sampler's positive text recorded (a language model's output feeding PromptManager), the recorded texts show as execution. Outputs and texts are read in one transaction. A result the file resolves alone never changes; a lookup failure is logged and judges the file alone; local Inspect and ingestion are unchanged (tests/test_recorded_saver_anchor.py, tests/test_run_attribution.py, tests/test_api_history_outputs.py).

tools/inspection_corpus.py --root DIR --out JSONL [--workers N] [--baseline JSONL] [--summary TXT] [--code TREE] measures a media folder read-only against the #240 invariants H1 to H8. It runs the inspection route pipeline and the workspace JS facts of --code (default: its own tree), opens media only for reading, follows no symlinks, imports no database, and refuses --out/--summary inside the root or a code tree. Its rows hold statuses, sizes, timings and SHA-256 digests of resolved role texts, never file names or prompt text unless --with-paths is given; digests of short prompts can still be guessed, so the JSONL stays local and only the aggregate summary goes into a PR body. Run it on the base commit first and pass that JSONL as --baseline for H1 and H8 (2x the baseline p99, never below 50 ms). It exits 1 when an invariant fails, including the harness line: a tool exception or facts that were not computed (no Node.js) fail the run. Unreadable or unsupported files are inspector outcomes, not harness errors. Never point it at a live install's folders from an automated job. Installing the Python inspection/source-scope changes requires a maintainer ComfyUI restart. Automated tests use disposable hosts and never restart the running personal ComfyUI.

Run the focused page checks with:

npm run --prefix tools/vendor test:workflows -- workspace.spec.mjs workspace-images.spec.mjs
node --test tests/js/workspace-*.test.js

Use the disposable fixture and managed-host prerequisites above. A maintainer live check needs a ComfyUI restart after adding the Python route, then opening /prompt_manager/workspace; the mockup preview server is a separate design tool.

Concept shell and comparison method (#249)

CSS base and drift check. web/js/workspace/concept.css is a byte-identical copy of the approved concept's docs/concepts/workspace/style.css. Never edit the copy; it is only rewritten from the concept with npm run --prefix tools/vendor sync:concept. npm run --prefix tools/vendor check runs sync-concept-css.mjs --check, which fails on a missing copy or names the first differing byte. workspace.html loads, in order, the toolkit controls, Viewer.js, concept.css and the production overlay workspace.css last; every page stylesheet that waited for its page PR is retired. tests/vendor/concept-css.test.mjs asserts that order, the drift check, and that no other page or canvas script loads workspace CSS.

Overlay decision-marker lint. lintOverlay in tools/vendor/sync-concept-css.mjs fails any workspace.css rule whose selector is also a concept selector unless the rule carries a /* D<n> */ comment, before its selector or inside its block. The D-number must be one of this spec's (#249): a comment that cites any other issue, such as D5 (#245), is that issue's ruling and is not a marker, so write #245 decision 5 for those. The lint test fails if workspace.css is missing. The match is by exact selector, so a narrower selector over a concept rule (for example .ca-tools dialog.prompt-sender) passes the lint; by convention such rules carry a marker too.

PR D deleted images.css and inspector.css, and PR F-b deleted library.css, the last page stylesheet (test the retired shell, vocabulary, editor, Images, inspector and library stylesheets stay deleted). the overlay keeps no retired Images page or inspector rules keeps the replaced card, filter, toolbar, preview, facts and inspector rules out, and the overlay keeps no rule waiting for a page rebuild keeps out the interim guards and the history page's private role colors. Every rule that stayed has a live consumer and a marker: the Library rows windowed (D3) and the shelf's states (D40), the history panel's wrap, archived-lane and coarse-target rules (D45), and under D48 the production surfaces the concept never shows, drawn in the concept's tokens (--green, --red, --ca-*): recorded executions and the Recorded run dialog (#209, D26), pre.prompt-text for stored text in the frozen field provenance and the Archive negative confirmation, whose section.prompt-block (#235) keeps its rules too, and the acknowledged prompt sender (spec §2.2). Rules that repeated the concept (the .library-grid tracks and breakpoints, the history .row-actions flex row and button size, summary cursors, h2 margins, the sender and Recorded run dialogs' colors and border) or had no effect (min-inline-size on block children, a .recorded-run-dialog pre limit, a 700px padding that a later rule overrode) were deleted; the workspace browser specs on Chromium and the concept specs on touch prove the pages unchanged.

Comparison method. Production must equal the concept except for the recorded deviations in the #249 design (spec §8, D-numbers). It is never compared against blessed production screenshots.

  • The fixture is tests/browser/workspace_concept_fixture.py, reset through POST /__test__/concept/reset. It holds the concept's six prompts and pairs, and 24 PNGs with real links, runs and the concept's inspector facts. The sidebar counts are therefore the concept's own: 24, 6 and 15.
  • The shared inventory is tests/browser/concept-inventory.mjs. One self-contained in-page measurer runs the same concept selectors in the immutable concept (/__test__/canonical/workspace) and in production. An absent element becomes null, so the diff names its path (for example chrome.breadcrumbs) instead of failing the measurement.
  • Each page's map<Page>Concept(reference) applies only the recorded deviations, each commented with its D-number. diffInventory must then report nothing.
  • Sizes, offsets and heights that follow from a removed element are derived from the concept's own measurements, never copied from production.
  • mutate(page, {css, remove}) appends a stylesheet and detaches elements, and returns an undo. Each comparison has a mutation check proving it fails. For the shell, a .sidebar nav a { min-height: 30px } rule must fail at chrome.navs.0.rows.0.minHeight and .height, and removing .breadcrumbs must fail at chrome.breadcrumbs.
  • Paired concept/production captures are attached as test artifacts. There are no PNG baselines.

tests/browser/shell-concept.spec.mjs compares the shell: the sidebar, topbar, page heading and footer, at 1600x1100 and 390x844, in dark and light, under normal and reduced motion, on Images, Prompt library and Tags. The heading is compared in full on Tags; on Images and Library only its frame and h1 are compared, because their copy and actions belong to their own PRs. The spec also compares the hover state of the first non-current nav row, the Theme select and the ComfyUI link, and the keyboard rings of the first nav link and heading button.

Recorded shell deviations:

  • D4: a "Theme" select with Dark, Light and System. System follows the ComfyUI palette, then the OS.

  • D5: retired by Activity (#249 Activity-1). The concept's Activity button and Activity row are shown; their differences are D52 to D54.

  • D28: no Design review. (Amended by #331: the COLLECTIONS group ships; its rows, counts and phone layout are D136.) The bottom nav is the concept's Activity and System, plus the production Overview hub (its own outline home glyph, not the concept's activity pulse, and no count). The connection reads "Your library, on your server" with a neutral muted dot.

  • D49 (saved views, #249 D16): the SAVED VIEWS group label has no "PROPOSED" badge, because saved views are persisted (/prompt_manager/saved-views). Its rows are the concept's links() rows: the search icon, the view name and no count, linking #/saved/<id>. Opening one shows its page with the saved toolbar value and Refine filters, and the view's name as the h1, breadcrumb and title. A value its page no longer accepts (a removed Source or Folder) stays default; an unknown id opens Images. A toolbar change made while the sources are still loading keeps the saved Source and Folder until discovery settles. A saved view, like Favorites, never replaces the plain Images or Library return state. Writes (POST, PATCH) validate strictly; a state over 4 KB is refused in the browser with "The view is too large to save. Shorten its search, folder or tags and try again." Startup and restore check only the table's structure and that each row's state is a JSON object of at most 4 KB, never the value rules, so a row saved under older rules (a missing or retired key, a sort no longer offered) never stops the database from opening: reads fill missing keys with their defaults, drop unknown keys, default invalid values and make the name displayable (tests/test_saved_views.py). A live row whose state is not a JSON object never blocks startup either: its id is logged as a warning, the row is left in place, the listing and rename skip it, and its #/saved/<id> link behaves like a missing view. Restore stays strict and rejects such a backup ("Saved views contains invalid values"). Only request validation is a 400; any other failure is a logged 500 with a generic message. The Favorites count re-read after starring is coalesced to one read 300 ms after the last toggle. a saved view row matches the concept's saves one view in both documents and compares the rows; tests/browser/workspace-saved-views.spec.mjs covers saving, reopening, the defaults that replace rejected values, and failed reads and saves.

  • D50 (retired by #249 PR F, ruling R5): SAVED VIEWS now lists the concept's "Needs review" row after Favorites, with its count; the comparison maps nothing out for it (only the concept's sample count "3" reads as the fixture's "0").

  • D51 (maintainer ruling, 2026-10-21, beyond the concept): SAVED VIEWS starts with the concept's Favorites row (star icon, name, count). Its count is the Favorites listing's own limit=1 total (/images/output?mode=workspace&favorites=1), follows the nav-count rules (hidden until loaded, absent when its read fails, never a placeholder) and is re-read after every confirmed star or unstar, on any page. #/favorites is Images filtered to favorites, named "Favorites" (concept renderImages); favorites=1 keeps only the selected roots' favorites, read per root from image_favorites and matched against the scan with the toggle's case folding, and a failed read is an error, never an unfiltered page. Unlike the concept, an unstarred card stays on Favorites (showing ☆) until the next load, so the star can be undone in place. Favorites neither restores nor replaces the Images return state. Save view there saves favorites: true, so the view reopens the favorites. An open saved view's heading leads with Edit: "Edit saved view" with "View name" and Delete… (danger), Cancel and Save. Save re-reads the list, retitles the page and toasts "Saved view renamed."; an empty name keeps the dialog open. Delete… swaps the same dialog to "Delete saved view" (Cancel / Delete; never window.confirm; its Cancel closes the dialog without deleting rather than returning to Edit); Delete removes the view, replaces the dead route with the view's plain page and toasts "Saved view deleted.". Failures toast "The view could not be renamed. Try again." or "The view could not be deleted. Try again."; a view another tab already deleted counts as deleted. tests/browser/workspace-saved-views.spec.mjs covers the row, count, route, star updates, Save view on Favorites, Edit, and the failure paths; tests/test_image_favorites.py covers favorites=1.

  • D52 (Activity, #249 Activity-1): the top-bar button#activity-open and the sidebar's Activity row (the concept's activity pulse, first in system-nav) count this session's running jobs. The concept counts every sample job. span.count#activity-count is hidden at 0 (its text stays "0"), and the row has no .nav-count then. The Activity heading has no "Unified activity · proposed" chip (prototype copy). At max-width: 700px the full-width .top-actions row may wrap (flex-wrap: wrap), so the button, Theme and ComfyUI stay inside a zoomed phone. The shell comparison hides the concept's count at runtime (#activity-count { display: none }), so the concept's own CSS lays out its button without it, and maps the row's count to none, the button's count to "0" and the phone row's flexWrap to wrap.

  • D53: while a job runs, the approved Activity mockup's progress pill sits before the Activity button on every page: a#activity-pill.activity-pill, "Scanning · 41% · 8,240 / 19,622" (the verb by job kind, the server's floored percentage, and the file counts once the total is known), a 70px mini bar, href="#/activity/<id>" and the same text as its aria-label. With no running job it is hidden, which the shell comparison maps as a hidden item before the button. At max-width: 700px it keeps the verb and percentage only; on coarse pointers it is 40px tall like the concept's buttons. Its rules are in workspace.css under D53.

  • D54: each .activity-item is a real job of this session (GET /prompt_manager/jobs), running first, then finished newest first. The concept's structure and CSS stay: .panel-heading > h3 "✓