Repository navigation
feat(nzb-postproc): publish typed terminal failure codes - #150
Closed
thedancingdeveloper wants to merge 2 commits into
Closed
thedancingdeveloper wants to merge 2 commits into
thedancingdeveloper wants to merge 2 commits into
Conversation
Persist an engine-owned failure code with each terminal history row instead
of requiring consumers to parse human-readable diagnostic prose, and make the
durable terminal row authoritative over a job's lingering queue view.
- New `JobFailureCode` enum (`nzb-core`) with stable snake_case wire values
(Display + FromStr): articles_unavailable, repair_failed,
archive_password_required, archive_invalid, storage_unavailable,
download_failed.
- Post-processing assigns codes from causal stage state: `run_pipeline`
threads a `failure_code` (articles-unavailable, repair-failed) and
`run_extract_stage` returns a typed code, including a typed
`ArchivePasswordRequired` error (replacing the `anyhow::bail!("archive is
password-protected")` prose that consumers had to string-match).
- Persist `HistoryEntry.failure_code` (DB migration v12 adds the column and
backfills existing failed rows to `download_failed`); `history_insert`
enforces the invariant that a Failed row carries exactly one code and a
non-Failed row carries none.
- `queue_manager` tracks the code in memory across pause/resume/clear and
writes it on terminal transition; `queue_admission_observe` now consults the
authoritative history row before the queue view, and reports the code via
`QueueAdmissionState::History`. Exposed on the history API response.
Ported from MrVampy/rustnzb (e0870d8), adapted to main: DB migration
renumbered v10 -> v12 (main's v10/v11 are damage_ledger / queue_admissions);
history SQL column indices adjusted for main's `retry_data` column; the
pipeline changes reapplied onto main's `run_pipeline_with_cleanup` structure;
and `QueueAdmissionState::History` extends the variant added in the idempotent
queue-admission change this branch is stacked on. Fork flake/workspace bumps
excluded.
Tests: JobFailureCode wire-value roundtrip; typed ArchivePasswordRequired
survives as a downcastable error; run_extract_stage / run_pipeline code
assignment; DB migration backfill, history invariant, and terminal-history
authority over the queue view; queue_manager terminal-code persistence
(ArchiveInvalid / DownloadFailed). Full nzb-core / nzb-postproc / nzb-web /
rustnzb suites pass; clippy/fmt clean.
Co-Authored-By: MrVampy <4302946+MrVampy@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The desktop app depends on `rustnzb`/`nzb-web` by path; the new dependencies added by this change must be reflected in desktop/src-tauri/Cargo.lock so the `desktop` CI job (built with --locked) accepts it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports typed terminal failure codes from
MrVampy/rustnzb(e0870d8): persist an engine-owned failure code with each terminal history row instead of making consumers parse human-readable diagnostic prose, and make the durable terminal row authoritative over a job's lingering queue view.What it adds
JobFailureCodeenum (nzb-core) with stable snake_case wire values (Display+FromStr):articles_unavailable,repair_failed,archive_password_required,archive_invalid,storage_unavailable,download_failed.run_pipelinethreads afailure_code(articles-unavailable, repair-failed) andrun_extract_stagereturns a typed code — including a typedArchivePasswordRequirederror that replaces theanyhow::bail!("archive is password-protected")prose consumers previously had to string-match (this prose-matching debt was still live on main'sunpack.rs).HistoryEntry.failure_code(DB migration v12 adds the column and backfills existing failed rows todownload_failed);history_insertenforces the invariant that a Failed row carries exactly one code and a non-Failed row carries none.queue_managertracks the code in memory across pause/resume/clear and writes it on terminal transition;queue_admission_observenow consults the history row before the queue view and reports the code viaQueueAdmissionState::History. Exposed on the history API response.Port notes
damage_ledger/queue_admissions).retry_datacolumn (fork didn't have it); newfailure_codecolumn appended toSELECTs to avoid index churn.run_pipeline_with_cleanupstructure (fork's wasrun_pipeline_with_resources).QueueAdmissionState::Historyextends the variant added in feat(nzb-web): idempotent queue admission via Idempotency-Key #149.Tests
JobFailureCodewire-value roundtrip; typedArchivePasswordRequiredsurvives as a downcastable error.run_extract_stage/run_pipelinecode assignment (ArchiveInvalid, ArticlesUnavailable).download_failed, completed untouched); history invariant (Failed ⇔ code present); terminal-history authority over the queue view.queue_managerterminal-code persistence (ArchiveInvalid for raw-artifacts, DownloadFailed fallback).cargo clippy --workspace --all-targets+cargo fmt --checkclean.Original author: @MrVampy (credited via
Co-Authored-By; ported by hand due to migration collisions and divergent pipeline/history code on main).🤖 Generated with Claude Code