Invariants¶
The test suite checks these properties on hypothesis-generated event sequences run through the simulator (packages/rampgate/tests/test_invariants.py). The ci hypothesis profile runs on every push and pull request; the nightly profile generates at least 200 scenarios. Code and tests refer to them by number.
- I1 Never two untrusted WARMING/STARTING jobs on the same device (with
probation="all": never two WARMING/STARTING jobs). - I2 Without
force: at everyStart,F + Σ stable reservations + Σ_warming W + amount ≤ capacityon each placement device, withWas in Rule A. The amount is the estimate; for a trusted estimate it is the charge (I22, which the cap can make larger than the raw estimate's headroom); an unknown estimate counts asunknown_min_free. - I3
StagePolicywith backfill off: no job of group k+1 is started while group k is incomplete. - I4
decideis deterministic: the same snapshot andnowgive the same decision. - I5 Idempotence: after reducing a decision's actions, an immediate second
decideemits no duplicateStart/Stop. - I6 A reservation never decreases within an attempt.
- I7 OOM retries are bounded, and the estimate strictly increases after each OOM until it is capped at capacity. This holds even with no hint, no history and no observations. A job gets
Fail(EXCEEDS_DEVICE_CAPACITY)only if it OOMed while it had effectively the whole device (room_at_oom ≥ capacity × (1 − foreign_tolerance)in an OOM'd dimension). - I8
dump/loadround-trips to an equal state. - I9 A gang job starts on all of its devices or on none.
- I10 A PREEMPTED job keeps its group open, and resuming a job whose earlier attempt ran always sets
resume=True(a job held while PENDING never ran, so it starts withresume=False; see Lifecycle). - I11 Replaying any prefix of an already-applied stream of fact events (
JobSubmitted,JobStarted,JobExited,JobObserved,DeviceObserved: duplicates, stale attempts, out-of-order observations) leaves the state unchanged except for theignored_eventslog. - I11b Every command is idempotent when applied twice in a row:
Paused; Paused==Paused,PreemptRequested; PreemptRequested==PreemptRequested, an identicalJobUpdatedtwice == once, and likewise for the other commands. Commands carry no event ids. - I12 LOST retries are bounded, and a LOST exit never changes the OOM counter or the estimate.
- I13 A job that exits while STOPPING is never re-queued automatically. It ends in SUCCEEDED, PREEMPTED or CANCELLED, never FAILED. Exception (Rule V): a job stopped by
Stop(vacate=True), with no user preempt or cancel request since, returns to PENDING withRequeue(VACATED)(or ends SUCCEEDED). - I14 Rule S depends only on
steps_in_attempt(andepoch_in_attempt). The same workload resumed with a cumulative counter or with a counter reset to 0 stabilizes at the same simulated time. - I15 With head-of-line blocking on, a job never starts on device
din a tick where an earlier blocking candidate needingdwas not admitted, except on a device whose isolation holder is that job (an isolation hold takes precedence over head-of-line holds; see Isolation retry), and except for earlier candidates that were waiting for a sibling (WaitingForSibling): that hold never closes a device either. - I16 For every edge-triggered warning key,
WarnandWarnClearedstrictly alternate in the emitted action stream, starting withWarn. - I17 With Rule P on: while an untrusted job is STARTING/WARMING on device
d(or keepsd's slot in the tick it became STABLE), noStartis issued ond, for trusted and untrusted jobs alike (forceskips Rule A only, not Rule P). Checked against the state within the tick, including starts made earlier in the same tick. - I18 With Rule V on: after
decide, on every device where aMarkStableorUpdateReservationhappened in the tick, one of these holds over the non-stopping, non-forced managed jobs ond(forced jobs are left out ofU_dand of the count, Rule V):U_d ≤ C_d × (1 − vacate_headroom); or at most one of them remains; or none of them is STABLE. Every job thisdecidestopped withvacate=Truewas STABLE and not forced. - I19 At the
Startof a job with the isolation flag (or a sibling-hold measurement candidate, I21), no other managed job is STARTING/WARMING/STABLE/STOPPING on any device of its placement (checked against the state within the tick); and noStartis issued on a device held by a waiting isolation job other than that job itself. - I20 (liveness) In every tick, on a device
dwith no active managed job and the engine not paused, every PENDING job whose placement includesdis started in that tick or waits for a reason that is not a scheduler hold (capacity, foreign usage, unknown estimate, group barrier, admission, a user hold). ADeviceHeldFor(d', h)is allowed when the chain of holders it starts ends in such a reason; a cycle of holds is a violation.WaitingForWarmup/WaitingForIsolationcount only on a device that has an active job or a start in that tick.WaitingForSibling(j)is a hold whose chain continues atj; a measurement candidate'sWaitingForIsolationcounts like an isolation retry's. Checked for every policy (FifoPolicystrict and not,PriorityPolicy,StagePolicy), with and without restarts, and for the baselines. Extended: a PENDING job whose trusted charge is capped on such a device (E × m + q > C_d − F_d) is started or waits for a reason other than capacity. - I21 With the isolation retry on, no
Startof a jobkis issued while the sibling hold applies to it (its template is not measured on some device of its placement, judged on the tick's estimator answers, and another job of the template has the isolation flag or the answer is a lower bound; see Isolation retry), unlesskis its template's isolation retry (the oldest flag) or its measurement candidate (no flagged or running sibling, no earlier held sibling); a measurement candidate starts like an isolation retry (I19). Judged on the state within the tick, including theStarts made earlier in the same tick (like I17 and I19): a job started earlier in the tick is a running sibling. Checked for every policy, with and without restarts. - I22 Admission and accounting use the same charge. For every
Startwithoutforce, on every device where the estimate is trusted:F + Σ R + Σ W + charge ≤ Cin every dimension, judged on the state within the tick, withcharge = min(E × m + q_d, C_d − F_d)(E = Start.estimate,mfromStart.observations,q_dfrom the device,F_d = Start.foreign); and right after theStart, the job's warming load ismax(charge, usage). Untrusted estimates keep the check atE(I17). The checker computes the charge itself, not throughdecide. Checked for every policy, with and without restarts, with and withoutq_d. - I23 Batch = sequential. The
Startactions of onedecide(snapshot, now)equal those of the sequential procedure at the samenow: reduce the decision's non-Startactions into the state; then repeatedly calldecideon the snapshot with that state (the estimator facts unchanged), reduce only the firstStartit returns, and stop when it returns none. Equal means the same jobs in the same order with the same fields (devices, resume, free, estimates, trusted, observations, foreign). It catches state derived once per tick instead of after every start. Checked at every tick for every policy, with and without restarts, with and withoutq_d, gangs, sibling holds, isolation retries and capped charges, and for the baselines' admissions.