feat(scheduler-allocation): implement the unsatisfiable-resreq cache

Adds alloc_cache.c: xce_cache_key_t, cache_key_ops (the corrected
three-way, 0-means-equal .cmp -- an inverted-boolean version was a
real bug found during design review), and cache_lookup/insert/clear
against a real kvtab_t (constructed matching xce_select.c's
sel_node_table_init() precedent). Cache values are a boxed reason-
category int, not a bare hit/miss sentinel, satisfying Req 7 AC5's
requirement that a hit reproduce the original pend-reason category.
unsatisfiable_cache lives on xce_scheduler_t per Req 7 AC1.

Task 2.2 (scheduler-allocation spec). Requirements 7.1, 7.3, 7.4, 7.5.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYdtrEWWZfKRRGED7raEYg
This commit is contained in:
Rongsong Shen 2026-09-04 17:23:59 +00:00
parent d9831b0bc8
commit 86c86352d1
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
8 changed files with 871 additions and 1 deletions

View file

@ -138,6 +138,27 @@ typedef struct {
typedef struct {
xce_sched_core_t core;
xcecli_ctx_t apictx;
/* Req 7.1 (scheduler-allocation spec, task 2.2): the per-session
* unsatisfiable-resreq fingerprint cache -- a kvtab_t (kv.h, RTTI `var`)
* keyed by xce_cache_key_t (sched/alloc_cache.h), value = a pend-reason
* category boxed as (void*)(intptr_t)category (Req 7.5). Constructed in
* sched_init(), destroyed in sched_fini() (scheduler.c) -- both minimal
* construct/destroy calls only, using the exported cache_key_ops
* (sched/alloc_cache.h), mirroring xce_select.c's sel_node_table_init()
* convention for a composite-struct-keyed kvtab_t. Lookup/insert
* (cache_lookup()/cache_insert(), alloc_cache.c) are confined to the
* allocator thread; NULL until sched_init() constructs it.
*
* NOTE (task 2.2 CONCERN, for a later task's attention): Req 7.2
* requires cache_clear() to run inside core_begin_session_internal()
* (core_session.c), which only receives xce_sched_core_t* core, not
* xce_scheduler_t* -- this field lives on the outer driver struct per
* this task's own scope, not on `core` above. Wiring AC 2's clear call
* is explicitly a later task (tasks.md 5.2), not this one; whoever
* implements it will need to either reach the owning xce_scheduler_t
* from `core` (core is this struct's first member, so the standard
* pointer-to-first-member idiom applies) or relocate this field. */
var unsatisfiable_cache;
xce_cluster_config_t
cluster_cfg; /* HA candidate list. Empty (candidates_count==0) only
* transiently before sched_init() runs, when no