Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat: remove business-knowledge-github-repos ff (#123927)

Alex V5324c6a7d4c1
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 81bc851bbcbf..b8e7a13c1b03 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -271,7 +271,6 @@ export const FEATURE_FLAGS = {
BILLING_ALERTS: 'billing-alerts', // owner: #team-billing, gates the Billing > Alerts tab
BILLING_REAL_TIME_USAGE: 'billing-real-time-usage', // owner: #team-billing, gates the Real-time usage scene
BROADCASTS_AI_FIRST_NEW: 'broadcasts-ai-first-new', // owner: @dmarchuk #team-workflows
- BUSINESS_KNOWLEDGE_GITHUB_REPOS: 'business-knowledge-github-repos', // owner: @veryayskiy #team-conversations
CANVAS_COMMENTS: 'posthog-desktop-canvas-comments', // owner: @k11kirky, shows canvas comments and selection comments on web canvases, shared with PostHog Desktop
CDP_DWH_TABLE_SOURCE: 'cdp-dwh-table-source', // owner: #team-workflows-cdp
CDP_DWH_VIEW_SOURCE: 'cdp-dwh-view-source', // owner: #team-workflows-cdp
diff --git a/frontend/src/scenes/settings/SettingsMap.tsx b/frontend/src/scenes/settings/SettingsMap.tsx
index 7609080b7f14..d077056147b0 100644
--- a/frontend/src/scenes/settings/SettingsMap.tsx
+++ b/frontend/src/scenes/settings/SettingsMap.tsx
@@ -1693,7 +1693,6 @@ export const SETTINGS_MAP: SettingSection[] = [
description:
'Let business knowledge read these repositories when answering a question. It searches file names and the README, then reads a file. It does not index the code.',
component: <GithubReposSetting />,
- flag: 'BUSINESS_KNOWLEDGE_GITHUB_REPOS',
keywords: ['business', 'knowledge', 'github', 'repository', 'code'],
},
],
diff --git a/products/business_knowledge/backend/api/libraries.py b/products/business_knowledge/backend/api/libraries.py
index 12c97f79c318..ab838188ba2b 100644
--- a/products/business_knowledge/backend/api/libraries.py
+++ b/products/business_knowledge/backend/api/libraries.py
@@ -1,5 +1,5 @@
from functools import cached_property
-from typing import Any, cast
+from typing import Any
from uuid import UUID
from django.core.exceptions import ValidationError as DjangoValidationError
@@ -14,13 +14,12 @@ from rest_framework.viewsets import ViewSet
from posthog.api.mixins import ValidatedRequest, validated_request
from posthog.api.routing import TeamAndOrgViewSetMixin
-from posthog.models.user import User
from posthog.permissions import APIScopePermission, PostHogFeatureFlagPermission
from posthog.rate_limit import BurstRateThrottle, SustainedRateThrottle
from products.access_control.backend.facade.user_access_control import UserAccessControl
-from ..github_repos import has_github_repos_feature_flag, selected_repositories
+from ..github_repos import selected_repositories
from ..libraries import (
LibraryNotFound,
LibraryRejected,
@@ -123,10 +122,6 @@ class KnowledgeLibraryViewSet(TeamAndOrgViewSetMixin, ViewSet):
def partial_update(self, request: ValidatedRequest, pk: str, **kwargs: Any) -> Response:
library_id = _parse_library_id(pk)
data = request.validated_data
- if "repos" in data:
- user = cast(User, request.user)
- if not has_github_repos_feature_flag(self.team, str(user.distinct_id)):
- raise exceptions.PermissionDenied(detail="GitHub repositories are not available for this project.")
allowlist = self._allowlist() if "repos" in data else set()
try:
with transaction.atomic():
diff --git a/products/business_knowledge/backend/api/repositories.py b/products/business_knowledge/backend/api/repositories.py
index 52333247f40f..e14de15c5cbe 100644
--- a/products/business_knowledge/backend/api/repositories.py
+++ b/products/business_knowledge/backend/api/repositories.py
@@ -3,7 +3,7 @@ from typing import Any, cast
from drf_spectacular.utils import OpenApiResponse, extend_schema
from rest_framework import exceptions
from rest_framework.decorators import action
-from rest_framework.permissions import BasePermission, IsAuthenticated
+from rest_framework.permissions import IsAuthenticated
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.viewsets import ViewSet
@@ -15,7 +15,6 @@ from posthog.permissions import APIScopePermission, PostHogFeatureFlagPermission
from posthog.rate_limit import BurstRateThrottle, SustainedRateThrottle
from products.business_knowledge.backend.github_repos import (
- GITHUB_REPOS_FLAG,
GithubReposError,
RepositoryFile,
RepositorySearchOutcome,
@@ -42,28 +41,12 @@ _READ_ACTIONS = frozenset({"status", "search", "read_file"})
_WRITE_ACTIONS = frozenset({"connect", "disconnect", "select"})
-class BusinessKnowledgeGithubReposPermission(BasePermission):
- """Both the product flag and the repository flag. The stock checker returns on the first hit."""
-
- def has_permission(self, request: Request, view: Any) -> bool:
- checker = PostHogFeatureFlagPermission()
- for flag in ("product-business-knowledge", GITHUB_REPOS_FLAG):
- view.posthog_feature_flag = flag
- if not checker.has_permission(request, view):
- self.message = checker.message
- code = getattr(checker, "code", None)
- if code is not None:
- self.code = code
- return False
- return True
-
-
class BusinessKnowledgeRepositoriesViewSet(TeamAndOrgViewSetMixin, ViewSet):
scope_object = "business_knowledge"
# Plain ViewSet: object permissions never run, so resource-level access is checked here.
requires_resource_level_access = True
- permission_classes = [IsAuthenticated, APIScopePermission, BusinessKnowledgeGithubReposPermission]
- posthog_feature_flag = GITHUB_REPOS_FLAG
+ permission_classes = [IsAuthenticated, APIScopePermission, PostHogFeatureFlagPermission]
+ posthog_feature_flag = "product-business-knowledge"
throttle_classes = [BurstRateThrottle, SustainedRateThrottle]
pagination_class = None
diff --git a/products/business_knowledge/backend/github_repos.py b/products/business_knowledge/backend/github_repos.py
index aec31a3350c1..650835813bb2 100644
--- a/products/business_knowledge/backend/github_repos.py
+++ b/products/business_knowledge/backend/github_repos.py
@@ -14,7 +14,6 @@ from typing import Any
from urllib.parse import quote
from uuid import UUID
-from django.conf import settings
from django.core.cache import cache
from django.db import connection, models, transaction
from django.utils import timezone
@@ -36,14 +35,12 @@ from posthog.models.integration_repository_cache import (
)
from posthog.models.team.team import Team
from posthog.models.user import User
-from posthog.permissions import posthog_feature_flag_enabled
from .learning_settings import get_environment_business_knowledge_config
from .models import TeamBusinessKnowledgeConfig
logger = structlog.get_logger(__name__)
-GITHUB_REPOS_FLAG = "business-knowledge-github-repos"
MAX_GITHUB_REPOS = 100
MAX_SEARCH_HITS = 20
MAX_README_HITS = 5
@@ -122,21 +119,7 @@ class RepositoryFile:
truncated: bool
-def has_github_repos_feature_flag(team: Team, distinct_id: str) -> bool:
- """Same person, organization and project context as the API permission, so the prompt and the tools agree.
-
- On in DEBUG so a local playground can call the tools.
- """
- if settings.DEBUG:
- return True
- return posthog_feature_flag_enabled(
- GITHUB_REPOS_FLAG, distinct_id, organization_id=team.organization_id, team_id=team.id
- )
-
-
-def repository_tools_enabled(team: Team, distinct_id: str) -> bool:
- if not has_github_repos_feature_flag(team, distinct_id):
- return False
+def repository_tools_enabled(team: Team) -> bool:
integration_id, repos = selected_repositories(team)
return integration_id is not None and bool(repos)
diff --git a/products/business_knowledge/backend/sandbox.py b/products/business_knowledge/backend/sandbox.py
index 4703cd1040cc..6be525a80000 100644
--- a/products/business_knowledge/backend/sandbox.py
+++ b/products/business_knowledge/backend/sandbox.py
@@ -13,7 +13,6 @@ from pydantic import BaseModel, Field, ValidationError
from posthog.dataclasses import frozen
from posthog.models.team.team import Team
-from posthog.models.user import User
from products.tasks.backend.facade import api as tasks_facade
from products.tasks.backend.facade.contracts import CreatedTaskDTO, TaskRunDTO
@@ -233,11 +232,6 @@ def open_sandbox_task_ids(*, team_id: int, user_id: int) -> set[UUID]:
)
-def _distinct_id_for(user_id: int) -> str:
- distinct_id = User.objects.filter(pk=user_id).values_list("distinct_id", flat=True).first()
- return str(distinct_id)
-
-
def start_sandbox_run(
*,
team: Team,
@@ -271,9 +265,7 @@ def start_sandbox_run(
created = tasks_facade.create_and_run_task(
team=team,
title=_title_for(question),
- description=build_sandbox_prompt(
- question, always_on, repo_tools=repository_tools_enabled(team, _distinct_id_for(user_id))
- ),
+ description=build_sandbox_prompt(question, always_on, repo_tools=repository_tools_enabled(team)),
origin_product=origin,
user_id=user_id,
repository=None,
diff --git a/products/business_knowledge/backend/tests/test_api.py b/products/business_knowledge/backend/tests/test_api.py
index f7fc7d18afa7..1ae65221046b 100644
--- a/products/business_knowledge/backend/tests/test_api.py
+++ b/products/business_knowledge/backend/tests/test_api.py
@@ -446,8 +446,7 @@ class TestKnowledgeSourceAPI(APIBaseTest):
assert retrieve.status_code == status.HTTP_404_NOT_FOUND
assert search.status_code == status.HTTP_404_NOT_FOUND
- @patch("products.business_knowledge.backend.api.libraries.has_github_repos_feature_flag", return_value=True)
- def test_parent_repo_replace_keeps_a_child_only_link(self, _ff, _repos_flag) -> None:
+ def test_parent_repo_replace_keeps_a_child_only_link(self, _ff) -> None:
from posthog.models.integration import Integration
from posthog.models.scoping import team_scope
from posthog.models.team import Team
diff --git a/products/business_knowledge/frontend/scenes/sources/LibraryDialog.tsx b/products/business_knowledge/frontend/scenes/sources/LibraryDialog.tsx
index 5766f0426c75..4b3f509f1c04 100644
--- a/products/business_knowledge/frontend/scenes/sources/LibraryDialog.tsx
+++ b/products/business_knowledge/frontend/scenes/sources/LibraryDialog.tsx
@@ -2,14 +2,11 @@ import { useActions, useValues } from 'kea'
import { LemonModal } from '@posthog/lemon-ui'
-import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
-
import { businessKnowledgeLogic } from './businessKnowledgeLogic'
import { LibraryNameForm } from './LibraryNameForm'
import { LibraryRepoForm } from './LibraryRepoForm'
export function LibraryDialog(): JSX.Element | null {
- const githubEnabled = useFeatureFlag('BUSINESS_KNOWLEDGE_GITHUB_REPOS')
const { libraryDialog, libraryScope, libraries, savingLibrary } = useValues(businessKnowledgeLogic)
const { closeLibraryDialog, createLibrary, renameLibrary, saveLibraryRepos } = useActions(businessKnowledgeLogic)
const active = libraries.find((library) => library.id === libraryScope)
@@ -44,7 +41,7 @@ export function LibraryDialog(): JSX.Element | null {
width={480}
footer={null}
>
- {libraryDialog === 'repos' && githubEnabled && active ? (
+ {libraryDialog === 'repos' && active ? (
<LibraryRepoForm
initialRepos={active.repos}
saving={savingLibrary}
diff --git a/products/business_knowledge/frontend/scenes/sources/LibrarySummary.tsx b/products/business_knowledge/frontend/scenes/sources/LibrarySummary.tsx
index 5d72871d6bca..04a1cf1bd218 100644
--- a/products/business_knowledge/frontend/scenes/sources/LibrarySummary.tsx
+++ b/products/business_knowledge/frontend/scenes/sources/LibrarySummary.tsx
@@ -4,14 +4,12 @@ import { IconDocument, IconFolder, IconFolderOpen, IconGithub, IconPencil, IconT
import { LemonButton, LemonDialog, LemonTag } from '@posthog/lemon-ui'
import { CopyToClipboardInline } from 'lib/components/CopyToClipboard'
-import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { pluralize } from 'lib/utils/strings'
import { LIBRARY_SCOPE_ALL, LIBRARY_SCOPE_UNFILED, businessKnowledgeLogic } from './businessKnowledgeLogic'
import { LibrarySummaryPanel } from './LibrarySummaryPanel'
export function LibrarySummary(): JSX.Element | null {
- const githubEnabled = useFeatureFlag('BUSINESS_KNOWLEDGE_GITHUB_REPOS')
const { libraryScope, selectedLibrary, libraries, librariesLoading, savingLibrary } =
useValues(businessKnowledgeLogic)
const { openLibraryDialog, deleteSelectedLibrary } = useActions(businessKnowledgeLogic)
@@ -44,10 +42,10 @@ export function LibrarySummary(): JSX.Element | null {
return null
}
- const counts = [pluralize(selectedLibrary.source_count, 'source')]
- if (githubEnabled) {
- counts.push(pluralize(selectedLibrary.repos.length, 'repository', 'repositories'))
- }
+ const counts = [
+ pluralize(selectedLibrary.source_count, 'source'),
+ pluralize(selectedLibrary.repos.length, 'repository', 'repositories'),
+ ]
return (
<LibrarySummaryPanel
@@ -65,17 +63,15 @@ export function LibrarySummary(): JSX.Element | null {
>
Rename
</LemonButton>
- {githubEnabled && (
- <LemonButton
- size="small"
- type="secondary"
- icon={<IconGithub />}
- onClick={() => openLibraryDialog('repos')}
- data-attr="business-knowledge-library-repos"
- >
- Repositories
- </LemonButton>
- )}
+ <LemonButton
+ size="small"
+ type="secondary"
+ icon={<IconGithub />}
+ onClick={() => openLibraryDialog('repos')}
+ data-attr="business-knowledge-library-repos"
+ >
+ Repositories
+ </LemonButton>
<LemonButton
size="small"
type="secondary"
@@ -105,7 +101,7 @@ export function LibrarySummary(): JSX.Element | null {
<span translate="no">{counts.join(' · ')}</span>
{selectedLibrary.is_default && <span>. Sources learned from support tickets join this library.</span>}
</p>
- {githubEnabled && selectedLibrary.repos.length > 0 && (
+ {selectedLibrary.repos.length > 0 && (
<div className="flex flex-wrap gap-1">
{selectedLibrary.repos.map((repo) => (
<LemonTag key={repo} icon={<IconGithub />}>
diff --git a/products/business_knowledge/mcp/tools.yaml b/products/business_knowledge/mcp/tools.yaml
index 7f96d1651361..337321f82786 100644
--- a/products/business_knowledge/mcp/tools.yaml
+++ b/products/business_knowledge/mcp/tools.yaml
@@ -126,7 +126,7 @@ tools:
business-knowledge-repositories-search. Returns the file text and a permalink. Does not search file
contents. Pass library_id to read a repository in that library, using the same id as document search and
repository search. Omit library_id to read any selected repository.
- feature_flag: business-knowledge-github-repos
+ feature_flag: product-business-knowledge
business-knowledge-repositories-search:
operation: business_knowledge_repositories_search
enabled: true
@@ -144,7 +144,7 @@ tools:
holds a handbook or docs, search that repository for those words and read the file. Does not search inside
file contents and does not call GitHub code search. Pass library_id to search repositories in that library,
using the same id as document search and file read. Omit library_id to search every selected repository.
- feature_flag: business-knowledge-github-repos
+ feature_flag: product-business-knowledge
business-knowledge-sources-list:
operation: business_knowledge_sources_list
enabled: true
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 94d0efe8e4cf..a7952e2a7ddd 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -2226,7 +2226,7 @@
"openWorldHint": true,
"readOnlyHint": true
},
- "feature_flag": "business-knowledge-github-repos"
+ "feature_flag": "product-business-knowledge"
},
"business-knowledge-repositories-search": {
"description": "Search file paths and README text in the GitHub repositories selected for business knowledge. Call this when business knowledge document search returns nothing. Pass file names or identifiers, not a full sentence. Each repository in the response includes its GitHub description. When a description says the repository holds a handbook or docs, search that repository for those words and read the file. Does not search inside file contents and does not call GitHub code search. Pass library_id to search repositories in that library, using the same id as document search and file read. Omit library_id to search every selected repository.",
@@ -2242,7 +2242,7 @@
"openWorldHint": true,
"readOnlyHint": true
},
- "feature_flag": "business-knowledge-github-repos"
+ "feature_flag": "product-business-knowledge"
},
"business-knowledge-sources-list": {
"description": "List all business knowledge sources in the project, with document/chunk counts, processing status, and refresh metadata.",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 0abd96fab2a8..0cca6a023cf9 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -2241,7 +2241,7 @@
"openWorldHint": true,
"readOnlyHint": true
},
- "feature_flag": "business-knowledge-github-repos"
+ "feature_flag": "product-business-knowledge"
},
"business-knowledge-repositories-search": {
"description": "Search file paths and README text in the GitHub repositories selected for business knowledge. Call this when business knowledge document search returns nothing. Pass file names or identifiers, not a full sentence. Each repository in the response includes its GitHub description. When a description says the repository holds a handbook or docs, search that repository for those words and read the file. Does not search inside file contents and does not call GitHub code search. Pass library_id to search repositories in that library, using the same id as document search and file read. Omit library_id to search every selected repository.",
@@ -2257,7 +2257,7 @@
"openWorldHint": true,
"readOnlyHint": true
},
- "feature_flag": "business-knowledge-github-repos"
+ "feature_flag": "product-business-knowledge"
},
"business-knowledge-sources-list": {
"description": "List all business knowledge sources in the project, with document/chunk counts, processing status, and refresh metadata.",
diff --git a/services/mcp/tests/unit/tool-filtering.test.ts b/services/mcp/tests/unit/tool-filtering.test.ts
index 0d4c976dc00f..49db409b4b52 100644
--- a/services/mcp/tests/unit/tool-filtering.test.ts
+++ b/services/mcp/tests/unit/tool-filtering.test.ts
@@ -1096,7 +1096,6 @@ describe('Tool Filtering - Feature Flags', () => {
const allFlags = getRequiredFeatureFlags()
const branchFlags = [
'scout-trials',
- 'business-knowledge-github-repos',
'signals-report-checks-replace',
'inbox-report-actions-mcp',
'signals-reviewer-exclusions-mcp',