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

@ -51,6 +51,8 @@ enum OPCode {
ctrlstatus @40;
fetchfile @41;
schedAdmin @42;
jobStateQuery @43;
jobStateReport @44;
}
struct PeerInfo $C.mapname("xce_peerinfo_t") {
@ -715,6 +717,48 @@ struct SchedAdminReply $C.mapname("sched_admin_reply_t") {
startedAt @5: UInt64; # logical time recording started (nanoseconds since epoch)
}
# ── 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) ─────────────────────────────
# Wire protocol for the controller<->worker job-state reconciliation
# exchange sent on worker (re)join: OPCode_jobStateQuery (controller ->
# worker, lists the jobs the controller currently believes are non-
# terminal on that host) and OPCode_jobStateReport (worker -> controller,
# the worker's per-job answer, plus any extra running/recently-finished
# job outside the query, queried=false). Both are sent fire-and-forget
# (no reply arm -- same one-way pattern as e.g. OPCode_push/OPCode_notify)
# and are paginated via the same {ntotal, pos, count} shape already used
# by JobData/WorkerData/ResourceVals (see request.c's xce_reply_get/
# xce_push_data_req). This is schema-only: the C-side encode/decode
# helpers (task 1.4), controller/worker send-receive wiring (tasks 3.1,
# 4.2, 6.1, 6.2), and reconciliation-apply logic (tasks 2.1-2.2, 3.2) are
# all later tasks, out of this task's scope.
enum JobStateStatus {
running @0;
finishedOk @1;
finishedFail @2;
unrecognized @3;
}
struct JobStateEntry $C.mapname("xce_job_state_entry_t") {
jobid @0: UInt64;
status @1: JobStateStatus;
exitCode @2: Int32 $C.mapname("exit_code"); # meaningful only for finishedFail
finishTimeMs @3: UInt64 $C.mapname("finish_time_ms"); # meaningful only for finishedOk/finishedFail; worker-reported (Req 3.5), not report-send time
queried @4: Bool; # false = Req 3.6 extra, not part of the controller's original query
}
struct JobStateQuery $C.mapname("xce_job_state_query_t") {
ntotal @0: UInt32 $C.mapname("n_total");
pos @1: UInt32;
jobids @2: List(UInt64) $C.mapname("jobids") $C.maplistcount("count");
}
struct JobStateReport $C.mapname("xce_job_state_report_t") {
ntotal @0: UInt32 $C.mapname("n_total");
pos @1: UInt32;
entries @2: List(JobStateEntry) $C.mapname("entries") $C.maplistcount("count");
}
struct Request $C.mapname("xce_request_t"){
opcode @0: OPCode;
seq @1: UInt64;
@ -750,6 +794,8 @@ struct Request $C.mapname("xce_request_t"){
fetchfilemsg @30: FetchFileMsg;
schedadminmsg @31: SchedAdminRequest;
probeconfigtagrequestmsg @32: ProbeConfigTagRequest;
jobstatequerymsg @33: JobStateQuery;
jobstatereportmsg @34: JobStateReport;
}
}
@ -798,6 +844,11 @@ struct ClusterConfig $C.mapname("cluster_config_t") {
hproviders @10: List(ScalerConfig) $C.mapname("hproviders") $C.maplistcount("nhproviders");
limits @11: List(LimitConfig) $C.mapname("limits") $C.maplistcount("nlimits");
configGeneration @12: UInt64 $C.mapname("config_generation");
# worker-rejoin-resync (Req 3.7, 5.3): shared, cluster-wide via
# operational-uniformity override (design.md Configuration Model) --
# alongside heartbeatInterval/inactiveHeartbeatCount above, same domain.
workerResyncWindowMs @13: UInt32 $C.mapname("worker_resync_window_ms");
workerResyncTimeoutMs @14: UInt32 $C.mapname("worker_resync_timeout_ms");
}
# ── Persistence configuration (Part 2.6) ────────────────────────────