Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Read cache validity independently of payload filters
Check cache completeness and legacy markers independently of time, cursor, or source filters applied to cached items. Nonempty filtered data does not prove the bucket is complete.
Bad example
| 1 | type Entry = { score: number; value: string }; |
| 2 | const valid = (entries: Entry[], cutoff: number) => { |
| 3 | const visible = entries.filter(entry => entry.score >= cutoff); |
| 4 | return visible.length > 0 && !visible.some(entry => entry.value === 'legacy'); |
| 5 | }; |
Explanation (EN)
A nonempty filtered result can hide a legacy marker or incomplete source traversal.
Objašnjenje (HR)
Neprazan filtrirani rezultat može sakriti oznaku starog formata ili nepotpun prolaz izvora.
Good example
| 1 | type State = { exists: boolean; complete: boolean; legacy: boolean }; |
| 2 | const valid = (state: State) => state.exists && state.complete && !state.legacy; |
Explanation (EN)
Read validity metadata independently before trusting filtered content.
Objašnjenje (HR)
Stanje valjanosti pročitaj neovisno prije nego povjeruješ filtriranom sadržaju.
Notes (EN)
Read completeness/version/legacy metadata independently of a user's item filters and require a coherent generation between metadata and payload.
Bilješke (HR)
Podatke o potpunosti, verziji i starom formatu čitaj neovisno o korisničkim filtrima elemenata. Metapodaci i sadržaj moraju pripadati usklađenoj generaciji.
Exceptions / Tradeoffs (EN)
A separate metadata read is unnecessary when the existing atomic read guarantees all validity markers are included. One pipeline reduces round trips but is not inherently an atomic snapshot; use a transaction/script/version check when concurrent writes can invalidate the decision.
Iznimke / Tradeoffi (HR)
Zasebno čitanje nije potrebno ako postojeći atomski dohvat već uključuje sve oznake valjanosti. Pipeline smanjuje broj mrežnih odlazaka, ali sam po sebi ne jamči atomsku snimku. Ako konkurentni upisi mogu promijeniti odluku, koristi transakciju, skriptu ili provjeru verzije.