Skip to content

fix(cli): report the byte-entropy provider id in cleanup diagnostics - #7319

Closed
x-labb wants to merge 2 commits into
morluto:mainfrom
x-labb:fix-7279-byte-entropy-cleanup-provider
Closed

x-labb wants to merge 2 commits into
morluto:mainfrom
x-labb:fix-7279-byte-entropy-cleanup-provider

Conversation

@x-labb

@x-labb x-labb commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When rea inspect-byte-entropy finishes reading a file but the descriptor close fails, the cleanup diagnostic names provider rea-byte-entropy, while the retained Evidence names byte-entropy. This makes the cleanup diagnostic use the Evidence provider's identity.

Fixes #7279

Written with AI assistance.

Problem and expected behavior

src/cli/binaryDiagnosticsCommands.ts passed the literal "rea-byte-entropy" to finishAnalysisCommand, while the provider identity is BYTE_ENTROPY_PROVIDER.id ("byte-entropy"). It is the only command in that file whose literal differs from its provider constant. With a persistent descriptor-close failure, details.diagnostics.cleanup_error.details.provider_id was rea-byte-entropy. The failure status, resource list and completed Evidence were already correct.

Change and scope

Use BYTE_ENTROPY_PROVIDER.id at the call site, so the cleanup provider id and the Evidence provider id come from one owner. Nothing else changes.

Not included: the other "rea-…" literals in the same file match their provider constants today. Replacing them with the constants would be a separate cleanup, so I left them alone.

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

Contract and boundary impact

  • Semantic owner and earliest changed stage: BYTE_ENTROPY_PROVIDER (src/domain/investigationProviders.ts); the CLI command registration passed a duplicated string. No superseded path was removed.
  • Contribution scope fit and linked maintainer decision: not applicable (bug fix within existing boundaries).
  • CLI and MCP/tool-catalog contract: no schema or catalog change. Only the nested cleanup diagnostic's provider_id value changes (rea-byte-entropy → byte-entropy) on the descriptor-close failure path.
  • Provider, bridge, target-format, or platform compatibility: none; no provider is involved.
  • Evidence, artifact, provenance, or reconstruction contract: Evidence is unchanged; the diagnostic now agrees with it.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • 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: tests/process-global/byteEntropyCleanupCli.test.ts. It runs the real registered inspect-byte-entropy CLI on a 512-byte file with a persistent EIO injected on the file handle's close() (module mock of node:fs/promises). It asserts cleanup_incomplete, the retained cleanup: incomplete details, that the nested cleanup_error.details.provider_id equals BYTE_ENTROPY_PROVIDER.id, and that the retained partial observation (diagnostics.primary_error.details.partial_observation) still carries the Evidence provider id, the file's SHA-256 and its byte count. A normal-close control asserts successful Evidence with the same provider id.
  • Base reproduction or other evidence (executed): on the unfixed code the close-failure case failed with provider_id: "rea-byte-entropy" where "byte-entropy" was expected; the control passed. With the fix both pass (vitest run --project process-global).
  • User-visible CLI/MCP output: only the nested provider_id value above changes.
  • Remaining proof gaps: see "Validation performed".

Boundary/lifecycle regressions covered: public CLI delivery with a cleanup failure after a completed observation ("Cleanup fails after success"). Not covered: primary-failure-plus-cleanup-failure for this command, cancellation during final close, and a naturally occurring OS close failure (the failure is injected).

  • 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

Windows 11, Node 24.22.1:

  • npx vitest run --project process-global tests/process-global/byteEntropyCleanupCli.test.ts — fails on base with the provider-id mismatch; 2/2 pass with the fix. The neighboring binaryDiagnosticsCliCleanup.test.ts also passes (4/4).
  • npm run test:local -- src/application/binaryDiagnostics/ByteEntropyService.test.ts — 20 passed, 2 skipped, 1 failed ("reports a changed artifact when its parent directory moves during streaming", a Windows ENOENT on rename). The same failure occurs without this change.
  • npm run check:fast (typecheck and lint) — passed.
  • oxfmt --check on the two changed files — clean.
  • npm run verify:test-discovery — all 2591 test files discovered exactly once.

Not run:

  • npm run test:focused and the acceptance suite (e.g. tests/acceptance/localPathAdmissionCli.test.ts): they need the compiled runtime, and the build needs Windows native artifacts that this host lacks. Run directly, that acceptance test fails because no dist/ exists; that failure is environmental.
  • npm run check, npm run docs:check, and the real-provider suites.
  • Linux. The test relies only on a module mock, not on platform behavior, but it was run only on Windows.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. The only observable change is the nested diagnostic's provider_id string.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (no provider involved).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; no authority, process or path logic changes.

Author readiness

Human owner: @x-labb

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

@greptile-apps

greptile-apps Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Low impact] The PR appears safe to merge; no blocking issues remain.

Summary

Changes inspect-byte-entropy cleanup diagnostics to use BYTE_ENTROPY_PROVIDER.id, matching the retained Evidence.

  • Byte-entropy cleanup errors use the same provider name as Evidence.

Reviews (3) · Last reviewed commit: "test(cli): assert retained entropy Evide..." · Reviewed by Greptile

@x-labb
x-labb marked this pull request as ready for review October 26, 2026 23:21
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-26T23:21:42.872714Z
We couldn’t complete this review. Comment @codex review to try again.
a9e4f19 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

inspect-byte-entropy passed a hard-coded "rea-byte-entropy" to the shared command finalizer, so a failed descriptor close named a provider that differs from the Evidence provider ("byte-entropy"). Use BYTE_ENTROPY_PROVIDER.id so both come from one owner.

Fixes #7279
…stic

Check the partial observation returned with the close-failure diagnostic: provider id, file digest and byte count.
@x-labb
x-labb force-pushed the fix-7279-byte-entropy-cleanup-provider branch from d5aa7ec to 2f43ac3 Compare October 29, 2026 09:58
@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: I ran the new test file on head 2f43ac3, and both tests pass on Node 22, 24 and 26. With src/cli/binaryDiagnosticsCommands.ts put back to the merge base d3ecf68, the close-fails test fails on all three, so it does check the fix. I did not run a real binary, macOS or Windows.

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
Head 2f43ac3 pass: 1 file, 2 tests pass: 1 file, 2 tests pass: 1 file, 2 tests
Red run (old src/cli/binaryDiagnosticsCommands.ts from d3ecf68) fail: 1 test failed, 1 passed fail: 1 test failed, 1 passed fail: 1 test failed, 1 passed

All rows ran tests/process-global/byteEntropyCleanupCli.test.ts.

  • The red run fails names the Evidence provider in cleanup diagnostics (close fails: true). The error is AssertionError: expected { code: 'cleanup_incomplete', …(5) } to match object { code: 'cleanup_incomplete', …(1) }.
  • The close-succeeds case passed in both runs. So the close-fails test fails without the fix and passes with it.
  • CI on 2f43ac3: CI and PR title are waiting for a maintainer to approve them (action_required). Greptile Review passed. PR readiness has one successful and one cancelled run, and its commit status is success. Validate author declaration has one successful and one cancelled check run.
  • The head is 500 commits behind main b81da90. GitHub says the PR is mergeable, and its merge state is blocked.

Not run

  • rea byte-entropy against a real binary with a failing cleanup.
  • macOS or Windows.
  • A merge with current main, b81da90.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, Linux 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 2f43ac3 / d3ecf68 (merge base with main)
  • Red run: 2f43ac3 with src/cli/binaryDiagnosticsCommands.ts from d3ecf68
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1, exit 0, for both trees
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- tests/process-global/byteEntropyCleanupCli.test.ts

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

gensokyo-dev added a commit that referenced this pull request Nov 14, 2026
…ation

Since #8444 the completed observation is projected once at the composed
error's details.partial_observation rather than inside primary_error,
so restore #7319's retained-Evidence assertion there.

Refs #7279

Co-Authored-By: gensokyo-dev <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
N0zoM1z0 pushed a commit that referenced this pull request Nov 14, 2026
…ation

Since #8444 the completed observation is projected once at the composed
error's details.partial_observation rather than inside primary_error,
so restore #7319's retained-Evidence assertion there.

Refs #7279

Co-Authored-By: gensokyo-dev <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Thanks! This landed on main in #10490 as its own commit, cherry-picked with your authorship kept (rebase merge). Closing in favor of that merge.

@N0zoM1z0 N0zoM1z0 closed this Nov 14, 2026
@morluto morluto added area: cli CLI adapter and one-shot commands bug Something isn't working labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] inspect-byte-entropy cleanup names provider rea-byte-entropy

4 participants