Skip to content

Progressive sessions honour damaged_input (Salvage/Resync), reported as HeaderDamaged - #316

Merged
xbmc4lyfe merged 10 commits into
mainfrom
progressive-salvage
Nov 27, 2026
Merged

xbmc4lyfe merged 10 commits into
mainfrom
progressive-salvage

Conversation

@xbmc4lyfe

Copy link
Copy Markdown
Collaborator

Extends #310's damaged-RAR salvage (extract::Options::damaged_input) to progressive sessions, which RustyGet's live extraction uses.

API

  • ProgressiveOptions::extract.damaged_input is now honoured by ProgressiveSession::new and from_sealed_memory. Refuse (the default) behaves exactly as before.
  • New event ProgressiveEvent::HeaderDamaged { volume: u32, damage: extract::HeaderDamage }, one per damaged header. It arrives before anything read from that header, so a member whose header failed its checksum gets it just before its MemberStarted. It uses the same records as Summary::damaged_headers (offset, kind, name, resumed_at). damage.volume is the volume name the session asked for.
  • Persistent-partial sessions (new_partial) still refuse, whatever the option says. Their journal binds each member to the header bytes it was read from, and a header repaired later would no longer match. This is a follow-up, documented in docs/persistent-partials.md and covered by a test.

Behaviour with holes (docs/compat-options.md, "Damaged headers in a progressive session")

Only bytes the source has delivered are judged:

  • A header still to come (NotYet, volume not there yet) is waited for. It is never reported as damage, and it is read normally once it arrives.
  • A header inside a Hole answer is not damage either. The session stops with HeaderHole, as under Refuse, because repair may still fill it.
  • A resync never searches across a Hole; it stops with HeaderHole instead. On an open-ended source (GrowingFileVolumes), a search that hasn't found a header yet waits for more bytes.
  • Only present-but-wrong headers are salvaged: a failed checksum, fields that don't parse, or a header/data running past the volume's known end (SourceInfo::length unless Advertised(u64::MAX)). The result matches the whole-archive runners: same members, same bytes, same damage list.

Implementation

  • HeaderParser::advance_salvaging sorts header failures the way Volume does: Unreadable / UnexpectedEnd vs. a real error. Under salvage it also takes the volume's known length (set_complete_len), and after a resync it continues with resume_at.
  • The session handles damaged frames (ChecksumMismatch), unreadable or cut headers, and a RAR 5.0 volume without an end header. The rest of a damaged volume is passed over. A volume set moves on to its next volume; a sealed set or a declared last volume may end there.
  • A new Phase::Resync does the search incrementally across polls. It uses RAR damaged-input salvage: Options::damaged_input (Salvage as UnRAR 7.30, Resync) and a headers-damaged signal #310's resync_shape/resync_checks. Work is bounded per volume at 16 × the furthest offset read plus 1 MiB. Its window (at most one chunk plus one candidate header) is charged to MetadataBytes, and cancellation and the per-poll work budget are respected.
  • Solid history follows RAR damaged-input salvage: Options::damaged_input (Salvage as UnRAR 7.30, Resync) and a headers-damaged signal #310's rule: bytes passed over drop the history, so the next solid member stops with SolidHistoryUnavailable.
  • A folder whose damaged header claims data is created and that data skipped, as UnRAR does. A damaged main header in a later volume (or a second one) is taken as present.

Routes covered (tests/progressive_salvage.rs)

  • refuse_fails_at_the_damage_as_before: every damaged case, sealed and piecewise. Refuse fails with no events.
  • salvage_and_resync_extract_what_the_whole_archive_runner_does: all of RAR damaged-input salvage: Options::damaged_input (Salvage as UnRAR 7.30, Resync) and a headers-damaged signal #310's cases and fixtures (RAR5/RAR4 header CRC, main CRC, garbage, zeroed header, cut header, damaged name/type, no end header, the 6 fixtures, two-volume sets including a damaged second main header). For each, Salvage and Resync over sealed memory and over a source delivering 13 bytes at a time give the same files, bytes, folders and damage list as extract::run.
  • a_header_still_to_come_is_waited_for_and_one_in_a_hole_is_not_damage
  • a_resync_never_searches_across_a_hole
  • solid_history_after_a_skipped_header_fails_the_next_solid_member: header lost four ways (hole, service, main, folder).
  • corrupting_every_37th_offset_never_panics
  • resync_crosses_random_data_and_false_headers_in_bounded_work: 4 MiB of noise, and 20 000 false headers.
  • a_persistent_session_still_refuses_damaged_headers (with persistent-partials)

Revert check: with salvage disabled in the session (parsers kept at Refuse), the Salvage/Resync tests fail. On old main the test file doesn't compile, because HeaderDamaged doesn't exist there.

Clean-room: the behaviour matches observed UnRAR 7.30 / 7-Zip 26.06, as #310 recorded it. No third-party source was read.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj

xbmc4lyfe and others added 2 commits November 26, 2026 16:59
…st damaged RAR headers, reported as HeaderDamaged

ProgressiveOptions::extract.damaged_input now reads past damaged RAR 4.x / 5.0 headers in ProgressiveSession::new and
from_sealed_memory as the whole-archive runners do (same members, bytes and HeaderDamage records), and reports each
as the new ProgressiveEvent::HeaderDamaged { volume, damage }. Refuse (the default) is unchanged.

Only delivered bytes are judged: a header still to come (NotYet) is waited for, one inside a Hole answer is
HeaderHole as before (repair may fill it), and a resync never searches across a hole. Under salvage the parser takes
the volume's known length so a cut header or data is UnexpectedEnd. Resync runs as an incremental phase over the
source with #310's candidate filter and a per-volume linear work bound; its window is charged to MetadataBytes.
Bytes passed over break the solid history. Persistent-partial sessions keep refusing (follow-up: the journal binds
members to header bytes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T02:28:40.497510Z adb8d47 Manual request
ℹ️ 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b2cefaa677

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/progressive/session/salvage.rs Resolved
Comment thread src/progressive/session/salvage.rs Resolved
Comment thread src/progressive/session.rs Resolved
…, no salvage before a signature or with encrypted headers

- A resync charges its work allowance for bytes a read delivered, not for the buffer it asked for: a source
  delivering a few bytes a call (or waiting) no longer runs the allowance out while crossing a long stretch.
- A source that ends before a RAR signature is refused as before instead of reading as a damaged empty archive.
- An encrypted-header archive cut at a header boundary is a truncation, not damage: the parser salvages nothing once
  headers are encrypted, at the end of a volume too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 346db4586b

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: e902d8d06c

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 85164fd24b

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: b7681c4882

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b7681c4882

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/progressive/session/salvage.rs Resolved
… main header reads on with an empty one

As Volume::initialize_held does: a main header whose type byte was hit reads as a block of an unknown type, and the
session now takes the main header as present (defaults) instead of failing with 'block before main'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c628f5cd1

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/progressive/session.rs Resolved
Comment thread src/progressive/session.rs Resolved
xbmc4lyfe and others added 2 commits November 26, 2026 18:19
…read is delivered; replacement replay reads salvaged headers

- A HeaderDamaged queued by the read that also ends the session or uses up the poll's work is delivered before the
  end (poll_event drains the queue before its Done fast path and before yielding).
- Strict replacement verification replays the header witnesses under the damaged-input choice they were read with:
  a damaged header is read as it stands (its bytes still compared with the witness) and the replay resumes where a
  resync did, so a member read past damage can still reach Strict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 187c0c1c1b

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/progressive/session.rs Resolved
…racting, whatever its last event

A HeaderDamaged delivered as the session reaches Done (a damaged end header) left extraction_active set, so
poll_verify and publish_recovered refused the artifacts it had handed out. Done now always clears it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: adb8d470c8

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

Local CI (.claude/skills/ci-local/run.sh --host rustyget-x86-c) on the exact head adb8d47: fmt, clippy (plain + persistent-partials), workspace tests (plain + persistent-partials), doctests (plain + persistent-partials): ALL GATES PASSED @ adb8d47 (full). Codex review on adb8d47: no findings; every review thread is resolved; the branch is up to date with origin/main.

@xbmc4lyfe
xbmc4lyfe merged commit ba9e8f4 into main Nov 27, 2026
5 of 7 checks passed
@xbmc4lyfe
xbmc4lyfe deleted the progressive-salvage branch November 27, 2026 02:44
xbmc4lyfe added a commit that referenced this pull request Nov 27, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
xbmc4lyfe added a commit that referenced this pull request Nov 27, 2026
…kb and 7z x -so hand over of a failing member (#317)

* Opt-in unverified output: UnverifiedOutput::Emit writes, prints and streams what UnRAR and 7-Zip hand over of a failing member

- Options::unverified_output (whole-archive RAR runners, RarSession extraction with keep_broken): a RAR member cut
  off by a missing volume keeps every byte UnRAR 7.30 `x -kb` keeps (RAR 3.x/4.x: LZ tokens starting in the last
  30 bytes left out; RAR 5.0: the partial block decoded, symbols in the last 128 bits left out, a block with under
  1024 bytes skipped; observed on 50 cut points).
- RarPrintOptions::unverified_output (`unrar p`): a member failing on its own data prints what was decoded of it;
  RarEntryOutcome::unverified_bytes says how many bytes went out.
- sevenzip::print_selected_with_options + SevenZipPrintOptions (`7z x -so`): a failing 7z member streams what
  7-Zip 26.06 streams (CRC failure: all; data error / cut folder: the bytes before it); Summary::unverified.
- SelectOptions::unverified_output (SelectedEntry): 7z as above; RAR 3.x/4.x unsupported VM filters streamed
  unfiltered; read fails with UnverifiedWritten { bytes, cause }.
- LZMA readers hand out the bytes decoded before a data error, then the error.

Defaults unchanged. tests/unverified_output.rs checks each route against the reference tools' output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj

* Codex on #317: 7z unverified members keep archive order, output errors propagate, LZMA errors at the last byte stay

- A member failing behind ones held for the folder's CRC is queued behind them (printed in archive order).
- wrong_password() returns a result: an output error replaying held members ends the run.
- The LZMA readers put a data error off only when the caller asked for more than was made; one asking for exactly
  the bytes left never reads again, so the error is returned then (default outcomes unchanged).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj

* Merge origin/main; unverified_output in the new rar5_link_password literal

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj

* Codex on #317: cut-member output faults end the run, printing hands over buffered bytes, unfiltered prerequisites don't stop a selected read

- Run::emit_unverified returns a fault writing the flushed bytes as the run's terminal error.
- RarSession decoding under UnverifiedOutput::Emit flushes what a failing decoder still buffers before the failure
  (printing and keep_broken extraction get every byte decoded).
- SelectedEntry (Emit) goes on past a solid prerequisite written unfiltered; only the selected member's own
  unfiltered write fails the read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj

* Codex on #317: a split part failing its own checksum hands over what was decoded under Emit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj

* unverified_output in the Options literal #313 added

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj

* unverified_output in the Options literals #316 added

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant