feat(scheduler-sim-live-allocation): wire simulation mode onto shared picker/allocator (task 4.1)

Replaces sim_picker_thread_fn() (the always-PEND placeholder) with the
real sched_job_picker()/sched_allocator() threads (task 3.1), spawned
against &(sim->core) in sched_sim_driver_run(). Simulation mode now
genuinely uses the jbuf capacity-1 rendezvous for the first time
(confirmed still exactly one producer/one consumer). Adds
sched_election.c to sched_sim_isolation_lib.

Fixes bug-1829 (blocking, only reachable once sim_allocator() actually
called sched_make_allocation() for the first time): core->seqjob_
allocator/parjob_allocator were never bootstrapped for simulation mode
at all. Fixed via new sim_alloc.c (sim_bootstrap_seqjob_allocator()/
sim_bootstrap_parjob_allocator()), mirroring the sim_picker.c/
sim_limit.c precedent.

That fix's own workaround -- a throwaway xce_scheduler_t wrapper
satisfying seqjob/parjob's init_fn -- has a documented, narrow side
effect: prepare_allocation_hook fan-out during a live seqjob/parjob
dispatch attempt reaches the wrapper's own separate plugin registry,
not sim->core.plugins, so a plugin registered only against the real
sim core (the limit plugin) isn't reached for host-scoped matching
during a live dispatch yet. Documented in design.md's new "Known Seam
Gap" section; task 4.3 added to tasks.md to close it before task 5.2's
acceptance test can pass for the host-scoped case.

TDD: new end-to-end test drives a real .replay with an empty decisions
array (ruling out reconciliation) through the real thread pair,
proving a genuine DISPATCH from live resource availability. 25
pre-existing white-box sim/repl test files given link-satisfying
stubs reproducing the OLD always-PEND contract unchanged -- their own
assertions are untouched (task 5.3's job to reconcile deeper).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RLSNJhNoULvVcUhXEFafQC
This commit is contained in:
Rongsong Shen 2026-09-19 04:50:40 +00:00
parent 4195331b47
commit 08df64930b
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
33 changed files with 3809 additions and 92 deletions

View file

@ -2077,3 +2077,33 @@ sched_election_sim_fixture_test = executable(
test('scheduler election sim fixture test',
sched_election_sim_fixture_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])
# scheduler-sim-live-allocation spec, task 4.1 (Req 1.1, 1.2, 3.3, 4.2, 4.3,
# 5.1, boundary: Unified Picker/Allocator Threads, Sim Driver): proves
# sched_sim_driver_run() (sim_loop.c) itself -- not just the relocated
# thread pair in isolation (task 3.1's own sched_election_sim_fixture_test
# above) -- genuinely dispatches a job against simulation mode's own core
# state when driven from a real `.replay` stream, closing the always-PEND
# gap sim_picker_thread_fn() (now removed) documented as its own "known
# scope boundary". Same real-scheduler_srcs link technique as
# sched_election_sim_fixture_test immediately above: sched_allocator()
# (sched_election.c) reaches the real sched_make_allocation()/
# seqjob_allocator.c chain, none of which is reachable via a white-box
# #include of sim_loop.c alone.
sched_sim_live_allocation_test_srcs = ['test_sim_live_allocation.c']
foreach f : scheduler_srcs
if f != 'src/main.c'
sched_sim_live_allocation_test_srcs += ['../' + f]
endif
endforeach
sched_sim_live_allocation_test = executable(
'sched_sim_live_allocation_test',
sched_sim_live_allocation_test_srcs,
include_directories:[incdir],
dependencies: [scheduler_test_deps],
install: false)
test('scheduler sim live allocation test',
sched_sim_live_allocation_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])