[PR #6777] [CLOSED] fix(entropy): report symlink loops and overlong paths as path input errors #7410

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/6777
Author: @Sriram-PR
Created: 10/23/2026
Status: ❌ Closed

Base: main ← Head: fix/entropy-path-selection-errors


📝 Commits (2)

  • 4d52f38 fix(entropy): report symlink loops and overlong paths as path input errors
  • 9ce6984 fix(entropy): classify selected-path errnos through the shared owner and keep the cause

📊 Changes

2 files changed (+50 additions, -7 deletions)

View changed files

📝 src/application/binaryDiagnostics/ByteEntropyService.test.ts (+31 -1)
📝 src/application/binaryDiagnostics/ByteEntropyService.ts (+19 -6)

📄 Description

Summary

inspect_byte_entropy turned ELOOP (a self-referential symlink) and ENAMETOOLONG (a 256-byte filename component) from the initial stat into AnalysisOutputError, which projects as unreadable_output / execution_failure with "run rea doctor" advice and no mention of path. Both happen before the file is admitted, so they're bad selections, same as the missing-file case right next to them, which already returns a path input error.

Fixes #6754

Problem and expected behavior

Smallest trigger: ByteEntropyService.inspect({ path }) where path is a symlink to itself, or has a 256-character last component on Linux. Main returns code: "unreadable_output". Expected: invalid_request with an issue at ["path"] saying which host limit was hit, like Selected file could not be found. for ENOENT.

Change and scope

  • readFailure in ByteEntropyService now classifies selected-path errnos with the shared artifactSelectedPathErrno (ENOENT, ENOTDIR, ELOOP, ENAMETOOLONG), as BEAM and EVM do, instead of checking ENOENT/ENOTDIR by hand. Before admission each becomes a path input error with a per-errno message (the existing "Selected file could not be found." for ENOENT/ENOTDIR); after admission, the existing "path changed during entropy inspection" error.
  • The input error now keeps the original SystemError as cause (before, invalid dropped it).
  • Not included: other services' path handling; this only touches the entropy workflow from the issue.

Contribution scope: ordinary fix within existing boundaries; no scope decision needed.

Contract and boundary impact

  • Semantic owner and earliest changed stage: readFailure in src/application/binaryDiagnostics/ByteEntropyService.ts.
  • Contribution scope fit and linked maintainer decision: not applicable (bug fix, #6754).
  • CLI and MCP/tool-catalog contract: no schema change; these two failures now use the existing invalid_request error shape instead of unreadable_output.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none; no Evidence is produced for either failure before or after.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata, package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • 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: src/application/binaryDiagnostics/ByteEntropyService.test.ts adds reports symlink loops and overlong path components as path input errors (skipped on Windows), checking the projected error for both cases (invalid_request, issue path ["path"], invalid_value, message naming the errno) and that cause keeps the errno and syscall: "stat".
  • Base reproduction: the new test fails on main's source with:
    -   "code": "invalid_request",
    +   "code": "unreadable_output",
    
  • User-visible CLI/MCP output: e.g. invalid_request with {"path": ["path"], "reason": "invalid_value", "message": "Selected path's symbolic links loop or exceed the host limit (ELOOP)."}.
  • Remaining proof gaps: Linux only; the post-admission branch for these codes reuses the existing changed-artifact error and has no dedicated test.

For evidence-bearing changes:

  • 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 -- src/application/binaryDiagnostics/ByteEntropyService.test.ts tests/boundary/mcp/binaryDiagnosticsMcp.test.ts: 25 passed (the new test fails on main's source)
  • npm run check:fast: typecheck and lint passed

Compatibility, safety, and release

  • Breaking changes or migration steps: none; only the error category for these two filesystem failures changes.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux x64, Node 24.18.0.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none.

Author readiness

Human owner: @Sriram-PR

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

🔄 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/6777 **Author:** [@Sriram-PR](https://github.com/Sriram-PR) **Created:** 10/23/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/entropy-path-selection-errors` --- ### 📝 Commits (2) - [`4d52f38`](https://github.com/morluto/rea/commit/4d52f380dc89c71ea761b1ad1ca22385364d72d9) fix(entropy): report symlink loops and overlong paths as path input errors - [`9ce6984`](https://github.com/morluto/rea/commit/9ce6984845f5298984b843111639827e6ffdaa1b) fix(entropy): classify selected-path errnos through the shared owner and keep the cause ### 📊 Changes **2 files changed** (+50 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `src/application/binaryDiagnostics/ByteEntropyService.test.ts` (+31 -1) 📝 `src/application/binaryDiagnostics/ByteEntropyService.ts` (+19 -6) </details> ### 📄 Description ## Summary `inspect_byte_entropy` turned `ELOOP` (a self-referential symlink) and `ENAMETOOLONG` (a 256-byte filename component) from the initial `stat` into `AnalysisOutputError`, which projects as `unreadable_output` / `execution_failure` with "run `rea doctor`" advice and no mention of `path`. Both happen before the file is admitted, so they're bad selections, same as the missing-file case right next to them, which already returns a `path` input error. Fixes #6754 ## Problem and expected behavior Smallest trigger: `ByteEntropyService.inspect({ path })` where `path` is a symlink to itself, or has a 256-character last component on Linux. Main returns `code: "unreadable_output"`. Expected: `invalid_request` with an issue at `["path"]` saying which host limit was hit, like `Selected file could not be found.` for `ENOENT`. ## Change and scope - `readFailure` in `ByteEntropyService` now classifies selected-path errnos with the shared `artifactSelectedPathErrno` (ENOENT, ENOTDIR, ELOOP, ENAMETOOLONG), as BEAM and EVM do, instead of checking `ENOENT`/`ENOTDIR` by hand. Before admission each becomes a `path` input error with a per-errno message (the existing "Selected file could not be found." for ENOENT/ENOTDIR); after admission, the existing "path changed during entropy inspection" error. - The input error now keeps the original SystemError as `cause` (before, `invalid` dropped it). - Not included: other services' path handling; this only touches the entropy workflow from the issue. Contribution scope: ordinary fix within existing boundaries; no scope decision needed. ## Contract and boundary impact - Semantic owner and earliest changed stage: `readFailure` in `src/application/binaryDiagnostics/ByteEntropyService.ts`. - Contribution scope fit and linked maintainer decision: not applicable (bug fix, #6754). - CLI and MCP/tool-catalog contract: no schema change; these two failures now use the existing `invalid_request` error shape instead of `unreadable_output`. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: none; no Evidence is produced for either failure before or after. - Target selection, authority, upstream behavior, and cleanup details: not applicable. - Generated metadata, package, or installation impact: none. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] 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: `src/application/binaryDiagnostics/ByteEntropyService.test.ts` adds `reports symlink loops and overlong path components as path input errors` (skipped on Windows), checking the projected error for both cases (`invalid_request`, issue path `["path"]`, `invalid_value`, message naming the errno) and that `cause` keeps the errno and `syscall: "stat"`. - Base reproduction: the new test fails on main's source with: ``` - "code": "invalid_request", + "code": "unreadable_output", ``` - User-visible CLI/MCP output: e.g. `invalid_request` with `{"path": ["path"], "reason": "invalid_value", "message": "Selected path's symbolic links loop or exceed the host limit (ELOOP)."}`. - Remaining proof gaps: Linux only; the post-admission branch for these codes reuses the existing changed-artifact error and has no dedicated test. For evidence-bearing changes: - [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 -- src/application/binaryDiagnostics/ByteEntropyService.test.ts tests/boundary/mcp/binaryDiagnosticsMcp.test.ts`: 25 passed (the new test fails on main's source) - `npm run check:fast`: typecheck and lint passed ## Compatibility, safety, and release - Breaking changes or migration steps: none; only the error category for these two filesystem failures changes. - Real Hopper/Ghidra, browser, or OS coverage: Linux x64, Node 24.18.0. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none. ## Author readiness Human owner: @Sriram-PR - [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] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:47:40 +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#7410
No description provided.