package dev.ulfrx.recipe.shared.domain.model

import kotlinx.datetime.Instant
import kotlinx.serialization.Serializable

/**
 * Per-row sync footer for every household-scoped or catalog entity.
 *
 * All three timestamps are server-assigned, never client-supplied — the
 * monotonic `(updatedAt, id)` pair is the pull cursor, and a client-set
 * `updatedAt` would break LWW conflict resolution across devices with drifted
 * clocks. [deletedAt] is the soft-delete tombstone; rows with `deletedAt != null`
 * still ship through sync so deletes propagate to other devices.
 */
@Serializable
public data class SyncMeta(
    public val id: String,
    public val householdId: HouseholdId,
    public val createdAt: Instant,
    public val updatedAt: Instant,
    public val deletedAt: Instant? = null,
)

/**
 * A household — the tenancy boundary for every per-household entity (plan,
 * pantry, shopping list, the household-scoped taxonomy entries in
 * [IngredientCategory] / [MealSlot]). Members share a single household; v1 has
 * one active household per user.
 */
@Serializable
public data class Household(
    public val id: HouseholdId,
    public val name: String,
    public val createdAt: Instant,
    public val updatedAt: Instant,
)
