feat(scheduler-sim-live-allocation): close host-scoped limit fan-out seam gap (task 4.3)

Fully closes bug-1829's own tracked follow-up from task 4.1: retypes
seqjob_allocator.c/parjob_allocator.c's init_fn AND runtime hooks
(prepare_allocation_hook, job_alloc_fn) to read the plugin's own
honest plugin->core field (task 1.2) instead of deriving an
xce_scheduler_t* from plugin->sched -- mirroring task 2.3's limit.c
migration exactly. The gap was broader than initially scoped: not
just init_fn, but every runtime hook independently derived sched from
plugin->sched on each allocation attempt.

Adds seqjob_allocator_new_plugin()/parjob_allocator_new_plugin()
factories (plugin.h, mirroring limit_new_plugin()), letting
sim_alloc.c's bootstrap functions register both plugins DIRECTLY
against &(sim->core) via the existing plugin_register_core() -- the
same call sim_bootstrap_picker()/sim_bootstrap_limit_plugin() already
use. Task 4.1's throwaway xce_scheduler_t wrapper is gone from the
plugin-registry/fan-out path entirely; plugin_prepare_allocation()'s
fan-out during a live seqjob/parjob dispatch now genuinely reaches
sim->core.plugins, the same registry the limit plugin is registered
in.

One narrow, necessary exception remains, independently verified
confined: my_alloc() still needs a small xce_scheduler_t wrapper
(only .core.resmgr aliased to sim->core) to satisfy sched_make_allocs()
(scheduler.c, out of this task's boundary, unmodified) -- set on
plugin->sched only AFTER plugin_register_core() has run, never read by
the plugin registry or any prepare_allocation_hook fan-out.

TDD: new test_sim_alloc_limit_fanout.c drives a real live dispatch
(sched_job_picker()/sched_allocator() thread pair) with a host-scoped
limit registered directly against sim->core, proving a real usage
instance is created -- isolated from both reconciliation and
global-limit matching. RED: dispatch succeeded but the usage-instance
iterator was empty. GREEN: 82/82, zero regressions.

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 07:38:34 +00:00
parent 915782fc66
commit f6a2862110
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
12 changed files with 778 additions and 193 deletions

View file

@ -188,6 +188,32 @@ extern var limit_get_usage_instances(xce_sched_core_t* core);
extern int register_seqjob_allocator(void*);
extern int register_parjob_allocator(void*);
/*
* seqjob_allocator_new_plugin/parjob_allocator_new_plugin -
* scheduler-sim-live-allocation spec, task 4.3: factory half of
* register_seqjob_allocator()'s/register_parjob_allocator()'s own
* template-build step, extracted so a caller with no xce_scheduler_t*
* (the simulation driver, via plugin_register_core() -- see sim_alloc.c)
* can obtain a freshly calloc'd, fully populated xce_sched_plugin_t for
* the seqjob/parjob allocator plugin -- same hooks/init_fn/fini_fn
* template register_seqjob_allocator()/register_parjob_allocator()
* themselves use, just not yet registered anywhere. Mirrors
* limit_new_plugin()'s (plugins/limit.c) identical extraction exactly
* (scheduler-sim-diagnostics spec, task 6; bug-1825), closing bug-1829's
* tracked follow-up: seqjob_allocator_init()/parjob_allocator_init() (and
* the prepare_allocation_hook/job_alloc_fn hooks these plugins register)
* now read the honestly-typed plugin->core field (task 1.2) instead of
* plugin->sched, so a plugin built here and registered via
* plugin_register_core(&(sim->core), plugin) directly reaches the SAME
* core->plugins registry every other sim-mode plugin (the picker, the
* limit plugin) is registered in -- no separate wrapper registry, unlike
* task 4.1's now-superseded fix. Returns NULL on allocation failure.
* Caller owns the returned plugin (frees it only on a subsequent
* registration failure -- once registered, the plugin registry owns it).
*/
extern xce_sched_plugin_t* seqjob_allocator_new_plugin(void);
extern xce_sched_plugin_t* parjob_allocator_new_plugin(void);
/* ---------------------------------------------------------------------
* Job picker plugin interface (xce_job_picker_iface_t)
*