Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Fence destructive cleanup against worker takeover
Destructive cleanup needs the same ownership protection as publication. Do not choose the live data to preserve solely from a caller-supplied snapshot identifier.
Bad example
| 1 | await removeOlderThan(cutoff, callerGeneration); |
Explanation (EN)
Destructive cleanup needs the same ownership protection as publication. Do not choose the live data to preserve solely from a caller-supplied snapshot identifier.
Objašnjenje (HR)
Primjer ne provodi opisanu zastitu.
Good example
| 1 | const current = await requireOwnedLease(run); |
| 2 | const retired = await findRetired(current.generation, safeCutoff); |
| 3 | await deleteFenced(retired, run); |
Explanation (EN)
Read the authoritative pointer, verify persisted lease identity and expiry, and recheck before destructive batches. A check followed by a delete is not atomic fencing on its own. Use immutable non-reused generations and a safe temporal boundary, conditional deletes, or another invariant that remains true during delayed requests. Test a takeover while cleanup is waiting.
Objašnjenje (HR)
Provjeri uvjete prije operacije i sacuvaj jasno definirano ponasanje.
Notes (EN)
Read the authoritative pointer, verify persisted lease identity and expiry, and recheck before destructive batches. A check followed by a delete is not atomic fencing on its own. Use immutable non-reused generations and a safe temporal boundary, conditional deletes, or another invariant that remains true during delayed requests. Test a takeover while cleanup is waiting.
Bilješke (HR)
Primijeni kod spremanja podataka i skupnih operacija kada vrijede opisani uvjeti.
Exceptions / Tradeoffs (EN)
A proven single-writer environment without delayed or overlapping work can use simpler cleanup, but that constraint must be enforced rather than assumed.
Iznimke / Tradeoffi (HR)
Iznimke ovise o ugovoru sustava navedenom u engleskom opisu.