feat(ha-commit-barrier-rollout): mark_job_* idempotency/ordering guards (task 6.2)

Guards at the top of mark_job_start/finish/update under the caller's
job lock, before BEFORE_EVENT: duplicate (FINISH on terminal) → INFO
no-op skipping the AFTER_EVENT hook (no WAL append, lsn frozen);
terminal→non-terminal backward (START/UPDATE) → WARN reject preserving
state. Shared job_state_is_backward predicate provably admits every
production forward merge (PDONE/PERR/suspend bit-OR) while rejecting
overwrites. mark_job_fail intentionally unguarded (its merges are
always terminal-forward; job_ctrl pre-gates terminal). 5/5 guard tests
green; full job-lifecycle suite green; census 0 FAIL.
This commit is contained in:
Rongsong Shen 2026-06-13 04:54:36 +00:00
parent 2308389eb1
commit 5522d6f274
3 changed files with 76 additions and 1 deletions

View file

@ -84,7 +84,7 @@
- Observable completion: new cases FAIL (red) against the unguarded `mark_job_start/finish/fail/update` (job.c:583/638/696/726 anchors)
- _Requirements: 5.1, 5.2, 5.3_
- [ ] 6.2 Implement the guards to green
- [x] 6.2 Implement the guards to green
- Add transition guards at the top of each `mark_job_*` (under the caller-held job WRITE lock, before BEFORE_EVENT fires): duplicate → log + return no-op; terminal → non-terminal → WARN + reject preserving state; forward transitions unchanged
- Audit all callers (`on_job_*`, `job_ctrl`, `update_job_rusages`) for the new return semantics
- Observable completion: all task 6.1 tests PASS; existing job lifecycle tests green