test(scheduler-sim-decision-parity): regression suite for existing guarantees (task 4.2)

Four checks in one run: (a) REPL-vs-batch decision equivalence unmodified
and still passing; (b) --sim-verify reports no false mismatch for a
recording with multiple already-resolved jobs across rounds (non-adjacent
memmove compaction, no cross-round bleed); (c) a replay starting from a
snapshot with a job already RUN-state and no in-window recorded decision
degrades gracefully (no crash, no fabricated value, a second ordinary job
unaffected) -- the first test to exercise reconciliation's "not found"
path through the real sched_sim_driver_run()/xce_sched_core_load_snapshot()
path rather than a hand-built core; (d) normal-mode behavior is byte-for-
byte unchanged (zero production diff, the strongest possible evidence).

Found and fixed a real test-authoring gap while building (b): builtin_fcfs
re-offers a still-PEND job as a fresh PEND every round (confirmed
pre-existing, unrelated, also visible in test_repl_equivalence.c's own
fixture) -- the first draft's round-2 fixture omitted this recurrence.

No production code touched (task 3 already completed the feature) --
git diff on sim_loop.c/resource.c/scheduler.c/driver.c/sim_verify.c is
empty. 49/50 scheduler tests pass; the 1 failure is pre-existing bug-1560
(unrelated).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-08-22 11:40:14 +00:00
parent b31907324c
commit 88bed529a7
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
4 changed files with 803 additions and 1 deletions

View file

@ -810,6 +810,27 @@ sched_sim_round_boundary_reconciliation_test = executable(
dependencies: [scheduler_test_deps],
install: false)
# Regression coverage for task 4.2 (Req 4.1, 4.2): a replay starting from a
# SNAPSHOT that already has a job in RUN state, with no recorded decision
# for it anywhere in this replay's own window, must degrade gracefully --
# job->accounts/allocs stay NULL (unavailable, never fabricated), the run
# completes cleanly (rc == 0, no --sim-verify mismatch), and a second,
# ordinary job elsewhere in the same replay is still decided normally. A
# different trigger shape from sched_sim_verify_test's own already-resolved-
# job case (that job transitions RUN mid-replay via a JOB_STATE_CHANGE
# event WITH a matching recorded DISPATCH in the same round -- reconciled,
# not left unavailable): this file's job is already RUN in the INITIAL
# SNAPSHOT itself, with no recorded decision anywhere in-window to
# reconcile from at all, so sim_reconcile_unaccounted_jobs()'s "not found"
# branch (task 2.2) is the only path that can ever touch it -- see this
# file's own header comment for the full scenario and rationale.
sched_sim_snapshot_reconcile_gap_test = executable(
'sched_sim_snapshot_reconcile_gap_test',
['test_sim_snapshot_reconcile_gap.c'],
include_directories:[incdir],
dependencies: [scheduler_test_deps],
install: false)
# Record-then-replay-and-diff parity proof for task 4.1 (Req 1.4, 2.1, 2.2):
# extends task 1.2's resource-contention scenario (worker capacity 10.0,
# jobs wanting 8.0/5.0/2.0) to an actual round-by-round comparison between a
@ -1169,6 +1190,9 @@ test('scheduler sim resource contention test',
test('scheduler sim round boundary reconciliation test',
sched_sim_round_boundary_reconciliation_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])
test('scheduler sim snapshot reconcile gap test',
sched_sim_snapshot_reconcile_gap_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])
test('scheduler sim contention parity test',
sched_sim_contention_parity_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])