feat(scheduler-sim-decision-parity): add reconciliation trigger and lookup (task 2.2)

Adds sim_reconcile_unaccounted_jobs(xce_sched_sim_driver_t*, replay_session_t*)
to sim_loop.c -- not yet wired into the round boundary (task 3). Once per
call, finds every RUN-state job with job->accounts == NULL (the signature of
a job already resolved before this replay's own live decision-making ever
considered it) and searches this round's decoded recorded-decision stream
for a matching DISPATCH entry by jobid.

This task implements only the trigger + lookup + not-found path: when no
match exists, the job's allocation is left unknown (not fabricated), no
error is raised, and the job is safe to re-check next round (Requirement
4.1, 4.2). Match-found reconstruction (ownership transfer, freeing/
compacting the consumed entry, reporting) is tasks 2.3/2.4, not implemented
here -- decoded_session's decisions are read but not yet mutated.

6 new tests cover: not-found leaves job unaccounted, cross-round safety,
already-accounted jobs are skipped, a same-jobid PEND entry is correctly
not mistaken for a DISPATCH match, non-RUN-state jobs are gated out, and
NULL-argument safety. RED phase: compile-error-before/link-succeeds-after,
the correct RED variant for genuinely new code with no prior behavior.

46/47 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 07:53:53 +00:00
parent 134380b871
commit 81358b5231
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
4 changed files with 618 additions and 1 deletions

View file

@ -752,6 +752,23 @@ sched_sim_session_ordering_test = executable(
dependencies: [scheduler_test_deps],
install: false)
# Recorded-Decision Reconciliation trigger/lookup/not-found contract
# (scheduler-sim-decision-parity spec, task 2.2, Req 4.1/4.2, "Recorded-
# Decision Reconciliation" component). Calls the new sim_loop.c-local
# sim_reconcile_unaccounted_jobs() directly (it is `static` and not yet
# wired into any call site -- task 3's job) against hand-built
# xce_sched_core_t/replay_session_t fixtures (core_build_job()+
# sched_add_job(), no `.replay` file or capnp round-trip needed). Same
# white-box #include/stub set as sched_sim_event_loop_test -- sim_loop.c's
# compiled TU unconditionally references every one of those externs
# regardless of which functions this file's own tests call.
sched_sim_reconcile_unaccounted_test = executable(
'sched_sim_reconcile_unaccounted_test',
['test_sim_reconcile_unaccounted.c'],
include_directories:[incdir],
dependencies: [scheduler_test_deps],
install: false)
# Resource-contention replay fixture (scheduler-sim-decision-parity spec,
# task 1.2, Req 2.1/2.2): existing fixtures in this directory never have
# scarce capacity, so none can exercise or prove capacity-check correctness.
@ -1102,6 +1119,9 @@ test('scheduler sim equivalence test',
test('scheduler sim session ordering test',
sched_sim_session_ordering_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])
test('scheduler sim reconcile unaccounted test',
sched_sim_reconcile_unaccounted_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])
test('scheduler sim resource contention test',
sched_sim_resource_contention_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])