[GH-ISSUE #7276] [Bug] inspect-native-data-type reports target_unavailable for an invalid selector #4320

Open
opened 2026-10-31 00:48:53 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @coygeek on GitHub (Oct 26, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/7276

Before submitting

  • I searched the open and closed issues for a related report.
  • I removed credentials, tokens, private paths, and sensitive target data.

Area

CLI

Observed behavior

The registered inspect-native-data-type CLI attempts to open the target when neither --type nor --address is supplied, when both are supplied, and when the supplied selector is empty. Missing or plain text targets produce target_unavailable instead of the selector input error. This was reproduced through the production CLI builder and dispatcher, without mocked handlers or a live analysis provider.

Reproduction

  1. Use the source baseline and runtime under REA version and Runtime and platform, with its locked dependencies installed. Select a fresh, empty home directory for the probe with export HOME="$(mktemp -d)". No analysis provider or device is needed.
  2. Save the following disposable test as tests/boundary/cli/nativeDataTypeAdmissionProbe.test.ts. This is a compact version of the executed in-process probe: it invokes the real registered CLI and handlers without mocks.
import { mkdir, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { it } from "vitest";
import { createCli } from "../../../src/cli.js";
import { nativeDataTypeInputSchema } from "../../../src/domain/native/nativeDataType.js";

it("prints native type selector admission", async () => {
  const home = process.env.HOME!;
  await mkdir(home, { recursive: true });
  const missing = join(home, "missing.bin");
  const plain = join(home, "plain.bin");
  await writeFile(plain, "This is a plain text file.\n");
  const cases = [
    ["missing-none", missing, {}, []],
    ["missing-both", missing, { type: "Struct", address: "0x1000" }, ["--type", "Struct", "--address", "0x1000"]],
    ["plain-none", plain, {}, []],
    ["plain-both", plain, { type: "Struct", address: "0x1000" }, ["--type", "Struct", "--address", "0x1000"]],
    ["missing-empty-type", missing, { type: "" }, ["--type", ""]],
    ["missing-empty-address", missing, { address: "" }, ["--address", ""]],
    ["missing-type-control", missing, { type: "Struct" }, ["--type", "Struct"]],
    ["missing-address-control", missing, { address: "0x1000" }, ["--address", "0x1000"]],
  ] as const;
  for (const [name, path, selectors, flags] of cases) {
    let stdout = "";
    await createCli({ HOME: home, REA_LOG_LEVEL: "silent" }).serve(
      ["inspect-native-data-type", path, ...flags, "--json"],
      { env: {}, stdout: text => { stdout += text; }, exit: () => {} },
    );
    const { code, category } = JSON.parse(stdout);
    console.log(JSON.stringify({ name, canonicalAccepted: nativeDataTypeInputSchema.safeParse(selectors).success, code, category }));
  }
});
  1. Run npx --no-install vitest run tests/boundary/cli/nativeDataTypeAdmissionProbe.test.ts from the checkout root. The direct Vitest command is necessary because the source-test wrapper refuses this built-project test path; no artifact build is needed for this probe.
  2. Compare the printed canonical admission result with the CLI error code, then remove the disposable test. The six malformed cases each reproduced once; the two controls were each run once.

Expected behavior

Require exactly one nonempty --type or --address selector and reject an invalid selector combination before accessing the target. Return an input diagnostic, with correction information about the selector choice, even when the supplied target is absent or unsupported.

Expected source: docs/tool-design.md:339-350 requires aggregate CLI admission before target access and caller correction metadata; src/domain/native/nativeDataType.ts:5-14 defines exactly one nonempty selector, bound to the operation by src/contracts/officialToolContracts.ts:57-60.

Impact and scope

P2: malformed requests receive a target error and target-specific remediation that hides the independent selector problem. This is a bounded CLI admission defect, reproduced in all six malformed cases tested, not a demonstrated failure of valid type analysis. The controls verify that exactly one nonempty selector passes the canonical schema and reaches target loading. Supplying one such selector avoids this admission defect; successful native analysis and real-provider startup costs were not tested.

REA version

615fbbbdd7 (package.json version 6.8.0)

Runtime and platform

Node.js v26.12.1 on macOS arm64, using the checkout dependencies and Vitest 5.0.3 with an isolated home directory. No Ghidra, IDA, Hopper, device, or live target API was used.

Target and artifact context

A nonexistent local file and a regular file containing only This is a plain text file. followed by a newline. No executable or private target data is needed.

Interface

CLI

Earliest failure stage

Request parsing or validation

Relevant output or evidence

The focused registered CLI test executed eight calls once each and produced:

Case Canonical schema accepts CLI code CLI category
Missing file, neither selector false target_unavailable unavailable
Missing file, both selectors false target_unavailable unavailable
Plain text file, neither selector false target_unavailable unsupported_target
Plain text file, both selectors false target_unavailable unsupported_target
Missing file, empty type false target_unavailable unavailable
Missing file, empty address false target_unavailable unavailable
Missing file, type only true target_unavailable unavailable
Missing file, address only true target_unavailable unavailable

All malformed cases lacked invalid_request; the missing-file cases reported that the target does not exist, while the text-file cases reported Cannot open artifact: unsupported binary format. The canonical schema check independently rejected the six malformed selector objects and accepted both controls. The in-process callback does not establish the executable's process exit status.

Failure source: src/cli/coreNativeCommands.ts:226-250 forwards the optional selectors without aggregate admission; src/application/DirectAnalysis.ts:441-455 opens the target before executing the operation. Runtime evidence establishes the registered CLI reachability and incorrect error precedence; valid-target ordering is source-derived and provider startup cost was not measured.

Typed outcome or recovery expected

The six malformed cases should return invalid_request with actionable selector correction information before target access. Both single-selector controls should remain accepted and report target_unavailable for the missing file, distinguishing proper selector admission from unconditional rejection.

Additional context

Closed #492 introduced the type-inspection capability. Closed #3327 concerned metadata missing for equivalent accepted addresses; this report concerns invalid selector admission before target access. Searches of open and closed issues found no matching report of this admission-order failure.

Originally created by @coygeek on GitHub (Oct 26, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/7276 ### Before submitting - [x] I searched the open and closed issues for a related report. - [x] I removed credentials, tokens, private paths, and sensitive target data. ### Area CLI ### Observed behavior The registered `inspect-native-data-type` CLI attempts to open the target when neither `--type` nor `--address` is supplied, when both are supplied, and when the supplied selector is empty. Missing or plain text targets produce `target_unavailable` instead of the selector input error. This was reproduced through the production CLI builder and dispatcher, without mocked handlers or a live analysis provider. ### Reproduction 1. Use the source baseline and runtime under REA version and Runtime and platform, with its locked dependencies installed. Select a fresh, empty home directory for the probe with `export HOME="$(mktemp -d)"`. No analysis provider or device is needed. 2. Save the following disposable test as `tests/boundary/cli/nativeDataTypeAdmissionProbe.test.ts`. This is a compact version of the executed in-process probe: it invokes the real registered CLI and handlers without mocks. ```ts import { mkdir, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { it } from "vitest"; import { createCli } from "../../../src/cli.js"; import { nativeDataTypeInputSchema } from "../../../src/domain/native/nativeDataType.js"; it("prints native type selector admission", async () => { const home = process.env.HOME!; await mkdir(home, { recursive: true }); const missing = join(home, "missing.bin"); const plain = join(home, "plain.bin"); await writeFile(plain, "This is a plain text file.\n"); const cases = [ ["missing-none", missing, {}, []], ["missing-both", missing, { type: "Struct", address: "0x1000" }, ["--type", "Struct", "--address", "0x1000"]], ["plain-none", plain, {}, []], ["plain-both", plain, { type: "Struct", address: "0x1000" }, ["--type", "Struct", "--address", "0x1000"]], ["missing-empty-type", missing, { type: "" }, ["--type", ""]], ["missing-empty-address", missing, { address: "" }, ["--address", ""]], ["missing-type-control", missing, { type: "Struct" }, ["--type", "Struct"]], ["missing-address-control", missing, { address: "0x1000" }, ["--address", "0x1000"]], ] as const; for (const [name, path, selectors, flags] of cases) { let stdout = ""; await createCli({ HOME: home, REA_LOG_LEVEL: "silent" }).serve( ["inspect-native-data-type", path, ...flags, "--json"], { env: {}, stdout: text => { stdout += text; }, exit: () => {} }, ); const { code, category } = JSON.parse(stdout); console.log(JSON.stringify({ name, canonicalAccepted: nativeDataTypeInputSchema.safeParse(selectors).success, code, category })); } }); ``` 3. Run `npx --no-install vitest run tests/boundary/cli/nativeDataTypeAdmissionProbe.test.ts` from the checkout root. The direct Vitest command is necessary because the source-test wrapper refuses this built-project test path; no artifact build is needed for this probe. 4. Compare the printed canonical admission result with the CLI error code, then remove the disposable test. The six malformed cases each reproduced once; the two controls were each run once. ### Expected behavior Require exactly one nonempty `--type` or `--address` selector and reject an invalid selector combination before accessing the target. Return an input diagnostic, with correction information about the selector choice, even when the supplied target is absent or unsupported. Expected source: `docs/tool-design.md:339-350` requires aggregate CLI admission before target access and caller correction metadata; `src/domain/native/nativeDataType.ts:5-14` defines exactly one nonempty selector, bound to the operation by `src/contracts/officialToolContracts.ts:57-60`. ### Impact and scope P2: malformed requests receive a target error and target-specific remediation that hides the independent selector problem. This is a bounded CLI admission defect, reproduced in all six malformed cases tested, not a demonstrated failure of valid type analysis. The controls verify that exactly one nonempty selector passes the canonical schema and reaches target loading. Supplying one such selector avoids this admission defect; successful native analysis and real-provider startup costs were not tested. ### REA version 615fbbbdd750de2df5d92b9827d0c7c4422c1d03 (package.json version 6.8.0) ### Runtime and platform Node.js v26.12.1 on macOS arm64, using the checkout dependencies and Vitest 5.0.3 with an isolated home directory. No Ghidra, IDA, Hopper, device, or live target API was used. ### Target and artifact context A nonexistent local file and a regular file containing only `This is a plain text file.` followed by a newline. No executable or private target data is needed. ### Interface CLI ### Earliest failure stage Request parsing or validation ### Relevant output or evidence The focused registered CLI test executed eight calls once each and produced: | Case | Canonical schema accepts | CLI code | CLI category | | --- | --- | --- | --- | | Missing file, neither selector | false | target_unavailable | unavailable | | Missing file, both selectors | false | target_unavailable | unavailable | | Plain text file, neither selector | false | target_unavailable | unsupported_target | | Plain text file, both selectors | false | target_unavailable | unsupported_target | | Missing file, empty type | false | target_unavailable | unavailable | | Missing file, empty address | false | target_unavailable | unavailable | | Missing file, type only | true | target_unavailable | unavailable | | Missing file, address only | true | target_unavailable | unavailable | All malformed cases lacked `invalid_request`; the missing-file cases reported that the target does not exist, while the text-file cases reported `Cannot open artifact: unsupported binary format.` The canonical schema check independently rejected the six malformed selector objects and accepted both controls. The in-process callback does not establish the executable's process exit status. Failure source: `src/cli/coreNativeCommands.ts:226-250` forwards the optional selectors without aggregate admission; `src/application/DirectAnalysis.ts:441-455` opens the target before executing the operation. Runtime evidence establishes the registered CLI reachability and incorrect error precedence; valid-target ordering is source-derived and provider startup cost was not measured. ### Typed outcome or recovery expected The six malformed cases should return `invalid_request` with actionable selector correction information before target access. Both single-selector controls should remain accepted and report `target_unavailable` for the missing file, distinguishing proper selector admission from unconditional rejection. ### Additional context Closed [#492](https://github.com/morluto/rea/issues/492) introduced the type-inspection capability. Closed [#3327](https://github.com/morluto/rea/issues/3327) concerned metadata missing for equivalent accepted addresses; this report concerns invalid selector admission before target access. Searches of open and closed issues found no matching report of this admission-order failure.
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#4320
No description provided.