@@ -23,8 +23,7 @@ use crate::queue_backoff::queue_retry_after_ms;
2323type JobWrites = Vec < ( KeySpace , Key , Value ) > ;
2424type JobDeletes = Vec < ( KeySpace , Key ) > ;
2525
26- /// Single decode chokepoint for persisted job records. Wrapping the record in a
27- /// version envelope later (#286) is a one-site change here.
26+ /// Single decode chokepoint; wrappable in a version envelope later (#286).
2827pub fn decode_job_record ( bytes : & [ u8 ] ) -> Result < JobRecord , ConversionError > {
2928 JobRecord :: from_bytes ( bytes)
3029}
@@ -41,8 +40,7 @@ pub enum JobMutationError {
4140 Storage ( String ) ,
4241}
4342
44- /// The single schedule-index entry for a record follows its state: queued jobs
45- /// live under `due/`, claimed/running under `lease/`, terminal under `prune/`.
43+ /// Schedule-index key by state: queued -> due/, claimed/running -> lease/, terminal -> prune/.
4644fn schedule_index_key_for ( record : & JobRecord ) -> Key {
4745 match record. state {
4846 JobState :: Queued => job_due_index_key ( record. due_at_ms , record. job_id ) ,
@@ -65,9 +63,7 @@ fn empty_value() -> Value {
6563 ByteView :: from ( Vec :: new ( ) )
6664}
6765
68- /// Storage writes for creating a fresh job: record + schedule index + owner index
69- /// (+ dedup index when a key is set). This is the composable primitive a producer
70- /// can splice into its own transaction; the ≤4 writes of the submit budget.
66+ /// Writes creating a fresh job (<=4 keys); composable into a producer transaction.
7167pub fn job_insert_entries ( record : & JobRecord ) -> Result < JobWrites , ConversionError > {
7268 let mut writes = vec ! [
7369 (
@@ -96,8 +92,7 @@ pub fn job_insert_entries(record: &JobRecord) -> Result<JobWrites, ConversionErr
9692 Ok ( writes)
9793}
9894
99- /// Record + owner index + prune index deletes for a pruned terminal job. The
100- /// dedup entry was already removed when the job first went terminal.
95+ /// Deletes for a pruned terminal job (its dedup entry is already gone).
10196pub fn job_prune_delete_entries ( record : & JobRecord ) -> JobDeletes {
10297 vec ! [
10398 ( JOB_KEYSPACE . to_string( ) , job_record_key( record. job_id) ) ,
@@ -160,9 +155,7 @@ fn guard_token(record: &JobRecord, token: Ulid) -> Result<(), JobMutationError>
160155 }
161156}
162157
163- /// Read a job under a write transaction, apply `mutate`, and persist the record
164- /// plus its index deltas atomically. State changes are validated by the pure
165- /// transition guard so index and record can never disagree.
158+ /// Read, mutate, and persist a job with its index deltas in one transaction.
166159pub async fn mutate_job < F > (
167160 storage : & StorageHandle ,
168161 job_id : JobId ,
@@ -249,8 +242,7 @@ pub enum ClaimOutcome {
249242 NotEligible ,
250243}
251244
252- /// Claim a queued job for `holder_node_id`, or move a never-attempted
253- /// cancel-requested job straight to `Cancelled`.
245+ /// Claim a queued job, or cancel it directly if it was never-attempted and cancel-requested.
254246pub async fn claim_job (
255247 storage : & StorageHandle ,
256248 job_id : JobId ,
@@ -414,10 +406,8 @@ pub enum RequeueOutcome {
414406 Skipped ,
415407}
416408
417- /// Return a claimed/running job to the queue with `queue_retry_after_ms` backoff, or
418- /// move it to `Failed` once it has exhausted `JOB_MAX_ATTEMPTS`. `token` is `None`
419- /// for the lease-expiry sweep and startup recovery, which reclaim whatever holder is
420- /// recorded.
409+ /// Re-queue with backoff, or fail once `JOB_MAX_ATTEMPTS` is spent. `token` is `None`
410+ /// for the lease sweep and startup recovery.
421411pub async fn requeue_job (
422412 storage : & StorageHandle ,
423413 job_id : JobId ,
@@ -461,8 +451,7 @@ pub enum CancelRequestOutcome {
461451 AlreadyTerminal ( JobRecord ) ,
462452}
463453
464- /// Set `cancel_requested` without changing state. Idempotent; a terminal job is a
465- /// no-op returning the current record.
454+ /// Idempotently set `cancel_requested`; a terminal job is a no-op.
466455pub async fn set_cancel_requested (
467456 storage : & StorageHandle ,
468457 job_id : JobId ,
@@ -485,8 +474,7 @@ pub async fn set_cancel_requested(
485474 } )
486475}
487476
488- /// Owner-scoped listing, newest first, with an opaque 24-byte cursor and an
489- /// optional server-side state filter applied per page.
477+ /// Owner-scoped listing, newest first, with an opaque cursor and optional state filter.
490478pub async fn list_jobs_for_user (
491479 storage : & StorageHandle ,
492480 user_id : UserId ,
@@ -578,8 +566,7 @@ pub async fn iter_prefix_page(
578566 }
579567}
580568
581- /// Head of a schedule-index prefix, i.e. the earliest `(timestamp, job_id)` still
582- /// enqueued under `due/`, `lease/`, or `prune/`.
569+ /// Earliest `(timestamp, job_id)` under a schedule-index prefix.
583570pub async fn first_schedule_entry (
584571 storage : & StorageHandle ,
585572 prefix : & [ u8 ] ,
0 commit comments