---
id: TST-PFM-DJE-003
title: Admit batches
kind: unit
product_area: platform
module: data-job-engine
revision: 1
status: draft
source_sha:
  services-platform: ad3f6a6582843008ed0f5a17b131878d15829af1
  macroservice-libraries: 54536a441935c6e09fdb7f96f0bec71c52ba4e03
  services-crm: a8d1364f1dd44b723bb5f9acba12f983e9ec8d69
  services-membership: 5994c270e8a37a30f848e99ba5b5ee6b87c08893
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
repository: macroservice-libraries
files:
  - packages/data-jobs/src/admit-batches.spec.ts
implements: []
environment: local
implementation_state: implemented
latest_result: not-run
latest_run_at: null
latest_run_ref: null
conformance: not-verified
estimated_minutes: 1
isolation: In-memory fixtures and restored dependency doubles.
evidence:
  - 'macroservice-libraries:packages/data-jobs/src/admit-batches.spec.ts'
assertion_inventory:
  - '@rhythmsoftware/macroservice-data-jobs: admission hands over what the ceilings allow'
  - hands over the batches the room allows and says how many
  - >-
    records on the job what it has handed over altogether, which is the cursor a later invocation
    reads
  - hands over nothing when the ceiling leaves no room
  - 'records when it first found no room, so a later invocation can tell how long that has been so'
  - >-
    writes nothing more while the job stays blocked, because a job waiting is not news every few
    seconds
  - 'clears the record when room comes, so the time blocked is the time since the last admission'
  - '@rhythmsoftware/macroservice-data-jobs: admission fails a job it can never admit'
  - 'answers the workflow that there is no more to do, so the loop ends'
  - fails the job with the code and a summary naming the ceiling and how long it left no room
  - 'abandons the batches it never handed over, so they are counted as not attempted'
  - 'keeps waiting for a job whose own batches are in flight, however long they run'
  - 'keeps waiting behind a neighbour whose batches are moving, because its room is coming'
  - >-
    @rhythmsoftware/macroservice-data-jobs: admission asks the tenant profile and the capacity
    factor
  - takes the tenant's ceiling from its profile
  - 'never lets a profile take the whole share: it is capped at the share less one'
  - 'takes the budget''s per-tenant value when the profile cannot be read, and says so'
  - 'multiplies the global ceiling by the capacity factor, rounding down'
  - 'takes a factor it cannot read, or one that is not a number, as 1'
  - 'at a factor of 0 hands over nothing, and holds the job rather than counting it blocked'
  - 'never fails a job the factor holds, however long it has been blocked'
  - '@rhythmsoftware/macroservice-data-jobs: admission takes its turn among the contenders'
  - 'shares the free slots with another tenant''s job, round-robin'
  - lets a starved job of another tenant take the next slot first
  - counts the other tenants' batches in flight that the service reports
  - uses its own fresh counts over the service's entry for this job
  - >-
    @rhythmsoftware/macroservice-data-jobs: how long admission asks the workflow to wait before it
    runs again
  - 'names the two waits: five seconds, and twenty while a full ceiling holds the batches back'
  - asks for the short wait when it handed batches over
  - >-
    asks for the short wait while nothing is waiting and its own batches run, so the job finishes
    promptly
  - asks for the short wait while planning goes on and nothing is waiting yet
  - >-
    keeps the short wait when the job's own batches fill its ceiling, because its room opens as soon
    as one finishes
  - asks for the long wait when the tenant's ceiling is held by its other jobs
  - asks for no wait once there is nothing more to do
registration_note: Registration describes existing source; the suite is not executed by this documentation job.
---

# Admit batches

## Verification Boundary

The suite checks an isolated production calculation, declaration or adapter. The structured assertion inventory records the checks present at the pinned revision.

## What This Suite Proves

The existing checks exercise admit batches. The specification bindings identify the narrower outcomes supported by those assertions.

## What It Does Not Prove

An isolated check does not establish a deployed workflow, database enforcement or complete feature acceptance.

## Real Dependencies and Test Doubles

The production function or declaration is exercised with in-memory inputs and dependency doubles. This boundary does not require a live database.

## Must Not Be Doubled

The production function under examination and its returned decisions remain real; replacing their answers defeats the check.
