Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Finalize backfilled caches only after complete persisted traversal
A bulk cache rebuild needs an explicit completion step after every contributing source has finished and expected members and payloads are persisted. Preserve incomplete state after failures or size truncation.
Bad example
| 1 | async function rebuild(batches: string[][], write: (batch: string[]) => Promise<void>, complete: () => Promise<void>) { |
| 2 | for (const batch of batches) { |
| 3 | await write(batch); |
| 4 | await complete(); |
| 5 | } |
| 6 | } |
Explanation (EN)
Marking complete during an intermediate batch lets readers trust a partial bucket.
Objašnjenje (HR)
Oznaka potpunosti tijekom međupaketa dopušta čitateljima da vjeruju nepotpunim podacima.
Good example
| 1 | async function rebuild(batches: string[][], write: (batch: string[]) => Promise<void>, verifyAndComplete: () => Promise<void>) { |
| 2 | for (const batch of batches) await write(batch); |
| 3 | await verifyAndComplete(); |
| 4 | } |
Explanation (EN)
Finalize only after all writes; verification must reject missing payloads and truncated membership.
Objašnjenje (HR)
Dovrši tek nakon svih upisa; provjera mora odbiti nedostajuće podatke i skraćene skupove.
Notes (EN)
Before setting a shared cache complete, prove that all contributing sources traversed their intended range and every required membership/payload write persisted.
Bilješke (HR)
Prije označavanja zajedničkog cachea potpunim dokaži da su svi izvori prošli namjeravani raspon i da su svi potrebni zapisi članstva i sadržaja uspješno pohranjeni.
Exceptions / Tradeoffs (EN)
Independently complete partitions may be finalized separately when the cache contract does not combine them. A completed loop is not proof of completeness after swallowed writes, pagination truncation or concurrent writers. Use generation/version ownership when another rebuild can overlap.
Iznimke / Tradeoffi (HR)
Neovisne particije mogu se završavati zasebno ako ih ugovor ne spaja. Završena petlja nije dokaz potpunosti nakon prešućenih pogrešaka zapisa, prekinute paginacije ili istodobnih upisa. Za preklapajuće obnove koristi vlasništvo nad generacijom ili verzijom.