Files
zeekay 10e6fec4c0 debrand: the brand token is INSIGHTS_, and a wrong one stops the container
The rule table mapped HOG_ -> FN_ ahead of any POSTHOG rule, so POSTHOG_FOO
split into POST + HOG_ and came out POSTFN_FOO. Nothing sets that. The live
pods set INSIGHTS_SKIP_MIGRATION_CHECKS, which bin/migrate-check reads on the
container entrypoint, so the misspelling does not degrade a feature -- it runs
migrate --check against a database whose history this tree does not share and
the container never starts.

Both replacements are measured against the shipped tree rather than chosen:
every HOG_ name with a counterpart there is spelled INSIGHTS_ (HOG_QL ->
INSIGHTS_QL, HOG_FUNCTION_TEMPLATES -> INSIGHTS_FUNCTION_TEMPLATES, 12 of 12
determinate cases), and FN_ appears in it nowhere. Upstream carries 95 HOG_
tokens and zero FN_ ones, so repairing FN_ back out is exactly the inverse of
the bad rule and cannot collide with an upstream name.

The rule is fixed for the next convergence, and the tree it already produced is
repaired in the same commit -- the codemod is idempotent against its own output,
so it cannot undo this itself.
2026-08-01 17:42:28 -07:00

89 lines
3.1 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { SessionManager } from '@/lib/SessionManager'
import { getToolsFromContext } from '@/tools'
import type { Context } from '@/tools/types'
const createMockContext = (): Context => ({
api: {} as any,
cache: {} as any,
env: {
MCP_APPS_BASE_URL: undefined,
INSIGHTS_ANALYTICS_API_KEY: undefined,
INSIGHTS_ANALYTICS_HOST: undefined,
INSIGHTS_API_BASE_URL: undefined,
INSIGHTS_PUBLIC_URL: undefined,
INSIGHTS_MCP_APPS_ANALYTICS_BASE_URL: undefined,
INSIGHTS_UI_APPS_TOKEN: undefined,
},
stateManager: {
getApiKey: async () => ({ scopes: ['*'] }),
getAiConsentGiven: async () => undefined,
} as any,
sessionManager: new SessionManager({} as any),
getDistinctId: async () => 'test-distinct-id',
trackEvent: async () => {},
})
describe('Feature Routing Integration', () => {
const integrationTests = [
{
features: undefined,
description: 'all tools when no features specified',
expectedTools: [
'feature-flag-get-definition',
'dashboard-create',
'insights-list',
'organizations-list',
'query-error-tracking-issues-list',
],
},
{
features: ['dashboards'],
description: 'only dashboard tools',
expectedTools: [
'dashboard-create',
'dashboards-get-all',
'dashboard-get',
'dashboard-update',
'dashboard-delete',
'dashboard-reorder-tiles',
],
},
{
features: ['flags', 'workspace'],
description: 'tools from multiple features',
expectedTools: [
'feature-flag-get-definition',
'create-feature-flag',
'feature-flag-get-all',
'switch-organization',
'projects-get',
],
},
{
// Organization discovery must ship with the workspace navigation tools —
// otherwise an agent can switch orgs but has no way to enumerate them,
// stranding any project that lives in a different organization.
features: ['workspace'],
description: 'workspace feature includes organization discovery',
expectedTools: ['organizations-get', 'switch-organization', 'projects-get', 'switch-project'],
},
{
features: ['invalid', 'flags', 'unknown'],
description: 'valid tools ignoring invalid features',
expectedTools: ['feature-flag-get-definition', 'create-feature-flag'],
},
]
it.each(integrationTests)('should return $description', async ({ features, expectedTools }) => {
const context = createMockContext()
const tools = await getToolsFromContext(context, { features })
const toolNames = tools.map((t) => t.name)
for (const tool of expectedTools) {
expect(toolNames).toContain(tool)
}
})
})