Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Verify the existing integration owner and producer contract before adding metadata consumers
Before adding a metadata field in a consumer, trace the existing external-service integration and verify that the real producer exposes the field. Extend the owning integration when appropriate; a defaulted consumer with a fabricated test payload does not establish end-to-end support.
Bad example
| 1 | type Response = { article: Record<string, unknown> }; |
| 2 | function score(response: Response) { |
| 3 | return response.article.isSyndicated === true ? 2 : 1; |
| 4 | } |
| 5 | // A synthetic fixture passes even when the producer never sends this key. |
| 6 | const result = score({ article: { isSyndicated: true } }); |
Explanation (EN)
The consumer assumes an unverified field and silently defaults when the real producer omits it.
Objašnjenje (HR)
Potrošač pretpostavlja neprovjereno polje i koristi zadanu vrijednost kada ga stvarni izvor izostavi.
Good example
| 1 | type SourceArticle = { syndicated: boolean }; |
| 2 | type Metadata = { score: 1 | 2 }; |
| 3 | function metadataFor(article: SourceArticle): Metadata { |
| 4 | return { score: article.syndicated ? 2 : 1 }; |
| 5 | } |
| 6 | async function syncArticle(article: SourceArticle, send: (data: Metadata) => Promise<void>) { |
| 7 | await send(metadataFor(article)); |
| 8 | } |
Explanation (EN)
Extend the established integration using verified source data, and test the real producer-to-destination mapping.
Objašnjenje (HR)
Proširi postojeću integraciju provjerenim izvornim podatkom i testiraj stvarno mapiranje do odredišta.
Notes (EN)
Applies when adding fields across service boundaries or reviewing a consumer-only change. Inspect the producer projection, a representative response, and existing push/update paths. A missing-field fallback is compatibility behavior, not proof that new values can arrive. Verify the destination field contract before implementing the mapping.
Bilješke (HR)
Primjenjuje se na nova polja između servisa i pregled promjena samo u potrošaču. Provjeri projekciju izvora, stvarni odgovor i postojeće putove slanja. Fallback nije dokaz da nova vrijednost može stići. Provjeri ugovor odredišta prije mapiranja.
Exceptions / Tradeoffs (EN)
Separate delivery paths may both be required by the external service. In that case keep mappings consistent and explicitly coordinate producer and consumer changes; do not remove a path solely because another exists.
Iznimke / Tradeoffi (HR)
Vanjski servis može zahtijevati oba puta dostave. Tada uskladi mapiranja i promjene izvora i potrošača; nemoj ukloniti put samo zato što drugi postoji.