🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(ee)!: add self-hosted government plan for lf_gov_ license keys (#19316)
Steffen Reuther165b621fdf8f
diff --git a/packages/shared/src/features/entitlements/plans.ts b/packages/shared/src/features/entitlements/plans.tsindex bba22f0a9e..760fb1a978 100644--- a/packages/shared/src/features/entitlements/plans.ts+++ b/packages/shared/src/features/entitlements/plans.ts@@ -16,6 +16,7 @@ export const planLabels = {"cloud:enterprise": "Enterprise","self-hosted:pro": "Pro (self-hosted)","self-hosted:enterprise": "Enterprise (self-hosted)",+ "self-hosted:gov": "Government (self-hosted)",} as const;export type Plan = keyof typeof planLabels;diff --git a/packages/shared/src/server/ee/fips/assertFipsMode.test.ts b/packages/shared/src/server/ee/fips/assertFipsMode.test.tsindex 47a4399412..6b306a76b9 100644--- a/packages/shared/src/server/ee/fips/assertFipsMode.test.ts+++ b/packages/shared/src/server/ee/fips/assertFipsMode.test.ts@@ -12,7 +12,7 @@ vi.mock("crypto", async (importOriginal) => ({const createTestEnv = (overrides: Partial<SharedEnv> = {}): SharedEnv =>({LANGFUSE_REQUIRE_FIPS: "true",- LANGFUSE_EE_LICENSE_KEY: "langfuse_ee_test",+ LANGFUSE_EE_LICENSE_KEY: "lf_gov_test",NEXT_PUBLIC_LANGFUSE_CLOUD_REGION: undefined,...overrides,}) as SharedEnv;@@ -36,7 +36,7 @@ describe("assertFipsMode", () => {).not.toThrow();});- it("passes with an enterprise license and an active FIPS provider", () => {+ it("passes with a government license and an active FIPS provider", () => {expect(() => assertFipsMode(createTestEnv())).not.toThrow();});@@ -54,10 +54,11 @@ describe("assertFipsMode", () => {it.each([["no license key", undefined],["a pro license key", "langfuse_pro_test"],+ ["an enterprise license key", "langfuse_ee_test"],])("refuses to start with %s, even on a FIPS host", (_label, licenseKey) => {expect(() =>assertFipsMode(createTestEnv({ LANGFUSE_EE_LICENSE_KEY: licenseKey })),- ).toThrow(/enterprise license/);+ ).toThrow(/government license/);});it("refuses to start with a license when the FIPS provider is inactive", () => {diff --git a/packages/shared/src/server/ee/fips/assertFipsMode.ts b/packages/shared/src/server/ee/fips/assertFipsMode.tsindex 1bb4aec5b3..4c0f4ef889 100644--- a/packages/shared/src/server/ee/fips/assertFipsMode.ts+++ b/packages/shared/src/server/ee/fips/assertFipsMode.ts@@ -1,13 +1,14 @@/* eslint-disable @typescript-eslint/no-use-before-define */import { getFips } from "crypto";import { env, type SharedEnv } from "../../../env";-import { isEnterpriseLicenseAvailable } from "../licenseCheck";+import { isGovernmentLicenseAvailable } from "../licenseCheck";/**- * Enforce FIPS mode (LANGFUSE_REQUIRE_FIPS=true), an enterprise feature.+ * Enforce FIPS mode (LANGFUSE_REQUIRE_FIPS=true), a government feature.*- * Fails closed: when FIPS mode is requested, startup must stop unless an- * enterprise license is available and Node's OpenSSL FIPS provider is active.+ * Fails closed: when FIPS mode is requested, startup must stop unless the+ * deployment is Langfuse Cloud or holds a government license (an enterprise+ * license is not enough), and Node's OpenSSL FIPS provider is active.* The provider is only active when the host kernel runs in FIPS mode, so a* container cannot switch it on by itself.*@@ -21,9 +22,12 @@ export function assertFipsMode(envOverride?: SharedEnv): void {return;}- if (!isEnterpriseLicenseAvailable(e)) {+ if (+ e.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION === undefined &&+ !isGovernmentLicenseAvailable(e)+ ) {throw new Error(- "LANGFUSE_REQUIRE_FIPS=true requires a Langfuse enterprise license (LANGFUSE_EE_LICENSE_KEY).",+ "LANGFUSE_REQUIRE_FIPS=true requires a Langfuse government license (LANGFUSE_EE_LICENSE_KEY starting with lf_gov_).",);}diff --git a/packages/shared/src/server/ee/ingestionMasking/applyIngestionMasking.ts b/packages/shared/src/server/ee/ingestionMasking/applyIngestionMasking.tsindex eade80d532..1dde762b83 100644--- a/packages/shared/src/server/ee/ingestionMasking/applyIngestionMasking.ts+++ b/packages/shared/src/server/ee/ingestionMasking/applyIngestionMasking.ts@@ -49,7 +49,7 @@ export function isIngestionMaskingEnabled(envOverride?: SharedEnv): boolean {if (!isEnterpriseLicenseAvailable(envOverride)) {logger.warn(- "Ingestion masking callback URL is configured but enterprise license is not available. Masking will be disabled. Ingestion masking requires Langfuse Cloud or a self-hosted enterprise license (langfuse_ee_*).",+ "Ingestion masking callback URL is configured but enterprise license is not available. Masking will be disabled. Ingestion masking requires Langfuse Cloud or a self-hosted enterprise or government license (langfuse_ee_* or lf_gov_*).",);return false;}diff --git a/packages/shared/src/server/ee/licenseCheck/index.ts b/packages/shared/src/server/ee/licenseCheck/index.tsindex e28324846e..051bbfa8a0 100644--- a/packages/shared/src/server/ee/licenseCheck/index.ts+++ b/packages/shared/src/server/ee/licenseCheck/index.ts@@ -1,10 +1,23 @@import { env, type SharedEnv } from "../../../env";+/**+ * Check if a government license is available. Returns true only for+ * self-hosted deployments with a government license key (starts with+ * "lf_gov_"); Langfuse Cloud does not count.+ */+export function isGovernmentLicenseAvailable(envOverride?: SharedEnv): boolean {+ const e = envOverride ?? env;++ return e.LANGFUSE_EE_LICENSE_KEY?.startsWith("lf_gov_") ?? false;+}+/*** Check if enterprise EE license is available.* Returns true for:* - Langfuse Cloud (any region)* - Self-hosted with enterprise license key (starts with "langfuse_ee_")+ * - Self-hosted with government license key (starts with "lf_gov_"), which+ * includes every enterprise feature** Note: Pro tier (langfuse_pro_*) does NOT count as enterprise.*/@@ -16,11 +29,11 @@ export function isEnterpriseLicenseAvailable(envOverride?: SharedEnv): boolean {return true;}- // Self-hosted: must have enterprise license key (not pro)+ // Self-hosted: must have enterprise or government license key (not pro)const licenseKey = e.LANGFUSE_EE_LICENSE_KEY;if (licenseKey && licenseKey.startsWith("langfuse_ee_")) {return true;}- return false;+ return isGovernmentLicenseAvailable(e);}diff --git a/web/src/__tests__/server/audit-log-license-gate.servertest.ts b/web/src/__tests__/server/audit-log-license-gate.servertest.tsindex 579bc76d31..8204a601a9 100644--- a/web/src/__tests__/server/audit-log-license-gate.servertest.ts+++ b/web/src/__tests__/server/audit-log-license-gate.servertest.ts@@ -114,11 +114,20 @@ describe("audit log license gate", () => {};describe("self-hosted", () => {- it("persists records with an enterprise license key, without staging them", async () => {- mocks.licenseKey = "langfuse_ee_test";-- expect(await auditAllActorShapes()).toEqual({ persisted: 3, staged: 0 });- });+ it.each([+ ["an enterprise", "langfuse_ee_test"],+ ["a government", "lf_gov_test"],+ ])(+ "persists records with %s license key, without staging them",+ async (_label, licenseKey) => {+ mocks.licenseKey = licenseKey;++ expect(await auditAllActorShapes()).toEqual({+ persisted: 3,+ staged: 0,+ });+ },+ );it("persists no records without a license key", async () => {expect(await auditAllActorShapes()).toEqual({ persisted: 0, staged: 0 });diff --git a/web/src/__tests__/supportCaseSeverity.clienttest.ts b/web/src/__tests__/supportCaseSeverity.clienttest.tsindex e9334881f7..a9816f5cfb 100644--- a/web/src/__tests__/supportCaseSeverity.clienttest.ts+++ b/web/src/__tests__/supportCaseSeverity.clienttest.ts@@ -19,6 +19,7 @@ import {const ENTERPRISE = "cloud:enterprise"; // may raise Sev-1, Sev-2, Sev-3const SELF_HOSTED_ENTERPRISE = "self-hosted:enterprise"; // same as ENTERPRISE+const SELF_HOSTED_GOV = "self-hosted:gov"; // same as ENTERPRISEconst TEAM = "cloud:team"; // may raise Sev-3 onlyconst PRO = "cloud:pro"; // may raise Sev-3 onlyconst LOW_TIER = "cloud:hobby"; // no case severity at all@@ -35,6 +36,9 @@ describe("mapToPylonCaseSeverity", () => {plan: SELF_HOSTED_ENTERPRISE,}),).toBe("Sev-1");+ expect(+ mapToPylonCaseSeverity({ severity: SEVERITY_1, plan: SELF_HOSTED_GOV }),+ ).toBe("Sev-1");});it("downgrades Severity 1 to Sev-3 for non-Enterprise paid plans", () => {diff --git a/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx b/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsxindex 8e93c03b09..5c32850d82 100644--- a/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx+++ b/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx@@ -442,7 +442,9 @@ function ConnectedAppSidebar({});const selfHostedPlan =- plan === "self-hosted:pro" || plan === "self-hosted:enterprise"+ plan === "self-hosted:pro" ||+ plan === "self-hosted:enterprise" ||+ plan === "self-hosted:gov"? plan: "oss";diff --git a/web/src/components/nav/AppSidebar/AppSidebar.tsx b/web/src/components/nav/AppSidebar/AppSidebar.tsxindex 0da1d616b0..388ee81c9d 100644--- a/web/src/components/nav/AppSidebar/AppSidebar.tsx+++ b/web/src/components/nav/AppSidebar/AppSidebar.tsx@@ -98,6 +98,10 @@ const selfHostedPlanLabels = {short: "EE",long: planLabels["self-hosted:enterprise"],},+ "self-hosted:gov": {+ short: "Gov",+ long: planLabels["self-hosted:gov"],+ },} satisfies Record<SelfHostedPlan, { short: string; long: string }>;type UserNavigationItemBase = {diff --git a/web/src/ee/features/billing/server/defaultSpendAlerts.ts b/web/src/ee/features/billing/server/defaultSpendAlerts.tsindex 1a1627f5c3..dd5d26992e 100644--- a/web/src/ee/features/billing/server/defaultSpendAlerts.ts+++ b/web/src/ee/features/billing/server/defaultSpendAlerts.ts@@ -17,7 +17,8 @@ type PlanWithoutSpendAlerts =| "oss"| "cloud:hobby"| "self-hosted:pro"- | "self-hosted:enterprise";+ | "self-hosted:enterprise"+ | "self-hosted:gov";type PlanWithSpendAlerts = Exclude<Plan, PlanWithoutSpendAlerts>;diff --git a/web/src/features/audit-logs/isAuditLogEnabled.ts b/web/src/features/audit-logs/isAuditLogEnabled.tsindex fe3dd10369..3585e8ed8c 100644--- a/web/src/features/audit-logs/isAuditLogEnabled.ts+++ b/web/src/features/audit-logs/isAuditLogEnabled.ts@@ -14,9 +14,9 @@ import {** The self-hosted branch derives from the same entitlement table the read path* uses, rather than hardcoding "enterprise license => audit logs", so the two- * cannot drift apart. Today that means only `langfuse_ee_*` keys- * (`self-hosted:enterprise`) persist records: `self-hosted:pro` and `oss` do- * not. `isEnterpriseLicenseAvailable` in `@langfuse/shared` answers a similar+ * cannot drift apart. Today that means only `langfuse_ee_*` and `lf_gov_*`+ * keys (`self-hosted:enterprise`, `self-hosted:gov`) persist records:+ * `self-hosted:pro` and `oss` do not. `isEnterpriseLicenseAvailable` in `@langfuse/shared` answers a similar* question for code that also runs in the worker, but hardcodes the license* tier instead of consulting the entitlement table.*diff --git a/web/src/features/entitlements/constants/entitlements.ts b/web/src/features/entitlements/constants/entitlements.tsindex 9206934f90..09c6d90f89 100644--- a/web/src/features/entitlements/constants/entitlements.ts+++ b/web/src/features/entitlements/constants/entitlements.ts@@ -17,6 +17,7 @@ const entitlements = ["prompt-protected-labels","admin-api","in-app-agent",+ "self-host-telemetry-opt-out",] as const;export type Entitlement = (typeof entitlements)[number];@@ -32,6 +33,18 @@ const selfHostedAllPlansEntitlements: Entitlement[] = ["in-app-agent",];+// Shared by self-hosted enterprise and government, which adds to it+const selfHostedEnterpriseEntitlements: Entitlement[] = [+ ...selfHostedAllPlansEntitlements,+ "rbac-project-roles",+ "self-host-allowed-organization-creators",+ "self-host-ui-customization",+ "audit-logs",+ "data-retention",+ "prompt-protected-labels",+ "admin-api",+];+// Entitlement Limits: Limits on the number of resources that can be created/used// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Used via typeofconst entitlementLimits = [@@ -158,15 +171,20 @@ export const entitlementAccess: Record<},},"self-hosted:enterprise": {+ entitlements: selfHostedEnterpriseEntitlements,+ entitlementLimits: {+ "annotation-queue-count": false,+ "organization-member-count": false,+ "data-access-days": false,+ "model-based-evaluations-count-evaluators": false,+ "prompt-management-count-prompts": false,+ "monitor-count": false,+ },+ },+ "self-hosted:gov": {entitlements: [- ...selfHostedAllPlansEntitlements,- "rbac-project-roles",- "self-host-allowed-organization-creators",- "self-host-ui-customization",- "audit-logs",- "data-retention",- "prompt-protected-labels",- "admin-api",+ ...selfHostedEnterpriseEntitlements,+ "self-host-telemetry-opt-out",],entitlementLimits: {"annotation-queue-count": false,diff --git a/web/src/features/entitlements/server/getPlan.ts b/web/src/features/entitlements/server/getPlan.tsindex 168b5294ba..56651b82a7 100644--- a/web/src/features/entitlements/server/getPlan.ts+++ b/web/src/features/entitlements/server/getPlan.ts@@ -73,6 +73,9 @@ export function getOrganizationPlanServerSide(export function getSelfHostedInstancePlanServerSide(): Plan | null {const licenseKey = env.LANGFUSE_EE_LICENSE_KEY;if (!licenseKey) return null;+ if (licenseKey.startsWith("lf_gov_")) {+ return "self-hosted:gov";+ }if (licenseKey.startsWith("langfuse_ee_")) {return "self-hosted:enterprise";}diff --git a/web/src/features/public-api/server/RateLimitService.ts b/web/src/features/public-api/server/RateLimitService.tsindex deceea6e19..c8d0c7ec64 100644--- a/web/src/features/public-api/server/RateLimitService.ts+++ b/web/src/features/public-api/server/RateLimitService.ts@@ -296,6 +296,7 @@ const getPlanBasedRateLimitConfig = (case "oss":case "self-hosted:pro":case "self-hosted:enterprise":+ case "self-hosted:gov":return {resource,points: null,diff --git a/web/src/features/support-chat/formConstants.ts b/web/src/features/support-chat/formConstants.tsindex 1bff7ff254..d73360c2c6 100644--- a/web/src/features/support-chat/formConstants.ts+++ b/web/src/features/support-chat/formConstants.ts@@ -53,12 +53,14 @@ export const SEVERITY_3 = SeveritySchema.options[2];/*** Plans that may raise Severity 1 (Sev-1) and Severity 2 (Sev-2) support- * requests — Enterprise only. All other plans (and free/unknown plans) are- * limited to Severity 3. Mirrors the check in `mapToPylonCaseSeverity`.+ * requests — Enterprise and Government only. All other plans (and+ * free/unknown plans) are limited to Severity 3. Mirrors the check in+ * `mapToPylonCaseSeverity`.*/const ENTERPRISE_SUPPORT_PLANS = ["cloud:enterprise","self-hosted:enterprise",+ "self-hosted:gov",] as const;/** Whether the given plan may raise Severity 1/2 support requests. */diff --git a/web/src/features/telemetry/index.ts b/web/src/features/telemetry/index.tsindex 29a46db25b..9ed0a98f47 100644--- a/web/src/features/telemetry/index.ts+++ b/web/src/features/telemetry/index.ts@@ -11,6 +11,10 @@ import {logger,} from "@langfuse/shared/src/server";import { env } from "@/src/env.mjs";+import {+ getSelfHostedInstancePlanServerSide,+ hasEntitlementBasedOnPlan,+} from "@/src/features/entitlements/server";// Interval between jobs in minutesconst JOB_INTERVAL_MINUTES = Prisma.raw("720"); // 12 hours@@ -24,6 +28,14 @@ export async function telemetry() {if (process.env.NODE_ENV !== "production") return;// Do not run in Langfuse cloud, separate telemetry is usedif (env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== undefined) return;+ // Plans with the telemetry opt-out entitlement never send telemetry+ if (+ hasEntitlementBasedOnPlan({+ plan: getSelfHostedInstancePlanServerSide(),+ entitlement: "self-host-telemetry-opt-out",+ })+ )+ return;// Check if telemetry is not disabled, except for EEif (env.TELEMETRY_ENABLED === "false" &&diff --git a/worker/src/__tests__/dataRetentionProcessing.test.ts b/worker/src/__tests__/dataRetentionProcessing.test.tsindex 19676b1fbc..b027710c35 100644--- a/worker/src/__tests__/dataRetentionProcessing.test.ts+++ b/worker/src/__tests__/dataRetentionProcessing.test.ts@@ -1089,19 +1089,25 @@ describe("DataRetentionProcessingJob", () => {expect(trace).toBeDefined();});- it("should delete expired data on a self-hosted enterprise license", async () => {- const traceId = `${randomUUID()}-trace-ee`;- await seedExpiredTrace(traceId);-- await withSelfHostedLicense("langfuse_ee_some-key", async () => {- await handleDataRetentionProcessingJob({- data: { payload: { projectId, retention: 7 } },- } as Job);- });+ it.each([+ ["enterprise", "langfuse_ee_some-key"],+ ["government", "lf_gov_some-key"],+ ])(+ "should delete expired data on a self-hosted %s license",+ async (label, licenseKey) => {+ const traceId = `${randomUUID()}-trace-${label}`;+ await seedExpiredTrace(traceId);++ await withSelfHostedLicense(licenseKey, async () => {+ await handleDataRetentionProcessingJob({+ data: { payload: { projectId, retention: 7 } },+ } as Job);+ });- // Pins that the guard is the license and not an unrelated skip.- const trace = await getTraceById({ traceId, projectId });- expect(trace).toBeUndefined();- });+ // Pins that the guard is the license and not an unrelated skip.+ const trace = await getTraceById({ traceId, projectId });+ expect(trace).toBeUndefined();+ },+ );});});