Add an admin-managed provider model catalog with per-user summary selection, migration backfill, and generation snapshots. Retire report creation and messaging while preserving owner-scoped history. Refs #15 #16 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
6.5 KiB
Ticket #12 — isolated browser E2E
The supervisor requires Linux /proc, child-subreaper support and Python 3 (standard library only). Run make test-e2e from the project root after make deps and make test-postgres. The latter prepares the pinned embedded-postgres CLI v2.0.1/PostgreSQL 16.15.1 cache. Install Playwright's pinned Firefox beforehand if it is not already cached (cd frontend && npx playwright install firefox). These preparation steps may require network access; the E2E runner itself uses offline caches and never installs dependencies.
The runner builds the dedicated backend/cmd/e2e executable, starts a disposable tradarr_e2e database, applies the real migrations, and refuses a nonempty database. It ignores inherited application/test database URLs, chooses loopback ports, and bootstraps a reserved disposable admin. Exactly one fixture source is enabled. The catalogue contains one explicit fake summary model. The new user selects it in the real preferences UI; new accounts have no default selection. The injected Laya ranker and summary provider are separate test doubles, with no concrete retrieval adapter instantiated and no legacy role fallback. Production uses the same internal/server constructor with its existing real composition and scheduler enabled.
OpenFIGI, an Ollama-compatible fake Laya and a fake scraper share a loopback HTTP service with /audit counters and structured call events. The ranking fake extracts the real candidate UUID from the request prompt and returns it in ranked_article_ids; the browser assertion checks that actual UUID in audit events against the saved outcome. No hard-coded fixture ID selects a candidate.
The temporary private manifest declares networkPolicy: loopback-only and generationProvider: fake-laya, along with frontend/API/database/fake URLs, disposable bootstrap credentials and the cached psql path. The Playwright global guard validates it before opening Firefox. The manifest is generated by the runner, not a reusable configuration file. A new private work directory is created per run, with mode-0600 manifest/logs. It is removed on success, failure or interruption, along with processes and disposable DB files; build and PostgreSQL binary caches remain.
The Make recipe execs a launcher whose parent is make. A detached Python watchdog owns a separate worker session, monitors the original make PID/start time and a liveness pipe, and acts as a Linux child subreaper. It detects parent SIGKILL or a killed launcher without depending on shell traps. On exit it retains every observed PID/start-time identity, discovers direct children through /proc/self/task/*/children, signals all owned descendants (including detached groups/sessions), and escalates to SIGKILL after 1.5 seconds. An empty ancestry snapshot is never treated as proof of cleanup: completion requires the kernel's waitpid/ECHILD confirmation plus no live retained identity. It then removes the workspace. Kernel parent-death signals additionally protect the launcher, CLI worker, e2e-stack, Vite and Playwright launchers. The E2E Go main thread is kept alive for these thread-sensitive Linux guards. Cleanup is bounded; failure to terminate a process retains the workspace and reports an error. It never kills by executable name or removes shared build caches. As with any userspace watchdog, killing the watchdog itself with SIGKILL is outside this guarantee.
make test-e2e-supervisor runs offline regressions for owner/launcher SIGKILL, TERM-resistant detached grandchildren, and a deliberately empty /proc ancestry snapshot while a kernel-owned child remains alive. The latter fails on the original implementation; the initial three tests did not cover it.
make test-e2e-timeout launches the real runner via timeout --foreground --preserve-status --signal=INT --kill-after=8s 8s make test-e2e, with real disposable PostgreSQL/backend/Vite and a PATH wrapper that blocks Playwright before browser execution. It requires observing those real processes and a ready manifest, then verifies no surviving observed identity or workspace immediately when timeout returns. The test does not keep its own parent alive waiting for post-return cleanup. To use QA's actual wrapper instead of the built-in one, run make test-e2e-timeout E2E_REPRO_WRAPPER=/absolute/QA/wrapper-directory; a missing wrapper fails closed rather than silently running without the intended reproduction. The real E2E cleanup should also be checked with the QA PATH-wrapper/timeout --foreground --preserve-status --signal=INT --kill-after=8s 8s make test-e2e reproducer. The supervisor inherits the nearest enclosing GNU timeout's soft deadline from its /proc arguments and start time. It begins cancellation at that deadline even when make does not forward SIGINT to its recipe. For the 8s INT / 8s kill-after reproducer, cleanup must finish during the grace interval and return 130 (or make's error status), rather than relying on a watcher after exit 137. This matters when the outer execution environment tears down remaining processes as soon as timeout returns. An arbitrary SIGKILL of the entire execution namespace cannot leave a userspace watcher running.
The E2E executable rejects nonliteral/nonloopback destination URLs and installs an HTTP transport that refuses external egress without DNS/proxy fallback. The temporary Vite configuration removes external font/preconnect links and adds a restrictive CSP. Playwright blocks nonloopback page requests and service workers; Firefox prefetch/speculative connections are disabled. No production frontend file or retrieval adapter is changed for this policy.
The Firefox journey covers admin login/account creation, new-user login, explicit OpenFIGI search/selection/follow, language/ranking/model preferences and fake-backed generation. It checks the saved provider/model snapshot against the actual model recorded by the fake summary service. It compares counts and hashes for articles, article_symbols and scrape_jobs, verifies retired routes are 404, reads the authenticated aggregate history, verifies its single-source counters, and rejects fixture article fields and actual candidate IDs in that outcome. HTTP success through the real application is required; API/provider routes are not mocked in the browser.
npm run test:e2e alone still fails closed without a valid running stack manifest. Use make test-e2e for complete lifecycle management. The scenario has no automatic retry. Browser traces and logs can contain disposable credentials and are deliberately kept inside the cleaned workspace.