Enable BLSA per instance on GitLab Dedicated

Problem

GitLab Dedicated can't enable feature flags. The business logic security scan flow (bl_security) is available only on GitLab.com and gated by the bl_security_analyzer experiment flag, so it can't be reached on Dedicated at all. About 13 other places also check the flag directly: scan profiles, project scanner info, the BLSA context builder, model settings (including instance-level model selection in Admin > GitLab Duo > Model selection), the security configuration page and the inventory frontend push.

Change

BLSA adopts the per-instance Dedicated gate from Add available_on to foundational flows, with pe... (!262262 - merged).

  • bl_security sets available_on: %i[gitlab_com dedicated_enabled_instances] (was %i[gitlab_com]). On Dedicated, BLSA is on only when GitLab has enabled it for the instance. The customer also opts in with the instance AI beta setting.
  • The bl_security start request validator uses enabled_for?, and also runs on Dedicated, so its refusals (fork merge requests, nothing to scan) still apply there.
  • Each place that checked bl_security_analyzer directly now calls FoundationalFlow#enabled_for?:
    • GitLab.com and Self-Managed: the same Feature.enabled?(:bl_security_analyzer, <same actor>) as before.
    • Dedicated: GitLab's enablement and the instance beta setting.
  • The frontend still reads gon.features.blSecurityAnalyzer. The controllers push its value from the shared check, so no frontend change is needed.
  • Model selection: instance-level model selection and the self-hosted model settings list show the Business Logic row once the flow is enabled for the instance.
    • No separate testing-terms acceptance is needed: turning on the instance AI beta setting accepts the beta terms.
    • Ai::FeatureSetting maps such features to their foundational flow in FEATURES_UNDER_FOUNDATIONAL_FLOWS.
    • On self-hosted setups, beta (non-GA) model families in that row still need the testing terms (SelfHostedModel.allowed_models_with_family). Vendored models are unaffected.
  • On Self-Managed, runs stay refused (available_on doesn't include it); the screens follow the flag (see Trade-offs).
  • Specs: the shared check has a full spec table, and every changed call site has its own Dedicated case.
  • Scan profiles: the group and project security configuration pages, the project scanner list, the scan profile GraphQL fields and mutations, and FindOrCreateService use BlSecurity::Definition.scan_profiles_enabled_for?. Once BLSA is beta, it also requires the beta setting runs use: the group's "Experiment and beta features" on GitLab.com, the instance AI beta setting elsewhere. While BLSA is experimental, nothing changes.

Impact

Instance Before After
GitLab.com flag per group unchanged
Self-Managed runs refused (not in available_on); the screens follow the flag unchanged
Dedicated always off available only for instances GitLab enabled, once the customer turns on the instance AI beta setting

Depends on

BLSA works on a Dedicated instance only after GitLab adds that instance to the allowlist.

Not in this MR

  • This gate controls product availability only. Licensing, Duo Agent Platform access and billing apply as on any other instance.
  • A Dedicated instance whose Duo Agent Platform runs on a self-hosted model doesn't get BLSA.
  • Refusals use a generic message.
  • FEATURES_UNDER_FLAGS in features_configurable.rb: only the namespace-level model selection finder uses it, and that is a GitLab.com path.
  • Comments that say "while the flag is off": still true on GitLab.com.

Trade-offs and follow-ups

  • On Self-Managed, runs are refused, but the scan profile and security configuration screens still follow the bl_security_analyzer flag, as on master. Checking the deployment there too (blocked_for?) is a one-line change, but about 30 existing examples then need a GitLab.com or Dedicated setup. Follow-up: BLSA screens on Self-Managed should check the d... (#635654).

  • On Dedicated, turning on the instance AI beta setting stands in for the per-user testing-terms acceptance in model selection. The setting's own copy says it accepts the GitLab Testing Agreement. This is a product decision to confirm in review.

  • The specs turn on the beta setting in their "enabled" setups, so they pass both before and after Mark the BLSA flow as beta (!264192 - merged) marks BLSA as beta, whichever MR merges first.

  • Move BL security context to a foundational flow... (!263674 - merged) moves the BLSA context builder's gate into a new file that still checks the flag directly. Whichever MR merges second needs a one-line update there.

How to set up and validate

End to end again on 2026-10-27, on a Dedicated-like GDK: a local merge of this MR at 67b028e09171 on Add available_on to foundational flows, with pe... (!262262 - merged) at 0716ba517316, plus ai-assist main 628356d5e37c with feat(duo-workflow): add per-tool allowed_flows,... (gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!7510 - merged) at cfa804eee65a, enforcement on:

Case Result
Dedicated, beta on, instance on GitLab's allowlist A real BLSA scan finished on a GitLab-hosted runner, SAST report with 1 finding
Same, instance off the allowlist (every customer setting still on) Not offered and API start refused in Rails; the Duo Workflow Service refuses the token ("Flow 'bl_security' is not enabled for this instance")
Allowlisted, beta setting off Not offered, API start refused, no workflow created
Self-Managed Blocked, API start refused, no workflow created
Only the per-instance lookup blocks the flow (instance off the allowlist, or the AI gateway down) A group owner can still read and manage the project consumer; running it is refused

At 66c692774e2b (master a7aa648efe merged in after Add available_on to foundational flows, with pe... (!262262 - merged) landed, with this MR's own diff unchanged): the 14 spec files this MR touches, 538 examples, 0 failures; RuboCop clean on the 28 changed Ruby files; CI green.

End to end on 2026-10-22 (19:01–19:40 UTC) on a GDK set up as Dedicated:

Case Result
Dedicated, beta on, instance on GitLab's allowlist BLSA in scan profiles; security configuration and model selection (checked at 24c6882f3217). A real BLSA scan finished on the GitLab-hosted runner, SAST report with 1 finding.
Same, instance off the allowlist (every customer setting still on) Hidden in security configuration, scan profiles and model selection (security configuration and model selection checked at 24c6882f3217). API start returns 403. The Duo Workflow Service refuses a token: Flow 'bl_security' is not enabled for this instance.
Self-Managed (gitlab_dedicated_instance off, beta on) Hidden in security configuration, scan profiles and model selection (security configuration and model selection checked at 24c6882f3217). API start returns 403. A merge request pipeline starts no BLSA run.
GitLab.com mode Security configuration (checked at 24c6882f3217) and scan profiles follow the bl_security_analyzer flag: on → shown, off → hidden.
Beta maturity patched in locally, GitLab.com mode, group beta setting off scan profile list hidden; create, update and FindOrCreateService refused; both pages push blSecurityAnalyzer=false. With the setting on, all allowed.
Specs: the 22 spec files the merge changes against master 1810 examples. A first pass had 2 failures, from the local beta patch above being on disk; the 3 affected files re-ran with 0 failures.
Specs: the 13 spec files this MR touches, at ad0b77c62c87 500 examples, 0 failures
At 61e4a3e71f51 (project page and scanner list switched to the same check), on a local merge with master b813e144abd8: allowlisted Dedicated / off the allowlist project scanner list shows / hides BLSA; attaching a Business logic profile works / is refused; API start 403 off the allowlist
Specs at 67b028e09171: the 14 spec files this MR touches, with BLSA experimental, and with the maturity flipped to beta locally 535 examples, 0 failures in both runs; RuboCop: no offenses
Red check of 6 of the call-site Dedicated specs (group security configuration page, project scan profiles, scan profile create and update, ScanProfileResolver, FindOrCreateService), each call site reverted to the flag check its "enabled" example fails on its assertion
Red check of the beta-setting specs: call sites reverted each "setting off" example fails on its assertion
RuboCop on the changed Ruby files no offenses

Earlier on 2026-10-21, at ae1804906074 (same gate, before the call-site rework), this MR also passed these. They were not re-run:

Check Result
Beta off hidden; no AI gateway call
AI gateway down after a good answer BLSA stays available; a running scan finished
AI gateway down, no previous answer hidden (fails closed)

Evidence

At the merge `71cf8177` (this MR at `ad0b77c6`)
# Allowlisted Dedicated instance
SCAN_PROFILES group_available_business_logic=True project_attached=['BUSINESS_LOGIC']
PIPELINE id=609 source=duo_workflow status=success
WORKFLOW id=18 def=bl_security/experimental status=finished
JOB id=450 name=workload status=success runner_id=33 sast_report_vulns=1

# Not on the allowlist
HTTP=403
GENTOKEN status=error message=7:Flow 'bl_security' is not enabled for this instance. PERMISSION_DENIED

# Self-Managed
deployment=self_managed available_for=false
HTTP=403
no BLSA workflow after the merge request pipeline

# GitLab.com mode, Ultimate group
SCAN_PROFILES flag=on group_available_business_logic=true / flag=off false

# Beta maturity patched in locally, GitLab.com mode, group beta setting off
list=false create="don't have permission" update="don't have permission" find_or_create=error pages blSecurityAnalyzer=false

# Specs
13 files at ad0b77c62c87: 500 examples, 0 failures
At the merge `ee9c73ba4a85` (this MR at `24c6882f`; the security configuration and model selection files are unchanged since)
# Allowlisted Dedicated instance
STATE dedicated=true beta=true deployment=dedicated available_for=true presenter_business_logic=true project_config=http200/bl_mentions=6
MODEL_SELECTION rows=15 bl_security_present=True

# Not on the allowlist
STATE blocked_for=true available_for=false presenter_business_logic=false project_config=http200/bl_mentions=0
MODEL_SELECTION rows=14 bl_security_present=False

# Self-Managed
STATE deployment=self_managed presenter_business_logic=false
MODEL_SELECTION rows=14 bl_security_present=False

# GitLab.com mode
presenter_business_logic flag=on true / flag=off false

# Specs
24 files: 1844 examples, 0 failures, 1 pending

Setup

  1. Start a GDK set up as GitLab Dedicated, not GitLab.com, with Ultimate and Duo:
    ApplicationSetting.current.update!(gitlab_dedicated_instance: true)
  2. Run the AI gateway and the Duo Workflow Service from ai-assist main (it includes feat(dws): enable gated flows per instance for ... (gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!7508 - merged)). Set these on both services:
    DUO_WORKFLOW_AUTH__ENFORCE_FLOW_ENABLEMENT=true
    DUO_WORKFLOW_AUTH__ENABLED_FLOW_INSTANCE_UIDS='{"bl_security": ["<instance uid>"]}'
    In GDK with self-signed tokens, the instance uid is ApplicationSetting.current.uuid.
  3. Turn on the instance AI beta setting: Admin > GitLab Duo > Configuration > Feature preview.
  4. Enable BLSA for a group and apply a Business logic scan profile to a project.
  5. Register a GitLab-hosted instance runner, the way Dedicated provisions them. Then run a merge request pipeline on it.
  6. For model selection: in Admin > GitLab Duo > Model selection, pick a model for Business Logic Security Scan and run the pipeline again.

Context

Stacked on Add available_on to foundational flows, with pe... (!262262 - merged). Related to https://gitlab.com/gitlab-org/gitlab/-/work_items/633855+

Edited by Meir Benayoun

Merge request reports

Loading
Loading