--- id: "bug-1826" status: "fixed" status_updated: "2026-09-24" status_note: "" component: "scheduler" severity: "crash" timestamp: "2026-09-17T21:50:00Z" last_seen: "2026-09-19T09:00:00Z" occurrences: 1 files: ["src/scheduler/src/plugin.c"] tags: ["scheduler", "sim-mode", "repl", "limit-plugin", "limit-matching", "plugin-job-election", "architectural-gap", "discovered-during-scheduler-sim-diagnostics", "driver-parity", "follow-up-to-bug-1825"] related: [] legacy: true --- # bug-1826: deliberately out-of-scope follow-up discovered while fixing bug-1825 (sim-mode limit plugin… ## Description NOT A CRASH -- known, deliberately out-of-scope follow-up discovered while fixing bug-1825 (sim-mode limit plugin bootstrap, scheduler-sim-diagnostics task 6). Bug-1825's fix makes the limit plugin's CONFIGURED SETTING visible in sim mode (info limit now shows a real replay's actual limit configuration). But limit *matching* -- the mechanism that actually populates live usage instances (xce_vres_t) as jobs get evaluated -- is still never invoked during replay. So info limit's live-usage display will correctly show 'no active usage instance yet' for every limit against any real replay, even one whose original live session actively enforced and charged against that limit. ## Environment _Not recorded (migrated from buglog.json)._ ## Reproduction _Not recorded (migrated from buglog.json)._ ## Root cause limit_job_election() (plugins/limit.c, the function that calls match_job_global_limit_()/match_job_host_limit_() and populates xce_vres_t usage instances) is only ever invoked via plugin_job_election() (plugin.c:554), which -- like plugin_config_update()/plugin_prepare_allocation() -- takes a `void* arg` cast unconditionally to `xce_scheduler_t*` and reads `sched->core.plugins`. plugin_job_election() has exactly ONE call site in the entire codebase: scheduler.c (normal-mode only). Nothing in sim_loop.c's replay decision path calls plugin_job_election() or any core-safe equivalent, so no limit ever gets matched against any job during simulation/replay, regardless of whether the limit plugin is registered (bug-1825 fixes registration+config, not this). ## Fix FULLY FIXED (2026-09-19, scheduler-sim-live-allocation tasks 1.1-5.2). The core-safe plugin_job_election() variant this entry called for was built in task 1.2 (retyped to take xce_sched_core_t* directly, iterating core->plugins); it is now genuinely invoked in sim mode via two paths: (a) the unified sched_job_picker()/sched_allocator() thread pair (task 3.1, wired into sim mode in task 4.1) calls the full core-safe election/allocation chain for every job the live picker reaches, which includes limit matching via limit_job_election() (task 2.3, also fixed bug-1828, a pre-existing host-scoped-limit enforcement defect blocking this same path); (b) sim_reconcile_unaccounted_jobs() (task 4.2) additionally calls plugin_job_election() directly for any job only recovered via recorded-decision reconciliation, so a job never misses limit registration regardless of which path resolves it. Host-scoped limit fan-out during live seqjob/parjob dispatch specifically required a further fix (task 4.3, closing a throwaway-wrapper-registry seam gap) before it worked end-to-end. Proven via the full TDD + contention-fixture discipline this entry called for: bare-core contention fixtures (task 5.1, test_sim_contention_limit_driver_parity.c) and this entry concrete acceptance test -- a genuine real capnp-encoded .replay driven through the real, unmodified sched_sim_driver_run(), with both a global and a host-scoped limit configured and matched, both showing real non-zero usage via the same limit_get_usage_instances() accessor info limit reads (task 5.2, test_sim_e2e_limit_visibility.c) -- independently reviewed with a targeted revert-to-pre-task-4.3 RED-phase reproduction confirming the host-scoped half genuinely regresses without the fix. ## Verification _Not recorded (migrated from buglog.json)._ ## References _Not recorded (migrated from buglog.json)._