Repository navigation
fix(hopper): name the unconfirmed shutdown step in retained cleanup - #10594
Merged
Merged
Conversation
When close_binary retains a Hopper document, the cleanup error lists the retained resources but not why shutdown went unconfirmed. On Linux CI, hopperClient.handshakeRecovery "recovers an application exit after the first valid handshake occurs during cleanup" fails intermittently. The vitest blob reports show only hopper-document and the runtime root retained with authenticated_application "readable". From those facts we cannot tell whether the shutdown request was not sent, failed, or was sent while the application was still observed as present. Record the shutdown request outcome (method, status, error tag and provider state, or why it was not sent) and the final exit observation of the authenticated application in the retained-document diagnostics. Exit observation now reports a positively observed Linux exit in progress (PF_EXITING before state Z) as "exiting", separate from "present". Neither confirms exit. The flaky test asserts the projected error, so a later failure prints these diagnostics in the CI log. Refs #10556
2 tasks done
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
[Low impact] The PR appears safe to merge; no new actionable issues were found. SummaryAdds shutdown-request and application-exit facts to retained Hopper cleanup errors.
Reviews (4) · Last reviewed commit: "test(hopper): retry cleanup after confir..." · Reviewed by Greptile |
12 of 22 tasks
Davmunrey
added a commit
to Davmunrey/rea
that referenced
this pull request
Nov 14, 2026
morluto#10594 added an "exiting" result to observeProcessStartIdentityExit. This branch now waits through the shared exit settlement first, so "exiting" names an exit in progress that outlasted the cleanup grace. The never-settling test now expects "exiting" after more than one read.
19 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refs #10556. When
close_binarykeeps a Hopper document, the cleanup diagnostics now say why document shutdown was not confirmed. They record whether the shutdown request was sent, what it returned, and what the final exit check saw for the authenticated application. The flaky handshake-recovery test now asserts the projected error, so the next Linux CI failure prints those facts in the job log.This PR does not claim to fix the flake. I could not reproduce it, and I am not shipping a speculative timing change.
Problem and expected behavior
tests/boundary/providers/hopper/hopperClient.handshakeRecovery.test.ts> "recovers an application exit after the first valid handshake occurs during cleanup" fails intermittently on Linux CI.client.close()returnsProviderCleanupError("Provider hopper adapter failed during close_binary"). It has failed on both close sites::288after the cleanup handshake and:315after the restart.The job log shows only the message. The retained diagnostics are in the vitest blob reports, and I decoded them for four failures:
diagnosticshopper-document"authenticated shutdown acknowledgement was not observed" + runtime root "Private runtime retained because process or native document closure was not confirmed";authenticated_application: "readable"The "Portable tests" job only merges shard reports, so it repeats these failures rather than adding new ones.
So the identity was readable, and both issues come from
resources.shutdownConfirmedstaying false:recordUnconfirmedDocument(HopperCleanup.ts:334) and the runtime-root retention branch (HopperCleanup.ts:110). In this fixture (exit-without-ack), onlyconfirmExternalApplicationExitafter the shutdown request (HopperCleanup.ts:103) can set it. That means one of three things happened, and the current diagnostics cannot say which:presentorunverified.Expected behavior: a retained-document cleanup error names the step that failed.
Change and scope
src/hopper/HopperCleanup.ts:CleanupStaterecordsshutdownRequestandapplicationExit. Whenhopper-documentis retained, the details also include:shutdown_request: one of{ method, status: "confirmed" | "unconfirmed" | "failed", error_tag?, provider_state? }{ status: "not_sent", reason: "no_bridge_transport" | "bridge_transport_closed" | "bridge_operation_active" | "shutdown_already_confirmed" }application_exit:"exiting" | "present" | "unverified"confirmExternalApplicationExitnow returns its observation instead ofvoid. Cause messages are not copied into the details; only tags and states are.src/process/ProcessOwnershipObservation.ts:observeProcessStartIdentityExitreports a positively observed Linux exit in progress (PF_EXITING before state Z) as"exiting"instead of"present". It still does not confirm exit, and the only consumer (confirmExternalApplicationExit) treats every non-"exited"result as unconfirmed, so behavior does not change. This separates the "kernel exit window" hypothesis from "application still running" on the next failure.hopperClient.handshakeRecovery.test.ts: both close sites assertprojectAnalysisError(...)isnullinstead of rethrowing the error. A failure now prints the full diagnostics diff.Not included: no timeout, retry, or settle loop. The obvious candidate fix (wait for an observed
exitingidentity to reach Z) is not backed by evidence yet; see "Evidence".Contribution scope: not applicable (diagnostics within the existing Hopper cleanup boundary; no new authority or side effects).
Contract and boundary impact
cleanupHopperSession(HopperCleanup.ts) owns the retained-cleanup facts.observeProcessStartIdentityExitowns the exit observation. The only consumer of the new value is HopperCleanup.cleanup_incompletediagnostics for a retained Hopper document. The error code, resources, and remediation are unchanged. No schema change."exiting"can only be observed on Linux, where procfs reports PF_EXITING.exitedobservation still retains the document and runtime root.docs/public/product-catalog.json), package, or installation impact: none.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
src/hopper/HopperCleanup.test.ts: a new test uses the test process's own real start identity (a live application) and a failedshutdown_documentrequest. It assertsshutdown_request{ method: "shutdown_document", status: "failed", error_tag: "HopperProcessError", provider_state: "unreachable" }andapplication_exit: "present". On the base revision it would fail because neither field exists. The "does not confirm" case now also coversexiting.src/process/ProcessStartIdentity.test.ts: a readable, matching identity with lifecycleexitingmaps to"exiting".node:24.22.1-bookworm-slim, kernel 6.12.54-linuxkit,--cpus=4):shutdown_documentfailed withHopperProcessError/unreachable, and the exit check after shutdown found the fixture already reaped (exited)./proc/<pid>/statright after the peer socket closed because the peer calledprocess.exit(0)(the fixture'sexit-without-ackpath). It never saw a non-zombie or PF_EXITING state: idle{ENOENT: 299, ESRCH: 1}; 24 CPU hogs on 2 CPUs{ENOENT/ESRCH: 1423, Z: 77}(every ESRCH followed bykill(pid, 0)= ESRCH); synchronous read onendunder--cpus=0.2{Z: 300}. That evidence argues against the PF_EXITING window being the cause in this environment. It does not rule it out on the CI kernel (Ubuntu 26.04 runner image).cleanup_incompletenow also carries, for example,"shutdown_request": {"method": "shutdown_document", "status": "failed", "error_tag": "HopperProcessError", "provider_state": "unreachable"}, "application_exit": "present".Lifecycle regressions: this changes diagnostics only. Cleanup ordering, retention, and retry are unchanged and still covered by the existing Hopper cleanup,
cleanupRetry,externalExit, andhandshakeRecoverysuites.For evidence-bearing changes:
Validation performed
npm run test:local -- src/hopper/HopperCleanup.test.ts src/process/ProcessStartIdentity.test.ts: 2 files, 29 tests passednpm run test:focused -- <all 35 tests/boundary/providers/hopper/*.test.ts> tests/boundary/cli/hopperLaunchFailureCli.test.ts src/hopper/HopperCleanup.test.ts src/process/ProcessStartIdentity.test.ts: 36 files passed, 1 failed. The failure ishopperLaunchFailureCli.test.ts> "exits after a retained-cleanup failure and releases the target to a retry" (recovered.acquiredfalse). It fails identically on the base revision on this macOS host and is darwin-only, so it is unrelated to this change.npm run test:focused -- tests/boundary/providers/hopper/hopperClient.handshakeRecovery.test.ts ...cleanup/cleanupRetry/externalExit...: 6 files, 55 tests passednpx oxfmt --checkon changed files: passednpm run check:fast: passedCompatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.