← all branches

fix/job-active

needs attention
3e1361a · incrementalPR #314reviewed 2026-07-16 01:14 UTC0H · 1M · 0L · 3I
The branch
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)
The changes (whole branch)
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+195docs/development+2050domains/cross-domain+38314domains/utility/src/utility-contract+53010domains/utility/src/bill+324domains/utility/src/monitoring-subscription+390domains/utility/src/payment-monitoring-subscription+390domains/utility/src/site-utility-contract+430services/utility/bills/cfe+31
Blast
20 files, +1539/−41 across the branch. This commit is test-only (+40/−16 in one file).
test-only commit OCC safety
CI· No CI checks reported for this PRCodeRabbit· No .coderabbit.yaml in repo

Findings · 4

correctness1

medium

`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

info

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.

info

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.

info

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

  1. 3e1361aneeds attentionincremental0H · 1M · 0L2026-07-16 01:14current
  2. c7b4e31needs attentionincremental0H · 1M · 5L2026-07-16 01:03
  3. 2099ea7needs attentionincremental0H · 3M · 5L2026-07-16 00:53
  4. ce2dc3eneeds attentionincremental0H · 1M · 1L2026-07-16 00:44
  5. df0ef09needs attentionincremental0H · 2M · 3L2026-07-16 00:23
  6. d4a8d84needs attentionfull0H · 3M · 5L2026-07-16 00:04