Skip to main content

Feature toggles

white-label deploy rarely ขาย ทุก ๆ capability feature toggles let operator turn main product features on/off — ที่ deploy time ผ่าน config หรือ later ที่ runtime no redeploy ทั้งหมด features default enabled; deployment เพียง lists ones มันเปลี่ยน

Model​

  • Core.Features.FeatureFlag — enum ของ gateable features: Authoring Backtesting Execution CopyTrading Ai PortfolioAgent Alerts PropGuard PropFirm Accounts OpenApi Mcp Compliance core admin surfaces (dashboard users nodes auth) ไม่เคย gateable ไม่มี here
  • Core.Options.FeaturesOptions — config baseline bound จาก App:Features ทุก ๆ property defaults true
  • Core.Features.IFeatureGate — resolves effective state: config baseline overlaid ด้วย optional owner-set runtime override implemented โดย Infrastructure.Features.FeatureGate caches overrides briefly (FeatureSettings.OverrideCacheTtl) invalidates บน change

runtime overrides stored เป็น AppSetting rows keyed feature.<FeatureFlag> (value true/false) ไม่มี row = "ใช้ config baseline"

สองวิธี เพื่อ disable feature​

1. Deployment configuration (baseline)​

ตั้ง flag false ภายใต้ App:Features example appsettings.json:

{
"App": {
"Features": {
"CopyTrading": false,
"PropGuard": false
}
}
}

หรือ ผ่าน env vars (double underscore):

App__Features__CopyTrading=false

baseline gates startup registration ของ background workers (Nodes.AddNodes) และ MCP tools (Mcp server) ดังนั้น feature disabled ใน config ไม่เคย start hosted services ของมัน หรือ expose MCP tools ของมัน

2. Runtime override (owner)​

owner สามารถ flip any feature live จาก Settings → Features (/settings/features) หรือ API:

GET /api/features -> [{ "flag": "CopyTrading", "enabled": true }, ...] (owner)
PUT /api/features/{flag} body { "enabled": false } -> ตั้ง override (owner)
PUT /api/features/{flag} body { "enabled": null } -> clear override (revert) (owner)

runtime changes take effect immediately สำหรับ request-time gates (navigation API) background workers และ MCP tools gated ที่ startup pick ขึ้น runtime เปลี่ยน บน next process restart

สิ่งที่ gate enforces​

LayerMechanismTiming
HTTP APIRouteGroupBuilder.RequireFeature(flag) endpoint filter → 404 เมื่อ disabledruntime
navigationNavMenu hides links ผ่าน IFeatureGate.IsEnabledruntime
background workersconditional AddHostedService ใน Nodes.AddNodesstartup (config)
MCP toolsconditional WithTools<> ใน MCP serverstartup (config)

feature reached โดย deep link ขณะ disabled renders empty page — API ของมัน returns 404; nav ไม่มา longer surfaces มัน

flag → surface map​

flagAPI groupsnavworkers / MCP
Authoring/api/cbots /api/paramsets /api/buildercbots group → cbots (param sets per-cbot dialog)MCP CBotTools
Backtesting(shares /api/instances)cbots group → backtest—
Execution/api/instancescbots group → runMCP InstanceTools
CopyTrading/api/copycopy tradingCopyEngineSupervisor OpenApiTokenRefreshService MCP CopyTools
Ai/api/aiAI group → AI; settings → AI (key)AiRiskGuard MCP AiTools
PortfolioAgent/api/agentAI group → portfolio agentPortfolioAgentService
Alerts/api/alertsAI group → alertsAlertEvaluator
PropGuard/api/propprop group → prop guardPropGuardService
PropFirm/api/prop-firmprop group → challenges—
Accounts/api/ctidstrading accounts—
OpenApi/api/openapisettings → open API—
Mcp/api/mcp-keysAI group → MCP keys—
Compliance/api/compliancesettings → legal & privacy—

Tests​

  • Unit — UnitTests/Features/FeaturesOptionsTests.cs: baseline defaults per-flag mapping
  • Integration — IntegrationTests/FeatureGateTests.cs: config baseline runtime override beats config และ persists เป็น AppSetting clearing reverts เป็น baseline (real postgres)
  • E2E — E2ETests/FeatureToggleTests.cs: disabling CopyTrading ที่ runtime hides nav link ของมัน และ 404s /api/copy re-enabling restores ทั้งสอง