[PR #4236] [CLOSED] fix(hopper): report a readiness wait as starting instead of idle (#4226) #6139

Closed
opened 2026-10-31 01:12:09 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4236
Author: @DeryFerd
Created: 10/15/2026
Status: ❌ Closed

Base: main ← Head: fix/hopper-starting-readiness-telemetry


📝 Commits (1)

  • 09cf6b9 fix(hopper): report a readiness wait as starting instead of idle

📊 Changes

3 files changed (+129 additions, -17 deletions)

View changed files

📝 src/domain/providerOperationHealth.ts (+2 -0)
📝 src/hopper/HopperClient.ts (+42 -16)
📝 tests/boundary/providers/hopper/hopperClient.startupFailures.test.ts (+85 -1)

📄 Description

Summary

While Hopper's bridge startup is still waiting for readiness, binary_session reported provider_operation_health.state as idle with no active or queued requests. That made a provider whose bridge had never completed its authenticated handshake indistinguishable from an idle, ready provider. This adds a starting state and reports it while a startup promise is outstanding and the bridge is not ready, so a caller can tell a starting provider from a healthy idle one.

Refs #4226.

Problem and expected behavior

The smallest trigger is a Hopper bridge that is still in its readiness wait: the launcher has started, but the authenticated health handshake has not completed. During that window HopperClient.operationHealth() fell through to the idle branch and returned { state: "idle", stage: null, retryAction: null, exitCode: null, requests: [] }, while isReady() was still false. The session status then showed analysis activity idle with no queued work even though a readiness wait was in flight.

The violated invariant is that caller-visible provider telemetry must not report an idle provider while a lifecycle transition is outstanding. The expected behavior is that a provider that is starting is reported as starting with a wait recovery action, and that a genuinely idle provider still reports idle.

Change and scope

src/domain/providerOperationHealth.ts adds starting to PROVIDER_OPERATION_STATES and maps it to the wait retry action, alongside busy. src/hopper/HopperClient.ts reports starting from operationHealth() when #startPromise is outstanding and isReady() is false, with stage: "launch" and no retained requests. A client that has finished starting, or one that never started, still reports idle unchanged.

This is deliberately the smallest slice of #4226 that can be established without a real macOS Hopper. It does not touch pre-handshake recovery, primary-diagnostic retention while cleanup is pending, cleanup-pending telemetry, or close/reopen after positive closure proof. Those remain open in the report and are not addressed here.

Contract and boundary impact

  • Semantic owner and earliest changed stage: provider-operation telemetry in src/domain/providerOperationHealth.ts; the earliest changed stage is Hopper bridge startup in src/hopper/HopperClient.ts.
  • Contribution scope fit and linked maintainer decision: ordinary bug fix within the existing Hopper adapter and session-status contract; a separate maintainer scope decision is not applicable.
  • CLI and MCP/tool-catalog contract: provider_operation_health.state gains one additional enum value, starting. This is additive to the advertised output schema; the existing values are unchanged and no input contract changes.
  • Provider, bridge, target-format, or platform compatibility: Hopper-only telemetry; no provider protocol, bridge, or target-format change, and the state is produced from existing in-process startup bookkeeping.
  • Evidence, artifact, provenance, or reconstruction contract: no product Evidence change.
  • Target selection, authority, upstream behavior, and cleanup details: no change to target selection, execution authority, or cleanup; the change only reports an already-outstanding startup.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: the generated MCP catalog picks up the new enum value; npm run metadata:check passes.

Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/providers/hopper/hopperClient.startupFailures.test.ts gains a readiness-telemetry case that starts a silent launcher whose bridge socket never appears, waits on operationHealth(), and asserts state: "starting", retryAction: "wait", exitCode: null, requests: [], with isReady() false and requestActivity() null.
  • Base reproduction or other evidence: an independent socket-free probe on a real Windows 11 x64 host (Node 24.21.0) showed operationHealth() returning {"state":"idle",...} while isReady() was false during an outstanding readiness wait, matching the report.
  • User-visible CLI/MCP output (if applicable): the change is visible as provider_operation_health.state: "starting" in binary_session while startup is pending. The real macOS stdio MCP session from the report was not re-run.
  • Remaining proof gaps: no real macOS Hopper host was available. The bug and the fix are established at the adapter and session-status boundary with a controlled launcher, not through a real Hopper engine. The remaining items in #4226 (pre-handshake recovery, primary diagnostic retention during cleanup, cleanup-pending telemetry, close/reopen after closure proof) are not covered. Several Hopper boundary tests in this checkout require Unix sockets and do not run on Windows.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run tests/boundary/providers/hopper/hopperClient.startupFailures.test.ts -t "readiness wait as starting" --project boundary — 1 passed.
  • Red-green check — reverting providerOperationHealth.ts and HopperClient.ts makes the new case fail with expected { state: 'idle' } to match { state: 'starting' }; restoring both makes it pass.
  • npx vitest run src/domain/analysisErrorProjection.test.ts src/hopper/HopperProvider.test.ts src/hopper/HopperCleanup.test.ts — 62 passed.
  • npm run metadata:check — passed; the generated MCP catalog accepts the new enum value.
  • npx vitest run tests/boundary/mcp/advertisedPatternsVMode.test.ts --project mcp-boundary — 1 passed.
  • npx vitest run tests/composition/analysis-sessions/binarySession.test.ts --project composition — 42 passed, 1 pre-existing Windows symlink failure (EPERM), identical with the change stashed.
  • npx vitest run tests/boundary/mcp/sessionMcp.test.ts --project mcp-boundary — 8 passed, 1 pre-existing timeout, identical with the change stashed.
  • npx oxlint and npx oxfmt --check on the three changed files — 0 errors, format clean.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. starting is an added value on an output enum; existing values and input contracts are unchanged. Clients that switch exhaustively on the previous set should handle the new value, which the change documents here.
  • Real Hopper/Ghidra, browser, or OS coverage: no real Hopper engine was run; the change is verified with a controlled launcher at the adapter boundary. A real macOS Hopper check remains a gap.
  • Package or release metadata impact: the generated MCP catalog reflects the new enum value; no package or installation change.
  • Security, privacy, process, or containment review: no target execution, injection, mutation, network, or filesystem change. The state is derived from existing in-process startup bookkeeping.

Author readiness

Human owner: @DeryFerd

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4236 **Author:** [@DeryFerd](https://github.com/DeryFerd) **Created:** 10/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/hopper-starting-readiness-telemetry` --- ### 📝 Commits (1) - [`09cf6b9`](https://github.com/morluto/rea/commit/09cf6b9b2bd2bda37edf175495599d607a8dfc93) fix(hopper): report a readiness wait as starting instead of idle ### 📊 Changes **3 files changed** (+129 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/providerOperationHealth.ts` (+2 -0) 📝 `src/hopper/HopperClient.ts` (+42 -16) 📝 `tests/boundary/providers/hopper/hopperClient.startupFailures.test.ts` (+85 -1) </details> ### 📄 Description ## Summary While Hopper's bridge startup is still waiting for readiness, `binary_session` reported `provider_operation_health.state` as `idle` with no active or queued requests. That made a provider whose bridge had never completed its authenticated handshake indistinguishable from an idle, ready provider. This adds a `starting` state and reports it while a startup promise is outstanding and the bridge is not ready, so a caller can tell a starting provider from a healthy idle one. Refs #4226. ## Problem and expected behavior The smallest trigger is a Hopper bridge that is still in its readiness wait: the launcher has started, but the authenticated `health` handshake has not completed. During that window `HopperClient.operationHealth()` fell through to the idle branch and returned `{ state: "idle", stage: null, retryAction: null, exitCode: null, requests: [] }`, while `isReady()` was still `false`. The session status then showed analysis activity idle with no queued work even though a readiness wait was in flight. The violated invariant is that caller-visible provider telemetry must not report an idle provider while a lifecycle transition is outstanding. The expected behavior is that a provider that is starting is reported as starting with a wait recovery action, and that a genuinely idle provider still reports idle. ## Change and scope `src/domain/providerOperationHealth.ts` adds `starting` to `PROVIDER_OPERATION_STATES` and maps it to the `wait` retry action, alongside `busy`. `src/hopper/HopperClient.ts` reports `starting` from `operationHealth()` when `#startPromise` is outstanding and `isReady()` is false, with `stage: "launch"` and no retained requests. A client that has finished starting, or one that never started, still reports `idle` unchanged. This is deliberately the smallest slice of #4226 that can be established without a real macOS Hopper. It does not touch pre-handshake recovery, primary-diagnostic retention while cleanup is pending, cleanup-pending telemetry, or close/reopen after positive closure proof. Those remain open in the report and are not addressed here. ## Contract and boundary impact - Semantic owner and earliest changed stage: provider-operation telemetry in `src/domain/providerOperationHealth.ts`; the earliest changed stage is Hopper bridge startup in `src/hopper/HopperClient.ts`. - Contribution scope fit and linked maintainer decision: ordinary bug fix within the existing Hopper adapter and session-status contract; a separate maintainer scope decision is not applicable. - CLI and MCP/tool-catalog contract: `provider_operation_health.state` gains one additional enum value, `starting`. This is additive to the advertised output schema; the existing values are unchanged and no input contract changes. - Provider, bridge, target-format, or platform compatibility: Hopper-only telemetry; no provider protocol, bridge, or target-format change, and the state is produced from existing in-process startup bookkeeping. - Evidence, artifact, provenance, or reconstruction contract: no product Evidence change. - Target selection, authority, upstream behavior, and cleanup details: no change to target selection, execution authority, or cleanup; the change only reports an already-outstanding startup. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact: the generated MCP catalog picks up the new enum value; `npm run metadata:check` passes. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] Read existing files or captured data. - [x] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [x] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `tests/boundary/providers/hopper/hopperClient.startupFailures.test.ts` gains a readiness-telemetry case that starts a silent launcher whose bridge socket never appears, waits on `operationHealth()`, and asserts `state: "starting"`, `retryAction: "wait"`, `exitCode: null`, `requests: []`, with `isReady()` false and `requestActivity()` null. - Base reproduction or other evidence: an independent socket-free probe on a real Windows 11 x64 host (Node 24.21.0) showed `operationHealth()` returning `{"state":"idle",...}` while `isReady()` was `false` during an outstanding readiness wait, matching the report. - User-visible CLI/MCP output (if applicable): the change is visible as `provider_operation_health.state: "starting"` in `binary_session` while startup is pending. The real macOS stdio MCP session from the report was not re-run. - Remaining proof gaps: no real macOS Hopper host was available. The bug and the fix are established at the adapter and session-status boundary with a controlled launcher, not through a real Hopper engine. The remaining items in #4226 (pre-handshake recovery, primary diagnostic retention during cleanup, cleanup-pending telemetry, close/reopen after closure proof) are not covered. Several Hopper boundary tests in this checkout require Unix sockets and do not run on Windows. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npx vitest run tests/boundary/providers/hopper/hopperClient.startupFailures.test.ts -t "readiness wait as starting" --project boundary` — 1 passed. - Red-green check — reverting `providerOperationHealth.ts` and `HopperClient.ts` makes the new case fail with `expected { state: 'idle' } to match { state: 'starting' }`; restoring both makes it pass. - `npx vitest run src/domain/analysisErrorProjection.test.ts src/hopper/HopperProvider.test.ts src/hopper/HopperCleanup.test.ts` — 62 passed. - `npm run metadata:check` — passed; the generated MCP catalog accepts the new enum value. - `npx vitest run tests/boundary/mcp/advertisedPatternsVMode.test.ts --project mcp-boundary` — 1 passed. - `npx vitest run tests/composition/analysis-sessions/binarySession.test.ts --project composition` — 42 passed, 1 pre-existing Windows symlink failure (`EPERM`), identical with the change stashed. - `npx vitest run tests/boundary/mcp/sessionMcp.test.ts --project mcp-boundary` — 8 passed, 1 pre-existing timeout, identical with the change stashed. - `npx oxlint` and `npx oxfmt --check` on the three changed files — 0 errors, format clean. ## Compatibility, safety, and release - Breaking changes or migration steps: none. `starting` is an added value on an output enum; existing values and input contracts are unchanged. Clients that switch exhaustively on the previous set should handle the new value, which the change documents here. - Real Hopper/Ghidra, browser, or OS coverage: no real Hopper engine was run; the change is verified with a controlled launcher at the adapter boundary. A real macOS Hopper check remains a gap. - Package or release metadata impact: the generated MCP catalog reflects the new enum value; no package or installation change. - Security, privacy, process, or containment review: no target execution, injection, mutation, network, or filesystem change. The state is derived from existing in-process startup bookkeeping. ## Author readiness Human owner: @DeryFerd - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [ ] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [ ] The PR has one focused outcome and the title follows `type(scope): outcome`. - [ ] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [ ] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:12:09 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6139
No description provided.