feat(qg0): configurable QG-0 title limit via ORCH_QG0_TITLE_MAX (default 200)
Replace the hardcoded `len(name) > 80` cap in the QG-0 entry validation (_qg0_errors) with a configurable Settings.qg0_title_max (env ORCH_QG0_TITLE_MAX, default 200). The 80-char cap was a hygiene limit, not structural, so valid 81-200 char titles were rejected without a business reason. The limit is read dynamically per call and the error text interpolates the active value. Graceful degradation (AC-3, self-hosting safety): an empty/non-numeric env value no longer crashes the process on startup. A field_validator(mode="before") intercepts the raw env before int-parsing and falls back to 200 (never raises), suppressing pydantic ValidationError. Additive and backward-compatible (default 200 > old 80). Invariants unchanged: STAGE_TRANSITIONS, QG_CHECKS registry, DB schema, slug [:30], lower limits, soft-QG-0 warning path, API. Refs: ORCH-069 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from pydantic import field_validator
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
|
||||
@@ -407,6 +408,24 @@ class Settings(BaseSettings):
|
||||
# Неизвестное/пустое значение трактуется как edit (см. notifications).
|
||||
tracker_mode: str = "edit"
|
||||
|
||||
# ORCH-069: QG-0 upper title-length limit (entry gate _qg0_errors). The 80-char
|
||||
# cap was a hygiene limit, not structural (slug is cut to [:30] independently,
|
||||
# DB title TEXT is unbounded). Configurable via env ORCH_QG0_TITLE_MAX; default
|
||||
# 200 (was hardcoded 80). Invalid/empty value -> default (graceful, no crash).
|
||||
qg0_title_max: int = 200
|
||||
|
||||
@field_validator("qg0_title_max", mode="before")
|
||||
@classmethod
|
||||
def _qg0_title_max_default(cls, v):
|
||||
# Graceful (ORCH-069 AC-3): empty / non-numeric env -> default 200, the
|
||||
# process must not crash on startup. Never raises (self-hosting safety).
|
||||
try:
|
||||
if v is None or (isinstance(v, str) and v.strip() == ""):
|
||||
return 200
|
||||
return int(v)
|
||||
except (TypeError, ValueError):
|
||||
return 200
|
||||
|
||||
class Config:
|
||||
env_prefix = "ORCH_"
|
||||
env_file = ".env"
|
||||
|
||||
Reference in New Issue
Block a user