feat(scheduler-core): implement what-if branching and simulation output recording (task 11.5)

Add sim_record.c (scheduler_t-free .replay writer: ReplayHeader + loaded
SnapshotEntry once, then per-event pass-through and per-session
ReplaySession finalization) and wire --sim-alt-events event-source
selection into sim_loop.c's drain loop, coexisting with task 11.2's
stdout default and task 11.4's --sim-verify. Extract scheduler_t-free
halves out of recording_session.c's begin/end so sim-side code can reuse
the decision-encoding path without gaining an xce_scheduler_t* dependency,
preserving Req 5 AC 17 isolation. Per Req 5 AC 16/19.
This commit is contained in:
Rongsong Shen 2026-08-07 02:42:50 +00:00
parent a6083d803e
commit 564408e967
Signed by: rshen
SSH key fingerprint: SHA256:8Vf2pZ3h6rJa7EhGK+WaAQ9Mta/apZvteW6g9U/WKKk
14 changed files with 1750 additions and 91 deletions

View file

@ -17,6 +17,7 @@ scheduler_srcs = [
'src/sim.c',
'src/sim_loop.c',
'src/sim_verify.c',
'src/sim_record.c',
'src/schedobj.c',
'src/plugin.c',
'src/resource.c',
@ -64,17 +65,18 @@ sched_core_isolation_lib = static_library(
# Task 11.3 (scheduler-core spec, Req 5 AC 17): isolated compile target for
# the simulation driver's own files, consumed by
# testsuite/test_sim_isolation.c to prove at build time that sim.c/sim_loop.c
# reference zero controller-facing symbols (client/netio/xceapi/delay/idgen).
# Both files are compiled together into ONE archive -- task 11.2 added
# sim_loop.c as a sibling file to task 11.1's sim.c, and covering only one of
# them would repeat core.c's own siblings' (core_events.c/core_session.c/
# testsuite/test_sim_isolation.c to prove at build time that
# sim.c/sim_loop.c/sim_record.c reference zero controller-facing symbols
# (client/netio/xceapi/delay/idgen). All files are compiled together into ONE
# archive -- task 11.2 added sim_loop.c as a sibling file to task 11.1's
# sim.c, and task 11.5 adds sim_record.c as a third; covering only a subset
# of them would repeat core.c's own siblings' (core_events.c/core_session.c/
# core_clock.c) never-mechanically-covered gap for the sim driver. Same
# "compiling to an object is enough, no real linking needed" rationale as
# sched_core_isolation_lib above.
sched_sim_isolation_lib = static_library(
'sched_sim_isolation',
['src/sim.c', 'src/sim_loop.c'],
['src/sim.c', 'src/sim_loop.c', 'src/sim_record.c'],
include_directories: incdir,
dependencies: scheduler_deps,
install: false)