Repository navigation
Conversation
Adds the Backend trait (blocking, Send + Sync, object safe), a Registry with namespaced printer ids, partial-failure listing, neutral errors with native codes, document formats, a UserConfirmed consent marker for network backends, and the system spooler (cups or spooler) as a built-in adapter over the existing functions. The existing public API is unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…cancel and retry vocabulary Backend::submit now returns a Submitted as soon as the printer has accepted the document and never waits for the print. A job is followed with optional trait methods (watch_support, recommended_poll_interval, job_status, cancel_job) whose defaults say "accepted, outcome unknown". The registry routes job ids by prefix and offers submit_job, job_status, cancel_job and job_watch; Registry::submit still returns a Receipt. JobWatch is a caller-driven state machine with an injectable clock, a backoff that slows while the status does not change, a max_wait, a cancel token and failure retries; wait_for_job is the blocking convenience built on it. PrintError separates is_retryable (transient) from retry_safety (Safe, Idempotent, OutcomeUnknown), and adds phase and retry_after; RetryPolicy gives a bounded jittered backoff that never repeats an outcome-unknown error. The survey of how comparable stacks do this is in docs/job-lifecycle.md. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Adds craft_print::wsd, built on craft-wsd (named only in wsd/adapter.rs): typed WS-Print operations, the print ticket with its TicketShape quirk modes, the job flow with polling and tolerant cancel, pass-through and PWG raster encoders, and WsdBackend, a Network-class registry backend named wsd. It lists only the printers the app added, discovers nothing, maps printer elements to PrinterDetails and errors to the neutral PrintError with wsd-fault native codes. Tests run it through the registry against an in-memory fake printer and hostile loopback servers; a loopback test against a real fakeprint server runs only when FAKEPRINT_URL is set. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…build in CI Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ob status, cancel and classified retries WsdBackend::submit creates the job and sends the document and returns as soon as SendDocument is accepted; it no longer polls for up to five minutes. The job handle is wsd:<printer url>#<job id>. job_status is one GetJobElements mapped onto the neutral JobStatus (a forgotten job is NotFound with a message that says so), cancel_job is the tolerant CancelJob, watch_support is Poll and the recommended interval is configurable (with_poll_interval replaces with_poll). Errors are classified by what failed and which operation was in flight: transient or not, safe to repeat or not, phase, and a suggested wait. HTTP 408, 425, 429 and 5xx except 501 and 505 are retryable; a refused redirect, a policy refusal, 501 and 505 are not. A connection closed or a timeout after a create or send may have been delivered, so it is outcome-unknown and the backend leaves any created job alone; the same failure on a query or cancel is idempotent. WsdBackend::reconcile looks for the job by title and user before anything is resent. Tests: submit returns while the printer keeps the job, a watch on an injected clock, a forgotten job, a lost reply to SendDocument and CreatePrintJob with reconcile, no automatic retry of an outcome-unknown submit, and the retry table for every error kind and operation. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…kinds, stages and Retry-After The WSD adapter now follows craft-wsd's typed errors: a transport failure carries its kind and the stage the exchange reached, an HTTP status error and a fault carry the printer's Retry-After, and the safety of repeating comes from craft-wsd's own retry_safety(idempotent) instead of reading the failure text. The closed-connection error kind is gone (it is a transport kind now), the retry table and its tests cover every typed kind against every operation, and the lock follows craft-wsd to its new commit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… other non-retryable HTTP errors Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
craft-wsd replaced TransportKind::Other with InvalidResponse (a peer that did not speak HTTP: Failed, not retryable) and Io (an I/O error that matched no other kind: Unavailable, retryable), both at the reply stage. A request the HTTP client could not build now arrives as Invalid, which stays a preparation failure and Safe. The retry table, the every-kind test and the lifecycle doc follow, and the lock resolves craft-wsd e06d454. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
SubmitRequest carries JobOptions (media, orientation, quality, resolution, an explicit colour choice and the expected page count) as hints a backend may ignore, with new JobHint entries for what it honours. JobRef is replaced by a typed JobId with Display, FromStr, backend(), native() and new(), a typed ParseJobIdError, and the registry, watch and free functions take it. Progress is now an event with an optional total, and the expected page count becomes the sheet total for progress events and status readings only where the backend reports none. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… feature The wsd backend maps JobOptions into each job's ticket (media size, orientation, quality, resolution, explicit colour) and keeps the ticket shape, strict mode and transfer as backend-wide configuration; a clone with different settings shares the printer list, which is how an app varies them per invocation. WsdBackend::job_id, parse_native and parse_job_id name and read wsd jobs without string handling, and a wsd backend refuses a job id of another backend. The new cargo feature testing exports craft_print::testing::FakeBackend and craft_print::wsd::testing (the in-memory WS-Print printer), and the crate's own tests use them in place of their private copies. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nings Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… the feature is off Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…and the common remote-job base It describes one PrintJob per user-visible print that survives retries, the tag that lets a reconcile find an already-created job, and the backend-neutral job listing that CUPS, IPP, the Windows spooler and WS-Print can each fill in, with a per-source mapping table. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A leaf crate: NativeCode, BackendName/JobId/DeviceId, RetrySafety/RetryPolicy and advise() with seeded jitter, plus plain data records a UI can show for print and scan alike (JobView, DeviceView, Tag, Fingerprint, Tri indicators). No lifecycle, reconcile engine or I/O. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…tral job listing PrintJob is the lifecycle record of one user-visible print: the caller advances it with one bounded request per step on an injectable clock, it retries only what is safe, parks an unknown outcome in NeedsAttention for a reconcile, and keeps the attempts, a de-duplicated status trail and progress. Each print makes a short random tag that a backend carries where its protocol allows (default on for network backends, off for the local spooler), so a reconcile can find a job whose reply was lost. RemoteJob, JobFilter, Fingerprint and Reconciled with the optional Backend methods list_jobs, find_job, tag_support and job_query_caps give CUPS, IPP, the Windows spooler and WS-Print one common base; the registry routes them by printer id. The WS-Print backend carries the tag in the ticket job name and lists active and finished jobs, and the exported fakes gain CUPS-like and IPP-like presets, scripted lost replies and a queue to inspect. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Thirty-five tests drive PrintJob through the exported fakes on a manual clock (state machine, automatic retry and its limits, the tag, reconcile, cancel in every state, foreign jobs, totals, snapshots) and five more run it over the WS-Print backend and its in-memory printer, including a lost SendDocument reply that is reconciled by tag. The README gets a section on tracked jobs and the new fakes, and the job lifecycle note points to the design note. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The shared vocabulary now comes from the craft-job crate (storytold#120) and is re-exported at the old paths: JobId, NativeCode, RetrySafety, RetryPolicy, Jitter, RetryAdvice, JobState, Progress, ExpectedTotals, Tag, TagSupport, TagPlacement and Fingerprint. The duplicated definitions are removed from craft-print, and the printing-only helpers (a random tag, applying it to a name within a length limit, the reconcile listing a fingerprint asks for, expected totals from a request, jitter from a clock) are extension traits. Renames that break callers: JobTag is Tag (now Copy), ParseJobIdError is ParseIdError, RetryAdvice::CheckPrinterFirst is CheckDeviceFirst, JobState::Stopped is NeedsAttention, TagPlacement::JobName and Native are JobNameSuffix and NativeAttribute, TagSupport is an enum instead of a struct with a matchable flag, and RetryPolicy::next_delay is replaced by craft_job::advise through advise_error. JobState::CompletedWithWarnings is gone: a completed job the printer qualified is Completed with JobStatus::warnings, and a PrintJob still ends as Outcome::CompletedWithWarnings. PrintJob::view and Snapshot::view give the print as a craft_job::JobView (state, reasons and warnings, progress, wall-clock times, the document sent, attempts, the last error with its retry advice and native code, the tag and the printer). Snapshot gains a times field. Docs and tests are updated; print_job_view.rs covers the view for every lifecycle state. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…format conversion Quality gains Photo (a hint, like the others). DocumentFormat gains Jpeg, Png, Tiff, PlainText, Xps and OpenXps with mime(), from_mime(), extension(), from_extension(), sniff(), detect() and a configurable negotiate() against a printer's own list. PrinterDetails lists the printer's resolutions. The app registers a DocumentConverter; when a printer does not accept the document's format the registry picks the best target the converter makes and the printer lists, chooses the resolution nearest a target dpi from the printer's list, runs the converter and sends the result, or fails with a typed UnsupportedFormat naming both sides. A neutral PWG raster encoder (craft_print::pwg) is available without the wsd feature. The built-in spooler stays PDF-only. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…sion Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ons and registry conversion The WS-Print backend maps Quality::Photo into the ticket when the printer lists it (leaves it out with a warning otherwise, refuses it in strict mode), names every listed MIME type that has a DocumentFormat and passes a document in any of them through unchanged, and fills PrinterDetails::resolutions from the GetPrinterElements it already reads. It reports formats_per_printer, so a registry with a converter reads the printer's list before converting. wsd::pwg now re-exports the neutral craft_print::pwg encoder. The fakes gain qualities and resolutions (FakePrinter) and per-printer formats (FakeBackend). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Off by default; with it, the ids, tags, timestamps, records, JobView and DeviceView derive Serialize and Deserialize so an app can journal and print jobs without hand-written JSON. Lowercase snake_case names, ids as strings through Display/FromStr, durations as whole milliseconds, NativeCode and IndicatorKey strings interned on the way in (bounded), unknown fields ignored, optional fields defaulted, and a documented Unknown fallback where one exists. Round-trip tests behind the feature (serde_json is a dev-dependency), CI runs clippy, tests, docs and the wasm32 check with it, README documents the wire format. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Brings in Quality::Photo, the extra document formats and negotiation, printer resolutions, the document converter path, the public pwg module and the fake additions. The craft-job names and types win for the shared vocabulary; the converter path, formats and resolutions are kept. PrintJob now records the conversion the registry made (RequestRecord and Snapshot), shows the document as it was sent in view(), and a new test file covers a tracked print with a converter, a retry that converts again, and Photo on a raster-only WS-Print fake. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Brings in the README fix and the optional serde feature of craft-job; the feature is not enabled here. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…wait out the device before advising a resend PrintJobConfig gets a Staleness policy. Silence of three minutes or an unchanged reading for ten minutes while processing (thirty while pending) sends the print to NeedsAttention with the reasons no-news-since and stalled, probing every thirty seconds so a printer that comes back is noticed. Held and stopped jobs never time out. Three hours after acceptance the row ends as the new Outcome::Abandoned, which is not a failure and never causes a resend, and dismiss and dismiss_and_cancel end it earlier. Backends without status are not polled and never time out. After a send whose outcome is unknown the advice to resend waits for the device's own window (Backend::open_job_timeout, 65 seconds for WS-Print), and a reconcile that finds a document-timeout abort advises an immediate retry. Staleness::disabled keeps the earlier behaviour. The design note has a new section on the timeouts and their sources. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…eported Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…acking Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…, now that craft-job has the state The reason abandoned-no-outcome is kept. Tests, the design note and the README no longer say craft-job lacks an abandoned state. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
Author
|
Folded into #116, which now carries the whole print stack as one pull request, as six logical commits. The tracked-job commit here is the third of those, with the same content (the |
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.
craft-print: a tracked
PrintJob, an idempotency tag and a backend-neutral job listingStacked on slice 1 (#116, the backend trait and registry) and slice 2 (#118,
the WS-Print backend, now at
384004b), and depends oncraft-job(#120, now ataa6ea75).Review only the commits above
7eaf366other than the twocraft-jobmerges and the slice-2 merge:dae53d9(the designnote),
37544c9(the implementation),8129560(tests and docs),bdc2d6a(merge ofcraft-job, no conflicts),bce801d(craft-print builds on
craft-job, plusPrintJob::view),54dc532(merge of slice 2 at384004b: conflicts inbackend.rs,job.rs,lib.rs,registry.rs,wsd/backend.rs, resolved with thecraft-jobnames for the sharedvocabulary and slice 2's Photo, formats, resolutions, converter and fakes kept),
3e21544(merge ofcraft-jobat7d5aa42:README fix and an optional
serdefeature, no API change, feature not enabled here) and34257ef(job timeouts, seebelow),
ecee2ef(merge ofcraft-jobataa6ea75, which addsJobState::Abandoned; no conflicts) and122f117(anabandoned print is
JobState::Abandonedinview()). Branchcraft-print-job-tracking, head122f117.What
Merged in from slice 2 (
384004b), now cooperating withPrintJob:Quality::Photo, the extraDocumentFormatvariants and
negotiate,PrinterDetails::resolutions, theDocumentConverterpath (Registry::set_converter,submit_job_with_details,Submitted::conversion), the publicpwgmodule and the fake additions. A tracked print goesthrough the converter on every attempt (the document source is read and converted again after a safe failure), the tag is
applied once,
RequestRecord::conversionandSnapshot::conversionsay what the registry did, andview()shows thedocument as it was sent (the converted format and size).
Timeouts (
34257ef,PrintJobConfig::staleness,Staleness): an accepted print that is never heard from no longerstays
Acceptedfor ever. All times are on the job's clock, all fields are configurable, andStaleness::disabled()restores the earlier behaviour. A timeout is never
Failedand never resends: the device may still print.silence_afterNeedsAttention, reasonno-news-since:<unix secs of the last good read>; probes every 30 s, a good read returns the print toWatchingstall_after_processingsame_as) whileProcessingNeedsAttention, reasonstalled, adviceCheckDeviceFirst; any progress resets itstall_after_pendingPendingceilingOutcome::Abandoned(not a failure),JobState::Abandonedinview()(terminal, not a success, counted byneeds_attention) plus the reasonabandoned-no-outcomedismiss()/dismiss_and_cancel(&Registry)reconcile_afterBackend::open_job_timeout()(WS-Print 65 s; the IPP-like fake 240 s)PrintJob::reconcile_wait()); a reconcile that finds itAbortedwith a timeout reason advisesRetryNowA backend without status (
watch_support() == None) is not polled and never times out: the print isAccepted, alreadysettled (
SimpleState::Sent,JobState::Unknown), the same meaning as IPPqueued-in-device. Sources: CUPSMaxJobTime10800 s, RFC 8011 5.4.31 (
multiple-operation-time-out60 to 240 s), 5.3.7.2 (history of at least 60 s), thesubmission-interrupted/aborted-by-systemreasons, WS-PrintDocumentTimeoutErrorafter 60 s. The figures beyondthose protocol numbers (3 min, 30 s, 10 min, 30 min) are judgement. The Windows spooler's timeouts are unverified.
craft_print, one new dependency (craft-job, a leaf crate with no dependencies of its own) and no new feature:craft-job: the vocabulary shared with scanning (JobId,NativeCode,RetrySafety,RetryPolicy,RetryAdvice,Jitter,JobState,Progress,ExpectedTotals,Tag,TagSupport,TagPlacement,Fingerprint,namespaced_id,split_id) iscraft-job's and is re-exported here. Stays in craft-print:PrintJoband itslifecycle,
Attemptand the trail, the reconcile engine,RemoteJob/JobFilter/JobQueryCaps,ErrorKind/PrintError,Phase,Clock. What printing adds to the shared types is a set of extension traits (re-exported,imported where used):
TagExt(Tag::random(),apply_to,strip,find_in),TagSupportExt(carries,matchable),FingerprintExt,ExpectedTotalsExt(for_job,apply) andJitterExt(from_clock).PrintJob::view()/Snapshot::view(): the print as acraft_job::JobView(the record a scan job fills too):the printer's job id once accepted (a
local:print-<n>id before),JobKind::Print, the title, acraft_job::JobStatemapped from the lifecycle (NeedsAttentionisNeedsAttention), reasons and warnings,progress with optional totals, wall-clock
JobTimes, the document sent as aDocumentRef, the attempt count, the lasterror as an
ErrorSummarywith its retry advice and native code, the tag and the printer id. No I/O. The mapping is atable in
docs/job-tracking.md.PrintJob: the lifecycle record of one user-visible print, stable across retries. The caller drives it withadvance(&Registry)(at most one bounded request per call, no thread, no timer, no async runtime, an injectableClock);snapshot()is a cheap immutable view for a UI (no I/O; the attempt list and the status trail are sharedArcs, not copied). The lifecycle is its own state machine, separate from the printer'sJobState:Preparing,Submitting,Accepted,Watching(JobState),RetryScheduled { attempt, next_at },NeedsAttention(the outcome ofa send is unknown) and
Terminal(Completed | CompletedWithWarnings | Failed | Cancelled | Aborted | Abandoned), reduced for a UIto
SimpleState. The lifecycle keepsOutcome::CompletedWithWarnings; the printer'sJobStatedoes not.Accepted(Option<JobId>)or a typed
AttemptError { kind, safety, retry_after, native, phase, message }, and how the remote job ended); therequest as sent (
Job,JobOptions, the resolved printer, the tag, the document's length, format and a 64-bit FNV-1afingerprint, the backend's own description of how it was sent) and never the document bytes (a
DocumentSourcesupplies them again per attempt:
BytesSource,FnSource); a reconcileFingerprint(craft-job's); a bounded, de-duplicatedstatus trail with timestamps; progress with optional totals (
JobOptions::expected_pagesstill flows, a printer's owntotal still wins); warnings.
RetrySafety::Safeerrors that are also retryable, under aRetryPolicythat is on by default (3 attempts in a row, the device's
retry_afterhonoured,with_retry(None)disables it,per job). An
OutcomeUnknownfailure is never retried automatically: the print goes toNeedsAttention;reconcilefinds the already-created job, thenaccept(job)adopts it orretry()resends. A printer-sideAbortedorCancelledis a manualretry(): a new attempt, a new remoteJobId, history kept.retry_advice()isRetryNow,RetryAfter(duration),CheckDeviceFirstorDoNotRetry(craft_job::RetryAdvice).cancel()works in everystate (
cancel_token()lets an app thread stop a submit in flight).PrintJobmakes a short random tag (8 hex characters) once, the same for every attempt.SubmitRequest::with_tag;Backend::tag_support() -> TagSupport(None,Carried(TagPlacement::{JobNameSuffix, DocumentName, NativeAttribute})when listings return the tag,Partial(..)when a device may rewrite it). The backend applies itexactly once (
TagExt::apply_tokeeps the suffix" [ref abc123de]"inside the backend's length limit); the registry drops it for a backend that cannot carry it;Submitted::tagsays what was carried.TagPolicy::Auto(default) is on forBackendClass::Network, off for thelocal spooler;
AlwaysandNeveroverride it per job.RemoteJob,JobFilter,Reconciled,JobQueryCaps(andFingerprint, fromcraft-job) and theoptional
Backendmethodslist_jobs(defaultUnsupported),find_job(default built onlist_jobs),tag_supportandjob_query_caps, routed by printer id throughRegistry::list_jobs,find_jobandbackend_info(plus
Registry::default_printer). Foreign jobs are listed too (ours == false);JobFilter::tagonly marks, itnever hides.
list_jobsreadsGetActiveJobsandGetJobHistory(andGetJobElementsfor up to a few summaries without a name);find_jobmatches by tag, else by title and the backend'suser.
Submitted::effectivereports the ticket shape. The olderWsdBackend::reconcileandwsd::Reconciledareunchanged.
testing):FakeBackend::cups_like(local, no status, no tag support, no listing) andFakeBackend::ipp_like(network, pollable, a listing with creation time, user and history, the tag in a nativeattribute),
with_submit_script([SubmitStep::LoseReply(..), ..])(the job exists but the reply is lost),seed_jobfor foreign jobs,
remote_jobs(),with_tag_support,with_query_caps. The WS-Print fake needed no change.crates/print/docs/job-tracking.md(the design note, with a mapping table for CUPS, generic IPP, theWindows spooler and WS-Print: tag support, listing, creation time, state vocabulary, cancel, forgetting, and what the
built-in adapters do today), a README section and a pointer from
job-lifecycle.md.Why
Slices 1 and 2 follow one remote job and say whether resending a failed request is safe. A person pressed Print once
and expects one sheet, however many connections, retries and printer-side restarts that takes. The recurring hard case
is a connection that closes after
SendDocumentwas written: the job may exist, and guessing from the title can printtwice or not at all. The tag makes "did it?" answerable where the protocol can carry it, and the neutral listing makes
the same question askable of a spooler, an IPP printer or WS-Print. The apps (pdfcraft's CLI and GUI) need one object per
print to bind a UI row to, not a bag of ids that change per attempt.
How
PrintJobis built on the existing pieces:Registry::submit_job,JobWatch(for following),RetryPolicy(for the automatic retry) and
ManualClock. Nothing in slices 1 and 2 changes behaviour; the additions are new pubitems, the new
SubmitRequest::tagandSubmitted::{tag, effective}fields, and the new optionalBackendmethods(all with defaults, so an existing backend compiles unchanged).
retryhelper decide withcraft_job::adviseoverRetryFactsbuilt from the error (is_retryable(),retry_safety(),retry_after()).SafeandIdempotentretry as before; anOutcomeUnknownerror isCheckDeviceFirstalso when the attempts areused up (
next_delayansweredNonethere), which changes nothing in the behaviour of the loops.JobState::Completedwith a warning inJobStatus::warnings;PrintJobthen ends asOutcome::CompletedWithWarningsand copies the warnings. A job theprinter forgot still ends as
CompletedWithWarnings.craft_job::Tag::parse_from_title(the last well-formed[ref xxxxxxxx]markeranywhere in the name), so a name a device appended to is still recognised; only a trailing suffix is stripped for the
display title.
PreparingandSubmittingare separate, so a worker can publish "sending" before the blocking send. The defaultprinter is resolved once and pinned, so every retry goes to the same printer.
NeedsAttentionis not a failure: nothing is resent untilreconcileran (one idempotent read) and a person or theapp chose
acceptorretry.NotFoundadvisesRetryNowonly where the backend lists finished jobs(
JobQueryCaps::history), otherwiseCheckDeviceFirst.alone is reported and left alone, because it could be someone else's.
serde; nothing needs changing to add that behind afeature later.
Unsupportedforlist_jobsand carry no tag.lpandlpstatshow no titles and IPP listing needs a client this crate does not have; the Windows path does not keep thespooler job id. Neither can be exercised on the development machines or in CI, so they are not shipped untested; the
design note says how each would map.
How verified
On Windows, at
122f117:cargo test -p craft-print362 passed, 0 failed, 2 ignored (also with--features testing);--no-default-features223 passed, 0 failed, 2 ignored (the wsd tests are cfg-gated off).cargo test --workspace:616 passed, 0 failed, 4 ignored (including
craft-job). The new files areprint_job_conversion(4 tests: a trackedprint converted for a raster-only printer with the tag applied once and the options forwarded, a retry after a
Safefailure that reads the source and converts again, Photo quality on a raster-only WS-Print fake with the resolution
chosen, and no common format failing before anything is created) and
print_job_staleness(10 tests: silence andrecovery, the never-read token, stall reset by progress, pending vs processing thresholds, held and stopped never
timing out, the ceiling, dismiss and dismiss-and-cancel, no-status backends,
Staleness::disabled, thereconcile_afterwindow and the document-timeout advice).print_job_stalenessnow assertsview().state == JobState::Abandoned(terminal, needs attention, not a success) for both theceiling and
dismiss(), where it assertedUnknownbefore; the reason is still checked.print_jobtests now build their prints withStaleness::disabled()(their fakes answerUnknownfor ever, which thenew rules would end at the 3 h ceiling);
print_job_conversionscripts aCompletedstatus for the same reason.craft-jobnames and semantics: the lib tests ofretry.rs(thenext_delaytests now askadvise_error; anOutcomeUnknownerror isCheckDeviceFirst, also with the attempts used up, and the twodelay and jitter tests moved to
craft-job, which has them),tag.rs(Tagand the extension trait; a marker inthe middle of a name is now found, which the old trailing-only rule did not),
job.rs(noCompletedWithWarningsstate, warnings are part of a reading),
remote.rs(Fingerprinthas a submission time and a window),watch.rs;and the integration tests
job_lifecycle,print_job,print_job_wsdandwsd_registry(renames,Completedpluswarnings instead of
CompletedWithWarnings,Fingerprint::new(title, timestamp)). No assertion about behaviour wasloosened.
cargo fmt --checkclean;clippy --workspace --all-targets -D warningsclean, and for-p craft-printwith thedefault features,
--no-default-featuresand--features testing;cargo check -p craft-print --target wasm32-unknown-unknownpasses;cargo doc -p craft-print --no-depswithRUSTDOCFLAGS=-D warningspasses.ManualClockand the public API only: the state machine and its trail; auto-retry ofSafeerrors up to the cap and thenFailed, with the device's wait honoured and retry switched off; no automaticretry of an unknown outcome (however long the clock moves, one send); reconcile finds the already-created job by tag
on the IPP-like fake and on the WS-Print fake (over a transport that loses the
SendDocumentreply), and reportsAmbiguousandNotFoundwithout tag support, with the right advice (the CUPS-like fake can only sayCheckDeviceFirst); retry after a printerAbortedmakes a new attempt with a newJobIdand keeps the history;cancel in every state (including an unknown outcome); the tag is made once, is the same across attempts and appears
exactly once in every attempt's job name, including a 400-character title cut to 255; foreign jobs are listed with
ours == false; expected totals still flow; a snapshot makes no backend call and is not changed by later steps.print_job_viewchecksview()for a new print, every printer state through the lifecycle (pending, held, processing,a stopped printer, completed), the id (local before, the printer's after, local again after a manual retry), the
document, tag, times, progress totals (including expected totals), completed with warnings, a forgotten job, a
printer abort, completed with errors, a refusal (error label, advice, native code), an unknown outcome
(
CheckDeviceFirst), a scheduled retry (RetryAfter), a cancel, a backend that cannot report, and thatPrintJob::view()equalsSnapshot::view().Not verified:
devices list jobs (
GetJobHistorywindows, whether a job name is returned untouched) is untested.lp/lpstat) is only compile-checked on Windows and wasm, and the CUPS and Windows-spoolerlisting is not implemented (see How).
Boundaries
serde.advance).UserConfirmed, now also onPrintJob.Candidate follow-ups (not in this PR, not approved)
PrintJob(andserdefor its plain types, now thatcraft-jobhas the optional feature).Consumers
pdfcraft's CLI
print --wsdand its Print dialog (slice 3'scraft-ui::printing::network) can replace their own retry andreconcile logic with one
PrintJobper print and aSnapshotper frame. Nothing in the apps changes in this PR.Review order
Stacked on #116 and #118 and dependent on #120: review only the commits above
7eaf366(thecraft-jobmerge is #120'scontent). Start with
crates/print/docs/job-tracking.md(section 3 has theview()mapping); the code issrc/tracked.rs(PrintJob),src/tag.rs,src/remote.rs, theBackendadditions insrc/backend.rs,src/registry.rs, the WS-Print changes insrc/wsd/backend.rs, and the fakes insrc/testing.rs.🤖 Generated with Claude Code