namespace NeonSprawl.Server.Game.Contracts;
///
/// Persisted per-player contract instances (NEO-146).
/// Contract generator/completion orchestrators (NEO-147, NEO-149) consume this interface — not HTTP directly.
///
public interface IContractInstanceStore
{
/// True when mutations for are allowed (dev bucket or Postgres player_position row).
bool CanWritePlayer(string playerId);
/// Missing row ⇒ false.
bool TryGet(string playerId, string contractInstanceId, out ContractInstanceState snapshot);
/// At most one active row per player; missing active ⇒ false.
bool TryGetActiveForPlayer(string playerId, out ContractInstanceState snapshot);
///
/// Creates an active instance. Returns false when player not writable, ids invalid, duplicate instance id,
/// or player already has an active contract.
///
bool TryCreateActive(
string playerId,
string contractInstanceId,
string templateId,
string seedBucket,
DateTimeOffset issuedAt,
out ContractInstanceState snapshot);
/// First completion returns true; replays return false without changing .
bool TryMarkComplete(
string playerId,
string contractInstanceId,
DateTimeOffset completedAt,
out ContractInstanceState snapshot);
/// Dev fixture only — removes one instance row; idempotent when absent.
bool TryClearInstance(string playerId, string contractInstanceId);
}