feat(worker-rejoin-resync): define reconciliation wire protocol (task 1.1)

Add OPCode_jobStateQuery/OPCode_jobStateReport, JobStateEntry/
JobStateQuery/JobStateReport structs (paginated, mirroring JobData/
WorkerData/ResourceVals' {ntotal,pos,count} shape), and
workerResyncWindowMs/workerResyncTimeoutMs ClusterConfig fields to
controller.capnp, plus the companion typemap.h/clusterconfig.h C type
declarations this codebase's capnp $C.mapname codegen requires to
compile. Both new opcodes are fire-and-forget (Request.body union only,
no RequestReply arm), matching design.md and the push/notify precedent.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y4M5MJM2zK6nU43da267Ku
This commit is contained in:
Rongsong Shen 2026-09-01 08:44:33 +00:00
parent 6c908d5017
commit 1ff57ef66e
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
4 changed files with 96 additions and 1 deletions

View file

@ -25,6 +25,12 @@ typedef struct {
int nlimits;
xce_limit_config_t** limits;
uint64_t config_generation; /* monotonic audit counter from capnp schema */
/* worker-rejoin-resync (Req 3.7, 5.3): shared, cluster-wide via
* operational-uniformity override (design.md Configuration Model) --
* alongside heartbeat_interval/inactive_heartbeat_count above, same
* domain. */
int worker_resync_window_ms;
int worker_resync_timeout_ms;
} cluster_config_t;
#endif

View file

@ -281,6 +281,42 @@ typedef struct {
uint64_t responder_time_ms; /* @13: responder wall-clock at sample time (epoch ms) */
} xce_ctrlstatus_t;
/* ── Worker rejoin/resync job-state reconciliation (worker-rejoin-resync
* task 1.1, Req 2.1/2.2/3.5/3.7/5.3/8.1-8.3) ────────────────────────────
* Frame-only wire types for the controller<->worker job-state
* reconciliation exchange (OPCode_jobStateQuery/OPCode_jobStateReport) --
* same "no live C struct" convention as capnp_host_admin_state_t/
* replay_cluster_t above (see controller.capnp's comment at `struct
* JobStateEntry`). An enum-typed capnp field (status) maps to a plain
* `int` here, not a separate named C enum type -- mirrors the existing
* HostRole/JoinData.role and SchedAdminAction/sched_admin_req_t.action
* convention (the generated `enum JobStateStatus` in controller.capnp.h
* already supplies the JobStateStatus_running/finishedOk/finishedFail/
* unrecognized constants for callers that want them). This is schema-only:
* the C-side send/receive/encode/decode logic is later tasks (1.4 wire
* codec helpers; 6.1/6.2 controller wiring; 4.x worker wiring). */
typedef struct {
uint64_t jobid;
int status; /* JobStateStatus_running/finishedOk/finishedFail/unrecognized */
int32_t exit_code;
uint64_t finish_time_ms;
int queried;
} xce_job_state_entry_t;
typedef struct {
int n_total;
int pos;
int count;
uint64_t* jobids;
} xce_job_state_query_t;
typedef struct {
int n_total;
int pos;
int count;
xce_job_state_entry_t** entries;
} xce_job_state_report_t;
typedef struct {
uint64_t seq;
uint32_t opcode;
@ -343,6 +379,8 @@ typedef struct {
xce_fetchfile_t* fetchfilemsg;
sched_admin_req_t* schedadminmsg;
probe_config_tag_req_t* probeconfigtagrequestmsg;
xce_job_state_query_t* jobstatequerymsg;
xce_job_state_report_t* jobstatereportmsg;
} body;
} xce_request_t;