fix(schema): rename struct Data -> XceData to unshadow capnp builtin blob type

controller.capnp declared `struct Data $C.mapname("xce_data_t")` (an
OPCode_get query-result tagged union) at file scope, which shadows
Cap'n Proto's builtin Data blob type for every later `: Data` field in
the same file. This silently miscompiled 7 fields across 6 structs as
a struct-pointer type instead of a raw byte blob: UpgradeConfigRequest
.sha256/.bytes, ReplConfigReply.sha256/.bytes, ReplConfigPushRequest
.sha256/.bytes, ReplEnvelope.payload, SnapshotTransfer's chunk
payload, WalCatchupEntry.payload/.batchPayloads, and CtrlHelloRequest
.key. Production C code had already routed around it for years via
hand-rolled raw capn_ptr manipulation (see request.c's own comments);
nothing before now needed the generated codec/accessors to actually
work for these fields.

Renamed the local struct to XceData (capnp-level name only; the
$C.mapname("xce_data_t") C typedef is unchanged) and explicitly
repointed getdata/pushmsg at XceData by name, since those two fields
correctly want the local tagged union. Updated every derived
generated-identifier reference across 19 hand-written files spanning
controller, lib, scheduler, and the Go apiserver/xcecli CGo bindings.
Fixed 5 call sites in lib/request.c that had been typed against the
old workaround alias but now legitimately receive the correct
capn_data type (a pure type-name swap -- Data_ptr/XceData_ptr and
capn_data share the identical {capn_ptr p} layout).

Verified via full rebuild+test: lib (1/1), controller (3/3, incl. the
job-array push regression tests), scheduler (15/15), Go apiserver +
xcecli (all packages green), and a direct pycapnp round-trip proving
UpgradeConfigRequest.sha256/.bytes now encode/decode correctly.

Bug: bug-1461 (.wolf/buglog.json). Unblocks admin-config-tool task 3.3.
This commit is contained in:
Rongsong Shen 2026-07-22 09:22:04 +00:00
parent 7ed3a3941f
commit e53c086ec5
21 changed files with 144 additions and 144 deletions

View file

@ -41,7 +41,7 @@ static int sched_on_jobs(xce_scheduler_t* sched, int njobs, xce_job_t** jobs)
/* job-array-single-wal-record task 5.3 (design.md "Compact Scheduler/
* API-Server Push", File Structure Plan handler.c bullet; Req 6.3, 6.4, 6.5,
* 8.4): sibling case to Data_data_schedjobs (sched_handle_dataset, below)
* 8.4): sibling case to XceData_data_schedjobs (sched_handle_dataset, below)
* decoding the compact Data.jobArray descriptor -- task 5.1's
* xcesched_push_jobarray() wire shape, one JobSubmit{jobid, arraySize,
* submit} carrying the array's base jobid, element count and ONE shared job
@ -247,7 +247,7 @@ static int sched_on_job_array(xce_scheduler_t* sched,
free(jobs);
}
/* On success sched_on_jobs()/the pend-update killer now owns jobs[] and
* every element in it (mirrors the existing Data_data_schedjobs case
* every element in it (mirrors the existing XceData_data_schedjobs case
* below, which hands dataset->rows to sched_on_jobs the same way). */
return rc;
@ -325,7 +325,7 @@ static int sched_handle_dataset(xce_scheduler_t* sched, dataset_t* dataset)
TRACE("%s table = %s", __func__, xce_dataset_table(dataset->table));
switch (dataset->table) {
case Data_data_schedjobs:
case XceData_data_schedjobs:
rc = sched_on_jobs(sched, dataset->nrows, (xce_job_t**)dataset->rows);
if (rc >= 0) {
/* jobs will be put in pend update request queue */
@ -334,7 +334,7 @@ static int sched_handle_dataset(xce_scheduler_t* sched, dataset_t* dataset)
}
break;
case Data_data_schedworkers:
case XceData_data_schedworkers:
rc = sched_on_workers(sched, dataset->nrows,
(xce_worker_t**)dataset->rows);
if (rc >= 0) {
@ -343,7 +343,7 @@ static int sched_handle_dataset(xce_scheduler_t* sched, dataset_t* dataset)
dataset->rows = NULL;
}
break;
case Data_data_resources:
case XceData_data_resources:
rc = sched_handle_resources(sched, dataset->nrows,
(xce_resource_t**)dataset->rows);
if (rc >= 0) {
@ -351,7 +351,7 @@ static int sched_handle_dataset(xce_scheduler_t* sched, dataset_t* dataset)
dataset->rows = NULL;
}
break;
case Data_data_resvals:
case XceData_data_resvals:
rc = sched_handle_resvals(sched, dataset->nrows,
(xce_resval_t**)dataset->rows);
if (rc >= 0) {
@ -359,7 +359,7 @@ static int sched_handle_dataset(xce_scheduler_t* sched, dataset_t* dataset)
dataset->rows = NULL;
}
break;
case Data_data_jobArray:
case XceData_data_jobArray:
rc = sched_on_job_array(sched, (xce_job_submit_t*)dataset->rows);
/* Unlike the list-shaped cases above, we never alias dataset->rows
* into the pend-update queue -- every array element is its own

View file

@ -518,7 +518,7 @@ int sched_update_existing_queue(xce_scheduler_t* sched, xce_queue_t* updated)
/*
* sched_update_existing_job — apply a notify single-job update to an existing
* job IN PLACE. The job must already exist (created via the Data_data_schedjobs
* job IN PLACE. The job must already exist (created via the XceData_data_schedjobs
* dataset path); this function never creates a job.
*
* - NULL payload → -EINVAL

View file

@ -23,7 +23,7 @@
* scheduler-internal externs handler.c references but this file does not
* exercise are stubbed below: sched_init_config (config-init request path)
* and sched_get_job (job-array-single-wal-record task 5.3's per-element
* dedup check, Data_data_jobArray — not tested here, see
* dedup check, XceData_data_jobArray — not tested here, see
* test_job_array_expand.c for the real kvmgr-backed sched_get_job). */
int sched_init_config(xce_scheduler_t* s, xce_conf4sched_t* c)
{

View file

@ -89,7 +89,7 @@ static void seed_existing_job(xce_scheduler_t* sched, uint64_t jobid)
/* Builds a heap-allocated, heap-owned-strings (jobArray, submit) pair -- the
* same shape decode_JobSubmit_ptr() produces on the real wire-decode path
* (controller.capnp.c), not a stack/string-literal stand-in. Task 7.3 made
* sched_handle_dataset()'s Data_data_jobArray case free_JobSubmit_ptr() its
* sched_handle_dataset()'s XceData_data_jobArray case free_JobSubmit_ptr() its
* dataset->rows unconditionally, so any fixture routed through that handler
* must be genuinely heap-owned or the free segfaults on stack memory /
* string literals. Caller owns the returned pointer until it hands it to
@ -154,7 +154,7 @@ static void test_job_array_push_expands_into_n_tasks(void)
ja = init_job_array(5000, 3);
memset(&dataset, 0, sizeof(dataset));
dataset.table = Data_data_jobArray;
dataset.table = XceData_data_jobArray;
dataset.rows = (void*)ja;
/* sched_handle_dataset() owns and frees dataset.rows on return (task
@ -195,7 +195,7 @@ static void test_job_array_redelivery_does_not_duplicate(void)
fixture_init(&sched);
memset(&dataset, 0, sizeof(dataset));
dataset.table = Data_data_jobArray;
dataset.table = XceData_data_jobArray;
dataset.rows = (void*)init_job_array(6000, 2);
/* first delivery: 2 new tasks enqueued. sched_handle_dataset() owns and
@ -309,7 +309,7 @@ static void test_wire_dispatch_chain_delivers_n_tasks(void)
job_array.submit = &submit;
memset(&data, 0, sizeof(data));
data.table = Data_data_jobArray;
data.table = XceData_data_jobArray;
data.data.job_array = &job_array;
memset(&request, 0, sizeof(request));

View file

@ -49,7 +49,7 @@
* it: via xce_decode()'s output, never a hand-built dataset_t.
*
* Bug-catching demonstration (this task's "RED phase"): temporarily
* reverting extract_data()'s `case Data_data_jobArray:` (task 5.3b's fix)
* reverting extract_data()'s `case XceData_data_jobArray:` (task 5.3b's fix)
* back to falling through to `default: rc = -EINVAL` makes this test's first
* assertion (`callnext != 0` while dataset->rows stays NULL) fail loudly,
* and the subsequent job-count assertions fail too (zero tasks created) --
@ -244,7 +244,7 @@ static void build_encoded_push(io_packet_t** out_pkt, uint64_t base_jobid,
job_array.submit = submit_storage;
memset(&data, 0, sizeof(data));
data.table = Data_data_jobArray;
data.table = XceData_data_jobArray;
data.data.job_array = &job_array;
memset(&request, 0, sizeof(request));