feat(scheduler-allocation): add lazy plan/host iterator contracts

Defines xce_alloc_plan_t (partition of a job's task count into
per-host slot buckets), xce_alloc_plan_iter_t, and xce_host_iter_t
(init/next/fini vtables, stack-allocate-then-init-in-place convention
matching sched_ctx_init) as reusable abstractions any allocator can
adopt. Proven usable by a trivial no-op reference implementation and
a fresh-per-bucket host_iter composition test, no allocator wired in
yet.

Task 1.1 (scheduler-allocation spec). Requirements 2.1, 3.1.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYdtrEWWZfKRRGED7raEYg
This commit is contained in:
Rongsong Shen 2026-09-04 13:50:31 +00:00
parent d1a3e158ae
commit d5d2c1caf5
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
4 changed files with 482 additions and 1 deletions

View file

@ -1474,6 +1474,24 @@ sched_builtin_fcfs_cursor_uaf_test = executable(
dependencies: [scheduler_test_deps],
install: false)
# Contract test for the lazy allocation-plan and host-candidate iterator
# interfaces (scheduler-allocation spec, task 1.1, Req 2 AC 1-6 / Req 3 AC
# 1-6). Only #includes the new ../include/sched/alloc_iter.h -- no
# allocator is wired onto these interfaces yet (parjob_allocator/
# seqjob_allocator rewrap is later tasks' own work). Proves the contract
# shape compiles and is usable via a trivial, no-op reference
# implementation of each interface, stack-allocated and initialized in
# place per the documented convention, driven through a full
# init()/next()/fini() cycle -- including the exact plan -> per-bucket
# fresh-host_iter composition shape requirements.md's Composition
# Algorithm describes for allocate_primary() (Req 3 AC 4 / Req 4 AC 2).
sched_alloc_plan_iter_test = executable(
'sched_alloc_plan_iter_test',
['test_alloc_plan_iter.c'],
include_directories:[incdir],
dependencies: [scheduler_test_deps],
install: false)
# Register as meson tests so `meson test --suite scheduler` runs them all.
# detect_leaks=0 matches the suite convention (fixtures are not torn down).
test('scheduler test', scheduler_test, suite: 'scheduler',
@ -1656,3 +1674,6 @@ test('scheduler limit plugin test', sched_limit_plugin_test, suite: 'scheduler',
test('scheduler builtin fcfs cursor uaf test',
sched_builtin_fcfs_cursor_uaf_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])
test('scheduler alloc plan iter test',
sched_alloc_plan_iter_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])