feat(scheduler-core): implement REPL snapshot capture and simulation parameter commands (task 12.3)

Adds `snapshot [FILE]` and `set speed|output|verify ...`/`info config`
(Req 5 AC 22 "Snapshots"/"Simulation parameters") to the interactive
simulation REPL.

`snapshot` reuses sim_record.c's existing sim_record_write_header_and_
snapshot() (task 11.5) rather than reimplementing capnp encoding, so
the produced file is genuinely loadable via a fresh --sim invocation
-- the task's own Observable. `set speed`/`set output`/`set verify`
mutate fields sim_loop.c and core_clock.c already read fresh on every
event/session, so no new hook points were needed and sim_loop.c stays
untouched at exactly 800/800 lines (this project's hard per-file cap).

New repl_params.c is a fourth sibling in the repl.c/repl_break.c/
repl_info.c split (task 12.2's precedent) -- neither existing file had
headroom left under the 800-line cap for this task's own logic.

Scheduler suite: 36/36 clean (was 35/35). Review independently
reproduced the RED-phase probe and additionally verified the
snapshot round-trip Observable is non-vacuous.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JPPXeKSUXUqcqvzNXY1rzJ
This commit is contained in:
Rongsong Shen 2026-08-07 10:25:32 +00:00
parent 2fecea3592
commit 2329dbf2a8
Signed by: rshen
SSH key fingerprint: SHA256:8Vf2pZ3h6rJa7EhGK+WaAQ9Mta/apZvteW6g9U/WKKk
18 changed files with 2755 additions and 110 deletions

View file

@ -560,6 +560,9 @@ sched_sim_isolation_test = executable(
'-DXCE_SIM_REPL_INTERNAL_H_PATH="'
+ (meson.current_source_dir() / '..' / 'src' / 'repl_internal.h')
+ '"',
'-DXCE_SIM_REPL_PARAMS_C_PATH="'
+ (meson.current_source_dir() / '..' / 'src' / 'repl_params.c')
+ '"',
'-DXCE_SIM_LIB_PATH="'
+ sched_sim_isolation_lib.full_path()
+ '"'],
@ -708,6 +711,31 @@ sched_repl_breakpoints_inspection_test = executable(
dependencies: [scheduler_test_deps, libedit_dep],
install: false)
# Contract test for the interactive simulation REPL's snapshot-capture and
# simulation-parameter command slice (scheduler-core spec, task 12.3, Req 5
# AC 22 "Snapshots"/"Simulation parameters"): `snapshot [FILE]` writes a
# standalone .replay file a FRESH sched_sim_driver_start() can load, landing
# on the exact position the snapshot was taken at (the task's own central
# Observable, proved end to end via a forked child + a second, real
# sched_sim_driver_start() call in the parent); `set speed`/`set output`/
# `set verify` mutate the parameters `info config` reports. Same white-box
# #include pattern as sched_repl_breakpoints_inspection_test above (core.c,
# core_clock.c, core_events.c, core_session.c, decision.c, plugin.c,
# plugins/builtin_fcfs.c, recording.c, recording_session.c, sim.c,
# sim_loop.c, sim_record.c, sim_verify.c,
# snapshot.c/snapshot_wire.c/snapshot_load.c, repl.c, repl_break.c,
# repl_info.c) PLUS the new ../src/repl_params.c under test. Split into its
# own file rather than appended to test_repl_breakpoints_inspection.c --
# that file was already over 1000 lines after task 12.2, and this task's
# own fixture/assertion surface (a fork+reload round-trip plus five
# further unit-level command tests) does not belong crammed into it.
sched_repl_snapshot_params_test = executable(
'sched_repl_snapshot_params_test',
['test_repl_snapshot_params.c'],
include_directories:[incdir],
dependencies: [scheduler_test_deps, libedit_dep],
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',
@ -804,3 +832,6 @@ test('scheduler repl execution control test',
test('scheduler repl breakpoints inspection test',
sched_repl_breakpoints_inspection_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])
test('scheduler repl snapshot params test',
sched_repl_snapshot_params_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])