chore(586,594,485): PID-scoped E2E cleanup, ci-image-pin length guard, .gitignore core fix
PR Gates / CI image pin matches docker/ci (pull_request) Successful in 11s
PR Gates / Docs update reminder (pull_request) Successful in 11s
PR Gates / decisions lifecycle (pull_request) Successful in 12s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 21s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 15s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 6m22s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 21m9s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / Functional E2E (curl contracts) (pull_request) Successful in 5m55s
PR Gates / CI image pin matches docker/ci (pull_request) Successful in 11s
PR Gates / Docs update reminder (pull_request) Successful in 11s
PR Gates / decisions lifecycle (pull_request) Successful in 12s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 21s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 15s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 6m22s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 21m9s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / Functional E2E (curl contracts) (pull_request) Successful in 5m55s
Three independent CI/repo-hygiene fixes swept together; disjoint file sets. fixes #586 — E2E cleanup is scoped by PID, never a pattern-wide pkill - New decision record `testing.e2e-cleanup-scope-by-pid`. - docs/e2e-local.md states the constraint where a BRIEF-WRITER sees it (the #586 root cause was a delegation gap, not agent error). - scripts/e2e-local.sh: reviewed against e2e-ui.sh's trap lifecycle and deliberately does NOT adopt it — its contract is to hand a running instance back to its caller, so an EXIT trap would kill the server the instant the launcher returned (both callers use `OUT="$(e2e-local.sh ...)"`). Recorded. - Instead it gains what actually prevents the incident: an lsof pre-flight that NAMES a foreign listener's PID rather than letting Kestrel fail its bind and surface as "process N exited before becoming ready". - Pre-flight probes BOTH bound ports, and ETV_STREAMING_PORT now defaults to ETV_UI_PORT. Program.cs binds a second listener whose port defaults to 8409 independently of ETV_UI_PORT, so `ETV_UI_PORT=8420` alone still bound 8409 and died against a foreign holder — i.e. the documented escape hatch was a dead end that led straight back to the confusion behind the pattern kill. fixes #594 — ci-image-pin accepts any hex length - Length is a separate invariant from correctness: the resolve/staleness checks compare resolved shas, so an 8-char pin of the right commit passes green while matching NO registry tag, and all five container: jobs then die at image-pull with `manifest unknown` (reads like a registry outage). - Guard fails at the gate and prints the exact tag to use. Verified against doctored pins: 7 green; 6/8/10 red. - Uses a literal 7 rather than a derived `--short=7`: in a full clone git may widen an ambiguous abbreviation, demanding a pin ci-image.yml can never publish. Escape hatch documented inline. - Also fixes a pre-existing misdiagnosis: zero pins reported "MORE THAN ONE". - docs/ci-cd.md documents the 7-char rule and `git rev-parse --short=7 HEAD`. fixes #485 — .gitignore `core` silently ignored `*/Core/` files - A bare `core` matched any path component named `core`; case-insensitively on macOS that swallowed every `*/Core/` SOURCE dir, so new untracked files were dropped by `git add -A` while tracked ones stayed fine — a clean local build and a CI checkout that fails to compile. - Now `/core` + `/core.[0-9]*`, both anchored (an unanchored `core.[0-9]*` would re-introduce the same silent-exclusion class this fixes). - Verified by diffing the full ignored-file set before/after: identical, and the three real Core/ dirs are trackable without -f. Docs updated in-PR: docs/e2e-local.md, docs/ci-cd.md, docs/decisions/ workflow-process.md (+ regenerated catalog), docs/handoffs/chicorytv-issue-queue.md. Follow-ups filed: #596 (the same shared-host reap in the Playwright-MCP recovery record) and the ci-image.yml `--short=7` publisher-side fix, which cannot ride this PR — editing ci-image.yml re-points ci-image-pin's `expected` at this commit and reds the gate. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -619,3 +619,66 @@ Two further reasons the broad form is right, both of which the narrow version ha
|
||||
The noise objection is answered by the escape hatch rather than by scoping: **naming a tier costs one
|
||||
parameter and the hook never fires again**. The prompt is self-eliminating for anyone following the
|
||||
rule, which is the habit being built.
|
||||
|
||||
## 2026-07-25 — E2E cleanup kills only the PIDs it started; never a `pkill -f` pattern (#586)
|
||||
|
||||
`key: testing.e2e-cleanup-scope-by-pid` · `status: active` · `since: 2026-07-25` · `supersedes: none` · `superseded-by: none`
|
||||
**Rule:** An E2E harness or agent may only kill processes whose PIDs it captured at launch — capture the PID; whoever owns the lifecycle releases it from a `trap ... EXIT INT TERM`. Never `pkill -f "dotnet ErsatzTV.dll"` (or any pattern that can match a process this run did not start). A foreign listener is reported, not reaped.
|
||||
**Signals:** `pkill -f` · `pkill -f "dotnet ErsatzTV.dll"` · E2E teardown · shared-host reap · port 8409 · port 8410 · port 8420 · `lsof -ti :$PORT` · `trap cleanup EXIT INT TERM` · truncated E2E output · delegated-brief omission · paths: `scripts/e2e-local.sh`, `scripts/e2e-ui.sh`, `docs/e2e-local.md` · issues: #586, #596, #445, #533, #440, #406
|
||||
**Mechanics:** `PID=$!` at launch, `trap cleanup EXIT INT TERM` in the lifecycle-owning script; to identify a foreign listener use `lsof -ti :"$PORT"` and fail with its PID, or re-run under `ETV_UI_PORT=<other>`.
|
||||
|
||||
A delegated agent running the #440 live-E2E found a `dotnet ErsatzTV.dll` already on the default port
|
||||
8409 that wasn't its own (mismatched `api.key`). It moved its own run to 8420 — then during cleanup ran
|
||||
a broad `pkill -f "dotnet ErsatzTV.dll"`, which would have reaped the parallel #445/#533 session's
|
||||
instance too. No damage that time: `scripts/e2e-ui.sh` owns its instance lifecycle and kills its server
|
||||
from an EXIT/INT/TERM trap, so a free 8409 was the expected post-run state, and all four determinism
|
||||
runs had already printed explicit `3 passed` summaries.
|
||||
|
||||
(That 8420 run could only have succeeded because the other instance had already released 8409 — as the
|
||||
port section below explains, at the time `ETV_UI_PORT=8420` alone still bound 8409 as well, so it would
|
||||
have failed outright against a live holder. The incident report's "correctly moved to 8420" reads as a
|
||||
clean sidestep; it was closer to a coincidence. That is itself part of why the escape hatch needed
|
||||
fixing rather than just documenting.)
|
||||
|
||||
**The near-miss is the point.** A mid-run kill of an E2E harness does not fail loudly — it truncates
|
||||
output into plausible-looking-but-wrong data, which is exactly the failure class that survives review.
|
||||
Same shape as the #406 peak-anon incident: reaping a shared-host resource you did not create.
|
||||
|
||||
**Port separation is not mitigation — and there is less of it than the incident report assumed.** A
|
||||
`pkill -f "dotnet ErsatzTV.dll"` matches the *command line*, so it hits every instance regardless of
|
||||
which port each one chose. Worse, the ports are not actually separated: the CI `functional-e2e` step
|
||||
exports `ETV_UI_PORT=8409` (`docker-build.yml`), the *same* port local runs use — 8410 is the
|
||||
`ersatztv-test` container on jazz, a different thing that the incident report conflated with it. (The
|
||||
ui-E2E step added by #445 does use 8410.) Scope by PID, not by pattern and not by port.
|
||||
|
||||
**And "just use another port" is not a complete escape either.** `Program.cs` binds *two* listeners —
|
||||
`ListenAnyIP(UiPort)` plus `ListenAnyIP(StreamingPort)` when they differ — and `SystemEnvironment.cs`
|
||||
defaults `StreamingPort` to **8409 independently of `ETV_UI_PORT`**. So `ETV_UI_PORT=8420` alone still
|
||||
binds 8409 and dies at startup against a foreign holder. An agent that took the obvious escape hatch
|
||||
would land right back in the confusion that produced the pattern kill. `scripts/e2e-local.sh` now
|
||||
defaults `ETV_STREAMING_PORT` to the port it was given, and probes both before launching.
|
||||
|
||||
**Root cause is a delegation gap, not agent error.** The brief specified a fresh config dir (per
|
||||
`testing.e2e-local-fresh-config-dir`) but said nothing about process cleanup, so the agent invented a
|
||||
reasonable-looking pattern kill. An omitted rule is not an unenforced rule — it is a rule replaced by
|
||||
whatever plausible default the agent reaches for. Hence the constraint lives in `docs/e2e-local.md`,
|
||||
where a brief-writer reads it, and not only here.
|
||||
|
||||
**Known tension with `testing.playwright-mcp-download-and-recovery`,** which prescribes
|
||||
`pkill -f ms-playwright-mcp` as the stall-recovery move. That is the same pattern-kill hazard this
|
||||
record forbids — on a shared machine it reaps every session's MCP server, not just the stalled one —
|
||||
and the rule above is deliberately general ("any pattern that can match a process this run did not
|
||||
start"), so it covers that case too. That record is not line-edited here (records are superseded, not
|
||||
rewritten — `docs.decision-lifecycle`); PID-scoping the MCP recovery is tracked as **#596**, which
|
||||
also has to answer whether a session's own MCP server is externally identifiable at all. Until that
|
||||
lands, prefer `pgrep -f ms-playwright-mcp` to identify the specific stalled PID and kill only that one.
|
||||
|
||||
**`scripts/e2e-local.sh` deliberately does NOT adopt the trap.** Its documented contract is the
|
||||
inverse of `e2e-ui.sh`'s: it boots the server, prints `PID`/`PORT`/`CONFIG_DIR`/`LOG`, and **exits
|
||||
leaving the server running** so a caller can drive the live instance. An EXIT trap there would kill the
|
||||
server the instant the launcher returned, breaking every caller including `e2e-ui.sh` and the CI
|
||||
`functional-e2e` step. The split is correct as it stands: `e2e-local.sh` is the launcher and hands
|
||||
ownership of a single PID to its caller; `e2e-ui.sh` is a lifecycle owner and traps. What #586 changed
|
||||
in `e2e-local.sh` instead is the two things that actually prevent the incident — an `lsof` pre-flight
|
||||
that names a foreign listener's PID (so an agent meeting a busy port gets a diagnosis instead of
|
||||
inventing one) and an explicit statement of who owns the printed PID.
|
||||
|
||||
Reference in New Issue
Block a user