[PR #5241] [MERGED] fix(doctor): propagate cancellation to Kuna inspection #6833

Closed
opened 2026-11-01 21:43:22 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5241
Author: @maxazure
Created: 10/19/2026
Status: ✅ Merged
Merged: 10/20/2026
Merged by: @gensokyo-dev

Base: main ← Head: fix/kuna-doctor-cancellation-5106


📝 Commits (5)

  • c487b58 fix(doctor): propagate cancellation to Kuna inspection
  • 9fcbbbf chore: refresh Kuna doctor cancellation against main
  • b8a646f fix(doctor): project Kuna probe cancellation at the adapter
  • cd3049d fix(kuna): retain observed installation facts on cancellation
  • a123f0b fix(kuna): preserve first failures and facts across cleanup retries

📊 Changes

12 files changed (+569 additions, -55 deletions)

View changed files

📝 docs/kuna-provider.md (+8 -0)
📝 src/doctorRuntime.ts (+1 -0)
📝 src/kuna/KunaCommand.ts (+10 -6)
📝 src/kuna/KunaDoctor.ts (+18 -2)
📝 src/kuna/KunaInstallation.ts (+92 -7)
📝 src/kuna/KunaProvider.ts (+4 -5)
📝 src/kuna/KunaSessionClient.ts (+4 -5)
📝 tests/boundary/cli/doctorCancellation.test.ts (+55 -23)
📝 tests/boundary/providers/kuna/kunaDoctor.test.ts (+113 -1)
📝 tests/boundary/providers/kuna/kunaHashOwnerPropagation.test.ts (+148 -2)
📝 tests/boundary/providers/kuna/kunaInstallation.test.ts (+111 -1)
📝 tests/boundary/providers/kuna/kunaInstallationLifetime.test.ts (+5 -3)

📄 Description

Summary

Fixes #5106. Cancelling or closing doctor now reaches the Kuna installation probe, waits for it to stop, and surfaces the shared cancelled outcome with the caller's exact reason. Public CLI interrupts retain exits 130/143.

Forwarding the signal alone exposed a second boundary defect: the installation inspector's regular-file cancellation escaped as UNKNOWN / exit 1. Normalize cancellation at the doctor adapter and preserve completed installation observations at their producer. Doctor, profile and health consume one shared accessor; physical/cleanup failures keep their existing resource owners. The original contribution by @maxazure remains in this branch; the final adapter correction and CLI verification were added during maintainer qualification.

Contract and scope

Existing read-only readiness operation; additional maintainer scope decision is not applicable. The system doctor owns its combined caller/close signal; Kuna installation owns probe cancellation and joined cleanup; Kuna doctor projects those facts into the application error contract. No new process authority, provider capability, schemas, catalog, installer or cache. The installation owner classifies recorded process outcomes instead of guessing from a later signal. Error-keyed weak annotations preserve completed facts without replacing the exact failure or its cleanup owner; their lifetime follows that error, without retaining a global analysis cache. Completed facts are returned in typed errors at details.diagnostics.kuna_installation (doctor cleanup checks use details.kuna_installation) with status: "partial", selected command, canonical executable, version, completed hash, and script state when observed. Omitted facts remain unknown; these diagnostics do not admit the installation.

Executed evidence

Linux, pinned Node 24.18.0 / npm 11.16.0:

  • Base without signal propagation: 2 regression failures, caller cancellation and host closure both still pending at the 2-s check. Signal-only compiled patch: 2 public CLI regression failures, UNKNOWN instead of cancelled.
  • Final npm run test:focused -- Kuna doctor/installation/cancellation/lifetime/hash-owner tests, doctor composition/lifecycle, and tests/boundary/cli/doctorCancellation.test.ts: 75 tests passed across 8 files. Covers SIGINT/SIGTERM, signal-ignoring probes, exact reasons, pre-aborted callers, healthy controls and joined cleanup. Existing JADX and retained-owner checks remain covered. Producer-boundary cases cover doctor/profile/health × fingerprint/shebang close × successful/refused close. They independently verify digests, exact reasons, alias paths, unknown omission, JSON projection, retained descriptors and retry cleanup. Eight additional regressions failed before the latest review correction and pass after it: six close-refusal cases, timeout-before-abort, and lookup-failure-before-abort. Already-aborted lookup admission is separately covered.
  • Public CLI timeout-first check: a signal-ignoring probe acknowledged the real default 10,000-ms deadline before CLI SIGINT. The provider report retained version_unresolved, deadline_ms: 10000, and killed: true; conventional CLI signal exit remained 130. Joined cleanup verified.
  • Four additional real-artifact file-boundary checks use the official Kuna executable and actual version/hash reads with injected descriptor interruption/refusal. Independently pinned digest and ELF script: false survive where observed, and exact retained owners close on retry.
  • Public compiled CLI, controlled blocked probe: baseline still pending 250 ms after SIGINT and required fixture release; final stopped before release and exited 130 with cancelled in 80.0 ms after interruption.
  • Public CLI with the official Kuna 1.833 Linux x86_64 artifact: healthy doctor / exit 0 on both revisions. Returned version and executable SHA-256 match the downloaded binary (f9f088a2bd99d9b87f3c53195ba5b02678828ace6cc3a501acb42b1d483f6a39, 46,226,760 bytes); archive SHA-256 matches GitHub's published digest.
  • npm run docs:check: passed, including 5 README consistency tests.
  • Final npm run check: passed typecheck, formatting, lint, knip, metadata and module/architecture guards (existing lint warnings remain).

Resource and coverage limits

One CPU, 8-GiB hard / 7-GiB early cgroup limit, no swap. Completed interrupted-fixture + real-Kuna healthy CLI pair, baseline/final: 5.963/5.359 s elapsed, 5.250/4.984 s family CPU, 354.0/353.9 MiB peak; exit 0, owned processes cleared, no OOM. Fresh CLI processes, uncontrolled OS cache, single samples; no general speedup claim or measured ten-second baseline delay.

Output-only cl100k_base estimates for that pair: 5,334/2,708 tokens; cancelled reply 2,704/53 because cancelled inspection no longer finishes and emits a whole doctor report. CLI arguments, shell framing, earlier failed harness attempts and actual agent usage are unmeasured.

Blocking/interrupt behavior uses authored probes; the real Kuna control qualifies version/fingerprint readiness, not target decompilation or real-engine cancellation latency. Its loader emitted a weak GLIBC_2.39 warning while version probing exited 0. macOS/Windows and the full suite were not run locally. An initial CLI harness assumed the MCP error wrapper; it was corrected to the existing CLI contract. Initial expanded fixtures assumed a run-token group for Kuna's direct execFile probe; final tests preserve that distinction and retain a release gate for failure cleanup.

The legacy PR comparison was pinned to an old main revision and temporarily included inherited changes. Refreshing its base to current main corrected 485 files to the actual focused diff (12 files after the additional directly related review fixes); unrelated inherited-file findings are addressed as outside this PR.

Author readiness

Human owner: @gensokyo-dev

The task owner explicitly delegated validation, filling readiness, opening ready for review and merging selected fixes. The agent performed the final diff review and verification under that delegation; no separate human diff review or declaration by the original author is claimed.

  • 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

  • Focused existing-boundary fix; caller choices, ownership, cancellation and physical failures remain distinct.
  • Final diff checked for credentials and unrelated changes; generated/binary test artifacts remain outside the diff.
  • Final local check and final-head CI/review complete: a123f0bf8528c606f702c5bdb9e3385950ad5ac8, 18 successful / 18 skipped checks; Codex completed without findings; Greptile 5/5; no unresolved threads.

🔄 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/5241 **Author:** [@maxazure](https://github.com/maxazure) **Created:** 10/19/2026 **Status:** ✅ Merged **Merged:** 10/20/2026 **Merged by:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Base:** `main` ← **Head:** `fix/kuna-doctor-cancellation-5106` --- ### 📝 Commits (5) - [`c487b58`](https://github.com/morluto/rea/commit/c487b58057f9f6468ed1765c857c7591ea3ebe09) fix(doctor): propagate cancellation to Kuna inspection - [`9fcbbbf`](https://github.com/morluto/rea/commit/9fcbbbf3fc31da337b3418ff37de18c38c35d019) chore: refresh Kuna doctor cancellation against main - [`b8a646f`](https://github.com/morluto/rea/commit/b8a646f6839fabfb3f235d6778ab2498f60e5d05) fix(doctor): project Kuna probe cancellation at the adapter - [`cd3049d`](https://github.com/morluto/rea/commit/cd3049d076b712dd83eeb23944a9e3b0caa25c82) fix(kuna): retain observed installation facts on cancellation - [`a123f0b`](https://github.com/morluto/rea/commit/a123f0bf8528c606f702c5bdb9e3385950ad5ac8) fix(kuna): preserve first failures and facts across cleanup retries ### 📊 Changes **12 files changed** (+569 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `docs/kuna-provider.md` (+8 -0) 📝 `src/doctorRuntime.ts` (+1 -0) 📝 `src/kuna/KunaCommand.ts` (+10 -6) 📝 `src/kuna/KunaDoctor.ts` (+18 -2) 📝 `src/kuna/KunaInstallation.ts` (+92 -7) 📝 `src/kuna/KunaProvider.ts` (+4 -5) 📝 `src/kuna/KunaSessionClient.ts` (+4 -5) 📝 `tests/boundary/cli/doctorCancellation.test.ts` (+55 -23) 📝 `tests/boundary/providers/kuna/kunaDoctor.test.ts` (+113 -1) 📝 `tests/boundary/providers/kuna/kunaHashOwnerPropagation.test.ts` (+148 -2) 📝 `tests/boundary/providers/kuna/kunaInstallation.test.ts` (+111 -1) 📝 `tests/boundary/providers/kuna/kunaInstallationLifetime.test.ts` (+5 -3) </details> ### 📄 Description ## Summary Fixes #5106. Cancelling or closing doctor now reaches the Kuna installation probe, waits for it to stop, and surfaces the shared `cancelled` outcome with the caller's exact reason. Public CLI interrupts retain exits **130/143**. Forwarding the signal alone exposed a second boundary defect: the installation inspector's regular-file cancellation escaped as `UNKNOWN` / exit 1. Normalize cancellation at the doctor adapter and preserve completed installation observations at their producer. Doctor, profile and health consume one shared accessor; physical/cleanup failures keep their existing resource owners. The original contribution by @maxazure remains in this branch; the final adapter correction and CLI verification were added during maintainer qualification. ## Contract and scope Existing read-only readiness operation; additional maintainer scope decision is not applicable. The system doctor owns its combined caller/close signal; Kuna installation owns probe cancellation and joined cleanup; Kuna doctor projects those facts into the application error contract. No new process authority, provider capability, schemas, catalog, installer or cache. The installation owner classifies recorded process outcomes instead of guessing from a later signal. Error-keyed weak annotations preserve completed facts without replacing the exact failure or its cleanup owner; their lifetime follows that error, without retaining a global analysis cache. Completed facts are returned in typed errors at `details.diagnostics.kuna_installation` (doctor cleanup checks use `details.kuna_installation`) with `status: "partial"`, selected `command`, canonical `executable`, version, completed hash, and script state when observed. Omitted facts remain unknown; these diagnostics do not admit the installation. ## Executed evidence Linux, pinned Node 24.18.0 / npm 11.16.0: - Base without signal propagation: **2 regression failures**, caller cancellation and host closure both still pending at the 2-s check. Signal-only compiled patch: **2 public CLI regression failures**, `UNKNOWN` instead of `cancelled`. - Final `npm run test:focused --` Kuna doctor/installation/cancellation/lifetime/hash-owner tests, doctor composition/lifecycle, and `tests/boundary/cli/doctorCancellation.test.ts`: **75 tests passed across 8 files**. Covers SIGINT/SIGTERM, signal-ignoring probes, exact reasons, pre-aborted callers, healthy controls and joined cleanup. Existing JADX and retained-owner checks remain covered. Producer-boundary cases cover doctor/profile/health × fingerprint/shebang close × successful/refused close. They independently verify digests, exact reasons, alias paths, unknown omission, JSON projection, retained descriptors and retry cleanup. Eight additional regressions failed before the latest review correction and pass after it: six close-refusal cases, timeout-before-abort, and lookup-failure-before-abort. Already-aborted lookup admission is separately covered. - Public CLI timeout-first check: a signal-ignoring probe acknowledged the real default 10,000-ms deadline before CLI SIGINT. The provider report retained `version_unresolved`, `deadline_ms: 10000`, and `killed: true`; conventional CLI signal exit remained 130. Joined cleanup verified. - Four additional real-artifact file-boundary checks use the official Kuna executable and actual version/hash reads with injected descriptor interruption/refusal. Independently pinned digest and ELF `script: false` survive where observed, and exact retained owners close on retry. - Public compiled CLI, controlled blocked probe: baseline still pending 250 ms after SIGINT and required fixture release; final stopped before release and exited **130** with `cancelled` in **80.0 ms** after interruption. - Public CLI with the official [Kuna 1.833 Linux x86_64 artifact](https://github.com/Noelo-Lab/kuna/releases/download/v1.833/kuna-v1.833-linux-x86_64.tar.gz): healthy doctor / exit **0** on both revisions. Returned version and executable SHA-256 match the downloaded binary (`f9f088a2bd99d9b87f3c53195ba5b02678828ace6cc3a501acb42b1d483f6a39`, 46,226,760 bytes); archive SHA-256 matches GitHub's published digest. - `npm run docs:check`: passed, including **5** README consistency tests. - Final `npm run check`: passed typecheck, formatting, lint, knip, metadata and module/architecture guards (existing lint warnings remain). ## Resource and coverage limits One CPU, 8-GiB hard / 7-GiB early cgroup limit, no swap. Completed interrupted-fixture + real-Kuna healthy CLI pair, baseline/final: **5.963/5.359 s elapsed**, **5.250/4.984 s family CPU**, **354.0/353.9 MiB peak**; exit 0, owned processes cleared, no OOM. Fresh CLI processes, uncontrolled OS cache, single samples; no general speedup claim or measured ten-second baseline delay. Output-only `cl100k_base` estimates for that pair: **5,334/2,708** tokens; cancelled reply **2,704/53** because cancelled inspection no longer finishes and emits a whole doctor report. CLI arguments, shell framing, earlier failed harness attempts and actual agent usage are unmeasured. Blocking/interrupt behavior uses authored probes; the real Kuna control qualifies version/fingerprint readiness, not target decompilation or real-engine cancellation latency. Its loader emitted a weak `GLIBC_2.39` warning while version probing exited 0. macOS/Windows and the full suite were not run locally. An initial CLI harness assumed the MCP error wrapper; it was corrected to the existing CLI contract. Initial expanded fixtures assumed a run-token group for Kuna's direct execFile probe; final tests preserve that distinction and retain a release gate for failure cleanup. The legacy PR comparison was pinned to an old main revision and temporarily included inherited changes. Refreshing its base to current `main` corrected **485 files to the actual focused diff** (12 files after the additional directly related review fixes); unrelated inherited-file findings are addressed as outside this PR. ## Author readiness Human owner: @gensokyo-dev The task owner explicitly delegated validation, filling readiness, opening ready for review and merging selected fixes. The agent performed the final diff review and verification under that delegation; no separate human diff review or declaration by the original author is claimed. - [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 - [x] Focused existing-boundary fix; caller choices, ownership, cancellation and physical failures remain distinct. - [x] Final diff checked for credentials and unrelated changes; generated/binary test artifacts remain outside the diff. - [x] Final local check and final-head CI/review complete: `a123f0bf8528c606f702c5bdb9e3385950ad5ac8`, 18 successful / 18 skipped checks; Codex completed without findings; Greptile 5/5; no unresolved threads. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:43:22 +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#6833
No description provided.