Skip to content

test: isolate application restart recovery from the shared server suite - #2032

Open
BlueHotDog wants to merge 3 commits into
mainfrom
test/isolate-application-restart
Open

BlueHotDog wants to merge 3 commits into
mainfrom
test/isolate-application-restart

Conversation

@BlueHotDog

@BlueHotDog BlueHotDog commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Move the full :frontman_server shutdown/recovery scenario out of the shared server test VM without removing it from the existing developer or CI workflows. Related: the CI failures on #2017; this is a separate test-infrastructure fix.

Existing commands include both phases

  • make -C apps/frontman_server test: ordinary tests, then restart recovery in its private process/database.
  • make -C apps/frontman_server test-coverage: private restart test with native coverdata export, then ordinary tests through ExCoveralls, which imports the private data before writing cover/cobertura.xml.
  • make -C apps/frontman_server precommit and check: inherit both phases through their existing test invocation/dependency, exactly once.
  • make -C apps/frontman_server test-record: retains ordinary recording, then runs the restart scenario with its approved existing LLM mock.

There is no advertised standalone target or additional manual workflow. CI's existing make -C apps/frontman_server test-coverage runs everything once; the previously added redundant CI step has been removed. Each phase propagates failures.

Isolation and assertions

Every private invocation creates a cryptographically unique PostgreSQL database, migrates it, starts the real application in a separate BEAM, then destroys the entire disposable database. Caller/default database names, partitions and suffixes cannot select this database. No worker-specific cleanup or shared queue assertions are changed; the shared suite no longer changes Repo sandbox mode or stops the application.

Only the explicitly approved existing LLM-provider mock and its response fixtures are used. Repo, PostgreSQL, Oban, task APIs, Swarm runtime, and full application stop/start remain real. PaperTiger is disabled in the private VM; this scenario makes no Stripe or mail calls.

Preserved assertions: pending interactive approval; undispatched serial write; parked runtime; actual termination-generated Interrupted by restart; exhausted fifth-turn allowance; rejection of a new turn; real API approval resolution; persisted model selection; reconstructed result ordering; completion; one turn; no write replay. The actual activation SyncResendContact Oban job is asserted present and disappears with its disposable database—not through manual job deletion.

Resource lifecycle and P2 fix

The coordinator traps exits before opening pools, covering the start_link/unlink race. Each native maintenance pool is immediately unlinked/monitored, short-lived, and terminated/reaped with a finite timeout. The create pool ends before the child starts. After the child terminates/is reaped, cleanup opens a fresh native connection, drops only the successfully created database, and verifies absence. Rejected CREATE never enters database cleanup. Operational exceptions/exits produce operation/database-specific diagnostics and fail the command.

Runtime is bounded at 120 seconds, each test at 30 seconds, and connection/query/reaping operations have finite timeouts. Catchable signals invoke cleanup; the shell disables Erlang's interactive Ctrl-C break handler. Host termination or SIGKILL of the coordinator cannot guarantee cleanup. If PostgreSQL cleanup is unavailable, the command reports failure and the named owned database needs removal after availability is restored; it never substitutes global job deletion.

Coverage behavior

Uses the installed ExCoveralls 0.18.5 APIs and native Erlang coverdata, with no new dependencies or coverage framework. Its source/help explicitly confirms --import-cover imports after running ordinary tests; it does not skip the suite. The child instruments the same compiled application path and exports after its final real application stop. A unique temporary export directory prevents stale imports and is removed on completion/failure. The old Cobertura report is removed before either phase starts, so a failed private run cannot leave a stale success report.

Validation of current integration revision

Toolchain: Elixir 1.20.0 / OTP 29, Node 24.9.0 and Yarn 4.18.0; real local PostgreSQL. Standard Make commands were run with fresh, owned disposable ordinary-validation databases because the default local test database already contains an old leaked activation job. That row was not deleted or edited.

  • make -C apps/frontman_server test TEST_ARGS='--seed 131551': 1,092 ordinary + 1 private passed, exactly once each.
  • make -C apps/frontman_server test-coverage: repeated success, 1,092 ordinary + 1 private passed, exactly once each. Latest ordinary seed 343247; private seed 142660. Actual final cover/cobertura.xml parses as XML.
  • Native private coverdata contains 200 modules, including one hit on FrontmanServer.Tasks line 427 (Interrupted by restart) and the preserved-approval branch at line 445. The combined XML includes the restart branch (line 427: seven hits). This checks real exported line data, not a fabricated coverage percentage.
  • make -C apps/frontman_server precommit: 1,092 ordinary + 1 private passed, exactly once each; ordinary seed 598913. Compile/format/Credo passed.
  • make -n -C apps/frontman_server check, precommit, test-record, and test-coverage: each contains the private invocation exactly once. test-record was dry-run only—no recording/network LLM calls were made.
  • Actual ordinary assertion failure in a temporary smoke test makes make test fail without entering the private phase. The temporary test was removed; source test assertions remain unchanged.
  • Externally killing the owned private child after its application starts makes both standard make test and make test-coverage return nonzero and drop the private database. Coverage failure also removes its temporary export directory and leaves no stale report. A subsequent successful standard coverage run produced the final valid report.
  • Component lint, strict-compile, supported-Node make check-source-comments, and diff check passed.
  • Pre-existing default database queue snapshots are unchanged after validation. All generated private, integration-validation and failure-validation databases were removed.
  • Remote CI and fresh parent/Codex review for the newest head remain pending; no remote success is claimed.

Earlier real isolation/P2 regression evidence

  • Live-parent manual sandbox checkout and Oban sentinel remained intact across the private run: same Repo PID/queue, unrelated process still denied ownership.
  • pg_stat_activity showed no maintenance session while the real child application ran, and distinct native backend PIDs for create and cleanup.
  • Disabled connections on only an owned disposable maintenance database, killed its owned child, and verified the child was reaped before a fresh cleanup attempt returned exit 1 with a named diagnostic within the finite bound. Only owned fixture databases were restored/removed; no shared PostgreSQL service or unrelated session was restarted or terminated.
  • Failed-child, SIGTERM, and SIGINT cleanup smokes passed after the real child application started.

Existing full-suite warnings/failure-path logs remain visible; no warnings are suppressed. No production behavior, dependencies, PHP/WordPress files, or plans changed. skip-changelog is appropriate for this test-only chore. PR stays draft for parent review; no merge, auto-merge, force push, signing bypass, state promotion, or duplicate Codex request.

@BlueHotDog BlueHotDog added the skip-changelog Skip changelog check for this PR label Oct 27, 2026
@BlueHotDog
BlueHotDog requested a review from itayadler as a code owner October 27, 2026 11:09
@BlueHotDog BlueHotDog added the skip-changelog Skip changelog check for this PR label Oct 27, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T11:58:29.376614Z b13298c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@BlueHotDog
BlueHotDog marked this pull request as draft October 27, 2026 11:20
@BlueHotDog

Copy link
Copy Markdown
Collaborator Author

Marked draft while addressing a safety-review finding in the coordinator: the long-lived Postgrex maintenance pool is linked to the cleanup owner, so an abnormal connection/pool exit can terminate that owner before child/database cleanup. I am replacing that lifetime with short-lived native connections and a fresh bounded teardown connection, with real failure-path checks. This is not a finding about the approved LLM mock or the restart assertions. Please do not merge this head while the cleanup revision is in progress.

@BlueHotDog

Copy link
Copy Markdown
Collaborator Author

The coordinator safety finding is addressed in f067307. It traps exits before startup, unlinks and monitors short-lived maintenance pools, retires the create pool before the child starts, and uses a fresh bounded cleanup connection after child termination/reaping. Independent read-only review found the prior P2 addressed and no new material findings. Real native failure checks, signal/child-failure checks, precommit (1,092 regular tests), lint, strict compile and source-comment checks pass. I am marking the PR ready for review; fresh exact-head Codex review and remote CI remain separate gates. No merge or auto-merge is being performed.

@BlueHotDog
BlueHotDog marked this pull request as ready for review October 27, 2026 11:32
@BlueHotDog
BlueHotDog marked this pull request as draft October 27, 2026 11:43
@BlueHotDog

Copy link
Copy Markdown
Collaborator Author

The standard-entry-point integration gap is fixed in b13298c. Normal test and test-record commands invoke the private phase internally; precommit and check inherit it through test. test-coverage exports native private-BEAM coverage and merges it through ExCoveralls while still running ordinary tests. The standalone target/help and redundant CI step are removed. Actual test, test-coverage and precommit runs each passed 1,092 ordinary tests plus one private restart test exactly once. test-record was dry-run only. Independent review verified the Make paths and actual ExCoveralls import behavior with no material findings. Marking ready for fresh exact-head review; CI remains a separate gate and no merge is being performed.

@BlueHotDog
BlueHotDog marked this pull request as ready for review October 27, 2026 11:57

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Skip changelog check for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant