Skip to content

[Refactor/Chore] Prevent new deployment edition checks outside feature policies #46696

Open

Description

@QuantumGhost

AI disclosure: This issue was drafted with Codex using gpt-6.2-sol. I have reviewed the report, and I am responsible for the content.

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for refactors or chores; if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Description

Add a deployment edition guard for production Python and stubs under api/.
Reject new DeploymentEdition imports, qualified enum references, and direct
edition decisions such as Cloud or Enterprise comparisons and match cases.
Tests under api/tests can still set up deployment scenarios, and existing
production usages retain their Git baseline.

The feature policy modules allowed to resolve edition-dependent capabilities are:

  • api/services/feature_service.py
  • api/services/system_feature_service.py
  • api/services/knowledge_fs/feature_service.py

Diagnostics and api/AGENTS.md tell contributors where to reuse or add a named
capability. Use FeatureService for product capabilities and workspace
entitlements, or SystemFeatureService for deployment-wide system policies.

Motivation

Direct edition checks spread Cloud and Enterprise policy across business code.
Named capabilities give callers one place to find which policy enables a feature.
Checking new decisions separately from imports also catches new branches in
modules that already import the enum.

Additional Context

Use ast-grep and Python AST filtering through make lint and Python Style CI.
Compare CI changes against the target revision. Preserve existing occurrences
across formatting, import alias changes, and ordinary file renames. Treat
decisions moved from an exempt module into guarded code as new occurrences.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions