refactor(src): migrate jobs commands to AppError, drop 484 LOC#83
Merged
refactor(src): migrate jobs commands to AppError, drop 484 LOC#83
Conversation
Two changes bundled because the dead mod.rs wrappers don't delegate to
jobs_commands::* — they're full reimplementations, so deleting them is
orthogonal to the migration.
1. Migrate jobs_commands.rs (10 commands) from Result<T, String> to
Result<T, AppError>:
- create_job / list_jobs / get_job / cancel_job / get_job_logs /
get_job_counts / cleanup_old_jobs — all route through
AppError::db_lock_failed / db_not_initialized / db_query_failed
- Invalid job type or unsupported export format -> invalid_format
- Empty input list -> empty_input("Inputs list")
- No model loaded -> model_not_loaded()
- Job not found -> custom NOT_FOUND_JOB code with id as detail
(we don't have a dedicated constructor for job records, so
introduced a local job_not_found(id) helper routed to the
NotFound category)
- filesystem write errors -> AppError::from(io::Error) via the
existing From impl
- serde_json serialize errors in the export path -> internal()
2. Delete ~484 LOC of dead mod.rs duplicates:
- commands/mod.rs lines 3993-4119 (Job Commands section): duplicate
JobSummary struct + 7 wrappers that reimplement create_job /
list_jobs / get_job / cancel_job / get_job_logs / get_job_counts /
cleanup_old_jobs with their own DB queries.
- commands/mod.rs lines 4968-5324 (Phase 9: Batch Processing
Commands section): duplicate BatchInput / BatchResult /
BatchSource / BatchStatus structs + full reimplementations of
batch_generate / get_batch_status / export_batch_results.
- None were registered (registry.rs points at jobs_commands::*),
none were called externally. Same dead-duplicate pattern as the
Jira block cleaned up in PR #82.
mod.rs: 5592 -> 5108 lines (-484).
Verified:
- cargo check --all-targets clean, zero warnings
- cargo test --lib: 311 pass, 1 ignored
- cargo test --test command_contracts: 8 pass
- pnpm test: 67 files, 262 tests pass
- No frontend exact-string matches on jobs errors
This was referenced Apr 22, 2026
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
Two changes bundled because the dead
mod.rsjob wrappers don't delegate tojobs_commands::*— they're full reimplementations, so deleting them is orthogonal to the migration and pulls in cleanly.1. Migrate
jobs_commands.rs(10 commands)All ten move from
Result<T, String>toResult<T, AppError>:create_job,list_jobs,get_job,cancel_job,get_job_logs,get_job_counts,cleanup_old_jobs) route throughAppError::db_lock_failed/db_not_initialized/db_query_failed.batch_generate—empty_input("Inputs list"),model_not_loaded(),ValidationErrorauto-converts.get_batch_status/export_batch_results— introduced localjob_not_found(id)helper routed toNotFoundcategory with codeNOT_FOUND_JOB(no dedicated constructor exists for job records yet).From<io::Error>impl.AppError::invalid_format.AppError::internal(detail).2. Delete 484 LOC of dead mod.rs duplicates
Same pattern as PR #82 (Jira). Two dead blocks in
commands/mod.rs:Job Commandssection): duplicateJobSummarystruct + 7 wrappers that reimplement the DB-bound commands with their own queriesPhase 9: Batch Processing Commandssection): duplicateBatchInput/BatchResult/BatchSource/BatchStatusstructs + full reimplementations ofbatch_generate/get_batch_status/export_batch_resultsNeither block was registered (registry points at
jobs_commands::*), neither was called externally.mod.rs: 5592 → 5108 lines.Test plan
cargo check --all-targets— clean, zero warningscargo test --lib— 311 pass, 1 ignoredcargo test --test command_contracts— 8 passpnpm test— 67 files, 262 tests pass🤖 Generated with Claude Code