[PR #5902] fix(firmware): reclassify output-directory admission failures as invalid_request #7103

Open
opened 2026-11-01 21:45:24 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5902
Author: @codeXsidd
Created: 10/21/2026
Status: 🔄 Open

Base: main ← Head: fix/5900-firmware-destination-admission-error


📝 Commits (1)

  • f644851 fix(firmware): reclassify output-directory admission failures as invalid_request

📊 Changes

4 files changed (+114 additions, -6 deletions)

View changed files

📝 src/artifacts/SafeOutputTree.ts (+11 -5)
➕ src/artifacts/SafeOutputTreeAdmissionFailure.ts (+16 -0)
📝 src/firmware/FirmwareDeadline.test.ts (+69 -1)
📝 src/firmware/FirmwareFailures.ts (+18 -0)

📄 Description

Summary

Fixes #5900. Reclassifies extract-firmware output-directory admission failures as invalid_request / invalid_input with an output_directory field issue, while ensuring later filesystem sync/write failures keep their execution_failure classification.

Problem and expected behavior

SafeOutputTree.create destination checks (such as non-absolute path, dot/dotdot, missing parent, already-existing root, and nonempty root) indicate that the caller-supplied output_directory violates the admission contract. Previously, these threw generic ArtifactReaderFailure instances which fell through to the ProviderAdapterError catch-all in firmwareFailure, attributing them to the Unblob engine and omitting machine-readable field correction and inspect_input_contract recovery.

Callers received:

  • code: execution_failure, provider_id: unblob, and doctor-advice remediation.

They should receive:

  • code: invalid_request, category: invalid_input, an issue identifying output_directory, and inspect_input_contract recovery—consistent with the range-validation control already applied before extraction begins (FirmwareProvider.ts:429–436).

Furthermore, filesystem failures that occur during extraction publication (such as directory fsync failures in SafeOutputTree.commit(), which also throw ArtifactReaderFailure("path", ...) without cleanup) must NOT blame the caller's input and must retain their execution_failure classification.

Change and scope

  • Introduce SafeOutputTreeAdmissionFailure (subclass of ArtifactReaderFailure) in src/artifacts/SafeOutputTreeAdmissionFailure.ts and re-export it from src/artifacts/SafeOutputTree.ts.
  • Raise SafeOutputTreeAdmissionFailure specifically from destination admission checks in SafeOutputTree.create.
  • In firmwareFailure (src/firmware/FirmwareFailures.ts), restrict conversion to AnalysisInputError with an output_directory issue to SafeOutputTreeAdmissionFailure (and unwrapped from SafeOutputTreeCreationFailure when applicable).
  • Later directory sync failures in commit() or file write failures continue to throw generic ArtifactReaderFailure, retaining their ProviderAdapterError classification (execution_failure).

This is a structural classification fix at the owning producing boundary. It does not change refusal authority or provider execution.

Contract and boundary impact

  • Semantic owner and earliest changed stage: SafeOutputTree.ts admission checks and FirmwareFailures.ts classification.

  • Contribution scope fit: existing firmware error projection; no new authority, provider change, or schema change.

  • CLI and MCP/tool-catalog contract: invalid_request / invalid_input for caller-input destination failures; no schema or MCP changes.

  • Provider, bridge, target-format, or platform compatibility: no provider or format changes.

  • Evidence, artifact, provenance, or reconstruction contract: no evidence or stored artifact changes.

  • Target selection, authority, upstream behavior, and cleanup details: no new target interaction; cleanup path unchanged.

  • Generated metadata, package, or installation impact: none.

  • 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

  • Three unit tests in src/firmware/FirmwareDeadline.test.ts:

    1. SafeOutputTreeAdmissionFailure("path", "Extraction output root already exists") produces AnalysisInputError with output_directory issue and projected invalid_request.
    2. SafeOutputTreeAdmissionFailure("unavailable", "Extraction output parent is unavailable") produces AnalysisInputError with output_directory issue and projected invalid_request.
    3. Regression test: ArtifactReaderFailure("path", "Could not durably sync extraction output") (sync failure during commit) does NOT convert to AnalysisInputError and keeps execution_failure classification.
  • All 7 tests in FirmwareDeadline.test.ts passed.

  • npm run check:fast: passed (typecheck and lint). Pre-push check: passed.

  • 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

  • 7/7 unit tests in FirmwareDeadline.test.ts passed (includes 3 regressions).
  • npm run check:fast: passed (typecheck and lint).
  • No real Unblob provider was exercised. Integration-level reproduction was not run.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; invalid_request is the correct classification for this input.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; no provider execution.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: error classification only; no authority change.

Author readiness

Human owner: @codeXsidd

  • 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/5902 **Author:** [@codeXsidd](https://github.com/codeXsidd) **Created:** 10/21/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/5900-firmware-destination-admission-error` --- ### 📝 Commits (1) - [`f644851`](https://github.com/morluto/rea/commit/f6448516ed9334079e29ac40038415ff94a11982) fix(firmware): reclassify output-directory admission failures as invalid_request ### 📊 Changes **4 files changed** (+114 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/artifacts/SafeOutputTree.ts` (+11 -5) ➕ `src/artifacts/SafeOutputTreeAdmissionFailure.ts` (+16 -0) 📝 `src/firmware/FirmwareDeadline.test.ts` (+69 -1) 📝 `src/firmware/FirmwareFailures.ts` (+18 -0) </details> ### 📄 Description ## Summary Fixes #5900. Reclassifies `extract-firmware` output-directory admission failures as `invalid_request` / `invalid_input` with an `output_directory` field issue, while ensuring later filesystem sync/write failures keep their `execution_failure` classification. ## Problem and expected behavior `SafeOutputTree.create` destination checks (such as non-absolute path, dot/dotdot, missing parent, already-existing root, and nonempty root) indicate that the caller-supplied `output_directory` violates the admission contract. Previously, these threw generic `ArtifactReaderFailure` instances which fell through to the `ProviderAdapterError` catch-all in `firmwareFailure`, attributing them to the Unblob engine and omitting machine-readable field correction and `inspect_input_contract` recovery. Callers received: - `code: execution_failure`, `provider_id: unblob`, and doctor-advice remediation. They should receive: - `code: invalid_request`, `category: invalid_input`, an issue identifying `output_directory`, and `inspect_input_contract` recovery—consistent with the range-validation control already applied before extraction begins (`FirmwareProvider.ts:429–436`). Furthermore, filesystem failures that occur during extraction publication (such as directory `fsync` failures in `SafeOutputTree.commit()`, which also throw `ArtifactReaderFailure("path", ...)` without cleanup) must NOT blame the caller's input and must retain their `execution_failure` classification. ## Change and scope - Introduce `SafeOutputTreeAdmissionFailure` (subclass of `ArtifactReaderFailure`) in `src/artifacts/SafeOutputTreeAdmissionFailure.ts` and re-export it from `src/artifacts/SafeOutputTree.ts`. - Raise `SafeOutputTreeAdmissionFailure` specifically from destination admission checks in `SafeOutputTree.create`. - In `firmwareFailure` (`src/firmware/FirmwareFailures.ts`), restrict conversion to `AnalysisInputError` with an `output_directory` issue to `SafeOutputTreeAdmissionFailure` (and unwrapped from `SafeOutputTreeCreationFailure` when applicable). - Later directory sync failures in `commit()` or file write failures continue to throw generic `ArtifactReaderFailure`, retaining their `ProviderAdapterError` classification (`execution_failure`). This is a structural classification fix at the owning producing boundary. It does not change refusal authority or provider execution. ## Contract and boundary impact - Semantic owner and earliest changed stage: `SafeOutputTree.ts` admission checks and `FirmwareFailures.ts` classification. - Contribution scope fit: existing firmware error projection; no new authority, provider change, or schema change. - CLI and MCP/tool-catalog contract: `invalid_request` / `invalid_input` for caller-input destination failures; no schema or MCP changes. - Provider, bridge, target-format, or platform compatibility: no provider or format changes. - Evidence, artifact, provenance, or reconstruction contract: no evidence or stored artifact changes. - Target selection, authority, upstream behavior, and cleanup details: no new target interaction; cleanup path unchanged. - Generated metadata, package, or installation impact: none. - [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 - Three unit tests in `src/firmware/FirmwareDeadline.test.ts`: 1. `SafeOutputTreeAdmissionFailure("path", "Extraction output root already exists")` produces `AnalysisInputError` with `output_directory` issue and projected `invalid_request`. 2. `SafeOutputTreeAdmissionFailure("unavailable", "Extraction output parent is unavailable")` produces `AnalysisInputError` with `output_directory` issue and projected `invalid_request`. 3. Regression test: `ArtifactReaderFailure("path", "Could not durably sync extraction output")` (sync failure during commit) does NOT convert to `AnalysisInputError` and keeps `execution_failure` classification. - All 7 tests in `FirmwareDeadline.test.ts` passed. - `npm run check:fast`: passed (typecheck and lint). Pre-push check: passed. - [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 - 7/7 unit tests in `FirmwareDeadline.test.ts` passed (includes 3 regressions). - `npm run check:fast`: passed (typecheck and lint). - No real Unblob provider was exercised. Integration-level reproduction was not run. ## Compatibility, safety, and release - Breaking changes or migration steps: none; `invalid_request` is the correct classification for this input. - Real Hopper/Ghidra, browser, or OS coverage: not applicable; no provider execution. - Package or release metadata impact: none. - Security, privacy, process, or containment review: error classification only; no authority change. ## Author readiness Human owner: @codeXsidd - [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 - [ ] 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7103
No description provided.