Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Publish complete snapshots through an atomic read pointer
When readers require a complete replacement dataset, consider writing an isolated immutable generation and atomically switching a stable read pointer after validation.
Bad example
| 1 | await deleteLiveRows(); |
| 2 | await insertRows(nextRows); |
Explanation (EN)
This sequence does not enforce the required storage guarantee.
Objašnjenje (HR)
Ovaj slijed ne osigurava potrebnu garanciju pohrane.
Good example
| 1 | const candidate = await writeIsolatedGeneration(nextRows); |
| 2 | await validateAndMakeSearchable(candidate); |
| 3 | await publishWithOwnershipFence(candidate); |
Explanation (EN)
The storage operation and its observable result enforce the stated contract. Helper names denote required backend guarantees, not guarantees supplied by TypeScript.
Objašnjenje (HR)
Operacija i njezin vidljivi rezultat provode zadani ugovor. Nazivi helpera predstavljaju potrebne garancije baze, a ne TypeScripta.
Notes (EN)
Use this for complete dataset replacement when partial visibility or mixed generations violates the reader contract. A database transaction, versioned manifest or search alias can supply the switch. Prefer a stable read boundary over requiring every consumer to remember a generation filter. Atomic switching alone does not reject a delayed former owner. Enforce ownership in the same mutation or another proven invariant, and test takeover during publication. Keep old generations until in-flight readers are safe, then delete only retired resources. Account for index/shard cost and retention before choosing one index per generation. For reused generations, creation time is not retirement time. Start reader retention when the generation is superseded or first observed retired, and preserve it for the full reader grace period. If retirement metadata is absent, begin a conservative grace period rather than immediately deleting an old generation. Test a generation reused longer than retention and replaced while a reader still holds its identity. Budget retained copies from maximum changed-snapshot cadence, complete payload size and per-index/shard overhead. Choose the shortest grace period compatible with bounded readers. Keep generation IDs out of longer-lived caches or define explicit reader pins. Include delayed retirement observation and cleanup failures in capacity estimates. Do not delete still-readable generations merely to satisfy a count cap.
Bilješke (HR)
Kod potpune zamjene podataka pripremi novu generaciju i tek onda promijeni pokazivac. Atomska promjena sama ne sprjecava starog workera da kasnije objavi svoje podatke. Provjeri vlasnistvo pri samoj promjeni i sacuvaj stare podatke za aktivne citatelje. Kod dugo koristene generacije racunaj zadrzavanje od zamjene ili prve potvrde da vise nije aktivna, a ne od stvaranja. Ako taj podatak nedostaje, zapocni novi sigurni period.
Exceptions / Tradeoffs (EN)
Do not require a new physical index for every update. Incremental datasets, expensive index allocation, or an existing transactionally enforced reader boundary can justify another design. Evaluate this as a design choice rather than treating absence of an alias as a bug.
Iznimke / Tradeoffi (HR)
Primijeni samo kada postoje navedeni uvjeti. Jednostavniji pristup je valjan ako sustav vec jamci isti rezultat.