feat(scheduler-core): implement session-start signal + decision callback (task 4.4)

Adds xce_core_go()/xce_core_end_session() (new core_session.c):
xce_core_go() is non-blocking, performs begin-session state reset
(select-eval-ctx, resval resets), signals the picker thread via wbuf,
and returns -EINVAL on a reentrant call while a session is already
active (proven a true no-op, not just an early return). Draining
core->decisions and invoking the driver's on_decision callback is the
driver's own responsibility between core_go() and core_end_session()
(confirmed driver-owned, not core-owned, per the Driver <-> Core
protocol). xce_core_set_decision_cb() registers the callback + driver
context as a separate setter, keeping xce_sched_core_init()'s live
sched_init() call site untouched. Adds XCE_DECISION_PREEMPT to
decision.h (jobid/victims[]/reason) alongside the existing DISPATCH/
PEND types. Additive only — sched_go/sched_begin_session/
sched_end_session/sched_allocator/main.c remain untouched.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019dw5WnN3DXStaEaPYfACU1
This commit is contained in:
Rongsong Shen 2026-08-04 03:08:18 +00:00
parent e6c0a2448a
commit de69b6288d
Signed by: rshen
SSH key fingerprint: SHA256:8Vf2pZ3h6rJa7EhGK+WaAQ9Mta/apZvteW6g9U/WKKk
9 changed files with 900 additions and 26 deletions

View file

@ -241,6 +241,24 @@ sched_core_events_test = executable(
dependencies: [scheduler_test_deps],
install: false)
# Contract test for the session-start signal and decision callback protocol
# (scheduler-core spec, task 4.4, Req 5 AC 5 / AC 6): xce_core_go() signals
# the picker thread non-blockingly and rejects reentrant calls with
# -EINVAL; decisions placed on core->decisions reach the driver-registered
# on_decision callback once each, in order, followed by the end-of-session
# NULL marker terminating the drain loop; xce_core_end_session() clears
# session_active. Same white-box #include pattern as test_core_events.c
# (pulls ../src/core.c, ../src/core_session.c, and ../src/decision.c into
# this TU) -- see the test's own header comment for why this file needs no
# picker-plugin fixture (xce_core_go()/xce_core_end_session() never call
# sched_resolve_job_picker()).
sched_core_session_test = executable(
'sched_core_session_test',
['test_core_session.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',
@ -280,3 +298,6 @@ test('scheduler core jbuf capacity pin test',
test('scheduler core events test',
sched_core_events_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])
test('scheduler core session test',
sched_core_session_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])