Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Recover split publication and bind metadata to the selected snapshot
When publishing data and saving its checkpoint cannot share a transaction, define recovery for every crash window and read freshness metadata from the same selected generation as the data.
Bad example
| 1 | const rows = await readCurrentAlias(); |
| 2 | const checkpoint = await readCheckpoint(); |
| 3 | return { rows, freshAt: checkpoint.freshAt }; |
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 target = await resolvePublishedTarget(); |
| 2 | const checkpoint = await readCheckpoint(); |
| 3 | const state = checkpoint.generation === target.generation |
| 4 | ? checkpoint |
| 5 | : await readValidatedGenerationMetadata(target); |
| 6 | return { rows: await readConcreteTarget(target), freshAt: state.freshAt }; |
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)
Persist validated recovery metadata with the candidate before switching the read pointer. Make the published pointer authoritative for which dataset is live and reconcile a lagging checkpoint on retry using ownership protection. Readers must resolve once and query that same concrete generation, matching checkpoint identity or using generation-bound metadata. Do not interpret an ownership lease extension as successful data refresh. Test failure before publication, after publication but before checkpoint persistence, and during retry. An ambiguous timeout requires reading authoritative state before deciding whether publication failed.
Bilješke (HR)
Ako objava i checkpoint nisu jedna transakcija, definiraj oporavak nakon svakog prekida. Podatke i vrijeme osvjezavanja citaj za istu generaciju. Produzenje leasea ne znaci da su podaci uspjesno osvjezeni.
Exceptions / Tradeoffs (EN)
If data, pointer and checkpoint are committed in one transaction and read through a consistent snapshot, separate recovery metadata is unnecessary. An alternative durable log or reconciliation protocol is valid when it provides the same recovery and reader consistency guarantees.
Iznimke / Tradeoffi (HR)
Primijeni samo kada postoje navedeni uvjeti. Jednostavniji pristup je valjan ako sustav vec jamci isti rezultat.