myxce/.wolf
Rongsong Shen f7b732a300
fix(controller): WAL_JOB_RUSAGE loses job.run_usage on replay (bug-1690)
Same class as bug-1678/1687/1689: the WAL fact for WAL_JOB_RUSAGE only
carried {jobid, state}, so job.run_usage (client-reported per-host
CPU/mem usage) was never restored on either apply seam after a restart.

Unlike the prior three, xce_job_runusage_t/xce_host_runusage_t had no
existing Cap'n Proto mapping -- a genuine new schema addition
(HostRunusage/JobRunusage in controller.capnp, mirroring JobPendReason's
List(NestedStruct)+$C.maplistcount style), verified against the real
struct definitions in types.h, codegen confirmed via nm on the built
binary rather than assumed.

Two deliberate deviations from the established precedent, found by
reading the real code rather than copying the pattern blindly:

1. Adoption is unconditional, not gated on a state transition -- a
   rusage report almost never changes job.state (repeat reports keep
   state at RUN), so gating on JOB_TRANSITION_APPLIED like START/FINISH/
   DISPATCH do would make the fix dead code for the realistic case.

2. Merge, not free-and-replace. update_host_runusage() builds run_usage
   with host_name sourced from makeString() -- an RTTI-managed pointer,
   not malloc() -- and the primary's own live apply pump re-applies every
   fact it just wrote. A naive free_JobRunusage_ptr()-then-adopt (matching
   the prior three fixes exactly) would free() a non-malloc'd pointer on
   the very first live rusage report for a new host -- guaranteed heap
   corruption. Fixed with merge_job_runusage(): existing hosts get
   scalar-only in-place updates (host_name pointer never touched), only
   genuinely new hosts adopt their freshly-decoded (safe, malloc'd)
   host_name. Proved via a real makeString()-backed test asserting
   pointer identity survives, not just value equality. job_destroy()
   (src/lib/jobj.c) was found to have this identical latent mismatch,
   pre-existing and independent of this fix -- flagged, not fixed here.

Found by an /xce-audit-invariants controller pass (field-complete apply
parity dimension). 8 new tests in test_wal_job_rusage_fact.c; RED/GREEN
independently verified. Full controller suite: 1160 tests, 2 failures --
both the pre-existing, unrelated bug-1561 overlayfs sandbox flake. No
ASAN/heap-corruption findings. Backward compatibility confirmed for
old-format bare-payload entries.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AgYRU3zDTqNGV5Jk8aiKLg
2026-08-25 10:53:32 +00:00
..
hooks chore(wolf): sync anatomy/cerebrum/memory/hooks/token-ledger bookkeeping 2026-08-25 09:59:07 +00:00
_scan-state.json commit wolf status 2026-08-17 06:35:54 +00:00
anatomy-index.json commit wolf status 2026-08-17 06:35:54 +00:00
anatomy.md chore(wolf): sync anatomy/cerebrum/memory/hooks/token-ledger bookkeeping 2026-08-25 09:59:07 +00:00
buglog.json fix(controller): WAL_JOB_RUSAGE loses job.run_usage on replay (bug-1690) 2026-08-25 10:53:32 +00:00
cerebrum.md chore(wolf): sync anatomy/cerebrum/memory/hooks/token-ledger bookkeeping 2026-08-25 09:59:07 +00:00
config.json chore: checkpoint all prior work for clean state 2026-06-04 13:04:16 +00:00
cron-manifest.json chore: checkpoint all prior work for clean state 2026-06-04 13:04:16 +00:00
cron-state.json save wolf status 2026-08-18 14:50:44 +00:00
daemon.log save wolf status 2026-08-18 14:50:44 +00:00
designqc-report.json chore: checkpoint all prior work for clean state 2026-06-04 13:04:16 +00:00
identity.md chore: checkpoint all prior work for clean state 2026-06-04 13:04:16 +00:00
memory.md chore(wolf): sync anatomy/cerebrum/memory/hooks/token-ledger bookkeeping 2026-08-25 09:59:07 +00:00
OPENWOLF.md chore(wolf): guard buglog.json integrity, add dedupe rule and auto-checkpoint 2026-08-13 04:28:44 +00:00
reframe-frameworks.md chore: checkpoint all prior work for clean state 2026-06-04 13:04:16 +00:00
suggestions.json chore(wolf): checkpoint session state (anatomy, cerebrum, memory, scan-state) 2026-08-16 11:02:17 +00:00
token-ledger.json chore(wolf): sync anatomy/cerebrum/memory/hooks/token-ledger bookkeeping 2026-08-25 09:59:07 +00:00