"""
Field-length constants for the Discord audit module.

Asymmetric-headroom principle:

- External-domain text (Discord API field, foreign labels): 2x current
  spec; audit/snapshot rows must accept upstream drift without
  IntegrityError, since the alternative is silent data loss in
  post_delete signal handlers.
- Internal enum (we own the choices): 2x current longest value; one
  or two enum extensions without re-migrating.
- Django-contract fields (User.username, FK targets): exact match
  with Django's source-of-truth; deviation breaks the FK invariant.
"""

from __future__ import annotations

from typing import Final

# Discord username / global_name / member nickname. API spec is 32;
# the 2023 unicode extension showed Discord will widen domain rules
# without notice. Snapshot fields are append-only forensic — never
# reject upstream data.
DISCORD_NAME_MAX_LENGTH: Final = 64

# Discord role name. API spec is 100; 128 covers historical values from
# earlier API versions plus future widening.
DISCORD_ROLE_NAME_MAX_LENGTH: Final = 128

# ContentType-style "app_label.ModelName". AA community plugins ship
# with names like ``aa_some_long_descriptive_module.LongerModelName``;
# 100 is the ecosystem ceiling we'd realistically meet.
MODEL_LABEL_MAX_LENGTH: Final = 100

# String form of a PK referenced from ConfigChangeLog. Covers UUID (36),
# BigInt (19), and Django 5.2+ composite-key serialisations.
OBJECT_PK_MAX_LENGTH: Final = 100

# Internal enum default. Longest current value 'budget_exceeded' (15);
# 32 = 2x current with room for one rename round.
ENUM_MAX_LENGTH: Final = 32

# Reasons-style enum where values are multi-token snake_case
# (``reclassified_user_change`` is 24); 64 keeps headroom for compound
# reasons without migration churn.
REASON_ENUM_MAX_LENGTH: Final = 64

# Mirror of ``django.contrib.auth.User.username.max_length``. We copy
# the value into ConfigChangeLog.actor_username at write time;
# deviating from Django's contract risks truncation that loses audit
# attribution.
DJANGO_USERNAME_MAX_LENGTH: Final = 150
