Gate Mythos selection on namespace eligibility

Problem

BLSA is moving from a closed beta to an open beta for all entitled customers (Meir-decided 2026-11-04) — bl_security_analyzer will no longer restrict who gets BLSA. Mythos (Anthropic's restricted model) is the one exception that stays gated: Anthropic's terms require the customer to be on their approved list and operating from an approved country, and nothing in code checks that today. Once bl_security_analyzer stops being restrictive, it provides zero protection for Mythos specifically — this MR's flag becomes the only thing standing between any entitled customer and Mythos.

Impact

Area Before After
Model-selection catalog (Owner picks a model) Mythos shown to any BLSA-enabled namespace Mythos hidden unless mythos_restricted_namespace_model is enabled for that namespace's top-level group
Save path (namespace sets its model) No independent check beyond SaaS-availability Re-validates eligibility; rejects selecting Mythos for an ineligible namespace
Scan-resolution time (workflow start, resume, and the /ws connection-config refresh) Whatever was last saved is used Re-checks eligibility at the single shared ModelMetadata class all three paths call; falls back to the feature's GitLab-default model if the namespace has since lost eligibility
ai_model_release (separate, user-scoped "Day Zero" launch flag) Unaffected Unaffected — this MR doesn't touch it

Context

  • Proposal + design: gitlab-org/gitlab#636092 (confidential)
  • Epic: &22436 (BL Security Analyzer)
  • Raised by Chris Widstrom, confirmed from source 2026-10-21 — see #636092 for the full investigation.
  • Country/contracting-entity check stays procedural, not code-enforced by this MR: whoever enables the new flag is expected to have already verified the customer against Anthropic's published supported-countries list. This MR only adds the per-namespace allowlist primitive.
  • How this interacts with bl_security_analyzer and ai_model_release: once BLSA opens to all entitled customers, bl_security_analyzer is no longer a meaningful restriction — every entitled namespace will have it on. mythos_restricted_namespace_model is therefore the ONLY per-customer gate that matters for Mythos specifically. ai_model_release remains a separate, orthogonal axis: a user-scoped flag GitLab uses generically for staging any new model's launch (ai-assist#2522), nothing customer- or compliance-aware about it. It's expected to eventually open up broadly as Mythos graduates from internal testing; at that point this MR's flag is still the only enforcement of the compliance boundary.
  • Explicit scope decision, tested: self-managed/instance-level feature settings (no namespace) are NOT gated by this flag — namespace_eligible? returns true when there's no namespace to check. This matches how Mythos is separately restricted to GitLab.com-signed instance tokens at the DWS layer, so self-managed can't reach it regardless; this MR doesn't duplicate that check.
  • Follow-ups filed as separate, non-blocking items (not needed for this MR to be correct):
    • The model-ref string (claude_mythos_5_1) has no automated drift guard if the model catalog ever renames it — would silently stop matching.
    • The actor-scoping hazard ("flag enabled for a different group ⇒ still ineligible") is tested at the shared predicate but not repeated at each of the three call sites individually — belt-and-suspenders, not required (the predicate is the single source of truth and is itself correctly tested).
  • Open-beta scenario re-verified in sandbox (2026-11-04), rails console, real DB: with bl_security_analyzer enabled GLOBALLY (simulating the post-open-beta state) and mythos_restricted_namespace_model explicitly disabled for a real test group, RestrictedNamespaceModels.namespace_eligible?(group, 'claude_mythos_5_1') returned false — confirming bl_security_analyzer going global does not leak into Mythos eligibility, since the predicate never references that flag. The save-path (UpdateService) is covered by its own spec.
  • GitLabDuo review caught a real gap, now fixed: the scan-resolution-time fallback I'd described above as "covered" was wrong for one path. DuoAgentPlatformModelMetadataService (which the /ws connection-config refresh calls) had the recheck, but StartWorkflowService and ResumeWorkflowService — BLSA's actual CI-run start path — called Gitlab::Llm::AiGateway::AgentPlatform::ModelMetadata directly, bypassing it entirely. A namespace that saved Mythos while eligible and later lost the flag could still get Mythos at scan start. Fixed by moving the recheck into ModelMetadata#execute itself — the one class all three paths call — so there's a single choke point instead of three places that could drift out of sync. Red-checked directly: ee/spec/lib/gitlab/llm/ai_gateway/agent_platform/model_metadata_spec.rb's new "namespace-restricted (e.g. Mythos)" context fails on the pre-fix code (expected: nil, got: "claude_mythos_5_1") and passes after.
  • Rebased on current master (2026-11-04) to resolve a real conflict in update_service.rb against a same-day unrelated optimization (skip_unchanged_selection?) — merged so the new eligibility check runs after that fast path, with no duplicate catalog-fetch/update_params construction.
  • Flag type corrected (GitLabDuo's second finding): moved from config/feature_flags/experiment/ to config/feature_flags/ops/, type: experiment → type: ops. This flag is a permanent per-customer compliance boundary, not a short-lived A/B experiment — the experiment type would have made it eligible for the normal flag-cleanup process, which would silently remove the only Mythos gate. default_enabled: false unchanged; the per-group ChatOps-enable plan is unaffected.
  • Validated in sandbox post-rebase: rubocop 0 offenses (4 touched Ruby files), rspec 94 examples / 0 failures across all 4 touched/new spec files (Gitaly test-env needed a clean rebuild after an unrelated network blip; unrelated to this change).
  • Validated after the GitLabDuo-fix round: rubocop 0 offenses on the 2 files touched this round, full model_metadata_spec.rb green (35 examples / 0 failures, including the 2 new red-check cases).
  • Workflow-start path verified live in sandbox (2026-11-05), rails runner, real DB records: called StartWorkflowService#agent_platform_model_metadata_json directly — the exact method the real BLSA start path uses — against a persisted Group, Project, and Ai::ModelSelection::NamespaceFeatureSetting with claude_mythos_5_1 saved as the offered model. With mythos_restricted_namespace_model off for the group: identifier => nil (default model served). After Feature.enable(:mythos_restricted_namespace_model, group): identifier => "claude_mythos_5_1". This exercises the actual start-path call site GitLabDuo flagged, not just the shared class's unit spec.
  • GitLabDuo's 2nd re-review caught a real duplicate (now removed): DuoAgentPlatformModelMetadataService still had its own older copy of the same eligibility recheck that ModelMetadata#execute now handles — harmless while both agreed, but a future edit to only one could silently diverge with no test catching it. Removed the redundant method and its call site (16 lines), leaving ModelMetadata#execute as the single choke point. Service spec (50 examples) passed unchanged, as predicted; model_metadata_spec.rb (35 examples) also unaffected. Rubocop 0 offenses.
  • Re-verified live in sandbox (2026-11-06) on the new head, rails runner, real DB records: re-ran the exact same StartWorkflowService#agent_platform_model_metadata_json check from the entry above against head 9d5533c20562. Same result: flag off → identifier => nil; flag on → identifier => "claude_mythos_5_1". Confirms the duplicate-check removal didn't change the start path's behavior.
Edited by Meir Benayoun

Merge request reports

Loading
Loading