fix/job-active
needs attention3e1361a · incrementalPR #314reviewed 2026-07-16 01:14 UTC0H · 1M · 0L · 3I- Purpose
- Fix a live incident (2026-07-14, Solfium RPU 077120901845) where status-blind contract resolution picked a terminated row, minting a junk site and corpse SUC
- Goal
- Active-first RPU resolution + evidence-driven self-healing reactivation + OCC safety on updateContractShell
- Sub-goals
- SG-1: Active-first query adopted by job-intent, cfe-jobs, public-v1 jobs, wizard, payment-status writers
- SG-2: Terminated-only RPUs skip site/SUC/subscription creation
- SG-3: Evidence-driven ReactivateContract decision branch
- SG-4: reassignContractIdDeduped on SUC + subscription tables
- SG-5: Pin all three OCC diagnostic branches in tests (this commit)
- What
- Test-only: refactored OCC 500-branch spy setup to pre-fetched liveRow mocks; extracted runWithDiagnosticReRead helper; added soft-deleted-row test (third diagnostic branch)
- Why
- Prior mockImplementationOnce(originalFind) was fragile — called through to real DB via spy chain. New test pins that soft-deleted row must not produce retryable 409.
- Areas
- apps/platform+19−5docs/development+205−0domains/cross-domain+383−14domains/utility/src/utility-contract+530−10domains/utility/src/bill+32−4domains/utility/src/monitoring-subscription+39−0domains/utility/src/payment-monitoring-subscription+39−0domains/utility/src/site-utility-contract+43−0services/utility/bills/cfe+3−1
- Blast
- 20 files, +1539/−41 across the branch. This commit is test-only (+40/−16 in one file).
Findings · 4
correctness1
`expect(findSpy).toHaveBeenCalledTimes(2)` inside `try` before `return result` — failure hides actual shell output
domains/utility/src/utility-contract/__tests__/utility-contract.integration.test.ts:446
If spy count fails (future refactor removes the diagnostic re-read), AssertionError propagates before caller error-shape assertions run. Move assertion into each it() body.
tests3
Soft-deleted test fetches liveRow twice — helper already does it internally
domains/utility/src/utility-contract/__tests__/utility-contract.integration.test.ts:463
Use { ...testContract, deletedAt: new Date() } to avoid the redundant DB call.
409 test spy asymmetry vs 500 tests is correct but unexplained
domains/utility/src/utility-contract/__tests__/utility-contract.integration.test.ts:399
A one-line comment on the 409 test explaining why findByPublicId hits the real DB prevents confusion.
409 test does not assert on versionConflict context fields (expectedVersion / actualVersion)
domains/utility/src/utility-contract/__tests__/utility-contract.integration.test.ts:412
Nice-to-have: expect(result.error.actualVersion).toBeGreaterThan(result.error.expectedVersion) would pin the retry hint.
History · 6 commits
- 3e1361aneeds attentionincremental0H · 1M · 0L2026-07-16 01:14current
- c7b4e31needs attentionincremental0H · 1M · 5L2026-07-16 01:03
- 2099ea7needs attentionincremental0H · 3M · 5L2026-07-16 00:53
- ce2dc3eneeds attentionincremental0H · 1M · 1L2026-07-16 00:44
- df0ef09needs attentionincremental0H · 2M · 3L2026-07-16 00:23
- d4a8d84needs attentionfull0H · 3M · 5L2026-07-16 00:04