diff --git a/.kiro/specs/worker-rejoin-resync/tasks.md b/.kiro/specs/worker-rejoin-resync/tasks.md index 08998123..91fe14c1 100644 --- a/.kiro/specs/worker-rejoin-resync/tasks.md +++ b/.kiro/specs/worker-rejoin-resync/tasks.md @@ -7,7 +7,7 @@ - Observable completion: the schema builds cleanly and the new message/opcode/config-field definitions are visible in the generated bindings - _Requirements: 2.1, 2.2, 3.5, 3.7, 5.3, 8.1, 8.2, 8.3_ -- [ ] 1.2 (P) Add a worker reconciling status and round-tracking state +- [x] 1.2 (P) Add a worker reconciling status and round-tracking state - Add a new worker status value meaning "job-state reconciliation outstanding for this host" - Add a per-worker reconciliation-round structure capable of holding a round identifier, the set of queried job IDs, and a deadline - Observable completion: the new status value and round structure compile and are reachable from the worker record, unused by any caller yet diff --git a/src/include/xce/types.h b/src/include/xce/types.h index 6ef8856b..e7a71f19 100644 --- a/src/include/xce/types.h +++ b/src/include/xce/types.h @@ -174,6 +174,7 @@ typedef struct { #define XCE_WORKER_CLOSED (0x00100000) #define XCE_WORKER_HIDDEN (0x00200000) /* Admin explicitly removed — invisible but not yet cleaned up */ #define XCE_WORKER_CLOSED_BY_ADMIN (0x00400000) /* Admin closed — host closed explicitly by admin */ +#define XCE_WORKER_RECONCILING (0x00800000) /* worker-rejoin-resync: job-state reconciliation outstanding for this host (Req 5.1) */ #define IS_WORKER_UNAVAIL(status) (((status) & XCE_WORKER_UNAVAIL) != 0) #define IS_WORKER_LOCKEDU(status) (((status) & XCE_WORKER_LOCKEDU) != 0) @@ -182,6 +183,7 @@ typedef struct { #define IS_WORKER_LOCKED(status) \ (IS_WORKER_LOCKEDU(status) || IS_WORKER_LOCKEDW(status)) #define IS_WORKER_BUSY(status) (((status) & XCE_WORKER_BUSY) != 0) +#define IS_WORKER_RECONCILING(status) (((status) & XCE_WORKER_RECONCILING) != 0) typedef struct { char* hosttype; @@ -281,12 +283,32 @@ typedef struct { double allocated; } xce_res_account_t; +/* worker-rejoin-resync: per-worker job-state reconciliation round. One + * resync_state_t per worker_t (worker_t.resync below), absent (NULL) when + * no reconciliation is currently outstanding for that worker. Purely + * in-memory bookkeeping, not itself persisted -- see design.md's Data + * Models / State Management for the full rationale. */ typedef struct { - xce_worker_t host; - char hostkey[XCE_MAXKEY_LEN]; - endpoint_t* ep; - int idx; - zarray_t usages; + uint64_t round_token; /* discards stale/superseded reports (Req 6.3) */ + int n_queried_jobids; + uint64_t* queried_jobids; /* set semantics (membership-checked, not + * positionally iterated): job IDs queried this + * round; array+count, mirroring + * xce_job_state_query_t.jobids (typemap.h) */ + uint64_t deadline; /* CLOCK_MONOTONIC ms deadline (Req 5.3); same + * representation as delaymgr_t.nextrun_ms + * (delay.h) */ +} resync_state_t; + +typedef struct { + xce_worker_t host; + char hostkey[XCE_MAXKEY_LEN]; + endpoint_t* ep; + int idx; + zarray_t usages; + resync_state_t* resync; /* worker-rejoin-resync: NULL unless a job-state + * reconciliation round is currently outstanding + * for this worker */ } worker_t; typedef struct {