Files
supabase/apps/studio/lib/ai/braintrust-logger.test.ts
Matt Rossman 36ae9beb0c chore(ai): remove DPA signer killswitch for assistant tracing (#45134)
Removes the temporary killswitch added when Braintrust was onboarded as
a subprocessor, to satisfy the 30-day DPA notice obligation. The window
has elapsed and legal has cleared removal.

Drops the `orgIsDpaSigned` check from `isTracingAllowed`, removes the
extra `/platform/organizations/{slug}/documents/dpa-signed` network hop
from `getOrgAIDetails`, and cleans up all call sites and tests.

Closes AI-596

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Refactor**
* Simplified AI tracing eligibility logic by removing DPA signing status
checks. Tracing authorization decisions now depend solely on region,
HIPAA addon status, and project sensitivity settings.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-04-27 13:53:24 -04:00

73 lines
2.4 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { isTracingAllowed } from './braintrust-logger'
const baseAllowed = {
orgHasHipaaAddon: false,
projectIsSensitive: false,
projectRegion: 'us-east-1',
}
describe('isTracingAllowed', () => {
it('allows tracing when all flags are explicitly off/non-EU', () => {
expect(isTracingAllowed(baseAllowed)).toBe(true)
})
it('disallows tracing when HIPAA addon is active and project is sensitive', () => {
expect(
isTracingAllowed({ ...baseAllowed, orgHasHipaaAddon: true, projectIsSensitive: true })
).toBe(false)
})
it('allows tracing when HIPAA addon is active but project is not sensitive', () => {
expect(
isTracingAllowed({ ...baseAllowed, orgHasHipaaAddon: true, projectIsSensitive: false })
).toBe(true)
})
it('allows tracing when project is sensitive but no HIPAA addon', () => {
expect(
isTracingAllowed({ ...baseAllowed, orgHasHipaaAddon: false, projectIsSensitive: true })
).toBe(true)
})
it('disallows tracing for EU regions', () => {
expect(isTracingAllowed({ ...baseAllowed, projectRegion: 'eu-west-1' })).toBe(false)
expect(isTracingAllowed({ ...baseAllowed, projectRegion: 'eu-central-1' })).toBe(false)
})
it('allows tracing for non-EU regions', () => {
expect(isTracingAllowed({ ...baseAllowed, projectRegion: 'ap-southeast-1' })).toBe(true)
})
it('allows tracing when HIPAA addon is false and is_sensitive is null (DB default)', () => {
expect(isTracingAllowed({ ...baseAllowed, projectIsSensitive: null })).toBe(true)
})
it('disallows tracing when HIPAA addon is unknown and is_sensitive is null', () => {
expect(
isTracingAllowed({ ...baseAllowed, orgHasHipaaAddon: undefined, projectIsSensitive: null })
).toBe(false)
})
it('disallows tracing when flags are undefined (unknown = restricted)', () => {
expect(
isTracingAllowed({
orgHasHipaaAddon: undefined,
projectIsSensitive: undefined,
projectRegion: undefined,
})
).toBe(false)
expect(isTracingAllowed({ ...baseAllowed, projectRegion: undefined })).toBe(false)
expect(isTracingAllowed({ ...baseAllowed, orgHasHipaaAddon: undefined })).toBe(false)
// projectIsSensitive unknown only matters when orgHasHipaaAddon is also unknown
expect(
isTracingAllowed({
...baseAllowed,
orgHasHipaaAddon: undefined,
projectIsSensitive: undefined,
})
).toBe(false)
})
})