feat(scheduler-core): define new event payload types (task 7.2)

Adds JobStateChangeEvent (jobid/oldState/newState/exitCode) and
JobUpdateEvent (jobid/changedFields/job: Job) to controller.capnp,
matching design.md's spec verbatim. JobUpdateEvent.job reuses the
existing full 12-field Job/xce_job_t record, verified distinct from
the narrower SchedJob struct sharing the same mapname.

Extends ReplayEvent.body's union (task 7.1) with jobStateChange@10/
jobUpdate@11 -- the only two valid next ordinals, since capnp requires
strictly sequential ordinals with no gaps across a struct and task
7.1 deliberately stopped at @9. Existing @0-@9 fields and every other
struct in the schema are byte-identical.

Deep round-trip tests in test_e2e_capnp.c exercise every field with
non-default values, including the 3-level nested Job substructs
(submitData/allocs/pidinfo/pendreason). JOB_F_* bitmask bit values
deliberately left undefined -- a later task's job, not this
schema-only one's.

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 10:17:57 +00:00
parent 68a6196517
commit 755230705c
Signed by: rshen
SSH key fingerprint: SHA256:8Vf2pZ3h6rJa7EhGK+WaAQ9Mta/apZvteW6g9U/WKKk
4 changed files with 295 additions and 4 deletions

View file

@ -589,6 +589,28 @@ typedef struct {
sched_snapshot_data_t *data;
} replay_snapshot_entry_t;
/* task 7.2 (Req 5 AC 20): the two genuinely new event payload types -- every
* other replay_event_t.body variant above reuses a pre-existing wire type
* (see controller.capnp's comment at `struct JobStateChangeEvent`). */
typedef struct {
uint64_t jobid;
uint32_t old_state;
uint32_t new_state;
int32_t exit_code;
} job_state_change_event_t;
typedef struct {
uint64_t jobid;
/* changedFields is a UInt32 bitmask (JOB_F_PRIORITY, JOB_F_QUEUE,
* JOB_F_RESREQ per design.md) -- no JOB_F_* constants exist anywhere in
* the codebase yet (task 5.1's grep); concrete bit assignments are
* task 9+ event-translation/recording code's job, not this schema-only
* task's. */
uint32_t changed_fields;
xce_job_t *job; /* full updated record -- reuses xce_job_t (Job in
* controller.capnp) */
} job_update_event_t;
typedef struct {
uint64_t ts;
int body_which;
@ -602,6 +624,8 @@ typedef struct {
xce_queue_t *queue_update;
xce_job_rusages_t *job_rusage;
/* endSession: Void, no storage */
job_state_change_event_t *job_state_change;
job_update_event_t *job_update;
} body;
} replay_event_t;