[GH-ISSUE #7279] [Bug] inspect-byte-entropy cleanup names provider rea-byte-entropy #4319

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/7279

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

When rea inspect-byte-entropy finishes reading a regular file but both descriptor-close attempts fail, its cleanup diagnostic names rea-byte-entropy, while the retained Evidence names byte-entropy. This misattributes the cleanup diagnostic; the failure status, affected resource, and completed analysis remain available.

The wrong value is nested at details.diagnostics.cleanup_error.details.provider_id; top-level details.provider_id is absent on this reproduced path.

Reproduction

  1. Use the stated baseline with its locked dependencies installed and Node.js v24.22.1 available. Create a scratch home with mktemp -d, set HOME to it for the verifier process, and create the focused verifier file named under Relevant output or evidence. No analysis provider or external service is needed.
  2. In the verifier, write a regular file named entropy-input.bin inside that scratch home, containing 32 repetitions of the text entropy fixture followed by a newline (512 bytes total).
  3. Use Vitest’s vi.mock for node:fs/promises, delegating to importOriginal. Wrap only open: call the real implementation, and for the selected fixture retain the original bound FileHandle.close. Spy on that handle’s close method so the failure case increments an attempt counter and rejects with an Error whose code is EIO. Keep all real stat, open, read, and handle-stat operations unchanged. Apply the mock before importing the command-registration module.
  4. Create a real Cli.create instance with sync: false, register registerBinaryDiagnosticsCommands with silentLogger and an empty environment, and call its serve method with the arguments inspect-byte-entropy, the absolute fixture path, --format, json. Capture the supplied stdout callback and parse its JSON; use a no-op exit callback and restore the test process’s prior exit code afterward.
  5. Confirm the failure case attempted close twice, returned cleanup_incomplete, retained Evidence identifying byte-entropy, and reported rea-byte-entropy in the nested cleanup diagnostic. Do not replace the service, resource-scope close, or cleanup reporter.
  6. Run a control with a fresh CLI instance and the same fixture bytes, delegating the handle’s close to the real implementation. Confirm one close attempt and successful Evidence identifying byte-entropy.
  7. In teardown restore the spies, call the retained real close to release the failure-case descriptor, and remove the input. Run the focused command under Relevant output or evidence and delete the verifier file afterward. Each of two review runs exercised one control and one persistent-close-failure case; both failure cases produced the same identity mismatch.

Expected behavior

The cleanup diagnostic for this operation should identify the same provider as the operation’s Evidence: byte-entropy. Preserving a primary analysis error and reporting incomplete cleanup should preserve that provider identity in the nested cleanup diagnostic.

Expected source: AGENTS.md, Architecture and Cleanup (preserve identity across boundaries); src/domain/investigationProviders.ts:69-74 defines the provider identity; src/application/binaryDiagnostics/ByteEntropyService.ts:112-115 attaches it to this operation’s Evidence.

Impact and scope

P3: incorrect diagnostic attribution when the selected file cannot be confirmed closed and the final close retry also fails. The test observed the mismatch in both runs of that injected condition; natural filesystem failure frequency is unknown. The error still reports incomplete cleanup and retains its affected resource and entropy Evidence. A caller can use the canonical provider id from partial Evidence. No analysis corruption or downstream routing failure was demonstrated. No security boundary is crossed.

REA version

615fbbbdd7 (package.json version 6.8.0)

Runtime and platform

Node.js v24.22.1, macOS arm64, Vitest 5.0.3. Source-level registered CLI command; no packaged executable or external analysis provider.

Target and artifact context

A 512-byte regular file containing 32 repetitions of entropy fixture\n; static byte inspection only. Real filesystem stat, open, and read operations; EIO-shaped failures injected into the opened handle’s close method.

Interface

CLI

Earliest failure stage

Cleanup, cancellation, or lifecycle

Relevant output or evidence

Observed with the real registered command:

normal close: attempts=1, Evidence provider=byte-entropy
persistent close refusal: attempts=2, code=cleanup_incomplete
cleanup diagnostic provider_id=rea-byte-entropy
partial Evidence provider.id=byte-entropy

The real command returned cleanup_incomplete and retained the completed entropy Evidence. The cleanup diagnostic contained details.diagnostics.cleanup_error.details.provider_id: "rea-byte-entropy", while details.partial_observation.provider.id was "byte-entropy". Top-level details.provider_id was absent. The normal-close control returned successful Evidence with provider byte-entropy. The first verifier run failed an assertion copied from the hunter’s top-level-field assumption; after correcting the assertion to the actual nested field, the focused run passed both tests without a product change.

Failure source: src/cli/binaryDiagnosticsCommands.ts:199-235 passes the inconsistent id for the registered command; src/cli/finishAnalysisCommand.ts:51-99 reports a failed close; src/domain/analysisErrorCleanup.ts:9-55 retains that cleanup diagnostic; src/domain/analysisErrorProjection.ts:459-468 exposes its provider id.

Production reachability: src/cli.ts:148 registers the command. src/artifacts/ArtifactFileOperation.ts:296-326 retains the failed file-close lease and src/artifacts/ArtifactResourceScope.ts:309-349 retries it, producing the actual failure consumed by the CLI reporter. No resource-scope or service-close method was mocked.

  • Reproduction command: create the temporary focused verifier at src/entropyCleanupVerification.test.ts using the exact fixture, filesystem fault, CLI invocation, control, and teardown described above, then run npm run test:local -- src/entropyCleanupVerification.test.ts. The review executed this procedure with a temporary verifier that was deleted afterward. The test mocks a filesystem close error; it does not demonstrate a spontaneous kernel or filesystem failure. No product source was changed.

Typed outcome or recovery expected

With the same real-file fixture and persistent descriptor-close refusal, the command must still report cleanup_incomplete, retain the affected resource and completed Evidence, and identify the cleanup provider as byte-entropy, equal to the retained Evidence provider. The normal-close control must still return successful entropy Evidence with the same canonical provider. Changing the diagnostic assertion to compare against that identity should then pass. No repaired build was tested in this review.

Analysis or suspected cause

Source-derived: the command supplies an inconsistent provider id to the shared finalizer; the finalizer carries it into the cleanup diagnostic. The original primary error controls the top-level details, which explains why the wrong provider id appears only inside the nested cleanup error for the supported close-failure path.

Additional context

Closed issue #6947 concerns byte-entropy physical-read efficiency and is adjacent history, not this cleanup identity failure. Searches of open and closed issues for "byte-entropy" "cleanup", "rea-byte-entropy", and "entropy" "provider" "cleanup" found no issue reporting this behavior.

Originally created by @coygeek on GitHub (Oct 26, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/7279 ### 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 When `rea inspect-byte-entropy` finishes reading a regular file but both descriptor-close attempts fail, its cleanup diagnostic names `rea-byte-entropy`, while the retained Evidence names `byte-entropy`. This misattributes the cleanup diagnostic; the failure status, affected resource, and completed analysis remain available. The wrong value is nested at `details.diagnostics.cleanup_error.details.provider_id`; top-level `details.provider_id` is absent on this reproduced path. ### Reproduction 1. Use the stated baseline with its locked dependencies installed and Node.js v24.22.1 available. Create a scratch home with `mktemp -d`, set `HOME` to it for the verifier process, and create the focused verifier file named under Relevant output or evidence. No analysis provider or external service is needed. 2. In the verifier, write a regular file named `entropy-input.bin` inside that scratch home, containing 32 repetitions of the text `entropy fixture` followed by a newline (512 bytes total). 3. Use Vitest’s `vi.mock` for `node:fs/promises`, delegating to `importOriginal`. Wrap only `open`: call the real implementation, and for the selected fixture retain the original bound `FileHandle.close`. Spy on that handle’s `close` method so the failure case increments an attempt counter and rejects with an Error whose code is `EIO`. Keep all real stat, open, read, and handle-stat operations unchanged. Apply the mock before importing the command-registration module. 4. Create a real `Cli.create` instance with `sync: false`, register `registerBinaryDiagnosticsCommands` with `silentLogger` and an empty environment, and call its `serve` method with the arguments `inspect-byte-entropy`, the absolute fixture path, `--format`, `json`. Capture the supplied stdout callback and parse its JSON; use a no-op exit callback and restore the test process’s prior exit code afterward. 5. Confirm the failure case attempted close twice, returned `cleanup_incomplete`, retained Evidence identifying `byte-entropy`, and reported `rea-byte-entropy` in the nested cleanup diagnostic. Do not replace the service, resource-scope close, or cleanup reporter. 6. Run a control with a fresh CLI instance and the same fixture bytes, delegating the handle’s close to the real implementation. Confirm one close attempt and successful Evidence identifying `byte-entropy`. 7. In teardown restore the spies, call the retained real close to release the failure-case descriptor, and remove the input. Run the focused command under Relevant output or evidence and delete the verifier file afterward. Each of two review runs exercised one control and one persistent-close-failure case; both failure cases produced the same identity mismatch. ### Expected behavior The cleanup diagnostic for this operation should identify the same provider as the operation’s Evidence: `byte-entropy`. Preserving a primary analysis error and reporting incomplete cleanup should preserve that provider identity in the nested cleanup diagnostic. Expected source: `AGENTS.md`, Architecture and Cleanup (preserve identity across boundaries); `src/domain/investigationProviders.ts:69-74` defines the provider identity; `src/application/binaryDiagnostics/ByteEntropyService.ts:112-115` attaches it to this operation’s Evidence. ### Impact and scope P3: incorrect diagnostic attribution when the selected file cannot be confirmed closed and the final close retry also fails. The test observed the mismatch in both runs of that injected condition; natural filesystem failure frequency is unknown. The error still reports incomplete cleanup and retains its affected resource and entropy Evidence. A caller can use the canonical provider id from partial Evidence. No analysis corruption or downstream routing failure was demonstrated. No security boundary is crossed. ### REA version 615fbbbdd750de2df5d92b9827d0c7c4422c1d03 (package.json version 6.8.0) ### Runtime and platform Node.js v24.22.1, macOS arm64, Vitest 5.0.3. Source-level registered CLI command; no packaged executable or external analysis provider. ### Target and artifact context A 512-byte regular file containing 32 repetitions of `entropy fixture\n`; static byte inspection only. Real filesystem stat, open, and read operations; EIO-shaped failures injected into the opened handle’s close method. ### Interface CLI ### Earliest failure stage Cleanup, cancellation, or lifecycle ### Relevant output or evidence Observed with the real registered command: ```text normal close: attempts=1, Evidence provider=byte-entropy persistent close refusal: attempts=2, code=cleanup_incomplete cleanup diagnostic provider_id=rea-byte-entropy partial Evidence provider.id=byte-entropy ``` The real command returned `cleanup_incomplete` and retained the completed entropy Evidence. The cleanup diagnostic contained `details.diagnostics.cleanup_error.details.provider_id: "rea-byte-entropy"`, while `details.partial_observation.provider.id` was `"byte-entropy"`. Top-level `details.provider_id` was absent. The normal-close control returned successful Evidence with provider `byte-entropy`. The first verifier run failed an assertion copied from the hunter’s top-level-field assumption; after correcting the assertion to the actual nested field, the focused run passed both tests without a product change. Failure source: `src/cli/binaryDiagnosticsCommands.ts:199-235` passes the inconsistent id for the registered command; `src/cli/finishAnalysisCommand.ts:51-99` reports a failed close; `src/domain/analysisErrorCleanup.ts:9-55` retains that cleanup diagnostic; `src/domain/analysisErrorProjection.ts:459-468` exposes its provider id. Production reachability: `src/cli.ts:148` registers the command. `src/artifacts/ArtifactFileOperation.ts:296-326` retains the failed file-close lease and `src/artifacts/ArtifactResourceScope.ts:309-349` retries it, producing the actual failure consumed by the CLI reporter. No resource-scope or service-close method was mocked. - Reproduction command: create the temporary focused verifier at `src/entropyCleanupVerification.test.ts` using the exact fixture, filesystem fault, CLI invocation, control, and teardown described above, then run `npm run test:local -- src/entropyCleanupVerification.test.ts`. The review executed this procedure with a temporary verifier that was deleted afterward. The test mocks a filesystem close error; it does not demonstrate a spontaneous kernel or filesystem failure. No product source was changed. ### Typed outcome or recovery expected With the same real-file fixture and persistent descriptor-close refusal, the command must still report `cleanup_incomplete`, retain the affected resource and completed Evidence, and identify the cleanup provider as `byte-entropy`, equal to the retained Evidence provider. The normal-close control must still return successful entropy Evidence with the same canonical provider. Changing the diagnostic assertion to compare against that identity should then pass. No repaired build was tested in this review. ### Analysis or suspected cause Source-derived: the command supplies an inconsistent provider id to the shared finalizer; the finalizer carries it into the cleanup diagnostic. The original primary error controls the top-level details, which explains why the wrong provider id appears only inside the nested cleanup error for the supported close-failure path. ### Additional context Closed issue [#6947](https://github.com/morluto/rea/issues/6947) concerns byte-entropy physical-read efficiency and is adjacent history, not this cleanup identity failure. Searches of open and closed issues for `"byte-entropy" "cleanup"`, `"rea-byte-entropy"`, and `"entropy" "provider" "cleanup"` found no issue reporting this behavior.
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#4319
No description provided.