[PR #4699] [CLOSED] fix(kuna): resolve retained process failures once their owner releases #6364

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4699
Author: @kaoru0822-kitauji
Created: 10/17/2026
Status: ❌ Closed

Base: main ← Head: fix/kuna-caller-cleanup-ownership


📝 Commits (1)

  • 34b6c73 fix(kuna): resolve retained process failures once their owner releases

📊 Changes

2 files changed (+24 additions, -1 deletions)

View changed files

📝 src/kuna/KunaTargetCommands.ts (+6 -0)
📝 tests/boundary/providers/kuna/kunaStrings.test.ts (+18 -1)

📄 Description

Summary

Refs #4693. The caller-copy half of #4693 landed on main in 6eb55be4e. This PR covers the producer half on the same ownership path.

After a confirmed supervisor stop and a successful close(), a retained Kuna process failure never cleared. KunaTargetCommands dropped the failure from its retry list without resolving it. With 6eb55be4e binding caller copies to their producer, that left both the producer and every caller copy (for example list_strings waiting on the shared kuna:strings scan) reporting cleanupIncomplete: true and stale resources indefinitely.

Problem and expected behavior

Root cause: KunaTargetCommands.close() retries each retained process owner. On a confirmed stop it releases the run slot and splices the entry out of #retained, but it never calls resolveCleanup() on the retained ProviderCleanupError. Nothing else holds that error, so its live cleanup marker can never clear.

Expected: the retained failure stays incomplete until its owner confirms release, then clears, and everything bound to it clears too.

Change and scope

Stopped failures move to #stopped. Each retained error names both its process resources and request.workspace. Once every workspace root has closed, the stopped failures are resolved. If a root close fails, they stay unresolved and the root failure is reported as before, so a later close() retry resolves them.

Not included: no change to the caller-remapping helper (already fixed on main) or to any other Kuna owner.

Contract and boundary impact

  • Semantic owner and earliest changed stage: KunaTargetCommands (Kuna command cleanup owner).
  • Contribution scope fit and linked maintainer decision: not applicable; ordinary fix within existing boundaries.
  • CLI and MCP/tool-catalog contract: none.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details: cleanup status reporting only; no new cleanup actions.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • 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/kuna/kunaStrings.test.ts, "retains metadata admission until a string process stop is proven". It drives the public session client through a real hung fake-Kuna strings child with an unproven-stop launcher. It now asserts:
    • the list_strings error is a caller copy (operation list_strings, producer_operation: "kuna:strings") and is incomplete while the stop is unproven;
    • after the stop is released and close() returns ok, both the copy and its producer cause read cleanupIncomplete: false.
  • Base reproduction: on main 54c71313a (which includes 6eb55be4e) with only the test change, the final assertion fails: received cleanupIncomplete: true. With this change it passes.
  • Remaining proof gaps: no real Kuna engine. The failed-root-close retry path is reasoned from source, not exercised by a test. Windows is skipped by the existing test guard.

Validation performed

  • npm run test:focused -- tests/boundary/providers/kuna/kunaStrings.test.ts tests/boundary/providers/kuna/kunaQueryErrors.test.ts: 27 passed.
  • The same strings test with KunaTargetCommands.ts reverted to main: 1 failed (the new final assertion).
  • npm run test:focused -- tests/boundary/providers/kuna/*.test.ts: 256 passed, 3 failed. The failures are kunaReferences.test.ts "does not cache an unusable graph: not-json / miscounted / with-bodies": they expect operation: "kuna:call-graph" but receive procedure_callees. They fail the same way on unchanged main 54c71313a, so they are not caused by this PR; they appear to follow from main's caller-attribution change.
  • npm run check:fast (typecheck and lint): passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS arm64, Node 26.5.0 (the repo pins 24.18.0), simulated Kuna only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: status-only change; no new process, file or network actions.

Author readiness

Human owner:

  • 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.

🤖 Generated with Claude Code


🔄 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/4699 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/kuna-caller-cleanup-ownership` --- ### 📝 Commits (1) - [`34b6c73`](https://github.com/morluto/rea/commit/34b6c73b83324db8739606e6d276ea4463dc28f0) fix(kuna): resolve retained process failures once their owner releases ### 📊 Changes **2 files changed** (+24 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/kuna/KunaTargetCommands.ts` (+6 -0) 📝 `tests/boundary/providers/kuna/kunaStrings.test.ts` (+18 -1) </details> ### 📄 Description ## Summary Refs #4693. The caller-copy half of #4693 landed on main in 6eb55be4e. This PR covers the producer half on the same ownership path. After a confirmed supervisor stop and a successful `close()`, a retained Kuna process failure never cleared. `KunaTargetCommands` dropped the failure from its retry list without resolving it. With 6eb55be4e binding caller copies to their producer, that left both the producer and every caller copy (for example `list_strings` waiting on the shared `kuna:strings` scan) reporting `cleanupIncomplete: true` and stale resources indefinitely. ## Problem and expected behavior Root cause: `KunaTargetCommands.close()` retries each retained process owner. On a confirmed stop it releases the run slot and splices the entry out of `#retained`, but it never calls `resolveCleanup()` on the retained `ProviderCleanupError`. Nothing else holds that error, so its live cleanup marker can never clear. Expected: the retained failure stays incomplete until its owner confirms release, then clears, and everything bound to it clears too. ## Change and scope Stopped failures move to `#stopped`. Each retained error names both its process resources and `request.workspace`. Once every workspace root has closed, the stopped failures are resolved. If a root close fails, they stay unresolved and the root failure is reported as before, so a later `close()` retry resolves them. Not included: no change to the caller-remapping helper (already fixed on main) or to any other Kuna owner. ## Contract and boundary impact - Semantic owner and earliest changed stage: `KunaTargetCommands` (Kuna command cleanup owner). - Contribution scope fit and linked maintainer decision: not applicable; ordinary fix within existing boundaries. - CLI and MCP/tool-catalog contract: none. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details: cleanup status reporting only; no new cleanup actions. - Generated metadata, package, or installation impact: none. Expected effects: - [ ] 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/kuna/kunaStrings.test.ts`, "retains metadata admission until a string process stop is proven". It drives the public session client through a real hung fake-Kuna `strings` child with an unproven-stop launcher. It now asserts: - the `list_strings` error is a caller copy (operation `list_strings`, `producer_operation: "kuna:strings"`) and is incomplete while the stop is unproven; - after the stop is released and `close()` returns ok, both the copy and its producer cause read `cleanupIncomplete: false`. - Base reproduction: on main 54c71313a (which includes 6eb55be4e) with only the test change, the final assertion fails: received `cleanupIncomplete: true`. With this change it passes. - Remaining proof gaps: no real Kuna engine. The failed-root-close retry path is reasoned from source, not exercised by a test. Windows is skipped by the existing test guard. ## Validation performed - `npm run test:focused -- tests/boundary/providers/kuna/kunaStrings.test.ts tests/boundary/providers/kuna/kunaQueryErrors.test.ts`: 27 passed. - The same strings test with `KunaTargetCommands.ts` reverted to main: 1 failed (the new final assertion). - `npm run test:focused -- tests/boundary/providers/kuna/*.test.ts`: 256 passed, 3 failed. The failures are `kunaReferences.test.ts` "does not cache an unusable graph: not-json / miscounted / with-bodies": they expect `operation: "kuna:call-graph"` but receive `procedure_callees`. They fail the same way on unchanged main 54c71313a, so they are not caused by this PR; they appear to follow from main's caller-attribution change. - `npm run check:fast` (typecheck and lint): passed. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: macOS arm64, Node 26.5.0 (the repo pins 24.18.0), simulated Kuna only. - Package or release metadata impact: none. - Security, privacy, process, or containment review: status-only change; no new process, file or network actions. ## Author readiness Human owner: <!-- @GitHub-handle --> - [ ] 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. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:13:53 +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#6364
No description provided.