Skip to content

Flag Domain Model

Responsibility

internal/model/flag.go defines the core Flag entity and its validation. internal/model/errors.go defines sentinel errors used by handlers and stores.

Flag struct

Fields (JSON-tagged): name, description, enabled, rollout_percent, kill_switch, created_at, updated_at. See model.Flag.

Invariants (Validate)

  • Name must be non-empty (ErrInvalidName).
  • RolloutPercent must be in [0, 100] (ErrInvalidRollout).
  • Timestamps are set by the store on create/update, not by clients.

Sentinel errors

  • ErrNotFound — flag does not exist.
  • ErrAlreadyExists — duplicate name on create.
  • ErrInvalidName, ErrInvalidRollout — validation failures.

Usage

  • Handlers call f.Validate() before persistence and map sentinel errors to HTTP status codes (404, 409, 400).
  • Stores call Validate() again defensively on create/update.
  • Evaluation (internal/eval) reads fields but does not mutate.
  • openwiki/evaluation/flag-evaluation.md
  • openwiki/api/control-plane-api.md
  • openwiki/storage/storage-layer.md