feat(scheduler-sim-decision-parity): relocate resource accounting to core-level (task 1.1)

Relocates sched_account_jobs()/sched_charge_account()/sched_uncharge_account()/
sched_update_account()/sched_update_res_accounts()/sched_commit_job_alloc()
from xce_scheduler_t* to xce_sched_core_t*, mirroring the sched_resolve_job_picker()
precedent, so the simulation driver can call the same accounting service the
normal-mode driver already uses. Pure signature relocation -- every body
reference was already sched->core.*, no logic change. Updates the 3 real call
sites (driver.c's normal-mode round, scheduler.c's sched_begin_session and
sched_commit_decision) and 7 existing tests' link-satisfying stub signatures.

Adds test_resource_accounting.c proving Requirement 1.4: the relocated
accounting produces identical resInUse/sharedInUse output whether called
against a core embedded in xce_scheduler_t or xce_sched_sim_driver_t.

43/44 scheduler tests pass; the 1 failure is pre-existing bug-1560
(unrelated recording.c sandbox-permission ordering issue).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-08-22 06:04:03 +00:00
parent 0b2c856d8b
commit 3106c82ed0
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
15 changed files with 498 additions and 75 deletions

View file

@ -405,13 +405,14 @@ sched_driver_decision_cb_test = executable(
# through a genuinely test-registered xce_sched_plugin_t whose
# begin_session_fn/end_session_fn set/check an ordering flag -- per this
# task's own suggested technique, this is a stronger proof than spying on
# plugin_begin_session() itself. sched_account_jobs() (scheduler.c,
# xce_scheduler_t*-coupled, pulls in resource.c's sched_charge_account())
# is instead a SPY test double recording an order index -- this test's
# target is the DRIVER's ordering discipline, not sched_account_jobs()'s
# own resource-accounting correctness (out of this task's scope, same
# "spy the xce_scheduler_t*-coupled collaborator" rationale
# test_driver_decision_cb.c/test_driver_translate.c already established for
# plugin_begin_session() itself. sched_account_jobs() (scheduler.c, defined
# on xce_sched_core_t* as of scheduler-sim-decision-parity task 1.1, pulls
# in resource.c's sched_charge_account()) is instead a SPY test double
# recording an order index -- this test's target is the DRIVER's ordering
# discipline, not sched_account_jobs()'s own resource-accounting
# correctness (out of this task's scope, same "spy the collaborator"
# rationale test_driver_decision_cb.c/test_driver_translate.c already
# established for the xce_scheduler_t*-coupled
# sched_publish_dispatch()/sched_publish_pend_reason()).
sched_driver_session_ordering_test = executable(
'sched_driver_session_ordering_test',
@ -420,6 +421,23 @@ sched_driver_session_ordering_test = executable(
dependencies: [scheduler_test_deps],
install: false)
# Requirement 1.4 proof for the Core-Level Resource Accounting component
# (scheduler-sim-decision-parity spec, task 1.1): sched_charge_account()/
# sched_uncharge_account()/sched_commit_job_alloc() (resource.c, relocated
# from xce_scheduler_t* to xce_sched_core_t* by this task) produce
# byte-identical resInUse/sharedInUse output whether `core` came from an
# xce_scheduler_t (normal-mode driver) or an xce_sched_sim_driver_t
# (simulation driver, sim.h) -- see test_resource_accounting.c's own file
# header comment for why sched_account_jobs() itself (scheduler.c) is not
# also white-box #included here (no existing test in this directory
# white-box #includes scheduler.c, for the same reason documented there).
sched_resource_accounting_test = executable(
'sched_resource_accounting_test',
['test_resource_accounting.c'],
include_directories:[incdir],
dependencies: [scheduler_test_deps],
install: false)
# Cross-core behavioral-equivalence proof for
# xce_sched_core_save_snapshot()/xce_sched_core_load_snapshot()
# (scheduler-core spec, task 8.1, Req 5 AC 21 / Req 6 AC 5): save immediately
@ -996,6 +1014,9 @@ test('scheduler driver decision cb test',
test('scheduler driver session ordering test',
sched_driver_session_ordering_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])
test('scheduler resource accounting test',
sched_resource_accounting_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])
test('scheduler snapshot save load test',
sched_snapshot_save_load_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])