[GH-ISSUE #5753] [Bug] Inspector target refusals hide attachment and runtime-role recovery behind doctor advice #3499

Closed
opened 2026-10-31 00:41:12 +00:00 by bsakaguchi · 2 comments
Owner

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

Before submitting

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

Area

Process capture or runtime observation

Observed behavior

observe-javascript-runtime correctly refuses a Node target requested as electron-renderer, and a target whose discovery explicitly reports attached: true. Both return byte-identical target_unavailable errors with details.reason: target_not_allowed and generic rea doctor advice. Neither the message nor structured details identifies which condition blocked observation or how to correct it.

An independent verifier reproduced both cases through the built CLI at the baseline below. The same real Node target succeeds with --runtime-kind node or with the role omitted. The attachment case uses a loopback discovery fixture, not a real competing debugger.

Reproduction

From the built source checkout with the repository-pinned Node.js on PATH, run this procedure. It starts an owned Node target and a discovery fixture, isolates REA state, and stops only its recorded process IDs. The verifier executed the equivalent isolated procedure once per case and retained the outputs described below.

work_dir="$(mktemp -d)"
mkdir -p "$work_dir"/{home,cfg,data,cache,state,tmp}
rea_local() {
  env -i PATH="$PATH" HOME="$work_dir/home" \
    XDG_CONFIG_HOME="$work_dir/cfg" XDG_DATA_HOME="$work_dir/data" \
    XDG_CACHE_HOME="$work_dir/cache" XDG_STATE_HOME="$work_dir/state" \
    TMPDIR="$work_dir/tmp" REA_LOG_LEVEL=silent \
    node scripts/rea.mjs "$@" --json
}
printf 'setInterval(() => {}, 1000);\n' > "$work_dir/app.mjs"
node --inspect=127.0.0.1:0 "$work_dir/app.mjs" > "$work_dir/app.log" 2>&1 &
app_pid=$!
endpoint_pid=""
cleanup() {
  if [ -n "$endpoint_pid" ]; then kill "$endpoint_pid"; wait "$endpoint_pid"; fi
  kill "$app_pid"
  wait "$app_pid"
}
trap cleanup EXIT
endpoint="$(python3 - "$work_dir/app.log" <<'PYTHON'
import pathlib, re, sys, time
for _ in range(100):
    match = re.search(r'ws://127.0.0.1:(\d+)/', pathlib.Path(sys.argv[1]).read_text())
    if match:
        print('http://127.0.0.1:' + match[1])
        break
    time.sleep(0.05)
else:
    raise SystemExit('Inspector did not start')
PYTHON
)"
rea_local list-javascript-runtime-targets "$endpoint" > "$work_dir/targets.json"
target="$(node -e 'console.log(require(process.argv[1]).normalized_result.targets[0].target_id)' "$work_dir/targets.json")"
rea_local observe-javascript-runtime "$endpoint" "$target" --runtime-kind electron-renderer
printf 'Role mismatch exit: %s\n' "$?"
rea_local observe-javascript-runtime "$endpoint" "$target" --runtime-kind node > "$work_dir/valid-node.json"
printf 'Matching role exit: %s\n' "$?"
rea_local observe-javascript-runtime "$endpoint" "$target" > "$work_dir/valid-omitted.json"
printf 'Omitted role exit: %s\n' "$?"
rea_local observe-javascript-runtime "$endpoint" no-such-target
printf 'Missing target exit: %s\n' "$?"

cat > "$work_dir/endpoint.mjs" <<'JS'
import http from 'node:http';
import fs from 'node:fs';
import { pathToFileURL } from 'node:url';
const server = http.createServer((req, res) => {
  res.setHeader('content-type', 'application/json');
  if (req.url === '/json/version') {
    res.end(JSON.stringify({ Browser: 'node.js/' + process.version, 'Protocol-Version': '1.1' }));
  } else if (req.url === '/json/list') {
    res.end(JSON.stringify([{
      id: 'attached-fixture', type: 'node', attached: true,
      url: pathToFileURL(process.argv[2]).href,
      webSocketDebuggerUrl: `ws://127.0.0.1:${server.address().port}/attached-fixture`
    }]));
  } else {
    res.statusCode = 404;
    res.end('{}');
  }
});
server.listen(0, '127.0.0.1', () => {
  fs.writeFileSync(process.argv[3], String(server.address().port));
});
JS
node "$work_dir/endpoint.mjs" "$work_dir/app.mjs" "$work_dir/port" > "$work_dir/endpoint.log" 2>&1 &
endpoint_pid=$!
port="$(python3 - "$work_dir/port" <<'PYTHON'
import pathlib, sys, time
for _ in range(100):
    path = pathlib.Path(sys.argv[1])
    if path.exists() and path.read_text():
        print(path.read_text())
        break
    time.sleep(0.05)
else:
    raise SystemExit('Fixture did not start')
PYTHON
)"
rea_local list-javascript-runtime-targets "http://127.0.0.1:$port" > "$work_dir/attached-list.json"
rea_local observe-javascript-runtime "http://127.0.0.1:$port" attached-fixture --runtime-kind node
printf 'Explicit attachment exit: %s\n' "$?"

Expected behavior

Keep both restrictions enforced. For a runtime-role mismatch, identify the supplied role and discovered protocol type and give applicable declaration guidance. For explicit attachment, identify the reported state and explain that the existing attachment must be released before retrying. Preserve meaningful failure reasons rather than direct both callers to host diagnosis.

The baseline's runtime observation guide defines these restrictions under target selection and Node/Electron roles. AGENTS.md, Architecture and Cleanup, requires meaningful failure reasons to survive projection. The canonical observe_javascript_runtime contract promises a presence and attachability recheck.

Impact and scope

P3: diagnostic wording and recovery guidance are wrong for these correctly refused inputs. The verifier observed no bypass or data loss. Discovery exposes protocol_type and attached; a matching or omitted role restored real Node observation. Releasing a real debugger attachment was not exercised. Production Electron attachment reporting, other platforms, and the MCP adapter were not tested.

REA version

rea-agents 6.7.0, verified source baseline 9d8e7803326a382cbbb3ffdb900f5e93e5442d68. Submission rechecked current main d0067ba34a39ea47dd7e11bb2e6169bc0938cc3f: no post-baseline commits changed the cited contract, guide, provider, or error-projection files. No new runtime reproduction on main was needed or performed.

Runtime and platform

Verifier runtime: repository-pinned Node.js v24.18.0. Submission host: macOS 27.0.1 arm64, with ambient Node.js v26.12.0; the pinned v24.18.0 executable is installed. No Hopper/Ghidra provider is involved.

Target and artifact context

Owned Node application containing setInterval(() => {}, 1000) with a literal-loopback Inspector endpoint. A separate owned loopback HTTP fixture reports a valid node target referencing that readable application file and explicitly sets attached: true. Ordinary Node discovery omits attachment state, so that fixture establishes explicit-boolean refusal behavior only.

Interface

CLI

Earliest failure stage

Transport or result projection

Relevant output or evidence

Both refused calls exit 1 with this identical JSON:

{"code":"target_unavailable","category":"unavailable","message":"Analysis could not complete. Run `rea doctor`, then try again.","retryable":false,"remediation":{"action":"Analysis could not complete. Run `rea doctor`, then try again."},"details":{"operation":"observe_javascript_runtime","reason":"target_not_allowed"}}

Observed verifier controls:

  • Matching node and omitted role each exit 0 with observation Evidence for the real target.
  • Explicit-attachment listing exits 0, retaining protocol_type: "node", attached: true, and a verified file location. The fixture receives only discovery HTTP requests and no WebSocket request during the refused observation.
  • A missing target ID returns target_not_found with specific guidance to refresh discovery and select a returned ID.

Evidence provenance: observed by the independent verifier; local verification: reproduced; reproduction completeness: complete. The submission did not rerun runtime commands.

Typed outcome or recovery expected

Distinct, actionable diagnostics for the known attachment and role-mismatch conditions. Both requests must remain unsuccessful, matching/omitted-role observation must remain successful, and attachment refusal must precede connection. The implementation may choose how to represent the conditions; this report does not prescribe exact wording or relax target restrictions.

Analysis or suspected cause

Source-derived reasoning: V8InspectorProvider.ts, authorizedTarget and assertRuntimeKind, throws the same target_not_allowed reason without condition details. Both guards run before connection. observationFailureMessage in src/domain/browserObservationError.ts has no branch for it. src/domain/analysisErrorProjection.ts maps it to target_unavailable, and src/domain/analysisErrorPresentation.ts falls back to generic doctor advice for both message and remediation. No bundled dependency was identified as the cause.

Additional context

Related but distinct: #5437 concerns malformed attachment values aborting discovery; this fixture supplies valid true and discovery succeeds. Closed #2180 and merged #2230 concern named-input validation before provider admission. Closed #3126 concerns browser service-worker policy and was fixed with specific service-worker recovery; it does not cover these Inspector guards. This is a separate uncovered refusal diagnostic, not a claim that those fixes regressed.

Prepared with AI assistance and independently reproduced by a separate verifier. There is no target_not_allowed row in the baseline error catalog, so the expectation above does not rely on promised catalog wording. NOT_ENOUGH_INFO: no last known good version or production occurrence was established. No fix or restoration has been tested.

Originally created by @coygeek on GitHub (Oct 21, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/5753 ### 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 Process capture or runtime observation ### Observed behavior `observe-javascript-runtime` correctly refuses a Node target requested as `electron-renderer`, and a target whose discovery explicitly reports `attached: true`. Both return byte-identical `target_unavailable` errors with `details.reason: target_not_allowed` and generic `rea doctor` advice. Neither the message nor structured details identifies which condition blocked observation or how to correct it. An independent verifier reproduced both cases through the built CLI at the baseline below. The same real Node target succeeds with `--runtime-kind node` or with the role omitted. The attachment case uses a loopback discovery fixture, not a real competing debugger. ### Reproduction From the built source checkout with the repository-pinned Node.js on PATH, run this procedure. It starts an owned Node target and a discovery fixture, isolates REA state, and stops only its recorded process IDs. The verifier executed the equivalent isolated procedure once per case and retained the outputs described below. ```sh work_dir="$(mktemp -d)" mkdir -p "$work_dir"/{home,cfg,data,cache,state,tmp} rea_local() { env -i PATH="$PATH" HOME="$work_dir/home" \ XDG_CONFIG_HOME="$work_dir/cfg" XDG_DATA_HOME="$work_dir/data" \ XDG_CACHE_HOME="$work_dir/cache" XDG_STATE_HOME="$work_dir/state" \ TMPDIR="$work_dir/tmp" REA_LOG_LEVEL=silent \ node scripts/rea.mjs "$@" --json } printf 'setInterval(() => {}, 1000);\n' > "$work_dir/app.mjs" node --inspect=127.0.0.1:0 "$work_dir/app.mjs" > "$work_dir/app.log" 2>&1 & app_pid=$! endpoint_pid="" cleanup() { if [ -n "$endpoint_pid" ]; then kill "$endpoint_pid"; wait "$endpoint_pid"; fi kill "$app_pid" wait "$app_pid" } trap cleanup EXIT endpoint="$(python3 - "$work_dir/app.log" <<'PYTHON' import pathlib, re, sys, time for _ in range(100): match = re.search(r'ws://127.0.0.1:(\d+)/', pathlib.Path(sys.argv[1]).read_text()) if match: print('http://127.0.0.1:' + match[1]) break time.sleep(0.05) else: raise SystemExit('Inspector did not start') PYTHON )" rea_local list-javascript-runtime-targets "$endpoint" > "$work_dir/targets.json" target="$(node -e 'console.log(require(process.argv[1]).normalized_result.targets[0].target_id)' "$work_dir/targets.json")" rea_local observe-javascript-runtime "$endpoint" "$target" --runtime-kind electron-renderer printf 'Role mismatch exit: %s\n' "$?" rea_local observe-javascript-runtime "$endpoint" "$target" --runtime-kind node > "$work_dir/valid-node.json" printf 'Matching role exit: %s\n' "$?" rea_local observe-javascript-runtime "$endpoint" "$target" > "$work_dir/valid-omitted.json" printf 'Omitted role exit: %s\n' "$?" rea_local observe-javascript-runtime "$endpoint" no-such-target printf 'Missing target exit: %s\n' "$?" cat > "$work_dir/endpoint.mjs" <<'JS' import http from 'node:http'; import fs from 'node:fs'; import { pathToFileURL } from 'node:url'; const server = http.createServer((req, res) => { res.setHeader('content-type', 'application/json'); if (req.url === '/json/version') { res.end(JSON.stringify({ Browser: 'node.js/' + process.version, 'Protocol-Version': '1.1' })); } else if (req.url === '/json/list') { res.end(JSON.stringify([{ id: 'attached-fixture', type: 'node', attached: true, url: pathToFileURL(process.argv[2]).href, webSocketDebuggerUrl: `ws://127.0.0.1:${server.address().port}/attached-fixture` }])); } else { res.statusCode = 404; res.end('{}'); } }); server.listen(0, '127.0.0.1', () => { fs.writeFileSync(process.argv[3], String(server.address().port)); }); JS node "$work_dir/endpoint.mjs" "$work_dir/app.mjs" "$work_dir/port" > "$work_dir/endpoint.log" 2>&1 & endpoint_pid=$! port="$(python3 - "$work_dir/port" <<'PYTHON' import pathlib, sys, time for _ in range(100): path = pathlib.Path(sys.argv[1]) if path.exists() and path.read_text(): print(path.read_text()) break time.sleep(0.05) else: raise SystemExit('Fixture did not start') PYTHON )" rea_local list-javascript-runtime-targets "http://127.0.0.1:$port" > "$work_dir/attached-list.json" rea_local observe-javascript-runtime "http://127.0.0.1:$port" attached-fixture --runtime-kind node printf 'Explicit attachment exit: %s\n' "$?" ``` ### Expected behavior Keep both restrictions enforced. For a runtime-role mismatch, identify the supplied role and discovered protocol type and give applicable declaration guidance. For explicit attachment, identify the reported state and explain that the existing attachment must be released before retrying. Preserve meaningful failure reasons rather than direct both callers to host diagnosis. The baseline's [runtime observation guide](https://github.com/morluto/rea/blob/9d8e7803326a382cbbb3ffdb900f5e93e5442d68/docs/javascript-runtime-observation.md) defines these restrictions under target selection and Node/Electron roles. [AGENTS.md](https://github.com/morluto/rea/blob/9d8e7803326a382cbbb3ffdb900f5e93e5442d68/AGENTS.md), Architecture and Cleanup, requires meaningful failure reasons to survive projection. The canonical `observe_javascript_runtime` contract promises a presence and attachability recheck. ### Impact and scope P3: diagnostic wording and recovery guidance are wrong for these correctly refused inputs. The verifier observed no bypass or data loss. Discovery exposes `protocol_type` and `attached`; a matching or omitted role restored real Node observation. Releasing a real debugger attachment was not exercised. Production Electron attachment reporting, other platforms, and the MCP adapter were not tested. ### REA version `rea-agents` 6.7.0, verified source baseline `9d8e7803326a382cbbb3ffdb900f5e93e5442d68`. Submission rechecked current main `d0067ba34a39ea47dd7e11bb2e6169bc0938cc3f`: no post-baseline commits changed the cited contract, guide, provider, or error-projection files. No new runtime reproduction on main was needed or performed. ### Runtime and platform Verifier runtime: repository-pinned Node.js v24.18.0. Submission host: macOS 27.0.1 arm64, with ambient Node.js v26.12.0; the pinned v24.18.0 executable is installed. No Hopper/Ghidra provider is involved. ### Target and artifact context Owned Node application containing `setInterval(() => {}, 1000)` with a literal-loopback Inspector endpoint. A separate owned loopback HTTP fixture reports a valid node target referencing that readable application file and explicitly sets `attached: true`. Ordinary Node discovery omits attachment state, so that fixture establishes explicit-boolean refusal behavior only. ### Interface CLI ### Earliest failure stage Transport or result projection ### Relevant output or evidence Both refused calls exit 1 with this identical JSON: ```json {"code":"target_unavailable","category":"unavailable","message":"Analysis could not complete. Run `rea doctor`, then try again.","retryable":false,"remediation":{"action":"Analysis could not complete. Run `rea doctor`, then try again."},"details":{"operation":"observe_javascript_runtime","reason":"target_not_allowed"}} ``` Observed verifier controls: - Matching `node` and omitted role each exit 0 with observation Evidence for the real target. - Explicit-attachment listing exits 0, retaining `protocol_type: "node"`, `attached: true`, and a verified file location. The fixture receives only discovery HTTP requests and no WebSocket request during the refused observation. - A missing target ID returns `target_not_found` with specific guidance to refresh discovery and select a returned ID. Evidence provenance: observed by the independent verifier; local verification: reproduced; reproduction completeness: complete. The submission did not rerun runtime commands. ### Typed outcome or recovery expected Distinct, actionable diagnostics for the known attachment and role-mismatch conditions. Both requests must remain unsuccessful, matching/omitted-role observation must remain successful, and attachment refusal must precede connection. The implementation may choose how to represent the conditions; this report does not prescribe exact wording or relax target restrictions. ### Analysis or suspected cause Source-derived reasoning: [V8InspectorProvider.ts](https://github.com/morluto/rea/blob/9d8e7803326a382cbbb3ffdb900f5e93e5442d68/src/inspector/V8InspectorProvider.ts), `authorizedTarget` and `assertRuntimeKind`, throws the same `target_not_allowed` reason without condition details. Both guards run before connection. `observationFailureMessage` in `src/domain/browserObservationError.ts` has no branch for it. `src/domain/analysisErrorProjection.ts` maps it to `target_unavailable`, and `src/domain/analysisErrorPresentation.ts` falls back to generic doctor advice for both message and remediation. No bundled dependency was identified as the cause. ### Additional context Related but distinct: #5437 concerns malformed attachment values aborting discovery; this fixture supplies valid `true` and discovery succeeds. Closed #2180 and merged #2230 concern named-input validation before provider admission. Closed #3126 concerns browser service-worker policy and was fixed with specific service-worker recovery; it does not cover these Inspector guards. This is a separate uncovered refusal diagnostic, not a claim that those fixes regressed. Prepared with AI assistance and independently reproduced by a separate verifier. There is no `target_not_allowed` row in the baseline error catalog, so the expectation above does not rely on promised catalog wording. NOT_ENOUGH_INFO: no last known good version or production occurrence was established. No fix or restoration has been tested.
Author
Owner

@XinwangTao commented on GitHub (Oct 21, 2026):

Agreed — two different blocking conditions collapsing into one byte-identical target_not_allowed makes the caller guess whether to fix the runtime-kind argument or pick a different target entirely. Since the provider already knows which check rejected the target (role mismatch vs. already-attached vs. missing), surfacing that specific condition plus the actionable correction (use --runtime-kind node / omit the role; choose an unattached target) would turn an opaque refusal into a recoverable one. The generic rea doctor advice also buries the runtime-role recovery path that the runtime observation guide documents, so a model recovering from the error alone has no signal about which dimension to change.

<!-- gh-comment-id:6307815285 --> @XinwangTao commented on GitHub (Oct 21, 2026): Agreed — two different blocking conditions collapsing into one byte-identical target_not_allowed makes the caller guess whether to fix the runtime-kind argument or pick a different target entirely. Since the provider already knows which check rejected the target (role mismatch vs. already-attached vs. missing), surfacing that specific condition plus the actionable correction (use --runtime-kind node / omit the role; choose an unattached target) would turn an opaque refusal into a recoverable one. The generic rea doctor advice also buries the runtime-role recovery path that the runtime observation guide documents, so a model recovering from the error alone has no signal about which dimension to change.
Author
Owner

@coygeek commented on GitHub (Oct 24, 2026):

Checked the reported fix on main at d87e73f2db.

Explicit attachment still refuses before connection but now carries attached:true/target_id and advice to disconnect the other debugger or select an unattached target. Runtime-kind mismatch still enforces node/page compatibility while retaining supplied role, target ID and discovered protocol_type plus correction/omission guidance. BrowserObservationError promotes producer detail to userMessage and preserves remediation, and the regression projects both failures and asserts distinct messages/actions with no protocol commands.

Implementation: V8InspectorProvider.ts, V8InspectorProvider.ts.

The relevant regression checks in V8InspectorEndpoint.test.ts passed in the focused test run on this revision. This closure is based on the current source and those checks; provider fixtures do not establish a real-engine run. Closing as completed on main.

<!-- gh-comment-id:6380721112 --> @coygeek commented on GitHub (Oct 24, 2026): Checked the reported fix on `main` at d87e73f2db50be72d33a4b3c7199af35518b441c. Explicit attachment still refuses before connection but now carries attached:true/target_id and advice to disconnect the other debugger or select an unattached target. Runtime-kind mismatch still enforces node/page compatibility while retaining supplied role, target ID and discovered protocol_type plus correction/omission guidance. BrowserObservationError promotes producer detail to userMessage and preserves remediation, and the regression projects both failures and asserts distinct messages/actions with no protocol commands. Implementation: [V8InspectorProvider.ts](https://github.com/morluto/rea/blob/d87e73f2db50be72d33a4b3c7199af35518b441c/src/inspector/V8InspectorProvider.ts#L531), [V8InspectorProvider.ts](https://github.com/morluto/rea/blob/d87e73f2db50be72d33a4b3c7199af35518b441c/src/inspector/V8InspectorProvider.ts#L571). The relevant regression checks in [V8InspectorEndpoint.test.ts](https://github.com/morluto/rea/blob/d87e73f2db50be72d33a4b3c7199af35518b441c/src/inspector/V8InspectorEndpoint.test.ts) passed in the focused test run on this revision. This closure is based on the current source and those checks; provider fixtures do not establish a real-engine run. Closing as completed on main.
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#3499
No description provided.