[PR #4130] [CLOSED] fix(batch): report a provider's null pseudocode as unavailable, not unreadable #6075

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

📋 Pull Request Information

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

Base: main ← Head: fix/batch-decompile-null-pseudocode


📝 Commits (1)

  • 528da7c fix(batch): report a provider's null pseudocode as unavailable, not unreadable

📊 Changes

2 files changed (+83 additions, -27 deletions)

View changed files

📝 src/application/EnhancedTools.ts (+42 -27)
📝 tests/boundary/mcp/enhancedTools.callPathsAndBatches.test.ts (+41 -0)

📄 Description

Summary

procedure_pseudo_code's output contract is nullableText. A provider returns null to say a procedure has no pseudocode: Kuna does so for an import slot, and for a function its export failed to decompile. batch_decompile treated that null like malformed output. It reported unreadable_output with "Analysis returned an unreadable result. Run rea doctor and review the reported details; repeating the unchanged request is not expected to succeed." and the reason "provider returned empty pseudocode". The provider's actual reason was in the batch limitations, but the item told the agent to diagnose REA. Refs #1957.

Problem and expected behavior

Real Kuna 1.833, warm export of a small arm64 test program (odd), main e598b4656:

batch_decompile {"addresses": ["0x100004000", "0x10000050c"]}   (printf's import slot, _main)
  0x100004000 status=error code=unreadable_output "Analysis returned an unreadable result. Run `rea doctor` …"
  batch limitations include: "Kuna (kuna 1.833) procedure_pseudo_code: Kuna's export decompiles code entries only; this inventory entry, such as an import slot, has no body."

procedure_pseudo_code alone returns null with that limitation, which is correct. Expected: the batch item says the provider has no pseudocode for this procedure, without calling it unreadable output.

Change and scope

  • #batchPseudocode observes the full execution (#observe instead of #call, the same call path) and builds each item through a new pure batchPseudocodeItem. Its early returns replace a nested ternary.
  • A null result becomes an error item with code: capability_unavailable, retryable: false and the message "The provider reports no pseudocode for this procedure; the batch limitations for procedure_pseudo_code say why." The reason is not copied per item, because the batch limitations already carry it.
  • An empty string or another non-string value stays unreadable_output, as before.

This is generic batch_decompile behavior, so it applies to any provider that returns null; Kuna is the case observed here. The batch output schema is unchanged (items stay ok | error).

Not included: a separate item status for "no pseudocode", which would change the published output schema.

Scope: an ordinary fix within existing tool contracts; no maintainer scope decision applies.

Contract and boundary impact

  • Semantic owner and earliest changed stage: EnhancedTools batch item construction (application workflow).
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: no schema change. A null-pseudocode item's error code changes from unreadable_output to capability_unavailable; retryable stays false.
  • Provider, bridge, target-format, or platform compatibility: any provider that returns null pseudocode.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged. Limitations are aggregated as before.
  • Target selection, authority, upstream behavior, and cleanup details: none.
  • 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: enhancedTools.callPathsAndBatches.test.ts gets "reports a provider's null pseudocode as unavailable, not unreadable". A null item becomes capability_unavailable with the message above and retryable: false, and an empty-string item stays unreadable_output.

  • Base reproduction: the new test fails on the base revision (git stash of src/application).

  • Real Kuna 1.833, same batch as above, after the fix:

    0x100004000 error capability_unavailable "The provider reports no pseudocode for this procedure; the batch limitations for procedure_pseudo_code say why."
    0x10000050c ok
    limitations: ["Kuna (kuna 1.833) procedure_pseudo_code: Kuna's export decompiles code entries only; this inventory entry, such as an import slot, has no body."]
    
  • Remaining proof gaps: no other real provider was run; Hopper, Ghidra and IDA behavior for null is covered only by the shared code path.

  • 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

  • npm run test:focused -- on every test file that exercises batch_decompile (EnhancedToolSelectorOrigin, WorkflowEvidence, IDA selectorProvenance, enhancedTools.callPathsAndBatches, enhancedTools.01-lists-the-complete-target-open, serverWorkflowMcp, ghidraRoutingMcp, targetContentProvenance): 69 passed in 8 files.
  • npm run test:focused -- tests/boundary/providers/kuna/*.test.ts: 189 passed three times. One earlier run hit a single failure in the untouched cache test "preserves concurrent results and reclaims capacity (pin: true)". It has now been seen intermittently twice under full-suite load and passed alone and on re-runs, and I could not capture its cause.
  • New test on the base revision: failed.
  • npm run check:fast: typecheck and lint passed.
  • Real Kuna batch above.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; only the error code and message for null items change.
  • Real Hopper/Ghidra, browser, or OS coverage: real Kuna on macOS arm64 only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none.

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/4130 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/batch-decompile-null-pseudocode` --- ### 📝 Commits (1) - [`528da7c`](https://github.com/morluto/rea/commit/528da7cc31d694f668b4db867e2f398e84b2c08d) fix(batch): report a provider's null pseudocode as unavailable, not unreadable ### 📊 Changes **2 files changed** (+83 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `src/application/EnhancedTools.ts` (+42 -27) 📝 `tests/boundary/mcp/enhancedTools.callPathsAndBatches.test.ts` (+41 -0) </details> ### 📄 Description ## Summary `procedure_pseudo_code`'s output contract is `nullableText`. A provider returns `null` to say a procedure has no pseudocode: Kuna does so for an import slot, and for a function its export failed to decompile. `batch_decompile` treated that `null` like malformed output. It reported `unreadable_output` with "Analysis returned an unreadable result. Run `rea doctor` and review the reported details; repeating the unchanged request is not expected to succeed." and the reason "provider returned empty pseudocode". The provider's actual reason was in the batch limitations, but the item told the agent to diagnose REA. Refs #1957. ## Problem and expected behavior Real Kuna 1.833, warm export of a small arm64 test program (`odd`), main e598b4656: ``` batch_decompile {"addresses": ["0x100004000", "0x10000050c"]} (printf's import slot, _main) 0x100004000 status=error code=unreadable_output "Analysis returned an unreadable result. Run `rea doctor` …" batch limitations include: "Kuna (kuna 1.833) procedure_pseudo_code: Kuna's export decompiles code entries only; this inventory entry, such as an import slot, has no body." ``` `procedure_pseudo_code` alone returns `null` with that limitation, which is correct. Expected: the batch item says the provider has no pseudocode for this procedure, without calling it unreadable output. ## Change and scope - `#batchPseudocode` observes the full execution (`#observe` instead of `#call`, the same call path) and builds each item through a new pure `batchPseudocodeItem`. Its early returns replace a nested ternary. - A `null` result becomes an error item with `code: capability_unavailable`, `retryable: false` and the message "The provider reports no pseudocode for this procedure; the batch limitations for procedure_pseudo_code say why." The reason is not copied per item, because the batch limitations already carry it. - An empty string or another non-string value stays `unreadable_output`, as before. This is generic `batch_decompile` behavior, so it applies to any provider that returns `null`; Kuna is the case observed here. The batch output schema is unchanged (items stay `ok` | `error`). Not included: a separate item status for "no pseudocode", which would change the published output schema. Scope: an ordinary fix within existing tool contracts; no maintainer scope decision applies. ## Contract and boundary impact - Semantic owner and earliest changed stage: `EnhancedTools` batch item construction (application workflow). - Contribution scope fit and linked maintainer decision: not applicable. - CLI and MCP/tool-catalog contract: no schema change. A null-pseudocode item's error code changes from `unreadable_output` to `capability_unavailable`; `retryable` stays false. - Provider, bridge, target-format, or platform compatibility: any provider that returns `null` pseudocode. - Evidence, artifact, provenance, or reconstruction contract: unchanged. Limitations are aggregated as before. - Target selection, authority, upstream behavior, and cleanup details: none. - 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. - [x] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `enhancedTools.callPathsAndBatches.test.ts` gets "reports a provider's null pseudocode as unavailable, not unreadable". A `null` item becomes `capability_unavailable` with the message above and `retryable: false`, and an empty-string item stays `unreadable_output`. - Base reproduction: the new test fails on the base revision (`git stash` of `src/application`). - Real Kuna 1.833, same batch as above, after the fix: ``` 0x100004000 error capability_unavailable "The provider reports no pseudocode for this procedure; the batch limitations for procedure_pseudo_code say why." 0x10000050c ok limitations: ["Kuna (kuna 1.833) procedure_pseudo_code: Kuna's export decompiles code entries only; this inventory entry, such as an import slot, has no body."] ``` - Remaining proof gaps: no other real provider was run; Hopper, Ghidra and IDA behavior for `null` is covered only by the shared code path. - [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 - `npm run test:focused --` on every test file that exercises `batch_decompile` (`EnhancedToolSelectorOrigin`, `WorkflowEvidence`, IDA `selectorProvenance`, `enhancedTools.callPathsAndBatches`, `enhancedTools.01-lists-the-complete-target-open`, `serverWorkflowMcp`, `ghidraRoutingMcp`, `targetContentProvenance`): 69 passed in 8 files. - `npm run test:focused -- tests/boundary/providers/kuna/*.test.ts`: 189 passed three times. One earlier run hit a single failure in the untouched cache test "preserves concurrent results and reclaims capacity (pin: true)". It has now been seen intermittently twice under full-suite load and passed alone and on re-runs, and I could not capture its cause. - New test on the base revision: failed. - `npm run check:fast`: typecheck and lint passed. - Real Kuna batch above. ## Compatibility, safety, and release - Breaking changes or migration steps: none; only the error code and message for null items change. - Real Hopper/Ghidra, browser, or OS coverage: real Kuna on macOS arm64 only. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none. ## 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:11:39 +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#6075
No description provided.