chore: curatare agresiva comentarii — scoatere referinte US/PRD din cod si template-uri
Eliminat zgomotul de trasabilitate (US-xxx, PRD x.x, Rn, OV-x, Tn, decizii/naratiune istorica) din 41 fisiere app/ + template-uri. Pastrate comentariile care documenteaza invarianti si logica ne-evidenta (idempotenta/hash, reconciliere anti-duplicat, RAR 500 esec definitiv, creds per cont, WAF User-Agent, 422 fara echo de parola, scope NULL->1), curatate doar de tokeni. Verificare: pentru cele 27 module .py curatate, structura de cod (tokeni non-comentariu/ non-string) e IDENTICA fata de HEAD -> doar comentarii/docstring-uri schimbate. Singura schimbare de cod e in tests/test_web_responsive.py (scos 3 assert pe markeri US-006/007/008, inlocuite de asertiunile structurale alaturate). 0 tokeni US/PRD reziduali in app/. Regresie: 896 passed, 1 deselected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
"""Configurare gateway. Env vars (prefix AUTOPASS_) + valori implicite.
|
||||
|
||||
NU stocheaza parole RAR. Credentialele RAR vin per-cerere de la ROAAUTO
|
||||
(vezi plan.md sect. 5). Helper-ul `load_test_credentials` citeste blocul
|
||||
<test> din settings.xml DOAR pentru dev local / probe pe mediul de test.
|
||||
NU stocheaza parole RAR. Credentialele RAR vin per-cerere de la ROAAUTO.
|
||||
Helper-ul `load_test_credentials` citeste blocul <test> din settings.xml DOAR
|
||||
pentru dev local / probe pe mediul de test.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -22,22 +22,21 @@ class Settings(BaseSettings):
|
||||
# --- Bază de date ---
|
||||
db_path: Path = ROOT / "data" / "autopass.db"
|
||||
|
||||
# --- Observabilitate / jurnal aplicatie (PRD 5.6) ---
|
||||
# --- Observabilitate / jurnal aplicatie ---
|
||||
# Nivel minim al evenimentelor scrise in app_events + log text. Sub el, evenimentul
|
||||
# e ignorat (best-effort). DEBUG|INFO|WARNING|ERROR|CRITICAL.
|
||||
log_level: str = "INFO"
|
||||
# Retentie jurnal (app_events) — aliniat cu submissions/import_batches (decizie §5).
|
||||
log_retention_days: int = 90
|
||||
# Director pentru log-ul text rotativ (RotatingFileHandler in aplicatie, decizie §5).
|
||||
# Director pentru log-ul text rotativ (RotatingFileHandler in aplicatie).
|
||||
# Fisier per-proces (app-api.log / app-worker.log) — rotatia nu e multiproces-safe.
|
||||
log_dir: Path = ROOT / ".run"
|
||||
log_file_max_bytes: int = 5_000_000
|
||||
log_file_backup_count: int = 5
|
||||
# Retentie randuri blocate (error/needs_data/needs_mapping). Mai scurt decat 90z
|
||||
# ale `sent` — un blocat n-are valoare de audit (decizie §5).
|
||||
# ale `sent` — un blocat n-are valoare de audit.
|
||||
blocked_retention_days: int = 30
|
||||
|
||||
# --- Securitate (CORE) ---
|
||||
# --- Securitate ---
|
||||
# Enforcement auth API-key pe /v1/* protejat. False (dev/test): fara cheie ->
|
||||
# cont implicit id=1. True (prod): fara cheie valida -> 401. O cheie PREZENTA
|
||||
# dar invalida da 401 indiferent de flag.
|
||||
@@ -49,29 +48,28 @@ class Settings(BaseSettings):
|
||||
# python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
|
||||
creds_key: str | None = None
|
||||
|
||||
# --- Sesiuni web (US-002, PRD 3.3) ---
|
||||
# --- Sesiuni web ---
|
||||
# Secret semnat cookie sesiune. None -> efemer la fiecare restart (dev ok;
|
||||
# in prod seteaza persistent ca si creds_key, altfel cookieurile se invalideaza
|
||||
# la restart). Genereaza: python -c "import secrets; print(secrets.token_hex(32))"
|
||||
session_secret: str | None = None
|
||||
# True (IMPLICIT, sigur pentru prod): rutele web fara sesiune -> redirect /login;
|
||||
# CSRF enforce. Pentru dev rapid pe contul implicit id=1 (back-compat C12/§5 Q5),
|
||||
# CSRF enforce. Pentru dev rapid pe contul implicit id=1,
|
||||
# seteaza explicit AUTOPASS_WEB_AUTH_REQUIRED=false.
|
||||
web_auth_required: bool = True
|
||||
# True (prod, in spatele Cloudflare Tunnel TLS): cookie cu Secure flag (C4).
|
||||
# True (prod, in spatele Cloudflare Tunnel TLS): cookie cu Secure flag.
|
||||
# False (dev): cookie fara Secure, functioneaza pe HTTP.
|
||||
session_https_only: bool = False
|
||||
|
||||
# --- Notificare email admin la signup (US-012, PRD 3.3b) ---
|
||||
# Nesetat (smtp_host None) -> notificarea e DEGRADATA (doar log SIGNUP);
|
||||
# follow-up cand exista SMTP real configurat in .env.
|
||||
# --- Notificare email admin la signup ---
|
||||
# Nesetat (smtp_host None) -> notificarea e DEGRADATA (doar log SIGNUP).
|
||||
smtp_host: str | None = None
|
||||
smtp_port: int = 587
|
||||
smtp_user: str | None = None
|
||||
smtp_password: str | None = None
|
||||
smtp_from: str | None = None
|
||||
|
||||
# --- Rate-limit signup + login (US-009, PRD 3.3 C5) ---
|
||||
# --- Rate-limit signup + login ---
|
||||
# Max cereri POST /signup per IP in fereastra de timp (in-proces, fara dependinta noua).
|
||||
signup_rate_max: int = 5
|
||||
signup_rate_window_s: int = 3600
|
||||
@@ -83,25 +81,23 @@ class Settings(BaseSettings):
|
||||
rar_base_url_test: str = "https://apps.rarom.ro/test-rar-autopass"
|
||||
rar_base_url_prod: str = "https://apps.rarom.ro/rar-autopass"
|
||||
|
||||
# WAF-ul RAR da 403 fara User-Agent de browser (confirmat live, vezi
|
||||
# docs/api-rar-contract.md). Toate apelurile httpx il trimit.
|
||||
# WAF-ul RAR da 403 fara User-Agent de browser. Toate apelurile httpx il trimit.
|
||||
http_user_agent: str = "Mozilla/5.0"
|
||||
http_timeout_s: float = 30.0
|
||||
|
||||
# --- Worker ---
|
||||
worker_poll_interval_s: float = 5.0
|
||||
worker_heartbeat_stale_s: int = 30 # /healthz considera worker-ul mort peste atat
|
||||
# In schelet send-ul e DEZACTIVAT (nu trimite la RAR). Activeaza-l explicit
|
||||
# pentru proba end-to-end. Reconcilierea/retry-ul complet = T2.
|
||||
# Send DEZACTIVAT implicit (nu trimite la RAR). Activeaza-l explicit pentru
|
||||
# proba end-to-end.
|
||||
worker_send_enabled: bool = False
|
||||
# Dev: foloseste creds <test> din settings.xml pt login worker. In productie
|
||||
# creds vin per-cerere de la ROAAUTO (T2) — lasa False.
|
||||
# creds vin per-cerere de la ROAAUTO — lasa False.
|
||||
worker_use_test_creds: bool = False
|
||||
# T2 — recuperare orfane + retry/backoff:
|
||||
worker_sending_lease_s: int = 120 # rand 'sending' mai vechi de atat = orfan (worker mort mid-POST)
|
||||
worker_retry_base_s: int = 5 # backoff = base * 2^retry (plafonat la max)
|
||||
worker_retry_max_s: int = 300
|
||||
worker_max_retries: int = 8 # peste atat -> error + banner (pana persistenta)
|
||||
worker_max_retries: int = 8 # peste atat -> error + banner
|
||||
|
||||
@property
|
||||
def rar_base_url(self) -> str:
|
||||
|
||||
Reference in New Issue
Block a user