CAP-002 Phase 2 (Prerequisite #3) — pure survivor filter for the shard-scoped BullMQ retry path.
Single source of truth for the "which results survive a shard retry?" contract. Used by:
database/repositories/runRepo.jspurgeShardResults— the atomic transactional read-modify-write on the liveresultscolumn.workers/runWorker.jslegacy single-shard catch block — preserves the pre-CAP-002 wipe-all behaviour (every execution row dropped, only non-executed skips kept) whenshardIndex == null.backend/tests/run-worker-shard-retry.test.js— verifies the contract directly without mirroring the logic.
Survivors are kept when ANY of:
isNonExecutedSkip(r)returns true (over_budget / skipped_no_impact — AUTO-001 / AUTO-004 contract: a final dispatch decision, not a transient execution state).shardIndex != null && r._shardIndex != null && r._shardIndex !== shardIndex(sibling shard's already-completed row that must not be erased).
Legacy single-shard path (shardIndex == null) keeps only the non-executed
skips — bit-for-bit identical to the pre-CAP-002 wipe-all behaviour.
Parameters:
| Name | Type | Description |
|---|---|---|
results |
Array.<Object> | The current results array (may be empty/null). |
shardIndex |
number | null | 0-based shard index, or |
isNonExecutedSkip |
function | Predicate from |
- Source:
Returns:
Filtered survivors. Never returns the input array reference — callers can mutate the result without affecting the input.
- Type
- Array.<Object>
Methods
(static) countShardRetrySurvivors(survivors) → {Object}
CAP-002 Phase 2 — Re-derive { passed, failed } from a survivor array.
Matches the processResult contract: warning counts as passed.
Parameters:
| Name | Type | Description |
|---|---|---|
survivors |
Array.<Object> |
- Source:
Returns:
- Type
- Object