dify/api/core/moderation
GareArc adadf1ec5f
refactor(telemetry): migrate to type-safe enum-based event routing with centralized enterprise filtering
Changes:
- Change TelemetryEvent.name from str to TraceTaskName enum for type safety
- Remove hardcoded trace_task_name_map from facade (no mapping needed)
- Add centralized enterprise-only filter in TelemetryFacade.emit()
- Rename is_telemetry_enabled() to is_enterprise_telemetry_enabled()
- Update all 11 call sites to pass TraceTaskName enum values
- Remove redundant enterprise guard from draft_trace.py
- Add unit tests for TelemetryFacade.emit() routing (6 tests)
- Add unit tests for TraceQueueManager telemetry guard (5 tests)
- Fix test fixture scoping issue for full test suite compatibility
- Fix tenant_id handling in agent tool callback handler

Benefits:
- 100% type-safe: basedpyright catches errors at compile time
- No string literals: eliminates entire class of typo bugs
- Single point of control: centralized filtering in facade
- All guards removed except facade
- Zero regressions: 4887 tests passing

Verification:
- make lint: PASS
- make type-check: PASS (0 errors, 0 warnings)
- pytest: 4887 passed, 8 skipped
2026-02-05 20:15:12 -08:00
..
api use model_validate (#26182) 2025-10-10 17:30:13 +09:00
keywords remove bare list, dict, Sequence, None, Any (#25058) 2025-09-06 03:32:23 +08:00
openai_moderation fix(moderation): change OpenAI moderation model to omni-moderation-la… (#28119) 2025-11-13 15:21:44 +08:00
__init__.py feat: add api-based extension & external data tool & moderation backend (#1403) 2023-11-06 19:36:16 +08:00
base.py chore: add ast-grep rule to convert Optional[T] to T | None (#25560) 2025-09-15 13:06:33 +08:00
factory.py remove bare list, dict, Sequence, None, Any (#25058) 2025-09-06 03:32:23 +08:00
input_moderation.py refactor(telemetry): migrate to type-safe enum-based event routing with centralized enterprise filtering 2026-02-05 20:15:12 -08:00
output_moderation.py chore: add ast-grep rule to convert Optional[T] to T | None (#25560) 2025-09-15 13:06:33 +08:00